From: Janusz Dobrowolski Date: Mon, 28 Sep 2020 19:42:32 +0000 (+0200) Subject: Fixed warnings related to empty item/customer/supplier selector in search modes. X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=2f3375b4493c1b1e0b17c2801298275f22f8d76e Fixed warnings related to empty item/customer/supplier selector in search modes. --- diff --git a/gl/includes/db/gl_db_bank_accounts.inc b/gl/includes/db/gl_db_bank_accounts.inc index ea9a83ac..ee535be7 100644 --- a/gl/includes/db/gl_db_bank_accounts.inc +++ b/gl/includes/db/gl_db_bank_accounts.inc @@ -344,8 +344,8 @@ function get_default_supplier_bank_account($supplier_id) $sql = "SELECT curr_code FROM ".TB_PREF."suppliers WHERE supplier_id=".db_escape($supplier_id); $result = db_query($sql, "could not retreive default supplier currency code"); $row = db_fetch_row($result); - $ba = get_default_bank_account($row[0]); - return $ba['id']; + $id = $row ? get_default_bank_account($row[0])['id'] : 0; + return $id; } //--------------------------------------------------------------------------------------------- // diff --git a/inventory/cost_update.php b/inventory/cost_update.php index 35347000..f4fa70ba 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -126,13 +126,15 @@ div_start('cost_table'); start_table(TABLESTYLE2); $dec1 = $dec2 = $dec3 = 0; -$_POST['material_cost'] = price_decimal_format($myrow["material_cost"], $dec1); -$_POST['labour_cost'] = price_decimal_format($myrow["labour_cost"], $dec2); -$_POST['overhead_cost'] = price_decimal_format($myrow["overhead_cost"], $dec3); +if ($myrow) { + $_POST['material_cost'] = price_decimal_format($myrow["material_cost"], $dec1); + $_POST['labour_cost'] = price_decimal_format($myrow["labour_cost"], $dec2); + $_POST['overhead_cost'] = price_decimal_format($myrow["overhead_cost"], $dec3); +} amount_row(_("Unit cost"), "material_cost", null, "class='tableheader2'", null, $dec1); -if ($myrow["mb_flag"]=='M') +if ($myrow && $myrow["mb_flag"]=='M') { amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", null, "class='tableheader2'", null, $dec2); amount_row(_("Standard Overhead Cost Per Unit"), "overhead_cost", null, "class='tableheader2'", null, $dec3); diff --git a/inventory/manage/item_codes.php b/inventory/manage/item_codes.php index 0742780a..1881258c 100644 --- a/inventory/manage/item_codes.php +++ b/inventory/manage/item_codes.php @@ -113,11 +113,15 @@ echo "
"; set_global_stock_item($_POST['stock_id']); +$units = $dec = ''; $result = get_item_code_dflts($_POST['stock_id']); -$dec = $result['decimals']; -$units = $result['units']; -$dflt_desc = $result['description']; -$dflt_cat = $result['category_id']; +if ($result) { + $dec = $result['decimals']; + $units = $result['units']; + $dflt_desc = $result['description']; + $dflt_cat = $result['category_id']; +} + $result = get_all_item_codes($_POST['stock_id']); div_start('code_table'); diff --git a/inventory/prices.php b/inventory/prices.php index 70dd97d8..7132eb62 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -200,7 +200,8 @@ if (!isset($_POST['price'])) { } $kit = get_item_code_dflts($_POST['stock_id']); -small_amount_row(_("Price:"), 'price', null, '', _('per') .' '.$kit["units"]); +$units = $kit ? $kit["units"] : ''; +small_amount_row(_("Price:"), 'price', null, '', _('per') .' '.$units); end_table(1); if ($calculated) diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 8be2566b..43cb467e 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -133,6 +133,7 @@ $mb_flag = get_mb_flag($_POST['stock_id']); if ($mb_flag == -1) { display_error(_("Entered item is not defined. Please re-enter.")); + $Ajax->activate('price_table'); set_focus('stock_id'); } else diff --git a/purchasing/includes/db/supp_trans_db.inc b/purchasing/includes/db/supp_trans_db.inc index 8a2f85a9..aa9490af 100644 --- a/purchasing/includes/db/supp_trans_db.inc +++ b/purchasing/includes/db/supp_trans_db.inc @@ -131,7 +131,7 @@ function get_supp_payment_before($supplier_id, $date) . TB_PREF . "bank_trans," . TB_PREF . "bank_accounts " . "WHERE " - . TB_PREF . "supp_trans.supplier_id=" . $supplier_id . " " + . TB_PREF . "supp_trans.supplier_id='" . $supplier_id . "' " . "AND " . TB_PREF . "supp_trans.tran_date<'" . $date . "' " . "AND " . TB_PREF . "supp_trans.type=" . ST_SUPPAYMENT . " " . "AND " . TB_PREF . "supp_trans.trans_no=" . TB_PREF . "bank_trans.trans_no " diff --git a/purchasing/includes/db/suppliers_db.inc b/purchasing/includes/db/suppliers_db.inc index d66c89fc..602b86bf 100644 --- a/purchasing/includes/db/suppliers_db.inc +++ b/purchasing/includes/db/suppliers_db.inc @@ -187,7 +187,7 @@ function get_supplier_currency($supplier_id) $result = db_query($sql, "Retreive currency of supplier $supplier_id"); $myrow=db_fetch_row($result); - return $myrow[0]; + return $myrow ? $myrow[0] : get_company_currency(); } function get_suppliers_search($supplier) diff --git a/sales/includes/db/customers_db.inc b/sales/includes/db/customers_db.inc index 0dfc17e2..f9b111a0 100644 --- a/sales/includes/db/customers_db.inc +++ b/sales/includes/db/customers_db.inc @@ -197,7 +197,7 @@ function get_customer_currency($customer_id=null, $branch_id=null) $result = db_query($sql, "Retreive currency of customer $customer_id"); $myrow=db_fetch_row($result); - return $myrow[0]; + return $myrow ? $myrow[0] : get_company_currency(); } function get_customers_search($customer) diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index 2e1eae54..48b8e76a 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -203,7 +203,7 @@ function branch_settings($selected_id, $num_branches) { elseif ($Mode != 'ADD_ITEM') { $myrow = get_default_info_for_branch($_POST['customer_id']); - if(!$num_branches) { + if($myrow && !$num_branches) { $_POST['br_name'] = $myrow["name"]; $_POST['br_ref'] = $myrow["debtor_ref"]; $_POST['contact_name'] = _('Main Branch');