*** empty log message ***
[fa-stable.git] / inventory / includes / stock_transfers_ui.inc
1 <?php
2
3 include_once($path_to_root . "/includes/ui.inc");
4 include_once($path_to_root . "/includes/ui/items_cart.inc");
5
6 //--------------------------------------------------------------------------------
7
8 function add_to_order(&$order, $new_item, $new_item_qty, $standard_cost)
9 {
10     $already_on_order = 0;
11
12         foreach ($order->line_items as $order_item) 
13         {
14         if (strcasecmp($order_item->stock_id, $new_item) == 0) 
15         {
16             $already_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.");
18         }
19         }
20
21     if ($already_on_order != 1)
22     {
23          $order->add_to_cart ($new_item, $new_item_qty, $standard_cost);
24     } /* end of if not already on the order */
25 }
26
27 //--------------------------------------------------------------------------------
28
29 function display_order_header(&$order)
30 {
31         global $table_style;
32
33         start_table("width=70% $table_style");
34         echo "<tr><td width=33% valign=top>"; // outer table
35         echo "<table>";
36
37         locations_list_row(_("From Location:"), 'FromStockLocation', null);
38         locations_list_row(_("To Location:"), 'ToStockLocation', null);
39
40         echo "</table>";
41
42         echo "</td><td width=33%>"; // outer table
43
44         echo "<table>";
45
46         ref_row(_("Reference:"), 'ref', references::get_next(systypes::location_transfer()));
47
48     date_row(_("Date:"), 'AdjDate');
49
50         echo "</table>";
51
52         echo "</td><td width=33%>"; // outer table
53
54         echo "<table>";
55     movement_types_list_row(_("Transfer Type:"), 'type', null);
56         echo "</table>";
57
58         echo "</td></tr>";
59         end_table(1); // outer table
60 }
61
62 //---------------------------------------------------------------------------------
63
64 function display_transfer_items($title, &$order)
65 {
66         global $table_style, $path_to_root;
67
68         display_heading($title);
69         start_table("$table_style width=80%");
70         $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"));
71         table_header($th);
72         $subtotal = 0;
73         $k = 0;  //row colour counter
74
75         foreach ($order->line_items as $stock_item) 
76         {
77
78                 $quantity = number_format2($stock_item->quantity,user_qty_dec());
79
80                 if (!isset($_GET['Edit']) || $_GET['Edit'] != $stock_item->stock_id)
81                 {
82                 alt_table_row_color($k);
83
84                 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>");
85                 label_cell($stock_item->item_description);
86                 label_cell($quantity, "nowrap align=right");
87                 label_cell($stock_item->units);
88
89                         edit_link_cell(SID . "Edit=$stock_item->stock_id");
90                         delete_link_cell(SID . "Delete=$stock_item->stock_id");
91                 end_row();
92                 } 
93                 else 
94                 {
95                         transfer_edit_item_controls($order, $stock_item->stock_id);
96                 }
97         }
98
99         if (!isset($_GET['Edit']))
100                 transfer_edit_item_controls($order);
101
102     end_table();
103 }
104
105 //---------------------------------------------------------------------------------
106
107 function transfer_edit_item_controls(&$order, $stock_id=null)
108 {
109         start_row();
110
111         if (isset($_GET['Edit']) and $stock_id!=null)
112         {
113                 if (!isset($_POST['stock_id']))
114                         $_POST['stock_id'] = $order->line_items[$stock_id]->stock_id;
115                 if (!isset($_POST['qty']) || ($_POST['qty']==""))
116                         $_POST['qty'] = $order->line_items[$stock_id]->quantity;
117
118                 $_POST['units'] = $order->line_items[$stock_id]->units;
119
120                 hidden('stock_id', $_POST['stock_id']);
121                 label_cell($_POST['stock_id']);
122                 label_cell($order->line_items[$stock_id]->item_description);
123         }
124         else
125         {
126         echo "<TD colspan=2>";
127         stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
128         echo "</TD>";
129
130         $item_info = get_item_edit_info($_POST['stock_id']);
131
132                 $_POST['qty'] = 0;
133                 $_POST['units'] = $item_info["units"];
134         }
135
136
137         text_cells(null, 'qty', $_POST['qty'], 13, 15);
138         label_cell($_POST['units']);
139
140         if (isset($_GET['Edit'])) 
141         {
142         submit_cells('UpdateItem', _("Update"));
143         submit_cells('CancelItemChanges', _("Cancel"));
144         } 
145         else 
146         {
147                 submit_cells('AddItem', _("Add Item"), "colspan=2");
148         }
149
150         end_row();
151 }
152
153
154 //---------------------------------------------------------------------------------
155
156 function transfer_options_controls()
157 {
158           echo "<br>";
159           start_table();
160
161           textarea_row(_("Memo"), 'memo_', null, 50, 3);
162
163           end_table(1);
164 }
165
166
167 //---------------------------------------------------------------------------------
168
169 ?>