<?php
session_start();

include("../connect.php");

	$imid1=$_GET['imid'];
	$eve = "select * from res_invoice_master where imid=$imid1";
	$re = mysqli_query($conn, $eve);
	while($rt = mysqli_fetch_assoc($re))
	{
		$_SESSION['qdate']=implode('-', array_reverse(explode('-', $rt['qdate'])));
		$_SESSION['ino']=$rt['ino'];
		$_SESSION['invno1']=$rt['ino'];
		$_SESSION['imno']=$rt['imno'];
		$_SESSION['qrefno']=$rt['qrefno'];
		$_SESSION['disc1']=$rt['disc1'];
		$_SESSION['disc2']=$rt['disc2'];
		$_SESSION['createdby']=$rt['createdby'];
		$_SESSION['kindatten']=$rt['kindatten'];
		//$_SESSION['tax']=$rt['tax'];
		$custid=$rt['custid'];


		$eve1 = "select * from res_customer_master where bumid=$custid";
		$re1 = mysqli_query($conn, $eve1);
		while($rt1 = mysqli_fetch_assoc($re1))
		{
			$_SESSION['vatno']=$rt1['vatno'];
			$_SESSION['cname']=$rt1['cname'];
			$_SESSION['email']=$rt1['email'];
			$_SESSION['mobile']=$rt1['mobile'];
			$_SESSION['address']=$rt1['address'];
			$_SESSION['city']=$rt1['city'];
			$_SESSION['state']=$rt1['state'];
			$_SESSION['cmpname']=$rt1['cmpname'];
		}
		 $evechk1 = "select sum(pdiscamt) as tdiscamt from res_invoice_detail where imid=$imid1";
		$rechk11 = mysqli_query($conn, $evechk1);
		while($rtchk11 = mysqli_fetch_assoc($rechk11))
		{
			$_SESSION['tdiscamt']=$rtchk11['tdiscamt'];
		}




	}
require('fpdf.php');


class PDF_MC_Table extends FPDF
{
	var $widths;
	var $aligns;

	function SetWidths($w)
	{
		//Set the array of column widths
		$this->widths=$w;
	}

	function SetAligns($a)
	{
		//Set the array of column alignments
		$this->aligns=$a;
	}

	function Row($data)
	{
		//Calculate the height of the row
		$nb=0;
		for($i=0;$i<count($data);$i++)
			$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
		$h=5*$nb;
		//Issue a page break first if needed
		$this->CheckPageBreak($h);
		//Draw the cells of the row
		for($i=0;$i<count($data);$i++)
		{
			$w=$this->widths[$i];
			$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
			//Save the current position
			$x=$this->GetX();
			$y=$this->GetY();
			//Draw the border
			$this->Rect($x,$y,$w,$h);
			//Print the text
			$this->MultiCell($w,5,$data[$i],0,$a);
			//Put the position to the right of the cell
			$this->SetXY($x+$w,$y);
		}
		//Go to the next line
		$this->Ln($h);
	}

	function CheckPageBreak($h)
	{
		//If the height h would cause an overflow, add a new page immediately
		if($this->GetY()+$h>$this->PageBreakTrigger)
			$this->AddPage($this->CurOrientation);
	}

	function NbLines($w,$txt)
	{
		//Computes the number of lines a MultiCell of width w will take
		$cw=&$this->CurrentFont['cw'];
		if($w==0)
			$w=$this->w-$this->rMargin-$this->x;
		$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
		$s=str_replace("\r",'',$txt);
		$nb=strlen($s);
		if($nb>0 and $s[$nb-1]=="\n")
			$nb--;
		$sep=-1;
		$i=0;
		$j=0;
		$l=0;
		$nl=1;
		while($i<$nb)
		{
			$c=$s[$i];
			if($c=="\n")
			{
				$i++;
				$sep=-1;
				$j=$i;
				$l=0;
				$nl++;
				continue;
			}
			if($c==' ')
				$sep=$i;
			$l+=$cw[$c];
			if($l>$wmax)
			{
				if($sep==-1)
				{
					if($i==$j)
						$i++;
				}
				else
					$i=$sep+1;
				$sep=-1;
				$j=$i;
				$l=0;
				$nl++;
			}
			else
				$i++;
		}
		return $nl;
	}
}
function GenerateWord()
{
    //Get a random word
    $nb=rand(3,10);
    $w='';
    for($i=1;$i<=$nb;$i++)
        $w.=chr(rand(ord('a'),ord('z')));
    return $w;
}

function GenerateSentence()
{
    //Get a random sentence
    $nb=rand(1,10);
    $s='';
    for($i=1;$i<=$nb;$i++)
        $s.=GenerateWord().' ';
    return substr($s,0,-1);
}

/*
$pdf=new PDF_MC_Table();
$pdf->AddPage();
$pdf->SetFont('Arial','',14);
$pdf->SetWidths(array(30,50,30,40));
srand(microtime()*1000000);
for($i=0;$i<20;$i++)
    $pdf->Row(array(GenerateSentence(),GenerateSentence(),GenerateSentence(),GenerateSentence()));
$pdf->Output();

return;
*/


class PDF extends FPDF
{


var $widths;
	var $aligns;

	function SetWidths($w)
	{
		//Set the array of column widths
		$this->widths=$w;
	}

	function SetAligns($a)
	{
		//Set the array of column alignments
		$this->aligns=$a;
	}

