From 5f06887dedd4d14701864fb72994d7e20352086d Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 2 Feb 2010 10:02:01 +0000 Subject: [PATCH] Merged changes from main trunk up to 2.2.5 --- CHANGELOG.txt | 97 +++++++ admin/gl_setup.php | 1 + applications/generalledger.php | 2 + config.default.php | 2 +- gl/bank_transfer.php | 12 +- gl/includes/db/gl_db_trans.inc | 33 ++- gl/inquiry/balance_sheet.php | 361 +++++++++++++++++++++++++ gl/inquiry/gl_account_inquiry.php | 2 +- gl/manage/exchange_rates.php | 2 + includes/db/manufacturing_db.inc | 7 +- includes/errors.inc | 8 +- includes/types.inc | 5 + includes/ui/ui_view.inc | 85 +++++- js/inserts.js | 2 +- js/utils.js | 6 +- purchasing/supplier_payment.php | 2 +- reporting/includes/doctext.inc | 43 ++- reporting/includes/doctext2.inc | 43 ++- reporting/includes/header2.inc | 22 +- reporting/includes/reporting.inc | 9 + reporting/includes/reports_classes.inc | 13 +- reporting/rep107.php | 6 + reporting/rep108.php | 8 +- reporting/rep109.php | 6 + reporting/rep110.php | 6 + reporting/rep111.php | 6 + reporting/rep112.php | 181 +++++++++++++ reporting/rep209.php | 6 + reporting/rep210.php | 34 ++- reporting/rep601.php | 25 ++ reporting/rep704.php | 45 +-- reporting/rep705.php | 4 +- reporting/rep706.php | 4 +- reporting/rep707.php | 4 +- reporting/rep709.php | 6 +- reporting/reports_main.php | 11 + sales/customer_payments.php | 8 +- sales/includes/db/sales_order_db.inc | 2 + sales/includes/sales_db.inc | 18 ++ sales/inquiry/customer_inquiry.php | 4 +- sales/sales_order_entry.php | 46 ++-- sql/en_US-demo.sql | 3 +- sql/en_US-new.sql | 3 +- taxes/tax_types.php | 2 +- update.html | 4 +- 45 files changed, 1060 insertions(+), 139 deletions(-) create mode 100644 gl/inquiry/balance_sheet.php create mode 100644 reporting/rep112.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1894dd5b..4e0ee63b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,102 @@ Legend: ! -> Note $ -> Affected files +20-Jan-2010 Merged changes from main trunk 2.2.4-2.2.5 as follows +------------------------------- Release 2.2.5 ---------------------------------- +02-Feb-2010 Joe Hunt +! Release 2.2.5 +$ $config.default.php + update.html +# Bug in direct invoice when cash sales and no cash account defined in sales pos. +$ /sales/sales_order_entry.php + +01-Feb-2010 Janusz Dobrowolski +# Fixed error display hidden during ajax call in some situations +$ /includes/errors.inc +! Ajax timeout changed to 6/60s without retries, otherwise multiply + errors are generated on fatal failure. +$ /js/utils.js + /js/inserts.js + +01-Feb-2010 Joe Hunt +# [0000198] Bug ignoring shipping cost in Direct Invoice (cash). +$ /sales/sales_order_entry.php +# [0000197] Bug in closing some special balance sheet levels. +$ /gl/inquiry/balance_sheet.php + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + +31-Jan-2010 Joe Hunt +# Bug in Quick Entries with Tax added. +$ /includes/ui/ui_view.inc + +30-Jan-2010 Joe Hunt/Chaitanya ++ Added a Balance Sheet drilldown inquiry in Banking and GL. + Contributed by Chatanya. Magnificient! +$ /applications/generalledger.php + /gl/inquiry/balance_sheet.php (new file) + /gl/inquiry/gl_account_inquiry.php ++ Added Purchase tax account in en_US-new.sql and en_US-demo.sql +$ /sql/en_US-demo.sql + /sql/en_US_new.sql +# Fixed bug in gl accounts checks + /taxes/tax_types.php + +30-Jan-2010 Janusz Dobrowolski +# [0000194] Fixed tax records from journal entry (voiding problem) +$ /gl/includes/db/gl_db_trans.inc + /reporting/rep709.php + +25-Jan-2010 Joe Hunt +# [0000195] Bug not deleting refs record when deleting Sales Order, Quotation +# A couple of redirecting bugs +$ /sales/sales_order_entry.php + /sales/includes/db/sales_order_db.inc +# Bug in the sequence in sales price pickup +$ /sales/includes/sales_db.inc ++ Added document Receipt and small rearrangements and bugfixes +$ /includes/types.inc + /includes/ui/ui_view.inc + /reporting/rep107.php + /reporting/rep108.php + /reporting/rep109.php + /reporting/rep110.php + /reporting/rep111.php + /reporting/rep112.php (new document file) + /reporting/rep209.php + /reporting/rep210.php + /reporting/reports_main.php + /reporting/includes/doctext.inc + /reporting/includes/doctext2.inc + /reporting/includes/header2.inc + /reporting/includes/reporting.inc + /reporting/includes/reports_classes.inc + /sales/customer_payments.php + /sales/sales_order_entry.php + /sales/inquiry/customer_inquiry.php + +22-Jan-2010 Tom Hallman/Joe Hunt +# Exchange rate doesn't update table when adding new or deleting rate +$ /gl/manage/exchange_rates.php +! Small adjustments to Bank Statement and GL Transactions Reports +$ /reporting/rep601.php + /reporting/rep704.php +! Layout fix for Report Selectors in when running in Windows OS. +$ /reporting/includes/reports_classes.inc + +20-Jan-2010 Joe Hunt +! Put a heavy warning on marking the checkbox 'Allow Negative Inventory'. +$ /admin/gl_setup.php + +18-Jan-2010 Joe Hunt +# Demand was calculated double from Sales Quotation. Should be 0. +$ /includes/db/manufacturing_db.inc +# A back link was still in Bank Transfer. +$ /gl/bank_transfer.php + +---------- End of changes from main trunk 2.2.4-2.2.5 + 26-Jan-2010 Janusz Dobrowolski + Editable sales terms in sales orders and invoices, default terms from customer record. $ /admin/db/company_db.inc @@ -104,6 +200,7 @@ $ /admin/create_coy.php $ /js/utils.js 20-Jan-2010 Merged changes from main trunk 2.2.3-2.2.4 as follows + ------------------------------- Release 2.2.4 ---------------------------------- 17-Jan-2010 Joe Hunt ! Release 2.2.4 diff --git a/admin/gl_setup.php b/admin/gl_setup.php index ddd2b8e2..f1b2dbcc 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -177,6 +177,7 @@ gl_all_accounts_list_row(_("Purchase Discount Account:"), 'pyt_discount_act', $_ table_section_title(_("Inventory")); check_row(_("Allow Negative Inventory:"), 'allow_negative_stock', null); +label_row(null, _("Warning: Checking this will result in incorrect values in General Ledger"), "", "class='stockmankofg' colspan=2"); table_section_title(_("Items Defaults")); gl_all_accounts_list_row(_("Sales Account:"), 'default_inv_sales_act', $_POST['default_inv_sales_act']); diff --git a/applications/generalledger.php b/applications/generalledger.php index 676d3b10..c227dffa 100644 --- a/applications/generalledger.php +++ b/applications/generalledger.php @@ -42,6 +42,8 @@ class general_ledger_app extends application $this->add_rapp_function(1, _("Trial &Balance"), "gl/inquiry/gl_trial_balance.php?", 'SA_GLANALYTIC'); + $this->add_rapp_function(1, _("Balance &Sheet"), + "gl/inquiry/balance_sheet.php?", 'SA_GLANALYTIC'); $this->add_rapp_function(1, _("Banking &Reports"), "reporting/reports_main.php?Class=5", 'SA_BANKREP'); $this->add_rapp_function(1, _("General Ledger &Reports"), diff --git a/config.default.php b/config.default.php index b0d8043d..35ae9efd 100644 --- a/config.default.php +++ b/config.default.php @@ -56,7 +56,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // Main Title $app_title = "FrontAccounting"; // application version - $version = "2.3 CVS (m4)"; + $version = "2.3 CVS (m5)"; // src-data compatibility check. Do not change. $core_version = "2.3"; diff --git a/gl/bank_transfer.php b/gl/bank_transfer.php index 2256a4a0..7ec52cc8 100644 --- a/gl/bank_transfer.php +++ b/gl/bank_transfer.php @@ -42,7 +42,7 @@ if (isset($_GET['AddedID'])) hyperlink_no_params($_SERVER['PHP_SELF'], _("Enter &Another Transfer")); - safeExit(); + display_footer_exit(); } if (isset($_POST['_DatePaid_changed'])) { @@ -170,21 +170,11 @@ function handle_add_deposit() //---------------------------------------------------------------------------------------- -function safeExit() -{ - echo "

