$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;
}
//---------------------------------------------------------------------------------------------
//
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);
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');
}
$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)
if ($mb_flag == -1)
{
display_error(_("Entered item is not defined. Please re-enter."));
+ $Ajax->activate('price_table');
set_focus('stock_id');
}
else
. 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 "
$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)
$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)
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');