Tue, 02 Aug 2022 11:01:33 +0200
Removed product reports and archives.
www/Makefile | file | annotate | diff | comparison | revisions | |
www/includes/global.inc.php | file | annotate | diff | comparison | revisions | |
www/js/prod_archive_code.js | file | annotate | diff | comparison | revisions | |
www/js/prod_archive_date.js | file | annotate | diff | comparison | revisions | |
www/js/prod_archive_name.js | file | annotate | diff | comparison | revisions | |
www/prod_archive_code.php | file | annotate | diff | comparison | revisions | |
www/prod_archive_date.php | file | annotate | diff | comparison | revisions | |
www/prod_archive_name.php | file | annotate | diff | comparison | revisions | |
www/prod_r_efficiency.php | file | annotate | diff | comparison | revisions | |
www/prod_r_totals.php | file | annotate | diff | comparison | revisions | |
www/prod_r_yeast.php | file | annotate | diff | comparison | revisions |
--- a/www/Makefile Mon Aug 01 13:26:18 2022 +0200 +++ b/www/Makefile Tue Aug 02 11:01:33 2022 +0200 @@ -10,10 +10,9 @@ import_ingredients.php index.php \ log_brew.php log_co2pressure.php log_fermentation.php log_ispindel.php \ mon_brewer.php mon_co2meter.php mon_fermenter.php mon_ispindel.php mon_node.php \ - prod_archive_code.php prod_archive_date.php prod_archive_name.php prod_beerxml.php \ - prod_checklist.php prod_divide.php prod_duplicate.php prod_edit.php prod_export.php prod_forum.php \ + prod_beerxml.php prod_checklist.php prod_divide.php prod_duplicate.php \ + prod_edit.php prod_export.php prod_forum.php \ prod_impbrew.php prod_inprod.php prod_new.php prod_print.php prod_torecipe.php \ - prod_r_efficiency.php prod_r_yeast.php prod_r_totals.php \ rec_beerxml.php rec_duplicate.php rec_edit.php rec_export.php rec_forum.php \ rec_import.php rec_main.php rec_new.php rec_print.php rec_toproduct.php \ upl_brew.php upl_fermentables.php upl_hops.php upl_miscs.php upl_recipe.php \
--- a/www/includes/global.inc.php Mon Aug 01 13:26:18 2022 +0200 +++ b/www/includes/global.inc.php Tue Aug 02 11:01:33 2022 +0200 @@ -226,25 +226,7 @@ <ul style='width: 200px;'> <li><img style='float: left; margin-right: 5px;' src='images/beerstyles.png' /><a href="prod_inprod.php">In bewerking</a></li> <li><img style='float: left; margin-right: 5px;' src='images/list-add.png' /><a href="prod_new.php?return=index.php">Start nieuw</a></li> - <li><img style='float: left; margin-left: 3px; margin-right: 8px;' src='images/database.png' />Archief - <ul> - <li><a href="prod_archive_name.php">Op naam</a></li> - <li><a href="prod_archive_code.php">Op code</a></li> - <li><a href="prod_archive_date.php">Op datum</a></li> - </ul> - </li> - <li><img style='float: left; margin-right: 5px;' src='images/insert-object.png' />Import - <ul style='width: 200px;'> - <li><img style='float: left; margin-right: 5px;' src='images/insert-object.png' /><a href="prod_impbrew.php">Brouw log</a></li> - </ul> - </li> - <li><img style='float: left; margin-right: 5px;' src='images/printer.png' />Rapporten - <ul style='width: 200px;'> - <li><a href="prod_r_totals.php" target="_blank">Totaal productie</a></li> - <li><a href="prod_r_efficiency.php" target="_blank">Rendementen</a></li> - <li><a href="prod_r_yeast.php" target="_blank">Vergisting</a></li> - </ul> - </li> + <li><img style='float: left; margin-right: 5px;' src='images/insert-object.png' /><a href="prod_impbrew.php">Brouw log</a></li> </ul> </li> <li style='width: 80px;'>Recepten
--- a/www/js/prod_archive_code.js Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2019 - * - * Michiel Broek <mbroek at mbse dot eu> - * - * This file is part of BMS - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * BrewCloud 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 GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - - -$(document).ready(function() { - var source = { - datatype: 'json', - cache: false, - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'code', type: 'string' }, - { name: 'date', type: 'string' }, - { name: 'style', type: 'string' }, - { name: 'og', type: 'float' }, - { name: 'fg', type: 'float' }, - { name: 'batch_size', type: 'float' }, - ], - id: 'record', - url: 'includes/db_product.php?select=archcode' - }, - dataAdapter = new $.jqx.dataAdapter(source); - - // initialize jqxGrid - $('#jqxgrid').jqxGrid({ - width: 1280, - height: 630, - source: dataAdapter, - theme: theme, - columns: [ - { text: 'Code', datafield: 'code', width: 100 }, - { text: 'Naam', datafield: 'name' }, - { text: 'Stijl', datafield: 'style', width: 250 }, - { text: 'OG', datafield: 'og', width: 80, cellsformat: 'f3' }, - { text: 'FG', datafield: 'fg', width: 80, cellsformat: 'f3' }, - { text: 'Datum', datafield: 'date', width: 120 }, - { text: 'Liters', datafield: 'batch_size', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: '', datafield: 'Edit', width: 80, align: 'center', columntype: 'button', cellsrenderer: function() { - return 'Bekijk'; - }, buttonclick: function(row) { - var datarecord = dataAdapter.records[row]; - window.location.href = 'prod_edit.php?record=' + datarecord.record + '&select=archcode&return=prod_archive_code.php'; - } - } - ], - }); -});
--- a/www/js/prod_archive_date.js Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2019 - * - * Michiel Broek <mbroek at mbse dot eu> - * - * This file is part of BMS - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * BrewCloud 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 GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - - -$(document).ready(function() { - var source = { - datatype: 'json', - cache: false, - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'code', type: 'string' }, - { name: 'year', type: 'string' }, - { name: 'date', type: 'string' }, - { name: 'style', type: 'string' }, - { name: 'og', type: 'float' }, - { name: 'fg', type: 'float' }, - { name: 'batch_size', type: 'float' }, - ], - id: 'record', - url: 'includes/db_product.php?select=archdate' - }, - dataAdapter = new $.jqx.dataAdapter(source); - - // initialize jqxGrid - $('#jqxgrid').jqxGrid({ - width: 1280, - height: 630, - source: dataAdapter, - groupable: true, - theme: theme, - columns: [ - { text: 'Jaar', datafield: 'year', width: 80 }, - { text: 'Datum', datafield: 'date', width: 120, menu: false }, - { text: 'Naam', datafield: 'name', menu: false }, - { text: 'Stijl', datafield: 'style', width: 250 }, - { text: 'OG', datafield: 'og', width: 80, cellsformat: 'f3', menu: false }, - { text: 'FG', datafield: 'fg', width: 80, cellsformat: 'f3', menu: false }, - { text: 'Code', datafield: 'code', width: 100, menu: false }, - { text: 'Liters', datafield: 'batch_size', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', menu: false }, - { text: '', datafield: 'Edit', width: 80, align: 'center', columntype: 'button', cellsrenderer: function() { - return 'Bekijk'; - }, buttonclick: function(row) { - var datarecord = dataAdapter.records[row]; - window.location.href = 'prod_edit.php?record=' + datarecord.record + '&select=archdate&return=prod_archive_date.php'; - } - } - ], - groups: ['year'] - }); -});
--- a/www/js/prod_archive_name.js Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2019 - * - * Michiel Broek <mbroek at mbse dot eu> - * - * This file is part of BMS - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * BrewCloud 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 GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ThermFerm; see the file COPYING. If not, write to the Free - * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - *****************************************************************************/ - - -$(document).ready(function() { - var source = { - datatype: 'json', - cache: false, - datafields: [ - { name: 'record', type: 'number' }, - { name: 'name', type: 'string' }, - { name: 'code', type: 'string' }, - { name: 'date', type: 'string' }, - { name: 'style', type: 'string' }, - { name: 'og', type: 'float' }, - { name: 'fg', type: 'float' }, - { name: 'batch_size', type: 'float' }, - ], - id: 'record', - url: 'includes/db_product.php?select=archname' - }, - dataAdapter = new $.jqx.dataAdapter(source); - - // initialize jqxGrid - $('#jqxgrid').jqxGrid({ - width: 1280, - height: 630, - source: dataAdapter, - theme: theme, - columns: [ - { text: 'Naam', datafield: 'name' }, - { text: 'Stijl', datafield: 'style', width: 250 }, - { text: 'OG', datafield: 'og', width: 80, cellsformat: 'f3' }, - { text: 'FG', datafield: 'fg', width: 80, cellsformat: 'f3' }, - { text: 'Datum', datafield: 'date', width: 120 }, - { text: 'Code', datafield: 'code', width: 100 }, - { text: 'Liters', datafield: 'batch_size', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: '', datafield: 'Edit', width: 80, align: 'center', columntype: 'button', cellsrenderer: function() { - return 'Bekijk'; - }, buttonclick: function(row) { - var datarecord = dataAdapter.records[row]; - window.location.href = 'prod_edit.php?record=' + datarecord.record + '&select=archname&return=prod_archive_name.php'; - } - } - ], - }); -});
--- a/www/prod_archive_code.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -page_header('Producten archief op code', 'prod_archive_code'); -?> - - <div id="jqxgrid"></div> - <div style="margin-top: 30px;"> - <div id="cellbegineditevent"></div> - <div style="margin-top: 10px;" id="cellendeditevent"></div> - </div> - -<?php -page_footer(); -?>
--- a/www/prod_archive_date.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -page_header('Producten archief op datum', 'prod_archive_date'); -?> - - <div id="jqxgrid"></div> - <div style="margin-top: 30px;"> - <div id="cellbegineditevent"></div> - <div style="margin-top: 10px;" id="cellendeditevent"></div> - </div> - -<?php -page_footer(); -?>
--- a/www/prod_archive_name.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -page_header('Producten archief op naam', 'prod_archive_name'); -?> - - <div id="jqxgrid"></div> - <div style="margin-top: 30px;"> - <div id="cellbegineditevent"></div> - <div style="margin-top: 10px;" id="cellendeditevent"></div> - </div> - -<?php -page_footer(); -?>
--- a/www/prod_r_efficiency.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php'); - - -$link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); -if (! $link) { - die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); -} -if (! mysqli_set_charset($link, "utf8" )) { - echo "error"; - return 1; -} - -setlocale ( LC_ALL, 'nl_NL.UTF-8'); - -date_default_timezone_set('Europe/Amsterdam'); -$prdate = date(DATE_RFC2822); - -class PDF_MySQL_Table extends FPDF -{ - protected $ProcessingTable=false; - protected $aCols=array(); - protected $TableX; - - function Header() { - // Print the table header if necessary - if ($this->ProcessingTable) - $this->TableHeader(); - } - - function TableHeader() { - $this->SetFont('Helvetica','B',9); - $this->SetX($this->TableX); - $this->SetFillColor(255,150,100); - foreach($this->aCols as $col) - $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true); - $this->Ln(); - } - - function AddCol($width=-1, $caption='', $align='L') { - $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); - } - - function TableTotals() { - - global $link; - - $vul = $this->w - $this->rMargin - $this->lMargin - 128; - $this->AddCol(18,'Code','L'); - $this->AddCol($vul,'Naam','L'); - $this->AddCol(30,'Bier stijl','L'); - $this->AddCol(20,'Max extract','R'); - $this->AddCol(20,'Maish eff.','R'); - $this->AddCol(20,'Spoel eff.','R'); - $this->AddCol(20,'Kook eff.','R'); - - $cMargin=$this->cMargin; - $this->cMargin=2; - $this->TableX=$this->lMargin; - $this->TableHeader(); - $this->ProcessingTable=true; - - $this->SetFont('Helvetica','',9); - $this->SetFillColor(210,245,255); - - $result = mysqli_query($link, "SELECT * FROM products WHERE package_date AND type='2' ORDER BY code"); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - /* - * Data is not always available, try to calculate the mssing pieces. - */ - $mvol = 0; - $msugars = 0; // mash sugars - $ssugars = 0; - $arr = json_decode($row['json_mashs'], true); - foreach($arr as $item) { - if ($item['step_type'] == 0) - $mvol += $item['step_infuse_amount']; - } - - $ferms = json_decode($row['json_fermentables'], true); - foreach($ferms as $item) { - if ($item['f_added'] == 0) { - $d = $item['f_amount'] * ($item['f_yield'] / 100) * (1 - $item['f_moisture'] / 100); - $ssugars += $item['f_amount']; - $mvol += $item['f_amount'] * $item['f_moisture'] / 100; - $msugars += $d; - } - } - $sugardensity = 1.611; - $v = $msugars / $sugardensity + $mvol; - $plato = 1000 * $msugars / ($v * 10); // deg. Plato - $mash_efficiency = floatval($row['brew_mash_efficiency']); - $mash_sg = floatval($row['brew_mash_sg']); - if (($mash_efficiency == 0) && ($mash_sg > 1)) { - $mash_efficiency = 100 * sg_to_plato($mash_sg) / $plato; - } - $mash_extract = 100 * $msugars / $ssugars; - $preboil_sg = floatval($row['brew_preboil_sg']); - $preboil_volume = floatval($row['brew_preboil_volume']); - $est_preboil_plato = sg_to_plato($preboil_sg) * ($preboil_volume / 1.04) * $preboil_sg * 10 / 1000; - $preboil_efficiency = floatval($row['brew_preboil_efficiency']); - if (($msugars > 0) && ($preboil_efficiency == 0)) - $preboil_efficiency = $est_preboil_plato / $msugars * 100; - if ($preboil_efficiency < 0) - $preboil_efficiency = 0; - $aboil_efficiency = floatval($row['brew_aboil_efficiency']); - - $name = iconv('UTF-8','windows-1252',$row['name']); - $st_name = iconv('UTF-8','windows-1252',$row['st_name']); - $this->SetX($this->TableX); - $this->Cell(18,5,$row['code'],0,0,'L',true); - $this->Cell($vul,5,$name,0,0,'L',true); - $this->Cell(30,5,$st_name,0,0,'L',true); - $this->Cell(20,5,sprintf("%.1f",$mash_extract).'%',0,0,'R',true); - $this->Cell(20,5,sprintf("%.1f",$mash_efficiency).'%',0,0,'R',true); - $this->Cell(20,5,sprintf("%.1f",$preboil_efficiency).'%',0,0,'R',true); - $this->Cell(20,5,sprintf("%.1f",$aboil_efficiency).'%',0,0,'R',true); - $this->Ln(); - } - $this->ProcessingTable=false; - $this->cMargin=$cMargin; - $this->aCols=array(); - $this->Ln(); - } -} - - - -class PDF extends PDF_MySQL_Table { - function Header() { - global $prdate; - global $my_brewery_name; - $this->Image('images/logo.png',10,10,30); - // Title - $this->SetFont('Helvetica','B',18); - $this->SetX(45); - $this->Cell(0,8,"Efficientie ".$my_brewery_name,0,1,'L'); - $this->Ln(1); - $this->SetFont('Helvetica','',10); - $this->SetX(45); - $this->Cell(17,5,'Datum:',0,0,'L'); - $this->Cell(0,5,$prdate,0,1,'L'); - $this->Ln(20); - // Ensure table header is printed - parent::Header(); - } -} - - - -/* - * Generate PDF - */ -$pdf = new PDF(); -$pdf->AddPage(); -$pdf->TableTotals(); -$pdf->Output();
--- a/www/prod_r_totals.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php'); - - -$link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); -if (! $link) { - die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); -} -if (! mysqli_set_charset($link, "utf8" )) { - echo "error"; - return 1; -} - -setlocale ( LC_ALL, 'nl_NL.UTF-8'); - -date_default_timezone_set('Europe/Amsterdam'); -$prdate = date(DATE_RFC2822); - -class PDF_MySQL_Table extends FPDF -{ - protected $ProcessingTable=false; - protected $aCols=array(); - protected $TableX; - - function Header() { - // Print the table header if necessary - if ($this->ProcessingTable) - $this->TableHeader(); - } - - function TableHeader() { - $this->SetFont('Helvetica','B',9); - $this->SetX($this->TableX); - $this->SetFillColor(255,150,100); - foreach($this->aCols as $col) - $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true); - $this->Ln(); - } - - function AddCol($width=-1, $caption='', $align='L') { - $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); - } - - function TableTotals() { - - global $link; - - $vul = ($this->w - $this->rMargin - $this->lMargin - 130) / 2; - $this->Ln(); - $this->AddCol(15,'Nummer','C'); - $this->AddCol(10,'Jaar','C'); - $this->AddCol(35,'Brouw sessies','R'); - $this->AddCol(35,'Brouw volume','R'); - $this->AddCol(35,'Gemiddeld volume','R'); - - $total = $tvolume = $regel = 0; - $cMargin=$this->cMargin; - $this->cMargin=2; - $this->TableX=$this->lMargin+$vul; - $this->TableHeader(); - $this->ProcessingTable=true; - - $this->SetFont('Helvetica','',9); - $this->SetFillColor(210,245,255); - - $result = mysqli_query($link, "SELECT DISTINCT YEAR(package_date) FROM products WHERE package_date ORDER BY package_date"); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - - $regel++; - $year = $row['YEAR(package_date)']; - $this->SetX($this->TableX); - - $brews = 0; - $packaged = 0; - - $result2 = mysqli_query($link, "SELECT package_volume FROM products WHERE package_date AND YEAR(package_date) = '".$year."'"); - while ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { - $brews++; - $total++; - $packaged += floatval($row2['package_volume']); - $tvolume += floatval($row2['package_volume']); - } - $average = $packaged / $brews; - $this->Cell(15,5,$regel,0,0,'C',true); - $this->Cell(10,5,$year,0,0,'C',true); - $this->Cell(35,5,$brews,0,0,'R',true); - $this->Cell(35,5,sprintf("%.1f",$packaged).' L',0,0,'R',true); - $this->Cell(35,5,sprintf("%.1f",$average).' L',0,0,'R',true); - $this->Ln(); - } - $this->Cell($vul+25,5,'',0,0,'L',false); - $this->Cell(35,5,$total,0,0,'R',true); - $this->Cell(35,5,sprintf("%.1f",$tvolume).' L',0,0,'R',true); - $this->ProcessingTable=false; - $this->cMargin=$cMargin; - $this->aCols=array(); - $this->Ln(); - } -} - - - -class PDF extends PDF_MySQL_Table { - function Header() { - global $prdate; - global $my_brewery_name; - $this->Image('images/logo.png',10,10,30); - // Title - $this->SetFont('Helvetica','B',18); - $this->SetX(45); - $this->Cell(0,8,"Jaarproductie ".$my_brewery_name,0,1,'L'); - $this->Ln(1); - $this->SetFont('Helvetica','',10); - $this->SetX(45); - $this->Cell(17,5,'Datum:',0,0,'L'); - $this->Cell(0,5,$prdate,0,1,'L'); - $this->Ln(20); - // Ensure table header is printed - parent::Header(); - } -} - - - -/* - * Generate PDF - */ -$pdf = new PDF(); -$pdf->AddPage(); -$pdf->TableTotals(); -$pdf->Output();
--- a/www/prod_r_yeast.php Mon Aug 01 13:26:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -<?php -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); -require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php'); - - -$link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); -if (! $link) { - die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); -} -if (! mysqli_set_charset($link, "utf8" )) { - echo "error"; - return 1; -} - -setlocale ( LC_ALL, 'nl_NL.UTF-8'); - -date_default_timezone_set('Europe/Amsterdam'); -$prdate = date(DATE_RFC2822); - -class PDF_MySQL_Table extends FPDF -{ - protected $ProcessingTable=false; - protected $aCols=array(); - protected $TableX; - - function Header() { - // Print the table header if necessary - if ($this->ProcessingTable) - $this->TableHeader(); - } - - function TableHeader() { - $this->SetFont('Helvetica','B',9); - $this->SetX($this->TableX); - $this->SetFillColor(255,150,100); - foreach($this->aCols as $col) - $this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true); - $this->Ln(); - } - - function AddCol($width=-1, $caption='', $align='L') { - $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align); - } - - function TableTotals() { - - global $link; - - $vul = $this->w - $this->rMargin - $this->lMargin - 151; - $this->AddCol(16,'Code','L'); - $this->AddCol($vul,'Naam','L'); - $this->AddCol(35,'Gist','L'); - $this->AddCol(20,'Hoofdgisting','R'); - $this->AddCol(20,'Nagisten','R'); - $this->AddCol(20,'Lageren','R'); - $this->AddCol(10,'Duur','R'); - $this->AddCol(10,'OG','R'); - $this->AddCol(10,'FG','R'); - $this->AddCol(12,'SVG','R'); - - $cMargin=$this->cMargin; - $this->cMargin=2; - $this->TableX=$this->lMargin; - $this->TableHeader(); - $this->ProcessingTable=true; - - $this->SetFont('Helvetica','',9); - $this->SetFillColor(210,245,255); - - $result = mysqli_query($link, "SELECT * FROM products WHERE package_date AND type='2' ORDER BY json_yeasts"); - while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - /* - * Data is not always available, try to calculate the mssing pieces. - */ - $y_name = $y_lab = $y_product = ''; - $yeasts = json_decode($row['json_yeasts'], true); - foreach($yeasts as $item) { - if ($item['y_use'] == 0) { - $y_name = iconv('UTF-8','windows-1252',$item['y_name']); - $y_lab = iconv('UTF-8','windows-1252',$item['y_laboratory']); - $y_product = iconv('UTF-8','windows-1252',$item['y_product_id']); - break; - } - } - - // name,brew_date_end,primary_end_date,secondary_end_date,package_date - $d1 = new DateTime($row['brew_date_end']); - $d2 = new DateTime($row['primary_end_date']); - $d3 = new DateTime($row['secondary_end_date']); - $d4 = new DateTime($row['package_date']); - - $diff = $d2->diff($d1); - $primary_days = $diff->days; - $diff = $d3->diff($d2); - $secondary_days = $diff->days; - $diff = $d4->diff($d3); - $tertiary_days = $diff->days; - $diff = $d4->diff($d1); - $total_days = $diff->days; - - $og = floatval($row['brew_fermenter_sg']); - $fg = floatval($row['fg']); - $svg = calc_svg($og, $fg); - - $name = iconv('UTF-8','windows-1252',$row['name']); - $this->SetX($this->TableX); - $this->Cell(16,5,$row['code'],0,0,'L',true); - $this->Cell($vul,5,$name,0,0,'L',true); - $this->Cell(35,5,$y_lab.' '.$y_product,0,0,'L',true); - $this->Cell(13,5,sprintf("%.1f",$row['primary_end_temp']).DEG,0,0,'R',true); - $this->Cell( 7,5,sprintf("%d",$primary_days),0,0,'R',true); - $this->Cell(13,5,sprintf("%.1f",$row['secondary_temp']).DEG,0,0,'R',true); - $this->Cell( 7,5,sprintf("%d",$secondary_days),0,0,'R',true); - $this->Cell(13,5,sprintf("%.1f",$row['tertiary_temp']).DEG,0,0,'R',true); - $this->Cell( 7,5,sprintf("%d",$tertiary_days),0,0,'R',true); - $this->Cell(10,5,sprintf("%d",$total_days),0,0,'R',true); - $this->Cell(10,5,sprintf("%.3f",$og),0,0,'R',true); - $this->Cell(10,5,sprintf("%.3f",$fg),0,0,'R',true); - $this->Cell(12,5,sprintf("%.1f",$svg).'%',0,0,'R',true); - $this->Ln(); - } - $this->ProcessingTable=false; - $this->cMargin=$cMargin; - $this->aCols=array(); - $this->Ln(); - } -} - - - -class PDF extends PDF_MySQL_Table { - function Header() { - global $prdate; - global $my_brewery_name; - $this->Image('images/logo.png',10,10,30); - // Title - $this->SetFont('Helvetica','B',18); - $this->SetX(45); - $this->Cell(0,8,"Vergisting ".$my_brewery_name,0,1,'L'); - $this->Ln(1); - $this->SetFont('Helvetica','',10); - $this->SetX(45); - $this->Cell(17,5,'Datum:',0,0,'L'); - $this->Cell(0,5,$prdate,0,1,'L'); - $this->Ln(20); - // Ensure table header is printed - parent::Header(); - } -} - - - -/* - * Generate PDF - */ -$pdf = new PDF(); -$pdf->AddPage(); -$pdf->TableTotals(); -$pdf->Output();