<?php defined('BASEPATH') OR exit('No direct script access allowed'); 
$from_date = isset($from_date) ? format_date($from_date) :'';
$to_date = isset($to_date) ? format_date($to_date): '';
$fontname = (!empty($fontname) && $fontname != 'null') ? $fontname : ""; 
$gstr9_head = array(
	'4' => '4. Outward',
	'5' => '5. Outward',
	'6' => '6. ITC Availed',
	'7' => '7. ITC Reversal',
	'8' => '8. Other ITC',
	'9' => '9. Tax Paid',
	'10' => '10. Py',
	'14' => '14. Differential Tax',
	'15' => '15. Demands & refunds',
	'16' => '16. Comp ds & refunds',
	'17' => '17. HSN outward',
	'18' => '18. HSN Inward'
);
$tab_style = "width:100%";
$this->currency_symbol = get_company('symbol');
if(!empty($heading)) {
	$des_width = 96/count($heading);
	$des_width = 'width:'.$des_width.'%';
}
$totalcol = !empty($totalcol) ? $totalcol : 3;
if(!empty($branchName)) {
	//$branchName = (!empty($branchName) && $branchName == 'All Branches') ? '' : $branchName;
}

echo (!isset($pdf_type) || $pdf_type=='I')?'<page footer="page">':"<br>";
	if (!empty($bookmark_title)) { 
		echo '<bookmark title="'.$bookmark_title.'" level="'.((isset($account_type) && $account_type!='ALL')?1:0).'" ></bookmark>';
		echo '<a name="'.str_replace(' ','_',$bookmark_title).'"></a>';
	} ?>
	<div>
		<?php if (empty($hide_header)) { ?>
		<table  border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;" class="pdf_head">
			<tr>
				
				<td style="width:100%;text-align:center;font-size:16px;"> <?php if(!empty($title)) { echo $title.'<br>'; } ?>
					
					
					
						<?php if(!empty($name)) { ?> 
							<span style="font-weight:normal;color:#000;font-size:12px;"><?php echo ($name); ?></span><br>
						<?php } ?>
						<?php if(isset($filter_type)) { ?> 
							<span style="font-weight:normal;color:#000;font-size:12px;"><?php echo ucfirst($filter_type); ?></span><br>
						<?php } ?>
						
						<?php if(isset($status)) { ?> 
							<span style="font-weight:normal;color:#000;font-size:12px;"><?php echo ($status); ?></span><br>
						<?php } ?>
						
							
					<?php if(!isset($isLedger)) { ?>
					<?php if(!empty($compName)) { ?> <br>
							<span style="font-weight:normal;font-size:19px;"><?php echo $compName; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($additonalInfo)) { ?> 
							<span style="font-weight:normal;font-size:19px;"><?php echo $additonalInfo; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($sideHeader)) { ?> 
							<span style="font-weight:normal;font-size:15px;"><?php echo $sideHeader; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($extrahead)) { ?> 
							<span style="font-weight:normal;font-size:16px;"><b><?php echo $extrahead; ?></b></span>
					<br>
					<?php } ?>
					<?php if(!empty($extrahead1)) { ?> 
							<span style="font-weight:normal;font-size:12px;"><?php echo $extrahead1; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($extrahead2)) { ?> 
							<span style="font-weight:normal;font-size:12px;"><?php echo $extrahead2; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($extrahead3)) { ?> 
							<span style="font-weight:normal;font-size:12px;"><?php echo $extrahead3; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($attrName)) { ?> 
							<span style="font-weight:normal;font-size:12px;"><?php echo $attrName; ?></span>
					<br>
					<?php } ?>
					<?php	if(!empty($warehouse_location)){?>
						<span style="font-weight:normal;font-size:14px;"><?php echo ''.$warehouse_location; ?></span><br>
					<?php } ?>
					<?php if(!empty($asOn)) { ?>
					<span style="font-weight:normal;font-size:10px;">as at <?php echo !empty($to_date)?$to_date:date("d/m/Y"); ?></span>
					<?php } ?>
					<?php } ?>
					<?php if(!empty($gstin)) { ?> 
							<span style="font-weight:normal;font-size:13px;"><?php echo 'GSTIN - '. $gstin; ?></span>
					<br>
					<?php } ?>
					<?php if($type == 'gstrsummary') { 
						$gstr_head = 'GSTR1';
						if(isset($rep_type)){
							if($rep_type == 'gstr4'){
								$gstr_head = 'GSTR4';
							}
						}
						?> 
							<span style="font-weight:normal;font-size:14px;"><b><?php echo $gstr_head; ?></b></span>
					
					<?php 
						} 
					?>
					<?php if($type == 'gstr2sum') { ?> 
							<span style="font-weight:normal;font-size:14px;"><b><?php echo 'GSTR2 Summary'; ?></b></span>
					
					<?php } ?>
					<?php if(!empty($rangePeriod)) { ?> 
							<div style="font-weight:normal;font-size:14px;"><?php echo ''.$rangePeriod; ?></div>
					<br>
					<?php } ?>
					
					<?php if($from_date && $to_date && $type != 'gstr1all' && $type != 'gstr3all' && ($from_date != $to_date)) { ?>
					
					<span style="font-weight:normal;font-size:10px;"><?php echo $from_date.'&nbsp;-&nbsp;'.$to_date ; ?></span>
					
					<?php }else{ ?>
						<span style="font-weight:normal;font-size:11px;"><?php echo $from_date; ?></span>
					<?php } ?><br>
					<?php if(!empty($branchName)) { ?> 
							<span style="font-weight:normal;font-size:10px;"><?php echo $branchName; ?></span>
					<br>
					<?php } ?>
					<?php if(!empty($detHead)) { ?>
					<br>
					<span style="font-weight:normal;font-size:12px;"><b><?php echo $detHead; ?></b></span>
					<br>
					<?php } ?>
					<?php if($type == 'gstr1all'  || $type == 'gstr3all') { ?>
						<br><span style="font-weight:normal;font-size:12px;">Detailed Summary</span>
					<?php  } ?>
				</td>
				
				
			</tr>
		</table>

		<?php } if($type == 'gstr1all' || $type == 'gstr3all') { ?>
					<br>
		<table  bordercolor="#e5e5e5"  cellspacing="0" border="0" cellpadding="0"  style="width:100%;table-layout:fixed;">
			<tr>
				<td style="width:50%;text-align:left;" ><?php echo $gstin; ?></td>
				<td style="width:50%;text-align:right;"><?php echo $rangePeriod; ?></td>
			</tr>
			<tr>
				<td style="width:50%;text-align:left;" ><?php echo $compName; ?></td>
				<td style="width:50%;text-align:right;"><?php echo $rangeDate; ?></td>
			</tr>
		</table>
		<?php } ?>
		<?php if( $type !="gstr3") { ?><br><?php } ?>
		<?php if(!empty($gstin) && $type != 'gstr1all' && $type != 'gstr3all') { ?>
	<!--	<div style="font-weight:normal;">{title} summary</div><br>
		<table  bordercolor="#e5e5e5"  cellspacing="0" border="0" cellpadding="0" style="width:100%;table-layout:fixed;" class="gstr_head">
			<tr>
				<td style="width:50%;">GSTIN</td>
				<td style="width:50%;"><?php echo $gstin; ?></td>
			</tr>
			<tr>
				<td style="width:50%;">Legal name of the registered person</td>
				<td style="width:50%;"><?php echo $compName; ?></td>
			</tr>
		</table><br>-->
		
		<?php } ?>
		<?php if(!empty($summary)) {?>
		<table width="100%" style="overflow: wrap" border="0" cellpadding="0" cellspacing="0" class="summary_head" >
			<thead>
				<tr>
				<?php foreach($summary_head as $key=> &$val) {  
					echo "<th width=".$val['wid']."  class='headgst' style=text-align:".$val['align'].">".$val['name']."</th>";
				} ?>
				</tr>
			</thead>
			<tbody>
				<?php foreach($summary as $sumval) {  
						echo "<tr>";
							foreach($summary_head as $key=> &$val) {
								echo "<td width=".$val['wid']." style=text-align:".$val['align'].">".$sumval[$key]."</td>";
							}
						echo "</tr>";
				} ?>	
				<tr>
					<?php 
						echo "<td class='botop_black' colspan=".count($summary_head)."></td>";
					?>
				</tr>
			</tbody>
		</table>
		<br>
		<?php } ?>
		<?php if(!empty($csType) && $csType == 'P' && !empty($totDetails)) {
			/*Project header display start */?>
			<table width="100%" style="overflow: wrap" border="0" cellpadding="0" cellspacing="0" class="summary_head">
				<tr>
					<?php if(!empty($totDetails['totInvoiced'])) { ?>
					<td style="padding: 0px;"><?php echo $this->currency_symbol.$totDetails['totInvoiced'];?></td>
					<?php }?>
					<?php if(!empty($totDetails['totcostofgoods'])) { ?>
					<td><?php echo $this->currency_symbol . $totDetails['totcostofgoods'];?></td>
					<?php }?>
					<?php if(!empty($totDetails['expenses'])) { ?>
					<td><?php echo $this->currency_symbol . $totDetails['expenses'];?></td>
					<?php }?>
					<?php if(!empty($totDetails['totProfit'])) { ?>
					<td><?php echo $this->currency_symbol . $totDetails['totProfit'];?></td>
					<?php }?>
					<?php if(!empty($totDetails['totReceipts'])) { ?>
					<td><?php echo $this->currency_symbol . $totDetails['totReceipts'];?></td>
					<?php }?>
				</tr>
				<tr>
					<?php if(!empty($totDetails['totInvoiced'])) {?>
					<td><b>INVOICED<b></td>
					<?php } ?>
					<?php if(!empty($totDetails['totcostofgoods'])) { ?>
					<td><b>COST</b></td>
					<?php }?>
					<?php if(!empty($totDetails['expenses'])) { ?>
					<td><b>EXPENSES</b></td>
					<?php }?>
					<?php if(!empty($totDetails['totProfit'])) { ?>
					<td><b><?php echo isset($totDetails['loss']) ? 'LOSS' : 'PROFIT'?><b><br>After tax</td>
					<?php }?>
					<?php if(!empty($totDetails['totReceipts'])) { ?>
					<td style="padding : 0px !important;"><b>RECEIPT</b></td>
					<?php }?>
				</tr>
			</table><br>
		<?php /*Project header display end */  } ?>
		<div style="width:100%;"  class="container">
			<?php if($type=='pl_bs') { ?>
			<div style="float: left;width: 50%;">
				<table  width="100%" style="overflow: wrap" border="0" bordercolor="#000000" cellpadding="0" cellspacing="0" class="middlecol" style="border-right:0.5px solid grey;">
					<?php if ($_items) {
							if (!empty($heading)) {
								echo "<thead>";
								
								echo "<tr>";
								foreach($liheading as $key=> &$val) { 
									if(!empty($key) && ($key=='name'))
									{
										$assetfirst="text-align: left;";
									}
									else{
											$assetfirst="text-align: right;";
									}
									
									if($type!='default')
										echo "<th width=".$val['wid']." class='headgst' style='".$assetfirst."'>".$val['name']."</th>";
									else
										echo "<th width=".$val['wid']."  class='headgst' style='".$assetfirst.$des_width."'>".$val['name']."</th>";
								}
								echo "</tr></thead>";
								if ($_items) {
									echo "<tbody>";
									foreach ($_items as $item) {
										echo "<tr>";	
										$isTotal = !empty($item['isTot']) ?  'isTot' : '';
										$isFirstRow = !empty($item['isFirstRow']) ?  'isFirstRow' : '';
										foreach($liheading as $key=> &$val) {
											if(!empty($key) && ($key=='name'))
											{
												$assetfirst="text-align: left;";
											}
											else{
													$assetfirst="text-align: right;";
											}
											$isTotalValueExists = $isHead = '';
											
											$style = ( is_numeric($item[$key]) || substr($item[$key],0,1) == '(' || substr($item[$key],0,1) == '-' || substr($item[$key],-2) == 'Dr' || strpos($item[$key], 'align="right"') !== false )?" 'text-align:right;'":'';
											//$style = $style.;
											$style = $assetfirst;
											if((!empty($item['isTotal']) || !empty($item['isTot']))) {
											
												$isTotalValueExists = 'border-top:1px solid #000000;';
												$style = $style.$isTotalValueExists;
											}
											if(!empty($isFirstRow)) {
												$style .= 'border-top : 1px solid grey;'; 
											}
											if($type!='ledDetail' && $type!='detail')
												$item[$key] = ($item[$key]=='0.00') ? '' : $item[$key];
											echo "<td width=".$val['wid']." style='".$style."'>".$item[$key]."</td>";
										}
										echo "</tr>";
									}
									echo "</tbody>";
								}
							} 
						}?>
				</table>
			</div>
			<?php } ?>
			
			<?php $tab_style = (isset($heading) && count($heading) < 2)? "width: 70%; margin-left: auto;margin-right: auto;" : "width:100%"; ?>
			<div <?php echo !empty($type && $type=='pl_bs') ? 'style="float: right;width: 50%;"' :'style="'.$tab_style.'"' ?> >
				<table width="100%" style="overflow: wrap !important;" border="0" bordercolor="#000000" cellpadding="0" cellspacing="0" class="middlecol" <?php echo !empty($type && $type=='pl_bs') ? 'style="border-left:0.5px solid grey;"' :''?> >
					<?php if ($items) {
							if (!empty($heading)) {
								echo "<thead>";
								echo "<tr>";
							if($type=='stock') {
								echo '<th colspan="2" style="text-align:center">Item</th>';
								if($show_attrs==1 && !empty($attributes)){
									echo '<th colspan="'.(isset($attributes)?count($attributes):4).'" style="text-align:center;">Item Attributes</th>';
								}
								echo '<th colspan="2" style="text-align:center;">Opening Balance</th>'. (($isDetail) ? ('<th colspan="2" style="text-align:center;">Inward Purchase</th><th colspan="2"  style="text-align:center;">Inward Sales return</th>
								<th colspan="2" style="text-align:center;">Inward Mfg Journal</th><th colspan="2" style="text-align:center;">Inward trasfer stock</th><th colspan="2"  style="text-align:center;">Outward Sales</th><th colspan="2" style="text-align:center;">Outward Purchase Return</th><th colspan="2" style="text-align:center;">Outward Consume</th><th colspan="2"  style="text-align:center;">Outward expiry</th><th colspan="2" style="text-align:center;">Outward transfer</th>') : '<th colspan="2"  style="text-align:center;">Inwards</th><th colspan="2" style="text-align:center;">Outwards</th>') . '<th colspan="2" style="text-align:center;">Closing Balance</th></tr>';							
							}	
							if($type=='Aging') {
								echo '<th colspan="'.(!empty($rate_enabled) ? 1:'').'" style="text-align:center">Item</th>';
								echo '<th colspan="'.(!empty($rate_enabled) ? 1:'').'" style="text-align:center">SKU</th>';
								echo '<th colspan="'.(!empty($rate_enabled) ? 2:'').'" style="text-align:center;">'.'1 -'.$interval.' Days</th>';
								echo '<th colspan="'.(!empty($rate_enabled) ? 2:'').'"  style="text-align:center;">'.$interval.' -'.(2*$interval).' Days</th>';
								echo '<th colspan="'.(!empty($rate_enabled) ? 2:'').'"  style="text-align:center;">'.(2*$interval).' -'.(3*$interval).' Days</th>';
								echo'<th colspan="'.(!empty($rate_enabled) ? 2:'').'" style="text-align:center;">'.(3*$interval).' -'.(4*$interval).' Days</th>';
								echo'<th colspan="'.(!empty($rate_enabled) ? 2:'').'"  style="text-align:center;">'.(4*$interval).' Days</th>';
								echo '</tr><tr>';
							}	
							if($type=='gstr2sum') {
								echo '<th align="left" style="font-size: 14px;" rowspan="2">Document Details</th><th style="font-size: 14px;" rowspan="2">No.</th><th style="font-size: 14px;" rowspan="2">Advance Paid</th><th style="font-size: 14px;" rowspan="2">Invoice<br>value</th><th style="font-size: 14px;" rowspan="2">IGST</th><th style="font-size: 14px;" rowspan="2">CGST</th><th style="font-size: 14px;" rowspan="2">SGST</th><th style="font-size: 14px;" rowspan="2">CESS</th><th  colspan="4" style="text-align:center;font-size:14px">ITC (Rs. ) </th></tr><tr><th style="font-size: 14px;">IGST</th><th style="font-size: 14px;">CGST</th><th style="font-size: 14px;">SGST</th><th style="font-size: 14px;">CESS</th></tr>';
							}
							if(!empty($salesHeader)){
								echo $salesHeader.'</tr><tr>';
							}
							$colspan = 0;
							/*if (!empty($extraHeader)) {
										echo "<tr>";
										foreach($heading as $key=>$val) {
											if (!isset($extraHeader[$key])) {
												echo '<td style="
				border-bottom:1px solid black;border-right: none;
				border-left: none;"></td>';continue;
											}
											$style = ( is_numeric($extraHeader[$key]) || $key =='dueAmount' || substr($extraHeader[$key],0,1) == '(' || substr($extraHeader[$key],-2) == 'Dr' || strpos($extraHeader[$key], 'align="right"') !== false )?"text-align: right;":'';
											
											if($type!='ledDetail' && $type!='detail')
												$extraHeader[$key] = ($extraHeader[$key]=='0.00') ? '' : $extraHeader[$key];
											echo "<td  style='border-right: none;
				border-left: none;".$style."' >".$extraHeader[$key]."</td>";
											
										}
										echo "</tr>";
									}
							echo '<tr>';*/
							if(!empty( $compareCount)) {
							echo '<tr>';
										
									echo '<th class="tc" style="border-top:1px solid black"></th>';
									if(!empty($parentCategory)) {
										echo '<th class="tc" style="border-top:1px solid black"></th>';
									}
									if(!empty($_colspan)) {
										
							
									}
									
									$align = $compareCount > 1 ? 'tc' : 'tc';
									for($x = 0;$x <= ($compareCount);$x++) {
										echo '<th colspan="'.$_colspan.'" class="'.$align.'" style="border-top:1px solid black">'.$extraHeader['s_qty_'.$x].'</th>';
									}
									
							echo '</tr>';
							}
							echo '<tr>';
								foreach($heading as $key=> &$val) { 
									if(!empty($val['align']))
									{
										$txt_align = $val['align'];
									}
									else{
										$txt_align = "left";
									}
									$txt_align = 'text-align:'.$txt_align.';';
									if(!empty($branches)) {
										foreach($branches as $branch) {
											if($key == $branch) {
												$txt_align = "text-align: right";
											}
										}
									}
								
									
									if(empty($multiple_dates)) {
										if($type!='default') {
											echo "<th width=".$val['wid'].'%'." class='headgst' style='border-top: 1px solid black;border-bottom: 1px solid black;".$txt_align."'>".$val['name']."".'</th>';
												
											
										}
										else {
											echo "<th width=".$val['wid'].'%'."  class='headgst' style='".$txt_align."'>".$val['name']."</th>";
										}
									}
		
									
								}	
								
								echo '</tr>';
								
								$rowspn = '';
								if(!empty($multiple_dates)) {
									$rowspn = (!empty($plbstb_type) && $plbstb_type == 'T') ? '2' : '';
									if(empty($isCog )) {
									echo '<tr>';
										echo "<th rowspan='".$rowspn."' class='headgst' style='text-align:left'>Account Type </th>";
										foreach($multiple_dates as $keys =>$values) {
											
											echo '<th class="headgst" colspan="2" style="text-align:center">';
												echo '<div class="head_d">';
												if((!empty($plbstb_type) && $plbstb_type != 'P')) {
													echo '<span class="fwn">as at </span>';
												}
												if(!empty($plbstb_type) && $plbstb_type == 'P') {
													echo format_date($values['from_date']) .
													' - ';
												}
												echo format_date($values['to_date']).'</div>';
											echo '</th>';
											
										}	
									echo '</tr>';
									}
									echo '<tr>';
										if(!empty($isCog)) {	
											echo '<th class="headgst" style="text-align:left">Account Type</th>';
										}
										if(!empty($plbstb_type) && $plbstb_type == 'T' || !empty($isCog)) {
											$bt_style = '';
											if(empty($isCog)) {	
												$bt_style = "border-top:none";
											}
											for($i = 0; $i < $comp_length; $i++) {
												echo '<th class="headgst" style="'.$bt_style.'">'.(empty($isCog) ? 'Debit' : $currency).'</th>';
												echo '<th class="headgst" style="'.$bt_style.'">'.(empty($isCog) ? 'Credit' : $currency).'</th>';
											}
										}	
									echo '</tr>';
									
								}
								
								echo "</thead>";
								// echo "comes header end";
								// exit;
								if ($items) {
									echo "<tbody>";
									foreach ($items as $key => $item)
									{ 
										if(!empty($isDetparticulars)){
											$item['detparticulars'] = '';
											if (!empty($item['particulars'])) {
												$item['detparticulars'] = $item['particulars'];
												$item['particulars'] = '';
											}
										}
										if (($key % 10) == 0)
										{
											echo '<!-- chunk -->';
										}
										$isFirstRow = !empty($item['isFirstRow']) ? 'isFirstRow' : '';
										
										$isTotal = !empty($item['isTotal']) ?  'isTot' : '';
										$issubHeader = !empty($item['isHead']) ?  'isHead_' : '';
										if(($file_name == 'customer_sales_detail' || $file_name == 'purchase_supplier_details' || $file_name == 'pend_ord_list' || $file_name == 'sales_register_detail' || $file_name == 'purchase_register_detail' || !empty($isDetailBorder)) && !empty($item['isFirst'])) {
											echo "<tr><td colspan='".(count($heading))."' style='border-top:0.1px solid grey;padding:0px;'></td></tr>";
										}
										
										echo "<tr class='".$isTotal. ' ' .$isFirstRow .' '.$issubHeader."' >";	
											$start = 0;$isSkip = false;
										foreach($heading as $key=> &$val) {
											
											if(!empty($val['align']))
											{
												$txt_align = $val['align'];
											}
											else{
												$txt_align = "left";
											}
											$txt_align = 'text-align:'.$txt_align.';';
											if (preg_match('/[\'^£$%&*()}{@#~?><>,|=+¬-]/', $key)) {
												$txt_align="text-align: right;";
											}
											if(!empty($branches)) {
												foreach($branches as $branch) {
													if($key == $branch) {
														$txt_align.="text-align: right;";
													}
												}
											}
											if(!empty($item[$key])){
											$style = ( is_numeric($item[$key]) || substr($item[$key],0,1) == '(' || substr($item[$key],0,1) == '-' || substr($item[$key],-2) == 'Dr' || strpos($item[$key], 'align="right"') !== false )?"style='text-align:right;'":'';
											} else {
											$style = '';
											}
											//$style = $style.;
											if($type!='ledDetail' && $type!='detail')
												$item[$key] = (empty($item[$key]) || $item[$key]=='0.00') ? '' : $item[$key];
											//OB : For comp balancesheet border under parent_type = 'P' assigning class is not working so used the styles
											$bobtm = preg_match('/<b class="[^"]*bobottom[^"]*" align="right">/', $item[$key]);
											if(!empty($item['gross']) || !empty($item['net'])) {
												$txt_align = 'text-align: right;font-size:14px';
											}
											if($bobtm && strip_tags($item[$key]) && !empty($item['id']) && ($file_name == 'multiple_bs' || $file_name == 'multiple_pl')) {
												$bobtm = 'border-bottom:1px solid #000000;';
											}	
											else {
												$bobtm = '';
											}
											//OB : For comp balancesheet whole row total style,assigning class is not working so used the styles
											$isTotalValueExists = $isHead = '';
											if((!empty($item['isTotal']) || !empty($item['isTot']))) {
												$isTotalValueExists = 'border-bottom:1px solid #000000;border-top:none;';
											}
											if(isset($item['isHead'])) {
												$isHead = 'font-size:15px;';
											}
											$bg_class = '';
											
											if(preg_match('/<span class="[^"]*red_bg[^"]*">/', $item[$key])) {
												$bg_class = 'red_bg';
											}
											if(preg_match('/<span class="[^"]*green_bg[^"]*">/', $item[$key])) {
												$bg_class = 'green_bg';
											}	
											//Colspan
											if (array_key_exists(("name_colspan"),$item) ) {
													if($start < $colspan) {
														$isSkip = true;
													}
													else {
														$colspan = 0;$isSkip = false;
													}
												if((!empty($item['name']) && $key == 'name') || (!empty($item['itemName']) && $key == 'itemName')  || (!empty($item['conName']) && $key == 'conName'))  {
													$colspan = $item['name_colspan'];
													
												}
												$start++;
											}
											if($isSkip) {
												continue;
											}
											

											$cellColspan = (!empty($colspan) && $colspan > 0) ? $colspan : 1;
											echo "<td colspan='".$cellColspan."' class=".$bg_class." width=".$val['wid'].'%'."  style='".$bobtm.$txt_align.$isTotalValueExists.$isHead."'>".$item[$key]."</td>";
											
										}
										echo "</tr>";
										if (!empty($item['detparticulars']) && !empty($isDetparticulars)) {
											echo '<tr style="border-bottom:0.5pt solid gray;"><td style="border-bottom:0.5pt solid gray;" colspan='.count($heading).'>'.$item['detparticulars'].'</td></tr>';
										}
										if (!empty($attrs_row) && !empty($item['attrs'])) {
											echo '<tr style="border-bottom:0.5pt solid gray;"><td style="border-bottom:0.5pt solid gray;" colspan='.count($heading).'>'.strip_Tags($item['attrs']).'</td></tr>';
										}
	
										if (!empty($item['pen_trans'])) {
											
											echo '<tr><td colspan="2" class="nbt center aligned" >	
												<table>
														<tr>
																<td width="5%"><b>Date</b></td>
																<td width="10%"><b>#</b></td>
																<td width="35%"><b>Items</b></td>
																<td class="ar" width="10%"><b>Amount</b></td>';
																 if(!empty($isshowDueDate)){
																		echo '<td width="10%" class="ar"><b>'.(!empty($isshowDueDate) ? 'DueDate' : '').'</b></td>';
																}
																if(!empty($isshowDuedays)){
																	echo '<td class="ar" width="10%"><b>'.(!empty($isshowDuedays) ? 'DueDays' : '').'</b></td>';
																}
															if(!empty($isshowDuedays)){
																	echo '<td class="ar" width="10%"><b>'.(!empty($isShowtotAmount) ? 'TotAmount' : '').'</b></td>';
																}
																echo '<td width="10%" style="text-align: right;"><b>Balance</b></td>
														</tr>';
													foreach ($item['pen_trans'] as $row) {
														//$row['Amount'] = IND_money_format($row['Amount']);
														$row['dueDate'] = !empty($isshowDueDate)? $row['dueDate'] : '';
														$row['dueDays'] = !empty($isshowDuedays)? $row['dueDays'] : '';
														$row['totAmount'] = !empty($isShowtotAmount)? $row['totAmount'] : '';
														echo "<tr>
																		<td width='5%' style='text-align: left;'>".$row['tNo']."</td>
																		<td width='10%' > ".$row['tDate']."</td>
																		<td width='35%' style='white-space:nowrap;'>".$row['items']."</td>
																		<td  width='10%' style='text-align: right;'>".$row['Amount']."</td>";
																		 if(!empty($isshowDueDate)){
																				echo	"<td  width='10%' style='text-align: right;'>".$row['dueDate']."</td>";
																			}
																			if(!empty($isshowDuedays)){
																				echo "<td  width='10%' style='text-align: right;'>".$row['dueDays']."</td>";
																			}
																			if(!empty($isshowDuedays)){
																				echo "<td  width='10%' style='text-align: right;'>".$row['totAmount']."</td>";
																			}
																		echo"<td  width='10%' style='text-align: right;'>".$row['Amount']."</td>
																	</tr>";
													}
												echo '</table></td></tr>';
										}
									if (!empty($item['aging_det'])) {
											echo '<tr><td colspan="8" class="nbt center aligned" >
												<table class="ui fixed table cen_table" style="margin: 5px 0;">';
											$i = 0;
											foreach ($item['aging_det'] as $row) {
												echo "<tr>
														<td width='5%'></td>
														<td width='5%' style='text-align:left;padding:5px;'>".format_date($row['tDate'])."</td>
														<td width='10%' style='padding:5px;'>".$row['tNo']."</td>
														<td width='80%' style='white-space:nowrap;padding:5px;'>".$row['items']."</td>
														<td width='10%' style='text-align:right;padding:5px;'>".IND_money_format($row['dueAmount'])."</td>
														<td width='5%'></td>
													</tr>";

												$i++;
												if ($i % 20 == 0) {
													echo '</table></td></tr>';
													echo '<div style="page-break-after: always;"></div>';
													echo '<tr><td colspan="8" class="nbt center aligned" >
															<table class="ui fixed table cen_table">';
												}
											}
											echo '</table></td></tr>';
										}
									}
									if (!empty($lineTotalStock)) {
										echo "<tr>";
										echo "<td colspan='".(count($heading)-5)."'></td><td class='bott' style='border-top:1px solid black;font-size:13px'>".$lineTotalStock['contact']."</td><td class='bott' style='text-align:right;border-top:1px solid black;font-size:13px'>".$lineTotalStock['inqty']."</td><td class='bott' style='text-align:right;border-top:1px solid black;font-size:13px'>".$lineTotalStock['outqty']."</td><td></td><td></td>";
										echo "</tr>";
									}
									if (!empty($lineTotal)) {
										echo "<tr>";
										echo "<td colspan='".(count($heading)-$totalcol)."'></td><td class='bott' style='border-top:1px solid black;font-size:13px'>".(!empty($lineTotal['name']) ? $lineTotal['name'] : $lineTotal['tNo'])."</td><td class='bott' style='text-align:right;border-top:1px solid black;font-size:13px'>".$lineTotal['debit']."</td><td class='bott' style='text-align:right;border-top:1px solid black;font-size:13px'>".$lineTotal['credit']."</td>";
										if($totalcol == '4') {
											echo "<td class='bott' style='text-align:right;border-top:1px solid black;font-size:13px'></td>";
										}
										echo "</tr>";
									}
									//openbalance in cash/bank book
									if (!empty($totals_open) && empty($hide_footer) && empty($Outstandingtotals)) {
										echo "<tr>";
										foreach($heading as $key=>&$val) {
											$val['align'] =  !empty($val['align'])? $val['align'] : 'right';
											if (!isset($totals_open[$key])) {
												echo '<td style="
				border-right: none;
				border-left: none;border-top:1px solid black;"></td>';continue;
											}
											$style = ( is_numeric($totals_open[$key]) || $key =='dueAmount' || substr($totals_open[$key],0,1) == '(' || substr($totals_open[$key],-2) == 'Dr' || strpos($totals_open[$key], 'align="right"') !== false )?"text-align: right;":'';
											
											if($type!='ledDetail' && $type!='detail') {
												$totals_open[$key] = ($totals_open[$key]=='0.00') ? '' : $totals_open[$key];
												$style = 'text-align:'.$val["align"].';border-left:none;border-right:none';
											}
											else {
												$style = 'text-align:'.$val["align"].';border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none';
											}
											if(empty($isLedgerDetail)) {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' >".$totals_open[$key]."</td>";
											}
											else {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' ><b>".$totals_open[$key]."</b></td>";
											}
											
										}
										echo "</tr>";
									}
									//currentbalance in cash/bank book
									if (!empty($totals_current) && empty($hide_footer) && empty($Outstandingtotals)) {
										echo "<tr>";
										foreach($heading as $key=>&$val) {
											$val['align'] =  !empty($val['align'])? $val['align'] : 'right';
											if (!isset($totals_current[$key])) {
												echo '<td style="
				border-right: none;
				border-left: none;border-top:1px solid black;"></td>';continue;
											}
											$style = ( is_numeric($totals_current[$key]) || $key =='dueAmount' || substr($totals_current[$key],0,1) == '(' || substr($totals_current[$key],-2) == 'Dr' || strpos($totals_current[$key], 'align="right"') !== false )?"text-align: right;":'';
											
											if($type!='ledDetail' && $type!='detail') {
												$totals_current[$key] = ($totals_current[$key]=='0.00') ? '' : $totals_current[$key];
												$style = 'text-align:'.$val["align"].';border-left:none;border-right:none';
											}
											else {
												$style = 'text-align:'.$val["align"].';border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none';
											}
											if(empty($isLedgerDetail)) {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' >".$totals_current[$key]."</td>";
											}
											else {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' ><b>".$totals_current[$key]."</b></td>";
											}
											
										}
										echo "</tr>";
									}

									if (!empty($totals) && empty($hide_footer) && empty($Outstandingtotals)) {
										echo "<tr>";
										foreach($heading as $key=>&$val) {
											$val['align'] =  !empty($val['align'])? $val['align'] : 'right';
											if (!isset($totals[$key])) {
												echo '<td style="
				border-right: none;
				border-left: none;border-top:1px solid black;"></td>';continue;
											}
											$style = ( is_numeric($totals[$key]) || $key =='dueAmount' || substr($totals[$key],0,1) == '(' || substr($totals[$key],-2) == 'Dr' || strpos($totals[$key], 'align="right"') !== false )?"text-align: right;":'';
											
											if($type!='ledDetail' && $type!='detail') {
												$totals[$key] = ($totals[$key]=='0.00') ? '' : $totals[$key];
												$style = 'text-align:'.$val["align"].';border-left:none;border-right:none';
											}
											else {
												$style = 'text-align:'.$val["align"].';border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none';
											}
											if(empty($isLedgerDetail)) {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' >".$totals[$key]."</td>";
											}
											else {
												echo "<td style='text-align:".$val['align'].";border-top:1px solid black;border-bottom:1px solid black;border-left:none;border-right:none' ><b>".$totals[$key]."</b></td>";
											}
											
										}
										echo "</tr>";
									}
									if(!empty( $compareCount)) {
										echo '<tr>';
												echo '<th style="text-align:center">Total</th>';
												if(!empty($parentCategory)) {
													echo '<th class="tc" style="border-top:1px solid black"></th>';
												}
															if($compareCount <= 1){
											if($avgRateInc) {
												$cols = ($amountInc) ? 4 : 3;
											} else {
											$cols = ($s_qty && $avgRate) ? 2 : 2;
											}
									}else{
											
											$cols = ($s_qty && $avgRate) ? 2 : 1;
									}
												
												$styles="text-align:right;";
												if($compareCount > 1)  {
													if($avgRateInc) {
												$cols = 2;
											} else {
												$styles="";$cols = 1;
											}
													
												}
												for($x = 0;$x <= ($compareCount);$x++) {
													echo '<th colspan="1" style="'.$styles.'">'.$totals['s_qty_'.$x].'</th>';
													echo '<th colspan="'.$cols.'" style="'.$styles.'">'.$totals['s_amount_'.$x].'</th>';
												}
												
										echo '</tr>';
									}
									if(!empty($grand_total)) {
										echo "<tr>";
										foreach($heading as $key=>$val) {
											if (!isset($grand_total[$key])) {
												echo '<td style="
				border-bottom:1px solid black;border-right: none;
				border-left: none;"></td>';continue;
											}
											$style = ( is_numeric($grand_total[$key]) || $key =='dueAmount' || substr($totals[$key],0,1) == '(' || substr($grand_total[$key],-2) == 'Dr' || strpos($grand_total[$key], 'align="right"') !== false )?"text-align: right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;
				border-left: none;":'';
											
											if($type!='ledDetail' && $type!='detail')
												$grand_total[$key] = ($grand_total[$key]=='0.00') ? '' : $grand_total[$key];
												
											echo "<td  style='".$style."'>".$grand_total[$key]."</td>";
											
										}
										echo "</tr>";
									}
								if(isset($sideHeader) && $sideHeader == 'Batch-Wise Stock'){
									echo "<tr><td colspan='" . (3+ count($attributes)) . "' style='text-align:right;border-top:1px solid #000000;
									border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Total as on " . $to_date . "</b></td>";
									echo "<td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'>" . $total['p_qty'] . "</td>";
									echo "<td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'>" . $total['s_qty'] . "</td>";
									echo "<td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'>" . $total['b_qty'] . "</td>";
									echo "<td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'></td>";
									echo "<td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'>" . $total['amount'] . "</td>";
									echo "<td colspan='7' style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'></td></tr>";
								}
								if (isset($total) && !(isset($sideHeader) && $sideHeader == 'Batch-Wise Stock') && (!$isDetail) &&( $type!='pl_bs' && $type!='salesdetail' && !$isLedger)) {
									echo "<tr><td colspan='".(count($heading)-1)."' style='text-align:right;border-top:1px solid #000000;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Total Amount</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td></tr>";
								}
							
								if(!empty($Outstandingtotals))
								{	
									echo "<tr><td colspan='2' style='border-top:1px solid #000000;border-bottom:1px solid black;'>".$Outstandingtotals['tDate']."</td>";
									echo "<td colspan='2' style='border-top:1px solid #000000;border-bottom:1px solid black;'>".$Outstandingtotals['tType']."</td>";
									echo "<td colspan='2' style='border-top:1px solid #000000;border-bottom:1px solid black;'>".$Outstandingtotals['tNo']."</td>";
									echo "<td colspan='2' style='border-top:1px solid #000000;border-bottom:1px solid black;'>".$Outstandingtotals['totAmount']."</td></tr>";	
									if(!empty($heading) && count($heading) > 8){
										echo "<td colspan='2' style='border-top:1px solid #000000;border-bottom:1px solid black;'></td></tr>";	
									}
								}
							

								if(isset($isDetail) && ($sideHeader == 'Ledger')){
												echo "<tr><td colspan='".(count($heading)-2)."' style='text-align:right;border-top:none;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Closing Balance</b></td><td style=' text-align:right;border-top:none;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'></td></tr>";		
												echo "<tr><td colspan='".(count($heading)-2)."' style='text-align:right;border-top:none;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Closing Balance</b></td><td style=' text-align:right;border-top:none;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'></td></tr>";		
									}																		
									if (isset($isDetail) &&( $file_name == 'customer_sales_summary'||  $file_name=='purchase_supplier_summary')) {
									echo "<tr><td colspan='".(count($heading)-2)."' style='text-align:right;border-top:1px solid #000000;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Total Amount</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:none;border-right: none;border-left: none;font-size:13px;'></td></tr>";
									echo "<tr><td colspan='".(count($heading)-2)."' style='text-align:right;border-top:none;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Closing Balance</b></td><td style=' text-align:right;border-top:none;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'></td></tr>";
								}
				
								if (isset($isDetail) && ($file_name =='sales_register_summary'|| $file_name == 'purchase_register_summary')) {
									echo "<tr><td colspan='".(count($heading)-1)."' style='text-align:right;border-top:1px solid #000000;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Total Amount</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td></tr>";
									echo "<tr><td colspan='".(count($heading)-1)."' style='text-align:right;border-top:none;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Closing Balance</b></td><td style=' text-align:right;border-top:none;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td></tr>";
								}
					
								if (isset($total) && $type=='salesdetail') {
									echo "<tr><td colspan='".(count($heading)-2)."' style='text-align:right;border-top:1px solid #000000;
border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>Total Amount</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$total</b></td><td style=' text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;font-size:13px;'><b>$duetotal</b></td></tr>";
								}
									echo "</tbody>";
								}
							} 
						}?>
				</table>
<?php 
if (!empty($aging_det)) {
	$agingItems = !empty($aging_det['items']) ? $aging_det['items'] : [];
	$intervalRanges = !empty($aging_det['intervalRanges']) ? $aging_det['intervalRanges'] : [];
	$roundKeys = !empty($aging_det['round_keys']) ? $aging_det['round_keys'] : [];
	$isTypeT = (!empty($aging_det['rpType']) && $aging_det['rpType'] == 'T');
	$isCustomer = (!empty($aging_det['csType']) && $aging_det['csType'] == 'C');
	$agingBasis = !empty($aging_det['agingBasis']) ? strtolower($aging_det['agingBasis']) : 'duedate';
	$showIntervalCurrency = !empty($aging_det['showIntervalCurrency']);
	$currencySymbol = !empty($aging_det['currencySymbol']) ? $aging_det['currencySymbol'] : '';

	$intervalLabels = [];
	foreach ($intervalRanges as $range) {
		if (!empty($range['label'])) {
			if ($isTypeT && strtolower($range['label']) == 'current') {
				continue;
			}
			$intervalLabels[] = $range['label'];
		}
	}

	$displayColumns = [];
	$intervalLabelIndex = 0;
	foreach ($roundKeys as $key) {
		if ($key == 'tot_balance') {
			continue;
		}
		if ($isTypeT && ($key == 'rec_cur' || $key == 'oth_balance')) {
			continue;
		}

		if ($key == 'oth_balance') {
			$label = 'Others';
		} elseif ($key == 'rec_cur') {
			$label = !empty($intervalLabels[$intervalLabelIndex]) ? $intervalLabels[$intervalLabelIndex] : 'Current';
			$intervalLabelIndex++;
		} elseif (strpos($key, 'rec_') === 0) {
			$label = !empty($intervalLabels[$intervalLabelIndex]) ? $intervalLabels[$intervalLabelIndex] : ucfirst(str_replace('_', ' ', $key));
			$intervalLabelIndex++;
		} else {
			$label = ucfirst(str_replace('_', ' ', $key));
		}

		$displayColumns[] = ['key' => $key, 'label' => $label];
	}

	$displayColumns[] = ['key' => 'tot_balance', 'label' => 'Acc. Balance'];
	$colCount = !empty($displayColumns) ? count($displayColumns) : 1;
	$colWidth = (100 / $colCount) . '%';
	echo '<br>';
	if ($isTypeT) {
		$dayLabel = ($agingBasis === 'transdate') ? 'Trans Days' : 'Over Due Days';
		$aging_heading = $isCustomer ? ('Aging Receivables (' . $dayLabel . ')') : ('Aging Payables (' . $dayLabel . ')');
		
		echo '<div style="font-weight:bold; font-size:14px; padding:6px 0;">' . $aging_heading . '</div>';
	}

	echo '<table width="100%" style="table-layout:fixed; border-collapse:collapse;" border="0" cellpadding="0" cellspacing="0" class="middlecol">';
	echo '<thead><tr>';
	foreach ($displayColumns as $column) {
		$headLabel = $column['label'];
		if ($showIntervalCurrency && $column['key'] !== 'tot_balance') {
			$headLabel .= ' (' . $currencySymbol . ')';
		}
		echo '<th style="text-align:right; font-size:11px; padding:4px 2px; border-bottom:1px solid #000;">' . $headLabel . '</th>';
	}
	echo '</tr></thead>';

	echo '<tbody>';
	foreach ($agingItems as $agingRow) {
		echo '<tr>';
		foreach ($displayColumns as $column) {
			echo '<td style="text-align:right; font-size:11px; padding:3px 2px; vertical-align:middle;">' . (!empty($agingRow[$column['key']]) ? $agingRow[$column['key']] : '') . '</td>';
		}
		echo '</tr>';
	}
	echo '</tbody>';
	echo '</table>';
}
?>



				<?php  if($type== 'stockAlert' || $file_name == 'bank_ledger' || $file_name == 'aging_summary'||$file_name == 'daybook'||  $file_name == 'Stock Category'||  $file_name == 'Sales Rep.Analysis Summary'|| $file_name == 'Sales Rep.Analysis Details'||$file_name =='ratesheet_options' || $file_name == 'pend_ord_list') echo "<div style='border-top:0.5px solid grey;border-right: none;border-left: none;'></div>"?>			
			</div>
		</div>
		<?php if (!empty($dispatch_total)) {
				echo '<div  width="100%" style="margin-right:auto;margin-left:auto;border-top:1px solid black"><br>';
				echo '<div>Invoices ['.$dispatch_total['cnt'].']'.(!empty($ranges)?' : '.$ranges:'').'</div>';
				echo '<div>Total Inv. Value : '.$dispatch_total['itemTotal'].'</div>';
				echo '</div>';
			} ?>
		<div style="float: right;width: 100%;">
			<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class=""  bordercolor="#e5e5e5">
				<tr>
					<?php if(isset($tot2)) { ?>
						<td><table bordercolor="#ffffff"  cellspacing="0" cellpadding="0" class="middlecol" style="width:100%;"><col style="width:50%;"/><col style="width:25%;" align="right"/><col style="width:25%;" align="right"/><tr><td style="border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"><b>Total <?php if(!empty($branchName)) { echo 'for '.$branchName; } ?></b></td><td style="border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"></td><td style="text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"><b>{tot2}</b></td></tr></table></td>
					<?php } ?>
					<?php if(isset($tot1)) { ?>
						<td><table bordercolor="#ffffff"  cellspacing="0" cellpadding="0" class="middlecol" style="width:100%;"><col style="width:50%;"/><col style="width:25%;" align="right"/><col style="width:25%;" align="right"/><tr><td style="border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"><b>Total <?php if(!empty($branchName)) { echo 'for '.$branchName; } ?></b></td><td style="border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"></td><td style="text-align:right;border-top:1px solid #000000;border-bottom:1px solid black;border-right: none;border-left: none;"><b>{tot1}</b></td></tr></table></td>
					<?php } ?>
				</tr>
			</table>
		</div>
	
    
	
	<?php if(!empty($export_data)) { 
		foreach($export_head as $key => $gstr9item){
	?>
			<br><div style="font-weight:bold;font-style:italic;color:grey;font-size:13px;"> <?php echo $gstr9_head[$key]; ?></div><br>
		<?php
			if(isset($export_head[$key])){
				echo '<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot alltable"  bordercolor="#e5e5e5">';
				echo "<thead>";
					echo "<tr>";
						if($key == '17') {
							echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['hsn_sc']['name']."</th>";
							// echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['desc']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['uqc']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['qty']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['txval']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['taxRate']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['iamt']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['camt']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['samt']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['csamt']['name']."</th>";
						}else if($key == '18') {
							echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['itemHS']['name']."</th>";
							// echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['itemDesc']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['unit']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['qty']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['taxamt']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['taxRate']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['igst']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['cgst']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['sgst']['name']."</th>";
							echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['cess']['name']."</th>";
						}else{
							echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['name']['name']."</th>";
							if($key == '6')
								echo "<th class='headgst' style='padding:3px;text-align: left;'>".$gstr9item['type']['name']."</th>";
							if($key != '6' && $key != '7' && $key != '8' && $key != '15')
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['taxableAmount']['name']."</th>";
							if($key == '9' || $key == '14')
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['taxPaid']['name']."</th>";
							if($key != '14'){
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['igst']['name']."</th>";
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['cgst']['name']."</th>";
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['sgst']['name']."</th>";
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['cess']['name']."</th>";
							}
							if($key == '15'){
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['interest']['name']."</th>";
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['penalty']['name']."</th>";
								echo "<th class='headgst' style='padding:3px;text-align: right;'>".$gstr9item['latefee']['name']."</th>";
							}
						}
					echo"</tr>";
				echo"</thead>";
				echo "<tbody>";
					foreach($export_data[$key] as $item_data){ 	
						echo '<tr class="head">';
						if($key == '17'){
							echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['hsn_sc']."</td>";
							// echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['desc']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['uqc']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['qty']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['txval']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['taxRate']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['iamt']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['camt']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['samt']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['csamt']."</td>";
							// exit;
						}else if($key == '18'){
							echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['itemHS']."</td>";
							// echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['itemDesc']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['unit']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['qty']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['taxableamt']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['taxRate']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['igst']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['cgst']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['sgst']."</td>";
							echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['cess']."</td>";
						}else{			
							if($key != '6')	echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['name']."</td>";
							if($key == '6'){
								if (isset($item_data["types"]) && is_array($item_data["types"])) {
									$index = 0;									
									foreach ($item_data["types"] as $type) {
										if($index>0){
											echo '</tr>';
											echo '<tr class="head">';
										}
										if($index==0) echo "<td class='headgst' rowspan='".count($item_data["types"])."' style='padding:3px;text-align: left;'>".$item_data['name']."</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>".$item_data[$type . '_type']."</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_igst']) ? $item_data[$type . '_igst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_cgst']) ? $item_data[$type . '_cgst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_sgst']) ? $item_data[$type . '_sgst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_cess']) ? $item_data[$type . '_cess'] : "") . "</td>";
										$index++;
									}	
								}else{
									echo "<td class='headgst' style='padding:3px;text-align: left;'>".$item_data['name']."</td>";
									echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>".$item_data['type']."</td>";
								}
							}
							if($key != '6' && $key != '7' && $key != '8' && $key != '15')
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['taxableAmount']."</td>";
							if($key == '9' || $key == '14')
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['taxPaid']."</td>";
							if($key != '14'){
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['igst']."</td>";
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['cgst']."</td>";
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['sgst']."</td>";
								echo "<td class='headgst' style='padding:3px;text-align: right;'>".$item_data['cess']."</td>";
							}
							if($key == '15'){
								echo "<td  class='headgst' style='padding:3px;text-align: right;'>".$item_data['interest']."</td>";
								echo "<td  class='headgst' style='padding:3px;text-align: right;'>".$item_data['penalty']."</td>";
								echo "<td  class='headgst' style='padding:3px;text-align: right;'>".$item_data['latefee']."</td>";
							}
						}
					}
					/*if (isset($item_data["types"]) && is_array($item_data["types"])) {
									$index = 0;									
									foreach ($item_data["types"] as $type) {
										echo '<tr class="head">';
										if($index==0) echo "<td class='headgst' rowspan='".count($item_data["types"])."' style='padding:3px;text-align: left;'>".$item_data['name']."</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>".$item_data[$type . '_type']."</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_igst']) ? $item_data[$type . '_igst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_cgst']) ? $item_data[$type . '_cgst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_sgst']) ? $item_data[$type . '_sgst'] : "") . "</td>";
										echo "<td class='headgst' width='10%' style='padding:3px;text-align: right;'>" . (isset($item_data[$type . '_cess']) ? $item_data[$type . '_cess'] : "") . "</td>";
										echo"</tr>";	
										$index++;
									}									
								}
								*/
					// if(isset($export_detail[$key])){
					// 	foreach ($export_detail[$key] as $itemdetail) {
					// 		echo '<tr>';
					// 		echo "<td  width='8%' style='text-align: left'>". $itemdetail['idt'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: left'>". $itemdetail['inum'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: left'>". $itemdetail['cname'] ."</td>";
					// 		echo "<td  width='12%' style='text-align: left'>". $itemdetail['conTaxNo'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['txval'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['rt'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['igst'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['cgst'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['sgst'] ."</td>";
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['cess'] ."</td>";
					// 		if(isset($itemdetail['itemTotal'])){
					// 			echo "<td  width='8%' style='text-align: right'>". $itemdetail['itemTotal'] ."</td>";
					// 		}
					// 		echo "<td  width='8%' style='text-align: right'>". $itemdetail['val'] ."</td>";
					// 		echo '</tr>';
					// 	}
					// 	echo '<tr class="borderbttom"><td colspan="12"></td></tr>';

					// }			
				echo '</tbody></table>';
				// echo '';
			}
			
		}
		// exit;
	}
	?>
		<!---3.1 summary ------------------>
		<?php if (!empty($head_3)) { ?>
		<br><div style="font-weight:bold;font-style:italic;color:grey;font-size:13px;">3.1 Detail of Outward Supplies and Inward supplies liable to reverse charges</div><br>
		<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot"  bordercolor="#e5e5e5">
		<!--	<col style="width:31%;" align="left"/><col style="width:15%;" align="right"/><col style="width:15%;" align="right"/>	<col style="width:14%;" align="right"/><col style="width:14%;" align="right"/>	<col style="width:12%;" align="right"/>-->
			<?php
				if (!empty($head_3)) {
					echo "<thead>";
					echo "<tr>";
					foreach($head_3 as $key=> &$val) {
							if(!empty($key) && ($key== 'name')){
								$gstr3sum="text-align: left";
							}
							else{
								$gstr3sum="text-align: right";
							}
						echo "<th  width=".$val['wid']." class='headgst' style='padding:3px;".$gstr3sum."'>".$val['name']."</th>";
					}
					echo"</thead>";
					echo "</tr>";
						if ($head_3_val) {
						echo "<tbody>";
						foreach ($head_3_val as $item) {
							echo "<tr>";
							foreach($head_3 as $key=> &$val) {
								if(!empty($key) && ($key== 'name')){
									$gstr3sum="text-align: left";
								}
								else{
									$gstr3sum="text-align: right";
								}
								$style = (is_numeric($item[$key])||empty($item[$key]))? "style='text-align:right;padding:3px;'" : 'padding:3px;' ;
									if(!empty($type == 'gstr3')){
													$item[$key] = (empty($item[$key])) ? '-' : $item[$key];
								}
								echo "<td width=".$val['wid']." style='padding:3px;".$gstr3sum."'>".$item[$key]."</td>";
									
							}
							echo "</tr>";
						}
						echo "</tbody>";
					}
				}
			?>
		</table>
		<?php if (!empty($arr_32)) { ?>
		<br><div style="font-weight:bold;font-style:italic;color:grey;font-size:13px;">3.2 Of the supplies shown in 3.1 (a) above, details of inter-State supplies made to unregistered persons,composition taxable persons and UIN holders</div><br>
		<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot"  bordercolor="#e5e5e5">	
			<?php
				if (!empty($head_3)) {
					echo "<thead>";
						echo '<tr><th   class="headgst " rowspan="2">Place of Supply (State/UT)</th>
									<th colspan="2"   class="headgst boleft" style="text-align:center">Supplies made to Unregistered Persons</th>
									<th colspan="2"  class="headgst boleft" style="text-align:center">Supplies made to Composition Taxable Persons</th>
									<th colspan="2"  class="headgst boleft" style="text-align:center">Supplies made to UIN Holders</th>
									
							</tr>';
						echo '<tr >
								
								<th class="headgst boleft " style="padding:3px">Total Taxable Value</th>
								<th class="headgst" style="text-align:right;padding:3px">Amount of Integrated Tax </th>
								<th class="headgst boleft" style="text-align:right;padding:3px">Total Taxable Value</th>
								<th class="headgst" style="text-align:right;padding:3px" >Amount of Integrated Tax </th>
								<th class="headgst boleft" style="text-align:right;padding:3px">Total Taxable Value</th>
								<th class="headgst" style="text-align:right;padding:3px"  >Amount of Integrated Tax </th>
								
						</tr>';
					echo"</thead>";
					echo "<tbody>";
						foreach ($arr_32 as $arr_key => $arr_val) {
							
							echo "<tr>";
								echo '<td class="pad-3" style="padding:3px;">';echo !empty($arr_val['name']) ? $arr_val['name'] : '';echo '</td>';
								echo '<td class="ar pad-3"  style="padding:3px;">';echo !empty($arr_val['taxRate']) ? $arr_val['taxRate'] : '';echo '</td>';
								echo '<td class="ar pad-3" style="padding:3px;">';echo !empty($arr_val['taxableAmount']) ? $arr_val['taxableAmount'] : '';echo '</td>';
								echo '<td class="ar pad-3" style="padding:3px;">';echo !empty($arr_val['IGSTtaxValue']) ? $arr_val['IGSTtaxValue'] : '';echo '</td>';
								echo '<td class="ar pad-3" style="padding:3px;">';echo !empty($arr_val['CGSTtaxValue']) ? $arr_val['CGSTtaxValue'] : '';echo '</td>';
								echo '<td class="ar pad-3" style="padding:3px;">';echo !empty($arr_val['SGSTtaxValue']) ? $arr_val['SGSTtaxValue'] : '';echo '</td>';
							echo "</tr>";
						}
					echo "</tbody>";
					
						
					
				}
			?>
		</table>
		<?php } ?>
		<?php } ?>
		<!---4 summary ------------------>
		<?php if (!empty($head_4)) { ?>
		<br><div style="font-weight:bold;font-style:italic;color:grey;font-size:13px;">4 Eligible ITC</div><br>
		<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot"  bordercolor="#e5e5e5">
			<col style="width:27%;" align="left"/><col style="width:15%;" align="right"/><col style="width:20%;" align="right"/>	<col style="width:19%;" align="right"/><col style="width:19%;" align="right"/>	
			<?php
				if (!empty($head_4)) {
					echo "<thead>";
					echo "<tr>";
					foreach($head_4 as $key=> &$val) {
						if(!empty($key) && ($key== 'name')){
							$gstr3first="text-align: left";
						}
						else{
							$gstr3first="text-align: right";
						}
						echo "<th  width=".$val['wid']." class='headgst' style='padding:3px;".$gstr3first."'>".$val['name']."</th>";
					}
					echo "</thead>";
					echo "</tr>";
						if ($head_4_val) {
						echo "<tbody>";
						foreach ($head_4_val as $item) {
							
							echo "<tr>";
							foreach($head_4 as $key=> &$val) {
								if(!empty($key) && ($key== 'name')){
									$gstr3first="text-align: left";
								}
								else{
									$gstr3first="text-align: right";
								}
								$style = (is_numeric($item[$key])||empty($item[$key])) ? "style='padding:3px;'":'padding:3px;';
								if(!empty($type == 'gstr3')){
													$item[$key] = (empty($item[$key])) ? '-' : $item[$key];
								}
								echo "<td width=".$val['wid']." style='padding:3px;".$gstr3first."'>".$item[$key]."</td>";
									
							}
							echo "</tr>";
						}
						echo "</tbody>";
					}
				}
			?>
		</table>
		<?php } ?>

		<!--Nil summary-->
		<?php if (!empty($docValue)) { ?>
		<br>
		<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot nil"  >
			<?php 
				if (!empty($docHeading)) {
					echo "<thead>";
					echo "<tr>";
					foreach($docHeading as $key=> &$val) {
							
							$gstrfirst="text-align: right";
							if($key == 'categoryCode' || $key == 'code') {
								$gstrfirst = "text-align: left";
							}
							echo "<th width=".$val['wid']."class='headgst'  style=' border-top:1px solid #000000;
		border-bottom:1px solid #000000;padding:3px;".$gstrfirst."'>".$val['name']."</th>";
					}
					
					
					echo "</tr>";
					echo "</thead>";
						if ($docValue) {
						echo "<tbody>";
						echo "<br>";
						foreach ($docValue as $item) {
							echo "<tr>";
							foreach($docHeading as $key=> &$val) {
								
								$gstrfirst="text-align: right";
								if($key == 'categoryCode' || $key == 'code') {
									$gstrfirst = "text-align: left";
								}
								echo "<td width=".$val['wid']." style='padding:3px;".$gstrfirst."'>".$item[$key]."</td>";
							}
							
							echo "</tr>";
						}
						echo "</tbody>";
					}
				}
			?>
		</table>
		<?php } ?>
		<!--Nil summary-->
		<?php if (!empty($nilHeading)) { ?>
		<br><!--<div class="tophead">Nil summary</div>-->
		<table border="0"  cellspacing="0" cellpadding="0" style="width:100%;table-layout:fixed;font-size:10pt" class="gstr_foot nil"  >
			<?php 
				if (!empty($nilHeading)) {
					echo "<thead>";
					echo "<tr>";
					foreach($nilHeading as $key=> &$val) {
							
							$gstrfirst="text-align: right";
							if($key == 'categoryCode' || $key == 'code') {
								$gstrfirst = "text-align: left";
							}
							echo "<th width=".$val['wid']."class='headgst'  style=' border-top:1px solid #000000;
		border-bottom:1px solid #000000;padding:3px;".$gstrfirst."'>".$val['name']."</th>";
					}
					
					
					echo "</tr>";
					echo "</thead>";
						if ($nilValue) {
						echo "<tbody>";
						echo "<br>";
						foreach ($nilValue as $item) {
							echo "<tr>";
							foreach($nilHeading as $key=> &$val) {
								/*$style = ( is_numeric($item[$key])|| (empty($item[$key])) || substr($item[$key],0,1) == '(' || substr($item[$key],-2) == 'Dr' || strpos($item[$key], 'align="right"') !== false )?"style='text-align:right;padding:3px;'":'padding:3px;';
								if(!empty($type == 'gstrsummary')||!empty($type == 'gstr3') ){
													$item[$key] = (empty($item[$key])) ? '-' : $item[$key];
								}*/
								$gstrfirst="text-align: right";
								if($key == 'categoryCode' || $key == 'code') {
									$gstrfirst = "text-align: left";
								}
								echo "<td width=".$val['wid']." style='padding:3px;".$gstrfirst."'>".$item[$key]."</td>";
							}
							
							echo "</tr>";
						}
						echo "</tbody>";
					}
				}
			?>
		</table>
		<?php } ?>
	</div>
	<?php if(!empty($bankDetail)) { ?>
	<htmlpagefooter name="last_page_footer" >
		<div class="last_page_footer" style="height:2cm">
		<br>
		<table border="" width="100%" style="font-size:20px !important">
			<tr> 
				<td width="50%">
					<table class="bank accInfo noborder nopadding nwrap" border="0" cellspacing="0" cellpadding="0"  >
						<tbody>
							<tr>
								<td class="wrp" colspan="2">
									<p class="bank title nm">Our Bank Details</p>
								</td>
							</tr>
							<tr>
								<td class="accNumber title wrp" style="width:25%">Account No</td>
								<td class="accNumber value wrp">&nbsp;: <b><?php echo $bankDetail['accNumber']; ?></b></td>
							</tr>
							<?php if(!empty($bankDetail['bankAccName'])) { ?>
							<tr>
								<td class="accName title wrp">Account Name</td>
								<td class="accName value wrp">&nbsp;: <b><?php echo $bankDetail['bankAccName']; ?></b></td>
							</tr>
							<?php } ?>
							<tr>
								<td class="bankName title wrp">Bank</td>
								<td class="bankName value wrp">&nbsp;: <b><?php echo $bankDetail['bankName']; ?></b></td>
							</tr>
							<tr>
								<td class="branch title wrp">Branch</td>
								<td class="branch value wrp">&nbsp;: <b><?php echo $bankDetail['branchName']; ?></b></td>
							</tr>
							<tr>
								<td class="ifsc title wrp">IFSC Code</td>
								<td class="ifsc value wrp">&nbsp;: <b><?php echo $bankDetail['ifscRouteCode']; ?></b></td>
							</tr>
							
						</tbody>
					</table>
				</td>
				<td width="50%" class="ar vab" valign="bottom">
					<br><br><br>
					Authorized Signature
				</td>
			</tr>
		</table>
	</div>
</htmlpagefooter>
<sethtmlpagefooter name="last_page_footer" value="1" />
<?php } ?>
	<!--<htmlpageheader name="otherpages" style="display:none">
		<?php if($type == 'ledDetail') { ?>
		<div style="text-align:left;display:inline-block;" width="80%"><?php echo strtoupper($summaryName); ?> Ledger <?php echo $from_date; ?> - <?php echo $to_date; ?></div>
		<?php } ?>
		<div width="20%"></div>
	</htmlpageheader>-->
	<!--<htmlpagefooter name="foot">
		<div style="border-top:0.5px solid black;padding-bottom:20px;line-height:10px;"></div>
	</htmlpagefooter>->
	<htmlpagefooter name="LastPageFooter">
   		<div style="border-top:none"></div>
	</htmlpagefooter>
	<sethtmlpagefooter name="LastPageFooter" value="1" />
	<!--<sethtmlpageheader name="firstpage" value="on" show-this-page="1" />
	<sethtmlpageheader name="otherpages" value="on" show-this-page="2" />-->
	<!--<htmlpagefooter name="foot">
		<div style="border-top:0.5px solid black;padding-bottom:20px;line-height:10px;">{PAGENO} / {nb}</div>
	</htmlpagefooter>
	<htmlpagefooter name="LastPageFooter">
   		<div style="border-top:none">{PAGENO} / {nb}</div>
	</htmlpagefooter>
	<sethtmlpagefooter name="LastPageFooter" value="1" />
	<?php if(!isset($pdf_type) || $pdf_type=='I') { ?>
		<page_footer></page_footer>
	<?php } ?>
	<!--<sethtmlpageheader name="firstpage" value="on" show-this-page="1" />
	<sethtmlpageheader name="otherpages" value="on" />-->
	<style>
	
	.pdf_head h3, .pdf_head h4 {
		text-align:center;
		margin:10px;
		padding:10px;
	}
	.middlecol{
		color:#000;
		width: 100%;
		height: 60%;
	}
	.middlecol th{
		<?php if($type != 'gstrsummary' && $type != 'gstr2sum' && $type != 'b2b' && $type != 'cdnr' && $type != 'exp' && $type != 'exemp' && $type !='hsn' && $type != 'b2cl' && $type != '13' && $type != 'b2cs' && $type != '4B' && $type != 'gstr3det') { ?>
		/*background: #208ED3; */
		/*font-size:9px !important;*/
		/*color:#FFF;*/
		font-weight:bold;
		<?php } ?>
		<?php if($type == 'gstrsummary' || $type == 'gstr2sum' || $type == 'b2b' || $type == 'cdnr' || $type == 'exp' || $type == 'exemp' || $type == 'hsn' || $type == 'b2cl' || $type == '13' || $type == 'b2cs' || $type == '4B' || $type == 'gstr3det') { ?>
		
		
		border:1px solid #f2f2f2 ;
		<?php } ?>
		text-align:right;
		<?php if($type != 'gstr1all' && $type != 'gstr3all') { ?> background: #e5e5e5; <?php } ?>
		vertical-align: middle;
		padding: 5px;
	}
	.middlecol tr.odd{
		background:#EAEAEA;
	}
	 tr.back{
		background:#e5e5e5;
	}
	.gstr_head td,.gstr_foot td,{
		padding-right:10px !important;
		padding: 8px !important;
		border-color:#e5e5e5;
	}
	.middlecol tr.even{
		background:#FFFFFF;
	}
	.middlecol td{
		
		padding-top: 3px !important;
		
		
		
	}
	
	/*.headbod {
		border-top:1px solid #000000;
		border-bottom:1px solid black;
		border-right: none;
		border-left: none;
	}<?php if($type != 'gstr1all' && $type != 'gstr3all') { ?> background: #e5e5e5; <?php } ?>*/

	
	.botop { 
		border-top:1px solid black !important;
		/*background: #e5e5e5;*/
	}
	<?php if (!empty($bookmark_title)) { ?>
		.middlecol th{
			border-top:0.2px solid #999;
			border-bottom:0.2px solid #999;
			background:none !important;
			text-align:center;
			color:#000;
		}
		/* .middlecol{
			color:#000 !important;
		} */
		hr{
			border-width: 0.2px;
		}
		
		
		span{
			color:#000 !important;
		}
	<?php } ?>
	
	
	/** {
		font-size:12px;
		
	}*/
	
	

<?php if($type == 'salesdetail') { ?>


<?php } ?>
@page {
	size:auto;
	/*header: html_otherpages;*/
/*	footer: html_foot;*/
}

@page :first {
   /* header: html_firstpage;*/
	/*footer: html_firstpagefooter;*/
}
tr,.pg {
  page-break-inside: avoid !important; 
}
/*td {
	overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
white-space: nowrap;
max-width:83mm;
}*/
th {
	/*white-space: nowrap !important;
	font-size:12px;*/
	
}


div {
	 position: static;
}
td {
	vertical-align : top !important;
	
}


<?php if(!empty($comp_length)) { ?>
	<?php if(!empty($comp_length) && !empty($plbstb_type)) { ?>
		<?php if($plbstb_type == 'T') { ?>
		.middlecol td:nth-child(2n+3),th:nth-child(2n+3) {
			border-left: 1px solid #efefef !important;
		}
		<?php } ?>
		.middlecol td:nth-child(2n+2), th:nth-child(2n+2) {
		  border-left: 1px solid rgb(212, 212, 213);
		}
	<?php } ?>
<?php } ?>
<?php if(!empty($compareCount) && $compareCount >= 1) { ?>
.middlecol td:nth-child(2n+3),.middlecol th:nth-child(2n+3) {
			border-left: 1px solid #efefef !important;
		}
.middlecol td:nth-child(2n+2),.middlecol th:nth-child(2n+2) {
		  border-left: 1px solid rgb(212, 212, 213);
		}
<?php } ?>
<?php if(!empty($isCog)) { ?>
	.middlecol td:nth-child(2),.middlecol th:nth-child(2) {		
		  border-right: 1px solid rgb(212, 212, 213) !important;
	}
<?php } ?>

.sub_table tr{
width: auto;
}
.head_sub_table tr th {	
	font-size : 9px;
	padding:2px;
	table-layout: fixed;
	display: inline-block !important;
	border-top: solid 0.1px  #cccccc !important;
	border-bottom : none !important;
	text-align : left !important;
}
th {
	
	font-size : 13px !important;
}
.middlecol .isTot td{
	
	border-top:1px solid #000000 !important;
	border-bottom:1px solid #000000 !important;
	border-right: none !important;
	border-left: none !important
}
td.bobottom {
	border-bottom : 1px solid #000000 !important;
}
td.ar {	
	text-align: right !important;
}
.headgst {
	border-top:1px solid #000000;
	border-bottom:1px solid #000000;
}
.bordertop {
	border-top:1px solid black !important;
}
* {
	font-size:12px !important;
}
.fwn {
	font-weight: normal;
	font-size:10px !important;
}
.ar {
	text-align: right !important
}
.boleft {
	border-left : 1px solid grey !important;
}
.pad-3 {
	padding:3px !important;
}
.red_bg {
	background: #fff6f6!important;
	color: #9f3a38!important;
}
.green_bg {
	color: green;
	/* background: green; */
	background: #e7f6e7;
}
.tc {
	text-align : center !important;
}
.vab {
	vertical-align : bottom !important;
}
.isFirstRow td{
	border-top : 1px solid grey !important;
}
.sideValue {
	font-size : 14px !important;
}
.sideWid {
	width : 3cm;
}
.botop_black {
	border-top : 1px solid #000000 !important;
}
.summary_head td,.summary_head th {
	padding : 3px !important;
}
<?php if(!empty($heading) && count($heading) <= 5){?>
	td {
		font-size : 12px !important;
	}
<?php } ?>
<?php if(!empty($fontname)){?>
	body{
	font-family :  <?php echo $fontname ?> !important;
	}
<?php }?>

</style>
<?php if(!isset($pdf_type) || $pdf_type=='I') { ?>
</page>
<?php } ?>
