Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions accounts/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function execute()
$this->obj_form_ar->formname = "ar_invoice_quickselect";
$this->obj_form_ar->language = $_SESSION["user"]["lang"];

$structure = form_helper_prepare_dropdownfromdb("id", "SELECT id, code_invoice as label FROM account_ar WHERE amount_total!=amount_paid ORDER BY code_invoice");
$structure = form_helper_prepare_dropdownfromdb("id", "SELECT id, code_invoice as label FROM account_ar WHERE amount_total!=amount_paid AND cancelled=0 ORDER BY code_invoice");

if (count($structure["values"]) == 0)
{
Expand Down Expand Up @@ -105,7 +105,7 @@ function execute()

// unpaid
$sql_obj = New sql_query;
$sql_obj->string = "SELECT SUM(amount_total) as amount_total, SUM(amount_paid) as amount_paid FROM account_ar WHERE amount_total!=amount_paid";
$sql_obj->string = "SELECT SUM(amount_total) as amount_total, SUM(amount_paid) as amount_paid FROM account_ar WHERE amount_total!=amount_paid AND cancelled=0";
$sql_obj->execute();
$sql_obj->fetch_array();

Expand All @@ -114,7 +114,7 @@ function execute()

// overdue
$sql_obj = New sql_query;
$sql_obj->string = "SELECT SUM(amount_total) as amount_total, SUM(amount_paid) as amount_paid FROM account_ar WHERE amount_total!=amount_paid AND date_due < '". date("Y-m-d") ."'";
$sql_obj->string = "SELECT SUM(amount_total) as amount_total, SUM(amount_paid) as amount_paid FROM account_ar WHERE cancelled=0 AND amount_total!=amount_paid AND date_due < '". date("Y-m-d") ."'";
$sql_obj->execute();
$sql_obj->fetch_array();

Expand Down
183 changes: 183 additions & 0 deletions accounts/ap/ap-credits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?php
/*
accounts/ap/ap-credits.php

access: accounts_ap_view

List all the credit notes in the system and allow users to view and search them.
*/


class page_output
{
var $obj_table;


function check_permissions()
{
return user_permissions_get('accounts_ap_view');
}

function check_requirements()
{
// nothing todo
return 1;
}


function execute()
{
// establish a new table object
$this->obj_table = New table;

$this->obj_table->language = $_SESSION["user"]["lang"];
$this->obj_table->tablename = "account_ap_credit_credit";

// define all the columns and structure
$this->obj_table->add_column("standard", "code_credit", "account_ap_credit.code_credit");
$this->obj_table->add_column("standard", "code_ordernumber", "account_ap_credit.code_ordernumber");
$this->obj_table->add_column("standard", "code_ponumber", "account_ap_credit.code_ponumber");
$this->obj_table->add_column("standard", "name_vendor", "vendors.name_vendor");
$this->obj_table->add_column("standard", "name_staff", "CONCAT_WS(' -- ', staff.staff_code, staff.name_staff)");
$this->obj_table->add_column("date", "date_trans", "account_ap_credit.date_trans");
$this->obj_table->add_column("price", "amount_tax", "account_ap_credit.amount_tax");
$this->obj_table->add_column("price", "amount", "account_ap_credit.amount");
$this->obj_table->add_column("price", "amount_total", "account_ap_credit.amount_total");

// totals
$this->obj_table->total_columns = array("amount_tax", "amount", "amount_total");


// defaults
$this->obj_table->columns = array("code_credit", "name_vendor", "date_trans", "amount_total");
$this->obj_table->columns_order = array("code_credit");
$this->obj_table->columns_order_options = array("code_credit", "code_ordernumber", "code_ponumber", "name_vendor", "name_staff", "date_trans", "date_due", "sent");

// define SQL structure
$this->obj_table->sql_obj->prepare_sql_settable("account_ap_credit");
$this->obj_table->sql_obj->prepare_sql_addfield("id", "account_ap_credit.id");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN vendors ON vendors.id = account_ap_credit.vendorid");
$this->obj_table->sql_obj->prepare_sql_addjoin("LEFT JOIN staff ON staff.id = account_ap_credit.employeeid");


// acceptable filter options
$structure = NULL;
$structure["fieldname"] = "date_start";
$structure["type"] = "date";
$structure["sql"] = "date_trans >= 'value'";
$this->obj_table->add_filter($structure);

$structure = NULL;
$structure["fieldname"] = "date_end";
$structure["type"] = "date";
$structure["sql"] = "date_trans <= 'value'";
$this->obj_table->add_filter($structure);

$structure = form_helper_prepare_dropdownfromdb("employeeid", "SELECT id, staff_code as label, name_staff as label1 FROM staff ORDER BY name_staff");
$structure["sql"] = "account_ap_credit.employeeid='value'";
$structure["options"]["search_filter"] = "enabled";
$this->obj_table->add_filter($structure);

$structure = form_helper_prepare_dropdownfromdb("vendorid", "SELECT id, code_vendor as label, name_vendor as label1 FROM vendors ORDER BY name_vendor");
$structure["sql"] = "account_ap_credit.vendorid='value'";
$structure["options"]["search_filter"] = "enabled";
$this->obj_table->add_filter($structure);

$structure = NULL;
$structure["fieldname"] = "credit_notes_search";
$structure["type"] = "input";
$structure["sql"] = "notes LIKE '%value%'";
$this->obj_table->add_filter($structure);

$structure = NULL;
$structure["fieldname"] = "hide_closed";
$structure["type"] = "checkbox";
$structure["options"]["label"] = "Hide Locked Credits";
$structure["defaultvalue"] = "enabled";
$structure["sql"] = "account_ap_credit.locked='0'";
$this->obj_table->add_filter($structure);

// load options
$this->obj_table->load_options_form();


// fetch all the chart information
$this->obj_table->generate_sql();
$this->obj_table->load_data_sql();

}


function render_html()
{

// heading
print "<h3>LIST OF ACCOUNTS PAYABLES CREDIT NOTES</h3>";
print "<p>This page only displays credit notes which have yet to be completed, unless the \"Hide Paid Credits\" check box is unchecked.</p>";

// display options form
$this->obj_table->render_options_form();

// display table
if (!count($this->obj_table->columns))
{
format_msgbox("important", "<p>Please select some valid options to display.</p>");
}
elseif (!$this->obj_table->data_num_rows)
{
$sql_obj = New sql_query;
$sql_obj->string = "SELECT id FROM account_ap_credit LIMIT 1";
$sql_obj->execute();

if ($sql_obj->num_rows())
{
format_msgbox("important", "<p>Your current filter options do not match to any credit notes.</p>");
}
else
{
format_msgbox("info", "<p>You currently have no AP credit notes in your database.</p>");
}
}
else
{
// details link
$structure = NULL;
$structure["id"]["column"] = "id";
$this->obj_table->add_link("details", "accounts/ap/credit-view.php", $structure);


// items link
$structure = NULL;
$structure["id"]["column"] = "id";
$this->obj_table->add_link("items", "accounts/ap/credit-items.php", $structure);

// payments link
$structure = NULL;
$structure["id"]["column"] = "id";
$this->obj_table->add_link("payments", "accounts/ap/credit-payments.php", $structure);



// display the table
$this->obj_table->render_table_html();

// display CSV/PDF download link
print "<p align=\"right\"><a class=\"button_export\" href=\"index-export.php?mode=csv&page=accounts/ap/ap.php\">Export as CSV</a></p>";
print "<p align=\"right\"><a class=\"button_export\" href=\"index-export.php?mode=pdf&page=accounts/ap/ap.php\">Export as PDF</a></p>";
}
}


function render_csv()
{
$this->obj_table->render_table_csv();
}

function render_pdf()
{
$this->obj_table->render_table_pdf();
}

}

?>
15 changes: 10 additions & 5 deletions accounts/ap/ap.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ function execute()
$this->obj_table->add_column("price", "amount", "account_ap.amount");
$this->obj_table->add_column("price", "amount_total", "account_ap.amount_total");
$this->obj_table->add_column("price", "amount_paid", "account_ap.amount_paid");
$this->obj_table->add_column("bool_tick", "closed", "(account_ap.amount_paid=account_ap.amount_total AND account_ap.amount_total>0)");

// totals
$this->obj_table->total_columns = array("amount_tax", "amount", "amount_total", "amount_paid");


// defaults
$this->obj_table->columns = array("name_vendor", "code_invoice", "date_trans", "amount_total", "amount_paid");
$this->obj_table->columns = array("name_vendor", "code_invoice", "date_trans", "amount_total", "amount_paid","closed");
$this->obj_table->columns_order = array("code_invoice");
$this->obj_table->columns_order_options = array("name_vendor", "code_invoice", "code_ordernumber", "code_ponumber", "name_staff", "date_trans", "date_due", "sent");

Expand Down Expand Up @@ -93,13 +94,11 @@ function execute()
$structure = NULL;
$structure["fieldname"] = "hide_closed";
$structure["type"] = "checkbox";
$structure["options"]["label"] = "Hide Closed Invoices";
$structure["options"]["label"] = "Hide Completed Invoices";
$structure["defaultvalue"] = "enabled";
$structure["sql"] = "account_ap.amount_paid!=account_ap.amount_total";
$structure["sql"] = "((account_ap.amount_paid<>account_ap.amount_total AND account_ap.amount_total>0) OR (account_ap.amount_total=0))";
$this->obj_table->add_filter($structure);



// load options
$this->obj_table->load_options_form();

Expand Down Expand Up @@ -158,6 +157,12 @@ function render_html()
$structure["id"]["column"] = "id";
$this->obj_table->add_link("payments", "accounts/ap/invoice-payments.php", $structure);

// journal link
$structure = NULL;
$structure["id"]["column"] = "id";
$this->obj_table->add_link("journal", "accounts/ap/journal.php", $structure);



// display the table
$this->obj_table->render_table_html();
Expand Down
65 changes: 65 additions & 0 deletions accounts/ap/credit-add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/*
accounts/ap/credit-add.php

access: accounts_ap_write

Provides the UI for entering new credit notes into ABS.
*/

// custom includes
require("include/accounts/inc_credits_forms.php");



class page_output
{
var $id;
var $obj_menu_nav;
var $obj_form_credit;

function __construct()
{
$this->requires["javascript"][] = "include/vendors/javascript/populate_invoices_dropdown.js";
}

function check_permissions()
{
return user_permissions_get("accounts_ap_write");
}


function check_requirements()
{
// nothing to check
return 1;
}


function execute()
{

$vendor_id = @security_script_input('/^[0-9]*$/', $_GET["vendorid"]);

$this->obj_form_credit = New credit_form_details;
$this->obj_form_credit->type = "ap_credit";
$this->obj_form_credit->credit_id = 0;
$this->obj_form_credit->vendor_id = $vendor_id;
$this->obj_form_credit->processpage = "accounts/ap/credit-edit-process.php";

$this->obj_form_credit->execute();
}

function render_html()
{
// heading
print "<h3>ADD CREDIT NOTE</h3><br>";
print "<p>This page provides features to allow you to create a new credit note for a vendor's invoice.</p>";

// display form
$this->obj_form_credit->render_html();
}

}

?>
39 changes: 39 additions & 0 deletions accounts/ap/credit-delete-process.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/*
accounts/ap/credit-delete-process.php

access: accounts_ap_write

Deletes credits from the database
*/

// includes
require("../../include/config.php");
require("../../include/amberphplib/main.php");

// custom includes
require("../../include/accounts/inc_credits_process.php");



if (user_permissions_get('accounts_ap_write'))
{
/*
Let the credits functions do all the work for us
*/

$returnpage_error = "accounts/ap/credit-delete.php";
$returnpage_success = "accounts/ap/ap-credits.php";

credit_form_delete_process("ap_credit",$returnpage_error, $returnpage_success);
}
else
{
// user does not have perms to view this page/isn't logged on
error_render_noperms();
header("Location: ../index.php?page=message.php");
exit(0);
}


?>
Loading