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)
29 global $table_style2, $Refs;
31 start_outer_table("width=70% $table_style2"); // outer table
34 locations_list_row(_("Location:"), 'StockLocation', null);
35 ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_INVADJUST));
37 table_section(2, "33%");
39 date_row(_("Date:"), 'AdjDate', '', true);
41 table_section(3, "33%");
43 movement_types_list_row(_("Detail:"), 'type', null);
45 if (!isset($_POST['Increase']))
46 $_POST['Increase'] = 1;
47 yesno_list_row(_("Type:"), 'Increase', $_POST['Increase'],
48 _("Positive Adjustment"), _("Negative Adjustment"));
50 end_outer_table(1); // outer table
53 //---------------------------------------------------------------------------------
55 function display_adjustment_items($title, &$order)
57 global $table_style, $path_to_root;
59 display_heading($title);
60 div_start('items_table');
61 start_table("$table_style width=80%");
62 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
63 _("Unit"), _("Unit Cost"), _("Total"), "");
64 if ( count($order->line_items)) $th[] = '';
68 $k = 0; //row colour counter
70 $id = find_submit('Edit');
71 foreach ($order->line_items as $line_no=>$stock_item)
74 $total += ($stock_item->standard_cost * $stock_item->quantity);
78 alt_table_row_color($k);
80 view_stock_status_cell($stock_item->stock_id);
81 label_cell($stock_item->item_description);
82 qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
83 label_cell($stock_item->units);
84 amount_cell($stock_item->standard_cost);
85 amount_cell($stock_item->standard_cost * $stock_item->quantity);
87 edit_button_cell("Edit$line_no", _("Edit"),
88 _('Edit document line'));
89 delete_button_cell("Delete$line_no", _("Delete"),
90 _('Remove line from document'));
95 adjustment_edit_item_controls($order, $line_no);
100 adjustment_edit_item_controls($order);
102 label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right");
108 //---------------------------------------------------------------------------------
110 function adjustment_edit_item_controls(&$order, $line_no=-1)
115 $id = find_submit('Edit');
116 if ($line_no != -1 && $line_no == $id)
118 $_POST['stock_id'] = $order->line_items[$id]->stock_id;
119 $_POST['qty'] = qty_format($order->line_items[$id]->quantity,
120 $order->line_items[$id]->stock_id, $dec);
121 $_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost);
122 $_POST['units'] = $order->line_items[$id]->units;
124 hidden('stock_id', $_POST['stock_id']);
125 label_cell($_POST['stock_id']);
126 label_cell($order->line_items[$id]->item_description, 'nowrap');
127 $Ajax->activate('items_table');
131 stock_costable_items_list_cells(null, 'stock_id', null, false, true);
132 if (list_updated('stock_id')) {
133 $Ajax->activate('units');
134 $Ajax->activate('qty');
135 $Ajax->activate('std_cost');
138 $item_info = get_item_edit_info($_POST['stock_id']);
139 $dec = $item_info['decimals'];
140 $_POST['qty'] = number_format2(0, $dec);
141 $_POST['std_cost'] = price_format($item_info["standard_cost"]);
142 $_POST['units'] = $item_info["units"];
145 qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
146 label_cell($_POST['units'], '', 'units');
148 amount_cells(null, 'std_cost', $_POST['std_cost']);
149 label_cell(" ");
153 button_cell('UpdateItem', _("Update"),
154 _('Confirm changes'), ICON_UPDATE);
155 button_cell('CancelItemChanges', _("Cancel"),
156 _('Cancel changes'), ICON_CANCEL);
157 hidden('LineNo', $line_no);
162 submit_cells('AddItem', _("Add Item"), "colspan=2",
163 _('Add new item to document'), true);
170 //---------------------------------------------------------------------------------
172 function adjustment_options_controls()
177 textarea_row(_("Memo"), 'memo_', null, 50, 3);
183 //---------------------------------------------------------------------------------