Current File : /home/inlingua/www/icentex/admin_fd/invoice_pdf.php
<?php
error_reporting(0);
session_start();
// Include the database connection details
require('../dbConnection.php');

// Include common functions
require('../commonFunc.php');

// Include common functions
require('../globalVars.php');

// Include the table handler class
require('../dbHandler.class.php');
//require_once('amount.php');

include_once("wordsClass.php");
// Init and connect to database
$dbObject = new dbHandler();
$dbObject->connect();

?>
<?php
require_once('../../tcpdf/config/lang/eng.php');
require_once('../../tcpdf/tcpdf.php');


$query="select a.*,b.ref_No from ingl_invoice_main a left join ingl_admission b on a.student_id=b.recNo where a.recNo='".$_REQUEST['kV']."'";
$result=mysqli_query($conn,$query);
$num=mysqli_fetch_array($result);

$queryA="select * from timesheet_location where recNo='".$num['centre']."'";
$resultA=mysqli_query($conn,$queryA);
$numA=mysqli_fetch_array($resultA);


// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {

    //Page header
   /* public function Header() {
        // Logo
        $image_file = K_PATH_IMAGES.'logo_example.jpg';
        $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }
*/
    // Page footer
    public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-10);
        // Set font
        $this->SetFont('helvetica', 'I', 10);
        // Page number
        //$this->Line(0,12,80,12);
        $this->Cell(0, 10, 'Regd Office :A- 95, Sector - 65, Noida - 201305 (U.P.)', 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}


// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('pispltd');
$pdf->SetTitle('pispltd');
$pdf->SetSubject('pispltd');
$pdf->SetKeywords('pispltd soft');

// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(true);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins('10', '10', '5');

//set auto page breaks
//$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetAutoPageBreak(TRUE, -5);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------

// set font
$email="".$numA['email']."";





$pdf->SetFont('Helvetica', '', 10);


$content="";
$content.='
<table border="0" width="100%">
<tr><td width="100%" align="center" style="font-size:60px;"><u><b>Invoice</b></u></td></tr>
</table>';


$content.='<table width="100%" border="0"><tr><td height="20">&nbsp;</td></tr></table>';
$content.='<table border="0" style="padding:3px;boder:0px thin #000000;" width="100%"><tr valign="top">
<td width="15%">Invoice No.</td>
<td width="35%"><b>'.$num['invoice_no'].'</b></td><td width="50%" rowspan="4" align="center"><img src="../images/logo_certificate.JPG"><br>
<table width="100%" border="0" style="padding:1px;"><tr><td width="30%" align="right"><b>Branch Office :</b></td><td style="text-align:justify;" width="85%">'.nl2br($numA['address']).'</td></tr>
<tr><td align="right"><b>Contact:</b></td><td align="left">'.$numA['contact'].'</td></tr>';
if($email!="")
{
$content.='<tr><td align="right"><b>Email:</b></td><td align="left">'.$email.'</td></tr>';
}

$content.='</table></td></tr>
<tr valign="top"><td>Date</td><td><b>'.date("d-M-Y",strtotime($num['createDate'])).'</b></td></tr>
<tr valign="top"><td>To </td><td><b>'.$num['student_name'].'</b>
</td>

</tr>

<tr valign="top"><td>Address</td><td rowspan="2" style="height:30px;"><b>'.nl2br($num['student_address']).'</b></td>

</tr>

';

$content.='<tr><td colspan="4">';


$content.='<table width="100%" border="1" style="padding:1px;">
<tr><td width="6%" style="background-color:#ffffff;"><b>S.No.</b></td>
<td width="53%" style="background-color:#ffffff;"><b>DESCRIPTION</b></td>
<td width="12%" style="background-color:#ffffff;" align="right"><b>Quantity</b></td>
<td width="13%" style="background-color:#ffffff;" align="right"><b>Rate</b></td>
<td width="15%" style="background-color:#ffffff;" align="right"><b>Amount</b></td></tr>
';

$queryI="select * from ingl_invoice_detail where main_id='".$_REQUEST['kV']."'";
$resultI=mysqli_query($conn,$queryI);
$countI=mysqli_num_rows($resultI);

$i=1;
$height=370;
$tot_qty=0;
$sub_roll=array();
while($numI=mysqli_fetch_array($resultI))
{
    
//$remarks="<br>".$numI['remarks']."";
             $subprodcat_array=array();
				$subprodcat= new dbHandler();
                $subprodcat->connect();
                $query_subprodcat="select recNo,bill_details from ingl_billing_main where recNo='".$numI['product_id']."'";
	            $result_subprodcat=$subprodcat->select($query_subprodcat);
				
				$data_subprodcat=$subprodcat->SelectNext($result_subprodcat);
              		  
$height1=40;
$content.='<tr><td style="padding:3px;border-right:1px thick #000000;height:'.$height1.'px;"><b>'.$i.'</b></td>
<td style="padding:3px;border-left:1px thin #000000;"><b>'.nl2br($data_subprodcat['bill_details']).'</b>';

if($numI['remarks']!="")
{
$content.='<br>'.nl2br($numI['remarks']).'';
}
$content.='</td>';
$content.='<td style="padding:3px;border-left:1px thin #000000;" align="right"><b>'.nl2br($numI['quantity']).'</b></td>';
$content.='<td style="padding:3px;border-left:1px thin #000000;" align="right"><b>'.$numI['rates'].'</b></td>';

$content.='<td style="padding:3px;border-left:1px thin #000000;height:'.$height1.'px;" align="right"><b>'.number_format($numI['amount'],2,'.',',').'</b></td></tr>';
$i++;

$tot_qty=$tot_qty+$numI['qty'];
$ht=$ht+$height1;

}
$height2=$height-$ht;
$content.='<tr><td style="border-right:1px thick #000000;border-bottom:1px thick #000000;height:'.$height2.'px;">&nbsp;</td>
<td style="border-left:1px thin #000000;height:'.$height2.'px;">&nbsp;</td>
<td style="border-left:1px thin #000000;height:'.$height2.'px;">&nbsp;</td>
<td style="border-left:1px thin #000000;height:'.$height2.'px;">&nbsp;</td>
<td style="border-left:1px thin #000000;height:'.$height2.'px;">&nbsp;</td></tr>';
 

