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 $allready_on_order = 0;
12 foreach ($order->line_items as $order_item)
14 if (strcasecmp($order_item->stock_id, $new_item) == 0)
16 $allready_on_order = 1;
17 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.");
21 if ($allready_on_order != 1)
23 $order->add_to_cart ($new_item, $new_item_qty, $standard_cost);
24 } /* end of if not already on the order */
27 //--------------------------------------------------------------------------------
29 function display_order_header(&$order)
33 start_table("width=70% $table_style2"); // outer table
34 echo "<tr><td valign=top width=33%>";
35 echo "<table>"; // inner table
37 locations_list_row(_("Location:"), 'StockLocation', null);
38 ref_row(_("Reference:"), 'ref', references::get_next(systypes::inventory_adjustment()));
40 echo "</table>"; // inner table
42 echo "</td><td width=33%>";
44 echo "<table>"; // inner table
46 date_row(_("Date:"), 'AdjDate');
48 echo "</table>"; // inner table
50 echo "</td><td width=33%>";
52 echo "<table>"; // inner table
53 movement_types_list_row(_("Detail:"), 'type', null);
55 if (!isset($_POST['Increase']))
56 $_POST['Increase'] = 1;
57 yesno_list_row(_("Type:"), 'Increase', $_POST['Increase'],
58 _("Positive Adjustment"), _("Negative Adjustment"));
60 echo "</table>"; // inner table
63 end_table(1); // outer table
66 //---------------------------------------------------------------------------------
68 function display_adjustment_items($title, &$order)
70 global $table_style, $path_to_root;
72 display_heading($title);
73 start_table("$table_style width=80%");
74 $th = array(_("Item Code"), _("Item Description"), _("Quantity"),
75 _("Unit"), _("Unit Cost"), _("Total"));
78 $k = 0; //row colour counter
80 foreach ($order->line_items as $stock_item)
83 $quantity = number_format2($stock_item->quantity,user_qty_dec());
85 $total += ($stock_item->standard_cost * $stock_item->quantity);
87 if (!isset($_GET['Edit']) || $_GET['Edit'] != $stock_item->stock_id)
89 alt_table_row_color($k);
91 label_cell("<a target='_blank' href='$path_to_root/inventory/inquiry/stock_status.php?" . SID . "stock_id=" . $stock_item->stock_id . "'>$stock_item->stock_id</a>");
92 label_cell($stock_item->item_description);
93 label_cell($quantity, "nowrap align=right");
94 label_cell($stock_item->units);
95 amount_cell($stock_item->standard_cost);
96 amount_cell($stock_item->standard_cost * $stock_item->quantity);
98 edit_link_cell(SID . "Edit=$stock_item->stock_id");
99 delete_link_cell(SID . "Delete=$stock_item->stock_id");
104 adjustment_edit_item_controls($order, $stock_item->stock_id);
108 if (!isset($_GET['Edit']))
109 adjustment_edit_item_controls($order);
111 label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right");
116 //---------------------------------------------------------------------------------
118 function adjustment_edit_item_controls(&$order, $stock_id=null)
122 if (isset($_GET['Edit']) and $stock_id!=null)
124 if (!isset($_POST['stock_id']))
125 $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id;
126 if (!isset($_POST['qty']) OR ($_POST['qty']==""))
127 $_POST['qty'] = $order->line_items[$stock_id]->quantity;
128 if (!isset($_POST['std_cost']) OR ($_POST['std_cost']==""))
129 $_POST['std_cost'] = $order->line_items[$stock_id]->standard_cost;
131 $_POST['units'] = $order->line_items[$stock_id]->units;
133 hidden('stock_id', $_POST['stock_id']);
134 label_cell($_POST['stock_id']);
135 label_cell($order->line_items[$stock_id]->item_description);
139 echo "<td colspan=2>";
140 stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
143 $item_info = get_item_edit_info($_POST['stock_id']);
146 $_POST['std_cost'] = $item_info["standard_cost"];
147 $_POST['units'] = $item_info["units"];
150 text_cells(null, 'qty', $_POST['qty'], 13, 15);
152 label_cell($_POST['units']);
153 text_cells(null, 'std_cost', $_POST['std_cost'], 15, 14);
154 label_cell(" ");
156 if (isset($_GET['Edit']))
158 submit_cells('UpdateItem', _("Update"));
159 submit_cells('CancelItemChanges', _("Cancel"));
163 submit_cells('AddItem', _("Add Item"), "colspan=2");
170 //---------------------------------------------------------------------------------
172 function adjustment_options_controls()
177 textarea_row(_("Memo"), 'memo_', null, 50, 3);
183 //---------------------------------------------------------------------------------