<div class="back"><div><?php defined('BASEPATH') OR exit('No direct script access allowed');

// 'isLogo, color, isDueDate, isSlNoCol, isItemDesc, isHsnCol, isBankDetail, isCustSign, isPageNo, isFullPage, isPrintDate, footerText, copiesToPrint, printType, topMargin, rightMargin, bottomMargin, leftMargin'

	if (!isset($isCompact))
	{
		$isCompact = false;
	}
	
	$addressView = !empty($addressView) ? $addressView : 'export/address/salinv';
	$detailsView = !empty($detailsView) ? $detailsView : 'export/details/salinv';
	if($tType == 'SE'){
		$detailsView.="_est";
	}

	$custFieldsView = !empty($custFieldsView) ? $custFieldsView : 'export/customfields';
	//$custFieldsView = !empty($custFieldsView) ? $custFieldsView : 'export/sunkingcustomfields';
	$exportDetailsView = !empty($exportDetailsView) ? $exportDetailsView : 'export/exportdetails';
	$letterPadHeader = 'export/letterpadHeader';
	$headColor = (empty($is_email) ? $bgColor : $color);
	if($tType == 'PI') {
		$billing['headColor'] = $headColor;
	}
	$billing['fontname'] = !empty($fontname) ? $fontname : '';
	$shipping['fontname'] = !empty($fontname) ? $fontname : '';
	$isQuote = false;
	if ($tType == 'SE' || $tType == 'SO')
	{
		$isQuote = true;
		//$pdf_type = '';
	}

	if ($isPrint && $isExport)
	{
		$isEstimate = true;
	}

	if($isPrint && $printcolor == 'transparent')
	{
		$foreColor = "#000000";
	}
	if (!empty($is_email) && $color != 'transparent')
	{
		$foreColor = "#ffffff";
	}
	
	$hasHSN = ($hasHSN && $isHsnCol) ? 1 : 0;

	if ($isShipping && $tType != 'PE' && (!$sameAsBill || empty($hidShipAdr)))
	{
		$isShipping = true;
	}
	else
	{
		$isShipping = false;
	}
	
	$pdff_type = $pdf_type;
	//For Normal Print clicks hide the pdf type
	if(!empty($isOriginal))
	{
		$pdff_type = '';
	}
	if($bgColor == 'transparent')
	{
		$showVerticalLine= false;
	}
	else
	{
		$showVerticalLine = true;
	}
	$fontname = (!empty($fontname) && $fontname != 'null' )  ? $fontname : "";
	$this->view('export/css', array(
		"fontname" => $fontname
	));
	
	if($tType == 'PC' || $tType == 'PD' || $tType == 'PE')
	{
		$company['logo'] = '';
	}

	if($dueDate == '0000-00-00')
	{
		$dueDate = '';
	}

	if (isset($download) && $download == -1)
	{
		echo '<bookmark title="'.$tNo.'" level="0" ></bookmark>';
	}
	if (!empty($isAllPageHeader))
	{
		echo '<htmlpageheader name="'.$pdf_type.'">';
	}
	if(!empty($isOriginal))
	{
		$printColors = '';
	}
	if(!empty($printColors))
	{
		$headColor = $printColors;
	}
	if(!empty($isSlip) && $pdf_type == 'Extra Copy') {
		$pdff_type = '';
	}

