Reduced size of the icons to 12 pix.
[fa-stable.git] / reporting / rep409.php
1 <?php
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 = 2;
13 // ----------------------------------------------------------------
14 // $ Revision:  2.0 $
15 // Creator:     Janusz Dobrwolski
16 // date_:       2008-01-14
17 // Title:       Print Workorders
18 // draft version!
19 // ----------------------------------------------------------------
20 $path_to_root="..";
21
22 include_once($path_to_root . "/includes/session.inc");
23 include_once($path_to_root . "/includes/date_functions.inc");
24 include_once($path_to_root . "/includes/data_checks.inc");
25 include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
26
27 //----------------------------------------------------------------------------------------------------
28
29 print_workorders();
30
31 //----------------------------------------------------------------------------------------------------
32
33 function print_workorders()
34 {
35         global $path_to_root;
36
37         include_once($path_to_root . "/reporting/includes/pdf_report.inc");
38
39         $from = $_POST['PARAM_0'];
40         $to = $_POST['PARAM_1'];
41         $email = $_POST['PARAM_2'];
42         $comments = $_POST['PARAM_3'];
43
44         if ($from == null)
45                 $from = 0;
46         if ($to == null)
47                 $to = 0;
48         $dec = user_price_dec();
49
50         $fno = explode("-", $from);
51         $tno = explode("-", $to);
52
53         $cols = array(4, 60, 190, 255, 320, 385, 450, 515);
54
55         // $headers in doctext.inc
56         $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right');
57
58         $params = array('comments' => $comments);
59
60         $cur = get_company_Pref('curr_default');
61
62         if ($email == 0)
63         {
64                 $rep = new FrontReport(_('WORK ORDER'), "WorkOrderBulk", user_pagesize());
65                 $rep->currency = $cur;
66                 $rep->Font();
67                 $rep->Info($params, $cols, null, $aligns);
68         }
69
70         for ($i = $fno[0]; $i <= $tno[0]; $i++)
71         {
72                 $myrow = get_work_order($i);
73                 if ($myrow === false)
74                         continue;
75                 $date_ = sql2date($myrow["date_"]);                     
76                 if ($email == 1)
77                 {
78                         $rep = new FrontReport("", "", user_pagesize());
79                         $rep->currency = $cur;
80                         $rep->Font();
81                                 $rep->title = _('WORK ORDER');
82                                 $rep->filename = "WorkOrder" . $myrow['reference'] . ".pdf";
83                         $rep->Info($params, $cols, null, $aligns);
84                 }
85                 else
86                         $rep->title = _('WORK ORDER');
87                 $rep->Header2($myrow, null, null, '', 26);
88
89                 $result = get_wo_requirements($i);
90                 $rep->TextCol(0, 5,_("Work Order Requirements"), -2);
91                 $rep->NewLine(2);
92                 $has_marked = false;
93                 while ($myrow2=db_fetch($result))
94                 {
95                         $qoh = 0;
96                         $show_qoh = true;
97                         // if it's a non-stock item (eg. service) don't show qoh
98                         if (!has_stock_holding($myrow2["mb_flag"]))
99                                 $show_qoh = false;
100
101                         if ($show_qoh)
102                                 $qoh = get_qoh_on_date($myrow2["stock_id"], $myrow2["loc_code"], $date_);
103
104                         if ($show_qoh && ($myrow2["units_req"] * $myrow["units_issued"] > $qoh) &&
105                                 !sys_prefs::allow_negative_stock())
106                         {
107                                 // oops, we don't have enough of one of the component items
108                                 $has_marked = true;
109                         }
110                         else
111                                 $has_marked = false;
112                         if ($has_marked)
113                                 $str = $myrow2['stock_id']." ***";
114                         else
115                                 $str = $myrow2['stock_id'];
116                         $rep->TextCol(0, 1,     $str, -2);
117                         $rep->TextCol(1, 2, $myrow2['description'], -2);
118
119                         $rep->TextCol(2, 3,     $myrow2['location_name'], -2);
120                         $rep->TextCol(3, 4,     $myrow2['WorkCentreDescription'], -2);
121                         $dec = get_qty_dec($myrow2["stock_id"]);
122
123                         $rep->AmountCol(4, 5,   $myrow2['units_req'], $dec, -2);
124                         $rep->AmountCol(5, 6,   $myrow2['units_req'] * $myrow['units_issued'], $dec, -2);
125                         $rep->AmountCol(6, 7,   $myrow2['units_issued'], $dec, -2);
126                         $rep->NewLine(1);
127                         if ($rep->row < $rep->bottomMargin + (15 * $rep->lineHeight))
128                                 $rep->Header2($myrow, null, null,'',26);
129                 }
130                 $rep->NewLine(1);
131                 $rep->TextCol(0, 5," *** = "._("Insufficient stock"), -2);
132
133                 $comments = get_comments(26, $i);
134                 if ($comments && db_num_rows($comments))
135                 {
136                         $rep->NewLine();
137                         while ($comment=db_fetch($comments))
138                                 $rep->TextColLines(0, 6, $comment['memo_'], -2);
139                 }
140         }
141         if ($email == 0)
142                 $rep->End();
143 }
144
145 ?>