<?php
	ob_start();
	session_start();
?>
<?php
include("config.php");
	if(!isset($_SESSION["adminname"]) && !isset($_SESSION["username"]))
	{
		header("Location: index.php");
	}
include("MPDF/mpdf.php");

?>
<div class="main">
  <div class="main-inner">
    <div class="container">
      <div class="row">
		<div class="span12">
			<div class="widget">
			   <div class="widget-header">
					<h3>Generate PDF</h3> 
				</div>
				<div class="widget-content">
					<div class="container" >
					  <div class="modal fade" id="supModal" role="dialog" style="width:30%;">
						<div class="modal-dialog" >
						  <div class="modal-content">
							<div class="modal-body">
								<center><img src="img/ajax-loader.gif"></center>
								<center>PDF Generation On Progress</center>
								
<?php


if(isset($_GET['dcno'])){
	$dcno=$_GET['dcno'];
    $cdate=date('Y-m-d');
$query=mysql_query("select * from report where dcno='$dcno' and cdate='$cdate'");
$row=mysql_fetch_assoc($query);

$address1=$row['address1'];
$address2=$row['address2'];
$address3=$row['address3'];
$address4=$row['address4'];
$description=$row['adescription'];
$quantity=$row['aquantity'];
$date=$row['date'];


$mpdf=new mPDF(''); 
$mpdf=new mPDF('c','A4','','',20,15,35,25,10,10); 
$mpdf->useOnlyCoreFonts = true;    // false is default
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("");
$mpdf->SetAuthor("");
$mpdf->SetWatermarkText("");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
//$mpdf->mirrorMargins = 1;
$html = '
<html>
<head>
<title>"QuotationPDF"</title>
<style>
table, tr, th 
{
	border: 1px solid black;
	border-collapse: collapse;
	
}
#hidelines2
{
	
	border-right:1px solid #FFF;
	border-top:1px solid #fff;
	border-bottom:1px solid #fff;
}
#hidelines1
{
	border-left:1px solid #FFF;
	border-top:1px solid #fff;
	border-bottom:1px solid #fff;
}
#hidelines
{
	border-left:1px solid #FFF;
	border-right:1px solid #FFF;
	border-top:1px solid #fff;
	border-bottom:1px solid #fff;
}
.hide_line
{
border: 0px;
}
.bor
{
	margin-top: 20px;
	font-size: 12pt;
	
}
.databord ,td
{
	border: 1px solid black;
	font-size: 12pt;
	
}
.wid table,tr
{
	width:100%;
	font-size:12px;
	font-width:bold;
}
.dis
{
	text-align:right;
}
.tos
{
	border: 0px;
	margin-top: 20px;
	font size:12pt;
}

</style>
</head>
<body>
<!--mpdf
</htmlpageheader>


<htmlpagefooter name="myfooter">
<div style="text-align: center;">Page {PAGENO} of {nb}</center></div>
<div style="border-top: 1px solid #000000; font-size: 9pt; text-align: center; padding-top: 10mm; ">
</div>
</htmlpagefooter>
<sethtmlpageheader name="myheader" value="on" show-this-page="1" />
<sethtmlpagefooter name="myfooter" value="on" />';

$html.="<br><table style='width:100%;' >
<tr style='border-left:1px solid #fff;border-right:1px solid #fff;border-top:1px solid #fff;border-bottom:1px solid #fff; '><td  style='text-align:center; font-size:14pt;'><b><u>DELIVERY CHALLAN</u></b></td></tr>
</table>"; 

$html.="</table>
<table style='width:100%;'  id='hidelines'>
  <tr  id='hidelines'>
    <td  width='50%' id='hidelines1'>
		  <table  id='hidelines'> 
		   <tr  id='hidelines'><td  id='hidelines1' ></td></tr>
		 </table>
	</td>
    <td  width='50%'  id='hidelines2' style='text-align:right'>
	     <table  id='hidelines' >
		   <tr  id='hidelines'><td ></td></tr>
		 </table>
	</td>
  </tr>
</table>";
$html.="<div  >
<table style='width:100%;'  id='hidelines'>
  <tr  id='hidelines'>
    <td  width='50%' id='hidelines1'>
		  <table  id='hidelines' > 
		   <tr  id='hidelines'><td  id='hidelines1' >GSTIN:34AAMFB9946N1ZO</td></tr>
		   <tr  id='hidelines'><td  id='hidelines1' ></td></tr>
		   <tr  id='hidelines'><td  id='hidelines1' style='font-size:16pt;'><b>BM BIO ENERGY</b></td></tr>
		   <tr  id='hidelines'><td  id='hidelines1' ></td></tr>
		   <tr  id='hidelines'><td  id='hidelines1'>T.S.No.12/7,No.66,Perungalur Village,</td></tr>
		   <tr  id='hidelines'><td  id='hidelines1'>Puducherry-605 007.</td></tr>
		   
		 </table>
	</td>
    <td  width='50%'  id='hidelines2' >
	     <table  id='hidelines' >
		   <tr  id='hidelines'><td  id='hidelines'>M/S:</td></tr>
		   <tr  id='hidelines'><td  id='hidelines' style='padding-left:40px;'>  ".$address1."</td></tr>
		   <tr  id='hidelines'><td  id='hidelines' style='padding-left:40px;'>  ".$address2."</td></tr>
		   <tr  id='hidelines'><td  id='hidelines' style='padding-left:40px;'>  ".$address3."</td></tr>
		   <tr  id='hidelines'><td  id='hidelines' style='padding-left:40px;'>  ".$address4."</td></tr>
		   <tr id='hidelines'>
			<td id='hidelines'> DC No:".$dcno."</td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<td align='right;' > Date:&nbsp;".date('d/m/Y')."</td>
		</tr>
		 </table>
		 
	</td>
  </tr>
</table>
</div>";

$q2=mysql_query("select * from report where dcno='$dcno'");
$q2res=mysql_fetch_assoc($q2);
$s=$q2res['dcno'];

$html.="
<table class='head'  style='width:100%;height:500px' id='example1'>
<thead>
<tr>
<td class='databord' style='text-align:center;width:7%;'>S.No</td>
<td class='databord' style='text-align:center;width:53%;'>DESCRIPTION</td>
<td class='databord' style='text-align:center;width:10%;'>Quantity</td>
<td class='databord' style='text-align:center;width:35%;'>REMARKS</td>
</tr></thead>";
$html.="<tbody >
<tr>
<td  style='text-align:center;width:7%;height:100px;border-top:5px solid #fff;'>1<br><br><br><br><br><br><br><br><br></td>
<td  style='text-align:center;width:53%;height:100px;border-top:5px solid #fff;'>".$description."<br><br><br><br><br><br><br><br><br></td>
<td  style='text-align:center;width:10%;height:100px;border-top:5px solid #fff;'>".$quantity."<br><br><br><br><br><br><br><br><br></td>
<td style='text-align:center;width:10%;height:100px;border-top:5px solid #fff;'><br><br><br><br><br><br><br><br><br><br></td>
</tr></tbody>";

$html.="</table>
<table style='width:100%;'  id='hidelines'>
  <tr id='hidelines'>
    <td  width='50%' id='hidelines'>
		  <table  id='hidelines'> 
		   <tr  id='hidelines'><td  id='hidelines' >Received the goods in good condition</td></tr>
		 </table>
	</td>
    <td  width='50%'  id='hidelines' style='text-align:right'>
	     <table  id='hidelines' >
		   <tr  id='hidelines'><td >For <b>BM BIO ENERGY<b></td></tr>
		 </table>
	</td>
  </tr>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
<table style='width:100%;'  id='hidelines'>
  <tr  id='hidelines'>
    <td  width='50%' id='hidelines'>
		  <table  id='hidelines'> 
		   <tr  id='hidelines'><td  id='hidelines' >Received Signature</td></tr>
		 </table>
	</td>
    <td  width='50%'  id='hidelines' style='text-align:right'>
	     <table  id='hidelines' >
		
		 </table>
	</td>
  </tr>
</table>";
$html.="</body></html>";
//echo $html;exit;						
$mpdf->useAdobeCJK = true;
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->WriteHTML($html);
$val='pdf/'.$dcno.'.pdf'; 
$mpdf->Output($val, 'F');
	if($dcno==''){
	?><script type="text/javascript">window.location.href="viewreport.php";</script><?php
	}else{
		?><script type="text/javascript">window.location.href="viewreport.php";</script><?php
	}
}
//GRN PDF End
?>
<center><a href="<?php echo $val ?>" style="text-decoration: none; font-weight: bold; font-size: 22px; color: red;" target="_blank">CLICK HERE TO VIEW PDF</a></center>
							</div>
						  </div>
						</div>
					  </div>
					</div>
				</div>
			</div>
		</div>
	  </div>
      <!-- /row --> 
    </div>
    <!-- /container --> 
  </div>
  <!-- /main-inner --> 
</div>
<!-- /main -->

<script>
 $("#supModal").modal();
 $("#supModal").css("top","50%");
 $("#supModal").css("left","55%");
</script>