From: Janusz Dobrowolski Date: Sun, 13 Sep 2009 21:17:48 +0000 (+0000) Subject: Eliminated non-static method calls and some more fixes to avoid log warnings on php4&5 X-Git-Tag: v2.4.2~19^2~1250 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=286e6233d6d7d63fbaafea42475ecbd5f4cf0dd0;p=fa-stable.git Eliminated non-static method calls and some more fixes to avoid log warnings on php4&5 --- diff --git a/includes/JsHttpRequest.php b/includes/JsHttpRequest.php index 12dbf686..1ef9a815 100644 --- a/includes/JsHttpRequest.php +++ b/includes/JsHttpRequest.php @@ -230,12 +230,12 @@ class JsHttpRequest $result = array(); if ($isList) { foreach ($a as $v) { - $result[] = JsHttpRequest::php2js($v); + $result[] = $this->php2js($v); } return '[ ' . join(', ', $result) . ' ]'; } else { foreach ($a as $k => $v) { - $result[] = JsHttpRequest::php2js($k) . ': ' . JsHttpRequest::php2js($v); + $result[] = $this->php2js($k) . ': ' . $this->php2js($v); } return '{ ' . join(', ', $result) . ' }'; } diff --git a/includes/banking.inc b/includes/banking.inc index cf532ea0..301a3729 100644 --- a/includes/banking.inc +++ b/includes/banking.inc @@ -164,7 +164,9 @@ function exchange_from_to($amount, $from_curr_code, $to_curr_code, $date_) function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $amount, $person_type, $neg=false) { - if ($person_type == payment_person_types::customer()) + global $systypes_array; + + if ($person_type == PT_CUSTOMER) { $trans = get_customer_trans($trans_no, $type); $pyt_trans = get_customer_trans($pyt_no, $pyt_type); @@ -190,20 +192,20 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am if ($inv_amt != $pay_amt) { $diff = $inv_amt - $pay_amt; - if ($person_type == payment_person_types::supplier()) + if ($person_type == PT_SUPPLIER) $diff = -$diff; if ($neg) $diff = -$diff; $exc_var_act = get_company_pref('exchange_diff_act'); if (date1_greater_date2($date, $pyt_date)) { - $memo = systypes::name($pyt_type)." ".$pyt_no; + $memo = $systypes_array[$pyt_type]." ".$pyt_no; add_gl_trans($type, $trans_no, $date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id); add_gl_trans($type, $trans_no, $date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id); } else { - $memo = systypes::name($type)." ".$trans_no; + $memo = $systypes_array[$type]." ".$trans_no; add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id); add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id); } diff --git a/includes/errors.inc b/includes/errors.inc index 566d9f49..68c26488 100644 --- a/includes/errors.inc +++ b/includes/errors.inc @@ -19,6 +19,15 @@ $before_box = ''; // temporary container for output html data before error box function error_handler($errno, $errstr, $file, $line) { global $messages, $go_debug; + // skip well known warnings we don't care about. + // Please use restrainedly to not risk loss of important messages + $excluded_warnings = array('html_entity_decode', 'htmlspecialchars'); + foreach($excluded_warnings as $ref) { + if (strpos($errstr, $ref) !== false) { + return true; + } + } + // error_reporting==0 when messages are set off with @ if ($errno & error_reporting()) $messages[] = array($errno, $errstr, $file, $line); diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index 4c4f1633..cc2f04d0 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -25,194 +25,21 @@ define('GETTEXT_NATIVE', 1); define('GETTEXT_PHP', 2); -/** -* Generic gettext static class. -* -* This class allows gettext usage with php even if the gettext support is -* not compiled in php. -* -* The developper can choose between the GETTEXT_NATIVE support and the -* GETTEXT_PHP support on initialisation. If native is not supported, the -* system will fall back to PHP support. -* -* On both systems, this package add a variable interpolation system so you can -* translate entire dynamic sentences in stead of peace of sentences. -* -* Small example without pear error lookup : -* -* -* -* A gettext mini-howto should be provided with this package, if you're new -* to gettext usage, please read it to learn how to build a gettext -* translation directory (locale). -* -* @todo Tools to manage gettext files in php. -* -* - non traducted domains / keys -* - modification of keys -* - domain creation, preparation, delete, ... -* - tool to extract required messages from TOF templates -* -* @version 0.5 -* @author Laurent Bedubourg -*/ -class get_text -{ - /** - * This method returns current gettext support class. - * - * @return GetText_Support - * @static 1 - * @access private - */ - function &_support($set=false) - { - static $support_obj; - if ($set !== false) - { - $support_obj = $set; - } - elseif (!isset($support_obj)) - { - trigger_error("get_text not initialized !". '\n'. - "Please call get_text::init() before calling ". - "any get_text function !" . '\n' , E_USER_ERROR); - } - return $support_obj; - } - - /** - * Initialize gettext package. - * - * This method instantiate the gettext support depending on managerType - * value. - * - * GETTEXT_NATIVE try to use gettext php support and fall back to PHP - * support if not installed. - * - * GETTEXT_PHP explicitely request the usage of PHP support. - * - * @param int $managerType - * Gettext support type. - * - * @access public - * @static 1 - */ - function init($managerType = GETTEXT_NATIVE) - { +function get_text_init($managerType = GETTEXT_NATIVE) { + + if (!isset($_SESSION['get_text'])) { + if ($managerType == GETTEXT_NATIVE) { if (function_exists('gettext')) { - return get_text::_support(new gettext_native_support()); + $_SESSION['get_text'] = new gettext_native_support(); + return; } } // fail back to php support - return get_text::_support(new gettext_php_support()); - } - - /** - * Set the language to use for traduction. - * - * @param string $lang_code - * The language code usually defined as ll_CC, ll is the two letter - * language code and CC is the two letter country code. - * - * @throws GetText_Error if language is not supported by your system. - */ - function set_language($lang_code, $encoding) - { - $support = &get_text::_support(); - return $support->set_language($lang_code, $encoding); - } - - /** - * Add a translation domain. - * - * The domain name is usually the name of the .po file you wish to use. - * For example, if you created a file 'lang/ll_CC/LC_MESSAGES/myapp.po', - * you'll use 'myapp' as the domain name. - * - * @param string $domain - * The domain name. - * - * @param string $path optional - * The path to the locale directory (ie: /path/to/locale/) which - * contains ll_CC directories. - */ - function add_domain($domain, $path=false) - { - $support =& get_text::_support(); - return $support->add_domain($domain, $path); - } - - /** - * Retrieve the translation for specified key. - * - * @param string $key - * String to translate using gettext support. - */ - function gettext($key) - { - $support = &get_text::_support(); - return $support->gettext($key); - } - - /** - * Add a variable to gettext interpolation system. - * - * @param string $key - * The variable name. - * - * @param string $value - * The variable value. - */ - function set_var($key, $value) - { - $support =& get_text::_support(); - return $support->set_var($key, $value); - } - - /** - * Add an hashtable of variables. - * - * @param hashtable $hash - * PHP associative array of variables. - */ - function set_vars($hash) - { - $support =& get_text::_support(); - return $support->set_vars($hash); - } - - /** - * Reset interpolation variables. - */ - function reset() - { - $support =& get_text::_support(); - return $support->reset(); - } + $_SESSION['get_text'] = new gettext_php_support(); + } } function raise_error($str) { @@ -243,7 +70,7 @@ class gettext_native_support putenv("LANG=$lang_code"); putenv("LC_ALL=$lang_code"); putenv("LANGUAGE=$lang_code"); - + //$set = setlocale(LC_ALL, "$lang_code"); //$set = setlocale(LC_ALL, "$encoding"); $set = setlocale(LC_ALL, $lang_code.".".$encoding); diff --git a/includes/lang/language.php b/includes/lang/language.php index a444838c..f9b86b17 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -57,10 +57,9 @@ class language // check id file exists only once for session $_SESSION['language']->is_locale_file = file_exists($locale); } - $lang = $_SESSION['language']; - get_text::set_language($lang->code, $lang->encoding); - get_text::add_domain($lang->code, $path_to_root . "/lang"); + $_SESSION['get_text']->set_language($lang->code, $lang->encoding); + $_SESSION['get_text']->add_domain($lang->code, $path_to_root . "/lang"); // Necessary for ajax calls. Due to bug in php 4.3.10 for this // version set globally in php.ini @@ -69,7 +68,7 @@ class language if (isset($_SESSION['App']) && $changed) $_SESSION['App']->init(); // refresh menu } - +} /** * This method loads an array of language objects into a session variable * called $_SESSIONS['languages']. Only supported languages are added. @@ -92,18 +91,16 @@ class language $_SESSION['language'] = $_SESSION['languages'][$dflt_lang]; } -} - function _set($key,$value) { - get_text::set_var($key,$value); + $_SESSION['get_text']->set_var($key,$value); } if (!function_exists("_")) { function _($text) { - $retVal = get_text::gettext($text); + $retVal = $_SESSION['get_text']->gettext($text); if ($retVal == "") return $text; return $retVal; diff --git a/includes/main.inc b/includes/main.inc index ee4417e2..1a2478e9 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -11,7 +11,6 @@ ***********************************************************************/ include_once($path_to_root . "/includes/db/connect_db.inc"); -include_once($path_to_root . "/includes/reserved.inc"); include_once($path_to_root . "/includes/errors.inc"); include_once($path_to_root . "/includes/types.inc"); include_once($path_to_root . "/includes/systypes.inc"); diff --git a/includes/page/footer.inc b/includes/page/footer.inc index 7256dfe1..90c951c1 100644 --- a/includes/page/footer.inc +++ b/includes/page/footer.inc @@ -19,12 +19,12 @@ function page_footer($no_menu=false, $is_index=false) $rend = new renderer(); $rend->menu_footer($no_menu, $is_index); - $edits = "editors = ".JsHttpRequest::php2js($Editors).";"; + $edits = "editors = ".$Ajax->php2js($Editors).";"; $Ajax->addScript('editors', $edits); echo ""; diff --git a/includes/prefs/sysprefs.inc b/includes/prefs/sysprefs.inc index 733a18b1..f8e78282 100644 --- a/includes/prefs/sysprefs.inc +++ b/includes/prefs/sysprefs.inc @@ -51,7 +51,6 @@ class sys_prefs function default_delivery_required_by() { return get_company_pref('default_delivery_required'); - return 1; } function default_dimension_required_by() diff --git a/includes/prefs/userprefs.inc b/includes/prefs/userprefs.inc index 32e92ce6..62bfd7e6 100644 --- a/includes/prefs/userprefs.inc +++ b/includes/prefs/userprefs.inc @@ -47,7 +47,7 @@ class user_prefs } else { $this->language = $user["language"]; - language::set_language($this->language); + $_SESSION['language']->set_language($this->language); $this->qty_dec = $user["qty_dec"]; $this->price_dec = $user["prices_dec"]; diff --git a/includes/references.inc b/includes/references.inc index 260c7a76..786ce62b 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -18,7 +18,7 @@ class references { add_reference($type, $id, $reference); if ($reference != 'auto') - references::save_last($reference, $type); + $this->save_last($reference, $type); } function get($type, $id) @@ -38,7 +38,7 @@ class references function save_last($reference, $type) { - $next = references::increment($reference); + $next = $this->increment($reference); save_next_reference($type, $next); } diff --git a/includes/reserved.inc b/includes/reserved.inc deleted file mode 100644 index 5cc1fcdd..00000000 --- a/includes/reserved.inc +++ /dev/null @@ -1,58 +0,0 @@ -. -***********************************************************************/ -// always use capitals in reserved words (for is_reserved_word comparisons) - -$any_item = 'AN'; -$any_number = -1; -$all_option = ''; -$all_option_numeric = -1; - -class reserved_words -{ - - function get_any() - { - global $any_item; - return $any_item; - } - - function get_any_numeric() - { - global $any_number; - return $any_number; - } - - function get_all() - { - global $all_option; - return $all_option; - } - - function get_all_numeric() - { - global $all_option_numeric; - return $all_option_numeric; - } - - function is_reserved_word($str) - { - $str = strtoupper($str); - if ($str == get_any()) - return true; - if ($str == get_all()) - return true; - return false; - } - -} - -?> \ No newline at end of file diff --git a/includes/session.inc b/includes/session.inc index 566c9a66..a306acf0 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -145,15 +145,15 @@ session_start(); // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks header("Cache-control: private"); -get_text::init(); +get_text_init(); // Page Initialisation if (!isset($_SESSION['languages'])) { - language::load_languages(); // sets also default $_SESSION['language'] + load_languages(); // sets also default $_SESSION['language'] } -language::set_language($_SESSION['language']->code); +$_SESSION['language']->set_language($_SESSION['language']->code); // include $Hooks object if locale file exists if(@include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) @@ -175,6 +175,10 @@ $Editors = array(); // page help. Currently help for function keys. $Pagehelp = array(); +$SysPrefs = new sys_prefs(); + +$Refs = new references(); + // intercept all output to destroy it in case of ajax call register_shutdown_function('end_flush'); ob_start('output_html',0); @@ -217,8 +221,8 @@ if (!$_SESSION["wa_current_user"]->logged_in()) // Incorrect password login_fail(); } - $lang = $_SESSION['language']; - language::set_language($_SESSION['language']->code); + $lang = &$_SESSION['language']; + $lang->set_language($_SESSION['language']->code); } } diff --git a/includes/types.inc b/includes/types.inc index 1d6c47f7..675ecb77 100644 --- a/includes/types.inc +++ b/includes/types.inc @@ -10,149 +10,80 @@ See the License here . ***********************************************************************/ //---------------------------------------------------------------------------------- +define('ST_JOURNAL', 0); + +define('ST_BANKPAYMENT', 1); +define('ST_BANKDEPOSIT', 2); +define('ST_BANKTRANSFER', 4); + +define('ST_SALESINVOICE', 10); +define('ST_CUSTCREDIT', 11); +define('ST_CUSTPAYMENT', 12); +define('ST_CUSTDELIVERY', 13); +define('ST_LOCTRANSFER', 16); +define('ST_INVADJUST', 17); +define('ST_PURCHORDER', 18); +define('ST_SUPPINVOICE', 20); +define('ST_SUPPCREDIT', 21); +define('ST_SUPPAYMENT', 22); +define('ST_SUPPRECEIVE', 25); + +define('ST_WORKORDER', 26); + +define('ST_SALESORDER', 30); +define('ST_SALESQUOTE', 32); +define('ST_COSTUPDATE', 35); +define('ST_DIMENSION', 40); + +define('ST_MANUISSUE', 28); +define('ST_MANURECEIVE', 29); $systypes_array = array ( - 0=> array ('name' => _("Journal Entry")), - 1=> array ('name' => _("Bank Payment")), - 2=> array ('name' => _("Bank Deposit")), - 4=> array ('name' => _("Funds Transfer")), - 10=> array ('name' => _("Sales Invoice")), - 11=> array ('name' => _("Customer Credit Note")), - 12=> array ('name' => _("Customer Payment")), - 13=> array ('name' => _("Delivery Note")), - 16=> array ('name' => _("Location Transfer")), - 17=> array ('name' => _("Inventory Adjustment")), - 18=> array ('name' => _("Purchase Order")), - 20=> array ('name' => _("Supplier Invoice")), - 21=> array ('name' => _("Supplier Credit Note")), - 22=> array ('name' => _("Supplier Payment")), - 25=> array ('name' => _("Purchase Order Delivery")), - 26=> array ('name' => _("Work Order")), - 28=> array ('name' => _("Work Order Issue")), - 29=> array ('name' => _("Work Order Production")), - 30=> array ('name' => _("Sales Order")), - 32=> array ('name' => _("Sales Quotation")), - 35=> array ('name' => _("Cost Update")), - 40=> array ('name' => _("Dimension")) - ); -class systypes -{ - - function journal_entry() - { - return 0; - } - - function bank_payment() - { - return 1; - } - - function bank_deposit() - { - return 2; - } - - function bank_transfer() - { - return 4; - } - - function cust_payment() - { - return 12; - } - - function cust_dispatch() - { - return 13; - } - - function location_transfer() - { - return 16; - } - - function inventory_adjustment() - { - return 17; - } - - function po() - { - return 18; - } - - function supp_payment() - { - return 22; - } - - function work_order() - { - return 26; - } - - function sales_order() - { - return 30; - } - - function sales_quotation() - { - return 32; - } - - function cost_update() - { - return 35; - } - - function dimension() - { - return 40; - } - - function name($index) - { - global $systypes_array; - if ($index < 0) - return ''; - return $systypes_array[$index]['name']; - } -} + ST_JOURNAL => _("Journal Entry"), + ST_BANKPAYMENT => _("Bank Payment"), + ST_BANKDEPOSIT => _("Bank Deposit"), + ST_BANKTRANSFER => _("Funds Transfer"), + ST_SALESINVOICE => _("Sales Invoice"), + ST_CUSTCREDIT => _("Customer Credit Note"), + ST_CUSTPAYMENT => _("Customer Payment"), + ST_CUSTDELIVERY => _("Delivery Note"), + ST_LOCTRANSFER => _("Location Transfer"), + ST_INVADJUST => _("Inventory Adjustment"), + ST_PURCHORDER => _("Purchase Order"), + ST_SUPPINVOICE => _("Supplier Invoice"), + ST_SUPPCREDIT => _("Supplier Credit Note"), + ST_SUPPAYMENT => _("Supplier Payment"), + ST_SUPPRECEIVE => _("Purchase Order Delivery"), + ST_WORKORDER => _("Work Order"), + ST_MANUISSUE => _("Work Order Issue"), + ST_MANURECEIVE => _("Work Order Production"), + ST_SALESORDER => _("Sales Order"), + ST_SALESQUOTE => _("Sales Quotation"), + ST_COSTUPDATE => _("Cost Update"), + ST_DIMENSION => _("Dimension") + ); //---------------------------------------------------------------------------------- - -$bank_account_types_array = array ( - 0=> array ('id' => 0, 'name' => _("Savings Account"), 'ptype' => _("Transfer")), - 1=> array ('id' => 1, 'name' => _("Chequing Account"),'ptype' => _("Cheque")), - 2=> array ('id' => 2, 'name' => _("Credit Account"), 'ptype' => _("Credit")), - 3=> array ('id' => 3, 'name' => _("Cash Account"), 'ptype' => _("Cash")) +define('BT_TRANSFER', 0); +define('BT_CHEQUE', 1); +define('BT_CREDIT', 2); +define('BT_CASH', 3); + +$bank_account_types = array ( + BT_TRANSFER => _("Savings Account"), + _("Chequing Account"), + _("Credit Account"), + _("Cash Account") ); -class bank_account_types -{ - - function get_all() - { - global $bank_account_types_array; - return $bank_account_types_array;; - } - - function name($index) - { - global $bank_account_types_array; - return $bank_account_types_array[$index]['name']; - } - - function transfer_type($index) - { - global $bank_account_types_array; - return $bank_account_types_array[$index]['ptype']; - } -} +$bank_transfer_types = array( + BT_TRANSFER => _("Transfer"), + _("Cheque"), + _("Credit"), + _("Cash") + ); +//---------------------------------------------------------------------------------- /* Menu tabs */ $tabs = array('orders'=>_("Sales"), 'AP'=>_("Purchases"), 'stock'=>_("Items and Inventory"), 'manuf'=>_("Manufacturing"), 'proj'=>_("Dimensions"), 'GL'=>_("Banking and General Ledger"), 'system'=>_("Setup")); @@ -164,162 +95,98 @@ include_once($path_to_root . "/purchasing/includes/purchasing_db.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/dimensions/includes/dimensions_db.inc"); -$payment_person_types_array = array ( - 0=> array ('id' => 0, 'name' => _("Miscellaneous")), - 1=> array ('id' => 1, 'name' => _("Work Order")), - 2=> array ('id' => 2, 'name' => _("Customer")), - 3=> array ('id' => 3, 'name' => _("Supplier")), - 4=> array ('id' => 4, 'name' => _("Quick Entry")) - ); +define('PT_MISC', 0); +define('PT_WORKORDER', 1); +define('PT_CUSTOMER', 2); +define('PT_SUPPLIER', 3); +define('PT_QUICKENTRY', 4); +define('PT_DIMESION', 5); + +$payment_person_types = array ( + PT_MISC => _("Miscellaneous"), + _("Work Order"), + _("Customer"), + _("Supplier"), + _("Quick Entry") + ); -class payment_person_types -{ - function get_all() +function payment_person_currency($type, $person_id) { + switch ($type) { - global $payment_person_types_array; - return $payment_person_types_array; - } + case PT_MISC : + case PT_QUICKENTRY : + case PT_WORKORDER : + return get_company_currency(); - function misc() - { - return 0; - } - - function WorkOrder() - { - return 1; - } - - function customer() - { - return 2; - } - - function supplier() - { - return 3; - } - - function QuickEntry() - { - return 4; - } - - function dimension() - { - return 5; - } - - function type_name($type) - { - global $payment_person_types_array; - return $payment_person_types_array[$type]['name']; - } - - function person_name($type, $person_id, $full=true) - { - switch ($type) - { - case payment_person_types::misc() : - return $person_id; - case payment_person_types::QuickEntry() : - $qe = get_quick_entry($person_id); - return ($full?payment_person_types::type_name($type) . " ":"") . $qe["description"]; - case payment_person_types::WorkOrder() : - 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() : - return ($full?payment_person_types::type_name($type) . " ":"") . get_supplier_name($person_id); - default : - //DisplayDBerror("Invalid type sent to person_name"); - //return; - return ''; - } - } - - function person_currency($type, $person_id) - { - switch ($type) - { - case payment_person_types::misc() : - case payment_person_types::QuickEntry() : - case payment_person_types::WorkOrder() : - return get_company_currency(); - - case payment_person_types::customer() : - return get_customer_currency($person_id); - - case payment_person_types::supplier() : - return get_supplier_currency($person_id); - - default : - return get_company_currency(); - } - } - - function has_items($type) - { - switch ($type) - { - case payment_person_types::misc() : - return true; - case payment_person_types::QuickEntry() : - return db_has_quick_entries(); - case payment_person_types::WorkOrder() : // 070305 changed to open workorders JH - return db_has_open_workorders(); - case payment_person_types::customer() : - return db_has_customers(); - case payment_person_types::supplier() : - return db_has_suppliers(); - default : - display_db_error("Invalid type sent to has_items", ""); - return false; - } - } -} - -//---------------------------------------------------------------------------------- + case PT_CUSTOMER : + return get_customer_currency($person_id); -$wo_types_array = array ( - 0=> array ('id' => 0, 'name' => _("Assemble")), - 1=> array ('id' => 1, 'name' => _("Unassemble")), - 2=> array ('id' => 2, 'name' => _("Advanced Manufacture")) - ); - -class wo_types -{ + case PT_SUPPLIER : + return get_supplier_currency($person_id); - function assemble() - { - return 0; + default : + return get_company_currency(); } +} - function unassemble() - { - return 1; - } +function payment_person_name($type, $person_id, $full=true) { + global $payment_person_types; - function advanced() - { - return 2; - } - - function get_all() + switch ($type) { - global $wo_types_array; - return $wo_types_array;; + case PT_MISC : + return $person_id; + case PT_QUICKENTRY : + $qe = get_quick_entry($person_id); + return ($full ? $payment_person_types[$type] . " ":"") . $qe["description"]; + case PT_WORKORDER : + global $wo_cost_types; + return $wo_cost_types[$person_id]; + case PT_CUSTOMER : + return ($full ?$payment_person_types[$type] . " ":"") . get_customer_name($person_id); + case PT_SUPPLIER : + return ($full ? $payment_person_types[$type] . " ":"") . get_supplier_name($person_id); + default : + //DisplayDBerror("Invalid type sent to person_name"); + //return; + return ''; } +} - function name($index) +function payment_person_has_items($type) { + switch ($type) { - global $wo_types_array; - return $wo_types_array[$index]['name']; + case PT_MISC : + return true; + case PT_QUICKENTRY : + return db_has_quick_entries(); + case PT_WORKORDER : // 070305 changed to open workorders JH + return db_has_open_workorders(); + case PT_CUSTOMER : + return db_has_customers(); + case PT_SUPPLIER : + return db_has_suppliers(); + default : + display_db_error("Invalid type sent to has_items", ""); + return false; } } +//---------------------------------------------------------------------------------- + +define('WO_ASSEMBLY', 0); +define('WO_UNASSEMBLY', 1); +define('WO_ADVANCED', 2); + +$wo_types_array = array ( + WO_ASSEMBLY => _("Assemble"), + WO_UNASSEMBLY => _("Unassemble"), + WO_ADVANCED => _("Advanced Manufacture") + ); + +//---------------------------------------------------------------------------------- + define('CL_NONE', 0); // for backward compatibility define('CL_ASSETS', 1); define('CL_LIABILITIES', 2); @@ -387,4 +254,13 @@ $stock_types = array( 'B' => _("Purchased"), 'D' => _("Service") ); + +/* + Special option values for various list selectors. +*/ +define('ANY_TEXT', ''); +define('ANY_NUMERIC', -1); +define('ALL_TEXT', ''); +define('ALL_NUMERIC', -1); + ?> \ No newline at end of file diff --git a/includes/ui/allocation_cart.inc b/includes/ui/allocation_cart.inc index 32cb1add..e1f45ce1 100644 --- a/includes/ui/allocation_cart.inc +++ b/includes/ui/allocation_cart.inc @@ -190,8 +190,8 @@ class allocation exchange_variation($this->type, $this->trans_no, $alloc_item->type, $alloc_item->type_no, $this->date_, $alloc_item->current_allocated, - $sup ? payment_person_types::supplier() - : payment_person_types::customer()); + $sup ? PT_SUPPLIER + : PT_CUSTOMER); ////////////////////////////////////////////////////////////// @@ -248,7 +248,7 @@ class allocation_item function show_allocatable($show_totals) { - global $table_style; + global $table_style, $systypes_array; $k = $counter = $total_allocated = 0; @@ -262,7 +262,7 @@ function show_allocatable($show_totals) { foreach ($_SESSION['alloc']->allocs as $alloc_item) { alt_table_row_color($k); - label_cell(systypes::name($alloc_item->type)); + label_cell($systypes_array[$alloc_item->type]); label_cell(get_trans_view_str($alloc_item->type, $alloc_item->type_no)); label_cell($alloc_item->date_, "align=right"); label_cell($alloc_item->due_date, "align=right"); @@ -312,6 +312,8 @@ function show_allocatable($show_totals) { function check_allocations() { + global $SysPrefs; + $total_allocated = 0; for ($counter = 0; $counter < $_POST["TotalNumberOfAllocs"]; $counter++) @@ -339,7 +341,7 @@ function check_allocations() if ($_SESSION['alloc']->type == 21 || $_SESSION['alloc']->type == 22) $amount = -$amount; - if ($total_allocated - ($amount + input_num('discount')) > sys_prefs::allocation_settled_allowance()) + if ($total_allocated - ($amount + input_num('discount')) > $SysPrefs->allocation_settled_allowance()) { display_error(_("These allocations cannot be processed because the amount allocated is more than the total amount left to allocate.")); return false; diff --git a/includes/ui/items_cart.inc b/includes/ui/items_cart.inc index b0d3a609..0f8b3c35 100644 --- a/includes/ui/items_cart.inc +++ b/includes/ui/items_cart.inc @@ -218,7 +218,9 @@ class line_item function check_qoh($location, $date_, $reverse) { - if (!sys_prefs::allow_negative_stock()) + global $SysPrefs; + + if (!$SysPrefs->allow_negative_stock()) { if (has_stock_holding($this->mb_flag)) { diff --git a/includes/ui/ui_globals.inc b/includes/ui/ui_globals.inc index b591f290..e8fd2b44 100644 --- a/includes/ui/ui_globals.inc +++ b/includes/ui/ui_globals.inc @@ -9,7 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -include_once($path_to_root . "/includes/reserved.inc"); +//include_once($path_to_root . "/includes/reserved.inc"); function set_global_supplier($supplier_id) { @@ -19,7 +19,7 @@ function set_global_supplier($supplier_id) function get_global_supplier($return_all=true) { if (!isset($_SESSION['wa_global_supplier_id']) || - ($return_all == false && $_SESSION['wa_global_supplier_id'] == reserved_words::get_all())) + ($return_all == false && $_SESSION['wa_global_supplier_id'] == ALL_TEXT)) return ""; return $_SESSION['wa_global_supplier_id']; } @@ -32,7 +32,7 @@ function set_global_stock_item($stock_id) function get_global_stock_item($return_all=true) { if (!isset($_SESSION['wa_global_stock_id']) || - ($return_all == false && $_SESSION['wa_global_stock_id'] == reserved_words::get_all())) + ($return_all == false && $_SESSION['wa_global_stock_id'] == ALL_TEXT)) return ""; return $_SESSION['wa_global_stock_id']; } @@ -45,7 +45,7 @@ function set_global_customer($customer_id) function get_global_customer($return_all=true) { if (!isset($_SESSION['wa_global_customer_id']) || - ($return_all == false && $_SESSION['wa_global_customer_id'] == reserved_words::get_all())) + ($return_all == false && $_SESSION['wa_global_customer_id'] == ALL_TEXT)) return ""; return $_SESSION['wa_global_customer_id']; } diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 4498a1bd..913b8a79 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -10,7 +10,6 @@ See the License here . ***********************************************************************/ include_once($path_to_root . "/includes/banking.inc"); -include_once($path_to_root . "/includes/reserved.inc"); include_once($path_to_root . "/includes/types.inc"); include_once($path_to_root . "/includes/current_user.inc"); @@ -20,7 +19,7 @@ $_search_button = " "; -$all_items = reserved_words::get_all(); +$all_items = ALL_TEXT; //---------------------------------------------------------------------------- // Universal sql combo generator @@ -376,6 +375,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name', array( 'format' => '_format_add_curr', + 'order' => array('supp_ref'), 'search_box' => $mode!=0, 'type' => 1, 'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option, @@ -425,6 +425,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ return combo_input($name, $selected_id, $sql, 'debtor_no', 'name', array( 'format' => '_format_add_curr', + 'order' => array('debtor_ref'), 'search_box' => $mode!=0, 'type' => 1, 'size' => 20, @@ -477,6 +478,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, return combo_input($name, $selected_id, $sql, 'branch_code', 'br_name', array( 'where' => $where, + 'order' => array('branch_ref'), 'spec_option' => $spec_option === true ? _('All branches') : $spec_option, 'spec_id' => $all_items, 'select_submit'=> $submit_on_change, @@ -927,7 +929,7 @@ function tax_types_list($name, $selected_id=null, $none_option=false, $submit_on return combo_input($name, $selected_id, $sql, 'id', 'name', array( 'spec_option' => $none_option, - 'spec_id' => reserved_words::get_all_numeric(), + 'spec_id' => ALL_NUMERIC, 'select_submit'=> $submit_on_change, 'async' => false, ) ); @@ -964,7 +966,7 @@ function tax_groups_list($name, $selected_id=null, array( 'order' => 'id', 'spec_option' => $none_option, - 'spec_id' => reserved_words::get_all_numeric(), + 'spec_id' => ALL_NUMERIC, 'select_submit'=> $submit_on_change, 'async' => false, ) ); @@ -1017,7 +1019,8 @@ function item_tax_types_list_row($label, $name, $selected_id=null) function shippers_list($name, $selected_id=null) { $sql = "SELECT shipper_id, shipper_name, inactive FROM ".TB_PREF."shippers"; - combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', array()); + combo_input($name, $selected_id, $sql, 'shipper_id', 'shipper_name', + array('order'=>array('shipper_name'))); } function shippers_list_cells($label, $name, $selected_id=null) @@ -1041,7 +1044,8 @@ function shippers_list_row($label, $name, $selected_id=null) function sales_persons_list($name, $selected_id=null) { $sql = "SELECT salesman_code, salesman_name, inactive FROM ".TB_PREF."salesman"; - combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', array()); + combo_input($name, $selected_id, $sql, 'salesman_code', 'salesman_name', + array('order'=>array('salesman_name'))); } function sales_persons_list_cells($label, $name, $selected_id=null) @@ -1415,6 +1419,7 @@ function pos_list_row($label, $name, $selected_id=null, $spec_option=false, $sub 'async' => true, 'spec_option' =>$spec_option, 'spec_id' => -1, + 'order'=> array('pos_name') ) ); echo "\n"; @@ -1650,15 +1655,9 @@ function languages_list_row($label, $name, $selected_id=null) function bank_account_types_list($name, $selected_id=null) { - $types = bank_account_types::get_all(); + global $bank_account_types; - $items = array(); - foreach ($types as $type) - { - $items[$type['id']] = $type['name']; - } - - return array_selector($name, $selected_id, $items ); + return array_selector($name, $selected_id, $bank_account_types); } function bank_account_types_list_cells($label, $name, $selected_id=null) @@ -1680,19 +1679,9 @@ function bank_account_types_list_row($label, $name, $selected_id=null) //------------------------------------------------------------------------------------------------ function payment_person_types_list($name, $selected_id=null, $submit_on_change=false) { - $types = payment_person_types::get_all(); + global $payment_person_types; - $items = array(); - foreach ($types as $type) - { - if (payment_person_types::has_items($type['id'])) - { - if ($type['id'] != payment_person_types::WorkOrder()) - $items[$type['id']] = $type['name']; - } - } - - return array_selector($name, $selected_id, $items, + return array_selector($name, $selected_id, $payment_person_types, array( 'select_submit'=> $submit_on_change ) ); } @@ -1718,13 +1707,9 @@ function payment_person_types_list_row($label, $name, $selected_id=null, $relate function wo_types_list($name, $selected_id=null) { - $types = wo_types::get_all(); - - $items = array(); - foreach ($types as $type) - $items[$type['id']] = $type['name']; + global $wo_types_array; - return array_selector($name, $selected_id, $items, + return array_selector($name, $selected_id, $wo_types_array, array( 'select_submit'=> true, 'async' => true ) ); } @@ -1950,7 +1935,7 @@ function number_list($name, $selected, $from, $to, $no_option=false) return array_selector($name, $selected, $items, array( 'spec_option' => $no_option, - 'spec_id' => reserved_words::get_all_numeric()) ); + 'spec_id' => ALL_NUMERIC) ); } function number_list_cells($label, $name, $selected, $from, $to, $no_option=false) diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index bedf484a..2d4f120c 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -18,7 +18,7 @@ function get_supplier_trans_view_str($type, $trans_no, $label="", $icon=false, $class='', $id='') { $viewer = "purchasing/view/"; - if ($type == systypes::po()) + if ($type == ST_PURCHORDER) $viewer .= "view_po.php"; elseif ($type == 20) $viewer .= "view_supp_invoice.php"; @@ -131,9 +131,9 @@ function get_inventory_trans_view_str($type, $trans_no, $label="", { $viewer = "inventory/view/"; - if ($type == systypes::inventory_adjustment()) + if ($type == ST_INVADJUST) $viewer .= "view_adjustment.php"; - elseif ($type == systypes::location_transfer()) + elseif ($type == ST_LOCTRANSFER) $viewer .= "view_transfer.php"; else return null; @@ -156,7 +156,7 @@ function get_manufacturing_trans_view_str($type, $trans_no, $label="", $viewer .= "wo_issue_view.php"; elseif ($type == 29) $viewer .= "wo_production_view.php"; - elseif ($type == systypes::work_order()) + elseif ($type == ST_WORKORDER) $viewer .= "work_order_view.php"; else return null; @@ -440,7 +440,7 @@ function display_footer_exit() function display_allocations($alloc_result, $total) { - global $table_style; + global $table_style, $systypes_array; if (!$alloc_result || db_num_rows($alloc_result) == 0) return; @@ -459,7 +459,7 @@ function display_allocations($alloc_result, $total) alt_table_row_color($k); - label_cell(systypes::name($alloc_row['type'])); + label_cell($systypes_array[$alloc_row['type']]); label_cell(get_trans_view_str($alloc_row['type'],$alloc_row['trans_no'])); label_cell(sql2date($alloc_row['tran_date'])); $alloc_row['Total'] = round2($alloc_row['Total'], user_price_dec()); @@ -491,11 +491,11 @@ function display_allocations_from($person_type, $person_id, $type, $type_no, $to { switch ($person_type) { - case payment_person_types::customer() : + case PT_CUSTOMER : $alloc_result = get_allocatable_to_cust_transactions($person_id, $type_no, $type); display_allocations($alloc_result, $total); return; - case payment_person_types::supplier() : + case PT_SUPPLIER : $alloc_result = get_allocatable_to_supp_transactions($person_id, $type_no, $type); display_allocations($alloc_result, $total); return;