5 include_once($path_to_root . "/includes/ui/items_cart.inc");
7 include_once($path_to_root . "/includes/session.inc");
9 include_once($path_to_root . "/includes/date_functions.inc");
10 include_once($path_to_root . "/includes/data_checks.inc");
12 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
13 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
14 include_once($path_to_root . "/manufacturing/includes/work_order_issue_ui.inc");
17 $js .= get_js_date_picker();
18 page(_("Issue Items to Work Order"), false, false, "", $js);
20 //-----------------------------------------------------------------------------------------------
22 if (isset($_GET['AddedID']))
24 echo "<center>" . _("The work order issue has been entered.");
26 hyperlink_no_params("search_work_orders.php", _("Select another Work Order to Process"));
32 //--------------------------------------------------------------------------------------------------
34 function handle_new_order()
36 if (isset($_SESSION['issue_items']))
38 $_SESSION['issue_items']->clear_items();
39 unset ($_SESSION['issue_items']);
42 Session_register("issue_items");
44 $_SESSION['issue_items'] = new items_cart;
45 $_SESSION['issue_items']->order_id = $_GET['trans_no'];
48 //-----------------------------------------------------------------------------------------------
50 function can_process()
52 if (!is_date($_POST['date_']))
54 display_error(_("The entered date for the issue is invalid."));
58 elseif (!is_date_in_fiscalyear($_POST['date_']))
60 display_error(_("The entered date is not in fiscal year."));
64 if (!references::is_valid($_POST['ref']))
66 display_error(_("You must enter a reference."));
71 if (!is_new_reference($_POST['ref'], 28))
73 display_error(_("The entered reference is already in use."));
78 $failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']);
79 if ($failed_item != null)
81 display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") .
82 " " . $failed_item->stock_id . " - " . $failed_item->item_description);
89 if (isset($_POST['Process']))
92 // if failed, returns a stockID
93 $failed_data = add_work_order_issue($_SESSION['issue_items']->order_id,
94 $_POST['ref'], $_POST['IssueType'], $_SESSION['issue_items']->line_items,
95 $_POST['Location'], $_POST['WorkCentre'], $_POST['date_'], $_POST['memo_']);
97 if ($failed_data != null)
99 display_error(_("The process cannot be completed because there is an insufficient total quantity for a component.") . "<br>"
100 . _("Component is :"). $failed_data[0] . "<br>"
101 . _("From location :"). $failed_data[1] . "<br>");
105 meta_forward($_SERVER['PHP_SELF'], "AddedID=1");
108 } /*end of process credit note */
110 //-----------------------------------------------------------------------------------------------
112 function check_item_data()
114 if (!is_numeric($_POST['qty']))
116 display_error(_("The quantity entered is not a valid number."));
121 if ($_POST['qty'] <= 0)
123 display_error(_("The quantity entered must be greater than zero."));
128 if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0)
130 display_error(_("The entered standard cost is negative or invalid."));
131 set_focus('std_cost');
138 //-----------------------------------------------------------------------------------------------
140 function handle_update_item()
142 if($_POST['UpdateItem'] != "" && check_item_data())
144 $_SESSION['issue_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
148 //-----------------------------------------------------------------------------------------------
150 function handle_delete_item()
152 $_SESSION['issue_items']->remove_from_cart($_GET['Delete']);
155 //-----------------------------------------------------------------------------------------------
157 function handle_new_item()
159 if (!check_item_data())
162 add_to_order($_SESSION['issue_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
165 //-----------------------------------------------------------------------------------------------
167 if ($_GET['Delete']!="")
168 handle_delete_item();
170 if ($_POST['AddItem']!="")
173 if ($_POST['UpdateItem']!="")
174 handle_update_item();
176 //-----------------------------------------------------------------------------------------------
178 if (isset($_GET['trans_no']))
183 //-----------------------------------------------------------------------------------------------
185 display_order_header($_SESSION['issue_items']);
187 start_form(false, true);
189 start_table("$table_style width=90%", '10');
191 display_adjustment_items(_("Items to Issue"), $_SESSION['issue_items']);
192 adjustment_options_controls();
197 if (!isset($_POST['Process']))
201 submit_cells('Update', _("Update"));
202 if ($_SESSION['issue_items']->count_items() >= 1)
204 submit_cells('Process', _("Process Issue"));
212 //------------------------------------------------------------------------------------------------