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_order(&$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 order. You can change the quantity ordered of the existing line if necessary.");
22 $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
25 //--------------------------------------------------------------------------------
27 function display_order_header(&$order)
31 start_outer_table(TABLESTYLE, "width=70%");
35 locations_list_row(_("From Location:"), 'FromStockLocation', null);
36 locations_list_row(_("To Location:"), 'ToStockLocation', null);
38 table_section(2, "33%");
40 ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_LOCTRANSFER));
42 date_row(_("Date:"), 'AdjDate', '', true);
44 table_section(3, "33%");
46 movement_types_list_row(_("Transfer Type:"), 'type', null);
48 end_outer_table(1); // outer table
51 //---------------------------------------------------------------------------------
53 function display_transfer_items($title, &$order)
57 display_heading($title);
58 div_start('items_table');
59 start_table(TABLESTYLE, "width=80%");
60 $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), '');
61 if ( count($order->line_items)) $th[] = '';
64 $k = 0; //row colour counter
66 $id = find_submit('Edit');
67 foreach ($order->line_items as $line_no=>$stock_item)
72 alt_table_row_color($k);
74 view_stock_status_cell($stock_item->stock_id);
75 label_cell($stock_item->item_description);
76 qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
77 label_cell($stock_item->units);
79 edit_button_cell("Edit$line_no", _("Edit"),
80 _('Edit document line'));
81 delete_button_cell("Delete$line_no", _("Delete"),
82 _('Remove line from document'));
87 transfer_edit_item_controls($order, $line_no);
92 transfer_edit_item_controls($order);
98 //---------------------------------------------------------------------------------
100 function transfer_edit_item_controls(&$order, $line_no=-1)
105 $id = find_submit('Edit');
106 if ($line_no != -1 && $line_no == $id)
108 $_POST['stock_id'] = $order->line_items[$id]->stock_id;
109 $_POST['qty'] = qty_format($order->line_items[$id]->quantity, $order->line_items[$id]->stock_id, $dec);
110 $_POST['units'] = $order->line_items[$id]->units;
112 hidden('stock_id', $_POST['stock_id']);
113 label_cell($_POST['stock_id']);
114 label_cell($order->line_items[$id]->item_description);
115 $Ajax->activate('items_table');
119 stock_costable_items_list_cells(null, 'stock_id', null, false, true);
120 if (list_updated('stock_id')) {
121 $Ajax->activate('units');
122 $Ajax->activate('qty');
125 $item_info = get_item_edit_info($_POST['stock_id']);
127 $dec = $item_info['decimals'];
128 $_POST['qty'] = number_format2(0, $dec);
129 $_POST['units'] = $item_info["units"];
132 small_qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
133 label_cell($_POST['units'], '', 'units');
137 button_cell('UpdateItem', _("Update"),
138 _('Confirm changes'), ICON_UPDATE);
139 button_cell('CancelItemChanges', _("Cancel"),
140 _('Cancel changes'), ICON_CANCEL);
141 hidden('LineNo', $line_no);
146 submit_cells('AddItem', _("Add Item"), "colspan=2",
147 _('Add new item to document'), true);
154 //---------------------------------------------------------------------------------
156 function transfer_options_controls()
161 textarea_row(_("Memo"), 'memo_', null, 50, 3);
167 //---------------------------------------------------------------------------------