<?php
include('database.php');
$database = new Database();

$ord=$_REQUEST['order'];
$billno=$_REQUEST['billno'];
$name=$_REQUEST['cname'];
$mob=$_REQUEST['contact'];
$picfr=$_REQUEST['loc'];
$disc=$_REQUEST['disc'];
$pay=$_REQUEST['pay'];
$total=$_REQUEST['total'];
$date=$_REQUEST['rdate'];
 
  
      
         
      
  







$result1 = $database->runQuery("SELECT Itemname,Rate,Qty,Totalamt FROM carttbl where Orderid='$ord'");
$header1 = $database->runQuery("SELECT UCASE(`COLUMN_NAME`) 
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='htechsol_hts' 
AND `TABLE_NAME`='carttbl'
and `COLUMN_NAME` in ('NAME','RATE','QTY','TOTAL')");

require('fpdf/fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$height=0;
$pdf->Image('pdfheader.png',0,0);
$height=$height+33;
$pdf -> Line(5, $height, 200, $height);
$height=$height+10;
$pdf -> Line(5, $height, 200, $height);
$height=$height+20;
$pdf -> Line(5, $height, 200, $height);


$textheight=38;
$pdf->SetFont('Arial','B',10);

$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "ORDER NO : ";
$pdf->Write(0, $text);

$pdf->SetXY(29, $textheight); // X start, Y start in mm
$text = $billno;
$pdf->Write(0, $text);

$pdf->SetXY(143, $textheight); // X start, Y start in mm
$text = "INVOICE DATE:";
$pdf->Write(0, $text);

$pdf->SetXY(170, $textheight); // X start, Y start in mm
$text = $date;
$pdf->Write(0, $text);


$textheight=$textheight+9;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "TO : ";
$pdf->Write(0, $text);


$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $name;
$pdf->Write(0, $text);
$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $mob;
$pdf->Write(0, $text);
$textheight=$textheight+4;
$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = $picfr;
$pdf->Write(0, $text);


$textheight=$textheight+10;

$pdf->SetXY(7, $textheight); // X start, Y start in mm
$text = "ITEM NAME ";
$pdf->Write(0, $text);

$pdf->SetXY(7+100, $textheight); // X start, Y start in mm
$text = "RATE "."($)";
$pdf->Write(0, $text);

$pdf->SetXY(7+120, $textheight); // X start, Y start in mm
$text = "QTY ";
$pdf->Write(0, $text);

$pdf->SetXY(7+140, $textheight); // X start, Y start in mm
$text = "TOTAL "."($)";
$pdf->Write(0, $text);

$textheight=$textheight+5;
$pdf -> Line(5, $textheight, 200, $textheight);



foreach($result1 as $row) {
	$textheight=$textheight+10;
	$pdf->Ln();
	$textwidth=7;
	$i=1;
	foreach($row as $column)
	{
	
	
	$pdf->SetXY($textwidth, $textheight); // X start, Y start in mm

$pdf->Write(0, $column);
if($i==1)
{
$textwidth=$textwidth+100;
}
else
{
	$textwidth=$textwidth+20;
}

$i=$i+1;
	}
	
		//$pdf->Cell(35,5,$column,1);
}

$textheight=$textheight+5;
$pdf -> Line(5, $textheight, 200, $textheight);

$textheight=$textheight+5;
$pdf->SetXY(7+95, $textheight); // X start, Y start in mm
$text = "TOTAL AMOUNT "."($)  ";
$pdf->Write(0, $text);

$pdf->SetXY(7+140, $textheight); // X start, Y start in mm
$text = "$ ".$total;
$pdf->Write(0, $text);

$textheight=$textheight+5;
$pdf->SetXY(7+95, $textheight); // X start, Y start in mm
$text = "DISC AMOUNT "."($)  ";
$pdf->Write(0, $text);

$pdf->SetXY(7+140, $textheight); // X start, Y start in mm
$text = "$ ". $disc;
$pdf->Write(0, $text);


$textheight=$textheight+5;
$pdf->SetXY(7+95, $textheight); // X start, Y start in mm
$text = "NET AMOUNT "."($)  ";
$pdf->Write(0, $text);

$pdf->SetXY(7+140, $textheight); // X start, Y start in mm
$text = "$ ".$pay;
$pdf->Write(0, $text);



$textheight=$textheight+5;
$pdf -> Line(5, $textheight, 200, $textheight);

$pdf->Output();
?>