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 alt_table_row_color($k);
65 label_cells(_("Standard Labour Cost"), number_format2($item['labour_cost'],user_price_dec()),
66 "colspan=6 align=left", "class=odd_row nowrap align=right");
69 if ($item['overhead_cost'] != 0)
71 alt_table_row_color($k);
72 label_cells(_("Standard Overhead Cost"), number_format2($item['overhead_cost'],user_price_dec()),
73 "colspan=6 align=left", "nowrap align=right");
76 label_row("<b>" . _("Total Cost") . "</b>", "<b>" . number_format2($total_cost,user_price_dec()) ."</b>",
77 "colspan=6 align=right", "nowrap align=right");
82 //--------------------------------------------------------------------------------------
84 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
88 $result = get_wo_requirements($woid);
90 if (db_num_rows($result) == 0)
92 display_note(_("There are no Requirements for this Order."), 1, 0);
97 start_table(TABLESTYLE, "width='80%'");
98 $th = array(_("Component"), _("From Location"), _("Work Centre"),
99 _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand"));
103 $k = 0; //row colour counter
109 while ($myrow = db_fetch($result))
114 // if it's a non-stock item (eg. service) don't show qoh
115 if (!has_stock_holding($myrow["mb_flag"]))
119 $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date);
121 if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
122 !$SysPrefs->allow_negative_stock())
124 // oops, we don't have enough of one of the component items
125 start_row("class='stockmankobg'");
129 alt_table_row_color($k);
131 if (user_show_codes())
132 label_cell($myrow["stock_id"]. " - " . $myrow["description"]);
134 label_cell($myrow["description"]);
136 label_cell($myrow["location_name"]);
137 label_cell($myrow["WorkCentreDescription"]);
138 $dec = get_qty_dec($myrow["stock_id"]);
139 qty_cell($myrow["units_req"], false, $dec);
140 qty_cell($myrow["units_req"] * $quantity, false, $dec);
141 qty_cell($myrow["units_issued"], false, $dec);
143 qty_cell($qoh, false, $dec);
153 display_note(_("Marked items have insufficient quantities in stock."), 0, 0, "class='red'");
157 //--------------------------------------------------------------------------------------
159 function display_wo_productions($woid)
161 global $path_to_root;
163 $result = get_work_order_productions($woid);
165 if (db_num_rows($result) == 0)
167 display_note(_("There are no Productions for this Order."), 1, 1);
171 start_table(TABLESTYLE);
172 $th = array(_("#"), _("Reference"), _("Date"), _("Quantity"));
176 $k = 0; //row colour counter
179 while ($myrow = db_fetch($result))
182 alt_table_row_color($k);
184 $total_qty += $myrow['quantity'];
186 label_cell(get_trans_view_str(ST_MANURECEIVE, $myrow["id"]));
187 label_cell($myrow['reference']);
188 label_cell(sql2date($myrow["date_"]));
189 qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference']));
193 label_row(_("Total"), number_format2($total_qty,user_qty_dec()),
194 "colspan=3", "nowrap align=right");
200 //--------------------------------------------------------------------------------------
202 function display_wo_issues($woid)
204 global $path_to_root;
206 $result = get_work_order_issues($woid);
208 if (db_num_rows($result) == 0)
210 display_note(_("There are no Issues for this Order."), 0, 1);
214 start_table(TABLESTYLE);
215 $th = array(_("#"), _("Reference"), _("Date"));
219 $k = 0; //row colour counter
221 while ($myrow = db_fetch($result))
224 alt_table_row_color($k);
226 label_cell(get_trans_view_str(ST_MANUISSUE, $myrow["issue_no"]));
227 label_cell($myrow['reference']);
228 label_cell(sql2date($myrow["issue_date"]));
236 //--------------------------------------------------------------------------------------
238 function display_wo_payments($woid)
240 global $path_to_root, $wo_cost_types;
242 $result = get_wo_costing($woid);
244 if (db_num_rows($result) == 0)
246 display_note(_("There are no additional costs for this Order."), 0, 1);
250 start_table(TABLESTYLE);
251 $th = array(_("#"), _("Type"), _("Date"), _("Amount"));
256 while ($myrow = db_fetch($result))
258 alt_table_row_color($k);
260 label_cell(get_gl_view_str( $myrow["trans_type"], $myrow["trans_no"], $myrow["trans_no"]));
261 label_cell($wo_cost_types[$myrow['cost_type']]);
262 $date = sql2date($myrow["tran_date"]);
264 amount_cell(-($myrow['amount']));
272 //--------------------------------------------------------------------------------------
274 function display_wo_details($woid, $suppress_view_link=false)
276 global $wo_types_array;
278 $myrow = get_work_order($woid);
280 if (strlen($myrow[0]) == 0)
282 display_note(_("The work order number sent is not valid."));
286 start_table(TABLESTYLE, "width='80%'");
288 if ($myrow["released"] == true)
289 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
290 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"),
291 _("Released Date"), _("Manufactured"));
293 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
294 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"));
298 if ($suppress_view_link)
299 label_cell($myrow["id"]);
301 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
302 label_cell($myrow["wo_ref"]);
303 label_cell($wo_types_array[$myrow["type"]]);
304 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
305 label_cell($myrow["location_name"]);
306 label_cell(sql2date($myrow["date_"]));
307 label_cell(sql2date($myrow["required_by"]));
308 $dec = get_qty_dec($myrow["stock_id"]);
309 qty_cell($myrow["units_reqd"], false, $dec);
311 if ($myrow["released"] == true)
313 label_cell(sql2date($myrow["released_date"]));
314 qty_cell($myrow["units_issued"], false, $dec);
318 comments_display_row(ST_WORKORDER, $woid);
322 if ($myrow["closed"] == true)
324 display_note(_("This work order is closed."));
328 //--------------------------------------------------------------------------------------
330 function display_wo_details_quick($woid, $suppress_view_link=false)
332 global $wo_types_array;
334 $myrow = get_work_order($woid);
336 if (strlen($myrow[0]) == 0)
338 display_note(_("The work order number sent is not valid."));
342 start_table(TABLESTYLE, "width='80%'");
344 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
345 _("Into Location"), _("Date"), _("Quantity"));
349 if ($suppress_view_link)
350 label_cell($myrow["id"]);
352 label_cell(get_trans_view_str(ST_WORKORDER, $myrow["id"]));
353 label_cell($myrow["wo_ref"]);
354 label_cell($wo_types_array[$myrow["type"]]);
355 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
356 label_cell($myrow["location_name"]);
357 label_cell(sql2date($myrow["date_"]));
359 qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"]));
363 comments_display_row(ST_WORKORDER, $woid);
367 if ($myrow["closed"] == true)
369 display_note(_("This work order is closed."));