?>
<div class="trans" >
	<a name="<?php echo $tNo; ?>"></a>
		<table  cellspacing="0" cellpadding="0" class="" style="border-bottom: none !important;">
			<tbody>
				<tr>
					<td  <?php echo (!empty($isShipping) && $tType != 'PO') ? 'colspan="3"' : 'colspan="2"' ?> class="ac vam np" >
						<strong><big><?php echo $titleText; ?></big></strong>
					</td>
				</tr>
				<?php
					if($paper == 'A5')
					{
						$img_height = '75px';
					}
					else
					{
						$img_height = '120px';
					}
					if ($isPrint){
						$width = "50%";
					}else{
						$width = "100%";
					}?>
					<tr><td  style="text-align:center;" <?php echo (!empty($isShipping) && $tType != 'PO') ? 'width="33%"' : 'width="50%"' ?> <?php echo (!empty($isShipping)&& $tType != 'PO') ? 'colspan="2"' :'' ?>  >
					<?php 
					if(!empty($isLogo) && $isLogo == 2)
					{
			
					echo '<div class="" ><img style="height:auto; width: auto;display: inline-block;" src="' . $company['fullHeaderImg'] . '" /></div>';
					}
					if(!empty($isLogo) && $isLogo == 1 && !empty($company['logo']))
					{
			
					echo '<div class="" ><img style="min-height: 100px;" src="' . $company['logo'] . '" /></div>';
					}
					echo '</td>';?>
					<td width="50%" >
						<div style="padding: 5px;">
							<?php
							 $this->subview($addressView, $company);
							?>
						</div>
					</td>
				</tr>
				<?php
					if (!empty($tType!='PC') && !empty($tType != 'PD')){
				?><?php
					if(!empty($billing['name']) || !empty($shipping['name'])){
					  $contact_name = !empty($contact['company']) ? $contact['company'] : (!empty($contact['contactPerson']) ? $contact['contactPerson'] : (!empty($conName) ? $conName : (!empty($contact['name']) ? ($contact['name']) : "")));
					  $billing["name"] = !empty($contact_name) ? $contact_name : $conName;
					  //Edited shipping name directly in grid
					if($shipping["name"] != $contact_name){
						$contact_name  = $shipping["name"];
					}
					$shipping["name"] = !empty($contact_name) ? $contact_name : $conName;
				?>
				<tr>
				<?php
				 if((!empty($isShowAddress) && !empty($billing['countryCode']))|| !empty($tType=='PI')) { ?>
					<td class="vat"  <?php echo (!empty($isShipping) && $tType != 'PO') ? 'width="33%"' : 'width="49%"' ?> >
						<div><?php
							$addr = "To";

							if ($tType == 'PO' || $tType == 'PI')
							{
								$addr = "Supplier";
							}
							
								echo '<span class="">' . $addr . '</span>';
							
							if ($tType == 'SH')
							{
								$billing["name"] = $contact_name;
							}
							if(!empty($conTaxNo))
							{
								$billing['gstin'] = $conTaxNo;
							}
							$this->subview($addressView, $billing);
							echo '<p class="nm">'.mylang("SOS").' : '.$pos.'</p>' ;
						    ?>
						</div>
					</td>
					<?php
					if ($isShipping && !$isAllServices && $tType != 'PO')
					{
					?>
						<td width="30%" <?php echo !empty($showVerticalLine) ? 'style="padding:5px;border-left: 4px solid '.$headColor.'"' : '' ?>><?php echo $tType != 'PO' ? mylang("ShippingAddress") : 'Dispatch To'; ?>: <br>
						<?php $this->subview($addressView, $shipping);?>
						</td>
					<?php
					}?>
				<?php } ?>
					<td  <?php echo (!empty($isShipping) && $tType != 'PO') ? 'width="33%"' : 'width="50%"' ?> style="padding:0px;vertical-align: top;" > 
						<?php 
							 if (!empty($export_details[0]['value'])){
								//	$this->view($exportDetailsView);
							}
							if(!empty($fields))
							{ 
								//	$this->view($custFieldsView);
							}
						 ?>
						<?php $titleText = "" ;include(APPPATH . "views/export/simplemeta.php"); ?>
					</td>
				</tr>
				<?php } } ?>
				<tr>
					<td colspan="2"><?php
								// if (!empty($export_details[0]['value']))
								// {
								// 	$this->view($exportDetailsView, array('issimpletemp' => 'true'));
								// }
								if(!empty($fields))
								{ 
									$this->view($custFieldsView ,array('issimpletemp' => 'true'));
								}
							?>
					</td>
				</tr>
				<?php if (
						($tType == "SH" || $tType == "TD" || $tType =="GR" || $tType =="TR") &&
						!empty($contact) &&
						!empty($contact['csType']) &&
						($contact['csType'] == 'B' || $contact['csType'] == 'L')
					) {
						$colspan = 3;

						echo '<tr>';
						echo '<td colspan="' . $colspan . '" class="bot ac vam" style="border-bottom:0.5px solid #000000">';
						echo 'Stock Transfer / Branch Transfer - Not for Sale';
						echo '</td>';
						echo '</tr>';
					}?>
		</tbody>
		
	</table>
</div>
<?php
if (!empty($isAllPageHeader))
{
	echo '</htmlpageheader><sethtmlpageheader name="'.$pdf_type.'" value="on" show-this-page="1" page="all" />';
}
?>
<?php
	$this->view($detailsView, array(
		"useSimpleTaxCol" => isset($useSimpleTaxCol) ? $useSimpleTaxCol : 1,
		'showVerticalLine' => 1,
		'isShowFor' => '1',
		'issimpletemp' => 'true',
		//'hideAmount' => !empty($isAmount) ? false : true
		// 'sysAttrAsCol' => true,
		// "hideAllAmount" => 1,
	));
?>
</div>
<style>

body {
<?php if(!empty($isWatermark)) { ?>
		  background: url('<?php echo $waterImg; ?>') no-repeat 0 0;
		<?php if($isWatermark && $isWatermark == 1){?>
		  background-position: top;
		<?php } ?>
		<?php if($isWatermark && $isWatermark == 2){?>
		  background-position: center;
		<?php } ?>
		<?php if($isWatermark && $isWatermark == 3){?>
		  background-position: bottom;
		<?php } ?>
<?php } ?>
}

.invMeta {
	width: auto;
}
<?php if(!empty($isPrint)) { ?>
.invMeta td {
	padding:0px !important;
	/*white-space: nowrap;*/
}
<?php } ?>
</style>

