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 //----------------------------------------------------------------------------------------------------
69 function print_work_order_listing()
71 global $path_to_root, $wo_types_array;
73 $item = $_POST['PARAM_0'];
74 $location = $_POST['PARAM_1'];
75 $open_only = $_POST['PARAM_2'];
76 $comments = $_POST['PARAM_3'];
77 $orientation = $_POST['PARAM_4'];
78 $destination = $_POST['PARAM_5'];
80 include_once($path_to_root . "/reporting/includes/excel_report.inc");
82 include_once($path_to_root . "/reporting/includes/pdf_report.inc");
84 $orientation = ($orientation ? 'L' : 'P');
90 $row = get_item($item);
91 $items = $row['description'];
97 $loc = get_location_name($location);
99 $open = $open_only == 1 ? _('Yes') : _('No');
101 $cols = array(0, 100, 120, 165, 210, 275, 315, 375, 385, 440, 495, 555);
103 $headers = array(_('Type'), '#', ('Reference'), _('Location'), _('Item'), _('Required'), _('Manufactured'), ' ', _('Date'), _('Required By'), _('Closed'));
105 $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'left', 'left', 'left', 'left');
107 $params = array( 0 => $comments,
108 1 => array('text' => _('Items'), 'from' => $items, 'to' => ''),
109 2 => array('text' => _('Location'), 'from' => $loc, 'to' => ''),
110 3 => array('text' => _('Open Only'), 'from' => $open, 'to' => ''));
112 $rep = new FrontReport(_('Work Order Listing'), "WorkOrderListing", user_pagesize(), 9, $orientation);
113 if ($orientation == 'L')
114 recalculate_cols($cols);
117 $rep->Info($params, $cols, $headers, $aligns);
120 $res = getTransactions($item, $open_only, $location);
121 while ($trans=db_fetch($res))
123 $rep->TextCol(0, 1, $wo_types_array[$trans['type']]);
124 $rep->TextCol(1, 2, $trans['id'], -1);
125 $rep->TextCol(2, 3, $trans['wo_ref'], -1);
126 $rep->TextCol(3, 4, $trans['location_name'], -1);
127 $rep->TextCol(4, 5, $trans['description'], -1);
128 $dec = get_qty_dec($trans['stock_id']);
129 $rep->AmountCol(5, 6, $trans['units_reqd'], $dec);
130 $rep->AmountCol(6, 7, $trans['units_issued'], $dec);
131 $rep->TextCol(7, 8, '', -1);
132 $rep->TextCol(8, 9, sql2date($trans['date_']), -1);
133 $rep->TextCol(9, 10, sql2date($trans['required_by']), -1);
134 $rep->TextCol(10, 11, $trans['closed'] ? ' ' : _('No'), -1);
137 $rep->Line($rep->row);