	function Row($data)
	{
		//Calculate the height of the row
		$nb=0;
		for($i=0;$i<count($data);$i++)
			$nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
		$h=5*$nb;
		//Issue a page break first if needed
		$this->CheckPageBreak($h);
		//Draw the cells of the row
		for($i=0;$i<count($data);$i++)
		{
			$w=$this->widths[$i];
			$a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
			//Save the current position
			$x=$this->GetX();
			$y=$this->GetY();
			//Draw the border
			$this->Rect($x,$y,$w,$h);
			//Print the text
			$this->MultiCell($w,5,$data[$i],0,$a);
			//Put the position to the right of the cell
			$this->SetXY($x+$w,$y);
		}
		//Go to the next line
		$this->Ln($h);
	}

	function CheckPageBreak($h)
	{
		//If the height h would cause an overflow, add a new page immediately
		if($this->GetY()+$h>$this->PageBreakTrigger)
			$this->AddPage($this->CurOrientation);
	}

	function NbLines($w,$txt)
	{
		//Computes the number of lines a MultiCell of width w will take
		$cw=&$this->CurrentFont['cw'];
		if($w==0)
			$w=$this->w-$this->rMargin-$this->x;
		$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
		$s=str_replace("\r",'',$txt);
		$nb=strlen($s);
		if($nb>0 and $s[$nb-1]=="\n")
			$nb--;
		$sep=-1;
		$i=0;
		$j=0;
		$l=0;
		$nl=1;
		while($i<$nb)
		{
			$c=$s[$i];
			if($c=="\n")
			{
				$i++;
				$sep=-1;
				$j=$i;
				$l=0;
				$nl++;
				continue;
			}
			if($c==' ')
				$sep=$i;
			$l+=$cw[$c];
			if($l>$wmax)
			{
				if($sep==-1)
				{
					if($i==$j)
						$i++;
				}
				else
					$i=$sep+1;
				$sep=-1;
				$j=$i;
				$l=0;
				$nl++;
			}
			else
				$i++;
		}
		return $nl;
	}


function LoadData($file)
{
    // Read file lines
    $lines = file($file);
    $data = array();
    foreach($lines as $line)
        $data[] = explode(';',trim($line));
    return $data;
}
// Page header
function Header()
{
	include "../connect.php";
	$eve_header="select * from res_settings_master";
	$re_header = mysqli_query($conn, $eve_header);
	while($rt_header = mysqli_fetch_assoc($re_header))
	{
		$headerimg=$rt_header['headerimg'];
	}

	$header = "../allimages/$headerimg";
	$this->Image("$header",8,6,194,30);
    $this->SetFont('Arial','',15);
    $this->Ln(30);

}

// Page footer
function Footer()
{
	include "../connect.php";
	$eve_header="select * from res_settings_master";
	$re_header = mysqli_query($conn, $eve_header);
	while($rt_header = mysqli_fetch_assoc($re_header))
	{
		$footerimg=$rt_header['footerimg'];
	}

	$footer = "../allimages/$footerimg";

	$this->Image("$footer",10,270,190,15);


    $this->SetY(-15);

    $this->SetFont('Arial','',8);

}


function ImprovedTable11()
{

	$kindatten=$_SESSION['kindatten'];

	//$cmpperson = "";

    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];
		$this->Ln(6);
		$this->SetFont('Arial','',12);

		if($kindatten=='')
		{
		}
		else
		{
			$this->Cell(190,5,"Kind Attn. $kindatten",0,0,'C');
		}

		$disc1=strip_tags($_SESSION['disc1']);
		if($disc1=="")
			{

			}
			else
			{


		$this->SetFont('Arial','B',10);
		$this->Cell(10,5,'',0,0,'L');
		$this->Ln();
		$this->SetFont('Arial','',10);
		$this->MultiCell(0,5,"$disc1");
		$this->SetLineWidth(.3);
        $this->Ln();
			}




    //}
    // Closing line

}

function ImprovedTable22()
{



	//$cmpperson = "";

    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];


		$disc2=strip_tags($_SESSION['disc2']);
		if($disc2=="")
			{

			}
			else
			{


		$this->SetFont('Arial','',10);
		$this->MultiCell(0,5,"$disc2");
		$this->SetLineWidth(.3);

			}




    //}
    // Closing line

}

