<?php
include ('class.ezpdf.php');
include 'includes/config.php';
include 'defs.php';
$pdf = new Cezpdf('A4','portrait');
$pdf->selectFont('fonts/Times-Roman.afm');
$pdf->addJpegFromFile('images/logo1.jpg',30,740,70);
//$pdf->addText(18,750,9,"MIS GENERATED REPORT");
$date1=Date("j-n-Y");
//$pdf->ezStartPageNumbers(526, 16, 10, 'right', '', 1);
$pdf->setColor(0.72, 0.72, 0.72);
$pdf->filledRectangle(220, 770, 160, 30, 'rgb');
$pdf->setColor(0,0,0);
$pdf->addText(265,780,13,"<b>(GLAKB)</b>");
$pdf->ezSetDy(-100);

$typee=$_POST['item3']; 
$strFrom=$_POST['strFrom'];
$fdate=date('d-m-Y',strtotime($strFrom));
$pdf->addText(20,720,12,"<b>Effective from </b>    $fdate");


$header = $pdf->openObject();
$pdf->addText(20, 16, 10, "<b>Contact us @</b> Sabzal Road - Block No 3, STN Colony, Near Spini Road, Quetta (+92 81 2873538)");
$pdf->addText(20, 30, 10, "<b>________________________________________________________________________________________________________________</b>");

$pdf->closeObject();
$pdf->addObject($header, "all");

if($typee=='Retail')
{
$pdf->addText(230,755,12,"<b>(RETAILER PRICE LIST)</b>");
$nResult = MySQLi_Query($link, "Select * from products order by Full_Name ");
$count=0;
$one=1;
$rp=0;
$ucart=0;
$lit=0;
$tpl=0;
$tpc=0;
while($rstRow = mysqli_fetch_array($nResult))
{
$rp=$rstRow['R_Price'];
$ucart=$rstRow['Carton_Qty'];
$lit=$rstRow['Unit_Liter'];
$tpl=$rp*$lit;
$tpc=$tpl*$ucart;
$tpl1=number_format($tpl, 0);        
$tpc1=number_format($tpc, 0);        
$rp1=number_format($rp, 0);        
$count=$one+$count;
$data[] = array('num'=>$count,'fname'=>$rstRow['Full_Name'],'api'=>$rstRow['API'],'grade'=>$rstRow['Grade'],'pack'=>$rstRow['Size'],'rrate'=>$rp1,'tpl'=>$tpl1,'tpc'=>$tpc1);
}

$cols = array('num'=>'<b>S. No</b>','fname'=>'<b>Product Full Name</b>','api'=>'<b>API</b>','grade'=>'<b>SAE / Grade</b>','pack'=>'<b>Packing</b>','rrate'=>'<b>TP Per Ltr</b>','tpl'=>'<b>TP Per Unit</b>','tpc'=>'<b>TP Per Carton</b>');
$pdf->ezTable($data,$cols,'',
        array('xPos'=>20,'xOrientation'=>'right','fontSize' => 10,'width'=>680,'showHeadings'=>1,'shaded'=>0, 'showLines'=>2,'cols'=>array(
                'num'=>array('justification'=>'center','width'=>38),
                 'fname'=>array('justification'=>'left','width'=>140),
                 'api'=>array('justification'=>'center','width'=>45),
                'grade'=>array('justification'=>'left','width'=>70),
                 'pack'=>array('justification'=>'center','width'=>60),
                'rrate'=>array('justification'=>'right','width'=>60),
                'tpl'=>array('justification'=>'right','width'=>62),
                'tpc'=>array('justification'=>'right','width'=>75)
                )));

}

