+function check_item_data($n)
+{
+ global $check_price_charged_vs_order_price,
+ $check_qty_charged_vs_del_qty;
+ if (!check_num('this_quantity_inv'.$n, 0) || input_num('this_quantity_inv'.$n)==0)
+ {
+ display_error( _("The quantity to invoice must be numeric and greater than zero."));
+ set_focus('this_quantity_inv'.$n);
+ return false;
+ }
+
+ if (!check_num('ChgPrice'.$n))
+ {
+ display_error( _("The price is not numeric."));
+ set_focus('ChgPrice'.$n);
+ return false;
+ }
+
+ if ($check_price_charged_vs_order_price == True)
+ {
+ if ($_POST['order_price'.$n]!=input_num('ChgPrice'.$n)) {
+ if ($_POST['order_price'.$n]==0 ||
+ input_num('ChgPrice'.$n)/$_POST['order_price'.$n] >
+ (1 + (sys_prefs::over_charge_allowance() / 100)))
+ {
+ display_error(_("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") .
+ _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
+ set_focus('ChgPrice'.$n);
+ return false;
+ }
+ }
+ }
+
+ if ($check_qty_charged_vs_del_qty == True)
+ {
+ if (input_num('this_quantity_inv'.$n) / ($_POST['qty_recd'.$n] - $_POST['prev_quantity_inv'.$n]) >
+ (1+ (sys_prefs::over_charge_allowance() / 100)))
+ {
+ display_error( _("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.")
+ . _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
+ set_focus('this_quantity_inv'.$n);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+$id = find_submit('grn_item_id');
+if ($id != -1)
+{
+ if (check_item_data($id))
+ {
+ if (input_num('this_quantity_inv'.$id) >= ($_POST['qty_recd'.$id] - $_POST['prev_quantity_inv'.$id]))
+ {
+ $complete = true;
+ }
+ else
+ {
+ $complete = false;
+ }
+
+ $_SESSION['supp_trans']->add_grn_to_trans($id, $_POST['po_detail_item'.$id],
+ $_POST['item_code'.$id], $_POST['item_description'.$id], $_POST['qty_recd'.$id],
+ $_POST['prev_quantity_inv'.$id], input_num('this_quantity_inv'.$id),
+ $_POST['order_price'.$id], input_num('ChgPrice'.$id), $complete,
+ $_POST['std_cost_unit'.$id], "");
+ }
+}
+