function ImprovedTable($header, $data)
{
	include "../connect.php";


	// Column widths

    $w = array(15,20,40,20,15,20,20,20,20);
	/*
	  for($i=0;$i<count($header);$i++)
        $this->Cell($w[$i],7,$header[$i],1,0,'C');
    $this->Ln();
	*/
    // Header

		if($_SESSION['tdiscamt']>0)
		{
		$this->SetWidths(array(10,18,88,10,15,15,12,22));
		$this->SetAligns(array('C','C','C','C','C','C','C','C'));
		//$this->SetFillColor(128, 0, 0);
		$this->SetFont('Arial','B',10);
		$this->Row(array('SR. No.','HSN CODE ','PRODUCT DISCRIPTION','GST (%)','PRICE','QTY','DISC (%)','AMOUNT'));
		$this->SetFont('Arial','',10);

		$this->SetWidths(array(10,18,88,10,15,15,12,22));
		$this->SetAligns(array('C','L','L','R','R','R','R','R'));
		}
		else{
		$this->SetWidths(array(10,18,100,10,15,15,22));
		$this->SetAligns(array('C','C','C','C','C','C','C'));
		//$this->SetFillColor(128, 0, 0);
		$this->SetFont('Arial','B',10);
		$this->Row(array('SR. No.','HSN CODE ','PRODUCT DISCRIPTION','GST (%)','PRICE','QTY','AMOUNT'));
		$this->SetFont('Arial','',10);

		$this->SetWidths(array(10,18,100,10,15,15,22));
		$this->SetAligns(array('C','L','L','R','R','R','R'));
		}

	$prefinalamount=0;


	include "../connect.php";
		$ccount="0";
		$subtotal="0";
		$extra1charges="0";
		$extra2charges="0";
		$extra3charges="0";
		$taxtotal="0";
		$grandtotal="0";

		$eve3= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re3 = mysqli_query($conn, $eve3);
		while($rt3 = mysqli_fetch_assoc($re3))
		{

			$_SESSION['extra1charges']=$rt3['extra1charges'];
			$_SESSION['extra2charges']=$rt3['extra2charges'];
			$_SESSION['extra3charges']=$rt3['extra3charges'];
			$_SESSION['qterms']=$rt3['qterms'];
			$_SESSION['qterms2']=$rt3['qterms2'];
			$_SESSION['qterms2yesno']=$rt3['qterms2yesno'];

			/*$_SESSION['extra1']=$rt3['extra1'];
			$_SESSION['extra2']=$rt3['extra2'];
			$_SESSION['extra3']=$rt3['extra3'];*/

		}

		//$tclass = new array();

		$eve2 = "select * from res_invoice_detail where imid=".$_GET['imid'];
		$re2 = mysqli_query($conn, $eve2);
		while($rt2 = mysqli_fetch_assoc($re2))
		{
			$ccount++;
			$pid=$rt2['pid'];

			$pprice=$rt2['pprice'];
			$pqty=$rt2['pqty'];
			$pdesc=$rt2['pdesc'];
			$totalamount=$rt2['amount'];
			$discper=$rt2['pdiscper'];

			$hsncode=$rt2['hsncode'];
			$tcamt1=$rt2['tcamt1'];
			$tcamt2=$rt2['tcamt2'];
			$amount=$rt2['amount'];
			$gst=$rt2['tcper1']+$rt2['tcper1'];
			if($gst>0)
			{
				if (empty($tclass["$gst"]))
				{
					$tclass["$gst"]=0;
					$evetaxclass = "select tcper from res_taxclass_master";
					$retaxclass = mysqli_query($conn, $evetaxclass);
					while($rttaxclass = mysqli_fetch_assoc($retaxclass))
					{
						if($gst==$rttaxclass['tcper'])
						{
							$tclass["$gst"]=$tclass["$gst"]+($tcamt1+$tcamt2);
						}

					}
				}
				else
				{
					$tclass["$gst"]=$tclass["$gst"]+($tcamt1+$tcamt2);
				}
			}
		$_SESSION['amount']=$amount;
		$_SESSION['tcper1']=$rt2['tcper1'];
		$_SESSION['tcper2']=$rt2['tcper2'];
		$_SESSION['tcamt1'] = $tcamt1;
		$_SESSION['tcamt2'] = $tcamt2;
		$_SESSION['totalamount'] = $totalamount;

			$eve3 = "select * from res_product_master where pid=$pid";
			$re3 = mysqli_query($conn, $eve3);
			while($rt3 = mysqli_fetch_assoc($re3))
			{
				$pname=$rt3['pname'];

				$umid=$rt3['umid'];
				//$dweek=$rt3['delweek'];
			$subtotal = $subtotal + $totalamount;

			if(strlen($pdesc)>0)
			{
				$pname=$pname."\n".$pdesc;
			}

	//for($i=0;$i<=$n-1;$i++)
	//{
		//$p=$this->SetFont('Arial','B',10).$pname;

		if($_SESSION['tdiscamt']>0)
		{
		$this->Row(array($ccount,$hsncode,$pname,$gst,$pprice,$pqty." ".$umid,$discper,$totalamount));
		}
		else{
		$this->Row(array($ccount,$hsncode,$pname,$gst,$pprice,$pqty." ".$umid,$totalamount));
			}
		//$this->Row(array("",$pdescription,$umid,"","","(".$_SESSION['tcper1']."%)","(".$_SESSION['tcper2']."%)",""));

		//$this->Cell($pdf2->Output());

		// $this->Cell($a);
		/*
		$this->Cell($w[0],6,$i+1,'LR');
		$this->Cell($w[1],6,$pname[$i],'L',0,'L');
		$this->Cell($w[2],6,number_format($pprice[$i]),'LR',0,'R');
		$this->Cell($w[3],6,number_format($pprice[$i]),'LR',0,'R');
		$this->Cell($w[4],6,number_format($pqty[$i]),'LR',0,'R');
		$this->Cell($w[5],6,number_format($pamount[$i]),'LR',0,'R');
		$this->Ln();
		*/
	//}

		}
		}
		$tgst=0;
		foreach($tclass as $key => $value) {
			$tgst=$tgst+$value;
		}
		$_SESSION['tclass'] = $tclass;
		$_SESSION['subtotal'] = $subtotal;

		$_SESSION['grandtotal'] = $_SESSION['subtotal'] + $_SESSION['extra1charges'] + $_SESSION['extra2charges'] + $_SESSION['extra3charges']+$tgst ;

	//$pdf2->Output('F','table.pdf');


	//for($i=0;$i<=$n;$i++)
	//{

		//for($i=0;$i<20;$i++)
		//$pdf2->Row(array($i+1,$pname[$i],number_format($pprice[$i]),number_format($pprice[$i]),number_format($pqty[$i]),number_format($pamount[$i])));

		//$this->Cell($pdf2->Output());

		// $this->Cell($a);
		/*
		$this->Cell($w[0],6,$i+1,'LR');
		$this->Cell($w[1],6,$pname[$i],'L',0,'L');
		$this->Cell($w[2],6,number_format($pprice[$i]),'LR',0,'R');
		$this->Cell($w[3],6,number_format($pprice[$i]),'LR',0,'R');
		$this->Cell($w[4],6,number_format($pqty[$i]),'LR',0,'R');
		$this->Cell($w[5],6,number_format($pamount[$i]),'LR',0,'R');
		$this->Ln();
		*/
	//}








	/*
    foreach($data as $row)
    {
        $this->Cell($w[0],6,$row[0],'LR');
        $this->Cell($w[1],6,number_format($row[2]),'LR',0,'R');
        $this->Cell($w[2],6,number_format($row[3]),'LR',0,'R');
        $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R');
        $this->Cell($w[4],6,number_format($row[3]),'LR',0,'R');
        $this->Cell($w[5],6,number_format($row[3]),'LR',0,'R');
        $this->Ln();
    }
	*/
//	$this->Ln(0);
    // Closing line
    $this->Cell(array_sum($w),0,'','T');
	$this->Ln();
}
function ImprovedTable2()
{
	include "../connect.php";

	$eve_settings ="select * from res_settings_master";
	$re_settings = mysqli_query($conn, $eve_settings);
	while($rt_settings = mysqli_fetch_assoc($re_settings))
	{
		$cmpdetail1=$rt_settings['cmpdetail1'];
		$cmpdetail2=$rt_settings['cmpdetail2'];
		$cmpdetail3=$rt_settings['cmpdetail3'];
		$cmpdetail4=$rt_settings['cmpdetail4'];
		$_SESSION['cmpdetail5']=$rt_settings['cmpdetail5'];
		$cmpdetail6=$rt_settings['cmpdetail6'];
		$cmpdetail7=$rt_settings['cmpdetail7'];

	}

	$qrefno = $_SESSION['qrefno'];
	$vatno = $_SESSION['vatno'];
	$quodate = $_SESSION['qdate'];
	$customercmpname  = $_SESSION['cname'];
	$cmpname = $_SESSION['cmpname'];
	$customeremail  = $_SESSION['email'];
	$customerid = $_SESSION['qno'];
	$city = $_SESSION['city'];
	$state = $_SESSION['state'];
	$address = $_SESSION['address'].' '.$city.'-'.$state;
	$mobile = $_SESSION['mobile'];
	$customercontactpersonname = $_SESSION['cname'];


	$qdate=$_SESSION['qdate'];
	$ino=$_SESSION['ino'];
	//$cmpperson = "";

	if (preg_match('/^.{1,50}\b/s', $address, $match))
	{
		$line1=$match[0];
	}

	$tt = strlen($line1);

	$linesub = substr($address,$tt);
	$line2="";
	if (preg_match('/^.{1,50}\b/s', $linesub, $match2))
	{
		$line2=$match2[0];
	}


	$line3="";
	$line3 = substr($address,strlen($line1)+strlen($line2),50);








    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];

		$this->SetFont('Arial','B',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"$cmpname",'LRT');
		$this->SetFont('Arial','B',10);
		$this->Cell($w[1],6,"Invoice Number: $ino      Date: $qdate",'LRT');

        $this->Ln();
		$this->SetFont('Arial','',10);
        $this->Cell($w[0],6,"$line1",'LR');
		$this->SetFont('Arial','B',10);
		$this->Cell($w[1],6,"Reference Number: $qrefno",'LR');
		$this->SetFont('Arial','',10);
		$this->Ln();
		$this->Cell($w[0],6,"$line2",'LR');
		$this->Cell($w[1],6,"$cmpdetail1",'LR');
		$this->Ln();
        $this->Cell($w[0],6,"GSTN: $vatno",'LR');
		$this->Cell($w[1],6,"$cmpdetail2",'LR');
		$this->Ln(6);


    //}
    // Closing line
    $this->Cell(array_sum($w),0,'','T');
	$this->Ln();
}
function ImprovedTable2_1()
{ $w = array(138,30,22);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		$amount = $_SESSION['subtotal'];
		$cmpdetail5=$_SESSION['cmpdetail5'];
		setlocale(LC_MONETARY, 'en_IN');
		//$pckamt = money_format('%!i', $amount);
		$pckamt = $amount;
		//$amountinwords =  convert_number_to_words( (int)$amount);

		//$pckamt= number_format("$amount",2);

		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"$cmpdetail5",'L');
		$this->Cell($w[1],6,"Sub-Total",'LRTB',0,'R');
		$this->Cell($w[2],6,"$pckamt",'LRTB',0,'R');


        $this->Ln();

    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');

}
function ImprovedTable3()
{ $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		$amount1 = $_SESSION['amount'];

		//$amountinwords =  convert_number_to_words( (int)$amount);
		$amt= number_format("$amount1",2);


		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'LTB');
		$this->Cell($w[1],6,"Extra Service Amount : $amt/-",'RTB',0,'R');


        $this->Ln();

    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');

}
function ImprovedTable3_1()
{ $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$amountinwords =  convert_number_to_words( (int)$amount);
		//gst28
		$gst28 = $_SESSION['gst28'];

		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'LTB');
		$this->Cell($w[1],6,"Tax Amount : $gst28/-",'RTB',0,'R');


        $this->Ln();

    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');

}
function ImprovedTable3_2()
{ $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		$td=$_SESSION['tax1amt'];

		$tax = $_SESSION['taxtotal'];
		//$amountinwords =  convert_number_to_words( (int)$amount);
		$taxes= number_format("$tax",2);


		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"Amount In Words",'LTB');
		$this->Cell($w[1],6,"Tax Amount($td%) : Rs. $taxes/-",'RTB',0,'R');


        $this->Ln();

    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');

}

