php 8.1 deprecated null parameters fixed.
authorJoe <joe.hunt.consulting@gmail.com>
Sat, 4 Jun 2022 22:34:23 +0000 (00:34 +0200)
committerJoe <joe.hunt.consulting@gmail.com>
Sat, 4 Jun 2022 22:34:23 +0000 (00:34 +0200)
includes/JsHttpRequest.php
includes/ui/ui_lists.inc
reporting/includes/pdf_report.inc
reporting/rep101.php
reporting/rep103.php
reporting/rep201.php
reporting/rep206.php
reporting/rep302.php
reporting/rep705.php

index 7eb712dd7c79cf530ecd645ccce18f5507d39d8d..59d5b86edf168aeb34ffcd55a07543acd21a98bc 100644 (file)
@@ -266,12 +266,14 @@ class JsHttpRequest
             '_POST'=> $rawPost,
         );
         foreach ($source as $dst=>$src) {
-            // First correct all 2-byte entities.
-            $s = preg_replace('/%(?!5B)(?!5D)([0-9a-f]{2})/si', '%u00\\1', $src);
-            // Now we can use standard parse_str() with no worry!
-            $data = null;
-            parse_str($s, $data);
-            $GLOBALS[$dst] = $this->_ucs2EntitiesDecode($data);
+            if ($src != NULL) {
+                // First correct all 2-byte entities.
+                $s = preg_replace('/%(?!5B)(?!5D)([0-9a-f]{2})/si', '%u00\\1', $src);
+                // Now we can use standard parse_str() with no worry!
+                $data = null;
+                parse_str($s, $data);
+                $GLOBALS[$dst] = $this->_ucs2EntitiesDecode($data);
+            }
         }
         $GLOBALS['HTTP_GET_VARS'] = $_GET; // deprecated vars
         $GLOBALS['HTTP_POST_VARS'] = $_POST;
