3 include_once($path_to_root . "/includes/ui.inc");
4 include_once($path_to_root . "/includes/ui/items_cart.inc");
6 //--------------------------------------------------------------------------------
8 function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost)
10 if ($order->find_cart_item($new_item))
11 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.");
13 $order->add_to_cart (count($order->line_items), $new_item, $new_item_qty, $standard_cost);
16 //--------------------------------------------------------------------------------
18 function display_order_header(&$order)
22 start_table("width=70% $table_style2"); // outer table
23 echo "<tr><td valign=top width=33%>";
24 echo "<table>"; // inner table
26 locations_list_row(_("Location:"), 'StockLocation', null);
27 ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::inventory_adjustment()));
29 echo "</table>"; // inner table
31 echo "</td><td width=33%>";
33 echo "<table>"; // inner table
35 date_row(_("Date:"), 'AdjDate');
37 echo "</table>"; // inner table
39 echo "</td><td width=33%>";
41 echo "<table>"; // inner table
42 movement_types_list_row(_("Detail:"), 'type', null);
44 if (!isset($_POST['Increase']))
45 $_POST['Increase'] = 1;
46 yesno_list_row(_("Type:"), 'Increase', $_POST['Increase'],
47 _("Positive Adjustment"), _("Negative Adjustment"));
49 echo "</table>"; // inner table
52 end_table(1); // outer table
55 //---------------------------------------------------------------------------------
57 function display_adjustment_items($title, &$order)
59 global $table_style, $path_to_root;
61 display_heading($title);
62 div_start('items_table');
63 start_table("$table_style width=80%");
64 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
65 _("Unit"), _("Unit Cost"), _("Total"));
66 if ( count($order->line_items)) $th[] = '';
70 $k = 0; //row colour counter
72 $id = find_submit('Edit');
73 foreach ($order->line_items as $line_no=>$stock_item)
76 $total += ($stock_item->standard_cost * $stock_item->quantity);
80 alt_table_row_color($k);
82 view_stock_status_cell($stock_item->stock_id);
83 label_cell($stock_item->item_description);
84 qty_cell($stock_item->quantity, false, get_qty_dec($stock_item->stock_id));
85 label_cell($stock_item->units);
86 amount_cell($stock_item->standard_cost);
87 amount_cell($stock_item->standard_cost * $stock_item->quantity);
89 edit_button_cell("Edit$line_no", _("Edit"),
90 _('Edit document line'));
91 edit_button_cell("Delete$line_no", _("Delete"),
92 _('Remove line from document'));
97 adjustment_edit_item_controls($order, $line_no);
102 adjustment_edit_item_controls($order);
104 label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right");
110 //---------------------------------------------------------------------------------
112 function adjustment_edit_item_controls(&$order, $line_no=-1)
117 $id = find_submit('Edit');
118 if ($line_no != -1 && $line_no == $id)
120 $_POST['stock_id'] = $order->line_items[$id]->stock_id;
121 $_POST['qty'] = qty_format($order->line_items[$id]->quantity,
122 $order->line_items[$id]->stock_id, $dec);
123 $_POST['std_cost'] = price_format($order->line_items[$id]->standard_cost);
124 $_POST['units'] = $order->line_items[$id]->units;
126 hidden('stock_id', $_POST['stock_id']);
127 label_cell($_POST['stock_id']);
128 label_cell($order->line_items[$id]->item_description, 'nowrap');
129 $Ajax->activate('items_table');
133 stock_costable_items_list_cells(null, 'stock_id', null, false, true);
134 if (list_updated('stock_id')) {
135 $Ajax->activate('units');
136 $Ajax->activate('qty');
137 $Ajax->activate('std_cost');
140 $item_info = get_item_edit_info($_POST['stock_id']);
142 $_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec);
143 $_POST['std_cost'] = price_format($item_info["standard_cost"]);
144 $_POST['units'] = $item_info["units"];
147 qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
148 label_cell($_POST['units'], '', 'units');
150 amount_cells(null, 'std_cost', $_POST['std_cost']);
151 label_cell(" ");
155 edit_button_cell('UpdateItem', _("Update"),
156 _('Confirm changes'));
157 edit_button_cell('CancelItemChanges', _("Cancel"),
158 _('Cancel changes'));
159 hidden('LineNo', $line_no);
164 submit_cells('AddItem', _("Add Item"), "colspan=2",
165 _('Add new item to document'), true);
172 //---------------------------------------------------------------------------------
174 function adjustment_options_controls()
179 textarea_row(_("Memo"), 'memo_', null, 50, 3);
185 //---------------------------------------------------------------------------------