function ImprovedTable3_2_1_1()
{ $w = array(138,30,22);

	include "../connect.php";
	$eve_display= "select * from res_settings_master";
	$re_display = mysqli_query($conn, $eve_display);
	while($rt_display = mysqli_fetch_assoc($re_display))
	{
		$_SESSION['cmpstate']=$rt_display['cmpstate'];
	}

	// Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{





		if($_SESSION['state']==$_SESSION['cmpstate'])
		{
			$tclass1=$_SESSION['tclass'];
			foreach($tclass1 as $key => $value) {
				$key2=$key/2;
				$value1=$value/2;
				$this->SetFont('Arial','',10);
				$this->SetLineWidth(.3);
				$this->Cell($w[0],6,"",'L');
				$value2= number_format($value1,2);
				$this->Cell($w[1],6,"CGST $key2%",'LRTB',0,'R');
				$this->Cell($w[2],6,"$value2",'LRTB',0,'R');
				$this->Ln();
				$this->SetFont('Arial','',10);
				$this->SetLineWidth(.3);
				$this->Cell($w[0],6,"",'L');
				$this->Cell($w[1],6,"SGST $key2%",'LRTB',0,'R');
				$this->Cell($w[2],6,"$value2",'LRTB',0,'R');
				$this->Ln();


			}

		}
		else
		{
			$tclass1=$_SESSION['tclass'];
			foreach($tclass1 as $key => $value) {
			$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'L');

			$value1= number_format($value,2);
				$this->Cell($w[1],6,"IGST $key%",'LRTB',0,'R');
				$this->Cell($w[2],6,"$value1",'LRTB',0,'R');
				        $this->Ln();

			}

		}


    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}


