diff -r 9472106a3143 -r 6ce2c2e6796e www/inv_yeastlab.php --- a/www/inv_yeastlab.php Mon Jul 11 15:46:18 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -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( 60,'Gist','L'); - $this->AddCol( 50,'Omschrijving','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,type,form,inventory,production_date,short_desc 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(60,5,iconv('UTF-8','windows-1252',$row['name']),0,0,'L',true); - $this->Cell(50,5,iconv('UTF-8','windows-1252',$row['short_desc']),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();