 <?php
// Include the main TCPDF library (search for installation path).

ini_set('max_execution_time', 300);
require_once('../classes/b2b.class.dbConnect.php');
require_once('../classes/b2b.class.dbQuery.php');
require_once('../classes/b2b.class.BusiLogic.php');
require_once('../special/spl.class.Special.php');
require_once('swift/swift_required.php'); 


$DBName = isset($_SESSION['DBName']) ? $_SESSION['DBName'] : 'exb2b_solar_sc';
$objDBConnect	= new DBConnect($DBName);
$objDBQuery		= new DBQuery($objDBConnect);
$classBusiLogic	= new BusiLogic($objDBQuery, $DBName);
$objSolarCustomer	= new BusiLogic($objDBQuery, $DBName);
$objSpecialClass	= new SpecialClass($objDBQuery, $DBName, $classBusiLogic);

	$RE11Id=   $_GET['RE11Id'];
	$RE11Trans	= $objSpecialClass->getRE11Exp($_GET['RE11Id']);

// create new PDF document
include("PHPPDF/mpdf.php");
$mpdf=new mPDF('','A4',13,'',5,3,10,10,9,9, 'L'); 

$mpdf->useAdobeCJK = true;		// Default setting in config.php
								// You can set this to false if you have defined other CJK fonts
$mpdf->SetAutoFont(AUTOFONT_ALL);	//	AUTOFONT_CJK | AUTOFONT_THAIVIET | AUTOFONT_RTL | AUTOFONT_INDIC	// AUTOFONT_ALL
								// () = default ALL, 0 turns OFF (default initially)

