From 2383d33373d6ddec06906658a0ed6398077c1147 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Thu, 25 Jun 2009 14:11:58 +0000 Subject: [PATCH] Merged changes from main branch up to 2.1.3. --- CHANGELOG.txt | 363 + admin/backups.php | 38 +- admin/company_preferences.php | 52 +- admin/view_print_transaction.php | 4 +- applications/setup.php | 2 +- config.php | 17 +- dimensions/inquiry/search_dimensions.php | 2 +- gl/gl_journal.php | 7 +- gl/includes/db/gl_db_account_types.inc | 12 - gl/includes/db/gl_db_accounts.inc | 20 +- gl/includes/db/gl_db_trans.inc | 43 + gl/includes/ui/gl_bank_ui.inc | 10 +- gl/inquiry/gl_trial_balance.php | 33 +- gl/inquiry/tax_inquiry.php | 5 +- gl/manage/gl_account_classes.php | 23 +- includes/data_checks.inc | 6 +- includes/db/manufacturing_db.inc | 164 +- includes/errors.inc | 21 +- includes/references.inc | 16 +- includes/session.inc | 8 +- includes/types.inc | 38 +- includes/ui/db_pager_view.inc | 5 +- includes/ui/ui_lists.inc | 91 +- includes/ui/ui_view.inc | 15 +- install.html | 4 +- inventory/inquiry/stock_status.php | 39 +- inventory/manage/items.php | 5 +- inventory/manage/locations.php | 40 + inventory/manage/sales_kits.php | 2 +- inventory/prices.php | 2 - inventory/purchasing_data.php | 8 +- .../LC_MESSAGES/empty.po | 10506 +++++++--------- .../db/work_order_produce_items_db.inc | 10 +- manufacturing/includes/db/work_orders_db.inc | 66 +- .../includes/db/work_orders_quick_db.inc | 84 +- manufacturing/includes/manufacturing_ui.inc | 19 +- manufacturing/inquiry/bom_cost_inquiry.php | 19 +- manufacturing/manage/bom_edit.php | 13 +- manufacturing/search_work_orders.php | 15 +- manufacturing/view/work_order_view.php | 9 +- manufacturing/work_order_add_finished.php | 44 +- manufacturing/work_order_costs.php | 165 + manufacturing/work_order_entry.php | 82 +- manufacturing/work_order_issue.php | 12 +- manufacturing/work_order_release.php | 6 +- .../allocations/supplier_allocation_main.php | 4 +- purchasing/includes/db/grn_db.inc | 22 +- purchasing/includes/db/invoice_db.inc | 33 +- purchasing/includes/db/po_db.inc | 4 +- purchasing/includes/purchasing_db.inc | 17 + purchasing/includes/ui/po_ui.inc | 10 +- purchasing/inquiry/po_search_completed.php | 8 + purchasing/inquiry/supplier_inquiry.php | 3 +- purchasing/po_receive_items.php | 2 +- purchasing/supplier_credit.php | 6 + purchasing/supplier_invoice.php | 12 +- reporting/includes/class.mail.inc | 21 +- reporting/includes/pdf_report.inc | 5 +- reporting/includes/reports_classes.inc | 30 +- reporting/rep109.php | 2 +- reporting/rep209.php | 10 +- reporting/rep302.php | 71 +- reporting/rep303.php | 100 +- reporting/rep701.php | 41 +- reporting/rep705.php | 175 +- reporting/rep706.php | 197 +- reporting/rep707.php | 171 +- reporting/rep708.php | 30 - reporting/reports_main.php | 1 + sales/create_recurrent_invoices.php | 2 +- sales/customer_delivery.php | 9 +- sales/includes/db/sales_order_db.inc | 42 - sales/includes/ui/sales_order_ui.inc | 3 +- sales/inquiry/sales_orders_view.php | 4 +- sales/manage/customer_branches.php | 2 +- sales/sales_order_entry.php | 4 + sql/alter2.2.sql | 4 +- sql/en_US-demo.sql | 1344 +- sql/en_US-new.sql | 237 +- taxes/db/tax_types_db.inc | 24 +- taxes/tax_types.php | 9 + update.html | 10 +- 82 files changed, 7036 insertions(+), 7778 deletions(-) create mode 100644 manufacturing/work_order_costs.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d5985553..eeb8e93a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,89 @@ Legend: ! -> Note $ -> Affected files +25-Jun-2009 Janusz Dobrowolski +! Merged changes from main trunk 2.1.2-2.1.3 (see below) +$ /admin/backups.php + /admin/company_preferences.php + /admin/view_print_transaction.php + /applications/setup.php + /config.php + /dimensions/inquiry/search_dimensions.php + /gl/gl_journal.php + /gl/includes/db/gl_db_accounts.inc + /gl/includes/db/gl_db_account_types.inc + /gl/includes/db/gl_db_trans.inc + /gl/includes/ui/gl_bank_ui.inc + /gl/inquiry/gl_trial_balance.php + /gl/inquiry/tax_inquiry.php + /gl/manage/gl_account_classes.php + /includes/data_checks.inc + /includes/db/manufacturing_db.inc + /includes/errors.inc + /includes/main.inc + /includes/references.inc + /includes/session.inc + /includes/types.inc + /includes/ui/db_pager_view.inc + /includes/ui/ui_lists.inc + /includes/ui/ui_view.inc + /inventory/inquiry/stock_status.php + /inventory/manage/items.php + /inventory/manage/locations.php + /inventory/manage/sales_kits.php + /inventory/prices.php + /inventory/purchasing_data.php + /lang/new_language_template/LC_MESSAGES/empty.po + /manufacturing/includes/db/work_orders_db.inc + /manufacturing/includes/db/work_orders_produce_items_db.inc + /manufacturing/includes/db/work_orders_quick_db.inc + /manufacturing/includes/manufacturing_ui.inc + /manufacturing/inquiry/bom_cost_inquiry.php + /manufacturing/manage/bom_edit.php + /manufacturing/search_work_orders.php + /manufacturing/view/work_order_view.php + /manufacturing/work_order_add_finished.php + /manufacturing/work_order_costs.php (new file) + /manufacturing/work_order_entry.php + /manufacturing/work_order_issue.php + /manufacturing/work_order_release.php + /purchase/po_receive_items.php + /purchasing/allocations/supplier_allocation_main.php + /purchasing/includes/db/grn_db.inc + /purchasing/includes/db/invoice_db.inc + /purchasing/includes/db/po_db.inc + /purchasing/includes/purchasing_db.inc + /purchasing/includes/ui/po_ui.inc + /purchasing/inquiry/po_search_completed.php + /purchasing/inquiry/supplier_inquiry.php + /purchasing/supplier_credit.php + /purchasing/supplier_invoice.php + /reporting/includes/class.mail.inc + /reporting/includes/pdf.report.inc + /reporting/includes/reports_classes.inc + /reporting/rep109.php + /reporting/rep209.php + /reporting/rep302.php + /reporting/rep302.php + /reporting/rep303.php + /reporting/rep303.php + /reporting/rep701.php + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + /reporting/rep708.php + /reporting/reports_main.php + /sales/create_recurrent_invoices.php + /sales/customer_delivery.php + /sales/includes/db/sales_order_db.inc + /sales/includessales_order_ui.inc + /sales/inquiry/sales_orders_view.php + /sales/manage/customer_branches.php + /sql/en_US-demo.sql + /sql/en_US-new.sql + /taxes/db/tax_types_db.inc + /taxes/tax_types.php + 17-Jun-2009 Janusz Dobrowolski # Fixed supplier payment view link $ /includes/ui/ui_view.inc @@ -563,6 +646,286 @@ $ /.htaccess /sales/inquiry/sales_deliveries_view.php /sales/inquiry/sales_orders_view.php +------------------------------- Release 2.1.3 ---------------------------------- +25-Jun-2009 Joe Hunt +! Release 2.1.3 +$ config.php + /sql/en_US-new.sql + /sql/en_US-demo.sql +! Suppressed menu on access denied in view popup windows. +$ /includes/session.inc + /includes/main.inc +! New empty.po file + /lang/new_language_template/LC_MESSAGES/empty.po + +23-Jun-2009 Janusz Dobrowolski +! Added edition link in Purchase Order Inquiry +$ /purchasing/includes/ui/po_ui.inc + /purchasing/inquiry/po_search_completed.php + +23-Jun-2009 Joe Hunt +# [0000137] Material Cost Averaging Problem (again) when voiding. +$ /purchasing/includes/db/invoice_db.inc + +21-Jun-2009 Joe Hunt +# If no additional costs (overhead/labour) it should reduce the average additional costs. +$ /manufacturing/includes/db/work_orders_quick_db.inc + +20-Jun-2009 Janusz Dobrowolski +! Php notices removed from logging to avoid flood from @ constructs. +$ /includes/errors.inc +# [0000135] Direct posting to gl accounts with more than one related tax type forbidden. +$ /gl/gl_journal.php + /includes/ui/ui_view.inc + /purchasing/supplier_credit.php + /purchasing/supplier_invoice.php + /taxes/tax_types.php + /taxes/db/tax_types_db.inc + +20-Jun-2009 Joe Hunt/Tu Nguyen +# [0000137] Material Cost Averaging Problem when voiding Supp Inv and qoh reaches 0. +$ /purchasing/includes/db/grn_db.inc + +18-Jun-2009 Joe Hunt +! Better support for conversion_factor in Purchasing Pricing. Instruction on Sticky Inventory Forum. +$ /inventory/purchasing_data.php + /purchasing/includes/purchasing_db.inc + /purchasing/includes/db/po_db.inc + /purchasing/includes/ui/po_ui.inc + +17-Jun-2009 Janusz Dobrowolski +# Fixed form reset after error, allowed png logo files. +$ /admin/company_preferences.php +! Removed unneeded submit_on_change in uom selector. +$ /includes/ui/ui_lists.inc +# Allowed reuse of supplier references from voided invoices. +$ /purchasing/supplier_invoice.php +# Total payment/credit sign fix. +$ /purchasing/allocations/supplier_allocation_main.php +# Voided documents should not be displayed. +$ /purchasing/inquiry/supplier_inquiry.php + +17-Jun-2009 Joe Hunt/Tu Nguyen +# [0000136] view_po on invoices and credits shows transactions from other suppliers +$ /purchasing/includes/db/invoice_db.inc + +16-Jun-2009 Janusz Dobrowolski +! Added error logging to file or syslog. +$ /config.php + /includes/errors.inc +# Cleaned output buffering notices. +$ /includes/errors.inc + /includes/session.inc + +15-Jun-2009 Joe Hunt +! Added Item Code Entry in Work Order Entry and quantity decimals now follows the item +! Clean-up in ui_list codes. +$ /includes/ui/ui_lists.inc + /manufacturing/work_order_entry.php + /manufacturing/search_work_orders.php + /manufacturing/manage/bom_edit.php + /manufacturing/inquiry/bom_cost_inquiry.php + +14-Jun-2009 Joe Hunt +! Much better presentation of new Balance Sheet, P&L Statement and Monthly Breakdown. +$ /gl/includes/db/gl_db_account_types.inc + /gl/includes/db/gl_db_accounts.inc + /includes/types.inc + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php +! New variable in config.php, $use_oldstyle_convert, if set to 1, same convert as in old versions. +$ config.php + +13-Jun-2009 Joe Hunt/Pete/Tom Moulton +! Changed next reference method to also include partly alpha characters in front, fi. WA036 increments to WA037 +$ /includes/references.inc +! Improved email sending of documents. With help of Tom Moulton +$ /reporting/rep109.php + /reporting/rep209.php + /reporting/includes/class.mail.inc + /reporting/includes/pdf.report.inc + +12-Jun-2009 Joe Hunt +! Code clean-up +$ /gl/includes/db/gl_db_trans.inc + /gl/inquiry/gl_trial_balance.php + /includes/ui/ui_view.inc + /reporting/rep708.php + +11-Jun-2009 Joe Hunt +! Changed balance_sheet operation in class table to class type for sign convert in Balance Sheet, Profit and Loss Statement and Monthly Breakdown +$ /gl/manage/gl_account_classes.php + /gl/includes/db/gl_db_account_types.inc + /gl/includes/db/gl_db_accounts.inc + /gl/inquiry/gl_trial_balance.php + /includes/types.inc + /includes/ui/ui_lists.inc + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + /reporting/rep708.php + +09-Jun-2009 Joe Hunt +# Bad format in due date column in search dimensions +$ /dimensions/inquiry/search_dimensions.php + +08-Jun-2009 Joe Hunt +! Changed Advanced Manufacturing payments to be more flexible and simpler. Removed from Payment. +$ /gl/includes/db/gl_db_trans.inc + /gl/includes/ui/gl_bank_ui.inc + /includes/types.inc + /includes/ui/ui_lists.inc + /manufacturing/search_work_orders.php + /manufacturing/work_order_costs.php (new file) + /manufacturing/work_order_entry.php +# Overhead costs in Manufacturing/Assembling wasn't added to stock overhead cost +$ /manufacturing/work_order_add_finished.php + /manufacturing/work_order_issue.php + /manufacturing/work_order_release.php + /manufacturing/includes/manufacturing_ui.inc + /manufacturing/includes/db/work_orders_db.inc + /manufacturing/includes/db/work_orders_quick_db.inc + /manufacturing/includes/db/work_orders_produce_items_db.inc + /manufacturing/view/work_order_view.php + +05-Jun-2009 Joe Hunt +# Missing underscore in gettext string +$ /sales/create_recurrent_invoices.php +# Broken gettext string over 2 lines +$ /sales/customer_delivery.php + +04-Jun-2009 Joe Hunt +# [0000134] Voiding a supplier credit note didn't activate the PO Receivals and void the stock moves. +$ /purchasing/includes/db/invoice_db.inc + +03-Jun-2009 Joe Hunt +! Changed to present reference number in Print Invoices/Credit Notes if global $print_invoice_no = 0 +$ /reporting/includes/reports_classes.inc +# Deleting of Locations was too easy. Implemented much more checks +$ /inventory/manage/locations.php +! Report Stock Check Sheet and 'Inventory Item Status' was wrong when Locations were selected. +$ /reporting/rep302.php + /reporting/rep303.php + /includes/db/manufacturing_db.inc +# When producing advanced manufacture there should be errors when insuffient qoh in items (if 'Allow Negative Stock' is not marked). +$ /manufacturing/work_order_issue.php + /manufacturing/work_order_add_finished.php +# Missing decimal calculation in BOM edit. +$ /manufacturing/manage/bom_edit.php +# Wrong toottip text on Process button in Purchase Order, Receive Items. +$ /purchase/po_receive_items.php + +27-May-2009 Joe Hunt +# After heavy testing a new set of nested subtypes in COA, Monthly Breakdown, Balance Sheet and P&L Statement. +$ /gl/includes/db/gl_db_accounts.inc + /gl/includes/db/gl_db_account_types.inc + /reporting/rep701.php + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php + +26-May-2009 Joe Hunt +# Again fixed nested subtypes in account types correctly in COA, Monthly Breakdown, Balance Sheet and P&L Statement +$ /gl/includes/db/gl_db_accounts.inc + /gl/includes/db/gl_db_account_types.inc + /reporting/rep701.php + /reporting/rep705.php + /reporting/rep706.php + /reporting/rep707.php +# fixed wider combobox for backup-files in company backup +$ /admin/backups.php + +25-May-2009 Joe Hunt +# Fixed Supplier Credit so Purchase Order Outstanding is decreased too. +$ /purchasing/includes/db/grn_db.inc +# Fixed so nested subtypes in account types are nested correctly in Balance Sheet and P&L Statement +$ /gl/includes/db/gl_db_accounts.inc + /reporting/rep706.php + /reporting/rep707.php +! Extra column in Stock Check Sheet, On Order and option for selecting Only Shortage. +$ /reporting/rep303.php + /reporting/reports_main.php + +23-May-2009 Janusz Dobrowolski +# Fixed transaction table search update. +$ /admin/view_print_transaction.php +# Fixed initial select for array_selector() +$ /includes/ui/ui_lists.inc + +22-May-2009 Janusz Dobrowolski +# Fixed buggy reference instead of id in report dimension selectors. +$ /reporting/includes/reports_classes.inc +# Fixed typo in setup menu +$ /applications/setup.php + +21-May-2009 Joe Hunt/Tom Moulton +# Recursion fix in manufacturing_db.inc by Tom Moulton +$ /includes/db/manufacturing_db.inc + +20-May-2009 Janusz Dobrowolski +# Small cleanup +$ /inventory/prices.php +# Fixed select buttons icon. +$ /sales/manage/customer_branches.php + +20-May-2009 Joe Hunt +# Fixed and optimized On Order in Inventory Items Status and reports +$ /includes/db/manufacturing_db.inc + /inventory/inquiry/stock_status.php + /reporting/rep302.php + /reporting/rep303.php + /sales/includes/db/sales_order_db.inc + +18-May-2009 Joe Hunt +# html header shown in backup downloads. +$ /admin/backups.php +! Reinserted the link to GL in Work Order Inquiry. +$ /manufacturing/search_work_orders.php +# Added non closed work order requirements on On Order in Inventory Items Status +$ /inventory/inquiry/stock_status.php +! Added mb_flag 'M' in demand checks +$ /sales/includes/db/sales_order_db.inc + /reporting/rep302.php + /reporting/rep303.php + +17-May-2009 Joe Hunt +! Changed service items to use cogs account instead of inventory account. +$ /inventory/manage/items.php + +16-May-2009 Joe Hunt +# [0000133] Removed buggy & obsolete hotkey support in pager_link() +$ /includes/ui/db_pager_view.inc +! Removed obsolete 'K' mb_flag checks. +$ /includes/data_checks.inc + /includes/ui/ui_lists.inc + +13-May-2009 Joe Hunt +# Bug in demensions_list. If dimensions are closed they shall NOT show up in the lists. +$ /includes/ui/ui_lists.inc + +10-May-2009 Joe Hunt +# Period presentation bug in tax report/inquiry +$ /gl/inquiry/tax_inquiry.php + /reporting/includes/reports_classes.inc + +07-May-2009 Joe Hunt +# Layout bug in exchange rate display +$ /includes/ui/ui_view.inc +# Layout bug in sales_order_view. Column Comments renamed to Cust Order Ref +$ /sales/inquiry/sales_orders_view.php +# Layout bug in sales_order_ui. Bad presentation of customer if not editable +$ /sales/includessales_order_ui.inc + +05-May-2009 Janusz Dobrowolski +# Fixed check if code for new sales kit is not used. +$ /inventory/manage/sales_kits.php + +04-May-2009 Joe Hunt +# Purchase Order document shows wrong purch data conversion if purch data +$ /reporting/rep209.php + + ------------------------------- Release 2.1.2 ---------------------------------- 30-Apr-2009 Joe Hunt ! Release 2.1.2 diff --git a/admin/backups.php b/admin/backups.php index dd8c6639..18ca9972 100644 --- a/admin/backups.php +++ b/admin/backups.php @@ -16,6 +16,24 @@ include_once($path_to_root . "/includes/session.inc"); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/admin/db/maintenance_db.inc"); +if (get_post('view')) { + $filename = BACKUP_PATH . get_post('cmb_backups'); + if (in_ajax()) + $Ajax->popup( $filename ); + else { + header('Content-type: application/octet-stream'); + header('Content-Length: '.filesize($filename)); + header("Content-Disposition: inline; filename=$filename"); + readfile($filename); + exit(); + } +}; + +if (get_post('download')) { + download_file(BACKUP_PATH . get_post('cmb_backups')); + exit; +} + page(_("Backup and Restore Database"), false, false, '', ''); check_paths(); @@ -61,7 +79,7 @@ function get_backup_file_combo() if (preg_match("/.sql(.zip|.gz)?$/", $file)) $opt_files .= ""; - $selector = ""; + $selector = ""; $Ajax->addUpdate('cmd_backups', "_cmd_backups_sel", $selector); $selector = "".$selector."\n"; @@ -111,24 +129,6 @@ if (get_post('restore')) { display_notification(_("Restore backup completed.")); } -if (get_post('view')) { - $filename = BACKUP_PATH . get_post('cmb_backups'); - if (in_ajax()) - $Ajax->popup( $filename ); - else { - header('Content-type: application/octet-stream'); - header('Content-Length: '.filesize($filename)); - header("Content-Disposition: inline; filename=$filename"); - readfile($filename); - exit(); - } -}; - -if (get_post('download')) { - download_file(BACKUP_PATH . get_post('cmb_backups')); - exit; -} - if (get_post('delete')) { if (unlink(BACKUP_PATH . get_post('cmb_backups'))) { display_notification(_("File successfully deleted.")." " diff --git a/admin/company_preferences.php b/admin/company_preferences.php index 648d260f..6bcb0dbd 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -44,9 +44,10 @@ if (isset($_POST['update']) && $_POST['update'] != "") $filename .= "/".$_FILES['pic']['name']; //But check for the worst - if (strtoupper(substr(trim($_FILES['pic']['name']), strlen($_FILES['pic']['name']) - 3)) != 'JPG') + if (!in_array((substr(trim($_FILES['pic']['name']),-3)), + array('jpg','JPG','png','PNG'))) { - display_error(_('Only jpg files are supported - a file extension of .jpg is expected')); + display_error(_('Only jpg and png files are supported - a file extension of .jpg or .png is expected')); $input_error = 1; } elseif ( $_FILES['pic']['size'] > ($max_image_size * 1024)) @@ -113,29 +114,30 @@ if (isset($_POST['update']) && $_POST['update'] != "") start_form(true); - -$myrow = get_company_prefs(); - -$_POST['coy_name'] = $myrow["coy_name"]; -$_POST['gst_no'] = $myrow["gst_no"]; -$_POST['tax_prd'] = $myrow["tax_prd"]; -$_POST['tax_last'] = $myrow["tax_last"]; -$_POST['coy_no'] = $myrow["coy_no"]; -$_POST['postal_address'] = $myrow["postal_address"]; -$_POST['phone'] = $myrow["phone"]; -$_POST['fax'] = $myrow["fax"]; -$_POST['email'] = $myrow["email"]; -$_POST['coy_logo'] = $myrow["coy_logo"]; -$_POST['domicile'] = $myrow["domicile"]; -$_POST['use_dimension'] = $myrow["use_dimension"]; -$_POST['base_sales'] = $myrow["base_sales"]; -$_POST['no_item_list'] = $myrow["no_item_list"]; -$_POST['no_customer_list'] = $myrow["no_customer_list"]; -$_POST['no_supplier_list'] = $myrow["no_supplier_list"]; -$_POST['curr_default'] = $myrow["curr_default"]; -$_POST['f_year'] = $myrow["f_year"]; -$_POST['time_zone'] = $myrow["time_zone"]; -$_POST['version_id'] = $myrow["version_id"]; +if (!isset($_POST['coy_name'])) { + $myrow = get_company_prefs(); + + $_POST['coy_name'] = $myrow["coy_name"]; + $_POST['gst_no'] = $myrow["gst_no"]; + $_POST['tax_prd'] = $myrow["tax_prd"]; + $_POST['tax_last'] = $myrow["tax_last"]; + $_POST['coy_no'] = $myrow["coy_no"]; + $_POST['postal_address'] = $myrow["postal_address"]; + $_POST['phone'] = $myrow["phone"]; + $_POST['fax'] = $myrow["fax"]; + $_POST['email'] = $myrow["email"]; + $_POST['coy_logo'] = $myrow["coy_logo"]; + $_POST['domicile'] = $myrow["domicile"]; + $_POST['use_dimension'] = $myrow["use_dimension"]; + $_POST['base_sales'] = $myrow["base_sales"]; + $_POST['no_item_list'] = $myrow["no_item_list"]; + $_POST['no_customer_list'] = $myrow["no_customer_list"]; + $_POST['no_supplier_list'] = $myrow["no_supplier_list"]; + $_POST['curr_default'] = $myrow["curr_default"]; + $_POST['f_year'] = $myrow["f_year"]; + $_POST['time_zone'] = $myrow["time_zone"]; + $_POST['version_id'] = $myrow["version_id"]; +} $_POST['del_coy_logo'] = 0; start_outer_table($table_style2); diff --git a/admin/view_print_transaction.php b/admin/view_print_transaction.php index d6d8ca3b..94c22416 100644 --- a/admin/view_print_transaction.php +++ b/admin/view_print_transaction.php @@ -82,8 +82,6 @@ function check_valid_entries() display_error(_("The ending transaction number is expected to be numeric and greater than zero.")); return false; } - if (!isset($_POST['filterType']) || $_POST['filterType'] == "") - return false; return true; } @@ -139,7 +137,7 @@ function handle_search() } $table =& new_db_pager('transactions', $sql, $cols); - if (list_updated('filterType')) { + if (list_updated('filterType') || get_post('ProcessSearch')) { $table->set_sql($sql); $table->set_columns($cols); } diff --git a/applications/setup.php b/applications/setup.php index 3bb5578d..d380ee8a 100644 --- a/applications/setup.php +++ b/applications/setup.php @@ -35,7 +35,7 @@ $this->add_rapp_function(1, _("&Points of Sale"),"sales/manage/sales_points.php?"); $this->add_rapp_function(1, _("&Printers"),"admin/printers.php?"); - $this->add_module(_("Maintanance")); + $this->add_module(_("Maintenance")); $this->add_lapp_function(2, _("&Void a Transaction"),"admin/void_transaction.php?"); $this->add_lapp_function(2, _("View or &Print Transactions"),"admin/view_print_transaction.php?"); $this->add_lapp_function(2, _("&Attach Documents"),"admin/attachments.php?filterType=20"); diff --git a/config.php b/config.php index 7c3d6410..52f10e6f 100644 --- a/config.php +++ b/config.php @@ -20,7 +20,11 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root'])) die("Restricted access"); - + // Log file for error/warning messages. Should be set to any location + // writable by www server. When set to empty string logging is switched off. + // Special value 'syslog' can be used for system logger usage (see php manual). + $error_logfile = ''; + //$error_logfile = dirname(__FILE__).'/tmp/errors.log'; $debug = 1; $show_sql = 0; $go_debug = 0; @@ -43,10 +47,16 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // ini_alter("error_reporting","E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_PARSE"); ini_set("display_errors", "On"); } + + if($error_logfile != '') { + ini_set("error_log", $error_logfile); + ini_set("ignore_repeated_errors", "On"); + ini_set("log_errors", "On"); + } // Main Title $app_title = "FrontAccounting"; // application version - $version = "2.2 CVS"; + $version = "2.2m3 CVS"; // Build for development purposes $build_version = date("d.m.Y", filemtime("$path_to_root/CHANGELOG.txt")); @@ -64,6 +74,9 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ /* use Audit Trails in GL */ $use_audit_trail = 0; + /* use old style convert (income and expense in BS, PL) */ + $use_oldstyle_convert = 0; + /* Integrated base Wiki Help URL or null if not used */ //$help_base_url = $path_to_root.'/modules/wiki/index.php?n='._('Help').'.'; $help_base_url = null; diff --git a/dimensions/inquiry/search_dimensions.php b/dimensions/inquiry/search_dimensions.php index fb261b94..29ee8709 100644 --- a/dimensions/inquiry/search_dimensions.php +++ b/dimensions/inquiry/search_dimensions.php @@ -172,7 +172,7 @@ $cols = array( _("Name"), _("Type"), _("Date") =>'date', - _("Due Date") => array('name'=>'due_date', 'date', 'ord'=>'asc'), + _("Due Date") => array('name'=>'due_date', 'type'=>'date', 'ord'=>'asc'), _("Closed") => array('fun'=>'is_closed'), _("Balance") => array('type'=>'amount', 'insert'=>true, 'fun'=>'sum_dimension'), array('insert'=>true, 'fun'=>'edit_link') diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 5bff9165..3ce28e3a 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -232,7 +232,12 @@ function check_item_data() set_focus('AmountCredit'); return false; } - + + if (!is_tax_gl_unique(get_post('code_id'))) { + display_error(_("Cannot post to GL account used by more than one tax type.")); + set_focus('code_id'); + return false; + } if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) { diff --git a/gl/includes/db/gl_db_account_types.inc b/gl/includes/db/gl_db_account_types.inc index d0f2b785..80d4fe3a 100644 --- a/gl/includes/db/gl_db_account_types.inc +++ b/gl/includes/db/gl_db_account_types.inc @@ -54,7 +54,6 @@ function get_account_type_name($id) return $row[0]; } - function delete_account_type($id) { $sql = "DELETE FROM ".TB_PREF."chart_types WHERE id = $id"; @@ -106,16 +105,6 @@ function get_account_class_name($id) return $row[0]; } -function get_sign_convert($account_type) -{ - $sql = "SELECT sign_convert FROM ".TB_PREF."chart_class INNER JOIN ".TB_PREF."chart_types ON - ".TB_PREF."chart_class.cid = ".TB_PREF."chart_types.class_id WHERE ".TB_PREF."chart_types.id=$account_type"; - $result = db_query($sql, "could not get sign convert"); - - $row = db_fetch_row($result); - return ($row[0]==1); -} - function delete_account_class($id) { $sql = "DELETE FROM ".TB_PREF."chart_class WHERE cid = $id"; @@ -123,5 +112,4 @@ function delete_account_class($id) db_query($sql, "could not delete account type"); } - ?> \ No newline at end of file diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index 9622ebc2..414ad8e2 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -51,13 +51,19 @@ function get_gl_accounts($from=null, $to=null) function get_gl_accounts_all($balance=-1) { - $sql = "SELECT ".TB_PREF."chart_master.*,".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_class.class_name AS AccountClassName - FROM ".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class - WHERE ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id AND - ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid"; + if ($balance == 1) + $where ="WHERE balance_sheet>0 AND balance_sheet<".CL_INCOME; + elseif ($balance == 0) + $where ="WHERE balance_sheet>".CL_EQUITY." OR balance_sheet=0"; // backwards compatibility + $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType, + ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID, + ".TB_PREF."chart_class.balance_sheet AS ClassType + FROM ".TB_PREF."chart_types INNER JOIN ".TB_PREF."chart_class ON ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid + LEFT JOIN ".TB_PREF."chart_master ON ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id "; if ($balance != -1) - $sql .= " AND ".TB_PREF."chart_class.balance_sheet=$balance"; - $sql .= " ORDER BY ".TB_PREF."chart_class.cid, ".TB_PREF."chart_types.id, ".TB_PREF."chart_master.account_code"; + $sql .= $where; + $sql .= " ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), + IF(parent > 0,".TB_PREF."chart_types.id, parent), ".TB_PREF."chart_master.account_code"; return db_query($sql, "could not get gl accounts"); } @@ -79,7 +85,7 @@ function is_account_balancesheet($code) $result = db_query($sql,"could not retreive the account class for $code"); $row = db_fetch_row($result); - return $row[0]; + return $row[0] > 0 && $row[0] < CL_INCOME; } function get_gl_account_name($code) diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index c956a5e2..d80dfe47 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -138,6 +138,19 @@ function get_gl_trans($type, $trans_id) //-------------------------------------------------------------------------------- +function get_gl_wo_cost_trans($trans_id, $person_id=-1) +{ + $sql = "SELECT ".TB_PREF."gl_trans.*, ".TB_PREF."chart_master.account_name FROM ".TB_PREF."gl_trans, ".TB_PREF."chart_master + WHERE ".TB_PREF."chart_master.account_code=".TB_PREF."gl_trans.account + AND ".TB_PREF."gl_trans.type=".systypes::work_order()." AND ".TB_PREF."gl_trans.type_no=$trans_id + AND ".TB_PREF."gl_trans.person_type_id=".payment_person_types::WorkOrder(); + if ($person_id != -1) + $sql .= " AND ".TB_PREF."gl_trans.person_id=$person_id"; + $sql .= " AND amount < 0"; + + return db_query($sql, "The gl transactions could not be retrieved"); +} + function get_gl_balance_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0) { $from = date2sql($from_date); @@ -184,6 +197,36 @@ function get_gl_trans_from_to($from_date, $to_date, $account, $dimension=0, $dim return $row[0]; } +//---------------------------------------------------------------------------------------------------- +function get_balance($account, $dimension, $dimension2, $from, $to, $from_incl=true, $to_incl=true) +{ + $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) as debit, SUM(IF(amount < 0, -amount, 0)) as credit, SUM(amount) as balance + FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class + WHERE ".TB_PREF."gl_trans.account=".TB_PREF."chart_master.account_code AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id + AND ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid AND"; + + if ($account != null) + $sql .= " account='$account' AND"; + if ($dimension > 0) + $sql .= " dimension_id=$dimension AND"; + if ($dimension2 > 0) + $sql .= " dimension2_id=$dimension2 AND"; + $from_date = date2sql($from); + if ($from_incl) + $sql .= " tran_date >= '$from_date' AND"; + else + $sql .= " tran_date > IF(balance_sheet>0 AND balance_sheet<".CL_INCOME.", '0000-00-00', '$from_date') AND"; + $to_date = date2sql($to); + if ($to_incl) + $sql .= " tran_date <= '$to_date' "; + else + $sql .= " tran_date < '$to_date' "; + + $result = db_query($sql,"No general ledger accounts were returned"); + + return db_fetch($result); +} + //-------------------------------------------------------------------------------- function get_budget_trans_from_to($from_date, $to_date, $account, $dimension=0, $dimension2=0) diff --git a/gl/includes/ui/gl_bank_ui.inc b/gl/includes/ui/gl_bank_ui.inc index ccb3e33f..4693ec34 100644 --- a/gl/includes/ui/gl_bank_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -53,9 +53,9 @@ function display_bank_header(&$order) text_row_ex($payment ?_("To the Order of:"):_("Name:"), 'person_id', 40, 50); break; - case payment_person_types::WorkOrder() : - workorders_list_row(_("Work Order:"), 'person_id', null); - break; + //case payment_person_types::WorkOrder() : + // workorders_list_row(_("Work Order:"), 'person_id', null); + // break; case payment_person_types::supplier() : supplier_list_row(_("Supplier:"), 'person_id', null, false, true); break; @@ -223,8 +223,8 @@ function gl_edit_item_controls(&$order, $dim, $Index=null) $acc = get_supplier_accounts($_POST['person_id']); $_POST['code_id'] = $acc['payable_account']; } - elseif ($_POST['PayType'] == payment_person_types::WorkOrder()) - $_POST['code_id'] = get_company_pref('default_assembly_act'); + //elseif ($_POST['PayType'] == payment_person_types::WorkOrder()) + // $_POST['code_id'] = get_company_pref('default_assembly_act'); else { $_POST['code_id'] = get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act'); diff --git a/gl/inquiry/gl_trial_balance.php b/gl/inquiry/gl_trial_balance.php index 2ea606ee..deaa0b41 100644 --- a/gl/inquiry/gl_trial_balance.php +++ b/gl/inquiry/gl_trial_balance.php @@ -53,33 +53,6 @@ function gl_inquiry_controls() //---------------------------------------------------------------------------------------------------- -function get_balance($account, $from, $to, $from_incl=true, $to_incl=true) -{ - $sql = "SELECT SUM(IF(amount >= 0, amount, 0)) AS debit, SUM(IF(amount < 0, -amount, 0)) AS credit, SUM(amount) AS balance - FROM ".TB_PREF."gl_trans,".TB_PREF."chart_master,".TB_PREF."chart_types, ".TB_PREF."chart_class - WHERE ".TB_PREF."gl_trans.account=".TB_PREF."chart_master.account_code AND ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id - AND ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid AND"; - - if ($account != null) - $sql .= " account='$account' AND"; - $from_date = date2sql($from); - if ($from_incl) - $sql .= " tran_date >= '$from_date' AND"; - else - $sql .= " tran_date > IF(".TB_PREF."chart_class.balance_sheet=1, '0000-00-00', '$from_date') AND"; - $to_date = date2sql($to); - if ($to_incl) - $sql .= " tran_date <= '$to_date' "; - else - $sql .= " tran_date < '$to_date' "; - - $result = db_query($sql,"No general ledger accounts were returned"); - - return db_fetch($result); -} - -//---------------------------------------------------------------------------------------------------- - function display_trial_balance() { global $table_style, $path_to_root; @@ -114,9 +87,9 @@ function display_trial_balance() while ($account = db_fetch($accounts)) { - $prev = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); - $curr = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); - $tot = get_balance($account["account_code"], $begin, $_POST['TransToDate'], false, true); + $prev = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransFromDate'], false, false); + $curr = get_balance($account["account_code"], 0, 0, $_POST['TransFromDate'], $_POST['TransToDate'], true, true); + $tot = get_balance($account["account_code"], 0, 0, $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) continue; alt_table_row_color($k); diff --git a/gl/inquiry/tax_inquiry.php b/gl/inquiry/tax_inquiry.php index db10eea0..39d90bb1 100644 --- a/gl/inquiry/tax_inquiry.php +++ b/gl/inquiry/tax_inquiry.php @@ -43,8 +43,9 @@ if (get_post('TransFromDate') == "" && get_post('TransToDate') == "") $row = get_company_prefs(); $edate = add_months($date, -$row['tax_last']); $edate = end_month($edate); - $bdate = add_months($edate, -$row['tax_prd'] + 1); - $_POST["TransFromDate"] = begin_month($bdate); + $bdate = begin_month($edate); + $bdate = add_months($bdate, -$row['tax_prd'] + 1); + $_POST["TransFromDate"] = $bdate; $_POST["TransToDate"] = $edate; } diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index 95eee370..7df38e2c 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -107,7 +107,7 @@ $result = get_account_classes(check_value('show_inactive')); start_form(); start_table($table_style); -$th = array(_("Class ID"), _("Class Name"), _("Balance Sheet"), _("Sign Convert"), "", ""); +$th = array(_("Class ID"), _("Class Name"), _("Class Type"), "", ""); inactive_control_column($th); table_header($th); @@ -117,26 +117,9 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); - if ($myrow["balance_sheet"] == 0) - { - $bs_text = _("No"); - } - else - { - $bs_text = _("Yes"); - } - if ($myrow["sign_convert"] == 0) - { - $sc_text = _("No"); - } - else - { - $sc_text = _("Yes"); - } label_cell($myrow["cid"]); label_cell($myrow['class_name']); - label_cell($bs_text); - label_cell($sc_text); + label_cell($class_types[$myrow["balance_sheet"]]); inactive_control_cell($myrow["cid"], $myrow["inactive"], 'chart_class', 'cid'); edit_button_cell("Edit".$myrow["cid"], _("Edit")); delete_button_cell("Delete".$myrow["cid"], _("Delete")); @@ -172,7 +155,7 @@ else text_row_ex(_("Class Name:"), 'name', 50, 60); -yesno_list_row(_("Balance Sheet:"), 'Balance', null, "", "", false); +class_types_list_row(_("Class Type:"), 'Balance', null); yesno_list_row(_("Sign Convert (Balance Sheet/PL statement):"), 'convert', null, "", "", false); diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 633daa87..8e03d584 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -269,7 +269,7 @@ function check_db_has_stock_items($msg) function db_has_bom_stock_items() { - return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag='M' OR mb_flag='K')"); + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag='M'"); } function check_db_has_bom_stock_items($msg) @@ -301,7 +301,7 @@ function check_db_has_manufacturable_items($msg) function db_has_purchasable_items() { - return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='M' AND mb_flag!='K')"); + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='M'"); } function check_db_has_purchasable_items($msg) @@ -317,7 +317,7 @@ function check_db_has_purchasable_items($msg) function db_has_costable_items() { - return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE (mb_flag!='D' AND mb_flag!='K')"); + return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE mb_flag!='D'"); } function check_db_has_costable_items($msg) diff --git a/includes/db/manufacturing_db.inc b/includes/db/manufacturing_db.inc index 622b6822..c2f34d9b 100644 --- a/includes/db/manufacturing_db.inc +++ b/includes/db/manufacturing_db.inc @@ -9,6 +9,168 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +//---------------------------------------------------------------------------------------- +function get_demand_qty($stock_id, $location) +{ + $sql = "SELECT SUM(".TB_PREF."sales_order_details.quantity - ".TB_PREF."sales_order_details.qty_sent) AS QtyDemand + 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 "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.stk_code = '$stock_id'"; + + $result = db_query($sql,"No transactions were returned"); + $row = db_fetch($result); + if ($row === false) + return 0; + return $row['QtyDemand']; +} + +$bom_list = array(); +$qoh_stock = NULL; + +function load_stock_levels($location) +{ + global $qoh_stock; + $date = date2sql(Today()); + + $sql = "SELECT stock_id, SUM(qty) FROM ".TB_PREF."stock_moves WHERE tran_date <= '$date'"; + if ($location != '') $sql .= " AND loc_code = '$location'"; + $sql .= " GROUP BY stock_id"; + $result = db_query($sql, "QOH calulcation failed"); + while ($row = db_fetch($result)) { + $qoh_stock[$row[0]] = $row[1]; + } +} + +// recursion fixed by Tom Moulton. Max 10 recursion levels. +function stock_demand_manufacture($stock_id, $qty, $demand_id, $location, $level=0) +{ + global $bom_list, $qoh_stock; + $demand = 0.0; + if ($level > 10) { + display_warning("BOM Too many Manufacturing levels deep $level"); + return $demand; + } + // Load all stock levels (stock moves) into $qoh_stock + if ($qoh_stock == NULL) { + $qoh_stock = array(); + load_stock_levels($location); + } + $stock_qty = $qoh_stock[$stock_id]; + if ($stock_qty == NULL) $stock_qty = 0; + if ($qty < $stock_qty) return $demand; + $bom = $bom_list[$stock_id]; + if ($bom == NULL) { + $sql = "SELECT parent, component, quantity FROM ".TB_PREF."bom WHERE parent = '$stock_id'"; + if ($location != "") $sql .= " AND loc_code = '$location'"; + $result = db_query($sql, "Could not search bom"); + $bom = array(); + // Even if we get no results, remember that fact + $bom[] = array($stock_id, '', 0); + while ($row = db_fetch_row($result)) { + $bom[] = array($row[0], $row[1], $row[2]); + } + db_free_result($result); + $bom_list[$stock_id] = $bom; + } + $len = count($bom); + $i = 0; + while ($i < $len) { + $row = $bom[$i]; + $i++; + // Ignore the dummy entry + if ($row[1] == '') continue; + $q = $qty * $row[2]; + if ($row[1] == $demand_id) $demand += $q; + $demand += stock_demand_manufacture($row[1], $q, $demand_id, $location, $level+1); + } + return $demand; +} + +// recursion fixed by Tom Moulton +function get_demand_asm_qty($stock_id, $location) +{ + $demand_qty = 0.0; + $sql = "SELECT ".TB_PREF."sales_order_details.stk_code, SUM(".TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent) + AS Demmand + 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 "; + if ($location != "") + $sql .= TB_PREF."sales_orders.from_stk_loc ='$location' AND "; + $sql .= TB_PREF."sales_order_details.quantity-".TB_PREF."sales_order_details.qty_sent > 0 AND + ".TB_PREF."stock_master.stock_id=".TB_PREF."sales_order_details.stk_code AND + (".TB_PREF."stock_master.mb_flag='M' OR ".TB_PREF."stock_master.mb_flag='A') + GROUP BY ".TB_PREF."sales_order_details.stk_code"; + $result = db_query($sql, "No transactions were returned"); + while ($row = db_fetch_row($result)) { + $demand_qty += stock_demand_manufacture($row[0], $row[1], $stock_id, $location); + } + return $demand_qty; +} + +function get_on_porder_qty($stock_id, $location) +{ + $sql = "SELECT SUM(".TB_PREF."purch_order_details.quantity_ordered - ".TB_PREF."purch_order_details.quantity_received) AS qoo + FROM ".TB_PREF."purch_order_details INNER JOIN ".TB_PREF."purch_orders ON ".TB_PREF."purch_order_details.order_no=".TB_PREF."purch_orders.order_no + WHERE ".TB_PREF."purch_order_details.item_code='$stock_id' "; + if ($location != "") + $sql .= "AND ".TB_PREF."purch_orders.into_stock_location='$location' "; + $sql .= "AND ".TB_PREF."purch_order_details.item_code='$stock_id'"; + $qoo_result = db_query($sql,"could not receive quantity on order for item"); + + if (db_num_rows($qoo_result) == 1) + { + $qoo_row = db_fetch_row($qoo_result); + $qoo = $qoo_row[0]; + } + else + { + $qoo = 0; + } + return $qoo; +} + +function get_on_worder_qty($stock_id, $location) +{ + $sql = "SELECT SUM((".TB_PREF."workorders.units_reqd-".TB_PREF."workorders.units_issued) * + (".TB_PREF."wo_requirements.units_req-".TB_PREF."wo_requirements.units_issued)) AS qoo + FROM ".TB_PREF."wo_requirements INNER JOIN ".TB_PREF."workorders + ON ".TB_PREF."wo_requirements.workorder_id=".TB_PREF."workorders.id + WHERE ".TB_PREF."wo_requirements.stock_id='$stock_id' "; + if ($location != "") + $sql .= "AND ".TB_PREF."wo_requirements.loc_code='$location' "; + $sql .= "AND ".TB_PREF."workorders.released=1"; + $qoo_result = db_query($sql,"could not receive quantity on order for item"); + if (db_num_rows($qoo_result) == 1) + { + $qoo_row = db_fetch_row($qoo_result); + $qoo = $qoo_row[0]; + } + else + $qoo = 0.0; + $flag = get_mb_flag($stock_id); + if ($flag == 'A' || $flag == 'M') + { + $sql = "SELECT SUM((".TB_PREF."workorders.units_reqd-".TB_PREF."workorders.units_issued)) AS qoo + FROM ".TB_PREF."workorders + WHERE ".TB_PREF."workorders.stock_id='$stock_id' "; + if ($location != "") + $sql .= "AND ".TB_PREF."workorders.loc_code='$location' "; + $sql .= "AND ".TB_PREF."workorders.released=1"; + $qoo_result = db_query($sql,"could not receive quantity on order for item"); + if (db_num_rows($qoo_result) == 1) + { + $qoo_row = db_fetch_row($qoo_result); + $qoo += $qoo_row[0]; + } + } + return $qoo; +} + function get_mb_flag($stock_id) { $sql = "SELECT mb_flag FROM ".TB_PREF."stock_master WHERE stock_id = '" . $stock_id . "'"; @@ -48,4 +210,4 @@ function has_bom($item) //-------------------------------------------------------------------------------------- -?> \ No newline at end of file +?> diff --git a/includes/errors.inc b/includes/errors.inc index 1c0f2f97..566d9f49 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -17,12 +17,15 @@ $before_box = ''; // temporary container for output html data before error box // display in message box. function error_handler($errno, $errstr, $file, $line) { - global $messages; + global $messages, $go_debug; // error_reporting==0 when messages are set off with @ - if ($errno & error_reporting()) { - $messages[] = array($errno, $errstr, $file, $line); - } + if ($errno & error_reporting()) + $messages[] = array($errno, $errstr, $file, $line); + else if($errno&~E_NOTICE)// log all not displayed messages + error_log(user_company() . ':' . $_SESSION["wa_current_user"]->loginname.':' + . basename($file) .":$line: $errstr"); + return true; } //------------------------------------------------------------------------------ @@ -72,12 +75,18 @@ function error_box() { global $before_box; echo "
"; - $before_box = ob_get_clean(); // save html content before error box + $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('ob_end_flush'); + register_shutdown_function('end_flush'); ob_start('output_html'); echo "
"; } +/* + Helper to avoid sparse log notices. +*/ +function end_flush () { + if (ob_get_level()) ob_end_flush(); +} function display_db_error($msg, $sql_statement=null, $exit=true) { diff --git a/includes/references.inc b/includes/references.inc index 1f945599..260c7a76 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -56,10 +56,20 @@ class references function increment($reference) { - if (is_numeric($reference)) - return $reference + 1; + // New method done by Pete. So f.i. WA036 will increment to WA037 and so on. + // If $reference is trailed by digits, and digits only, + // extract them and add 1, then put the alpha prefix back on + // NB. preg_match returns 1 if the regex matches completely + // also $result[0] holds entire string, 1 the first captured, 2 the 2nd etc. + if (preg_match('/^(.*?)(\d+)$/', $reference, $result) == 1) + { + $dig_count = strlen($result[2]); // How many digits? eg. 0003 = 4 + $fmt = '%0' . $dig_count . 'd'; // Make a format string - leading zeroes + $nextval = $result[1] . sprintf($fmt, intval($result[2] + 1)); // Add one on, and put prefix back on + return $nextval; + } else - return $reference; + return $reference; } //------------------------------------ diff --git a/includes/session.inc b/includes/session.inc index f8d8c1e6..65b62f55 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -61,7 +61,11 @@ function check_page_security($page_security) if (!$_SESSION["wa_current_user"]->can_access_page($page_security)) { - page(_("Access denied")); + // no_menu parameter guess here is ugly hack, but works for now. + // Better solution is to use global switch for menu, set before + // session.inc inclusion. + page(_("Access denied"), strpos($_SERVER['PHP_SELF'], '/view/')); + echo "



