www/inv_instock.php

changeset 78
f35a38e8c16f
parent 77
a9f8de2d7b2b
child 82
7af1d472475a
equal deleted inserted replaced
77:a9f8de2d7b2b 78:f35a38e8c16f
3 require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php'); 3 require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
4 4
5 define('EURO', chr(128) ); 5 define('EURO', chr(128) );
6 6
7 $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); 7 $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
8 setlocale ( LC_ALL, 'nl_NL.UTF-8');
8 9
9 class PDF_MySQL_Table extends FPDF 10 class PDF_MySQL_Table extends FPDF
10 { 11 {
11 protected $ProcessingTable=false; 12 protected $ProcessingTable=false;
12 protected $aCols=array(); 13 protected $aCols=array();
55 function AddCol($width=-1, $caption='', $align='L') { 56 function AddCol($width=-1, $caption='', $align='L') {
56 $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); 57 $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align);
57 } 58 }
58 59
59 function TableFermentables($link,$prop) { 60 function TableFermentables($link,$prop) {
60 $this->AddCol(100,'Vergistbaar ingredient','L'); 61 $this->AddCol( 30,'Leverancier','L');
61 $this->AddCol( 28,'Voorraad','R'); 62 $this->AddCol( 90,'Vergistbaar ingredient','L');
63 $this->AddCol( 30,'Voorraad','R');
62 $this->AddCol( 20, 'Prijs/kg', 'R'); 64 $this->AddCol( 20, 'Prijs/kg', 'R');
63 $this->AddCol( 20, 'Waarde', 'R'); 65 $this->AddCol( 20, 'Waarde', 'R');
64 $prop['width']=$this->w-$this->lMargin-$this->rMargin; 66 $prop['width']=$this->w-$this->lMargin-$this->rMargin;
65 $prop['align']='L'; 67 $prop['align']='L';
66 $cMargin=$this->cMargin; 68 $cMargin=$this->cMargin;
72 $this->TableHeader(); 74 $this->TableHeader();
73 $this->SetFont('Helvetica','',9); 75 $this->SetFont('Helvetica','',9);
74 $this->ColorIndex=0; 76 $this->ColorIndex=0;
75 $this->ProcessingTable=true; 77 $this->ProcessingTable=true;
76 78
77 $result = mysqli_query($link, "SELECT name,inventory,cost FROM inventory_fermentables WHERE inventory > 0"); 79 $result = mysqli_query($link, "SELECT name,supplier,inventory,cost FROM inventory_fermentables WHERE inventory > 0 ORDER BY supplier,name");
78 $tot_fermentables = 0.0; 80 $tot_fermentables = 0.0;
79 81
80 while($row=mysqli_fetch_array($result)) { 82 while($row=mysqli_fetch_array($result)) {
81 $value = $row['inventory'] * $row['cost']; 83 $value = $row['inventory'] * $row['cost'];
82 $tot_fermentables += $value; 84 $tot_fermentables += $value;
83 85
84 $this->SetX($this->TableX); 86 $this->SetX($this->TableX);
85 $ci=$this->ColorIndex; 87 $ci=$this->ColorIndex;
86 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); 88 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
87 $this->Cell(100,5,$row['name'],0,0,'L',true); 89 $this->Cell(30,5,$row['supplier'],0,0,'L',true);
88 $this->Cell(28,5,sprintf("%10.3f kg",$row['inventory']),0,0,'R',true); 90 $this->Cell(90,5,$row['name'],0,0,'L',true);
89 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); 91 $this->Cell(30,5,sprintf("%10.3f kg",$row['inventory']),0,0,'R',true);
90 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); 92 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true);
91 $this->Ln(); 93 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true);
92 $this->ColorIndex=1-$ci; 94 $this->Ln();
93 } 95 $this->ColorIndex=1-$ci;
94 96 }
95 $this->SetX($this->TableX); 97
96 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]); 98 $this->SetX($this->TableX);
97 $this->Cell(148,5,'Totaal',0,0,'L',true); 99 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]);
100 $this->Cell(170,5,'Totaal',0,0,'L',true);
98 $this->Cell(20,5,sprintf("%8.2f ",$tot_fermentables).EURO,0,0,'R',true); 101 $this->Cell(20,5,sprintf("%8.2f ",$tot_fermentables).EURO,0,0,'R',true);
99 $this->Ln(); 102 $this->Ln();
100 103
101 $this->ProcessingTable=false; 104 $this->ProcessingTable=false;
102 $this->cMargin=$cMargin; 105 $this->cMargin=$cMargin;
103 $this->aCols=array(); 106 $this->aCols=array();
104 } 107 }
105 108
106 function TableHops($link,$prop) { 109 function TableHops($link,$prop) {
107 $this->AddCol(100,'Hoppen','L'); 110 $this->AddCol( 30,'Land','L');
108 $this->AddCol( 28,'Voorraad','R'); 111 $this->AddCol( 75,'Hoppen','L');
109 $this->AddCol( 20, 'Prijs/kg', 'R'); 112 $this->AddCol( 15,'Soort','L');
110 $this->AddCol( 20, 'Waarde', 'R'); 113 $this->AddCol( 30,'Voorraad','R');
111 $prop['width']=$this->w-$this->lMargin-$this->rMargin; 114 $this->AddCol( 20, 'Prijs/kg', 'R');
112 $prop['align']='L'; 115 $this->AddCol( 20, 'Waarde', 'R');
113 $cMargin=$this->cMargin; 116 $prop['width']=$this->w-$this->lMargin-$this->rMargin;
114 $this->cMargin=$prop['padding']; 117 $prop['align']='L';
115 $this->CalcWidths($prop['width'],$prop['align']); 118 $cMargin=$this->cMargin;
116 $this->TableHeader(); 119 $this->cMargin=$prop['padding'];
117 $this->SetFont('Helvetica','',9); 120 $this->CalcWidths($prop['width'],$prop['align']);
118 $this->ColorIndex=0; 121 $this->TableHeader();
119 $this->ProcessingTable=true; 122 $this->SetFont('Helvetica','',9);
120 123 $this->ColorIndex=0;
121 $result = mysqli_query($link, "SELECT name,form,origin,inventory,cost FROM inventory_hops WHERE inventory > 0"); 124 $this->ProcessingTable=true;
125
126 $result = mysqli_query($link, "SELECT name,form,origin,inventory,cost FROM inventory_hops WHERE inventory > 0 ORDER BY origin,name");
122 $tot_hops = 0.0; 127 $tot_hops = 0.0;
123 128
124 while($row=mysqli_fetch_array($result)) { 129 while($row=mysqli_fetch_array($result)) {
125 $value = $row['inventory'] * $row['cost']; 130 $value = $row['inventory'] * $row['cost'];
126 $tot_hops += $value; 131 $tot_hops += $value;
127 $hop = $row['form'] . " " . $row['origin'] . " - " . $row['name'];
128 $stock = floatval($row['inventory']) * 1000.0; 132 $stock = floatval($row['inventory']) * 1000.0;
129 133
130 $this->SetX($this->TableX); 134 $this->SetX($this->TableX);
131 $ci=$this->ColorIndex; 135 $ci=$this->ColorIndex;
132 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); 136 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
133 $this->Cell(100,5,$hop,0,0,'L',true); 137 $this->Cell(30,5,$row['origin'],0,0,'L',true);
134 $this->Cell(28,5,sprintf("%10.1f gr",$stock),0,0,'R',true); 138 $this->Cell(75,5,$row['name'],0,0,'L',true);
135 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); 139 $this->Cell(15,5,$row['form'],0,0,'L',true);
136 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); 140 $this->Cell(30,5,sprintf("%10.1f gr",$stock),0,0,'R',true);
137 $this->Ln(); 141 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true);
138 $this->ColorIndex=1-$ci; 142 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true);
139 } 143 $this->Ln();
140 144 $this->ColorIndex=1-$ci;
141 $this->SetX($this->TableX); 145 }
142 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]); 146
143 $this->Cell(148,5,'Totaal',0,0,'L',true); 147 $this->SetX($this->TableX);
148 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]);
149 $this->Cell(170,5,'Totaal',0,0,'L',true);
144 $this->Cell(20,5,sprintf("%8.2f ",$tot_hops).EURO,0,0,'R',true); 150 $this->Cell(20,5,sprintf("%8.2f ",$tot_hops).EURO,0,0,'R',true);
145 $this->Ln(); 151 $this->Ln();
146 152
147 $this->ProcessingTable=false; 153 $this->ProcessingTable=false;
148 $this->cMargin=$cMargin; 154 $this->cMargin=$cMargin;
151 157
152 function TableYeasts($link,$prop) { 158 function TableYeasts($link,$prop) {
153 $this->AddCol( 30,'Laboratorium','L'); 159 $this->AddCol( 30,'Laboratorium','L');
154 $this->AddCol( 20,'Product','L'); 160 $this->AddCol( 20,'Product','L');
155 $this->AddCol( 70,'Gist','L'); 161 $this->AddCol( 70,'Gist','L');
156 $this->AddCol( 28,'Voorraad','R'); 162 $this->AddCol( 30,'Voorraad','R');
157 $this->AddCol( 20, 'Prijs/kg', 'R'); 163 $this->AddCol( 20, 'Prijs/kg', 'R');
158 $this->AddCol( 20, 'Waarde', 'R'); 164 $this->AddCol( 20, 'Waarde', 'R');
159 $prop['width']=$this->w-$this->lMargin-$this->rMargin; 165 $prop['width']=$this->w-$this->lMargin-$this->rMargin;
160 $prop['align']='L'; 166 $prop['align']='L';
161 $cMargin=$this->cMargin; 167 $cMargin=$this->cMargin;
162 $this->cMargin=$prop['padding']; 168 $this->cMargin=$prop['padding'];
163 $this->CalcWidths($prop['width'],$prop['align']); 169 $this->CalcWidths($prop['width'],$prop['align']);
164 $this->TableHeader(); 170 $this->TableHeader();
165 $this->SetFont('Helvetica','',9); 171 $this->SetFont('Helvetica','',9);
166 $this->ColorIndex=0; 172 $this->ColorIndex=0;
167 $this->ProcessingTable=true; 173 $this->ProcessingTable=true;
168 174
169 $result = mysqli_query($link, "SELECT name,laboratory,product_id,form,inventory,cost FROM inventory_yeasts WHERE inventory > 0"); 175 $result = mysqli_query($link, "SELECT name,laboratory,product_id,form,inventory,cost FROM inventory_yeasts WHERE inventory > 0 ORDER BY laboratory,product_id");
170 $tot_yeasts = 0.0; 176 $tot_yeasts = 0.0;
171 177
172 while($row=mysqli_fetch_array($result)) { 178 while($row=mysqli_fetch_array($result)) {
173 $value = $row['inventory'] * $row['cost']; 179 $value = $row['inventory'] * $row['cost'];
174 $tot_yeasts += $value; 180 $tot_yeasts += $value;
179 $ci=$this->ColorIndex; 185 $ci=$this->ColorIndex;
180 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); 186 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
181 $this->Cell(30,5,$row['laboratory'],0,0,'L',true); 187 $this->Cell(30,5,$row['laboratory'],0,0,'L',true);
182 $this->Cell(20,5,$row['product_id'],0,0,'L',true); 188 $this->Cell(20,5,$row['product_id'],0,0,'L',true);
183 $this->Cell(70,5,$row['name'],0,0,'L',true); 189 $this->Cell(70,5,$row['name'],0,0,'L',true);
184 $this->Cell(28,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true); 190 $this->Cell(30,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true);
185 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); 191 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true);
186 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); 192 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true);
187 $this->Ln(); 193 $this->Ln();
188 $this->ColorIndex=1-$ci; 194 $this->ColorIndex=1-$ci;
189 } 195 }
190 196
191 $this->SetX($this->TableX); 197 $this->SetX($this->TableX);
192 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]); 198 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]);
193 $this->Cell(168,5,'Totaal',0,0,'L',true); 199 $this->Cell(170,5,'Totaal',0,0,'L',true);
194 $this->Cell(20,5,sprintf("%8.2f ",$tot_yeasts).EURO,0,0,'R',true); 200 $this->Cell(20,5,sprintf("%8.2f ",$tot_yeasts).EURO,0,0,'R',true);
195 $this->Ln(); 201 $this->Ln();
196 202
197 $this->ProcessingTable=false; 203 $this->ProcessingTable=false;
198 $this->cMargin=$cMargin; 204 $this->cMargin=$cMargin;
199 $this->aCols=array(); 205 $this->aCols=array();
200 } 206 }
201 207
202 function TableMiscs($link,$prop) { 208 function TableMiscs($link,$prop) {
203 $this->AddCol( 30,'Type','L'); 209 $this->AddCol( 30,'Type','L');
204 $this->AddCol( 70,'Ingredient','L'); 210 $this->AddCol( 90,'Ingredient','L');
205 $this->AddCol( 28,'Voorraad','R'); 211 $this->AddCol( 30,'Voorraad','R');
206 $this->AddCol( 20, 'Prijs/kg', 'R'); 212 $this->AddCol( 20, 'Prijs/kg', 'R');
207 $this->AddCol( 20, 'Waarde', 'R'); 213 $this->AddCol( 20, 'Waarde', 'R');
208 $prop['width']=$this->w-$this->lMargin-$this->rMargin; 214 $prop['width']=$this->w-$this->lMargin-$this->rMargin;
209 $prop['align']='L'; 215 $prop['align']='L';
210 $cMargin=$this->cMargin; 216 $cMargin=$this->cMargin;
211 $this->cMargin=$prop['padding']; 217 $this->cMargin=$prop['padding'];
212 $this->CalcWidths($prop['width'],$prop['align']); 218 $this->CalcWidths($prop['width'],$prop['align']);
213 $this->TableHeader(); 219 $this->TableHeader();
214 $this->SetFont('Helvetica','',9); 220 $this->SetFont('Helvetica','',9);
215 $this->ColorIndex=0; 221 $this->ColorIndex=0;
216 $this->ProcessingTable=true; 222 $this->ProcessingTable=true;
217 223
218 $result = mysqli_query($link, "SELECT name,type,amount_is_weight,inventory,cost FROM inventory_miscs WHERE inventory > 0"); 224 $result = mysqli_query($link, "SELECT name,type,amount_is_weight,inventory,cost FROM inventory_miscs WHERE inventory > 0 ORDER BY type,name");
219 $tot_miscs = 0.0; 225 $tot_miscs = 0.0;
220 226
221 while($row=mysqli_fetch_array($result)) { 227 while($row=mysqli_fetch_array($result)) {
222 $value = $row['inventory'] * $row['cost']; 228 $value = $row['inventory'] * $row['cost'];
223 $tot_miscs += $value; 229 $tot_miscs += $value;
226 232
227 $this->SetX($this->TableX); 233 $this->SetX($this->TableX);
228 $ci=$this->ColorIndex; 234 $ci=$this->ColorIndex;
229 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]); 235 $this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
230 $this->Cell(30,5,$row['type'],0,0,'L',true); 236 $this->Cell(30,5,$row['type'],0,0,'L',true);
231 $this->Cell(70,5,$row['name'],0,0,'L',true); 237 $this->Cell(90,5,$row['name'],0,0,'L',true);
232 $this->Cell(28,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true); 238 $this->Cell(30,5,sprintf("%10.1f ",$stock).$amount,0,0,'R',true);
233 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true); 239 $this->Cell(20,5,sprintf("%8.2f ",$row['cost']).EURO,0,0,'R',true);
234 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true); 240 $this->Cell(20,5,sprintf("%8.2f ",$value).EURO,0,0,'R',true);
235 $this->Ln(); 241 $this->Ln();
236 $this->ColorIndex=1-$ci; 242 $this->ColorIndex=1-$ci;
237 } 243 }
238 244
239 $this->SetX($this->TableX); 245 $this->SetX($this->TableX);
240 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]); 246 $this->SetFillColor($this->TotalColor[0],$this->TotalColor[1],$this->TotalColor[2]);
241 $this->Cell(168,5,'Totaal',0,0,'L',true); 247 $this->Cell(170,5,'Totaal',0,0,'L',true);
242 $this->Cell(20,5,sprintf("%8.2f ",$tot_miscs).EURO,0,0,'R',true); 248 $this->Cell(20,5,sprintf("%8.2f ",$tot_miscs).EURO,0,0,'R',true);
243 $this->Ln(); 249 $this->Ln();
244 250
245 $this->ProcessingTable=false; 251 $this->ProcessingTable=false;
246 $this->cMargin=$cMargin; 252 $this->cMargin=$cMargin;
250 256
251 257
252 258
253 class PDF extends PDF_MySQL_Table { 259 class PDF extends PDF_MySQL_Table {
254 function Header() { 260 function Header() {
261 $this->Image('images/logo.png',10,6,30);
255 // Title 262 // Title
256 $this->SetFont('Helvetica','',18); 263 $this->SetFont('Helvetica','',18);
257 $this->Cell(0,6,'Inventaris',0,1,'C'); 264 $this->Cell(0,10,'Inventaris',0,1,'C');
258 $this->Ln(10); 265 $this->Ln(20);
259 // Ensure table header is printed 266 // Ensure table header is printed
260 parent::Header(); 267 parent::Header();
261 } 268 }
262 } 269 }
263 270

mercurial