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 if ($use_popup_windows)
15 $js .= get_js_open_window(900, 500);
16 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."));
22 /*It all stops here if there aint no supplier selected and credit note initiated ie $_SESSION['supp_trans'] started off*/
25 //-----------------------------------------------------------------------------------------
27 display_heading($_SESSION['supp_trans']->supplier_name);
30 //-----------------------------------------------------------------------------------------
34 if (!check_num('This_QuantityCredited', 0))
36 display_error(_("The quantity to credit must be numeric and greater than zero."));
37 set_focus('This_QuantityCredited');
41 if (!check_num('ChgPrice', 0))
43 display_error(_("The price is either not numeric or negative."));
44 set_focus('ChgPrice');
51 //-----------------------------------------------------------------------------------------
53 if (isset($_POST['AddGRNToTrans']))
60 //$_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'],
61 // $_POST['po_detail_item'], $_POST['item_code'],
62 // $_POST['item_description'], $_POST['qty_recd'],
63 // $_POST['prev_quantity_inv'], $_POST['This_QuantityCredited'],
64 // $_POST['order_price'], $_POST['ChgPrice'], $complete,
65 // $_POST['std_cost_unit'], $_POST['gl_code']);
66 $_SESSION['supp_trans']->add_grn_to_trans($_POST['GRNNumber'],
67 $_POST['po_detail_item'], $_POST['item_code'],
68 $_POST['item_description'], $_POST['qty_recd'],
69 $_POST['prev_quantity_inv'], input_num('This_QuantityCredited'),
70 $_POST['order_price'], input_num('ChgPrice'), $complete,
71 $_POST['std_cost_unit'], "");
75 //-----------------------------------------------------------------------------------------
76 $id = find_submit('Delete');
79 $_SESSION['supp_trans']->remove_grn_from_trans($id);
80 $Ajax->activate('grn_items');
81 $Ajax->activate('grn_table');
84 //-----------------------------------------------------------------------------------------
85 start_form(false,true);
86 display_grn_items($_SESSION['supp_trans'], 1);
90 hyperlink_no_params("$path_to_root/purchasing/supplier_credit.php", _("Return to Credit Note Entry"));
93 //-----------------------------------------------------------------------------------------
95 // get the supplier grns that have been invoiced
96 $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, false, true);
98 if (db_num_rows($result) == 0)
100 display_note(_("There are no received items for the selected supplier that have been invoiced."));
101 display_note(_("Credits can only be applied to invoiced items."));
108 /*Set up a table to show the GRN items outstanding for selection */
109 start_form(false, true);
111 div_start('grn_table');
112 start_table("$table_style width=95%");
113 $th = array(_("Delivery"), _("Sequence #"), _("Order"), _("Item Code"), _("Description"),
114 _("Delivered"), _("Total Qty Received"), _("Qty Already Invoiced"),
115 _("Qty Yet To Invoice"), _("Order Price"), _("Line Value"));
118 while ($myrow = db_fetch($result))
121 $grn_already_on_credit = False;
123 foreach ($_SESSION['supp_trans']->grn_items as $entered_grn)
125 if ($entered_grn->id == $myrow["id"])
127 $grn_already_on_credit = True;
130 if ($grn_already_on_credit == False)
133 alt_table_row_color($k);
135 label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
136 submit_cells('grn_item_id'.$myrow["id"], $myrow["id"], '', '', true);
137 label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
138 label_cell($myrow["item_code"]);
139 label_cell($myrow["description"]);
140 label_cell(sql2date($myrow["delivery_date"]));
141 $dec = get_qty_dec($myrow["item_code"]);
142 qty_cell($myrow["qty_recd"], false, $dec);
143 qty_cell($myrow["quantity_inv"], false, $dec);
144 qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"], false, $dec);
145 amount_cell($myrow["unit_price"]);
146 amount_cell(round($myrow["unit_price"] * $myrow["quantity_inv"], user_price_dec()));
160 //-----------------------------------------------------------------------------------------
161 $id = find_submit('grn_item_id');
162 if ($id || get_post('AddGRNToTrans'))
164 $Ajax->activate('grn_selector');
166 if (get_post('AddGRNToTrans'))
168 $Ajax->activate('grn_table');
169 $Ajax->activate('grn_items');
173 div_start('grn_selector');
174 $id = find_submit('grn_item_id');
178 $myrow = get_grn_item_detail($id);
181 display_heading2(_("Delivery Item Selected For Adding To A Supplier Credit Note"));
182 start_table("$table_style width=80%");
183 $th = array(_("Sequence #"), _("Item"), _("Qty Already Invoiced"),
184 _("Quantity to Credit"), _("Order Price"), _("Credit Price"));
189 label_cell($myrow['item_code'] . " " . $myrow['description']);
190 $dec = get_qty_dec($myrow['item_code']);
191 qty_cell($myrow["quantity_inv"], false, $dec);
192 qty_cells(null, 'This_QuantityCredited', number_format2(max($myrow['quantity_inv'],0), $dec), null, null, $dec);
193 amount_cell($myrow['unit_price']);
194 amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
198 submit_center('AddGRNToTrans', _("Add to Credit Note"), true, '', true);
200 hidden('GRNNumber', $id);
201 hidden('item_code', $myrow['item_code']);;
202 hidden('item_description', $myrow['description']);
203 hidden('qty_recd', $myrow['qty_recd']);
204 hidden('prev_quantity_inv', $myrow['quantity_inv']);
205 hidden('order_price', $myrow['unit_price']);
206 hidden('std_cost_unit', $myrow['std_cost_unit']);
208 hidden('po_detail_item', $myrow['po_detail_item']);
214 end_page(false, true);