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 //-----------------------------------------------------------------------------------------
83 start_form(false,true);
84 display_grn_items($_SESSION['supp_trans'], 1);
88 hyperlink_no_params("$path_to_root/purchasing/supplier_credit.php", _("Return to Credit Note Entry"));
91 //-----------------------------------------------------------------------------------------
93 // get the supplier grns that have been invoiced
94 $result = get_grn_items(0, $_SESSION['supp_trans']->supplier_id, false, true);
96 if (db_num_rows($result) == 0)
98 display_note(_("There are no received items for the selected supplier that have been invoiced."));
99 display_note(_("Credits can only be applied to invoiced items."));
106 /*Set up a table to show the GRN items outstanding for selection */
107 start_form(false, true);
109 div_start('grn_table');
110 start_table("$table_style width=95%");
111 $th = array(_("Delivery"), _("Sequence #"), _("Order"), _("Item Code"), _("Description"),
112 _("Delivered"), _("Total Qty Received"), _("Qty Already Invoiced"),
113 _("Qty Yet To Invoice"), _("Order Price"), _("Line Value"));
116 while ($myrow = db_fetch($result))
119 $grn_already_on_credit = False;
121 foreach ($_SESSION['supp_trans']->grn_items as $entered_grn)
123 if ($entered_grn->id == $myrow["id"])
125 $grn_already_on_credit = True;
128 if ($grn_already_on_credit == False)
131 alt_table_row_color($k);
133 label_cell(get_trans_view_str(25, $myrow["grn_batch_id"]));
134 submit_cells('grn_item_id'.$myrow["id"], $myrow["id"], '', '', true);
135 label_cell(get_trans_view_str(systypes::po(), $myrow["purch_order_no"]));
136 label_cell($myrow["item_code"]);
137 label_cell($myrow["description"]);
138 label_cell(sql2date($myrow["delivery_date"]));
139 $dec = get_qty_dec($myrow["item_code"]);
140 qty_cell($myrow["qty_recd"], false, $dec);
141 qty_cell($myrow["quantity_inv"], false, $dec);
142 qty_cell($myrow["qty_recd"] - $myrow["quantity_inv"], false, $dec);
143 amount_cell($myrow["unit_price"]);
144 amount_cell(round($myrow["unit_price"] * $myrow["quantity_inv"], user_price_dec()));
158 //-----------------------------------------------------------------------------------------
159 $id = find_submit('grn_item_id');
160 if ($id || get_post('AddGRNToTrans'))
162 $Ajax->activate('grn_selector');
164 if (get_post('AddGRNToTrans'))
166 $Ajax->activate('grn_table');
167 $Ajax->activate('grn_items');
171 div_start('grn_selector');
172 $id = find_submit('grn_item_id');
176 $myrow = get_grn_item_detail($id);
179 display_heading2(_("Delivery Item Selected For Adding To A Supplier Credit Note"));
180 start_table("$table_style width=80%");
181 $th = array(_("Sequence #"), _("Item"), _("Qty Already Invoiced"),
182 _("Quantity to Credit"), _("Order Price"), _("Credit Price"));
187 label_cell($myrow['item_code'] . " " . $myrow['description']);
188 $dec = get_qty_dec($myrow['item_code']);
189 qty_cell($myrow["quantity_inv"], false, $dec);
190 qty_cells(null, 'This_QuantityCredited', number_format2(max($myrow['quantity_inv'],0), $dec), null, null, $dec);
191 amount_cell($myrow['unit_price']);
192 amount_cells(null, 'ChgPrice', price_format($myrow['unit_price']));
196 submit_center('AddGRNToTrans', _("Add to Credit Note"), true, '', true);
198 hidden('GRNNumber', $id);
199 hidden('item_code', $myrow['item_code']);;
200 hidden('item_description', $myrow['description']);
201 hidden('qty_recd', $myrow['qty_recd']);
202 hidden('prev_quantity_inv', $myrow['quantity_inv']);
203 hidden('order_price', $myrow['unit_price']);
204 hidden('std_cost_unit', $myrow['std_cost_unit']);
206 hidden('po_detail_item', $myrow['po_detail_item']);
212 end_page(false, true);