6 include_once($path_to_root . "/purchasing/includes/supp_trans_class.inc");
7 include_once($path_to_root . "/includes/session.inc");
8 include_once($path_to_root . "/purchasing/includes/purchasing_ui.inc");
9 include_once($path_to_root . "/purchasing/includes/purchasing_db.inc");
13 $js .= get_js_date_picker();
14 page(_("Select Received Items to Add"), false, false, "", $js);
16 if (!isset($_SESSION['supp_trans']))
18 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."));
20 /*It all stops here if there aint no supplier selected and credit note initiated ie $_SESSION['supp_trans'] started off*/
23 //-----------------------------------------------------------------------------------------
25 display_heading($_SESSION['supp_trans']->supplier_name);
28 //-----------------------------------------------------------------------------------------
32 if (!check_num('This_QuantityCredited', 0))
34 display_error(_("The quantity to credit must be numeric and greater than zero."));
35 set_focus('This_QuantityCredited');
39 if (!check_num('ChgPrice', 0))
41 display_error(_("The price is either not numeric or negative."));
42 set_focus('ChgPrice');
49 //-----------------------------------------------------------------------------------------
51 if (isset($_POST['AddGRNToTrans']))
58 //$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'],
59 // $_POST['po_detail_item'], $_POST['item_code'],
60 // $_POST['item_description'], $_POST['qty_recd'],
61 // $_POST['prev_quantity_inv'], $_POST['This_QuantityCredited'],
62 // $_POST['order_price'], $_POST['ChgPrice'], $complete,
63 // $_POST['std_cost_unit'], $_POST['gl_code']);
64 $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'],
65 $_POST['po_detail_item'], $_POST['item_code'],
66 $_POST['item_description'], $_POST['qty_recd'],
67 $_POST['prev_quantity_inv'], input_num('This_QuantityCredited'),
68 $_POST['order_price'], input_num('ChgPrice'), $complete,
69 $_POST['std_cost_unit'], "");
73 //-----------------------------------------------------------------------------------------
74 $id = find_submit('Delete');
77 $_SESSION['supp_trans']->remove_grn_from_trans($id);
78 $Ajax->activate('grn_items');
79 $Ajax->activate('grn_table');
82 //-----------------------------------------------------------------------------------------
84 display_grn_items($_SESSION['supp_trans'], 1);
87 hyperlink_no_params("$path_to_root/purchasing/supplier_credit.php", _("Return to Credit Note Entry"));
90 //-----------------------------------------------------------------------------------------
92 // get the supplier grns that have been invoiced
93 $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, false, true);
95 if (db_num_rows($result) == 0)
97 display_note(_("There are no received items for the selected supplier that have been invoiced."));
98 display_note(_("Credits can only be applied to invoiced items."));
105 /*Set up a table to show the GRN items outstanding for selection */
106 start_form(false, true);
108 div_start('grn_table');
109 start_table("$table_style width=95%");
110 $th = array(_("Delivery"), _("Sequence #"), _("Order"), _("Item Code"), _("Description"),
111 _("Delivered"), _("Total Qty Received"), _("Qty Already Invoiced"),
112 _("Qty Yet To Invoice"), _("Order Price"), _("Line Value"));
115 while ($myrow = db_fetch($result))
118 $grn_already_on_credit = False;
120 foreach ($_SESSION['supp_trans']->grn_items as $entered_grn)
122 if ($entered_grn->id == $myrow["id"])
124 $grn_already_on_credit = True;
127 if ($grn_already_on_credit == False)
130 alt_table_row_color($k);
132 label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
133 submit_cells('grn_item_id'.$myrow["id"], $myrow["id"], '', '', true);
134 label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
135 label_cell($myrow["item_code"]);
136 label_cell($myrow["description"]);
137 label_cell(sql2date($myrow["delivery_date"]));
138 $dec = get_qty_dec($myrow["item_code"]);
139 qty_cell($myrow["qty_recd"], false, $dec);
140 qty_cell($myrow["quantity_inv"], false, $dec);
141 qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"], false, $dec);
142 amount_cell($myrow["unit_price"]);
143 amount_cell(round($myrow["unit_price"] * $myrow["quantity_inv"], user_price_dec()));
157 //-----------------------------------------------------------------------------------------
158 $id = find_submit('grn_item_id');
159 if ($id || get_post('AddGRNToTrans'))
161 $Ajax->activate('grn_selector');
163 if (get_post('AddGRNToTrans'))
165 $Ajax->activate('grn_table');
166 $Ajax->activate('grn_items');
170 div_start('grn_selector');
171 $id = find_submit('grn_item_id');
175 $myrow = get_grn_item_detail($id);
178 display_heading2(_("Delivery Item Selected For Adding To A Supplier Credit Note"));
179 start_table("$table_style width=80%");
180 $th = array(_("Sequence #"), _("Item"), _("Qty Already Invoiced"),
181 _("Quantity to Credit"), _("Order Price"), _("Credit Price"));
186 label_cell($myrow['item_code'] . " " . $myrow['description']);
187 $dec = get_qty_dec($myrow['item_code']);
188 qty_cell($myrow["quantity_inv"], false, $dec);
189 qty_cells(null, 'This_QuantityCredited', number_format2(max($myrow['quantity_inv'],0), $dec), null, null, $dec);
190 amount_cell($myrow['unit_price']);
191 amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
195 submit_center('AddGRNToTrans', _("Add to Credit Note"), true, '', true);
197 hidden('GRNNumber', $id);
198 hidden('item_code', $myrow['item_code']);;
199 hidden('item_description', $myrow['description']);
200 hidden('qty_recd', $myrow['qty_recd']);
201 hidden('prev_quantity_inv', $myrow['quantity_inv']);
202 hidden('order_price', $myrow['unit_price']);
203 hidden('std_cost_unit', $myrow['std_cost_unit']);
205 hidden('po_detail_item', $myrow['po_detail_item']);
211 end_page(false, true);