From 39ef29ec4c57a03feabd4ecfa599e71f35b3dddb Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Fri, 26 Jun 2009 14:30:46 +0000 Subject: [PATCH] Added Print of Work Order --- CHANGELOG.txt | 12 ++ manufacturing/includes/db/work_orders_db.inc | 2 +- manufacturing/work_order_entry.php | 2 + reporting/includes/doctext.inc | 39 +++-- reporting/includes/doctext2.inc | 37 +++-- reporting/includes/header2.inc | 42 +++++- reporting/includes/pdf_report.inc | 2 +- reporting/includes/reports_classes.inc | 6 + reporting/rep409.php | 145 +++++++++++++++++++ reporting/reports_main.php | 7 +- 10 files changed, 262 insertions(+), 32 deletions(-) create mode 100644 reporting/rep409.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index eb2fd3cf..c1af7126 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,18 @@ Legend: ! -> Note $ -> Affected files +26-Jun-2009 Joe Hunt ++ Added Print of Work Order +$ /manufacturing/includes/db/work_orders_db.inc + /manufacturing/work_order_entry.php + /reporting/rep409.php (new file) + /reporting/reports_main.php + /reporting/includes/doctext.inc + /reporting/includes/doctext2.inc + /reporting/includes/header2.inc + /reporting/includes/pdf_report.inc + /reporting/includes/reports_classes.inc + 26-Jun-2009 Joe Hunt + Added Bank Charge field to Customer Payment, Supplier Payment and Bank Transfer and a new default bank charge account in gl_setup. $ /admin/gl_setup.php diff --git a/manufacturing/includes/db/work_orders_db.inc b/manufacturing/includes/db/work_orders_db.inc index 9f166d1c..f0ce31a5 100644 --- a/manufacturing/includes/db/work_orders_db.inc +++ b/manufacturing/includes/db/work_orders_db.inc @@ -170,7 +170,7 @@ function delete_work_order($woid) function get_work_order($woid, $allow_null=false) { $sql = "SELECT ".TB_PREF."workorders.*, ".TB_PREF."stock_master.description As StockItemName, - ".TB_PREF."locations.location_name + ".TB_PREF."locations.location_name, ".TB_PREF."locations.delivery_address FROM ".TB_PREF."workorders, ".TB_PREF."stock_master, ".TB_PREF."locations WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id AND ".TB_PREF."locations.loc_code=".TB_PREF."workorders.loc_code diff --git a/manufacturing/work_order_entry.php b/manufacturing/work_order_entry.php index 2c981774..e0a0d283 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -58,6 +58,8 @@ if (isset($_GET['AddedID'])) if ($_GET['type'] != wo_types::advanced()) { include_once($path_to_root . "/reporting/includes/reporting.inc"); + $ar = array('PARAM_0' => $id, 'PARAM_1' => $id); + display_note(print_link(_("Print this Work Order"), 409, $ar), 1); display_note(get_gl_view_str($stype, $id, _("View the GL Journal Entries for this Work Order")), 1); $ar = array('PARAM_0' => $_GET['date'], 'PARAM_1' => $_GET['date'], 'PARAM_2' => $stype); display_note(print_link(_("Print the GL Journal Entries for this Work Order"), 702, $ar), 1); diff --git a/reporting/includes/doctext.inc b/reporting/includes/doctext.inc index b28bb901..f29822a7 100644 --- a/reporting/includes/doctext.inc +++ b/reporting/includes/doctext.inc @@ -18,15 +18,27 @@ if (isset($header2type)) $doc_Shipping_Company = _("Shipping Company"); if ($doctype == 9) $doc_Due_Date = _("Delivery Date"); - else + else $doc_Due_Date = _("Due Date"); $doc_Your_Ref = _("Your Ref"); - $doc_Our_Ref = _("Our Ref."); - $doc_Your_VAT_no = _("Your VAT no."); + if ($doctype == 26) + { + $doc_Our_Ref = _("Type"); + $doc_Your_VAT_no = _("Manufactured Item"); + $doc_Payment_Terms = _("Required By"); + $doc_Customers_Ref = _("Reference"); + $doc_Our_Order_No = _("Into Location"); + $doc_Due_Date = _("Quantity"); + } + else + { + $doc_Our_Ref = _("Our Ref."); + $doc_Your_VAT_no = _("Your VAT no."); + $doc_Payment_Terms = _("Payment Terms"); + $doc_Customers_Ref = _("Customers Reference"); + $doc_Our_Order_No = _("Our Order No"); + } $doc_Our_VAT_no = _("Our VAT No."); - $doc_Payment_Terms = _("Payment Terms"); - $doc_Customers_Ref = _("Customers Reference"); - $doc_Our_Order_No = _("Our Order No"); $doc_Domicile = _("Domicile"); if($doctype == 13 || $doctype == 8 || $doctype == 9) { $doc_Bank_Account = ''; @@ -42,21 +54,26 @@ if (isset($header2type)) $doc_Bank = _("Bank"); $doc_Bank_Account = _("Bank Account"); $doc_Payment_Link = _("You can pay through"); - if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13) + if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26) { if ($doctype == 8) $this->title = _("PURCHASE ORDER"); - else if ($doctype == 13) + elseif ($doctype == 13) $this->title = _("DELIVERY NOTE"); - else if ($doctype == 9) + elseif ($doctype == 9) $this->title = ($print_as_quote==1 ? _("QUOTE") : _("SALES ORDER")); - else if ($doctype == 10) + elseif ($doctype == 10) $this->title = _("INVOICE"); + elseif ($doctype == 26) + $this->title = _("WORK ORDER"); else $this->title = _("CREDIT NOTE"); if ($doctype == 8) $this->headers = array(_("Item Code"), _("Item Description"), _("Delivery Date"), _("Quantity"), _("Unit"), _("Price"), _("Total")); + elseif ($doctype == 26) + $this->headers = array(_("Item Code"), _("Item Description"), + _("From Location"), _("Work Centre"), _("Unit Quantity"), _("Total Quantity"), _("Units Issued")); else $this->headers = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount %"), _("Total")); @@ -78,7 +95,7 @@ if (isset($emailtype)) if (isset($header2type) || isset($linetype)) { $doc_Invoice_no = ($doctype==13 ? _("Delivery Note No.") : (($doctype==8 || $doctype==9) ? _("Order no.") : - ($doctype==10 ? _("Invoice No.") : _("Credit No.")))); + ($doctype==10 ? _("Invoice No.") : ($doctype==26 ? _("Word Order No") : _("Credit No."))))); $doc_Delivery_no = _("Delivery Note No."); $doc_Order_no = _("Order no."); } diff --git a/reporting/includes/doctext2.inc b/reporting/includes/doctext2.inc index 689cbb5e..16460053 100644 --- a/reporting/includes/doctext2.inc +++ b/reporting/includes/doctext2.inc @@ -21,12 +21,24 @@ if (isset($header2type)) else $doc_Due_Date = "Due Date"; $doc_Your_Ref = "Your Ref"; - $doc_Our_Ref = "Our Ref."; - $doc_Your_VAT_no = "Your VAT No."; + if ($doctype == 26) + { + $doc_Our_Ref = "Type"; + $doc_Your_VAT_no = "Manufactured Item"; + $doc_Payment_Terms = "Required By"; + $doc_Customers_Ref = "Reference"; + $doc_Our_Order_No = "Into Location"; + $doc_Due_Date = "Quantity"; + } + else + { + $doc_Our_Ref = "Our Ref."; + $doc_Your_VAT_no = "Your VAT no."; + $doc_Payment_Terms = "Payment Terms"; + $doc_Customers_Ref = "Customers Reference"; + $doc_Our_Order_No = "Our Order No"; + } $doc_Our_VAT_no = "Our VAT No."; - $doc_Payment_Terms = "Payment Terms"; - $doc_Customers_Ref = "Customers Reference"; - $doc_Our_Order_No = "Our Order No"; $doc_Domicile = "Domicile"; if($doctype == 13 || $doctype == 8 || $doctype == 9) { $doc_Bank_Account = ''; @@ -41,21 +53,26 @@ if (isset($header2type)) $doc_Bank = "Bank"; $doc_Bank_Account = "Bank Account"; $doc_Payment_Link = "You can pay through"; - if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13) + if ($doctype == 8 || $doctype == 9 || $doctype == 10 || $doctype == 11 || $doctype == 13 || $doctype == 26) { if ($doctype == 8) $this->title = "PURCHASE ORDER"; - else if ($doctype == 9) + elseif ($doctype == 9) $this->title = ($print_as_quote==1 ? "QUOTE" : "SALES ORDER"); - else if ($doctype == 10) + elseif ($doctype == 10) $this->title = "INVOICE"; - else if ($doctype == 13) + elseif ($doctype == 13) $this->title = "DELIVERY NOTE"; + elseif ($doctype == 26) + $this->title = "WORK ORDER"; else $this->title = "CREDIT NOTE"; if ($doctype == 8) $this->headers = array('Item Code', 'Item Description', 'Delivery Date', 'Quantity', 'Unit', 'Price', 'Total'); + elseif ($doctype == 26) + $this->headers = array("Item Code", "Item Description", + "From Location", "Work Centre", "Unit Quantity", "Total Quantity", "Units Issued"); else $this->headers = array('Item Code', 'Item Description', 'Quantity', 'Unit', 'Price', 'Discount %', 'Total'); @@ -77,7 +94,7 @@ if (isset($emailtype)) if (isset($header2type) || isset($linetype)) { $doc_Invoice_no = ($doctype==13 ? "Delivery Note No." : (($doctype==8 || $doctype==9) ? "Order no." : - ($doctype==10 ? "Invoice No." : "Credit No."))); + ($doctype==10 ? "Invoice No." : ($doctype == 26 ? "Work Order No" : "Credit No.")))); $doc_Delivery_no = "Delivery Note No."; $doc_Order_no = "Order no."; } diff --git a/reporting/includes/header2.inc b/reporting/includes/header2.inc index 98bb9428..a857da9b 100644 --- a/reporting/includes/header2.inc +++ b/reporting/includes/header2.inc @@ -121,12 +121,16 @@ $this->Text($mcol + 100, $doc_Date.":"); if ($doctype == 8 || $doctype == 9) $this->Text($mcol + 180, sql2date($myrow['ord_date'])); + elseif ($doctype == 26) + $this->Text($mcol + 180, sql2date($myrow['date_'])); else $this->Text($mcol + 180, sql2date($myrow['tran_date'])); $this->NewLine(); $this->Text($mcol + 100, $doc_Invoice_no); if ($doctype == 8 || $doctype == 9) // PO or SO $this->Text($mcol + 180, $myrow['order_no']); + elseif ($doctype == 26) + $this->Text($mcol + 180, $myrow['id']); else if (isset($myrow['trans_no']) && isset($myrow['reference'])) // INV/CRE/STA { if ($print_invoice_no == 1) @@ -150,6 +154,12 @@ { $this->Text($ccol, $myrow['name'], $icol); } + elseif ($doctype == 26) + { + $this->Text($ccol, $myrow['location_name'], $icol); + $this->NewLine(); + $this->TextWrapLines($ccol, $icol - $ccol, $myrow['delivery_address']); + } else { if ($doctype == 8) { @@ -198,6 +208,8 @@ $col = $this->leftMargin; if ($doctype == 8) $this->TextWrap($col, $this->row, $width, $myrow['supp_account_no'], 'C'); + elseif ($doctype == 26) + $this->TextWrap($col, $this->row, $width, $myrow['wo_ref'], 'C'); elseif (isset($sales_order["customer_ref"])) $this->TextWrap($col, $this->row, $width, $sales_order["customer_ref"], 'C'); $col += $width; @@ -209,8 +221,12 @@ $row = db_fetch($result); $this->TextWrap($col, $this->row, $width, $row['salesman_name'], 'C'); } + elseif ($doctype == 26) + $this->TextWrap($col, $this->row, $width, wo_types::name($myrow["type"]), 'C'); $col += $width; - if ($doctype != 8 && isset($myrow['tax_id'])) + if ($doctype == 26) + $this->TextWrap($col, $this->row, $width, $myrow["StockItemName"], 'C'); + elseif ($doctype != 8 && isset($myrow['tax_id'])) $this->TextWrap($col, $this->row, $width, $myrow['tax_id'], 'C'); $col += $width; if ($doctype == 10) @@ -226,17 +242,26 @@ } $this->TextWrap($col, $this->row, $width, $line, 'C'); } + elseif ($doctype == 26) + $this->TextWrap($col, $this->row, $width, $myrow["location_name"], 'C'); elseif (isset($myrow['order_'])) $this->TextWrap($col, $this->row, $width, $myrow['order_'], 'C'); - $col += $width; - $id = $myrow['payment_terms']; - $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'"; - $result = db_query($sql,"could not get paymentterms"); - $row = db_fetch($result); - $this->TextWrap($col, $this->row, $width, $row["terms"], 'C'); + $col += $width; + if ($doctype == 26) + $this->TextWrap($col, $this->row, $width, sql2date($myrow["required_by"]), 'C'); + else + { + $id = $myrow['payment_terms']; + $sql = "SELECT terms FROM ".TB_PREF."payment_terms WHERE terms_indicator='$id'"; + $result = db_query($sql,"could not get paymentterms"); + $row = db_fetch($result); + $this->TextWrap($col, $this->row, $width, $row["terms"], 'C'); + } $col += $width; if ($doctype == 9) $this->TextWrap($col, $this->row, $width, sql2date($myrow['delivery_date']), 'C'); + elseif ($doctype == 26) + $this->TextWrap($col, $this->row, $width, $myrow["units_issued"], 'C'); else if ($doctype != 8 && $doctype != 11 && isset($myrow['due_date'])) $this->TextWrap($col, $this->row, $width, sql2date($myrow['due_date']), 'C'); @@ -249,7 +274,8 @@ $this->Font(); $this->Font('italic'); $this->row = $iline7 - $this->lineHeight - 6; - $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C'); + if ($doctype != 26) + $this->TextWrap($ccol, $this->row, $right - $ccol, $doc_Please_Quote . " - " . $myrow['curr_code'], 'C'); $this->NewLine(); if (isset($bankaccount['bank_name'])) diff --git a/reporting/includes/pdf_report.inc b/reporting/includes/pdf_report.inc index 467fb3f1..4245ccde 100644 --- a/reporting/includes/pdf_report.inc +++ b/reporting/includes/pdf_report.inc @@ -266,7 +266,7 @@ class FrontReport extends Cpdf if ($this->pageNumber > 1) $this->newPage(); $header2type = true; - if ($this->currency != $myrow['curr_code']) + if (isset($myrow['curr_code']) && $this->currency != $myrow['curr_code']) { include($path_to_root . "/reporting/includes/doctext2.inc"); } diff --git a/reporting/includes/reports_classes.inc b/reporting/includes/reports_classes.inc index 803160fe..69597924 100644 --- a/reporting/includes/reports_classes.inc +++ b/reporting/includes/reports_classes.inc @@ -296,6 +296,12 @@ class Report $sql = "SELECT stock_id, concat(stock_id, '-', description) as name FROM ".TB_PREF."stock_master WHERE (mb_flag='A' OR mb_flag='M') ORDER BY stock_id"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); break; + case 'WORKORDER': + $sql = "SELECT ".TB_PREF."workorders.id, concat(".TB_PREF."workorders.id, '-', + ".TB_PREF."stock_master.description) as IName + FROM ".TB_PREF."stock_master, ".TB_PREF."workorders WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."workorders.stock_id ORDER BY ".TB_PREF."workorders.id DESC"; + $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy); + break; case 'LOCATIONS': $sql = "SELECT loc_code, location_name FROM ".TB_PREF."locations ORDER BY location_name"; $st .= dup_simple_codeandname_list($sql, "PARAM_$index", $dummy, true, _("No Location Filter"), false); diff --git a/reporting/rep409.php b/reporting/rep409.php new file mode 100644 index 00000000..016580c1 --- /dev/null +++ b/reporting/rep409.php @@ -0,0 +1,145 @@ +. +***********************************************************************/ +$page_security = 2; +// ---------------------------------------------------------------- +// $ Revision: 2.0 $ +// Creator: Janusz Dobrwolski +// date_: 2008-01-14 +// Title: Print Delivery Notes +// draft version! +// ---------------------------------------------------------------- +$path_to_root=".."; + +include_once($path_to_root . "/includes/session.inc"); +include_once($path_to_root . "/includes/date_functions.inc"); +include_once($path_to_root . "/includes/data_checks.inc"); +include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); + +//---------------------------------------------------------------------------------------------------- + +print_workorders(); + +//---------------------------------------------------------------------------------------------------- + +function print_workorders() +{ + global $path_to_root; + + include_once($path_to_root . "/reporting/includes/pdf_report.inc"); + + $from = $_POST['PARAM_0']; + $to = $_POST['PARAM_1']; + $email = $_POST['PARAM_2']; + $comments = $_POST['PARAM_3']; + + if ($from == null) + $from = 0; + if ($to == null) + $to = 0; + $dec = user_price_dec(); + + $fno = explode("-", $from); + $tno = explode("-", $to); + + $cols = array(4, 60, 190, 255, 320, 385, 450, 515); + + // $headers in doctext.inc + $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right'); + + $params = array('comments' => $comments); + + $cur = get_company_Pref('curr_default'); + + if ($email == 0) + { + $rep = new FrontReport(_('WORK ORDER'), "WorkOrderBulk", user_pagesize()); + $rep->currency = $cur; + $rep->Font(); + $rep->Info($params, $cols, null, $aligns); + } + + for ($i = $fno[0]; $i <= $tno[0]; $i++) + { + $myrow = get_work_order($i); + if ($myrow === false) + continue; + $date_ = sql2date($myrow["date_"]); + if ($email == 1) + { + $rep = new FrontReport("", "", user_pagesize()); + $rep->currency = $cur; + $rep->Font(); + $rep->title = _('WORK ORDER'); + $rep->filename = "WorkOrder" . $myrow['reference'] . ".pdf"; + $rep->Info($params, $cols, null, $aligns); + } + else + $rep->title = _('WORK ORDER'); + $rep->Header2($myrow, null, null, '', 26); + + $result = get_wo_requirements($i); + $rep->TextCol(0, 5,_("Work Order Requirements"), -2); + $rep->NewLine(2); + $has_marked = false; + while ($myrow2=db_fetch($result)) + { + $qoh = 0; + $show_qoh = true; + // if it's a non-stock item (eg. service) don't show qoh + if (!has_stock_holding($myrow2["mb_flag"])) + $show_qoh = false; + + if ($show_qoh) + $qoh = get_qoh_on_date($myrow2["stock_id"], $myrow2["loc_code"], $date_); + + if ($show_qoh && ($myrow2["units_req"] * $myrow["units_issued"] > $qoh) && + !sys_prefs::allow_negative_stock()) + { + // oops, we don't have enough of one of the component items + $has_marked = true; + } + else + $has_marked = false; + if ($has_marked) + $str = $myrow2['stock_id']." ***"; + else + $str = $myrow2['stock_id']; + $rep->TextCol(0, 1, $str, -2); + $rep->TextCol(1, 2, $myrow2['description'], -2); + + $rep->TextCol(2, 3, $myrow2['location_name'], -2); + $rep->TextCol(3, 4, $myrow2['WorkCentreDescription'], -2); + $dec = get_qty_dec($myrow2["stock_id"]); + + $rep->AmountCol(4, 5, $myrow2['units_req'], $dec, -2); + $rep->AmountCol(5, 6, $myrow2['units_req'] * $myrow['units_issued'], $dec, -2); + $rep->AmountCol(6, 7, $myrow2['units_issued'], $dec, -2); + $rep->NewLine(1); + if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight)) + $rep->Header2($myrow, null, null,'',26); + } + $rep->NewLine(1); + $rep->TextCol(0, 5," *** = "._("Insufficient stock"), -2); + + $comments = get_comments(26, $i); + if ($comments && db_num_rows($comments)) + { + $rep->NewLine(); + while ($comment=db_fetch($comments)) + $rep->TextColLines(0, 6, $comment['memo_'], -2); + } + } + if ($email == 0) + $rep->End(); +} + +?> \ No newline at end of file diff --git a/reporting/reports_main.php b/reporting/reports_main.php index 52ba3820..1bc322d4 100644 --- a/reporting/reports_main.php +++ b/reporting/reports_main.php @@ -169,7 +169,12 @@ $reports->addReport(_('Manufactoring'),401,_('&Bill of Material Listing'), new ReportParam(_('To component'),'ITEMS'), new ReportParam(_('Comments'),'TEXTBOX'), new ReportParam(_('Destination'),'DESTINATION'))); - $reports->addReportClass(_('Dimensions')); +$reports->addReport(_('Manufactoring'),409,_('Print &Work Orders'), + array( new ReportParam(_('From'),'WORKORDER'), + new ReportParam(_('To'),'WORKORDER'), + new ReportParam(_('email Customers'),'YES_NO'), + new ReportParam(_('Comments'),'TEXTBOX'))); +$reports->addReportClass(_('Dimensions')); if ($dim > 0) { $reports->addReport(_('Dimensions'),501,_('Dimension &Summary'), -- 2.30.2