"; - end_page(); - exit; -} - -//---------------------------------------------------------------------------------------- - if (isset($_POST['AddPayment'])) { if (check_valid_entries() == true) { handle_add_deposit(); - safeExit(); } } diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index 45d8eb08..7c94063a 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -337,8 +337,8 @@ function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate, if(!$tax_type) return; // $gl_code is not tax account $tax = get_tax_type($tax_type); - //if ($gl_code == $tax['sales_gl_code']) - // $amount = -$amount; + if ($gl_code == $tax['sales_gl_code']) + $amount = -$amount; // we have to restore net amount as we cannot know the base amount if ($tax['rate'] == 0) { // display_warning(_("You should not post gl transactions @@ -407,14 +407,27 @@ function get_tax_summary($from, $to) $todate = date2sql($to); $sql = "SELECT + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE + ." || trans_type=".ST_JOURNAL.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", net_amount*ex_rate,0)) net_output, + + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE + ." || trans_type=".ST_JOURNAL.",-1,1)* + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", amount*ex_rate,0)) payable, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", net_amount*ex_rate,0)) net_output, - SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", amount*ex_rate,0)) payable, - SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, net_amount*ex_rate)) net_input, + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", 0, net_amount*ex_rate)) net_input, + SUM(IF(trans_type=".ST_CUSTCREDIT." || trans_type=".ST_SUPPINVOICE.",-1,1)* - IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE." || trans_type=".ST_CUSTCREDIT.", 0, amount*ex_rate)) collectible, + IF(trans_type=".ST_BANKDEPOSIT." || trans_type=".ST_SALESINVOICE + ." || (trans_type=".ST_JOURNAL ." AND amount<0)" + ." || trans_type=".ST_CUSTCREDIT.", 0, amount*ex_rate)) collectible, taxrec.rate, ttype.id, ttype.name @@ -469,7 +482,7 @@ function write_journal_entries(&$cart, $reverse, $use_transaction=true) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, -$journal_item->amount, 1, $date_, $memo_); + ST_JOURNAL, $trans_id, $journal_item->amount, 1, $date_, $memo_); } if ($new) { @@ -506,7 +519,7 @@ function write_journal_entries(&$cart, $reverse, $use_transaction=true) } // store tax details if the gl account is a tax account add_gl_tax_details($journal_item->code_id, - ($journal_item->amount < 0.0 ? ST_BANKDEPOSIT : ST_BANKPAYMENT), $trans_id, $journal_item->amount, 1, $reversingDate, $memo_); + ST_JOURNAL, $trans_id, $journal_item->amount, 1, $reversingDate, $memo_); } add_comments($trans_type, $trans_id_reverse, $reversingDate, $memo_); diff --git a/gl/inquiry/balance_sheet.php b/gl/inquiry/balance_sheet.php new file mode 100644 index 00000000..370dfda6 --- /dev/null +++ b/gl/inquiry/balance_sheet.php @@ -0,0 +1,361 @@ +. +***********************************************************************/ +$page_security = 'SA_GLANALYTIC'; +$path_to_root="../.."; + +include_once($path_to_root . "/includes/session.inc"); + +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/ui.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); + +include_once($path_to_root . "/gl/includes/gl_db.inc"); + +$js = ""; +if ($use_date_picker) + $js = get_js_date_picker(); + +page(_($help_context = "Balance Sheet"), false, false, "", $js); + +//---------------------------------------------------------------------------------------------------- +// Ajax updates + +if (get_post('Show')) +{ + $Ajax->activate('balance_tbl'); +} + +if (isset($_GET["TransFromDate"])) + $_POST["TransFromDate"] = $_GET["TransFromDate"]; +if (isset($_GET["TransToDate"])) + $_POST["TransToDate"] = $_GET["TransToDate"]; +if (isset($_GET["AccGrp"])) + $_POST["AccGrp"] = $_GET["AccGrp"]; + +//---------------------------------------------------------------------------------------------------- + +function is_of_account_type($accttype,$typeslist) +{ + return in_array($accttype, $typeslist); +} + +function get_child_account_types($acctype) +{ + global $parentsarr; + $parentsarr = array(); + $childernsarr = array(); + $list = ''; + array_push($parentsarr, $acctype); + while (sizeof($parentsarr)>0) + { + $parent = array_pop($parentsarr); + array_push($childernsarr,$parent); + pushchilds($parent); + } + $list = substr($list,0,-1); + return $childernsarr; +} + +function pushchilds($parent) +{ + global $parentsarr; + + $sql = "SELECT id FROM ".TB_PREF."chart_types WHERE parent=".$parent; + $result = db_query($sql,"Query failed"); + while ($myrow=db_fetch($result)) + { + array_push($parentsarr, $myrow['id']); + } +} + +function inquiry_controls() +{ + + start_table("class='tablestyle_noborder'"); + date_cells(_("As at:"), 'TransToDate'); + submit_cells('Show',_("Show"),'','', 'default'); + end_table(); + + hidden('TransFromDate'); + hidden('AccGrp'); + +} + +function print_balance_sheet() +{ + global $comp_path, $path_to_root, $table_style; + + $from = begin_fiscalyear(); + $to = $_POST['TransToDate']; + + $dim = get_company_pref('use_dimension'); + $dimension = $dimension2 = 0; + + $classname = ''; + $classopen = 0.0; + $classperiod = 0.0; + $classclose = 0.0; + $assetsopen = 0.0; + $assetsperiod = 0.0; + $assetsclose = 0.0; + $equityopen = 0.0; + $equityperiod = 0.0; + $equityclose = 0.0; + $lopen = 0.0; + $lperiod = 0.0; + $lclose = 0.0; + + $typeopen = array(0,0,0,0,0,0,0,0,0,0); + $typeperiod = array(0,0,0,0,0,0,0,0,0,0); + $typeclose = array(0,0,0,0,0,0,0,0,0,0); + $typename = array('','','','','','','','','',''); + $acctype = array('','','','','','','','','',''); + $closing = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); + //$parent = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); + $level = 0; + $last = -1; + + $closeclass = false; + $ctype = 0; + $convert = 1; + + $accounts = get_gl_accounts_all(1); + + div_start('balance_tbl'); + + start_table("width=30% $table_style"); + + while ($account=db_fetch($accounts)) + { + if ($account['account_code'] == null && $account['parent'] > 0) + continue; + + //Check for confirming the account type + if (isset($_POST['AccGrp']) && (strlen($_POST['AccGrp']) > 0) ) + { + $sub_types_arr = get_child_account_types($_POST['AccGrp']); + if (!is_of_account_type($account['AccountType'], $sub_types_arr)) + continue; + } + + if ($account['account_code'] != null) + { + $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2); + + $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2); + + if (!$prev_balance && !$curr_balance) + continue; + } + if ($account['AccountClassName'] != $classname) + { + if ($classname != '') + { + $closeclass = true; + } + } + if ($account['AccountTypeName'] != $typename[$level]) + { + if ($typename[$level] != '') + { + for ( ; $level >= 0, $typename[$level] != ''; $level--) + { + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) + { + + $url = "" . $typename[$level] . ""; + + alt_table_row_color($k); + label_cell($url); + amount_cell($typeclose[$level] * $convert); + end_row(); + + $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0; + } + else + break; + } + + if ($closeclass) + { + start_row("class='inquirybg' style='font-weight:bold'"); + label_cell(_('Total') . " " . $classname); + amount_cell($classclose * $convert, true); + end_row(); + + if ($ctype == CL_EQUITY) + { + $equityopen += $classopen; + $equityperiod += $classperiod; + $equityclose += $classclose; + } + if ($ctype == CL_LIABILITIES) + { + $lopen += $classopen; + $lperiod += $classperiod; + $lclose += $classclose; + } + $assetsopen += $classopen; + $assetsperiod += $classperiod; + $assetsclose += $classclose; + $classopen = $classperiod = $classclose = 0.0; + + $closeclass = false; + } + } + if ($account['AccountClassName'] != $classname) + { + if (isset($_POST['AccGrp']) && (strlen($_POST['AccGrp']) > 0)) + table_section_title($account['AccountTypeName']); + else + table_section_title($account['AccountClassName']); + } + $level++; + if ($account['parent'] != $last) + $last = $account['parent']; + $typename[$level] = $account['AccountTypeName']; + + $acctype[$level] = $account['AccountType']; + + $closing[$level] = $account['parent']; + + } + $classname = $account['AccountClassName']; + $classtype = $account['AccountType']; + $ctype = $account['ClassType']; + $convert = get_class_type_convert($ctype); + + if ($account['account_code'] != null) + { + for ($i = 0; $i <= $level; $i++) + { + $typeopen[$i] += $prev_balance; + $typeperiod[$i] += $curr_balance; + $typeclose[$i] = $typeopen[$i] + $typeperiod[$i]; + } + $classopen += $prev_balance; + $classperiod += $curr_balance; + $classclose = $classopen + $classperiod; + + //Show accounts details only for drill down and direct child of Account Group + if ( isset($_POST['AccGrp']) && ($account['AccountType'] == $_POST['AccGrp'])) + { + $url = "" . $account['account_code'] + ." ". $account['account_name'] .""; + + start_row("class='stockmankobg'"); + label_cell($url); + amount_cell(($curr_balance + $prev_balance) * $convert); + end_row(); + } + } + } + + if ($account['AccountClassName'] != $classname) + { + if ($classname != '') + { + $closeclass = true; + } + } + if ($account['AccountTypeName'] != $typename[$level]) + { + + if ($typename[$level] != '') + { + for ( ; $level >= 0, $typename[$level] != ''; $level--) + { + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) + { + //Inside drill down, no hyperlink + if (isset($_POST['AccGrp']) && (strlen($_POST['AccGrp']) > 0) && ($acctype[$level] == $_POST['AccGrp'])) + { + start_row("class='inquirybg' style='font-weight:bold'"); + label_cell(_('Total') . " " .$typename[$level]); + amount_cell($typeclose[$level] * $convert); + end_row(); + } + else + { + $url = "" . $typename[$level] . ""; + + alt_table_row_color($k); + label_cell($url); + amount_cell($typeclose[$level] * $convert); + end_row(); + } + + $typeopen[$level] = $typeperiod[$level] = $typeclose[$level] = 0.0; + + } + else + break; + + } + + if (($closeclass) && !(isset($_POST['AccGrp']) && (strlen($_POST['AccGrp']) > 0)) ) + { + $calculateopen = -$assetsopen - $classopen; + $calculateperiod = -$assetsperiod - $classperiod; + $calculateclose = -$assetsclose - $classclose; + if ($ctype == CL_EQUITY) + { + $equityopen += $classopen; + $equityperiod += $classperiod; + $equityclose += $classclose; + } + + alt_table_row_color($k); + label_cell(_('Calculated Return')); + amount_cell($calculateclose * $convert); + end_row(); + + start_row("class='inquirybg' style='font-weight:bold'"); + label_cell(_('Total') . " " . $classname); + amount_cell(-$assetsclose * $convert); + end_row(); + + if ($equityopen != 0.0 || $equityperiod != 0.0 || $equityclose != 0.0 || + $lopen != 0.0 || $lperiod != 0.0 || $lclose != 0.0) + { + alt_table_row_color($k); + label_cell(_('Total') . " " . _('Liabilities') . _(' and ') . _('Equities')); + amount_cell(($lclose + $equityclose + $calculateclose) * -1); + end_row(); + } + } + } + } + end_table(1); // outer table + div_end(); +} + +//---------------------------------------------------------------------------------------------------- + +start_form(); + +inquiry_controls(); + +print_balance_sheet(); + +end_form(); + +end_page(); + +?> + diff --git a/gl/inquiry/gl_account_inquiry.php b/gl/inquiry/gl_account_inquiry.php index a86f0c2b..5612e363 100644 --- a/gl/inquiry/gl_account_inquiry.php +++ b/gl/inquiry/gl_account_inquiry.php @@ -228,7 +228,7 @@ gl_inquiry_controls(); div_start('trans_tbl'); -if (get_post('Show')) +if (get_post('Show') || get_post('account')) show_results(); div_end(); diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 9ea1c17f..e50fc5f3 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -67,6 +67,7 @@ function handle_submit() } $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- @@ -79,6 +80,7 @@ function handle_delete() return; delete_exchange_rate($selected_id); $selected_id = ''; + clear_data(); } //--------------------------------------------------------------------------------------------- diff --git a/includes/db/manufacturing_db.inc b/includes/db/manufacturing_db.inc index 14927475..1e8af932 100644 --- a/includes/db/manufacturing_db.inc +++ b/includes/db/manufacturing_db.inc @@ -17,7 +17,8 @@ function get_demand_qty($stock_id, $location) FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders WHERE ".TB_PREF."sales_order_details.order_no=" - .TB_PREF."sales_orders.order_no AND "; + .TB_PREF."sales_orders.order_no AND ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." AND + ".TB_PREF."sales_orders.trans_type=".TB_PREF."sales_order_details.trans_type AND "; if ($location != "") $sql .= TB_PREF."sales_orders.from_stk_loc =".db_escape($location)." AND "; $sql .= TB_PREF."sales_order_details.stk_code = ".db_escape($stock_id); @@ -101,7 +102,9 @@ function get_demand_asm_qty($stock_id, $location) FROM ".TB_PREF."sales_order_details, ".TB_PREF."sales_orders, ".TB_PREF."stock_master - WHERE ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND "; + WHERE ".TB_PREF."sales_orders.order_no = ".TB_PREF."sales_order_details.order_no AND + ".TB_PREF."sales_orders.trans_type=".ST_SALESORDER." AND + ".TB_PREF."sales_orders.trans_type=".TB_PREF."sales_order_details.trans_type AND "; if ($location != "") $sql .= TB_PREF."sales_orders.from_stk_loc =".db_escape($location)." AND "; $sql .= TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND diff --git a/includes/errors.inc b/includes/errors.inc index fc8f4fb6..551d32e4 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -85,9 +85,9 @@ function error_box() { global $before_box; echo "
"; - $before_box = ob_get_clean(); // save html content before error box + // Necessary restart instead of get_contents/clean calls due to a bug in php 4.3.2 - register_shutdown_function('end_flush'); + $before_box = ob_get_clean(); // save html content before error box ob_start('output_html'); echo "
"; } @@ -99,8 +99,8 @@ function end_flush () { if (isset($Ajax)) $Ajax->run(); - - if (ob_get_level()) ob_end_flush(); + // flush all output buffers (works also with exit inside any div levels) + while(ob_get_level()) ob_end_flush(); } function display_db_error($msg, $sql_statement=null, $exit=true) diff --git a/includes/types.inc b/includes/types.inc index 3636a493..c7bb52c2 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -42,6 +42,11 @@ define('ST_SALESQUOTE', 32); define('ST_COSTUPDATE', 35); define('ST_DIMENSION', 40); +// Don't include these defines in the $systypes_array. +// They are used for documents only. +define ('ST_STATEMENT', 91); +define ('ST_CHEQUE', 92); + $systypes_array = array ( ST_JOURNAL => _("Journal Entry"), ST_BANKPAYMENT => _("Bank Payment"), diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 8e2591c3..65b6bf91 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -597,9 +597,10 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') if (substr($qe_line['action'],0,1) != 'T') $part = $taxbase; else - $part = $base; + $part = $base/100; $item_tax = get_tax_type($qe_line['dest_id']); - if ($type == QE_SUPPINV && substr($qe_line['action'],0,1) != 'T') + //if ($type == QE_SUPPINV && substr($qe_line['action'],0,1) != 'T') + if ($type == QE_SUPPINV) { $taxgroup = $cart->tax_group_id; $rates = 0; @@ -649,6 +650,86 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') return $bank_amount; } +//-------------------------------------------------------------------------------------- +// +// Simple English version of number to words conversion. +// +function _number_to_words($number) +{ + $Bn = floor($number / 1000000000); /* Billions (giga) */ + $number -= $Bn * 1000000000; + $Gn = floor($number / 1000000); /* Millions (mega) */ + $number -= $Gn * 1000000; + $kn = floor($number / 1000); /* Thousands (kilo) */ + $number -= $kn * 1000; + $Hn = floor($number / 100); /* Hundreds (hecto) */ + $number -= $Hn * 100; + $Dn = floor($number / 10); /* Tens (deca) */ + $n = $number % 10; /* Ones */ + + $res = ""; + + if ($Bn) + $res .= _number_to_words($Bn) . " Billion"; + if ($Gn) + $res .= (empty($res) ? "" : " ") . _number_to_words($Gn) . " Million"; + if ($kn) + $res .= (empty($res) ? "" : " ") . _number_to_words($kn) . " Thousand"; + if ($Hn) + $res .= (empty($res) ? "" : " ") . _number_to_words($Hn) . " Hundred"; + + $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", + "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", + "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen", + "Nineteen"); + $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", + "Seventy", "Eigthy", "Ninety"); + + if ($Dn || $n) + { + if (!empty($res)) + $res .= " and "; + if ($Dn < 2) + $res .= $ones[$Dn * 10 + $n]; + else + { + $res .= $tens[$Dn]; + if ($n) + $res .= "-" . $ones[$n]; + } + } + + if (empty($res)) + $res = "zero"; + return $res; +} + +function price_in_words($amount, $document=0) +{ + global $Hooks; + // use local price_in_words() if the hook is defined + if (method_exists($Hooks, 'price_in_words')) + { + return $Hooks->price_in_words($amount, $document); + } + // Only usefor Remittance and Receipts as default + if (!($document == ST_SUPPAYMENT || $document == ST_CUSTPAYMENT || $document == ST_CHEQUE)) + return ""; + if ($amount < 0 || $amount > 999999999999) + return ""; + $dec = user_price_dec(); + if ($dec > 0) + { + $divisor = pow(10, $dec); + $frac = round2($amount - floor($amount), $dec) * $divisor; + $frac = sprintf("%0{$dec}d", $frac); + $and = _("and"); + $frac = " $and $frac/$divisor"; + } + else + $frac = ""; + return _number_to_words(intval($amount)) . $frac; +} function get_js_open_window($width, $height) { diff --git a/js/inserts.js b/js/inserts.js index a853a716..5b8d73a7 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -220,7 +220,7 @@ var inserts = { e.onclick = function() { save_focus(e); if (e.getAttribute('aspect') == 'process') - JsHttpRequest.request(this, null, 30000); + JsHttpRequest.request(this, null, 60000); else JsHttpRequest.request(this); return false; diff --git a/js/utils.js b/js/utils.js index 1f63f301..8d707b3d 100644 --- a/js/utils.js +++ b/js/utils.js @@ -35,10 +35,10 @@ function disp_msg(msg, cl) { // JsHttpRequest.request= function(trigger, form, tout) { // if (trigger.type=='submit' && !validate(trigger)) return false; - tout = tout | 3000; // default timeout value + tout = tout | 6000; // default timeout value document.getElementById('msgbox').innerHTML=''; - set_mark(tout>5000 ? 'progressbar.gif' : 'ajax-loader.gif'); - JsHttpRequest._request(trigger, form, tout, 2); + set_mark(tout>10000 ? 'progressbar.gif' : 'ajax-loader.gif'); + JsHttpRequest._request(trigger, form, tout, 0); } JsHttpRequest._request = function(trigger, form, tout, retry) { diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 0c8aa7dd..e0aa2d08 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -73,7 +73,7 @@ if (isset($_GET['AddedID'])) submenu_print(_("&Print This Remittance"), ST_SUPPAYMENT, $payment_id."-".ST_SUPPAYMENT, 'prtopt'); submenu_print(_("&Email This Remittance"), ST_SUPPAYMENT, $payment_id."-".ST_SUPPAYMENT, null, 1); - display_note(get_gl_view_str(22, $payment_id, _("View the GL &Journal Entries for this Payment"))); + display_note(get_gl_view_str(ST_SUPPAYMENT, $payment_id, _("View the GL &Journal Entries for this Payment"))); // hyperlink_params($path_to_root . "/purchasing/allocations/supplier_allocate.php", _("&Allocate this Payment"), "trans_no=$payment_id&trans_type=22"); diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index 40a0802b..c76cfed9 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -20,7 +20,10 @@ if (isset($header2type)) } else { - $doc_Charge_To = _("Charge To"); + if ($doctype == ST_CUSTPAYMENT) + $doc_Charge_To = _("With thanks from"); + else + $doc_Charge_To = _("Charge To"); $doc_Delivered_To = _("Delivered To"); } $doc_Shipping_Company = _("Shipping Company"); @@ -42,7 +45,7 @@ if (isset($header2type)) } else { - if ($doctype == ST_SUPPAYMENT) + if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $doc_Our_Ref = _("Type"); else $doc_Our_Ref = _("Sales Person"); @@ -53,10 +56,13 @@ if (isset($header2type)) } $doc_Our_VAT_no = _("Our VAT No."); $doc_Domicile = _("Domicile"); + $doc_Extra = ""; if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || - $doctype == ST_SUPPAYMENT) { - $doc_Bank_Account = ''; - $doc_Please_Quote = _("All amounts stated in"); + $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { + if ($doctype == ST_CUSTPAYMENT) + $doc_Extra = _("* Subject to Realisation of the Cheque."); + $doc_Bank_Account = ''; + $doc_Please_Quote = _("All amounts stated in"); } else { $doc_Bank_Account = _("Bank Account"); $doc_Please_Quote = $doctype==ST_SALESINVOICE ? @@ -68,7 +74,8 @@ if (isset($header2type)) $doc_Bank = _("Bank"); $doc_Payment_Link = _("You can pay through"); if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE || - $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT) + $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || + $doctype == ST_CUSTPAYMENT) { if ($doctype == ST_SALESQUOTE) $this->title = _("SALES QUOTATION"); @@ -84,6 +91,8 @@ if (isset($header2type)) $this->title = _("WORK ORDER"); elseif ($doctype == ST_SUPPAYMENT) $this->title = _("REMITTANCE"); + elseif ($doctype == ST_CUSTPAYMENT) + $this->title = _("RECEIPT"); else $this->title = _("CREDIT NOTE"); if ($doctype == ST_PURCHORDER) @@ -92,13 +101,13 @@ if (isset($header2type)) elseif ($doctype == ST_WORKORDER) $this->headers = array(_("Item Code"), _("Item Description"), _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued")); - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("Due Date"), _("Total Amount"), _("Left to Allocate"), _("This Allocation")); else $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount %"), _("Total")); } - else if ($doctype == ST_CUSTPAYMENT) + else if ($doctype == ST_STATEMENT) { $this->title = _("STATEMENT"); $this->headers = array(_("Trans Type"), _("#"), _("Date"), _("DueDate"), _("Charges"), @@ -115,9 +124,10 @@ if (isset($emailtype)) if (isset($header2type) || isset($linetype)) { $doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? _("Delivery Note No.") : + ($doctype == ST_CUSTPAYMENT ? _("Receipt No.") : ($doctype == ST_SUPPAYMENT ? _("Remittance No.") : (($doctype==ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? _("Order no.") : - ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No.")))))); + ($doctype==ST_SALESINVOICE ? _("Invoice No.") : ($doctype==ST_WORKORDER ? _("Word Order No") : _("Credit No."))))))); $doc_Delivery_no = _("Delivery Note No."); $doc_Order_no = _("Order no."); } @@ -136,13 +146,22 @@ if (isset($linetype)) $doc_TOTAL_PO = _("TOTAL PO EX VAT"); $doc_TOTAL_DELIVERY = _("TOTAL DELIVERY INCL. VAT"); } - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || ST_CUSTPAYMENT) { + $doc_Towards = _("As advance / full / part / payment towards:"); + $doc_by_Cheque = _("By Cash / Cheque* / Draft No."); + $doc_Dated = _("Dated"); + $doc_Drawn = _("Drawn on Bank"); + $doc_Drawn_Branch = _("Branch"); + $doc_Received = _("Received / Sign"); $doc_Total_Allocated = _("Total Allocated"); $doc_Left_To_Allocate = _("Left to Allocate"); - $doc_Total_Payment = _("TOTAL REMITTANCE"); + if ($doctype == ST_CUSTPAYMENT) + $doc_Total_Payment = _("TOTAL RECEIPT"); + else + $doc_Total_Payment = _("TOTAL REMITTANCE"); } - elseif ($doctype == ST_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $doc_Outstanding = _("Outstanding Transactions"); $doc_Current = _("Current"); diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc index 554409e7..761f60f7 100644 --- a/reporting/includes/doctext2.inc +++ b/reporting/includes/doctext2.inc @@ -20,7 +20,10 @@ if (isset($header2type)) } else { - $doc_Charge_To = "Charge To"; + if ($doctype == ST_CUSTPAYMENT) + $doc_Charge_To = "With thanks from"; + else + $doc_Charge_To = "Charge To"; $doc_Delivered_To = "Delivered To"; } $doc_Shipping_Company = "Shipping Company"; @@ -42,7 +45,7 @@ if (isset($header2type)) } else { - if ($doctype == ST_SUPPAYMENT) + if ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $doc_Our_Ref = "Type"; else $doc_Our_Ref = "Sales Person"; @@ -51,12 +54,15 @@ if (isset($header2type)) $doc_Customers_Ref = "Customers Reference"; $doc_Our_Order_No = "Our Order No"; } + $doc_Extra = ""; $doc_Our_VAT_no = "Our VAT No."; $doc_Domicile = "Domicile"; if($doctype == ST_CUSTDELIVERY || $doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || - $doctype == ST_SUPPAYMENT) { - $doc_Bank_Account = ''; - $doc_Please_Quote = "All amounts stated in"; + $doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { + if ($doctype == ST_CUSTPAYMENT) + $doc_Extra = "* Subject to Realisation of the Cheque."; + $doc_Bank_Account = ''; + $doc_Please_Quote = "All amounts stated in"; } else { $doc_Please_Quote = "Please quote ".($doctype==ST_SALESINVOICE ? "Invoice" : "Credit") ." no. when paying. All amounts stated in"; @@ -67,7 +73,8 @@ if (isset($header2type)) $doc_Bank = "Bank"; $doc_Payment_Link = "You can pay through"; if ($doctype == ST_SALESQUOTE || $doctype == ST_PURCHORDER || $doctype == ST_SALESORDER || $doctype == ST_SALESINVOICE || - $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT) + $doctype == ST_CUSTCREDIT || $doctype == ST_CUSTDELIVERY || $doctype == ST_WORKORDER || $doctype == ST_SUPPAYMENT || + $doctype == ST_CUSTPAYMENT) { if ($doctype == ST_SALESQUOTE) $this->title = "SALES QUOTATION"; @@ -83,6 +90,8 @@ if (isset($header2type)) $this->title = "WORK ORDER"; elseif ($doctype == ST_SUPPAYMENT) $this->title = "REMITTANCE"; + elseif ($doctype == ST_CUSTPAYMENT) + $this->title = "RECEIPT"; else $this->title = "CREDIT NOTE"; if ($doctype == ST_PURCHORDER) @@ -91,13 +100,13 @@ if (isset($header2type)) elseif ($doctype == ST_WORKORDER) $this->headers = array("Item Code", "Item Description", "From Location", "Work Centre", "Unit Quantity", "Total Quantity", "Units Issued"); - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Total Amount', 'Left to Allocate', 'This Allocation'); else $this->headers = array('Item Code', 'Item Description', 'Quantity', 'Unit', 'Price', 'Discount %', 'Total'); } - elseif ($doctype == ST_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $this->title = "STATEMENT"; $this->headers = array('Trans Type', '#', 'Date', 'Due Date', 'Charges', @@ -114,9 +123,10 @@ if (isset($emailtype)) if (isset($header2type) || isset($linetype)) { $doc_Invoice_no = ($doctype==ST_CUSTDELIVERY ? "Delivery Note No." : + ($doctype == ST_CUSTPAYMENT ? "Receipt No." : ($doctype == ST_SUPPAYMENT ? "Remittance No." : (($doctype == ST_SALESQUOTE || $doctype==ST_PURCHORDER || $doctype==ST_SALESORDER) ? "Order no." : - ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No."))))); + ($doctype==ST_SALESINVOICE ? "Invoice No." : ($doctype == ST_WORKORDER ? "Work Order No" : "Credit No.")))))); $doc_Delivery_no = "Delivery Note No."; $doc_Order_no = "Order no."; } @@ -135,13 +145,22 @@ if (isset($linetype)) $doc_TOTAL_PO = "TOTAL PO EX VAT"; $doc_TOTAL_DELIVERY = "TOTAL DELIVERY INCL. VAT"; } - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) { + $doc_Towards = "As advance / full / part / payment towards:"; + $doc_by_Cheque = "By Cash / Cheque* / Draft No."; + $doc_Dated = "Dated"; + $doc_Drawn = "Drawn on Bank"; + $doc_Drawn_Branch = "Branch"; + $doc_Received = "Received / Sign"; $doc_Total_Allocated = "Total Allocated"; $doc_Left_To_Allocate = "Left to Allocate"; - $doc_Total_Payment = "TOTAL REMITTANCE"; + if ($doctype == ST_CUSTPAYMENT) + $doc_Total_Payment = "TOTAL RECEIPT"; + else + $doc_Total_Payment = "TOTAL REMITTANCE"; } - elseif ($doctype == ST_CUSTPAYMENT) + elseif ($doctype == ST_STATEMENT) { $doc_Outstanding = "Outstanding Transactions"; $doc_Current = "Current"; diff --git a/reporting/includes/header2.inc b/reporting/includes/header2.inc index e09df981..5602afee 100644 --- a/reporting/includes/header2.inc +++ b/reporting/includes/header2.inc @@ -111,7 +111,7 @@ $this->Text($c2col, $this->company['gst_no'], $mcol); $this->NewLine(); } - if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['domicile'] != "") + if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['domicile'] != "") { $this->Text($ccol, $doc_Domicile, $c2col); $this->Text($c2col, $this->company['domicile'], $mcol); @@ -190,10 +190,10 @@ $this->row = $temp; if ($doctype == ST_PURCHORDER) $this->Text($mcol, $this->company['coy_name']); - elseif ($doctype != ST_SUPPAYMENT) + elseif ($doctype != ST_SUPPAYMENT && isset($sales_order['deliver_to'])) $this->Text($mcol, $sales_order['deliver_to']); $this->NewLine(); - if ($doctype != ST_SUPPAYMENT) + if ($doctype != ST_SUPPAYMENT && isset($sales_order['deliver_to'])) $this->TextWrapLines($mcol, $this->rightMargin - $mcol, $sales_order['delivery_address']); } $this->row = $iline2 - $this->lineHeight - 1; @@ -218,6 +218,8 @@ $this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C'); elseif (isset($sales_order["customer_ref"])) $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C'); + elseif (isset($myrow["debtor_ref"])) + $this->TextWrap($col, $this->row, $width, $myrow["debtor_ref"], 'C'); $col += $width; if ($branch != null) { @@ -228,7 +230,7 @@ //$this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C'); $this->TextWrap($col, $this->row, $width, get_salesman_name($id), 'C'); } - elseif ($doctype == ST_SUPPAYMENT) + elseif ($doctype == ST_SUPPAYMENT || $doctype == ST_CUSTPAYMENT) $this->TextWrap($col, $this->row, $width, $systypes_array[$myrow["type"]], 'C'); elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $wo_types_array[$myrow["type"]], 'C'); @@ -270,14 +272,15 @@ } elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C'); - elseif (isset($myrow['order_'])) + elseif (isset($myrow['order_']) && $myrow['order_'] != 0) $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C'); $col += $width; if ($doctype == ST_SALESORDER || $doctype == ST_SALESQUOTE) $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C'); elseif ($doctype == ST_WORKORDER) $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C'); - elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && isset($myrow['due_date'])) + elseif ($doctype != ST_PURCHORDER && $doctype != ST_CUSTCREDIT && $doctype != ST_CUSTPAYMENT && + $doctype != ST_SUPPAYMENT && isset($myrow['due_date'])) $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C'); if (!isset($packing_slip) || $packing_slip == 0) { @@ -335,12 +338,17 @@ $this->row -= $this->lineHeight; } } + if ($doc_Extra != "") + { + $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Extra, 'C'); + $this->row -= $this->lineHeight; + } if ($this->params['comments'] != '') { $this->TextWrap($ccol, $this->row, $right - $ccol, $this->params['comments'], 'C'); $this->row -= $this->lineHeight; } - if (($doctype == ST_SALESINVOICE || $doctype == ST_CUSTPAYMENT) && $this->company['legal_text'] != "") + if (($doctype == ST_SALESINVOICE || $doctype == ST_STATEMENT) && $this->company['legal_text'] != "") { $this->TextWrapLines($ccol, $right - $ccol, $this->company['legal_text'], 'C'); } diff --git a/reporting/includes/reporting.inc b/reporting/includes/reporting.inc index 4ce4d148..2bfa4257 100644 --- a/reporting/includes/reporting.inc +++ b/reporting/includes/reporting.inc @@ -77,6 +77,15 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no, 'PARAM_3' => $email, 'PARAM_4' => ''); break; + case ST_CUSTPAYMENT : + $rep = 112; + // from, to, currency, bank acc, email, comments + $ar = array( + 'PARAM_0' => $doc_no, + 'PARAM_1' => $doc_no, + 'PARAM_2' => '', + 'PARAM_4' => ''); + break; case ST_SUPPAYMENT : $rep = 210; // from, to, currency, bank acc, email, comments diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index fc1d9d0f..4db83a31 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -64,10 +64,9 @@ class BoxReports $st_params = "
\n" . "
\n"; - $st_params .= hidden('REP_ID', $report->id, false); $st_params .= submit('Rep'.$report->id, _("Display: ") . access_string($report->name, true), - false, '', $pdf_debug ? false : 'default') . '

