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"));
76 if ( count($order->line_items)) $th[] = '';
80 $k = 0; //row colour counter
82 foreach ($order->line_items as $stock_item)
85 $quantity = number_format2($stock_item->quantity,user_qty_dec());
87 $total += ($stock_item->standard_cost * $stock_item->quantity);
89 if (!isset($_GET['Edit']) || $_GET['Edit'] != $stock_item->stock_id)
91 alt_table_row_color($k);
93 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>");
94 label_cell($stock_item->item_description);
95 label_cell($quantity, "nowrap align=right");
96 label_cell($stock_item->units);
97 amount_cell($stock_item->standard_cost);
98 amount_cell($stock_item->standard_cost * $stock_item->quantity);
100 edit_link_cell(SID . "Edit=$stock_item->stock_id");
101 delete_link_cell(SID . "Delete=$stock_item->stock_id");
106 adjustment_edit_item_controls($order, $stock_item->stock_id);
110 if (!isset($_GET['Edit']))
111 adjustment_edit_item_controls($order);
113 label_row(_("Total"), number_format2($total,user_price_dec()), "colspan=5", "align=right");
118 //---------------------------------------------------------------------------------
120 function adjustment_edit_item_controls(&$order, $stock_id=null)
124 if (isset($_GET['Edit']) and $stock_id!=null)
126 if (!isset($_POST['stock_id']))
127 $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id;
128 if (!isset($_POST['qty']) OR ($_POST['qty']==""))
129 $_POST['qty'] = qty_format($order->line_items[$stock_id]->quantity, $order->line_items[$stock_id]->stock_id, $dec);
130 if (!isset($_POST['std_cost']) OR ($_POST['std_cost']==""))
131 $_POST['std_cost'] = price_format($order->line_items[$stock_id]->standard_cost);
133 $_POST['units'] = $order->line_items[$stock_id]->units;
135 hidden('stock_id', $_POST['stock_id']);
136 label_cell($_POST['stock_id']);
137 label_cell($order->line_items[$stock_id]->item_description);
141 echo "<td colspan=2>";
142 stock_costable_items_list('stock_id', null, false, true);
145 $item_info = get_item_edit_info($_POST['stock_id']);
147 $_POST['qty'] = qty_format(0, $_POST['stock_id'], $dec);
148 $_POST['std_cost'] = price_format($item_info["standard_cost"]);
149 $_POST['units'] = $item_info["units"];
152 qty_cells(null, 'qty', $_POST['qty'], null, null, $dec);
154 label_cell($_POST['units']);
155 amount_cells(null, 'std_cost', $_POST['std_cost']);
156 label_cell(" ");
158 if (isset($_GET['Edit']))
160 submit_cells('UpdateItem', _("Update"));
161 submit_cells('CancelItemChanges', _("Cancel"));
165 submit_cells('AddItem', _("Add Item"), "colspan=2");
172 //---------------------------------------------------------------------------------
174 function adjustment_options_controls()
179 textarea_row(_("Memo"), 'memo_', null, 50, 3);
185 //---------------------------------------------------------------------------------