Added private yeastlab pdf list

Thu, 05 Mar 2020 21:19:14 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 05 Mar 2020 21:19:14 +0100
changeset 626
571473f62c1e
parent 625
57bc32b5f411
child 627
f1a7c14d5601

Added private yeastlab pdf list

www/Makefile file | annotate | diff | comparison | revisions
www/images/science.png file | annotate | diff | comparison | revisions
www/includes/global.inc.php file | annotate | diff | comparison | revisions
www/inv_yeastlab.php file | annotate | diff | comparison | revisions
--- a/www/Makefile	Thu Mar 05 16:34:03 2020 +0100
+++ b/www/Makefile	Thu Mar 05 21:19:14 2020 +0100
@@ -12,7 +12,7 @@
 		  getwatersources.php getyeastsources.php getispindel.php getispindellog.php \
 		  import_ingredients.php index.php \
 		  inv_equipments.php inv_fermentables.php inv_hops.php inv_instock.php \
-		  inv_miscs.php inv_suppliers.php inv_waters.php inv_yeasts.php \
+		  inv_miscs.php inv_suppliers.php inv_waters.php inv_yeasts.php inv_yeastlab.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 \
Binary file www/images/science.png has changed
--- a/www/includes/global.inc.php	Thu Mar 05 16:34:03 2020 +0100
+++ b/www/includes/global.inc.php	Thu Mar 05 21:19:14 2020 +0100
@@ -305,6 +305,7 @@
        <li><img style='float: left; margin-left: 3px; margin-right: 9px;' src='images/water.png' /><a href="inv_waters.php">Brouwwater</a></li>
        <li><img style='float: left; margin-right: 5px;' src='images/mash.png' /><a href="inv_equipments.php">Brouw apparatuur</a></li>
        <li><img style='float: left; margin-left: 3px; margin-right: 8px;' src='images/database.png' /><a href="inv_instock.php">Voorraad lijst</a></li>