$HeadingRowStyleFirst = '';
$HeadingRowStyleOther = '';
$RowStyleFirst = '';
$RowStyleOther = '';
$CustomerCd = '';

	$SrNo = 0;
	$count = 1;
	$prevCustomerCd = 0;
	$headerData = $_GET;
	
	$action = $headerData['action'];

	$IdExpDet = trim($headerData['IdExpDet']);
	$MagazineCd		= $headerData['MagazineCd'];
	
	$HeadingRowStyleFirst = 'Style="font-size: 12px; font-weight: bold;border-bottom:1px solid grey;border-left:1px solid grey;border-right:1px solid grey;"';
	$HeadingRowStyleOther = 'Style="font-size: 12px; font-weight: bold;border-bottom:1px solid grey;border-right:1px solid grey;"';

	$RowStyleFirst = 'Style="font-size: 10px; font-weight: bold;border-bottom:1px solid grey;border-left:1px solid grey;border-right:1px solid grey; border-collapse:collapse;"';
	$RowStyleOther = 'Style="font-size: 10px; font-weight: bold;border-bottom:1px solid grey;border-right:1px solid grey; border-collapse:collapse;"';
	
	$html_str = '';
	
	$html_str .='<table border="1" style="border-collapse:collapse;" font-size: 20px; width="1000px" cellspacing="1" cellpadding="2" class="dynamic" id="vtblBreak">';
	$html_str .='<tr>
				    <td>
						<table align="center" border="1" style="border-collapse:collapse;" width="1000px" cellspacing="1" cellpadding="1">
						<tr>
							<td align="center"><h2><b>Form RE-11</b></h2><br/>
								<p>(See rules 50 and 77 of the Explosives Rules, 2008 )</p>
								<h2>Indent of Explosives</h2>
							</td>
						</tr>
						<tr>
							<td align="right"> <b>Indent No.- : '.$RE11Trans[0]["INDETNo"].'</b></td>
						</tr>
						<tr>
							<td align="right"><b>Date : '.$objSolarCustomer->convertDate($RE11Trans[0]["INDETDate"], FALSE, 1).' </b></td>
						</tr>
						<tr>
							<td align="right"><b>Place of Magazine : '.$RE11Trans[0]["Address"].', '.$RE11Trans[0]["magazinecountry"].'</b> </td>
						</tr>
						<tr>
							<td align="left"> 
								To, <br/>';
							if($RE11Trans[0]["CompanyCd"]=='1800'){ 
							$html_str .='M/S Solar Industries India Ltd <br/>
									Nagpur, Maharashtra';
								} else{
							$html_str .='M/S Economic Explosives India Ltd <br/>
									Nagpur, Maharashtra';
								}
							
						$html_str .='</td>
						</tr>
						<tr>
							<td>
								<b>Dear Sir,</b><br/>
								Kindly supply following quantities of explosives to me/us:- 
							</td>
						</tr>
						<tr>
							<td align="left">
								<table width="1000px" style="border-collapse:collapse" border="1">
									<tr>
										<th>Sno.</th>
										<th>Explosive Name<br/>(Brand ID)</th>
										<th>Class- Div</th>
										<th>Quantity</th>
										<th>Unit</th>
									</tr>';
							$Total= 0;
					for($l=0; $l<count($RE11Trans); $l++) { 
						$Total= $Total+$RE11Trans[$l]["Quantity"];
						$Quantity= $RE11Trans[$l]["Quantity"];
						$UOM= $RE11Trans[$l]["UOM"];
						if($UOM=='Ton'){
							$Quantity=sprintf('%0.3f', $Quantity*1000);
							$UOM= 'KG';
						}
						$html_str .='<tr><td>'.($l+1).'</td>
										<td>'.$RE11Trans[$l]["Item"].'('.$RE11Trans[$l]["ItemCd"].')</td>
										<td align="center">'.$RE11Trans[$l]["ItemCtgCd"].'</td>
										<td align="center">'.$Quantity.'</td>;
										<td align="center">'.$UOM.'</td></tr>';
					}				
						$html_str .='</table>
							</td>
						</tr>
						<tr>
							<td>
							I/We hold a Export licence number <b>'.$RE11Trans[0]["LicenceNo"]. '</b> in form <b>LE-8 </b>of Explosives Rules, 2008 for above quantities of explosives for export to <b>'.$RE11Trans[0]["Customer"].', '.$RE11Trans[0]["Country"].' : </b>
							</td>
						</tr>
						<tr>
							<td>
								<table width="1000px" style="border-collapse:collapse" border="1">
									<tr>
										<th>Sno.</th>
										<th>Explosive Name</th>
										<th>Class- Div</th>
										<th>Quantity</th>
										<th>Unit</th>
									</tr>
									<tr><td>1</td>
										<td align="center"> <b>NA</b></td>
										<td align="center"> <b>NA</b></td>
										<td align="center" colspan="2" ><b>For Export</b></td>
									</tr>
								</table>
							</td>
						</tr>';
			$html_str .='<tr>
							<td> The above mentioned licence is valid till <b>'.$objSolarCustomer->convertDate($RE11Trans[0]["ExpireDate"], False, 1).'</b></td>
						</tr>
						<tr>
							<td>I/We ready to receive explosives on <b>'.$objSolarCustomer->convertDate($RE11Trans[0]["ReadytoReceiveDate"], False, 1).'</b></td>
						</tr>
						<tr>
							<td>
								* The Licence is sent herewith for necessary endorsement as required under rule...... of explosives Rules, 2008. The Licence may please be returned after the endorsement.
							</td>
						</tr>
						<tr>
							<td>
								I/We solemnly declare that<br/>
									1. The reciept of explosives indented will not result in the licensed quantity being exceeded; and <br/>
									2. No identical indent has been placed with any other supplier.
							</td>
						</tr>
						<tr>
							<td>
								<table border="0" width="1000px">
									<tr>
										<td height="50px" width="700px"><b>The explosives may please be handed over to any one of my/our authorised representative whose <Br/> signatures are attested below (at my magazine mentioned above) :</b>
										<BR/>
										</td>
										<td width="300px" >
										</td>
									</tr>
									<tr>
										<td height="30px">
										1. Mr. Sanjay Topre.<br/><br/>
										</td>
										<td></td>
									</tr>
									<tr>
										<td height="30px">
										2. Mr. Ajit Raodeo.<br/><br/>
										</td>
										<td></td>
									</tr>
									<tr>
										<td height="30px">
										3. Mr. Srinivas Ramisetty<br/><br/>
										</td>
										<td></td>
									</tr>
									<tr>
										<td>Signature Attested By :</td>
										<td></td>
									</tr>
									<tr>
										<td >(';
									if($RE11Trans[0]["CompanyCd"]=='1800'){ 
									$html_str .='Mr. K.S. Talesra';
									} else{
									$html_str .='Mr. A.K. Jain';
									}
									$html_str .=' )</td>
										<td height="50px" align="center">';
										if($RE11Trans[0]["CompanyCd"]=='1800'){
										$html_str .=' Mr. K.S. Talesra';
										} else{
										$html_str .='Mr. A.K. Jain';
										}
										$html_str .='<br/>(Athorized Signatory)<br/>
											Licence Number :<br/> '.$RE11Trans[0]["LicenceNo"].'
											<br/>Licence From : <br/>LE-8</td>
									</tr>
								</table>
							</td>
						</tr>';
					//	<tr><td> <b>Copy Forwarded to : </b> <br/>
					//	&nbsp; &nbsp; 1. The Dy. Chief Controller of Explosives, shri Mohan Sita Compound, 5 Main Road, Behind Sushila Automobiles, Ranchi(J.H.) - 834001 for information. </ol>
					//	</td></tr>
	$html_str .='	</table>
				</td>
			</tr>
		</table>';
			
			
	$mpdf->AddPages('P');
	$mpdf->setHTMLFooter('<div align="center"><b>{PAGENO} / {nbpg}</b></div>') ;
	$mpdf->setHTMLFooter('<div align="center"><b><i>{PAGENO} / {nbpg}</i></b></div>','E') ;
	$mpdf->WriteHTML($html_str);
	
	$filename = "RE11";
	$Date = date('d-m-Y');
	$filename = $filename.$IdExpDet.$Date;

	$html_str = '<table id="tblHeading" width="100%" cellspacing="0" cellpadding="6" border="0"><tr><td><b>No record exist!!!!</b></td></tr></table>';
	$mpdf->Output($filename,'D');
 

	
?>
