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

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

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

?>
<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>
			<tr>
				<?php 
				if ($isLogo == 1 && (!empty($company['logo'])))
					{
						echo '<td class="vat ac" colspan="2" width="100%"><div class="imgDiv fltlt" style="width:100%"><img src="' . $company['logo'] . '" /></div></td>';
					}
				?>
			</tr>
			<?php
				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>';
				}
			?><?php if($isLogo != 2){?>
			<tr>
				<td class="ac" colspan="2"><?php
					if (!empty($bId) && $bId>0 && !empty($company['company']))
					{
						//$company["name"] = "<big>".lang("CompanyName")."</big><br>".$company['company'];
					}else{
						$company['name'] = "<big>".lang("CompanyName")."</big>";
					}
					if(empty($iscompanyaddress) || (!empty($iscompanyaddress) && $iscompanyaddress == 1)){
						$company['address1'] = '';
						$company['address2'] = '';
						$company['pan'] = '';	
					}
					$this->subview($addressView, $company);
					echo "<br><br><b style='font-size: 13px !important;'>" . $titleText . "</b>";
				?></td>
			</tr>
			<?php } ?>
			<tr>
				<td class="al"  <?php echo $paper == "2.25" ? "colspan=\"2\"" : ""; ?>><?php
					echo mylang("BillNo").' : ' . $tNo;
					echo '<br>';
					//$this->load->helper('date');
					echo '<span style="white-space: nowrap !important;">'.mylang("Date").' ';
					echo $tDate;
					echo '</span>';
					echo '<br>';
					/*if(!empty($isPrint)){
					echo 'Printed on';
					$cur_time = get_timezone_date();
					echo date('d/m/y H:i A',strtotime($cur_time));
					}*/
					// echo $tDate;
					if ((!empty($source) && $source == 'P') && !empty($tableType) && !empty($tableName)){
						// echo '<br>';
						echo '<span style="white-space: nowrap !important;">'.($tableType == 'D' ? 'Table: ' : 'Take Away: ');
						echo $tableName;
						echo '</span>';						
						if(!empty($kot_no)) {
							// echo '<br>';
							echo '<span style="white-space: nowrap !important;">,  KOT: ';
							echo $kot_no;
							echo '</span>';
							// echo '<br>';
						}
						if(!empty($sRepName)) {
							echo '<span style="white-space: nowrap !important;">'.('Waiter: ');
							echo $sRepName;
							echo '</span>';
						}
					}
					if (!empty($relNumber))
					{
						echo '<br>';// $rel_tNo_text
						echo mylang("OrdNo").' : ' . $relNumber;
					}
					if (!empty($relDate))
					{
						echo '<br>';// $rel_tDate_text
						echo mylang("OrdDt").' : ' . $relDate;
					}
						$conName = !empty($contact['company']) ? $contact['company'] : (!empty($contact['contactPerson']) ? $contact['contactPerson'] : (!empty($conName) ? $conName : (!empty($contact['name']) ?($contact['name']) : "")));
					if (!empty ($conName) && ((!empty($iscompanyaddress) && $iscompanyaddress == 1)||empty($iscompanyaddress)))
					{
						echo '<br>';
						echo '<b>' .$conName.'</b>';
						echo !empty($city) ? ','.$city : '';
						echo '<br>';
					}
				?></td><td>
				<?php if((!empty($iscompanyaddress) && $iscompanyaddress == 2)){
						$billing['name'] = !empty($contact['company']) ? $contact['company'] : (!empty($contact['contactPerson']) ? $contact['contactPerson'] :(!empty($conName) ? $conName : (!empty($contact['name']) ?($contact['name']) : "")));
						echo '<br>';					
						$this->subview($addressView, $billing);
						echo '<br>';		
					}?>
				</td>
				<?php if ($paper != "2.25" &&  $paymentName && $tType !='SP' && $tType !='PP') { ?>
				
				<td class="ar"><?php
					echo lang("Payment Mode").' : ' . $paymentName;
				?></td><?php } ?>
				<?php	if ((!empty($sRepName)&& !empty($issalesrep)) && (empty($source) || $source != 'P'))
					{
						echo '<br>';
						echo $srep_text .': '; 
						echo $sRepName;
						
					}
					if ((!empty($sRepMobile)&& !empty($issalesrep)) && (empty($source) || $source != 'P'))
					{
						echo '<br>';
						echo $srep_mobile_text .': '; 
						echo $sRepMobile;
						
					}
					if (!empty($refName))
					{
						echo '<br>';
						echo mylang("ReferredBy") .': '; 
						echo $refName;
						
					}
					if(!empty($isprojectname) && !empty($prjName)) {
						echo '<br>';
						echo mylang("ProjectName") .': '; 
						echo $prjName;
						
					}
					
				?>
				<?php if (
						($tType == "SH" || $tType == "TD" || $tType =="GR" || $tType =="TR") &&
						!empty($contact) &&
						!empty($contact['csType']) &&
						($contact['csType'] == 'B' || $contact['csType'] == 'L')
					) {
						echo '<td class="al">';	
						echo "Stock Transfer / Branch Transfer - Not for Sale";
						echo '</td>';
					}?>
			</tr>
		</tbody>
	</table>
<?php

	if(!empty($fields))
	{
		$this->view($custFieldsView, array("custFieldsCols" => 2, "isThermalPrint" => 1));
	}
	if(!empty($export_details) && ($isExport && $currencyCode != $expCurrencyCode))
	{ 
		$this->view($exportDetailsView);
	}

	$this->view($detailsView);
?></page>
<style>
	/** {
		font-size: 10px;
	}*/
	html, body, page, pre {
		color: #000;
	}
	table th, table td {
		letter-spacing: 1px;
	}
	small {
		font-size: 9px;
	}
	table.dashed, table tr.dashed th {
		border-bottom: 1px dotted #000;
	}
	table tr.dashed1 td {
		border-top: 1px dotted #000 !important;
	}
	table tr.dashed2 td {
		border-bottom: 1px dotted #000 !important;
	}
	.address {
		line-height: 14px;
	}
	table tr.small td {
		font-size: 9px;
	}
	<?php if (!$isPrint && is_numeric($paper)) { ?>
	page {
	    width: <?php echo $paper * 130; ?>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 } ?>
/*
	table.noborder {
		margin-top:5px;
	}
	page {
		margin-left: auto;
		margin-right: auto;	
	}*/
</style>
