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

	$rel_tNo_text =  (!empty($label) && !empty($label['OrderNo'])) ? $label['OrderNo'] : (!empty($rel_tNo_text) ? $rel_tNo_text : '') ;
	$rel_tDate_text =  (!empty($label) && !empty($label['OrderDate'])) ? $label['OrderDate'] : (!empty($rel_tDate_text) ? $rel_tDate_text : '') ;

	// $addressView = 'export/address/salretail1';
	// $detailsView = 'export/details/salretail1';

	// $custFieldsView = 'export/customfields';

	$company["compNamePrefix"] = $this->config->item("compNamePrefix");

	$fontname = (!empty($fontname) && $fontname != 'null' )  ? $fontname : "";
	$this->view('export/css', array("fontname" => $fontname));

	$isvertical = $isHorizontal = 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 dashed">
		<col style="width:50%;">
		<col style="width:50%;">
		<tbody>
<?php
			if ($isLogo == 1 && (!empty($company['logo'])))
			{
				echo '<tr><td class="vat ac" colspan="2" width="100%"><div class="imgDiv fltlt" style="width:100%"><img src="' . $company['logo'] . '" /></div></td></tr>';
			}

			if($isLogo == 2 )
			{
				echo '<tr><td colspan="2" width="100%"><div class="" ><img style="height: auto; width: 100%;display: inline-block;" src="' . $company['fullHeaderImg'] . '" /></div></td></tr>';
			}
/*
				if($isLogo != 2)
				{
?>			<tr>
				<td class="ac bt bb" colspan="2"><?php
					if(empty($iscompanyaddress) || (!empty($iscompanyaddress) && $iscompanyaddress == 1)){
						$company['address1'] = '';
						$company['address2'] = '';
						$company['pan'] = '';	
					}
					if (!empty($company['company']))
					{
						$company["name"] = "<big>".lang("CompanyName")."</big><br>".$company['company'];
					}else{
						$company['name'] = "<big>".lang("CompanyName")."</big>";
					}
					
					$this->subview($addressView, $company);
					
				?></td>
			</tr>
			<tr>
				<td class="ac" colspan="2">
					<b><big><?php echo $titleText; ?><big></b>
				</td>
			</tr>
<?php			}
*/
?>			<tr><td colspan="2">&nbsp;</td></tr>
			<tr>
				<td class="al" colspan="2"><?php
					echo mylang("BillNo") . ' : <b>' . $tNo ."</b>";
					$this->load->helper('date');
					echo '<br>';
					echo mylang("Date").' : ' . $tDate;

					if (!empty($sRepName)&& !empty($issalesrep))
					{
						echo '<br>' . $srep_text . ' : ' . $sRepName;
					}
/*
					if (!empty($sRepMobile)&& !empty($issalesrep))
					{
						echo '<br>' . $srep_mobile_text . ' : ' . $sRepMobile;
					}
*/
					if (!empty($refName))
					{
						echo '<br>' . mylang("ReferredBy") . ' : ' . $refName;
					}

					if (!empty($relNumber))
					{
						echo '<br>' . $rel_tNo_text . ' : ' . $relNumber;
					}

					if (!empty($relDate))
					{
						echo '<br>' . $rel_tDate_text . ' : ' . $relDate;
					}

					echo '<br>';
				?></td>
			</tr>
		</tbody>
	</table><?php

/*
	if(!empty($fields))
	{
		$this->view($custFieldsView, array("custFieldsCols" => 2, "isThermalPrint" => 1));
	}

	$this->view($detailsView);
*/
?>
<table class="noborder vam itemdetails" cellspacing="0">
	<thead>
		<tr class="dashed"><?php
			echo '<th class="al">' . mylang("Item") . '</th>';
			echo '<th class="ar">' . mylang("Qty") . '</th>';
?>		</tr>
	</thead>
	<tbody>
<?php
		if(!empty($details))
		{
			$totalitems = count($details);
			$totqty = 0;
			foreach ($details as $key => $val)
			{
				$val['qty'] = $val['qty'] > 0 ? (float)$val['qty'] : '';
				$totqty = $totqty + (float)$val['qty'];
				echo '<tr>';
				echo '<td>' . ($key+1) . '. ' . $val["itemName"];
				if (!empty($val["itemDesc"]))
				{
					echo '<br><small>' . $val["itemDesc"] . '</small>';
				}
				echo '</td>';
				echo '<td class="ar">' . $val["qty"] . '&nbsp;<small>' . $val['unit'] . '</small></td>';
				
				echo '</tr>';
			}
		}
?>
	</tbody>
	<tfoot>
		<tr class="subtotal">
			<td>Total</td>
			<td class="ar"><?php echo $totqty; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
	</tfoot>
</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, table tr.dashed td {
		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;
	}
	<?php if (!$isPrint && is_numeric($paper)) { ?>
	page {
	    width: <?php echo $paper * 100; ?>px;
	    margin-left: calc(50% - 150px);
	    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
	}
	<?php } ?>
	.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>