$content.='<tr><td colspan="4" align="right" style="padding:3px;border-right:1px thick #000000;border-top:1px thick #000000;border-bottom:1px thick #000000;"><b>Sub-Total</b></td>

<td style="padding:3px;border-left:1px thin #000000;border-top:1px thin #000000;border-bottom:1px thin #000000;" align="right"><b>'.number_format($num['amount'],2,'.',',').'</b></td></tr>';

$content.='<tr><td colspan="4" align="right" style="padding:3px;border-right:1px thick #000000;border-top:1px thick #000000;border-bottom:1px thick #000000;">
<b>Tax</b></td>

<td style="padding:3px;border-left:1px thin #000000;border-top:1px thin #000000;border-bottom:1px thin #000000;" align="right">
<b>'.number_format($num['tax_value'],2,'.',',').'</b></td></tr>';


$content.='<tr><td colspan="4" align="right" style="padding:3px;border-right:1px thick #000000;border-top:1px thick #000000;border-bottom:1px thick #000000;">
<b>Discount '.$num['discount_per'].' %</b></td>

<td style="padding:3px;border-left:1px thin #000000;border-top:1px thin #000000;border-bottom:1px thin #000000;" align="right">
<b>'.number_format($num['discount_value'],2,'.',',').'</b></td></tr>';


$content.='<tr><td colspan="4" align="right" style="padding:3px;border-right:1px thick #000000;border-top:1px thick #000000;border-bottom:1px thick #000000;">
<b>Total</b></td>

<td style="padding:3px;border-left:1px thin #000000;border-top:1px thin #000000;border-bottom:1px thin #000000;" align="right">
<b>'.number_format($num['final_amount'],2,'.',',').'</b></td></tr>';

$obj = new intToWord();
   $valinput = $num['final_amount'];
   $text =  $obj->getAmountInWords($valinput);


$content.='<tr><td colspan="5" align="right" style="padding:3px;border-top:1px thick #000000;border-bottom:1px thick #000000;">
<b>Total Amount in Words:</b> '.$text.'</td>
</tr>';


$content.='</table>';

$content.='</td></tr>';



$content.='</table><br>';


$queryTerms="select * from ingl_terms_conditions";
$resultTerms=mysqli_query($conn,$queryTerms);
$k=1;
while($numTerms=mysqli_fetch_array($resultTerms))
{
    $terms_conditions.="".$k.". ".nl2br($numTerms['terms_conditions'])."<br>";
    $k++;
}


//$content.='<table border="0" width="100%"><tr><td valign="center" height="10"  align="center">&nbsp;</td></tr></table>';

$content.='<table border="0" width="100%" style="padding:1px;"><tr><td valign="center" colspan="2"><b>Terms and conditions :</b></td></tr>


<tr><td width="100%" style="text-align:justify;">'.$terms_conditions.'</td>
</tr>

</table>';

$content.='<table border="0" width="100%" style="padding:1px;">


<tr><td width="70%" style="text-align:justify;">&nbsp;</td>
<td width="30%">


<table border="0" width="100%"><tr><td width="100%"  valign="center"><table width="100%" border="1"><tr><td height="50"><br></td></tr></table></td></tr>

<tr><td width="100%"  align="center"><b>(for inlingua new delhi.)</b></td></tr>
</table></td>
</tr>

</table>';
/*
$content.='<table><tr><td height="20"></td></tr></table>
<table border="0" width="100%">

<tr><td width="100%" align="center" style="font-size:30px;"><u><b>Regd Office :</b>A- 95, Sector - 65, Noida - 201305 (U.P.)</u></td></tr>
</table>';
*/
// add a page
$pdf->AddPage();


// set some text to print
$html = <<<EOD
 $content
EOD;
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

/*$pdf->AddPage();


$content1="";
$content1.="<table width='100%'><tr><td width='100%' align='center'>Details Of Rolls</td></tr></table>";
$content1.="<table width='100%'>";
$content1.="<tr><td>Roll Id</td><td>Product</td><td>Quantity</td></tr>";
foreach($sub_roll as $key=>$val)
{
    $queryRollDetails="select * from jumbo_roll_sub where recNo='".$val."'";
    $resultRollDetails=mysqli_query($conn,$queryRollDetails);
    $numRollDetails=mysqli_fetch_array($resultRollDetails);
    
$content1.="<tr><td>".$numRollDetails['jrNo']."</td><td>&nbsp;</td><td>".$numRollDetails['quantity']."</td></tr>";    
    
}

$content1.="</table>";

//$pdf->SetMargins('10', '10', '10');

// set some text to print
$html = <<<EOD
 $content1
EOD;
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
*/
$pdf->Output('pispltd_'.$num['po_id'].'.pdf', 'I');

?>