'; + false, '', $pdf_debug ? false : 'default') . hidden('REP_ID', $report->id, false).'

'; $st_params .= $this->getOptions($report->get_controls()); $st_params .= "\n
\n"; set_focus('Rep'.$report->id); @@ -333,6 +332,16 @@ class BoxReports FROM ".TB_PREF."suppliers, ".TB_PREF."supp_trans WHERE (type=".ST_BANKPAYMENT." OR type=".ST_SUPPAYMENT." OR type=".ST_SUPPCREDIT.") AND ".TB_PREF."suppliers.supplier_id=".TB_PREF."supp_trans.supplier_id ORDER BY ".TB_PREF."supp_trans.trans_no DESC"; return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); + case 'RECEIPT': + $BD = _("BD"); + $CP = _("CP"); + $CN = _("CN"); + $ref = ($print_invoice_no == 1 ? "trans_no" : "reference"); + $sql = "SELECT concat(".TB_PREF."debtor_trans.trans_no, '-', + ".TB_PREF."debtor_trans.type) AS TNO, concat(".TB_PREF."debtor_trans.$ref, if (type=".ST_BANKDEPOSIT.", ' $BD ', if (type=".ST_CUSTPAYMENT.", ' $CP ', ' $CN ')), ".TB_PREF."debtors_master.name) as IName + FROM ".TB_PREF."debtors_master, ".TB_PREF."debtor_trans WHERE (type=".ST_BANKDEPOSIT." OR type=".ST_CUSTPAYMENT." OR type=".ST_CUSTCREDIT.") AND ".TB_PREF."debtors_master.debtor_no=".TB_PREF."debtor_trans.debtor_no ORDER BY ".TB_PREF."debtor_trans.trans_no DESC"; + return combo_input($name, '', $sql, 'TNO', 'IName',array('order'=>false)); + case 'ITEMS': return stock_manufactured_items_list($name); diff --git a/reporting/rep107.php b/reporting/rep107.php index 5d181090..54aefe04 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -192,6 +192,12 @@ function print_invoices() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_INVOICE, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], $j); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep108.php b/reporting/rep108.php index dc5219d9..81e3bb7f 100644 --- a/reporting/rep108.php +++ b/reporting/rep108.php @@ -107,10 +107,10 @@ function print_statements() $rep->filename = "Statement" . $myrow['debtor_no'] . ".pdf"; $rep->Info($params, $cols, null, $aligns); } - $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT); + $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT); $rep->NewLine(); $linetype = true; - $doctype = ST_CUSTPAYMENT; + $doctype = ST_STATEMENT; if ($rep->currency != $myrow['curr_code']) { include($path_to_root . "/reporting/includes/doctext2.inc"); @@ -142,7 +142,7 @@ function print_statements() $rep->TextCol(7, 8, $DisplayNet, -2); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + (10 * $rep->lineHeight)) - $rep->Header2($myrow, null, null, $baccount, ST_CUSTPAYMENT); + $rep->Header2($myrow, null, null, $baccount, ST_STATEMENT); } $nowdue = "1-" . $PastDueDays1 . " " . $doc_Days; $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . $doc_Days; @@ -163,7 +163,7 @@ function print_statements() for ($i = 0; $i < 5; $i++) $rep->TextWrap($col[$i], $rep->row, $col[$i + 1] - $col[$i], $str2[$i], 'right'); if ($email == 1) - $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_CUSTPAYMENT); + $rep->End($email, $doc_Statement . " " . $doc_as_of . " " . sql2date($date), $myrow, ST_STATEMENT); } if ($email == 0) diff --git a/reporting/rep109.php b/reporting/rep109.php index 5b049c11..2c3bb116 100644 --- a/reporting/rep109.php +++ b/reporting/rep109.php @@ -158,6 +158,12 @@ function print_sales_orders() else $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESORDER); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep110.php b/reporting/rep110.php index a8fdbc4a..5afa8b82 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -187,6 +187,12 @@ function print_deliveries() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_DELIVERY, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); } if ($email == 1) diff --git a/reporting/rep111.php b/reporting/rep111.php index 0301ed61..5db2f9d0 100644 --- a/reporting/rep111.php +++ b/reporting/rep111.php @@ -142,6 +142,12 @@ function print_sales_quotations() else $rep->TextCol(3, 6, $doc_TOTAL_ORDER2, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESQUOTE); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep112.php b/reporting/rep112.php new file mode 100644 index 00000000..87d87ce5 --- /dev/null +++ b/reporting/rep112.php @@ -0,0 +1,181 @@ +. +***********************************************************************/ + +$page_security = $_POST['PARAM_0'] == $_POST['PARAM_1'] ? + 'SA_SALESTRANSVIEW' : 'SA_SALESBULKREP'; +// ---------------------------------------------------------------- +// $ Revision: 2.0 $ +// Creator: Joe Hunt +// date_: 2005-05-19 +// Title: Purchase Orders +// ---------------------------------------------------------------- +$path_to_root=".."; + +include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); + +//---------------------------------------------------------------------------------------------------- + +print_receipts(); + +//---------------------------------------------------------------------------------------------------- +function get_receipt($type, $trans_no) +{ + $sql = "SELECT ".TB_PREF."debtor_trans.*, + (".TB_PREF."debtor_trans.ov_amount + ".TB_PREF."debtor_trans.ov_gst + ".TB_PREF."debtor_trans.ov_freight + + ".TB_PREF."debtor_trans.ov_freight_tax + ".TB_PREF."debtor_trans.ov_discount) AS Total, + ".TB_PREF."debtors_master.name AS DebtorName, ".TB_PREF."debtors_master.debtor_ref, + ".TB_PREF."debtors_master.curr_code, ".TB_PREF."debtors_master.payment_terms, ".TB_PREF."debtors_master.tax_id AS tax_id, + ".TB_PREF."debtors_master.email, ".TB_PREF."debtors_master.address + FROM ".TB_PREF."debtor_trans, ".TB_PREF."debtors_master + WHERE ".TB_PREF."debtor_trans.debtor_no = ".TB_PREF."debtors_master.debtor_no + AND ".TB_PREF."debtor_trans.type = ".db_escape($type)." + AND ".TB_PREF."debtor_trans.trans_no = ".db_escape($trans_no); + $result = db_query($sql, "The remittance cannot be retrieved"); + if (db_num_rows($result) == 0) + return false; + return db_fetch($result); +} + +function get_allocations_for_receipt($debtor_id, $type, $trans_no) +{ + $sql = get_alloc_trans_sql("amt, trans.reference, trans.alloc", "trans.trans_no = alloc.trans_no_to + AND trans.type = alloc.trans_type_to + AND alloc.trans_no_from=$trans_no + AND alloc.trans_type_from=$type + AND trans.debtor_no=".db_escape($debtor_id), + TB_PREF."cust_allocations as alloc"); + $sql .= " ORDER BY trans_no"; + return db_query($sql, "Cannot retreive alloc to transactions"); +} + +function print_receipts() +{ + global $path_to_root, $systypes_array; + + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + + $from = $_POST['PARAM_0']; + $to = $_POST['PARAM_1']; + $currency = $_POST['PARAM_2']; + $comments = $_POST['PARAM_3']; + + if ($from == null) + $from = 0; + if ($to == null) + $to = 0; + $dec = user_price_dec(); + + $fno = explode("-", $from); + $tno = explode("-", $to); + + $cols = array(4, 85, 150, 225, 275, 360, 450, 515); + + // $headers in doctext.inc + $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right'); + + $params = array('comments' => $comments); + + $cur = get_company_Pref('curr_default'); + + $rep = new FrontReport(_('RECEIPT'), "ReceiptBulk", user_pagesize()); + $rep->currency = $cur; + $rep->Font(); + $rep->Info($params, $cols, null, $aligns); + + for ($i = $fno[0]; $i <= $tno[0]; $i++) + { + if ($fno[0] == $tno[0]) + $types = array($fno[1]); + else + $types = array(ST_BANKDEPOSIT, ST_CUSTPAYMENT, ST_CUSTCREDIT); + foreach ($types as $j) + { + $myrow = get_receipt($j, $i); + if (!$myrow) + continue; + $baccount = get_default_bank_account($myrow['curr_code']); + $params['bankaccount'] = $baccount['id']; + + $rep->title = _('RECEIPT'); + $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT); + $result = get_allocations_for_receipt($myrow['debtor_no'], $myrow['type'], $myrow['trans_no']); + + $linetype = true; + $doctype = ST_CUSTPAYMENT; + if ($rep->currency != $myrow['curr_code']) + { + include($path_to_root . "/reporting/includes/doctext2.inc"); + } + else + { + include($path_to_root . "/reporting/includes/doctext.inc"); + } + + $total_allocated = 0; + $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->NewLine(2); + + while ($myrow2=db_fetch($result)) + { + $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); + $rep->TextCol(1, 2, $myrow2['reference'], -2); + $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2); + $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2); + $rep->AmountCol(4, 5, $myrow2['Total'], $dec, -2); + $rep->AmountCol(5, 6, $myrow2['Total'] - $myrow2['alloc'], $dec, -2); + $rep->AmountCol(6, 7, $myrow2['amt'], $dec, -2); + + $total_allocated += $myrow2['amt']; + $rep->NewLine(1); + if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) + $rep->Header2($myrow, null, $myrow, $baccount, ST_CUSTPAYMENT); + } + + $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight); + + $rep->TextCol(3, 6, $doc_Total_Allocated, -2); + $rep->AmountCol(6, 7, $total_allocated, $dec, -2); + $rep->NewLine(); + $rep->TextCol(3, 6, $doc_Left_To_Allocate, -2); + $rep->AmountCol(6, 7, $myrow['Total'] - $total_allocated, $dec, -2); + $rep->NewLine(); + $rep->Font('bold'); + $rep->TextCol(3, 6, $doc_Total_Payment, - 2); + $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2); + $words = price_in_words($myrow['Total'], ST_CUSTPAYMENT); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(0, 7, $myrow['curr_code'] . ": " . $words, - 2); + } + $rep->Font(); + $rep->NewLine(); + $rep->TextCol(6, 7, $doc_Received, - 2); + $rep->NewLine(); + $rep->TextCol(0, 2, $doc_by_Cheque, - 2); + $rep->TextCol(2, 4, "______________________________", - 2); + $rep->TextCol(4, 5, $doc_Dated, - 2); + $rep->TextCol(5, 6, "__________________", - 2); + $rep->NewLine(1); + $rep->TextCol(0, 2, $doc_Drawn, - 2); + $rep->TextCol(2, 4, "______________________________", - 2); + $rep->TextCol(4, 5, $doc_Drawn_Branch, - 2); + $rep->TextCol(5, 6, "__________________", - 2); + $rep->TextCol(6, 7, "__________________"); + } + } + $rep->End(); +} + +?> \ No newline at end of file diff --git a/reporting/rep209.php b/reporting/rep209.php index e8278e60..87b9f559 100644 --- a/reporting/rep209.php +++ b/reporting/rep209.php @@ -167,6 +167,12 @@ function print_po() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_TOTAL_PO, - 2); $rep->TextCol(6, 7, $DisplayTotal, -2); + $words = price_in_words($SubTotal, ST_PURCHORDER); + if ($words != "") + { + $rep->NewLine(1); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep210.php b/reporting/rep210.php index f25b7925..27d56cd7 100644 --- a/reporting/rep210.php +++ b/reporting/rep210.php @@ -90,7 +90,7 @@ function print_remittances() if ($email == 0) { - $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize()); + $rep = new FrontReport(_('REMITTANCE'), "RemittanceBulk", user_pagesize()); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); @@ -103,8 +103,6 @@ function print_remittances() else $types = array(ST_BANKPAYMENT, ST_SUPPAYMENT, ST_SUPPCREDIT); foreach ($types as $j) - //for ($j = ST_BANKPAYMENT; $j <= ST_SUPPAYMENT; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999)) - //for ($j = $ft; $j <= $tt; $j = ($j == ST_BANKPAYMENT ? ST_SUPPAYMENT : 999)) { $myrow = get_remittance($j, $i); if (!$myrow) @@ -126,7 +124,21 @@ function print_remittances() $rep->Header2($myrow, null, $myrow, $baccount, ST_SUPPAYMENT); $result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']); + $linetype = true; + $doctype = ST_SUPPAYMENT; + if ($rep->currency != $myrow['curr_code']) + { + include($path_to_root . "/reporting/includes/doctext2.inc"); + } + else + { + include($path_to_root . "/reporting/includes/doctext.inc"); + } + $total_allocated = 0; + $rep->TextCol(0, 4, $doc_Towards, -2); + $rep->NewLine(2); + while ($myrow2=db_fetch($result)) { $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2); @@ -144,16 +156,6 @@ function print_remittances() } $rep->row = $rep->bottomMargin + (15 * $rep->lineHeight); - $linetype = true; - $doctype = ST_SUPPAYMENT; - if ($rep->currency != $myrow['curr_code']) - { - include($path_to_root . "/reporting/includes/doctext2.inc"); - } - else - { - include($path_to_root . "/reporting/includes/doctext.inc"); - } $rep->TextCol(3, 6, $doc_Total_Allocated, -2); $rep->AmountCol(6, 7, $total_allocated, $dec, -2); @@ -165,6 +167,12 @@ function print_remittances() $rep->Font('bold'); $rep->TextCol(3, 6, $doc_Total_Payment, - 2); $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2); + $words = price_in_words($myrow['Total'], ST_SUPPAYMENT); + if ($words != "") + { + $rep->NewLine(2); + $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); + } $rep->Font(); if ($email == 1) { diff --git a/reporting/rep601.php b/reporting/rep601.php index 893c8d9d..7e443fb2 100644 --- a/reporting/rep601.php +++ b/reporting/rep601.php @@ -106,6 +106,10 @@ function print_bank_transactions() $rep->NewLine(2); if ($rows > 0) { + // Keep a running total as we loop through + // the transactions. + $total_debit = $total_credit = 0; + while ($myrow=db_fetch($trans)) { $total += $myrow['amount']; @@ -116,9 +120,15 @@ function print_bank_transactions() $rep->DateCol(3, 4, $myrow["trans_date"], true); $rep->TextCol(4, 5, payment_person_name($myrow["person_type_id"],$myrow["person_id"], false)); if ($myrow['amount'] > 0.0) + { $rep->AmountCol(5, 6, abs($myrow['amount']), $dec); + $total_debit += abs($myrow['amount']); + } else + { $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); + $total_credit += abs($myrow['amount']); + } $rep->AmountCol(7, 8, $total, $dec); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) @@ -129,6 +139,13 @@ function print_bank_transactions() } $rep->NewLine(); } + + // Print totals for the debit and credit columns. + $rep->TextCol(3, 5, _("Total Debit / Credit")); + $rep->AmountCol(5, 6, $total_debit, $dec); + $rep->AmountCol(6, 7, $total_credit, $dec); + $rep->NewLine(2); + $rep->Font('bold'); $rep->TextCol(3, 5, _("Ending Balance")); if ($total > 0.0) @@ -138,6 +155,14 @@ function print_bank_transactions() $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); + + // Print the difference between starting and ending balances. + $net_change = ($total - $prev_balance); + $rep->TextCol(3, 5, _("Net Change")); + if ($total > 0.0) + $rep->AmountCol(5, 6, $net_change, $dec, 0, 0, 0, 0, null, 1, True); + else + $rep->AmountCol(6, 7, $net_change, $dec, 0, 0, 0, 0, null, 1, True); } $rep->End(); } diff --git a/reporting/rep704.php b/reporting/rep704.php index 8986237d..b6b12c38 100644 --- a/reporting/rep704.php +++ b/reporting/rep704.php @@ -66,21 +66,22 @@ function print_GL_transactions() $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize()); $dec = user_price_dec(); - $cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); + //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570); + $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525); //------------0--1---2---3----4----5----6----7----8----9----10------- //-----------------------dim1-dim2----------------------------------- //-----------------------dim1---------------------------------------- //------------------------------------------------------------------- - $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); + $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right'); if ($dim == 2) - $headers = array(_('Type'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", + $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension')." 1", _('Dimension')." 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); elseif ($dim == 1) - $headers = array(_('Type'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), + $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); else - $headers = array(_('Type'), _('#'), _('Date'), "", "", _('Person/Item'), + $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance')); if ($dim == 2) @@ -132,12 +133,12 @@ function print_GL_transactions() if ($prev_balance == 0.0 && $rows == 0) continue; $rep->Font('bold'); - $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']); - $rep->TextCol(3, 5, _('Opening Balance')); + $rep->TextCol(0, 4, $account['account_code'] . " " . $account['account_name'], -2); + $rep->TextCol(4, 6, _('Opening Balance')); if ($prev_balance > 0.0) - $rep->AmountCol(6, 7, abs($prev_balance), $dec); - else $rep->AmountCol(7, 8, abs($prev_balance), $dec); + else + $rep->AmountCol(8, 9, abs($prev_balance), $dec); $rep->Font(); $total = $prev_balance; $rep->NewLine(2); @@ -147,19 +148,21 @@ function print_GL_transactions() { $total += $myrow['amount']; - $rep->TextCol(0, 1, $systypes_array[$myrow["type"]]); - $rep->TextCol(1, 2, $myrow['type_no']); - $rep->DateCol(2, 3, $myrow["tran_date"], true); + $rep->TextCol(0, 1, $systypes_array[$myrow["type"]], -2); + $reference = get_reference($myrow["type"], $myrow["type_no"]); + $rep->TextCol(1, 2, $reference); + $rep->TextCol(2, 3, $myrow['type_no'], -2); + $rep->DateCol(3, 4, $myrow["tran_date"], true); if ($dim >= 1) - $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id'])); + $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id'])); if ($dim > 1) - $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id'])); - $rep->TextCol(5, 6, payment_person_name($myrow["person_type_id"],$myrow["person_id"], false)); + $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id'])); + $rep->TextCol(6, 7, payment_person_name($myrow["person_type_id"],$myrow["person_id"], false)); if ($myrow['amount'] > 0.0) - $rep->AmountCol(6, 7, abs($myrow['amount']), $dec); - else $rep->AmountCol(7, 8, abs($myrow['amount']), $dec); - $rep->TextCol(8, 9, number_format2($total, $dec)); + else + $rep->AmountCol(8, 9, abs($myrow['amount']), $dec); + $rep->TextCol(9, 10, number_format2($total, $dec)); $rep->NewLine(); if ($rep->row < $rep->bottomMargin + $rep->lineHeight) { @@ -170,11 +173,11 @@ function print_GL_transactions() $rep->NewLine(); } $rep->Font('bold'); - $rep->TextCol(3, 5, _("Ending Balance")); + $rep->TextCol(4, 6, _("Ending Balance")); if ($total > 0.0) - $rep->AmountCol(6, 7, abs($total), $dec); - else $rep->AmountCol(7, 8, abs($total), $dec); + else + $rep->AmountCol(8, 9, abs($total), $dec); $rep->Font(); $rep->Line($rep->row - $rep->lineHeight + 4); $rep->NewLine(2, 1); diff --git a/reporting/rep705.php b/reporting/rep705.php index ad10656c..607b446c 100644 --- a/reporting/rep705.php +++ b/reporting/rep705.php @@ -236,7 +236,7 @@ function print_annual_expense_breakdown() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); @@ -332,7 +332,7 @@ function print_annual_expense_breakdown() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); diff --git a/reporting/rep706.php b/reporting/rep706.php index 1ef4a9d7..58d60599 100644 --- a/reporting/rep706.php +++ b/reporting/rep706.php @@ -164,7 +164,7 @@ function print_balance_sheet() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); @@ -281,7 +281,7 @@ function print_balance_sheet() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); diff --git a/reporting/rep707.php b/reporting/rep707.php index 15690a09..0516c17e 100644 --- a/reporting/rep707.php +++ b/reporting/rep707.php @@ -191,7 +191,7 @@ function print_profit_and_loss_statement() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); @@ -295,7 +295,7 @@ function print_profit_and_loss_statement() { for ( ; $level >= 0, $typename[$level] != ''; $level--) { - if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0) + if ($account['parent'] == $closing[$level] || $account['parent'] < $last || $account['parent'] <= 0 || $closeclass) { $rep->row += 6; $rep->Line($rep->row); diff --git a/reporting/rep709.php b/reporting/rep709.php index 4baf0105..3fc4c637 100644 --- a/reporting/rep709.php +++ b/reporting/rep709.php @@ -143,7 +143,11 @@ function print_tax_report() $rep->Header(); } } - if (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) { + if ($trans['trans_type']==ST_JOURNAL && $trans['amount']<0) { + $taxes[$trans['tax_type_id']]['taxout'] -= $trans['amount']; + $taxes[$trans['tax_type_id']]['out'] -= $trans['net_amount']; + } + elseif (in_array($trans['trans_type'], array(ST_BANKDEPOSIT,ST_SALESINVOICE,ST_CUSTCREDIT))) { $taxes[$trans['tax_type_id']]['taxout'] += $trans['amount']; $taxes[$trans['tax_type_id']]['out'] += $trans['net_amount']; } else { diff --git a/reporting/reports_main.php b/reporting/reports_main.php index a36a043c..d1ba1b36 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -103,6 +103,17 @@ $reports->addReport(_('Customer'),111,_('&Print Sales Quotations'), _('Currency Filter') => 'CURRENCY', _('Email Customers') => 'YES_NO', _('Comments') => 'TEXTBOX')); +$reports->addReport(_('Customer'),111,_('&Print Sales Quotations'), + array( _('From') => 'QUOTATIONS', + _('To') => 'QUOTATIONS', + _('Currency Filter') => 'CURRENCY', + _('Email Customers') => 'YES_NO', + _('Comments') => 'TEXTBOX')); +$reports->addReport(_('Customer'),112,_('Print Receipts'), + array( _('From') => 'RECEIPT', + _('To') => 'RECEIPT', + _('Currency Filter') => 'CURRENCY', + _('Comments') => 'TEXTBOX')); $reports->addReportClass(_('Supplier')); $reports->addReport(_('Supplier'),201,_('Supplier &Balances'), diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 9f4630a4..565d9f95 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -19,6 +19,7 @@ include_once($path_to_root . "/includes/banking.inc"); include_once($path_to_root . "/includes/data_checks.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); //include_once($path_to_root . "/sales/includes/ui/cust_alloc_ui.inc"); +include_once($path_to_root . "/reporting/includes/reporting.inc"); $js = ""; if ($use_popup_windows) { @@ -60,14 +61,15 @@ if (isset($_GET['AddedID'])) { display_notification_centered(_("The customer payment has been successfully entered.")); + submenu_print(_("&Print This Receipt"), ST_CUSTPAYMENT, $payment_no."-".ST_CUSTPAYMENT, 'prtopt'); + display_note(get_gl_view_str(ST_CUSTPAYMENT, $payment_no, _("&View the GL Journal Entries for this Customer Payment"))); // hyperlink_params($path_to_root . "/sales/allocations/customer_allocate.php", _("&Allocate this Customer Payment"), "trans_no=$payment_no&trans_type=12"); hyperlink_no_params($path_to_root . "/sales/customer_payments.php", _("Enter Another &Customer Payment")); - br(1); - end_page(); - exit; + + display_footer_exit(); } //---------------------------------------------------------------------------------------------- diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index de50c6aa..cf7b6682 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -128,6 +128,8 @@ function delete_sales_order($order_no, $trans_type) .db_escape($order_no) . " AND trans_type=".db_escape($trans_type); db_query($sql, "order Detail Delete"); + delete_reference($trans_type, $order_no); + add_audit_trail($trans_type, $order_no, Today(), _("Deleted.")); commit_transaction(); } diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index c350642a..e9d7a95e 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -115,6 +115,23 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu $prices[$myrow['sales_type_id']][$myrow['curr_abrev']] = $myrow['price']; } $price = false; + if (isset($prices[$sales_type_id][$currency])) + { + $price = $prices[$sales_type_id][$currency]; + } + elseif (isset($prices[$base_id][$currency])) + { + $price = $prices[$base_id][$currency] * $factor; + } + elseif (isset($prices[$sales_type_id][$home_curr])) + { + $price = $prices[$sales_type_id][$home_curr] / $rate; + } + elseif (isset($prices[$base_id][$home_curr])) + { + $price = $prices[$base_id][$home_curr] * $factor / $rate; + } +/* if (isset($prices[$sales_type_id][$home_curr])) { $price = $prices[$sales_type_id][$home_curr] / $rate; @@ -127,6 +144,7 @@ function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=nu { $price = $prices[$base_id][$home_curr] * $factor / $rate; } +*/ elseif ($num_rows == 0 && $add_pct != -1) { $price = get_calculated_price($stock_id, $add_pct); diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index 8029dc9c..8bd2d4c7 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -194,7 +194,9 @@ function edit_link($row) function prt_link($row) { if ($row['type'] != ST_CUSTPAYMENT && $row['type'] != ST_BANKDEPOSIT) // customer payment or bank deposit printout not defined yet. - return print_document_link($row['trans_no'], _("Print"), true, $row['type'], ICON_PRINT); + return print_document_link($row['trans_no']."-".$row['type'], _("Print"), true, $row['type'], ICON_PRINT); + else + return print_document_link($row['trans_no']."-".$row['type'], _("Print Receipt"), true, ST_CUSTPAYMENT, ICON_PRINT); } function check_overdue($row) diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index b2483063..32e5c3b5 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -201,9 +201,16 @@ if (isset($_GET['AddedID'])) { submenu_view(_("&View This Invoice"), ST_SALESINVOICE, $invoice); - submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice, 'prtopt'); - submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice, null, 1); + submenu_print(_("&Print Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, 'prtopt'); + submenu_print(_("&Email Sales Invoice"), ST_SALESINVOICE, $invoice."-".ST_SALESINVOICE, null, 1); set_focus('prtopt'); + + $sql = "SELECT trans_type_from, trans_no_from FROM ".TB_PREF."cust_allocations + WHERE trans_type_to=".ST_SALESINVOICE." AND trans_no_to=".db_escape($invoice); + $result = db_query($sql, "could not retrieve customer allocation"); + $row = db_fetch($result); + if ($row !== false) + submenu_print(_("Print &Receipt"), $row['trans_type_from'], $row['trans_no_from']."-".$row['trans_type_from'], 'prtopt'); display_note(get_gl_view_str(ST_SALESINVOICE, $invoice, _("View the GL &Journal Entries for this Invoice")),0, 1); @@ -237,7 +244,7 @@ function copy_to_cart() if ($cart->cash) { $cart->due_date = $cart->document_date; $cart->phone = $cart->cust_ref = $cart->delivery_address = ''; - $cart->freight_cost = 0; + $cart->freight_cost = input_num('freight_cost'); $cart->ship_via = 1; $cart->deliver_to = '';//$_POST['deliver_to']; } else { @@ -332,6 +339,7 @@ function can_process() { return false; } + if (strlen($_POST['delivery_address']) <= 1) { display_error( _("You should enter the street address in the box provided. Orders cannot be accepted without a valid street address.")); set_focus('delivery_address'); @@ -364,6 +372,14 @@ function can_process() { return false; } } + else + { + if (!db_has_cash_accounts()) + { + display_error(_("You need to define a cash account for your Sales Point.")); + return false; + } + } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); @@ -498,27 +514,28 @@ function handle_cancel_order() if ($_SESSION['Items']->trans_type == ST_CUSTDELIVERY) { - display_note(_("Direct delivery entry has been cancelled as requested."), 1); - submenu_option(_("Enter a New Sales Delivery"), $_SERVER['PHP_SELF']."?NewDelivery=0"); + display_notification(_("Direct delivery entry has been cancelled as requested."), 1); + submenu_option(_("Enter a New Sales Delivery"), "/sales/sales_order_entry.php?NewDelivery=1"); } elseif ($_SESSION['Items']->trans_type == ST_SALESINVOICE) { - display_note(_("Direct invoice entry has been cancelled as requested."), 1); - submenu_option(_("Enter a New Sales Invoice"), $_SERVER['PHP_SELF']."?NewInvoice=0"); + display_notification(_("Direct invoice entry has been cancelled as requested."), 1); + submenu_option(_("Enter a New Sales Invoice"), "/sales/sales_order_entry.php?NewInvoice=1"); } else { if ($_SESSION['Items']->trans_no != 0) { - if (sales_order_has_deliveries(key($_SESSION['Items']->trans_no))) + if ($_SESSION['Items']->trans_type == ST_SALESORDER && + sales_order_has_deliveries(key($_SESSION['Items']->trans_no))) display_error(_("This order cannot be cancelled because some of it has already been invoiced or dispatched. However, the line item quantities may be modified.")); else { delete_sales_order(key($_SESSION['Items']->trans_no), $_SESSION['Items']->trans_type); if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) { - display_note(_("This sales quotation has been cancelled as requested."), 1); - submenu_option(_("Enter a New Sales Quotation"), $_SERVER['PHP_SELF']."?NewQuotation=Yes"); + display_notification(_("This sales quotation has been cancelled as requested."), 1); + submenu_option(_("Enter a New Sales Quotation"), "/sales/sales_order_entry.php?NewQuotation=Yes"); } else { - display_note(_("This sales order has been cancelled as requested."), 1); - submenu_option(_("Enter a New Sales Order"), $_SERVER['PHP_SELF']."?NewOrder=Yes"); + display_notification(_("This sales order has been cancelled as requested."), 1); + submenu_option(_("Enter a New Sales Order"), "/sales/sales_order_entry.php?NewOrder=Yes"); } } } else { @@ -528,9 +545,7 @@ function handle_cancel_order() } $Ajax->activate('_page_body'); processing_end(); - br(1); - end_page(); - exit; + display_footer_exit(); } //-------------------------------------------------------------------------------- @@ -634,7 +649,6 @@ if ($_SESSION['Items']->trans_type == ST_SALESINVOICE) { start_form(); hidden('cart_id'); - $customer_error = display_order_header($_SESSION['Items'], ($_SESSION['Items']->any_already_delivered() == 0), $idate); diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index c1597a2a..239b41a2 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -249,6 +249,7 @@ INSERT INTO `0_chart_master` VALUES ('2110', '', 'Accrued Income Tax - Federal', INSERT INTO `0_chart_master` VALUES ('2120', '', 'Accrued Income Tax - State', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2130', '', 'Accrued Franchise Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2140', '', 'Accrued Real & Personal Prop Tax', '4', '0'); +INSERT INTO `0_chart_master` VALUES ('2145', '', 'Purchase Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2150', '', 'Sales Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2160', '', 'Accrued Use Tax Payable', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2210', '', 'Accrued Wages', '4', '0'); @@ -1925,7 +1926,7 @@ CREATE TABLE `0_tax_types` ( ### Data of table `0_tax_types` ### -INSERT INTO `0_tax_types` VALUES ('1', '5', '2150', '2150', 'Tax', '0'); +INSERT INTO `0_tax_types` VALUES ('1', '5', '2150', '2145', 'Tax', '0'); ### Structure of table `0_trans_tax_details` ### diff --git a/sql/en_US-new.sql b/sql/en_US-new.sql index 0abbc967..d107e9ba 100644 --- a/sql/en_US-new.sql +++ b/sql/en_US-new.sql @@ -231,6 +231,7 @@ INSERT INTO `0_chart_master` VALUES ('2110', '', 'Accrued Income Tax - Federal', INSERT INTO `0_chart_master` VALUES ('2120', '', 'Accrued Income Tax - State', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2130', '', 'Accrued Franchise Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2140', '', 'Accrued Real & Personal Prop Tax', '4', '0'); +INSERT INTO `0_chart_master` VALUES ('2145', '', 'Purchase Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2150', '', 'Sales Tax', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2160', '', 'Accrued Use Tax Payable', '4', '0'); INSERT INTO `0_chart_master` VALUES ('2210', '', 'Accrued Wages', '4', '0'); @@ -1704,7 +1705,7 @@ CREATE TABLE `0_tax_types` ( ### Data of table `0_tax_types` ### -INSERT INTO `0_tax_types` VALUES ('1', '5', '2150', '2150', 'Tax', '0'); +INSERT INTO `0_tax_types` VALUES ('1', '5', '2150', '2145', 'Tax', '0'); ### Structure of table `0_trans_tax_details` ### diff --git a/taxes/tax_types.php b/taxes/tax_types.php index 87b3f255..14af1c19 100644 --- a/taxes/tax_types.php +++ b/taxes/tax_types.php @@ -38,7 +38,7 @@ function can_process() return false; } - if (!is_tax_gl_unique(get_post('sales_gl_code', 'purchasing_gl_code', $selected_id))) { + if (!is_tax_gl_unique(get_post('sales_gl_code'), get_post('purchasing_gl_code'), $selected_id)) { display_error( _("Selected GL Accounts cannot be used by another tax type.")); set_focus('sales_gl_code'); return false; diff --git a/update.html b/update.html index 2f6a2adb..01bdeee0 100644 --- a/update.html +++ b/update.html @@ -13,12 +13,12 @@
  • You can easily upload all the files to your installation folder on the server overwriting the existing files. From 2.2 RC, your existing configuration files, - config_db.php, config.php, /lang/installed_languages.inc and installed_extensions.php - will nolonger be installed. They are created the first time you install FrontAccounting and don't need further updates.