if($typee=='Whole Sale')
{
$pdf->addText(220,755,12,"<b>(WHOLE SALE PRICE LIST)</b>");
$nResult = MySQLi_Query($link, "Select * from products order by Full_Name ");
$count=0;
$one=1;
$rp=0;
$ucart=0;
$lit=0;
$tpl=0;
$tpc=0;
while($rstRow = mysqli_fetch_array($nResult))
{
$rp=$rstRow['W_Price'];
$ucart=$rstRow['Carton_Qty'];
$lit=$rstRow['Unit_Liter'];
$tpl=$rp*$lit;
$tpc=$tpl*$ucart;
$tpl1=number_format($tpl, 0);        
$tpc1=number_format($tpc, 0);        
$rp1=number_format($rp, 0);        
$count=$one+$count;
$data[] = array('num'=>$count,'fname'=>$rstRow['Full_Name'],'api'=>$rstRow['API'],'grade'=>$rstRow['Grade'],'pack'=>$rstRow['Size'],'rrate'=>$rp1,'tpl'=>$tpl1,'tpc'=>$tpc1);
}

$cols = array('num'=>'<b>S. No</b>','fname'=>'<b>Product Full Name</b>','api'=>'<b>API</b>','grade'=>'<b>SAE / Grade</b>','pack'=>'<b>Packing</b>','rrate'=>'<b>TP Per Ltr</b>','tpl'=>'<b>TP Per Unit</b>','tpc'=>'<b>TP Per Carton</b>');
$pdf->ezTable($data,$cols,'',
        array('xPos'=>20,'xOrientation'=>'right','fontSize' => 10,'width'=>680,'showHeadings'=>1,'shaded'=>0, 'showLines'=>2,'cols'=>array(
                'num'=>array('justification'=>'center','width'=>38),
                 'fname'=>array('justification'=>'left','width'=>140),
                 'api'=>array('justification'=>'center','width'=>45),
                'grade'=>array('justification'=>'left','width'=>70),
                 'pack'=>array('justification'=>'center','width'=>60),
                'rrate'=>array('justification'=>'right','width'=>60),
                'tpl'=>array('justification'=>'right','width'=>62),
                'tpc'=>array('justification'=>'right','width'=>75)
                )));

}



if($typee=='Dealer')
{
$pdf->addText(235,755,12,"<b>(DEALER PRICE LIST)</b>");
$nResult = MySQLi_Query($link, "Select * from products order by Full_Name ");
$count=0;
$one=1;
$rp=0;
$ucart=0;
$lit=0;
$tpl=0;
$tpc=0;
while($rstRow = mysqli_fetch_array($nResult))
{
$rp=$rstRow['D_Price'];
$ucart=$rstRow['Carton_Qty'];
$lit=$rstRow['Unit_Liter'];
$tpl=$rp*$lit;
$tpc=$tpl*$ucart;
$tpl1=number_format($tpl, 0);        
$tpc1=number_format($tpc, 0);        
$rp1=number_format($rp, 0);        
$count=$one+$count;
$data[] = array('num'=>$count,'fname'=>$rstRow['Full_Name'],'api'=>$rstRow['API'],'grade'=>$rstRow['Grade'],'pack'=>$rstRow['Size'],'rrate'=>$rp1,'tpl'=>$tpl1,'tpc'=>$tpc1);
}

$cols = array('num'=>'<b>S. No</b>','fname'=>'<b>Product Full Name</b>','api'=>'<b>API</b>','grade'=>'<b>SAE / Grade</b>','pack'=>'<b>Packing</b>','rrate'=>'<b>TP Per Ltr</b>','tpl'=>'<b>TP Per Unit</b>','tpc'=>'<b>TP Per Carton</b>');
$pdf->ezTable($data,$cols,'',
        array('xPos'=>20,'xOrientation'=>'right','fontSize' => 10,'width'=>680,'showHeadings'=>1,'shaded'=>0, 'showLines'=>2,'cols'=>array(
                'num'=>array('justification'=>'center','width'=>38),
                 'fname'=>array('justification'=>'left','width'=>140),
                 'api'=>array('justification'=>'center','width'=>45),
                'grade'=>array('justification'=>'left','width'=>70),
                 'pack'=>array('justification'=>'center','width'=>60),
                'rrate'=>array('justification'=>'right','width'=>60),
                'tpl'=>array('justification'=>'right','width'=>62),
                'tpc'=>array('justification'=>'right','width'=>75)
                )));

}



$pdf->ezSetDy(-20);
$pdf->ezText("<b>****GLAKB has Exclusive Rights to change the Price with / without Prior Notice.</b>", 12, array("justification" => 'left'));
$pdf->ezSetDy(-40);
$pdf->ezText("<b>Owner GLAKB</b>", 12, array("justification" => 'right'));
ob_clean();
$pdf->ezStream();
?>