function ImprovedTable3_2_3()
{ $w = array(138,30,22);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		include "../connect.php";
		$eve3= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re3 = mysqli_query($conn, $eve3);
		while($rt3 = mysqli_fetch_assoc($re3))
		{
			$extra1=$rt3['extra1'];
			$extra1charges=$rt3['extra1charges'];


			if($extra1charges==0)
			{

			}
			else
			{



		$tax = $extra1charges;

		$taxes1= number_format("$tax",2);



		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'LR');
		$this->Cell($w[1],6,"$extra1",'LRTB',0,'R');
		$this->Cell($w[2],6,"$taxes1",'LRTB',0,'R');


        $this->Ln();
			}
		}
    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}

function ImprovedTable3_2_32()
{ $w = array(138,30,22);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		include "../connect.php";
		$eve32= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re32 = mysqli_query($conn, $eve32);
		while($rt32 = mysqli_fetch_assoc($re32))
		{
			$extra2=$rt32['extra2'];
			$extra2charges=$rt32['extra2charges'];


			if($extra2charges==0)
			{

			}
			else
			{



		$tax2 = $extra2charges;

		$taxes2= number_format("$tax2",2);



		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'LR');
		$this->Cell($w[1],6,"$extra2",'LRTB',0,'R');
		$this->Cell($w[2],6,"$taxes2",'LRTB',0,'R');


        $this->Ln();
			}
		}
    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}

function ImprovedTable3_2_33()
{ $w = array(138,30,22);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		include "../connect.php";
		$eve33= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re33 = mysqli_query($conn, $eve33);
		while($rt33 = mysqli_fetch_assoc($re33))
		{
			$extra3=$rt33['extra3'];
			$extra3charges=$rt33['extra3charges'];


			if($extra3charges==0)
			{

			}
			else
			{



		$tax3 = $extra3charges;

		$taxes3= number_format("$tax3",2);



		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'LR');
		$this->Cell($w[1],6,"$extra3",'LRTB',0,'R');
		$this->Cell($w[2],6,"$taxes3",'LRTB',0,'R');


        $this->Ln();
			}
		}
    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}


function ImprovedTable3_2_4()
{ $w = array(140,30,20);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		include "../connect.php";
		$eve3= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re3 = mysqli_query($conn, $eve3);
		while($rt3 = mysqli_fetch_assoc($re3))
		{
			$extra2=$rt3['extra2'];
			$extra2charges=$rt3['extra2charges'];


			if($extra2charges==0)
			{

			}
			else
			{



		$tax = $extra2charges;

		$taxes1= number_format("$tax",2);



		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'');
		$this->Cell($w[1],6,"$extra2",'LRTB',0,'R');
		$this->Cell($w[1],6,"$taxes1",'LRTB',0,'R');


        $this->Ln();
			}
		}
    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}

function ImprovedTable3_2_5()
{ $w = array(140,30,20);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		include "../connect.php";
		$eve3= "select * from res_invoice_master where imid=".$_GET['imid'];
		$re3 = mysqli_query($conn, $eve3);
		while($rt3 = mysqli_fetch_assoc($re3))
		{
			$extra3=$rt3['extra3'];
			$extra3charges=$rt3['extra3charges'];


			if($extra3charges==0)
			{

			}
			else
			{



		$tax = $extra3charges;

		$taxes1= number_format("$tax",2);



		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"",'');
		$this->Cell($w[1],6,"$extra3",'LRTB',0,'R');
		$this->Cell($w[1],6,"$taxes1",'LRTB',0,'R');


        $this->Ln();
			}
		}
    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
}


