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

	$addressView = 'export/address/salretail1';
	$company["compNamePrefix"] = $this->config->item("compNamePrefix");
	
	$fontname = (!empty($fontname) && $fontname != 'null' )  ? $fontname : "";
	//OB : This template is applicable for font size > 10 & retail template (Display the custom fields one by one)
	//print_R($company);exit;
	$this->view('export/css', array("fontname" => $fontname,'isPrint' => 1 ,'printcolor' => '','paper' => 4));
	$isvertical = $isHorizontal = false;
/*
	$isHorizontal	= (!empty($isvertical) && $isvertical == 2) ? true : false;
	$isvertical		= (!empty($isvertical) && $isvertical == 1) ? true : false;
*/
?>
<page footer="page" pagegroup="new">
<?php 
	if (isset($download) && $download==-1){
		echo '<bookmark title="'.$tNo.'" level="0" ></bookmark>';
	}
?>
	<table cellspacing="0" cellpadding="0" class="vat noborder ">
		<col style="width:50%;">
		<col style="width:50%;">
		<tbody>
				<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:bold;font-size:15px;"><?php echo $compName; ?></span>
				<br>
				<?php } ?>
				<?php if(!empty($additonalInfo)) { ?> 
						<span style="font-weight:normal;font-size:13px;"><?php echo $additonalInfo; ?></span>
				<br>
				<?php } ?>
				<?php if(!empty($sideHeader)) { ?> 
						<span style="font-weight:normal;font-size:13px;"><?php echo $sideHeader; ?></span>
				<br>
				<?php } ?>
				<?php if(!empty($extrahead)) { ?> 
						<span style="font-weight:normal;font-size:13px;"><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(!empty($rangePeriod)) { ?> 
						<div style="font-weight:normal;font-size:14px;"><?php echo ''.$rangePeriod; ?></div>
				<br>
				<?php } ?>
				<?php if(!empty($from_date)&& !empty($to_date) && $type != 'gstr1all' && $type != 'gstr3all' && ($from_date != $to_date)) { ?>
					
					<span style="font-weight:normal;font-size:10px;"><b><?php echo $from_date.'&nbsp;-&nbsp;'.$to_date ; ?></b></span>
					
					<?php }else{ 
						if(!empty($from_date)){	?>
						<span style="font-weight:normal;font-size:11px;"><b><?php echo $from_date; ?></b></span>
				<?php 	}
						
						} ?><br>
				<?php if(!empty($branchName)) { ?> 
						<span style="font-weight:normal;font-size:10px;"><?php echo $branchName; ?></span>
				<br>
				<?php } ?>
			</td></tr>
		</tbody>
	</table>
	<table class="noborder vam itemdetails" cellspacing="0">
		<?php switch($type){
			//For item sales report ,Category sales report
			case 'summary': ?>
				<thead>
					<tr class="dashed1 dashed2">
						<td> <?php echo($pageType == 'IS') ? 'Items' : 'Category' ?></td>
						<td class="ar"> Qty </td>
						<?php if(!empty($avgRateInc)){?>
						<td class="ar"> Rate</td>
						<?php } ?>
						<td class="ar"> Amt</td>
					</tr>
				</thead>
				<tbody>
					<?php
					 foreach ($items as $item) {
					?>
					<tr>
						<td class="al"><b><?php echo !empty($item['itemName']) ? $item['itemName'] : $item['category']; ?></b></td>
						<td  class="ar" ><b><?php echo $item['s_qty_0']; ?></b></td>
						<?php if(!empty($avgRateInc)){?>
						<td class="ar"><?php echo $item['avgRateInc_0']; ?></td>
						<?php } ?>
						<td class="ar"><b><?php echo $item['s_amount_inc_0']; ?></b></td>
					</tr>
					<?php } ?>
				</tbody>
				<tfoot>
					<tr  class="dashed1 dashed2">
						<td class="al">Total</td>
						<td  class="ar" ><b><?php echo $totals['s_qty_0']; ?></b></td>
						<?php if(!empty($avgRateInc)){?>
						<td class="ar"></td>
						<?php } ?>
						<td class="ar"><b><?php echo $totals['s_amount_inc_0']; ?></b></td>
					</tr>
				</tfoot>
		<?php break;
		//For current stock report ,disposed wastage report
			case 'stockAlert':
		?>		
			<thead>
					<tr class="dashed1 dashed2">
						<td> Item </td>
						<td class="ar"> <?php echo (!empty($file_name) && $file_name == 'Wastage Report') ? 'Qty' : 'Stock' ?></td>
					</tr>
				</thead>
				<tbody>
					<?php
					 foreach ($items as $item) { ?>
					<tr>
						<td class="al"><?php echo $item['itemName']; ?></td>
						<td  class="ar"><?php echo $item['qty']; ?> &nbsp;&nbsp;<small style='font-style:italic;font-size:8px'><?php echo $item['uom'];?></small></td>
					</tr>
					<?php } ?>
				</tbody>
				<tfoot>
				
				</tfoot>
		<?php 	break;
		//For item production report
		case 'production':
			?>		
				<thead>
						<tr class="dashed1 dashed2">
							<td> Item </td>
							<td class="ar"> Qty </td>
							<td class="ar"> Rate </td>
						</tr>
					</thead>
					<tbody>
						<?php
						 foreach ($items as $item) { ?>
						<tr>
							<td class="al"><?php echo $item['itemName']; ?></td>
							<td  class="ar"><?php echo $item['qty']; ?></td>
							<td  class="ar"><?php echo $item['rate']; ?></td>
						</tr>
						<?php } ?>
					</tbody>
					<tfoot>
						<tr  class="dashed1 dashed2">
							<td class="al">Total</td>
							<td  class="ar">
								<?php echo $totals['qty']; ?></td>
							<td  class="ar"><?php  echo  $totals['rate']; ?></td>
						</tr>
					</tfoot>
			<?php 	break;
		
		//For sales register detail report
			case 'transDetail':
			 $heading = array_keys($heading);
			?>		
				<thead>
						<tr class="dashed1 dashed2">
							<td> Trans No </td>
							<?php if(in_array("pMode",$heading)) {?>
								<td> Payment mode </td>
							<?php } ?> 
							<td class="ar"> Amount </td>
						</tr>
					</thead>
					<tbody>
						
						<?php foreach ($items as $item) {?>
						<tr>
							<?php if(!empty($item['tno'])){?>
							<td class="al"><?php echo $item['tno']; ?></td>
							<?php } ?> 
							<?php if(in_array("pMode",$heading)) {?>
								<td> <?php echo $item['pMode']; ?></td>
							<?php } ?>
							<?php if(!empty($item['totamount'])){?>
							<td  class="ar"><?php echo $item['totamount']; ?></td>
							<?php } ?> 
						</tr>
						<?php } ?>
					</tbody>
					<tfoot>
					<tr  class="dashed1 dashed2">
						<td class="al">Total</td>
						<?php if(in_array("pMode",$heading)) {?>
								<td></td>
						<?php } ?>
						<td  class="ar"><?php echo $totals['totamount']; ?></td>
					</tr>
				</tfoot>
			<?php break;
	
	} ?>
	</table>
</page>
<style>
	html, body {
		font-size: <?php echo !empty($fontsize) ? $fontsize : 10; ?>px;
	}
	html, body, page, pre {
		color: #000;
	}
	small {
		font-size: 9px;
	}
	table.dashed, table tr.dashed th {
		border-bottom: 1px dotted #000;
	}
	table tr.subtotal td {
		border-top: 1px dotted #000 !important;
	}
	table tr.totDiscount td {
		border-top: 1px dotted #000 !important;
	}
	table tr.dashed1 td {
		border-top: 1px solid #000 !important;
	}
	table tr.dashed2 td {
		border-bottom: 1px solid #000 !important;
	}

	.address big {
		font-size: 20px;
	}

	.totAmountCurr .amt {
		font-size: 18px;
	}
/*
	.address {
		line-height: 14px;
	}
*/
	table tr.small td {
		font-size: 10px;
	}
	table tr td.bt {
		border-top: 1px solid #000;
	}
	table tr td.bb {
		border-bottom: 1px solid #000;
	}

	.det  td{
		padding: 1px;
	}
	table tr td {
		font-weight: 600;
	}
	table tr.row td {
		padding-bottom: 0px;
	}
	<?php if ($isHorizontal) { ?>
	table.noborder tr.item.row td, table tr.item.row td {
		border-bottom: 1px dotted #000;
	}
	<?php } ?>
	table tr.row2 td {
		padding-top: 0px;
	}
</style>
