Eliminated non-static method calls and some more fixes to avoid log warnings on php4&5
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 13 Sep 2009 21:17:48 +0000 (21:17 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 13 Sep 2009 21:17:48 +0000 (21:17 +0000)
18 files changed:
includes/JsHttpRequest.php
includes/banking.inc
includes/errors.inc
includes/lang/gettext.php
includes/lang/language.php
includes/main.inc
includes/page/footer.inc
includes/prefs/sysprefs.inc
includes/prefs/userprefs.inc
includes/references.inc
includes/reserved.inc [deleted file]
includes/session.inc
includes/types.inc
includes/ui/allocation_cart.inc
includes/ui/items_cart.inc
includes/ui/ui_globals.inc
includes/ui/ui_lists.inc
includes/ui/ui_view.inc

index 12dbf686aea7bb383e731aab6cc2a3c2fdff2724..1ef9a815e65ae288e980250a112a533e5daa7279 100644 (file)
@@ -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) . ' }';
         }
index cf532ea05ec95548da9b870edbe694c8fc4e1ec4..301a37299426edc85eba5b78edc634a9ec780068 100644 (file)
@@ -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);
                }
index 566d9f49eddbcdec19e5e1fb0cfecb1a2f95df55..68c26488579285aa949d3b777406e85a96612523 100644 (file)
@@ -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);
index 4c4f163396691c2314fb0e8e4ebbaa4406aa7421..cc2f04d02a8ec1ccea44affff70c5620b9639152 100644 (file)
 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 :
-* 
-* <?php
-* require_once "get_text.php";
-*
-* get_text::init();
-* get_text::set_language('fr_Fr');      // may throw GetText_Error
-* get_text::add_domain('myAppDomain');  // may throw GetText_Error
-* get_text::set_var('login', $login);   
-* get_text::set_var('name', $name);
-* 
-* // may throw GetText_Error
-* echo get_text::gettext('Welcome ${name}, you\'re connected with login ${login}');
-* 
-* // should echo something like :
-* //
-* // "Bienvenue Jean-Claude, vous ĂȘtes connectĂ© en tant qu'utilisateur jcaccount"
-* // 
-* // or if fr_FR translation does not exists
-* //
-* // "Welcome Jean-Claude, you're connected with login jcaccount"
-* 
-* ?>
-*
-* 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 <laurent.bedubourg@free.fr>
-*/
-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);
index a444838c22d40fb8df9eca1f66fffe1a3e445c93..f9b86b17ceaf2bfb84cfb10a54c87b893315dca1 100644 (file)
@@ -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;
index ee4417e24d86b661e4c95eded084fed79a992273..1a2478e9f6a9580c54aa0d50d354f05be1d3981f 100644 (file)
@@ -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");
index 7256dfe1aa41cb4910993cc2dc22b03c9b703d8f..90c951c19bb46e60327b4bf3c8ac5831056c93b1 100644 (file)
@@ -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 "<script>
                _focus = '" . get_post('_focus') . "';
-               _validate = " . JsHttpRequest::php2js($Validate).";
+               _validate = " . $Ajax->php2js($Validate).";
                var $edits
        </script>";
 
index 733a18b1dcbf4f73448e278d38a983e628b91977..f8e782826386d78afcec9e0fc7a7dbf44a852f9e 100644 (file)
@@ -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() 
index 32e92ce6df0fafd871ca75d1554c3d3d227aeecd..62bfd7e637726f3d760ecae5b5487976043a80bf 100644 (file)
@@ -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"];
index 260c7a769664407f2123fbc2d52ca647e0f86b18..786ce62b215f84f8ccfdc63f66198ea3d30fa41b 100644 (file)
@@ -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 (file)
index 5cc1fcd..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/**********************************************************************
-    Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU General Public License, GPL, 
-       as published by the Free Software Foundation, either version 3 
-       of the License, or (at your option) any later version.
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
-***********************************************************************/
-// 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
index 566c9a662b442200bc8636006380f47f9c3ac446..a306acf063010cabf703a03599cc8dea2b684763 100644 (file)
@@ -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);
        }
 }
 
index 1d6c47f78faebc7f212080a9c67992da8a215054..675ecb770f5f18f0cd1ab17d1433a4d7faed5435 100644 (file)
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 //----------------------------------------------------------------------------------
+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
index 32cb1addca324e554af992fa98cfa6b9ad4e76b7..e1f45ce1bdd20c6258e5b358694060dbe75c67f1 100644 (file)
@@ -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;
index b0d3a609cd30d5c9a9a53d5b63d6e04bf4fb6bf4..0f8b3c35462aefee00d8531d97dee54834742958 100644 (file)
@@ -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))
                        {
index b591f2906f01b78221d28532034d9ca7cdd27522..e8fd2b44cffbdc42101f9f62a559cf64988e4ff5 100644 (file)
@@ -9,7 +9,7 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-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'];
 }
index 4498a1bded5fbeb555cef6abf59991a457231ee5..913b8a7967f3ad741b2cb93474e7d5e3c4ab252a 100644 (file)
@@ -10,7 +10,6 @@
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 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 = "<input %s type='submit' class='combo_submit' style='border:0;
 $_select_button = "<input %s type='submit' class='combo_select' style='border:0;background:url($path_to_root/themes/"
        ."%s/images/button_ok.png) no-repeat;%s' aspect='fallback' name='%s' value=' ' title='"._("Select")."'> ";
 
-$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 "</td></tr>\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)
index bedf484a9c9112144ff7da880852e119b82473bb..2d4f120c8ca18ceddb0270246801003cc8113a82 100644 (file)
@@ -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;