function ImprovedTable3_3()
{ $w = array(138,30,22);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		$grandtotal= $_SESSION['grandtotal'];
		$grandtotal1= (int)$_SESSION['grandtotal'];
		$ta=$grandtotal - $grandtotal1;
		$ta=$ta*10;
		if($ta<10)
		{
			$ta=$ta*10;
		}
		$ta1=round($ta);

		if($ta1>0)
		{
			$ta2="Paisa";
		}
		setlocale(LC_MONETARY, 'en_IN');
//		$gt1 = money_format('%!i', $grandtotal);
		$gt1 = $grandtotal;
		//$gt1= number_format("$grandtotal",2);
		$amountinwords =  convert_number_to_words($grandtotal);
		//$amountinwords1 =  convert_number_to_words($ta1);

		$this->SetFont('Arial','',9);
		$this->SetLineWidth(.3);
        //$this->Cell($w[0],6,"Amount in Words:",'');





		$this->SetFont('Arial','B',10);
		$this->Cell($w[0],6,"",'LRB',0,'R');
		$this->Cell($w[1],6,"Total Amount",'LRTB',0,'R');
		$this->Cell($w[2],6,"$gt1",'LRTB',0,'R');
		$this->SetFont('Arial','',10);
		$this->Ln();
		 $w = array(190,0);

			$this->SetFont('Arial','B',10);
		$this->SetLineWidth(.3);
        $this->Cell($w[0],6,"Amount In Words",'LRT');
		 $this->Ln();
		$this->SetFont('Arial','',10);
		$this->Cell($w[0],4,"$amountinwords",'LRB');

        $this->Ln();

        $this->Ln();


    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
	$this->Ln();
}

function ImprovedTable4()
{
	/*$this->SetFont('Arial','B',15);
	$this->Cell(190,5,'Customer Information',0,0,'C');
    $this->Ln(10);*/

}
function ImprovedTable4_1()
{
	/*$w = array(95,95);
    	$customername1  = "Pratik";
		$customeremail1  = "pratikpatel3277@gmil.com";
		$address1 = "Vadodara";
		$mobile1 = "9898036028";
		$customerid1 = "1";
		$quodate1 = "11-08-2017";




		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);

        $this->Cell($w[0],6,"Name : $customername1",'LRT');
		$this->Cell($w[1],6,"Quotation Number : # ORA/$customerid1 ",'LRT');
		$this->Ln();
        $this->Cell($w[0],6,"Address : $address1",'LRT');
		$this->Cell($w[1],6,"Date : $quodate1",'LRT');
		$this->Ln();
        $this->Cell($w[0],6,"Email : $customeremail1",'LRT');
		$this->Cell($w[1],6,"GSTIN : 24ANBPT9438K2ZG",'LRT');
		$this->Ln();
        $this->Cell($w[0],6,"Mobile : $mobile1",'LRT');
		$this->Cell($w[1],6,"",'LRT');
		$this->Ln(6);

    $this->Cell(array_sum($w),0,'','T');
	$this->Ln(10);*/
}
function ImprovedTable4_2()
{
	$qdate=$_SESSION['qdate'];
	$qno=$_SESSION['qno'];

	$this->SetFont('Arial','B',15);
	$this->Cell(190,5,"Invoice",0,0,'C');
    $this->Ln(6);

}

function ImprovedTable2_9()
{



	//$cmpperson = "";

    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];


		$qterms=$_SESSION['qterms'];
		if($qterms=="")
			{

			}
			else
			{


		$this->SetFont('Arial','B',10);
		$this->Cell(10,5,'Terms & Conditions',0,0,'L');
		$this->Ln();
		$this->SetFont('Arial','',10);
		$this->MultiCell(0,5,"$qterms");
		$this->SetLineWidth(.3);
        $this->Ln();
			}




    //}
    // Closing line

}

function ImprovedTable2_9_1()
{



	//$cmpperson = "";

    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];


		$qterms2=$_SESSION['qterms2'];
		$qterms2yesno=$_SESSION['qterms2yesno'];
		if($qterms2yesno=="0")
		{

		}
		else
		{


		$this->SetFont('Arial','B',10);
		$this->Cell(10,5,'NOTE',0,0,'L');
		$this->Ln();
		$this->SetFont('Arial','',10);
		$this->MultiCell(0,5,"$qterms2");
		$this->SetLineWidth(.3);
        $this->Ln();
			}




    //}
    // Closing line

}

