<?php defined('BASEPATH') OR exit('No direct script access allowed');

$addressView = !empty($addressView) ? $addressView : 'export/address/lorryvoucher'; $amt= 0; ?>
<style>
html {
	font-size: 12px;
}
#mainDiv, table tr td {
	letter-spacing: 1px;
	line-stacking-strategy: inline-line-height;
	line-height: 1.1;
	font-size: 12px;
	height: 100%;
}
.amtinwords {
	font-size: 110%;
}
h1 {
	font-size: 200%;
}
h2{
	font-size: 120%;
}
h1, h2, h3, h4, h5, h6 {
	margin: 0px;
}
</style>
<div style="border: 1px solid black;" id="mainDiv">
<table class="noborder invMeta" style="width:100% ;">
	<tbody>
		<tr>
			<td width="100%">
				<img style="height: 150px; width: auto; display: inline-block" src="<?php echo $company['fullHeaderImg'] ?>" />
			</td>
		</tr>
	</tbody>
</table><br/>
<h2 style="text-align:center;">AUTHORISATION LETTER AND LORRY VOUCHER</h2>
<br/>
<div style="padding-top:5px;height:3cm;"><?php
 if(!empty($billing['name']) || !empty($shipping['name'])) { ?><table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 5px 10px;">
		<tbody>
			<tr>
				<td style="text-align:right;"><b> Date: <?php echo $tDate; ?></b></td>
			</tr>
			<tr>
				<td <?php echo !empty($showVerticalLine) ? 'style="padding:5px;border-left: 4px solid '.$headColor.'"' : '' ?>><?php
 if(!empty($contact['name']) || !empty($conName)) { ?><p class="fw nm">To</p><?php
 } if(!empty($conName)) { $this->subview($addressView, $billing); } if (!empty($contact['contactPersonMobile'])) { $billing['mobile'] = $contact['contactPersonMobile']; if(empty($isShipping)) { $shipping['mobile'] = $contact['contactPersonMobile']; } } ?></td>
			</tr>
</table><?php
 } ?>
	</div>
	<table cellspacing="0" cellpadding="0" class="noborder vat" style="border-spacing: 0 1em;padding-left: 10px;">
		<tbody>
			<tr>
				<td>
					<b><h4>Name of Commodity  </h4></b>
				</td>
				<td style="color: red;">
					<b><h4>: Rice</h4></b>
				</td>
			</tr>
			<tr>
				<td><b><h4>Bill No  </h4></b></td>
				<td style="color: red;" ><b><h4>: <?php echo $tNo;?></h4></b></td>
			</tr>
<?php if (!empty($fields)) { 
			foreach ($fields as $row) {
				 if($row['fName'] == 'Vehicle No') { 
					echo '<tr>'; echo '<td><b><h4>' . $row['fName'] . '</h4></b></td>' . PHP_EOL;
					 echo '<td style="color: red;"><b><h4>: '.$row['fValue'].'</h4></b></td>' . PHP_EOL; 
					echo '</tr>'; 
				}
			} 
	}
?>
<?php
if (!empty($fields)) {
	foreach ($fields as $row) {
		 if ($row['tType'] == 'SI') 
		{
			 $row['fValue'] = json_decode($row['fValue'], true);
				 $gridFields[] = $row; 
		}
 	}
 }

foreach ($details as $key => $val) {
	 foreach($gridFields as $k => $gf) {
		 if (empty($gf['fValue'][$val['id']])) { 
			continue; 
		} 
		$val['cf_' . $gf['fId']] = $gf['fValue'][$val['id']]; 
		if($gf['fName'] == 'No.of bags'){
			$gf['bags'] =  implode(', ', $gf['fValue']);
		}
		if($gf['fName'] == 'Kgs/bag'){
			$gf['kg'] =  implode(', ', $gf['fValue']);
		}
		if ($gf['isTotCol']) {
			 if (empty($gf['total'])) {
					$gf['total'] = 0; 
			}
			 $gf['cf_class'] = "al"; 
			if (is_numeric($gf['fValue'][$val['id']])) { 
				$gf['total'] += floatval($gf['fValue'][$val['id']]); $val['cf_class'] = "ar";
			 }
			 $gridFields[$k] = $gf; 
			
		} 
	} 
}

 if (!empty($gridFields)) {
	
	 foreach($gridFields as $val) {
			
			 /*if($val['fName'] == 'Kgs/bag') { 
					echo '<tr>'; echo '<td><b><h4>' . $val['fName'] . '</h4></b></td>' . PHP_EOL;
					 echo '<td style="color: red;"><b><h4>: '.$val['kg'].'</h4></b></td>' . PHP_EOL; 
					echo '</tr>'; 
			}*/
			if($val['fName'] == 'No.of bags') { 
					echo '<tr>'; echo '<td><b><h4>' . $val['fName'] . '</h4></b></td>' . PHP_EOL;
					 echo '<td style="color: red;"><b><h4>: '.$val['total'].'</h4></b></td>' . PHP_EOL; 
					echo '</tr>'; 
			}
			
	 }

 } 
	?>
	</tbody>
</table>
<div style="border-top: 1px solid black;">
	<?php if (!empty($fields)) { 
			foreach ($fields as $val) { 
					if ($val['fName'] == 'Lorry Hire Amount') {
						echo '<div style="text-align: center;">';
						echo '<br/><br/><br/><br/>';
						echo '<h1>'; 
							echo '	<b style="text-align:center;color:#339966">LORRY HIRE : Rs. </b>'; 
							echo '	<b style="color:red">'.$val['fValue'].'</b>'; 
						echo '</h1>'; 
						echo '<br/><br/><br/><br/>'; 
						echo '</div>'; 
						$amt =$val['fValue']; 
						break;
					 }
			 } 
		} ?>	</div>
	<div style="border-top: 1px solid black; padding-top:10px;"></div>
	<div class="nm amtinwords" style="height:1cm;white-space: pre-line; word-wrap: break-word !important;padding-left:10px;"><b>Please pay :</b>&nbsp;&nbsp;<?php
 $amtInWords = amount_in_words($amt); if ($isExport && $expCurrencyCode) { echo $expCurrencyCode . ' ' . $exp_amt_str . " only"; } else { echo $amtInWords['word'] . " only"; } ?></div>
	<table width="100%" align="left" class="footTable vat nbt wpw" autosize="1" style="page-break-inside: avoid" >
		<tbody>
			<tr>
				<td style="text-align: center;">
					<h4>Thanking You</h4>
				</td>
			</tr>
			<tr>
				<td width="100%" style="text-align: right;">
				<br/><br/><br/><br/>
					<b style="color: green">
						For <span style="color: red; font-size: 14px;font-style: italic"> <?php echo strtoupper(strip_tags($company["name"])); ?></span>
					</b>
				</td>
			</tr>
		</tbody>
	</table>
</div>

