Mysqli errors: Trying to access array offset on value of type bool. Fixed. Please...
[fa-stable.git] / gl / includes / ui / gl_bank_ui.inc
index b5a0932bc3dbcfa8f3d8491f2fe6632e8edd82bc..a4a95b85a3027526bcd73d3964940e7f0273cb0b 100644 (file)
@@ -74,7 +74,7 @@ function display_bank_header(&$order)
                        hidden('PersonDetailID');
                }
                $trans = get_customer_habit($_POST['person_id']); // take care of customers on hold
-               if ($trans['dissallow_invoices'] != 0)
+               if (is_array($trans) && $trans['dissallow_invoices'] != 0)
                {
                        if ($payment)
                        {
@@ -218,45 +218,43 @@ function gl_edit_item_controls(&$order, $dim, $Index=null)
                $_POST['LineMemo'] = $item->reference;
 
                hidden('Index', $id);
-               echo gl_all_accounts_list('code_id', null, true, true);
-               if ($dim >= 1)
-                       dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
-               if ($dim > 1)
-                       dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
            $Ajax->activate('items_table');
        }
        else
        {
-               $_POST['amount'] = price_format(0);
-               $_POST['dimension_id'] = 0;
-               $_POST['dimension2_id'] = 0;
                if(isset($_POST['_code_id_update'])) {
                            $Ajax->activate('code_id');
                }
-
-               if ($_POST['PayType'] == PT_CUSTOMER)
+               if (list_updated('PayType') || list_updated('person_id'))
                {
-                       $acc = get_branch_accounts($_POST['PersonDetailID']);
-                       $_POST['code_id'] = $acc['receivables_account'];
-               }
-               elseif ($_POST['PayType'] == PT_SUPPLIER)
-               {
-                       $acc = get_supplier_accounts($_POST['person_id']);
-                       $_POST['code_id'] = $acc['payable_account'];
-               }
-               else {
-                       $_POST['code_id'] =
-                               get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act');
+                       if ($_POST['PayType'] == PT_CUSTOMER)
+                       {
+                               $acc = get_branch_accounts($_POST['PersonDetailID']);
+                               $_POST['code_id'] = is_array($acc) ? $acc['receivables_account'] : '';
+                       }
+                       elseif ($_POST['PayType'] == PT_SUPPLIER)
+                       {
+                               $acc = get_supplier_accounts($_POST['person_id']);
+                               $_POST['code_id'] = is_array($acc) ? $acc['payable_account'] : '';
+                               $_POST['dimension_id'] = is_array($acc) ? $acc['dimension_id'] : '';
+                               $_POST['dimension2_id'] = is_array($acc) ? $acc['dimension2_id'] : '';
+                       }
+                       else {
+                               $_POST['code_id'] =
+                                       get_company_pref($payment ? 'default_cogs_act':'default_inv_sales_act');
+                       }
+                       $Ajax->activate('dimension_id');
+                       $Ajax->activate('dimension2_id');
                }
-               echo gl_all_accounts_list('code_id', null, true, true);
-               if ($dim >= 1)
-                       dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
-               if ($dim > 1)
-                       dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
        }
-       if ($dim < 1)
+       echo gl_all_accounts_list('code_id', null, true, true);
+       if ($dim >= 1)
+               dimensions_list_cells(null, 'dimension_id', null, true, " ", false, 1);
+       else
                hidden('dimension_id', 0);
-       if ($dim < 2)
+       if ($dim > 1)
+               dimensions_list_cells(null, 'dimension2_id', null, true, " ", false, 2);
+       else
                hidden('dimension2_id', 0);
 
        amount_cells(null, 'amount');