PHP 7.4 bug. Fixed in many files.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 3 Aug 2020 10:39:56 +0000 (12:39 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Mon, 3 Aug 2020 10:39:56 +0000 (12:39 +0200)
gl/gl_journal.php
gl/includes/db/gl_db_accounts.inc
includes/references.inc
includes/ui/items_cart.inc
sales/includes/db/sales_order_db.inc
sales/includes/sales_db.inc
sales/includes/ui/sales_order_ui.inc

index e8af7d23dbea6d68e4ce5def5e0484a13c35284c..99a6145e83bcc14611c9097505cc856f1e89037f 100644 (file)
@@ -147,7 +147,7 @@ function create_cart($type=0, $trans_no=0)
                {
                        $net_sum = 0;
                        foreach($cart->gl_items as $gl)
-                               if (!is_tax_account($gl->code_id) && !is_subledger_account($gl->code_id, $gl->person_id))
+                if (!is_tax_account($gl->code_id) && !is_subledger_account($gl->code_id))
                                        $net_sum += $gl->amount;
 
                        $ex_net = abs($net_sum) - array_sum($tax_info['net_amount']);
index 6bc73abd9d03234c437d1f6932a85885f83015dc..178d98b78175ad9762432b746187cddd576459a4 100644 (file)
@@ -224,7 +224,7 @@ function is_subledger_account($account)
 
        $result = db_query($sql,"Couldn't test AR/AP account");
        $myrow = db_fetch_row($result);
-       return $myrow[0];
+       return $myrow == false ? 0 : $myrow[0];
 }
 
 function get_subaccount_data($code_id, $person_id)
index fc343e65bec7c661e057536a6d3ef80e4c6f7b89..69f6806ecb2491d3096d7ce5bb84285f8c88cb21 100644 (file)
@@ -225,7 +225,7 @@ class references
                        return false;
 
                $result = db_fetch_row($result);
-               return $result[0];
+               return $result == false ? false : $result[0];
        }
 
        function is_new_reference($ref, $type, $trans_no=0)
index 0e32165b0be23c17dda2b8fc05fcd11cbd26330d..9387558966a576980620164e85250fc6d8b4cb2d 100644 (file)
@@ -144,8 +144,8 @@ class items_cart
            $this->gl_items[$index]->code_id = $code_id;
            $this->gl_items[$index]->person_id = $person_id;
 
-               $gl_type = is_subledger_account($code_id, $person_id);
-               if ($gl_type)
+        $gl_type = is_subledger_account($code_id);
+        if ($person_id != null && $gl_type)
                {
                        $this->gl_items[$index]->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER;
                        $data = get_subaccount_data($code_id, $person_id);
@@ -263,7 +263,7 @@ class items_cart
 
                foreach($this->gl_items as $gl)
                {
-                       if ($person_type = is_subledger_account($gl->code_id, $gl->person_id))
+            if ($person_type = is_subledger_account($gl->code_id))
                        {
                                $tax_info['person_type'] = $person_type < 0 ? PT_SUPPLIER : PT_CUSTOMER;
                                $tax_info['person_id'] = $gl->person_id;
@@ -521,8 +521,8 @@ class gl_item
 
                $this->code_id = $code_id;
                $this->person_id = $person_id;
-               $gl_type = is_subledger_account($code_id, $person_id);
-               if ($gl_type)
+        $gl_type = is_subledger_account($code_id);
+        if ($person_id != null  && $gl_type)
                {
                        $this->person_type_id = $gl_type > 0 ? PT_CUSTOMER : PT_SUPPLIER;
                        $data = get_subaccount_data($code_id, $person_id);
index a6bb878cfa2f673127c266aea975cf3c543ed7f2..dcf69e93ea7116aa81f830cc83853b1ee5d442d9 100644 (file)
@@ -644,6 +644,6 @@ function last_sales_order_detail($order, $field)
 
         $last_query=db_query($sql, "Could not retrieve last order detail");
         $row = db_fetch_row($last_query);
-        return $row[0];
+        return $row == false ? false : $row[0];
 }
 
index bdc449d83623f0d1a5973767189acbbfcacdf4d3..6f74a5745d2c689bb6320dd313832a5f67031266 100644 (file)
@@ -231,6 +231,7 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
        } else {
                // read header data from first document
                $myrow = get_customer_trans($trans_no[0],$doc_type);
+        $debtor_no = $myrow['debtor_no'];
                if (count_array($trans_no)>1)
                        $cart->trans_no = get_customer_trans_version($doc_type, $trans_no);
                else
@@ -238,7 +239,7 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
 
                $cart->set_sales_type($myrow["tpe"], $myrow["sales_type"], $myrow["tax_included"],0);
 
-               $cart->set_customer($myrow["debtor_no"], $myrow["DebtorName"],
+        $cart->set_customer($debtor_no, $myrow["DebtorName"],
                        $myrow["curr_code"], $myrow["discount"], $myrow["payment_terms"]);
 
                $cart->set_branch($myrow["branch_code"], $myrow["tax_group_id"],
@@ -279,7 +280,7 @@ function read_sales_trans($doc_type, $trans_no, &$cart)
                                        @$myrow["src_id"]);
                        }
                }
-               $cart->prepayments = get_payments_for($trans_no, $doc_type, $myrow["debtor_no"]);
+        $cart->prepayments = get_payments_for($trans_no, $doc_type, $debtor_no);
 
        } // !newdoc
 
index c47c5da57cfacb234e5c008547cefbfc867fab7d..d9e20583a3f655437c0015b8c035361de907943c 100644 (file)
@@ -378,7 +378,7 @@ function display_order_header(&$order, $editable, $date_text)
        if (($order->pos['cash_sale'] || $order->pos['credit_sale']) 
                && !$order->is_started()) {
                 // editable payment type 
-               if (get_post('payment') !== $order->payment) {
+        if (isset($_POST['payment']) && $_POST['payment'] !== $order->payment) {
                        $order->payment = get_post('payment');
                        $order->payment_terms = get_payment_terms($order->payment);
                        $order->due_date = get_invoice_duedate($order->payment, $order->document_date);