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 $page_security = 'SA_BOMREP';
13 // ----------------------------------------------------------------
17 // Title: Work Order Listing
18 // ----------------------------------------------------------------
21 include_once($path_to_root . "/includes/session.inc");
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/includes/data_checks.inc");
24 include_once($path_to_root . "/includes/banking.inc");
25 include_once($path_to_root . "/gl/includes/gl_db.inc");
26 include_once($path_to_root . "/inventory/includes/db/items_category_db.inc");
28 //----------------------------------------------------------------------------------------------------
30 print_work_order_listing();
32 function getTransactions($items, $open_only, $location)
38 location.location_name,
41 workorder.units_issued,
43 workorder.required_by,
46 FROM ".TB_PREF."workorders as workorder,"
47 .TB_PREF."stock_master as item,"
48 .TB_PREF."locations as location
49 WHERE workorder.stock_id=item.stock_id
50 AND workorder.loc_code=location.loc_code";
53 $sql .= " AND workorder.closed=0";
56 $sql .= " AND workorder.loc_code=".db_escape($location);
59 $sql .= " AND workorder.stock_id=".db_escape($items);
61 $sql .=" ORDER BY workorder.id";
63 return db_query($sql,"No transactions were returned");
67 function print_gl_rows(&$rep, $result, $title)
69 global $systypes_array;
71 $dec = user_price_dec();
73 if (db_num_rows($result))
75 $rep->Line($rep->row -= 4);
78 $rep->TextCol(3, 11, $title);
80 $rep->Line($rep->row -= 4);
81 while($myrow = db_fetch($result)) {
83 $rep->TextCol(0, 2, $systypes_array[$myrow['type']] . ' ' . $myrow['type_no'], -2);
84 $rep->TextCol(2, 3, sql2date($myrow["tran_date"]), -2);
85 $rep->TextCol(3, 4, $myrow['account'], -2);
86 $rep->TextCol(4, 5, $myrow['account_name'], -2);
87 if ($myrow['amount'] > 0.0)
88 $rep->AmountCol(5, 6, $myrow['amount'], $dec);
90 $rep->AmountCol(6, 7, $myrow['amount'] * -1, $dec, -1);
91 $rep->TextCol(8, 11, $myrow['memo_']);
96 //----------------------------------------------------------------------------------------------------
98 function print_work_order_listing()
100 global $path_to_root, $wo_types_array;
102 $item = $_POST['PARAM_0'];
103 $location = $_POST['PARAM_1'];
104 $open_only = $_POST['PARAM_2'];
105 $show_gl = $_POST['PARAM_3'];
106 $comments = $_POST['PARAM_4'];
107 $orientation = $_POST['PARAM_5'];
108 $destination = $_POST['PARAM_6'];
110 include_once($path_to_root . "/reporting/includes/excel_report.inc");
112 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
114 $orientation = ($orientation ? 'L' : 'P');
120 $row = get_item($item);
121 $items = $row['description'];
127 $loc = get_location_name($location);
129 $open = $open_only == 1 ? _('Yes') : _('No');
130 $show = $show_gl == 1 ? _('Yes') : _('No');
132 $cols = array(0, 100, 120, 165, 210, 275, 315, 375, 385, 440, 495, 555);
134 $headers = array(_('Type'), '#', ('Reference'), _('Location'), _('Item'), _('Required'), _('Manufactured'), ' ', _('Date'), _('Required By'), _('Closed'));
139 $headers2 = array(_("Transaction"), ' ', _("Date"), _("Account Code"),' ' . _("Account Name"), _("Debit"), _("Credit"), ' ', _("Memo"));
147 $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'left', 'left', 'left', 'left');
149 $params = array( 0 => $comments,
150 1 => array('text' => _('Items'), 'from' => $items, 'to' => ''),
151 2 => array('text' => _('Location'), 'from' => $loc, 'to' => ''),
152 3 => array('text' => _('Open Only'), 'from' => $open, 'to' => ''),
153 4 => array('text' => _('Show GL Rows'), 'from' => $show, 'to' => ''),
156 $rep = new FrontReport(_('Work Order Listing'), "WorkOrderListing", user_pagesize(), 9, $orientation);
157 if ($orientation == 'L')
158 recalculate_cols($cols);
162 $rep->Info($params, $cols2, $headers2, $aligns, $cols, $headers);
164 $rep->Info($params, $cols, $headers, $aligns);
167 $res = getTransactions($item, $open_only, $location);
168 while ($trans=db_fetch($res))
170 $rep->TextCol(0, 1, $wo_types_array[$trans['type']]);
171 $rep->TextCol(1, 2, $trans['id'], -1);
172 $rep->TextCol(2, 3, $trans['wo_ref'], -1);
173 $rep->TextCol(3, 4, $trans['location_name'], -1);
174 $rep->TextCol(4, 5, $trans['description'], -1);
175 $dec = get_qty_dec($trans['stock_id']);
176 $rep->AmountCol(5, 6, $trans['units_reqd'], $dec);
177 $rep->AmountCol(6, 7, $trans['units_issued'], $dec);
178 $rep->TextCol(7, 8, '', -1);
179 $rep->TextCol(8, 9, sql2date($trans['date_']), -1);
180 $rep->TextCol(9, 10, sql2date($trans['required_by']), -1);
181 $rep->TextCol(10, 11, $trans['closed'] ? ' ' : _('No'), -1);
185 $productions = get_gl_wo_productions($trans['id'], true);
186 print_gl_rows($rep, $productions, _("Finished Product Requirements"));
188 $issues = get_gl_wo_issue_trans($trans['id'], -1, true);
189 print_gl_rows($rep, $issues, _("Additional Material Issues"));
191 $costs = get_gl_wo_cost_trans($trans['id'], -1, true);
192 print_gl_rows($rep, $costs, _("Additional Costs"));
194 $wo = get_gl_trans(ST_WORKORDER, $trans['id']);
195 print_gl_rows($rep, $wo, _("Finished Product Receival"));
196 $rep->Line($rep->row - 2);
201 $rep->Line($rep->row);