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");
14 //--------------------------------------------------------------------------------------
16 function display_bom($item_check)
18 $result = get_bom($item_check);
20 if (db_num_rows($result) == 0)
22 display_note(_("The bill of material for this item is empty."), 0, 1);
27 start_table(TABLESTYLE);
28 $th = array(_("Component"), _("Description"), _("Work Centre"),
29 _("From Location"), _("Quantity"), _("Unit Cost"), _("Total Cost"));
34 $k = 0; //row colour counter
38 while ($myrow = db_fetch($result))
41 alt_table_row_color($k);
43 label_cell($myrow["component"]);
44 label_cell($myrow["description"]);
45 label_cell($myrow["WorkCentreDescription"]);
46 label_cell($myrow["location_name"]);
47 qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
48 amount_cell($myrow["standard_cost"]);
49 amount_cell($myrow["ComponentCost"]);
51 $total_cost += $myrow["ComponentCost"];
58 }//end of page full new headings if
61 label_row("<b>" . _("Total Cost") . "</b>", "<b>" . number_format2($total_cost,user_price_dec()) ."</b>",
62 "colspan=6 align=right", "nowrap align=right");
67 //--------------------------------------------------------------------------------------
69 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
73 $result = get_wo_requirements($woid);
75 if (db_num_rows($result) == 0)
77 display_note(_("There are no Requirements for this Order."), 1, 0);
82 start_table(TABLESTYLE, "width=80%");
83 $th = array(_("Component"), _("From Location"), _("Work Centre"),
84 _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand"));
88 $k = 0; //row colour counter
94 while ($myrow = db_fetch($result))
99 // if it's a non-stock item (eg. service) don't show qoh
100 if (!has_stock_holding($myrow["mb_flag"]))
104 $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date);
106 if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
107 !$SysPrefs->allow_negative_stock())
109 // oops, we don't have enough of one of the component items
110 start_row("class='stockmankobg'");
114 alt_table_row_color($k);
116 if (user_show_codes())
117 label_cell($myrow["stock_id"]. " - " . $myrow["description"]);
119 label_cell($myrow["description"]);
121 label_cell($myrow["location_name"]);
122 label_cell($myrow["WorkCentreDescription"]);
123 $dec = get_qty_dec($myrow["stock_id"]);
124 qty_cell($myrow["units_req"], false, $dec);
125 qty_cell($myrow["units_req"] * $quantity, false, $dec);
126 qty_cell($myrow["units_issued"], false, $dec);
128 qty_cell($qoh, false, $dec);
138 display_note(_("Marked items have insufficient quantities in stock."), 0, 0, "class='red'");
142 //--------------------------------------------------------------------------------------
144 function display_wo_productions($woid)
146 global $path_to_root;
148 $result = get_work_order_productions($woid);
150 if (db_num_rows($result) == 0)
152 display_note(_("There are no Productions for this Order."), 1, 1);
156 start_table(TABLESTYLE);
157 $th = array(_("#"), _("Reference"), _("Date"), _("Quantity"));
161 $k = 0; //row colour counter
164 while ($myrow = db_fetch($result))
167 alt_table_row_color($k);
169 $total_qty += $myrow['quantity'];
171 label_cell(get_trans_view_str(29, $myrow["id"]));
172 label_cell($myrow['reference']);
173 label_cell(sql2date($myrow["date_"]));
174 qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference']));
178 label_row(_("Total"), number_format2($total_qty,user_qty_dec()),
179 "colspan=3", "nowrap align=right");
185 //--------------------------------------------------------------------------------------
187 function display_wo_issues($woid)
189 global $path_to_root;
191 $result = get_work_order_issues($woid);
193 if (db_num_rows($result) == 0)
195 display_note(_("There are no Issues for this Order."), 0, 1);
199 start_table(TABLESTYLE);
200 $th = array(_("#"), _("Reference"), _("Date"));
204 $k = 0; //row colour counter
206 while ($myrow = db_fetch($result))
209 alt_table_row_color($k);
211 label_cell(get_trans_view_str(28, $myrow["issue_no"]));
212 label_cell($myrow['reference']);
213 label_cell(sql2date($myrow["issue_date"]));
221 //--------------------------------------------------------------------------------------
223 function display_wo_payments($woid)
225 global $path_to_root, $wo_cost_types;
227 $result = get_gl_wo_cost_trans($woid);
229 if (db_num_rows($result) == 0)
231 display_note(_("There are no additional costs for this Order."), 0, 1);
235 start_table(TABLESTYLE);
236 $th = array(_("#"), _("Type"), _("Date"), _("Amount"));
240 $k = 0; //row colour counter
242 while ($myrow = db_fetch($result))
245 alt_table_row_color($k);
247 label_cell(get_gl_view_str(ST_WORKORDER, $myrow["type_no"], $myrow["type_no"]));
248 label_cell($wo_cost_types[$myrow['person_id']]);
249 $date = sql2date($myrow["tran_date"]);
251 amount_cell(-($myrow['amount']));
259 //--------------------------------------------------------------------------------------
261 function display_wo_details($woid, $suppress_view_link=false)
263 global $wo_types_array;
265 $myrow = get_work_order($woid);
267 if (strlen($myrow[0]) == 0)
269 display_note(_("The work order number sent is not valid."));
273 start_table(TABLESTYLE, "width=80%");
275 if ($myrow["released"] == true)
276 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
277 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"),
278 _("Released Date"), _("Manufactured"));
280 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
281 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"));
285 if ($suppress_view_link)
286 label_cell($myrow["id"]);
288 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
289 label_cell($myrow["wo_ref"]);
290 label_cell($wo_types_array[$myrow["type"]]);
291 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
292 label_cell($myrow["location_name"]);
293 label_cell(sql2date($myrow["date_"]));
294 label_cell(sql2date($myrow["required_by"]));
295 $dec = get_qty_dec($myrow["stock_id"]);
296 qty_cell($myrow["units_reqd"], false, $dec);
298 if ($myrow["released"] == true)
300 label_cell(sql2date($myrow["released_date"]));
301 qty_cell($myrow["units_issued"], false, $dec);
305 comments_display_row(ST_WORKORDER, $woid);
309 if ($myrow["closed"] == true)
311 display_note(_("This work order is closed."));
315 //--------------------------------------------------------------------------------------
317 function display_wo_details_quick($woid, $suppress_view_link=false)
319 global $wo_types_array;
321 $myrow = get_work_order($woid);
323 if (strlen($myrow[0]) == 0)
325 display_note(_("The work order number sent is not valid."));
329 start_table(TABLESTYLE, "width=80%");
331 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
332 _("Into Location"), _("Date"), _("Quantity"));
336 if ($suppress_view_link)
337 label_cell($myrow["id"]);
339 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
340 label_cell($myrow["wo_ref"]);
341 label_cell($wo_types_array[$myrow["type"]]);
342 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
343 label_cell($myrow["location_name"]);
344 label_cell(sql2date($myrow["date_"]));
346 qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"]));
350 comments_display_row(ST_WORKORDER, $woid);
354 if ($myrow["closed"] == true)
356 display_note(_("This work order is closed."));