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."));
57 elseif (!is_date_in_fiscalyear($_POST['date_']))
59 display_error(_("The entered date is not in fiscal year."));
62 if (!references::is_valid($_POST['ref']))
64 display_error(_("You must enter a reference."));
68 if (!is_new_reference($_POST['ref'], 28))
70 display_error(_("The entered reference is already in use."));
74 $failed_item = $_SESSION['issue_items']->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']);
75 if ($failed_item != null)
77 display_error( _("The issue cannot be processed because an entered item would cause a negative inventory balance :") .
78 " " . $failed_item->stock_id . " - " . $failed_item->item_description);
85 if (isset($_POST['Process']))
88 // if failed, returns a stockID
89 $failed_data = add_work_order_issue($_SESSION['issue_items']->order_id,
90 $_POST['ref'], $_POST['IssueType'], $_SESSION['issue_items']->line_items,
91 $_POST['Location'], $_POST['WorkCentre'], $_POST['date_'], $_POST['memo_']);
93 if ($failed_data != null)
95 display_error(_("The process cannot be completed because there is an insufficient total quantity for a component.") . "<br>"
96 . _("Component is :"). $failed_data[0] . "<br>"
97 . _("From location :"). $failed_data[1] . "<br>");
101 meta_forward($_SERVER['PHP_SELF'], "AddedID=1");
104 } /*end of process credit note */
106 //-----------------------------------------------------------------------------------------------
108 function check_item_data()
110 if (!is_numeric($_POST['qty']))
112 display_error(_("The quantity entered is not a valid number."));
116 if ($_POST['qty'] <= 0)
118 display_error(_("The quantity entered must be greater than zero."));
122 if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0)
124 display_error(_("The entered standard cost is negative or invalid."));
131 //-----------------------------------------------------------------------------------------------
133 function handle_update_item()
135 if($_POST['UpdateItem'] != "" && check_item_data())
137 $_SESSION['issue_items']->update_cart_item($_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
141 //-----------------------------------------------------------------------------------------------
143 function handle_delete_item()
145 $_SESSION['issue_items']->remove_from_cart($_GET['Delete']);
148 //-----------------------------------------------------------------------------------------------
150 function handle_new_item()
152 if (!check_item_data())
155 add_to_order($_SESSION['issue_items'], $_POST['stock_id'], $_POST['qty'], $_POST['std_cost']);
158 //-----------------------------------------------------------------------------------------------
160 if ($_GET['Delete']!="")
161 handle_delete_item();
163 if ($_POST['AddItem']!="")
166 if ($_POST['UpdateItem']!="")
167 handle_update_item();
169 //-----------------------------------------------------------------------------------------------
171 if (isset($_GET['trans_no']))
176 //-----------------------------------------------------------------------------------------------
178 display_order_header($_SESSION['issue_items']);
180 start_form(false, true);
182 start_table("$table_style width=90%", '10');
184 display_adjustment_items(_("Items to Issue"), $_SESSION['issue_items']);
185 adjustment_options_controls();
190 if (!isset($_POST['Process']))
194 submit_cells('Update', _("Update"));
195 if ($_SESSION['issue_items']->count_items() >= 1)
197 submit_cells('Process', _("Process Issue"));
205 //------------------------------------------------------------------------------------------------