+function check_item_data($n)
+{
+
+ if (!check_num('This_QuantityCredited'.$n, 0))
+ {
+ display_error(_("The quantity to credit must be numeric and greater than zero."));
+ set_focus('This_QuantityCredited'.$n);
+ return false;
+ }
+
+ if (!check_num('ChgPrice'.$n, 0))
+ {
+ display_error(_("The price is either not numeric or negative."));
+ set_focus('ChgPrice'.$n);
+ return false;
+ }
+
+ return true;
+}
+
+function commit_item_data($n)
+{
+ if (check_item_data($n))
+ {
+ $item = get_grn_item($n);
+ $_SESSION['supp_trans']->add_grn_to_trans($n,
+ $item['po_detail_item'], $item['item_code'],
+ $item['description'], $item['qty_recd'],
+ $item['quantity_inv'], input_num('This_QuantityCredited'.$n),
+ $item['unit_price'], input_num('ChgPrice'.$n), $item['std_cost_unit']);
+ reset_tax_input();
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+
+$id = find_submit('grn_item_id');
+if ($id != -1)
+{
+ commit_item_data($id);
+}
+
+if (isset($_POST['InvGRNAll']))
+{
+ foreach($_POST as $postkey=>$postval )
+ {
+ if (strpos($postkey, "qty_recd") === 0)
+ {
+ $id = substr($postkey, strlen("qty_recd"));
+ $id = (int)$id;
+ commit_item_data($id);
+ }
+ }
+}
+
+