5 include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
7 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
10 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
14 $js .= get_js_date_picker();
15 page(_("Select Received Items to Add"), false, false, "", $js);
18 if (!isset($_SESSION['supp_trans']))
20 display_note("To enter supplier transactions the supplier must first be selected from the supplier selection screen, then the link to enter a supplier credit note must be clicked on.", 1, 0);;
24 //-----------------------------------------------------------------------------------------
26 display_heading($_SESSION['supp_trans']->supplier_name);
30 //-----------------------------------------------------------------------------------------
34 global $check_price_charged_vs_order_price,
35 $check_qty_charged_vs_del_qty;
36 if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv')==0)
38 display_error( _("The quantity to invoice must be numeric and greater than zero."));
42 if (!check_num('ChgPrice'))
44 display_error( _("The price is not numeric."));
48 if ($check_price_charged_vs_order_price == True)
50 if (input_num('ChgPrice')/$_POST['order_price'] >
51 (1 + (sys_prefs::over_charge_allowance() / 100)))
53 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.") .
54 _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
59 if ($check_qty_charged_vs_del_qty == True)
61 if (input_num('this_quantity_inv') / ($_POST['qty_recd'] - $_POST['prev_quantity_inv']) >
62 (1+ (sys_prefs::over_charge_allowance() / 100)))
64 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.")
65 . _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%");
73 //-----------------------------------------------------------------------------------------
75 if (isset($_POST['AddGRNToTrans']))
80 if (input_num('this_quantity_inv') >= ($_POST['qty_recd'] - $_POST['prev_quantity_inv']))
89 $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'], $_POST['po_detail_item'],
90 $_POST['item_code'], $_POST['item_description'], $_POST['qty_recd'],
91 $_POST['prev_quantity_inv'], input_num('this_quantity_inv'),
92 $_POST['order_price'], input_num('ChgPrice'), $complete,
93 $_POST['std_cost_unit'], "");
97 //-----------------------------------------------------------------------------------------
99 if (isset($_GET['Delete']))
101 $_SESSION['supp_trans']->remove_grn_from_trans($_GET['Delete']);
104 //-----------------------------------------------------------------------------------------
106 display_grn_items($_SESSION['supp_trans'], 1);
109 hyperlink_no_params("$path_to_root/purchasing/supplier_invoice.php", _("Back to Supplier Invoice Entry"));
112 //-----------------------------------------------------------------------------------------
114 function display_grn_items_for_selection()
118 $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, true);
120 if (db_num_rows($result) == 0)
122 display_note(_("There are no outstanding items received from this supplier that have not been invoiced by them."), 0, 1);
127 /*Set up a table to show the outstanding GRN items for selection */
128 start_form(false, true);
130 display_heading2(_("Items Received Yet to be Invoiced"));
132 start_table("$table_style colspan=7 width=95%");
133 $th = array(_("Delivery"), _("Sequence #"), _("P.O."), _("Item"), _("Description"),
134 _("Received On"), _("Quantity Received"), _("Quantity Invoiced"),
135 _("Uninvoiced Quantity"), _("Order Price"), _("Total"));
139 while ($myrow = db_fetch($result))
142 $grn_already_on_invoice = False;
144 foreach ($_SESSION['supp_trans']->grn_items as $entered_grn)
146 if ($entered_grn->id == $myrow["id"])
148 $grn_already_on_invoice = True;
151 if ($grn_already_on_invoice == False)
154 alt_table_row_color($k);
156 label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
157 //text_cells(null, 'grn_item_id', $myrow["id"]);
158 submit_cells('grn_item_id', $myrow["id"]);
159 label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
160 label_cell($myrow["item_code"]);
161 label_cell($myrow["description"]);
162 label_cell(sql2date($myrow["delivery_date"]));
163 qty_cell($myrow["qty_recd"]);
164 qty_cell($myrow["quantity_inv"]);
165 qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"]);
166 amount_cell($myrow["unit_price"]);
167 amount_cell($myrow["unit_price"] * ($myrow["qty_recd"] - $myrow["quantity_inv"]));
182 //-----------------------------------------------------------------------------------------
184 display_grn_items_for_selection();
186 //-----------------------------------------------------------------------------------------
188 if (isset($_POST['grn_item_id']) && $_POST['grn_item_id'] != "")
191 $myrow = get_grn_item_detail($_POST['grn_item_id']);
194 display_heading2(_("Delivery Item Selected For Adding To A Supplier Invoice"));
195 start_table("$table_style width=80%");
196 $th = array(_("Sequence #"), _("Item"), _("Description"), _("Quantity Outstanding"),
197 _("Quantity to Invoice"), _("Order Price"), _("Actual Price"));
201 label_cell($_POST['grn_item_id']);
202 label_cell($myrow['item_code']);
203 label_cell($myrow['description']);
204 qty_cell($myrow['QtyOstdg']);
205 qty_cells(null, 'this_quantity_inv', qty_format($myrow['QtyOstdg']));
206 amount_cell($myrow['unit_price']);
207 small_amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
211 submit_center('AddGRNToTrans', _("Add to Invoice"));
213 hidden('GRNNumber', $_POST['grn_item_id']);
214 hidden('item_code', $myrow['item_code']);
215 hidden('item_description', $myrow['description']);;
216 hidden('qty_recd', $myrow['qty_recd']);
217 hidden('prev_quantity_inv', $myrow['quantity_inv']);
218 hidden('order_price', $myrow['unit_price']);
219 hidden('std_cost_unit', $myrow['std_cost_unit']);
221 hidden('po_detail_item', $myrow['po_detail_item']);
224 //----------------------------------------------------------------------------------------