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"), _("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["ProductCost"]);
49 amount_cell($myrow["ComponentCost"]);
51 $total_cost += $myrow["ComponentCost"];
61 $item = get_item($item_check);
62 if ($item['labour_cost'] != 0)
64 $total_cost += $item['labour_cost'];
65 alt_table_row_color($k);
66 label_cells(_("Standard Labour Cost"), number_format2($item['labour_cost'],user_price_dec()),
67 "colspan=6 align=left", "class=odd_row nowrap align=right");
70 if ($item['overhead_cost'] != 0)
72 $total_cost += $item['overhead_cost'];
73 alt_table_row_color($k);
74 label_cells(_("Standard Overhead Cost"), number_format2($item['overhead_cost'],user_price_dec()),
75 "colspan=6 align=left", "nowrap align=right");
78 label_row("<b>" . _("Total Cost") . "</b>", "<b>" . number_format2($total_cost,user_price_dec()) ."</b>",
79 "colspan=6 align=right", "nowrap align=right");
84 //--------------------------------------------------------------------------------------
86 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
90 $result = get_wo_requirements($woid);
92 if (db_num_rows($result) == 0)
94 display_note(_("There are no Requirements for this Order."), 1, 0);
99 start_table(TABLESTYLE, "width='80%'");
100 $th = array(_("Component"), _("From Location"), _("Work Centre"),
101 _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand"));
105 $k = 0; //row colour counter
111 while ($myrow = db_fetch($result))
116 // if it's a non-stock item (eg. service) don't show qoh
117 if (!has_stock_holding($myrow["mb_flag"]))
121 $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date);
123 if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
124 !$SysPrefs->allow_negative_stock())
126 // oops, we don't have enough of one of the component items
127 start_row("class='stockmankobg'");
131 alt_table_row_color($k);
133 if (user_show_codes())
134 label_cell($myrow["stock_id"]. " - " . $myrow["description"]);
136 label_cell($myrow["description"]);
138 label_cell($myrow["location_name"]);
139 label_cell($myrow["WorkCentreDescription"]);
140 $dec = get_qty_dec($myrow["stock_id"]);
141 qty_cell($myrow["units_req"], false, $dec);
142 qty_cell($myrow["units_req"] * $quantity, false, $dec);
143 qty_cell($myrow["units_issued"], false, $dec);
145 qty_cell($qoh, false, $dec);
155 display_note(_("Marked items have insufficient quantities in stock."), 0, 0, "class='red'");
159 //--------------------------------------------------------------------------------------
161 function display_wo_productions($woid)
163 global $path_to_root;
165 $result = get_work_order_productions($woid);
167 if (db_num_rows($result) == 0)
169 display_note(_("There are no Productions for this Order."), 1, 1);
173 start_table(TABLESTYLE);
174 $th = array(_("#"), _("Reference"), _("Date"), _("Quantity"));
178 $k = 0; //row colour counter
181 while ($myrow = db_fetch($result))
184 alt_table_row_color($k);
186 $total_qty += $myrow['quantity'];
188 label_cell(get_trans_view_str(ST_MANURECEIVE, $myrow["id"]));
189 label_cell($myrow['reference']);
190 label_cell(sql2date($myrow["date_"]));
191 qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference']));
195 label_row(_("Total"), number_format2($total_qty,user_qty_dec()),
196 "colspan=3", "nowrap align=right");
202 //--------------------------------------------------------------------------------------
204 function display_wo_issues($woid)
206 global $path_to_root;
208 $result = get_work_order_issues($woid);
210 if (db_num_rows($result) == 0)
212 display_note(_("There are no Issues for this Order."), 0, 1);
216 start_table(TABLESTYLE);
217 $th = array(_("#"), _("Reference"), _("Date"));
221 $k = 0; //row colour counter
223 while ($myrow = db_fetch($result))
226 alt_table_row_color($k);
228 label_cell(get_trans_view_str(ST_MANUISSUE, $myrow["issue_no"]));
229 label_cell($myrow['reference']);
230 label_cell(sql2date($myrow["issue_date"]));
238 //--------------------------------------------------------------------------------------
240 function display_wo_payments($woid)
242 global $path_to_root, $wo_cost_types;
244 $result = get_wo_costing($woid);
246 if (db_num_rows($result) == 0)
248 display_note(_("There are no additional costs for this Order."), 0, 1);
252 start_table(TABLESTYLE);
253 $th = array(_("#"), _("Type"), _("Date"), _("Amount"));
258 while ($myrow = db_fetch($result))
260 alt_table_row_color($k);
262 label_cell(get_gl_view_str( $myrow["trans_type"], $myrow["trans_no"], $myrow["trans_no"]));
263 label_cell($wo_cost_types[$myrow['cost_type']]);
264 $date = sql2date($myrow["tran_date"]);
266 amount_cell($myrow['amount']);
274 //--------------------------------------------------------------------------------------
276 function display_wo_details($woid, $suppress_view_link=false)
278 global $wo_types_array;
280 $myrow = get_work_order($woid, true);
284 display_note(_("The work order number sent is not valid."));
288 start_table(TABLESTYLE, "width='80%'");
290 if ($myrow["released"] == true)
291 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
292 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"),
293 _("Released Date"), _("Manufactured"));
295 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
296 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"));
300 if ($suppress_view_link)
301 label_cell($myrow["id"]);
303 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
304 label_cell($myrow["wo_ref"]);
305 label_cell($wo_types_array[$myrow["type"]]);
306 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
307 label_cell($myrow["location_name"]);
308 label_cell(sql2date($myrow["date_"]));
309 label_cell(sql2date($myrow["required_by"]));
310 $dec = get_qty_dec($myrow["stock_id"]);
311 qty_cell($myrow["units_reqd"], false, $dec);
313 if ($myrow["released"] == true)
315 label_cell(sql2date($myrow["released_date"]));
316 qty_cell($myrow["units_issued"], false, $dec);
320 comments_display_row(ST_WORKORDER, $woid);
324 if ($myrow["closed"] == true)
326 display_note(_("This work order is closed."));
330 //--------------------------------------------------------------------------------------
332 function display_wo_details_quick($woid, $suppress_view_link=false)
334 global $wo_types_array;
336 $myrow = get_work_order($woid, true);
338 if ($myrow === false)
340 display_note(_("The work order number sent is not valid."));
344 start_table(TABLESTYLE, "width='80%'");
346 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
347 _("Into Location"), _("Date"), _("Quantity"));
351 if ($suppress_view_link)
352 label_cell($myrow["id"]);
354 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
355 label_cell($myrow["wo_ref"]);
356 label_cell($wo_types_array[$myrow["type"]]);
357 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
358 label_cell($myrow["location_name"]);
359 label_cell(sql2date($myrow["date_"]));
361 qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"]));
365 comments_display_row(ST_WORKORDER, $woid);
369 if ($myrow["closed"] == true)
371 display_note(_("This work order is closed."));