2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 include_once($path_to_root . "/includes/ui.inc");
13 include_once($path_to_root . "/includes/ui/items_cart.inc");
15 //--------------------------------------------------------------------------------
17 function add_to_issue(&$order, $new_item, $new_item_qty, $standard_cost)
19 if ($order->find_cart_item($new_item))
20 display_error(_("For Part :") . $new_item . " " . "This item is already on this issue. You can change the quantity issued of the existing line if necessary.");
22 $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
24 //---------------------------------------------------------------------------------
26 function display_issue_items($title, &$order)
30 display_heading($title);
31 div_start('items_table');
32 start_table(TABLESTYLE, "width='80%'");
33 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
34 _("Unit"), _("Unit Cost"), '');
35 if ( count($order->line_items)) $th[] = '';
39 $k = 0; //row colour counter
41 if (count($order->line_items))
42 $low_stock = $order->check_qoh($_POST['Location'], $_POST['date_'], !$_POST['IssueType']);
43 $id = find_submit('Edit');
44 foreach ($order->line_items as $line_no=>$stock_item)
49 if (in_array($stock_item->stock_id, $low_stock))
50 start_row("class='stockmankobg'"); // notice low stock status
52 alt_table_row_color($k);
54 view_stock_status_cell($stock_item->stock_id);
55 label_cell($stock_item->item_description);
56 qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
57 label_cell($stock_item->units);
58 amount_cell($stock_item->standard_cost);
59 // amount_cell($stock_item->standard_cost * $stock_item->quantity);
61 edit_button_cell("Edit$line_no", _("Edit"),
62 _('Edit document line'));
63 delete_button_cell("Delete$line_no", _("Delete"),
64 _('Remove line from document'));
69 issue_edit_item_controls($order, $line_no);
74 issue_edit_item_controls($order);
78 display_note(_("Marked items have insufficient quantities in stock as on day of issue."), 0, 1, "class='stockmankofg'");
82 //---------------------------------------------------------------------------------
84 function issue_edit_item_controls(&$order, $line_no=-1)
89 $id = find_submit('Edit');
90 if ($line_no != -1 && $line_no == $id)
92 $_POST['stock_id'] = $order->line_items[$id]->stock_id;
93 $_POST['qty'] = qty_format($order->line_items[$id]->quantity,
94 $order->line_items[$id]->stock_id, $dec);
95 $std_cost = $order->line_items[$id]->standard_cost;
96 $_POST['units'] = $order->line_items[$id]->units;
98 hidden('stock_id', $_POST['stock_id']);
99 label_cell($_POST['stock_id']);
100 label_cell($order->line_items[$id]->item_description);
101 $Ajax->activate('items_table');
105 $wo_details = get_work_order($_SESSION['issue_items']->order_id);
107 stock_component_items_list_cells(null, 'stock_id',
108 $wo_details["stock_id"], null, false, true);
109 if (list_updated('stock_id')) {
110 $Ajax->activate('units');
111 $Ajax->activate('qty');
112 $Ajax->activate('std_cost');
115 $item_info = get_item_edit_info($_POST['stock_id']);
117 $dec = $item_info["decimals"];
118 $_POST['qty'] = number_format2(0, $dec);
119 $std_cost = $item_info["material_cost"];
120 $_POST['units'] = $item_info["units"];
123 qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
124 label_cell($_POST['units'], '', 'units');
126 //amount_cells(null, 'std_cost', $_POST['std_cost']);
127 hidden('std_cost', $std_cost);
128 amount_cell($std_cost);
132 button_cell('UpdateItem', _("Update"),
133 _('Confirm changes'), ICON_UPDATE);
134 button_cell('CancelItemChanges', _("Cancel"),
135 _('Cancel changes'), ICON_CANCEL);
136 hidden('LineNo', $line_no);
141 submit_cells('AddItem', _("Add Item"), "colspan=2",
142 _('Add new item to document'), true);
149 //---------------------------------------------------------------------------------
151 function issue_options_controls()
157 date_row(_("Issue Date:"), 'date_');
158 locations_list_row(_("From Location:"), 'Location');
159 workcenter_list_row(_("To Work Centre:"), 'WorkCentre');
161 ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_MANUISSUE, null, array('date'=> get_post('date_'), 'location' => get_post('Location'))));
163 if (!isset($_POST['IssueType']))
164 $_POST['IssueType'] = 0;
166 yesno_list_row(_("Type:"), 'IssueType', $_POST['IssueType'],
167 _("Return Items to Location"), _("Issue Items to Work order"));
169 textarea_row(_("Memo"), 'memo_', null, 50, 3);
173 //---------------------------------------------------------------------------------