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)
20 $result = get_bom($item_check);
22 if (db_num_rows($result) == 0)
24 display_note(_("The bill of material for this item is empty."), 0, 1);
29 start_table($table_style);
30 $th = array(_("Component"), _("Description"), _("Work Centre"),
31 _("From Location"), _("Quantity"), _("Unit Cost"), _("Total Cost"));
36 $k = 0; //row colour counter
40 while ($myrow = db_fetch($result))
43 alt_table_row_color($k);
45 label_cell($myrow["component"]);
46 label_cell($myrow["description"]);
47 label_cell($myrow["WorkCentreDescription"]);
48 label_cell($myrow["location_name"]);
49 qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"]));
50 amount_cell($myrow["standard_cost"]);
51 amount_cell($myrow["ComponentCost"]);
53 $total_cost += $myrow["ComponentCost"];
60 }//end of page full new headings if
63 label_row("<b>" . _("Total Cost") . "</b>", "<b>" . number_format2($total_cost,user_price_dec()) ."</b>",
64 "colspan=6 align=right", "nowrap align=right");
69 //--------------------------------------------------------------------------------------
71 function display_wo_requirements($woid, $quantity, $show_qoh=false, $date=null)
75 $result = get_wo_requirements($woid);
77 if (db_num_rows($result) == 0)
79 display_note(_("There are no Requirements for this Order."), 1, 0);
84 start_table("$table_style width=80%");
85 $th = array(_("Component"), _("From Location"), _("Work Centre"),
86 _("Unit Quantity"), _("Total Quantity"), _("Units Issued"), _("On Hand"));
90 $k = 0; //row colour counter
96 while ($myrow = db_fetch($result))
101 // if it's a non-stock item (eg. service) don't show qoh
102 if (!has_stock_holding($myrow["mb_flag"]))
106 $qoh = get_qoh_on_date($myrow["stock_id"], $myrow["loc_code"], $date);
108 if ($show_qoh && ($myrow["units_req"] * $quantity > $qoh) &&
109 !sys_prefs::allow_negative_stock())
111 // oops, we don't have enough of one of the component items
112 start_row("class='stockmankobg'");
116 alt_table_row_color($k);
118 if (user_show_codes())
119 label_cell($myrow["stock_id"]. " - " . $myrow["description"]);
121 label_cell($myrow["description"]);
123 label_cell($myrow["location_name"]);
124 label_cell($myrow["WorkCentreDescription"]);
125 $dec = get_qty_dec($myrow["stock_id"]);
126 qty_cell($myrow["units_req"], false, $dec);
127 qty_cell($myrow["units_req"] * $quantity, false, $dec);
128 qty_cell($myrow["units_issued"], false, $dec);
130 qty_cell($qoh, false, $dec);
140 display_note(_("Marked items have insufficient quantities in stock."), 0, 0, "class='red'");
144 //--------------------------------------------------------------------------------------
146 function display_wo_productions($woid)
148 global $path_to_root, $table_style;
150 $result = get_work_order_productions($woid);
152 if (db_num_rows($result) == 0)
154 display_note(_("There are no Productions for this Order."), 1, 1);
158 start_table($table_style);
159 $th = array(_("#"), _("Reference"), _("Date"), _("Quantity"));
163 $k = 0; //row colour counter
166 while ($myrow = db_fetch($result))
169 alt_table_row_color($k);
171 $total_qty += $myrow['quantity'];
173 label_cell(get_trans_view_str(29, $myrow["id"]));
174 label_cell($myrow['reference']);
175 label_cell(sql2date($myrow["date_"]));
176 qty_cell($myrow['quantity'], false, get_qty_dec($myrow['reference']));
180 label_row(_("Total"), number_format2($total_qty,user_qty_dec()),
181 "colspan=3", "nowrap align=right");
187 //--------------------------------------------------------------------------------------
189 function display_wo_issues($woid)
191 global $path_to_root, $table_style;
193 $result = get_work_order_issues($woid);
195 if (db_num_rows($result) == 0)
197 display_note(_("There are no Issues for this Order."), 0, 1);
201 start_table($table_style);
202 $th = array(_("#"), _("Reference"), _("Date"));
206 $k = 0; //row colour counter
208 while ($myrow = db_fetch($result))
211 alt_table_row_color($k);
213 label_cell(get_trans_view_str(28, $myrow["issue_no"]));
214 label_cell($myrow['reference']);
215 label_cell(sql2date($myrow["issue_date"]));
223 //--------------------------------------------------------------------------------------
225 function display_wo_payments($woid)
227 global $path_to_root, $table_style;
229 $result = get_bank_trans(null, null, payment_person_types::WorkOrder(), $woid);
231 if (db_num_rows($result) == 0)
233 display_note(_("There are no Payments for this Order."), 0, 1);
237 start_table($table_style);
238 $th = array(_("#"), _("Reference"), _("Date"), _("Amount"));
242 $k = 0; //row colour counter
244 while ($myrow = db_fetch($result))
247 alt_table_row_color($k);
249 label_cell(get_trans_view_str(1, $myrow["trans_no"]));
250 label_cell($myrow['ref']);
251 label_cell(sql2date($myrow["trans_date"]));
252 amount_cell(-($myrow['amount']));
253 label_cell($myrow['bank_curr_code']);
261 //--------------------------------------------------------------------------------------
263 function display_wo_details($woid, $suppress_view_link=false)
267 $myrow = get_work_order($woid);
269 if (strlen($myrow[0]) == 0)
271 display_note(_("The work order number sent is not valid."));
275 start_table("$table_style width=80%");
277 if ($myrow["released"] == true)
278 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
279 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"),
280 _("Released Date"), _("Manufactured"));
282 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
283 _("Into Location"), _("Date"), _("Required By"), _("Quantity Required"));
287 if ($suppress_view_link)
288 label_cell($myrow["id"]);
290 label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"]));
291 label_cell($myrow["wo_ref"]);
292 label_cell(wo_types::name($myrow["type"]));
293 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
294 label_cell($myrow["location_name"]);
295 label_cell(sql2date($myrow["date_"]));
296 label_cell(sql2date($myrow["required_by"]));
297 $dec = get_qty_dec($myrow["stock_id"]);
298 qty_cell($myrow["units_reqd"], false, $dec);
300 if ($myrow["released"] == true)
302 label_cell(sql2date($myrow["released_date"]));
303 qty_cell($myrow["units_issued"], false, $dec);
307 comments_display_row(systypes::work_order(), $woid);
311 if ($myrow["closed"] == true)
313 display_note(_("This work order is closed."));
317 //--------------------------------------------------------------------------------------
319 function display_wo_details_quick($woid, $suppress_view_link=false)
323 $myrow = get_work_order($woid);
325 if (strlen($myrow[0]) == 0)
327 display_note(_("The work order number sent is not valid."));
331 start_table("$table_style width=80%");
333 $th = array(_("#"), _("Reference"), _("Type"), _("Manufactured Item"),
334 _("Into Location"), _("Date"), _("Quantity"));
338 if ($suppress_view_link)
339 label_cell($myrow["id"]);
341 label_cell(get_trans_view_str(systypes::work_order(), $myrow["id"]));
342 label_cell($myrow["wo_ref"]);
343 label_cell(wo_types::name($myrow["type"]));
344 view_stock_status_cell($myrow["stock_id"], $myrow["StockItemName"]);
345 label_cell($myrow["location_name"]);
346 label_cell(sql2date($myrow["date_"]));
348 qty_cell($myrow["units_issued"], false, get_qty_dec($myrow["stock_id"]));
352 comments_display_row(systypes::work_order(), $woid);
356 if ($myrow["closed"] == true)
358 display_note(_("This work order is closed."));