Added Print of Work Order
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 26 Jun 2009 14:30:46 +0000 (14:30 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 26 Jun 2009 14:30:46 +0000 (14:30 +0000)
CHANGELOG.txt
manufacturing/includes/db/work_orders_db.inc
manufacturing/work_order_entry.php
reporting/includes/doctext.inc
reporting/includes/doctext2.inc
reporting/includes/header2.inc
reporting/includes/pdf_report.inc
reporting/includes/reports_classes.inc
reporting/rep409.php [new file with mode: 0644]
reporting/reports_main.php

index eb2fd3cf2127f73e4cd8c51bd8750e39c85ae300..c1af7126704dca04763d0fb9d3eb0c9da146ff53 100644 (file)
@@ -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
index 9f166d1ca72f0b13fe1976a58551c5b0cffdc81b..f0ce31a59680381a7c8e49a56e6e0a04f0f1e3cf 100644 (file)
@@ -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
index 2c9817741640e8abcf4cdcfa41f332a8a203547e..e0a0d283d6367d6c7d9ef75abc9b28899d98fcc9 100644 (file)
@@ -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);
index b28bb901e9e1fc4facebb117eb0e29acc7bb48eb..f29822a701d3ee663e2669ad1f1194311ae7d4d5 100644 (file)
@@ -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.");
 }
index 689cbb5ea027d2961dbce7b3cea6b5ac3009c521..16460053bebe45fb9b014c1024c163072de0b89a 100644 (file)
@@ -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.";
 }
index 98bb9428165f5caf2ea672cb2c2dc3987aa82679..a857da9b957af4d5ff59538d9c01e5fa6ced39c1 100644 (file)
                $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)
                {
                        $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) {
                $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; 
                        $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)
                        }               
                        $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');
                
                $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']))
index 467fb3f1edd74ba02af7a5a8b9562e48633abdc9..4245ccdef0308b0f1172b30afda788b38c62ba5f 100644 (file)
@@ -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");
                }
index 803160fe8b740ec7d7afc8032c34eb2fd7475ea8..69597924d89a7dda3eb1c062ae2a1d2e281c8088 100644 (file)
@@ -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 (file)
index 0000000..016580c
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+$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
index 52ba38206f607b07a02c48fb8aef5de474d75370..1bc322d41279658260286ca43f7cc6f35e5e8fb3 100644 (file)
@@ -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'),