Fixed warnings related to empty item/customer/supplier selector in search modes.
[fa-stable.git] / inventory / cost_update.php
index 6fa3a01947ed023df115ff5af047f5dde2f1e66b..f4fa70ba0f0fec5cf7b2ecb1b4372a794edd346e 100644 (file)
@@ -52,8 +52,7 @@ if (isset($_GET['stock_id']))
 $should_update = false;
 if (isset($_POST['UpdateData']))
 {
-
-       $old_cost = get_standard_cost($_POST['stock_id']);
+       $old_cost = get_unit_cost($_POST['stock_id']);
 
        $new_cost = input_num('material_cost') + input_num('labour_cost')
             + input_num('overhead_cost');
@@ -127,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(_("Standard Material Cost Per Unit"), "material_cost", null, "class='tableheader2'", null, $dec1);
+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);