Current File : /home/inlingua/public_html/faridabad/icentex/conveyance/conveyance_report.php |
<?php
ob_start();
error_reporting(1);
session_start();
//include("check_conveyance.php");
date_default_timezone_set('Asia/Calcutta');
ini_set('max_execution_time', 0);
/*
$loggedUserNo = $_SESSION['loggedUserNo'];
if ($loggedUserNo == "")
{ echo "Please <a href='index.php'>login</a> first.";
exit(0);
}
*/
// 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');
$dbObject = new dbHandler();
$dbObject->connect();
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');
$lastid=$_REQUEST['lastid'];
$query="select a.*,b.name from ingl_conveyance_main a left join timesheet_user b on a.instructor=b.recNo where a.recNo='".$lastid."'";
$result=mysqli_query($conn,$query);
$numC=mysqli_fetch_array($result);
// create new PDF document
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Inlingua');
$pdf->SetTitle('Inlingua');
$pdf->SetSubject('Inlingua');
$pdf->SetKeywords('Inlingua Certificates');
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins('10', '10', '10');
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
if($numC['month']<=9)
{
$numC['month']="0".$numC['month']."";
}
$month=date("F",strtotime("".$numC['year']."-".$numC['month']."-01"));
$content.='
<table border="0" width="100%">
<tr><td width="15%"><img src="../images/logo_certificate.JPG"></td><td width="85%" align="center" style="font-size:80px;"><b>inlingua New Delhi Conveyance Sheet</b></td></tr>
</table>
<br>
<table border="0" width="100%">
<tr><td width="12%">Name</td><td width="88%">'.$numC['name'].'</td></tr>
<tr><td>Month</td><td>'.$month.'</td></tr>
<tr><td>Year</td><td>'.$numC['year'].'</td></tr>
<tr ><td>Total Amount</td><td>'.number_format($numC['totalAmount'],2,".","").'</td></tr>
<tr><td></td><td></td></tr>
<tr><td colspan="2" width="100%">
<table width="100%" border="1" style="padding:2px;font-size:30px;">
<tr style="background-color:#cccccc;">
<td width="9%" align="center">Date </td>
<td width="6%" align="center">Start </td>
<td width="10%" align="center">Center1 </td>
<td width="4%" align="right">Km1 </td>
<td width="10%" align="center">Center2 </td>
<td width="4%" align="right">Km2 </td>
<td width="8%" align="center">Center3 </td>
<td width="4%" align="right">Km3 </td>
<td width="8%" align="center">Center4 </td>
<td width="4%" align="right">Km4 </td>
<td width="6%" align="center">End </td>
<td width="4%" align="right">Km5 </td>
<td width="4%" align="right">Kms </td>
<td width="4%" align="center">Band </td>
<td width="5%" align="right">Total </td>
<td width="10%">Remarks </td>
</tr>';
$queryService="select * from ingl_conveyance where basic_recNo='".$numC['recNo']."' order by recNo";
$resultService=mysqli_query($conn,$queryService);
$countservice=mysqli_num_rows($resultService);
while($numSevice=mysqli_fetch_array($resultService))
{
if($numSevice['km1']=="0")
{
$numSevice['km1']="";
}
if($numSevice['km2']=="0")
{
$numSevice['km2']="";
}
if($numSevice['km3']=="0")
{
$numSevice['km3']="";
}
if($numSevice['km4']=="0")
{
$numSevice['km4']="";
}
if($numSevice['km5']=="0")
{
$numSevice['km5']="";
}
$content.='<tr valign="top">
<td valign="top" align="center">'.$numSevice['date_conveyance'].'</td>
<td valign="top" align="center">'.$numSevice['start_center'].'</td>
<td valign="top" align="center">';
$queryloc="select * from timesheet_location where recNo='".$numSevice['center1']."' order by location";
$resultloc=mysqli_query($conn,$queryloc);
$num=mysqli_fetch_array($resultloc);
if($numSevice['center1']=="9" || $numSevice['center1']=="Other" || $numSevice['center1']=="Training" || $numSevice['center1']=="Actual Exp.")
{
if($numSevice['center1']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other1']."";
}
else
{
$num['location']="".$numSevice['center1']." , ".$numSevice['other1']."";
}
}
$content.=''.$num['location'].'</td>
<td valign="top" align="right">'.$numSevice['km1'].'
</td>
<td valign="top" align="center">';
$queryloc="select * from timesheet_location where recNo='".$numSevice['center2']."' order by location";
$resultloc=mysqli_query($conn,$queryloc);
$num=mysqli_fetch_array($resultloc);
if($numSevice['center2']=="9" || $numSevice['center2']=="Other" || $numSevice['center2']=="Training" || $numSevice['center2']=="Actual Exp.")
{
if($numSevice['center2']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other2']."";
}
else
{
$num['location']="".$numSevice['center2']." , ".$numSevice['other2']."";
}
}
$content.=''.$num['location'].'
</td>
<td valign="top" align="right">'.$numSevice['km2'].'
</td>
<td valign="top" align="center">';
$queryloc="select * from timesheet_location where recNo='".$numSevice['center3']."' order by location";
$resultloc=mysqli_query($conn,$queryloc);
$num=mysqli_fetch_array($resultloc);
if($numSevice['center3']=="9" || $numSevice['center3']=="Other" || $numSevice['center3']=="Training" || $numSevice['center3']=="Actual Exp.")
{
if($numSevice['center3']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other3']."";
}
else
{
$num['location']="".$numSevice['center3']." , ".$numSevice['other3']."";
}
}
$content.=''.$num['location'].'
</td>
<td valign="top" align="right">
'.$numSevice['km3'].'</td>
<td align="center">';
$queryloc="select * from timesheet_location where recNo='".$numSevice['center4']."' order by location";
$resultloc=mysqli_query($conn,$queryloc);
$num=mysqli_fetch_array($resultloc);
if($numSevice['center4']=="9" || $numSevice['center4']=="Other" || $numSevice['center4']=="Training" || $numSevice['center4']=="Actual Exp.")
{
if($numSevice['center4']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other4']."";
}
else
{
$num['location']="".$numSevice['center4']." , ".$numSevice['other4']."";
}
}
$content.=''.$num['location'].'
</td>
<td valign="top" align="right">'.$numSevice['km4'].'</td>
<td align="center">'.$numSevice['center5'].'</td>
<td align="right">'.$numSevice['km5'].'</td>
<td valign="top" align="right">'.$numSevice['totalkms'].'</td>
<td valign="top" align="center">'.$numSevice['Band'].'</td>
<td valign="top" align="right">'.number_format($numSevice['total'],2,".","").'</td>
<td valign="top">'.$numSevice['remarks'].'</td>
</tr>';
}
$content.='</table>
</td></tr>
</table><br><b>"This is computer generated invoice. No need to sign."</b>';
// 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);
// print a block of text using Write()
//$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);
// ---------------------------------------------------------
//Close and output PDF document
$name=str_replace(" ","_",$numC['name']);
$pdf->Output('rpts/'.$name.'_'.$numC['month'].'_'.$numC['year'].'_conveyance.pdf', 'F');
//============================================================+
// END OF FILE
//============================================================+
include("mail.php");
$goUrl = "ingl_conveyance_main.select.php?action=Send";
header('Location: '.$goUrl);
?>