+       <li><img style='float: left; margin-left: 3px; margin-right: 8px;' src='images/science.png' /><a href="inv_yeastlab.php">Gistbank lijst</a></li>
       </ul>
      </li>
      <li style='width: 80px;'>Instellingen
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/inv_yeastlab.php	Thu Mar 05 21:19:14 2020 +0100
@@ -0,0 +1,162 @@
+<?php
+require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
+require_once($_SERVER['DOCUMENT_ROOT'].'/includes/constants.php');
+require_once($_SERVER['DOCUMENT_ROOT'].'/fpdf/fpdf.php');
+
+define('EURO', chr(128) );
+
+$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);
+
+$sql = "SELECT brewery_name,my_yeastlab FROM profile_setup WHERE record = '1';";
+$result = mysqli_query($link, $sql);
+if ($row=mysqli_fetch_array($result)) {
+	$my_brewery = iconv('UTF-8','windows-1252',$row['brewery_name']);
+	$my_lab = $row['my_yeastlab'];
+} else {
+	$my_brewery = $my_lab = '';
+}
+
+
+class PDF_MySQL_Table extends FPDF
+{
+	protected $ProcessingTable=false;
+	protected $aCols=array();
+	protected $TableX;
+	protected $HeaderColor;
+	protected $RowColors;
+	protected $TotalColor;
+	protected $ColorIndex;
+
+	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($this->HeaderColor[0],$this->HeaderColor[1],$this->HeaderColor[2]);
+		foreach($this->aCols as $col)
+			$this->Cell($col['w'],5,$col['c'],0,0,$col['a'],true);
+		$this->Ln();
+	}
+
+	function CalcWidths($width, $align) {
+		// Compute the widths of the columns
+		$TableWidth=0;
+		foreach($this->aCols as $i=>$col) {
+			$w=$col['w'];
+			if($w==-1)
+				$w=$width/count($this->aCols);
+			elseif(substr($w,-1)=='%')
+				$w=$w/100*$width;
+			$this->aCols[$i]['w']=$w;
+			$TableWidth+=$w;
+		}
+		// Compute the abscissa of the table
+		if($align=='C')
+			$this->TableX=max(($this->w-$TableWidth)/2,0);
+		elseif($align=='R')
+			$this->TableX=max($this->w-$this->rMargin-$TableWidth,0);
+		else
+			$this->TableX=$this->lMargin;
+	}
+
+	function AddCol($width=-1, $caption='', $align='L') {
+	        $this->aCols[]=array('c'=>$caption,'w'=>$width,'a'=>$align);
+	}
+
+	function TableYeasts($link,$prop) {
+		global $yeasttype;
+		global $yeastform;
+		global $my_lab;
+		$this->AddCol( 20,'Product','L');
+		$this->AddCol( 70,'Gist','L');
+		$this->AddCol( 18,'Soort','L');
+		$this->AddCol( 18,'Vorm','L');
+		$this->AddCol( 20,'Voorraad','R');
+		$this->AddCol( 25,'Datum','L');
+		$prop['width']=$this->w-$this->lMargin-$this->rMargin;
+		$prop['align']='L';
+		$cMargin=$this->cMargin;
+		$this->cMargin=$prop['padding'];
+		$this->HeaderColor=$prop['HeaderColor'];
+                $this->TotalColor=$prop['TotalColor'];
+                $this->RowColors=array($prop['color1'],$prop['color2']);
+		$this->CalcWidths($prop['width'],$prop['align']);
+		$this->TableHeader();
+		$this->SetFont('Helvetica','',9);
+		$this->ColorIndex=0;
+		$this->ProcessingTable=true;
+
+		$sql  = "SELECT name,product_id,type,form,inventory,production_date FROM inventory_yeasts ";
+		$sql .= "WHERE inventory > 0 AND laboratory = '".$my_lab."' ORDER BY product_id";
+		$result = mysqli_query($link, $sql);
+
+		while ($row=mysqli_fetch_array($result)) {
+			if ($row['form'] == 0)
+				$stock = floatval($row['inventory']);
+			else
+				$stock = floatval($row['inventory']) * 1000.0;
+			$form = array( 'pak', 'gr', 'ml', 'ml', 'ml', 'ml', 'gr' );
+
+			$this->SetX($this->TableX);
+			$ci=$this->ColorIndex;
+			$this->SetFillColor($this->RowColors[$ci][0],$this->RowColors[$ci][1],$this->RowColors[$ci][2]);
+			$this->Cell(20,5,iconv('UTF-8','windows-1252',$row['product_id']),0,0,'L',true);
+			$this->Cell(70,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true);
+			$this->Cell(18,5,iconv('UTF-8','windows-1252',$yeasttype[$row['type']]),0,0,'L',true);
+			$this->Cell(18,5,iconv('UTF-8','windows-1252',$yeastform[$row['form']]),0,0,'L',true);
+			$this->Cell(20,5,sprintf("%10.1f ",$stock).$form[$row['form']],0,0,'R',true);
+			$this->Cell(25,5,$row['production_date'],0,0,'L',true);
+			$this->Ln();
+			$this->ColorIndex=1-$ci;
+		}
+
+		$this->ProcessingTable=false;
+		$this->cMargin=$cMargin;
+		$this->aCols=array();
+	}
+}
+
+
+
+class PDF extends PDF_MySQL_Table {
+	function Header() {
+		global $prdate;
+		global $my_brewery;
+		$this->Image('images/logo.png',10,6,30);
+		// Title
+		$this->SetFont('Helvetica','',18);
+		$this->SetX(45);
+		$this->Cell(0,10,'Gistbank van '.$my_brewery,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(18);
+		// Ensure table header is printed
+		parent::Header();
+	}
+}
+
+
+$pdf = new PDF();
+$pdf->AddPage();
+$prop = array('HeaderColor'=>array(255,150,100), 'color1'=>array(210,245,255),
+		'color2'=>array(255,255,210), 'TotalColor'=>array(255,150,100), 'padding'=>2);
+$pdf->TableYeasts($link,$prop);
+$pdf->Output();

mercurial