index c83150d697c7ae4a4b0548aaa0426a02d6762faa..a15d45733e4519a85b6cd179c37e280a2c043923 100644 (file)
@@ -302,55 +302,57 @@ $opts = array(            // default options
                $link = "";
                $id = $name;
                if ($SysPrefs->use_popup_windows) {
-               switch (strtolower($type)) {
-                       case "stock":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "stock_manufactured":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=manufactured&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "stock_purchased":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=purchasable&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "stock_sales":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=sales&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "stock_costable":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "component":
-                               $parent = $opts['parent'];
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=component&parent=".$parent."&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "kits":
-                               $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
-                               $img_title = _("Search items");
-                               break;
-                       case "customer":
-                               $link = $path_to_root . "/sales/inquiry/customers_list.php?popup=1&client_id=" . $id;
-                               $img_title = _("Search customers");
-                               break;
-                       case "branch":
-                               $link = $path_to_root . "/sales/inquiry/customer_branches_list.php?popup=1&client_id=" . $id . "#customer_id";
-                               $img_title = _("Search branches");
-                               break;
-                       case "supplier":
-                               $link = $path_to_root . "/purchasing/inquiry/suppliers_list.php?popup=1&client_id=" . $id;
-                               $img_title = _("Search suppliers");
-                               break;
-                       case "account":
-                       case "account2":
-                               $skip = strtolower($type) == "account" ? false : true;
-                               $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&skip=".$skip."&client_id=" . $id;
-                               $img_title = _("Search GL accounts");
-                               break;
-               }
+                       if ($type != NULL) {
+                       switch (strtolower($type)) {
+                               case "stock":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=all&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "stock_manufactured":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=manufactured&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "stock_purchased":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=purchasable&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "stock_sales":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=sales&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "stock_costable":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=costable&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "component":
+                                       $parent = $opts['parent'];
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=component&parent=".$parent."&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "kits":
+                                       $link = $path_to_root . "/inventory/inquiry/stock_list.php?popup=1&type=kits&client_id=" . $id;
+                                       $img_title = _("Search items");
+                                       break;
+                               case "customer":
+                                       $link = $path_to_root . "/sales/inquiry/customers_list.php?popup=1&client_id=" . $id;
+                                       $img_title = _("Search customers");
+                                       break;
+                               case "branch":
+                                       $link = $path_to_root . "/sales/inquiry/customer_branches_list.php?popup=1&client_id=" . $id . "#customer_id";
+                                       $img_title = _("Search branches");
+                                       break;
+                               case "supplier":
+                                       $link = $path_to_root . "/purchasing/inquiry/suppliers_list.php?popup=1&client_id=" . $id;
+                                       $img_title = _("Search suppliers");
+                                       break;
+                               case "account":
+                               case "account2":
+                                       $skip = strtolower($type) == "account" ? false : true;
+                                       $link = $path_to_root . "/gl/inquiry/accounts_list.php?popup=1&skip=".$skip."&client_id=" . $id;
+                                       $img_title = _("Search GL accounts");
+                                       break;
+                       }
+               }
                }
 
                if ($link !=="") {
index 0d699731e75fbbdeaf80ac54f3a215b4e2031b1a..ecb31b0e46a5c3620bf1d3b2b08a9600f75d6f68 100644 (file)
@@ -743,7 +743,7 @@ class FrontReport extends Cpdf
 
        function TextWrap($xpos, $ypos, $len, $str, $align = 'left', $border = 0, $fill = 0, $link = NULL, $stretch = 1, $spacebreak=false)
        {
-               $str = strtr($str, array("\r"=>''));
+               $str = ($str != NULL ? strtr($str, array("\r"=>'')) : "");
 
                if ($this->fontSize != $this->oldFontSize)
                {
@@ -799,7 +799,7 @@ class FrontReport extends Cpdf
 
        function TextWrapLines($c, $width, $txt, $align='left', $border=0, $fill=0, $link=NULL, $stretch=0, $spacebreak=true)
        {
-               $str = explode("\n", $txt);
+               $str = ($txt != NULL ? explode("\n", $txt) : array());
 
                for ($i = 0; $i < count($str); $i++)
                {
index 667604c86c32621c7f72cd7e67ca95b5ce35c719..0ea49173927f9df340daa5f106b76f273f328aab 100644 (file)
@@ -172,16 +172,16 @@ function print_customer_balances()
                $bal = get_open_balance($myrow['debtor_no'], $from);
                $init = array();
 
-               $init[0] = round2(abs($bal['charges']*$rate), $dec);
-               $init[1] = round2(abs($bal['credits']*$rate), $dec);
-               $init[2] = round2($bal['Allocated']*$rate, $dec);
+               $init[0] = round2(($bal != false ? abs($bal['charges']) : 0)*$rate, $dec);
+               $init[1] = round2(($bal != false ? abs($bal['credits']) : 0)*$rate, $dec);
+               $init[2] = round2(($bal != false ? $bal['Allocated'] : 0)*$rate, $dec);
                if ($show_balance)
                {
                        $init[3] = $init[0] - $init[1];
                        $accumulate += $init[3];
                }       
                else    
-                       $init[3] = round2($bal['OutStanding']*$rate, $dec);
+                       $init[3] = round2(($bal != false ? $bal['OutStanding'] : 0)*$rate, $dec);
 
                $res = get_transactions($myrow['debtor_no'], $from, $to);
                if ($no_zeros && db_num_rows($res) == 0) continue;
index 271d6818c8453e8b8943c4c0d4a7f2dbcc41d525..9c694becb7a623398a943fe6a8602957fcf64a33 100644 (file)
@@ -215,7 +215,7 @@ function print_customer_details_listing()
                        $rep->TextCol(1, 2,     _('Price List') . ": " . $myrow['sales_type']);
                        $rep->TextCol(2, 3,     $myrow['br_name']);
                        $rep->NewLine();
-                       $adr = Explode("\n", $myrow['address']);
+                       $adr = $myrow['address'] != NULL ? Explode("\n", $myrow['address']) : array();
                        if ($myrow['br_post_address'] == '')
                                $adr2 = Explode("\n", $myrow['br_address']);
                        else
index 88db421d46639433a7f4747c08b6d6026ed9e461..8fddfa9568ccc662846d90e717c8072c4be49e0c 100644 (file)
@@ -150,20 +150,20 @@ function print_supplier_balances()
                $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
                $bal = get_open_balance($myrow['supplier_id'], $from);
                $init = array();
-               $bal['charges'] = isset($bal['charges']) ? $bal['charges'] : 0;
-               $bal['credits'] = isset($bal['credits']) ? $bal['credits'] : 0;
-               $bal['Allocated'] = isset($bal['Allocated']) ? $bal['Allocated'] : 0;
-               $bal['OutStanding'] = isset($bal['OutStanding']) ? $bal['OutStanding'] : 0;
-               $init[0] = round2(abs($bal['charges']*$rate), $dec);
-               $init[1] = round2(Abs($bal['credits']*$rate), $dec);
-               $init[2] = round2($bal['Allocated']*$rate, $dec);
+               //$bal['charges'] = $bal != false ? $bal['charges'] : 0;
+               //$bal['credits'] = $bal != false ? $bal['credits'] : 0;
+               //$bal['Allocated'] = $bal != false ? $bal['Allocated'] : 0;
+               //$bal['OutStanding'] = $bal != false ? $bal['OutStanding'] : 0;
+               $init[0] = round2(($bal != false ? abs($bal['charges']) : 0)*$rate, $dec);
+               $init[1] = round2(($bal != false ? abs($bal['credits']) : 0)*$rate, $dec);
+               $init[2] = round2(($bal != false ? $bal['Allocated'] : 0)*$rate, $dec);
                if ($show_balance)
                {
                        $init[3] = $init[0] - $init[1];
                        $accumulate += $init[3];
                }       
                else    
-                       $init[3] = round2($bal['OutStanding']*$rate, $dec);
+                       $init[3] = round2(($bal != false ? $bal['OutStanding'] : 0)*$rate, $dec);
                $res = getTransactions($myrow['supplier_id'], $from, $to);
                if ($no_zeros && db_num_rows($res) == 0) continue;
 
index 79f4f1f3b40338eeac0db6085069661037056eb7..9d184556b11c08d4e9bbd711c36aa9cd01b410d8 100644 (file)
@@ -149,13 +149,9 @@ function print_supplier_balances()
         $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
         $bal = get_open_balance($myrow['supplier_id'], $from);
                $init = array();
-               $bal['charges'] = isset($bal['charges']) ? $bal['charges'] : 0;
-               $bal['credits'] = isset($bal['credits']) ? $bal['credits'] : 0;
-               $bal['Allocated'] = isset($bal['Allocated']) ? $bal['Allocated'] : 0;
-               $bal['OutStanding'] = isset($bal['OutStanding']) ? $bal['OutStanding'] : 0;
-        $init[0] = round2(abs($bal['charges']*$rate), $dec);
-        $init[1] = round2(Abs($bal['credits']*$rate), $dec);
-        $init[2] = round2($bal['Allocated']*$rate, $dec);
+        $init[0] = round2(($bal != false ? abs($bal['charges']) : 0)*$rate, $dec);
+        $init[1] = round2(($bal != false ? abs($bal['credits']) : 0)*$rate, $dec);
+        $init[2] = round2(($bal != false ? $bal['Allocated'] : 0)*$rate, $dec);
 
         $init[3] = $init[1] - $init[0];
         $accumulate += $init[3];
index cdfd0e9a21e89d81a92422c3d063453f77f6d2ae..1c821689cf6cf067b9e2321d75a1c3a2da8a502f 100644 (file)
@@ -113,11 +113,11 @@ function print_inventory_planning()
 
        $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525);
 
-       $per0 = strftime('%b',mktime(0,0,0,date('m'),1,date('Y')));
-       $per1 = strftime('%b',mktime(0,0,0,date('m')-1,1,date('Y')));
-       $per2 = strftime('%b',mktime(0,0,0,date('m')-2,1,date('Y')));
-       $per3 = strftime('%b',mktime(0,0,0,date('m')-3,1,date('Y')));
-       $per4 = strftime('%b',mktime(0,0,0,date('m')-4,1,date('Y')));
+       $per0 = substr(date('F',mktime(0,0,0,date('m'),1,date('Y'))), 0, 3);
+       $per1 = substr(date('F',mktime(0,0,0,date('m')-1,1,date('Y'))), 0, 3);
+       $per2 = substr(date('F',mktime(0,0,0,date('m')-2,1,date('Y'))), 0, 3);
+       $per3 = substr(date('F',mktime(0,0,0,date('m')-3,1,date('Y'))), 0, 3);
+       $per4 = substr(date('F',mktime(0,0,0,date('m')-4,1,date('Y'))), 0, 3);
 
        $headers = array(_('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M',
                _('QOH'), _('Cust Ord'), _('Supp Ord'), _('Sugg Ord'));
index 452eaa7189c343feb6fd8f68e8bdcd4ad0a7dd0b..3ac9d66d0fcba3a8e3905c0d9e32af244130041e 100644 (file)
@@ -239,18 +239,18 @@ function print_annual_expense_breakdown()
                list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da);
        elseif ($SysPrefs->date_system == 2)
                list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da);
-       $per12 = strftime('%b',mktime(0,0,0,$mo,$da,$yr));
-       $per11 = strftime('%b',mktime(0,0,0,$mo-1,$da,$yr));
-       $per10 = strftime('%b',mktime(0,0,0,$mo-2,$da,$yr));
-       $per09 = strftime('%b',mktime(0,0,0,$mo-3,$da,$yr));
-       $per08 = strftime('%b',mktime(0,0,0,$mo-4,$da,$yr));
-       $per07 = strftime('%b',mktime(0,0,0,$mo-5,$da,$yr));
-       $per06 = strftime('%b',mktime(0,0,0,$mo-6,$da,$yr));
-       $per05 = strftime('%b',mktime(0,0,0,$mo-7,$da,$yr));
-       $per04 = strftime('%b',mktime(0,0,0,$mo-8,$da,$yr));
-       $per03 = strftime('%b',mktime(0,0,0,$mo-9,$da,$yr));
-       $per02 = strftime('%b',mktime(0,0,0,$mo-10,$da,$yr));
-       $per01 = strftime('%b',mktime(0,0,0,$mo-11,$da,$yr));
+       $per12 = substr(date('F',mktime(0,0,0,$mo,$da,$yr)), 0, 3);
+       $per11 = substr(date('F',mktime(0,0,0,$mo-1,$da,$yr)), 0, 3);
+       $per10 = substr(date('F',mktime(0,0,0,$mo-2,$da,$yr)), 0, 3);
+       $per09 = substr(date('F',mktime(0,0,0,$mo-3,$da,$yr)), 0, 3);
+       $per08 = substr(date('F',mktime(0,0,0,$mo-4,$da,$yr)), 0, 3);
+       $per07 = substr(date('F',mktime(0,0,0,$mo-5,$da,$yr)), 0, 3);
+       $per06 = substr(date('F',mktime(0,0,0,$mo-6,$da,$yr)), 0, 3);
+       $per05 = substr(date('F',mktime(0,0,0,$mo-7,$da,$yr)), 0, 3);
+       $per04 = substr(date('F',mktime(0,0,0,$mo-8,$da,$yr)), 0, 3);
+       $per03 = substr(date('F',mktime(0,0,0,$mo-9,$da,$yr)), 0, 3);
+       $per02 = substr(date('F',mktime(0,0,0,$mo-10,$da,$yr)), 0, 3);
+       $per01 = substr(date('F',mktime(0,0,0,$mo-11,$da,$yr)), 0, 3);
 
        $headers = array(_('Account'), _('Account Name'), $per01, $per02, $per03, $per04,
                $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12, _('Total'));