"; echo _("The security settings on your account do not permit you to access this function"); echo ""; @@ -141,7 +145,7 @@ $Ajax =& new Ajax(); $Validate = array(); // intercept all output to destroy it in case of ajax call -register_shutdown_function('ob_end_flush'); +register_shutdown_function('end_flush'); ob_start('output_html',0); // colect all error msgs diff --git a/includes/types.inc b/includes/types.inc index f1db9b1b..6039829e 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -216,8 +216,8 @@ class payment_person_types $qe = get_quick_entry($person_id); return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"]; case payment_person_types::WorkOrder() : - $wo = get_work_order($person_id); - return ($full?payment_person_types::type_name($type) . " ":"") . $wo["wo_ref"]; + global $wo_cost_types; + return $wo_cost_types[$person_id]; case payment_person_types::customer() : return ($full?payment_person_types::type_name($type) . " ":"") . get_customer_name($person_id); case payment_person_types::supplier() : @@ -309,6 +309,39 @@ class wo_types } } +define('CL_NONE', 0); // for backward compatibility +define('CL_ASSETS', 1); +define('CL_LIABILITIES', 2); +define('CL_EQUITY', 3); +define('CL_INCOME', 4); +define('CL_COGS', 5); +define('CL_EXPENSE', 6); + +$class_types = array( + CL_ASSETS => _("Assets"), + CL_LIABILITIES => _("Liabilities"), + CL_EQUITY => _("Equity"), + CL_INCOME => _("Income"), + CL_COGS => _("Cost of Goods Sold"), + CL_EXPENSE => _("Expense"), +); + +function get_class_type_convert($ctype) +{ + global $use_oldstyle_convert; + if (isset($use_oldstyle_convert) && $use_oldstyle_convert == 1) + return (($ctype >= CL_INCOME || $ctype == CL_NONE) ? -1 : 1); + else + return ((($ctype >= CL_LIABILITIES && $ctype <= CL_INCOME) || $ctype == CL_NONE) ? -1 : 1); +} +define('WO_LABOUR', 0); +define('WO_OVERHEAD', 1); + +$wo_cost_types = array( + WO_LABOUR => _("Labour Cost"), + WO_OVERHEAD => _("Overhead Cost"), +); + $quick_actions = array( '=' => _('Remainder'), // post current base amount to GL account 'a' => _('Amount'), // post amount to GL account @@ -343,5 +376,4 @@ $stock_types = array( 'B' => _("Purchased"), 'D' => _("Service") ); - ?> \ No newline at end of file diff --git a/includes/ui/db_pager_view.inc b/includes/ui/db_pager_view.inc index 7fe7754e..ce3ae3dd 100644 --- a/includes/ui/db_pager_view.inc +++ b/includes/ui/db_pager_view.inc @@ -14,12 +14,11 @@ function pager_link($link_text, $url, $icon=false) { global $path_to_root; - $link = access_string($link_text); if (user_graphic_links() && $icon) - $link[0] = set_icon($icon, $link[0]); + $link_text = set_icon($icon, $link_text); $href = $path_to_root . $url; - return "" . $link[0] . ""; + return "" . $link_text . ""; } function navi_button($name, $value, $enabled=true, $icon = false) { diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index bde06e22..0076a145 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -68,7 +68,7 @@ $opts = array( // default options if (!is_array($opts['where'])) $opts['where'] = array($opts['where']); $search_box = $opts['search_box']===true ? '_'.$name.'_edit' : $opts['search_box']; - $search_submit = $opts['search_submit']===true ? '_'.$name.'_button' : $opts['search_submit']; + $search_submit = $opts['search_submit']]===true ? '_'.$name.'_button' : $opts['search_submit']; $select_submit = $opts['select_submit']===true ? '_'.$name.'_update' : $opts['select_submit']; $spec_id = $opts['spec_id']; $spec_option = $opts['spec_option']; @@ -307,7 +307,7 @@ $opts = array( // default options //if($name=='SelectStockFromList') display_error($sql); foreach($items as $value=>$descr) { $sel = ''; - if ($selected_id == $value) { + if ((string)$selected_id === (string)$value) { $sel = 'selected'; $found = $value; } @@ -328,8 +328,9 @@ $opts = array( // default options } if ($found === false) { - $_POST[$name] = $first_id; + $selected_id = $first_id; } + $_POST[$name] = $selected_id; $aspect = $opts['edit_submit'] ? " aspect='editable'" : ''; $selector = "