function ImprovedTable2_10()
{



	//$cmpperson = "";

    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{

		//$quono = $_SESSION['sid2'];


		$createdby=$_SESSION['createdby'];


		$this->SetFont('Arial','B',10);
		$this->Cell(190,5,'For: Link Arise',0,0,'L');
		$this->Ln();
		$this->SetFont('Arial','',10);
		$this->Cell(190,5,"$createdby",0,0,'L');
		$this->SetLineWidth(.3);






    //}
    // Closing line

}


function ImprovedTable4_3()
{
	$w = array(95,95);

		$n3 = $_SESSION['n3'];

		$qdatetime1 = $_SESSION['qdatetime'];
		$qremarks1 = $_SESSION['qremarks'];
		$qlocation1 = $_SESSION['qlocation'];


		$this->SetFont('Arial','',10);
		$this->SetLineWidth(.3);

		for($i=0;$i<=$n3-1;$i++)
		{
			//$this->Row($qdatetime1[$i],$qremarks1[$i],$qlocation1[$i]);

		$this->Cell($w[0],6,"Event Date ",'LRT');
		$this->Cell($w[1],6,"$qdatetime1[$i]",'LRT');
		$this->Ln();
		$this->Cell($w[0],6,"Event ",'LRT');
		$this->Cell($w[1],6,"$qremarks1[$i]",'LRT');
		$this->Ln();
		$this->Cell($w[0],6,"Location ",'LRT');
		$this->Cell($w[1],6,"$qlocation1[$i]",'LRT');
		$this->Ln(6);

		$this->Cell(array_sum($w),0,'','T');
		$this->Ln(5);
		}
   // $this->Cell(array_sum($w),0,'','T');
	$this->Ln(150);

}



/*function ImprovedTable4()
{ $w = array(190);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)
    //{
		$this->SetFont('Arial','I',10);
		 $this->SetLineWidth(.3);
        $this->Cell($w[0],6,"Terms & Conditions:",'LRT');
		 $this->Ln();

		//$tnc_all = $_SESSION['tnc'];

		$j=1;
		$t1="";
		$t2="";
		$t3="";
		$t4="";


		if( isset($tnc_all) )
		{
			foreach ($tnc_all as $one_by_one_sid)
			{
				//$tnc_all=$tnc_all."<br>".$one_by_one_sid;

				if($j==1)
				{
					$t1 = $one_by_one_sid;
				}
				else if($j==2)
				{
					$t2 = $one_by_one_sid;
				}
				else if($j==3)
				{
					$t3 = $one_by_one_sid;
				}
				else if($j==4)
				{
					$t4 = $one_by_one_sid;
				}
				$j++;
				//echo "$this->Cell($w[0],6,\"".$one_by_one_sid."\",'LR')";
				//echo "$this->Ln();";
			}
		}



        $this->Cell($w[0],6,"$t1",'LR');
		$this->Ln();
        $this->Cell($w[0],6,"$t2",'LR');
		$this->Ln();
        $this->Cell($w[0],6,"$t3",'LR');
		$this->Ln();
        $this->Cell($w[0],6,"$t4",'LRB');


        $this->Ln(5);

    //}
    // Closing line
   // $this->Cell(array_sum($w),0,'','T');
	$this->Ln();
}*/
function ImprovedTable5()
{
    // Column widths
    $w = array(95,95);
    // Header
    //for($i=0;$i<count($header);$i++)
    //    $this->Cell($w[$i],7,$header[$i],1,0,'C');
    //$this->Ln();
    // Data
    //foreach($data as $row)

	//{

		$sign1 = "http://oratask.com/qm1/sign/".$_SESSION['sign'];

		$this->SetFont('Arial','',10);
		 $this->SetLineWidth(.3);
        $this->Cell($w[0],6,"We hope that above will be in line with ",'LRT');
		$this->Cell($w[1],6,"For Company 1 - JP Infoweb Solutions Pvt. Ltd.",'LRT');

        $this->Ln();
        $this->Cell($w[0],6,"yourrequirement, we are waiting",'LR');
		$this->Image("$sign1",120,230,50,10);
		$this->Ln();
        $this->Cell($w[0],6,"for your positive reply.",'LR');
		$this->Cell($w[1],6,"(Authorised Signatory)",'LR');

        $this->Ln(5);

    //}
    // Closing line
    $this->Cell(array_sum($w),0,'','T');
	$this->Ln();
}
}


function convert_number_to_words($myno,$part2=1)
{
   $number = $myno;
   $no = (int)($number);
   $point = round($number - $no, 2) * 100;
   $hundred = null;
   $digits_1 = strlen($no);
   $i = 0;
   $str = array();
   $words = array('0' => '',
   '1' => 'One',
   '2' => 'Two',
    '3' => 'Three',
	'4' => 'Four',
	'5' => 'Five',
	'6' => 'Six',
    '7' => 'Seven',
	'8' => 'Eight',
	'9' => 'Nine',
    '10' => 'Ten',
	'11' => 'Eleven',
	'12' => 'Twelve',
    '13' => 'Thirteen',
	'14' => 'Fourteen',
    '15' => 'Fifteen',
	'16' => 'Sixteen',
	'17' => 'Seventeen',
    '18' => 'Eighteen',
	'19' =>'Nineteen',
	'20' => 'Twenty',
    '30' => 'Thirty',
	'40' => 'Forty',
	'50' => 'Fifty',
    '60' => 'Sixty',
	'70' => 'Seventy',
    '80' => 'Eighty',
	'90' => 'Ninety');
   $digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
   while ($i < $digits_1) {
     $divider = ($i == 2) ? 10 : 100;
     $number = floor($no % $divider);
     $no = floor($no / $divider);
     $i += ($divider == 10) ? 1 : 2;
     if ($number) {
        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
        $str [] = ($number < 21) ? $words[$number] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number / 10) * 10]
            . " " . $words[$number % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str[] = null;
  }
  $str = array_reverse($str);
  $result = implode('', $str);
  $points = ($point) ?
    "." . $words[$point / 10] . " " .
          $words[$point = $point % 10] : '';


	$tnumber = $myno;

	$whole = floor($tnumber);
	$fraction = ($tnumber - $whole)*100;

	if($fraction>0.00)
	{
		$pointvalue = convert_number_to_words( (int)$fraction,-7);

		return $result . "Rupees and ".$pointvalue."Paisa Only.";
	}
	else if($part2==-7)
	{
		return $result;
	}
	else
	{
		return $result."Rupees Only.";

	}
}

