5 include_once($path_to_root . "/includes/ui/items_cart.inc");
7 include_once($path_to_root . "/includes/session.inc");
9 page(_("Issue Items to Work Order"));
11 include_once($path_to_root . "/includes/date_functions.inc");
12 include_once($path_to_root . "/includes/data_checks.inc");
14 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
15 include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
16 include_once($path_to_root . "/manufacturing/includes/work_order_issue_ui.inc");
18 //-----------------------------------------------------------------------------------------------
20 if (isset($_GET['AddedID']))
22 echo "<center>" . _("The work order issue has been entered.");
24 hyperlink_no_params("search_work_orders.php", _("Select another Work Order to Process"));
30 //--------------------------------------------------------------------------------------------------
32 function handle_new_order()
34 if (isset($_SESSION['issue_items']))
36 $_SESSION['issue_items']->clear_items();
37 unset ($_SESSION['issue_items']);
40 Session_register("issue_items");
42 $_SESSION['issue_items'] = new items_cart;
43 $_SESSION['issue_items']->order_id = $_GET['trans_no'];
46 //-----------------------------------------------------------------------------------------------
48 function can_process()
50 if (!is_date($_POST['date_']))
52 display_error(_("The entered date for the issue is invalid."));
55 elseif (!is_date_in_fiscalyear($_POST['date_']))
57 display_error(_("The entered date is not in fiscal year."));
60 if (!references::is_valid($_POST['ref']))
62 display_error(_("You must enter a reference."));
66 if (!is_new_reference($_POST['ref'], 28))
68 display_error(_("The entered reference is already in use."));
72 $failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']);
73 if ($failed_item != null)
75 display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") .
76 " " . $failed_item->stock_id . " - " . $failed_item->item_description);
83 if (isset($_POST['Process']))
86 // if failed, returns a stockID
87 $failed_data = add_work_order_issue($_SESSION['issue_items']->order_id,
88 $_POST['ref'], $_POST['IssueType'], $_SESSION['issue_items']->line_items,
89 $_POST['Location'], $_POST['WorkCentre'], $_POST['date_'], $_POST['memo_']);
91 if ($failed_data != null)
93 display_error(_("The process cannot be completed because there is an insufficient total quantity for a component.") . "<br>"
94 . _("Component is :"). $failed_data[0] . "<br>"
95 . _("From location :"). $failed_data[1] . "<br>");
99 meta_forward($_SERVER['PHP_SELF'], "AddedID=1");
102 } /*end of process credit note */
104 //-----------------------------------------------------------------------------------------------
106 function check_item_data()
108 if (!is_numeric($_POST['qty']))
110 display_error(_("The quantity entered is not a valid number."));
114 if ($_POST['qty'] <= 0)
116 display_error(_("The quantity entered must be greater than zero."));
120 if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0)
122 display_error(_("The entered standard cost is negative or invalid."));
129 //-----------------------------------------------------------------------------------------------
131 function handle_update_item()
133 if($_POST['UpdateItem'] != "" && check_item_data())
135 $_SESSION['issue_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
139 //-----------------------------------------------------------------------------------------------
141 function handle_delete_item()
143 $_SESSION['issue_items']->remove_from_cart($_GET['Delete']);
146 //-----------------------------------------------------------------------------------------------
148 function handle_new_item()
150 if (!check_item_data())
153 add_to_order($_SESSION['issue_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
156 //-----------------------------------------------------------------------------------------------
158 if ($_GET['Delete']!="")
159 handle_delete_item();
161 if ($_POST['AddItem']!="")
164 if ($_POST['UpdateItem']!="")
165 handle_update_item();
167 //-----------------------------------------------------------------------------------------------
169 if (isset($_GET['trans_no']))
174 //-----------------------------------------------------------------------------------------------
176 display_order_header($_SESSION['issue_items']);
178 start_form(false, true);
180 start_table("$table_style width=90%", '10');
182 display_adjustment_items(_("Items to Issue"), $_SESSION['issue_items']);
183 adjustment_options_controls();
188 if (!isset($_POST['Process']))
192 submit_cells('Update', _("Update"));
193 if ($_SESSION['issue_items']->count_items() >= 1)
195 submit_cells('Process', _("Process Issue"));
203 //------------------------------------------------------------------------------------------------