function convert_number_to_words2($number) {

    $hyphen      = '-';
    $conjunction = ' and ';
    $separator   = ' ';
    $negative    = 'negative ';
    $decimal     = ' and ';
    $dictionary  = array(
        0                   => 'Zero',
        1                   => 'One',
        2                   => 'Two',
        3                   => 'Three',
        4                   => 'Four',
        5                   => 'Five',
        6                   => 'Six',
        7                   => 'Seven',
        8                   => 'Eight',
        9                   => 'Nine',
        10                  => 'Ten',
        11                  => 'Eleven',
        12                  => 'Twelve',
        13                  => 'Thirteen',
        14                  => 'Fourteen',
        15                  => 'Fifteen',
        16                  => 'Sixteen',
        17                  => 'Seventeen',
        18                  => 'Eighteen',
        19                  => 'Nineteen',
        20                  => 'Twenty',
        30                  => 'Thirty',
        40                  => 'Fourty',
        50                  => 'Fifty',
        60                  => 'Sixty',
        70                  => 'Seventy',
        80                  => 'Eighty',
        90                  => 'Ninety',
        100                 => 'Hundred',
        1000                => 'Thousand',
        1000000             => 'Million',
        1000000000          => 'Billion',
        1000000000000       => 'Trillion',
        1000000000000000    => 'Quadrillion',
        1000000000000000000 => 'Quintillion'
    );

    if (!is_numeric($number)) {
        return false;
    }

    if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
        // overflow
        trigger_error(
            'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
            E_USER_WARNING
        );
        return false;
    }

    if ($number < 0) {
        return $negative . convert_number_to_words2(abs($number));
    }

    $string = $fraction = null;

    if (strpos($number, '.') !== false) {
        list($number, $fraction) = explode('.', $number);
    }

    switch (true) {
        case $number < 21:
            $string = $dictionary[$number];
            break;
        case $number < 100:
            $tens   = ((int) ($number / 10)) * 10;
            $units  = $number % 10;
            $string = $dictionary[$tens];
            if ($units) {
                $string .= $hyphen . $dictionary[$units];
            }
            break;
        case $number < 1000:
            $hundreds  = $number / 100;
            $remainder = $number % 100;
            $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
            if ($remainder) {
                $string .= $conjunction . convert_number_to_words2($remainder);
            }
            break;
        default:
            $baseUnit = pow(1000, floor(log($number, 1000)));
            $numBaseUnits = (int) ($number / $baseUnit);
            $remainder = $number % $baseUnit;
            $string = convert_number_to_words2($numBaseUnits) . ' ' . $dictionary[$baseUnit];
            if ($remainder) {
                $string .= $remainder < 100 ? $conjunction : $separator;
                $string .= convert_number_to_words2($remainder);
            }
            break;
    }

    if (null !== $fraction && is_numeric($fraction)) {
        $string .= $decimal;
        $words = array();
        foreach (str_split((string) $fraction) as $number) {
            $words[] = $dictionary[$number];
        }
        $string .= implode(' ', $words);
    }

    return $string;
}


// Instanciation of inherited class
$pdf = new PDF();
$header = array('Sr No.','Part No.','Discription','QTY', 'Unit Price ','HSN Code ','CGST','SGST','Amount' );
//$data = $pdf->LoadData('countries.txt');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->ImprovedTable4();
$pdf->ImprovedTable4_1();
$pdf->ImprovedTable4_2();
//$pdf->ImprovedTable4_3();
$pdf->ImprovedTable2();
$pdf->ImprovedTable11();
$pdf->ImprovedTable($header,"");



//require_once('../fpdf/fpdf.php');
/*
require_once('../fpdf/fpdi.php');
$pdf2 = new FPDI();
$pageCount = $pdf2->setSourceFile('./table.pdf');
$tplIdx = $pdf2->importPage(1, '/MediaBox');
$pdf2->addPage();
$pdf2->useTemplate($tplIdx, 10, 10, 200);
$pdf2->Output()->$pdf;
*/









$pdf->ImprovedTable2_1();
//$pdf->ImprovedTable2_9();
//$pdf->ImprovedTable3();
//$pdf->ImprovedTable3_1();
//$pdf->ImprovedTable3_2();
$pdf->ImprovedTable3_2_1_1();

$pdf->ImprovedTable3_2_3();
$pdf->ImprovedTable3_2_32();
$pdf->ImprovedTable3_2_33();
//$pdf->ImprovedTable3_2_4();
//$pdf->ImprovedTable3_2_5();
$pdf->ImprovedTable3_3();
$pdf->ImprovedTable2_9();
$pdf->ImprovedTable2_9_1();
$pdf->ImprovedTable22();
$pdf->ImprovedTable2_10();
//$pdf->ImprovedTable4();
//$pdf->ImprovedTable5();
$pdf->SetFont('Times','',12);
//$footer = "http://localhost/prewedding/allimage/".$_SESSION['cfooterimg'];

	//$pdf->Image("$footer",null,null,190);



//$pdf->Output();

$invno1 = $_SESSION['invno1'];
$imid2 = $_GET['imid'];
$pdf->Output('F',"../download/$invno1.pdf");

//return;

header("Location: ../invoicemasterstatus.php?id=$imid2");




?>
