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


//*****************

	$addressView = 'export/address/letterpad';
	$custFieldsView = !empty($custFieldsView) ? $custFieldsView : 'export/customfields';
	$detailsView = 'export/details/salinv';
	if($tType == 'SE'){
		$detailsView.="_est";
	}
	$headColor = (empty($is_email) ? $bgColor : $color);
	$flag1 = false;

	if ($isShipping && $tType != 'PE' && (!$sameAsBill || empty($hidShipAdr)))
	{
		$isShipping = true;
	}
	else
	{
		$isShipping = false;
	}
	if($tType == 'PC' || $tType == 'PD') { 
		$company['logo'] = '';
	}
	if($dueDate=='0000-00-00') {
		$dueDate = '';
	}
	$fontname = (!empty($fontname) && $fontname != 'null' )  ? $fontname : ""; 
	$this->view('export/css', array(
		"fontname" => $fontname
	));

	$company["name"] = "<big><big>" . $company["name"] . "</big></big>";
	$pdff_type = $pdf_type;
	if(!empty($isOriginal)) {
		$pdff_type = '';
	}

	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 = '';
	}
	
?>
	<?php if($paper == 'A5'){
			$img_height = '100px';
	}else{
			$img_height = '150px';
	}?>
	<?php if($isLogo == '2') { echo '<table class="vat noBorder"><tr><td colspan="3" width="100%"><div class="" ><img style="height:auto;
width: 100%;display: inline-block;" src="' . $company['fullHeaderImg'] . '" /></div></td></tr></table>';?>
		
	<?php } ?>
	
		<?php if($isLogo == 0 || $isLogo == 1) { ?>
	<table cellspacing="0" cellpadding="0" class="vat noborder">
		<tbody>
		
			<tr><?php
				$wid = '';
				if($paper == 'A5') {
					$wid = '20mm';
				}
				if (!empty($company['logo']))
				{
					echo '<td class="vam" style="width:' . (empty($company['logo_width']) ? '25' : '25') . '%;"><div class="imgDiv fltlt"><img width="'.$wid.'"  src="' . $company['logo'] . '" /></div></td>';
				}
				else {
					echo '<td style="width:25%"></td>';
				}
				?>
				<td width="60%" class="vam <?php echo empty($company['logo']) ? 'ac' : 'ac'; ?>" colspan="<?php echo empty($company['logo']) ? 2 : 1; ?>" ><?php
					echo '<b>' . $company["name"] . '</b><br>';
					//Branch name/Franchise name  given in Settings>Branches/Warehouse company name input
					if(!empty($company['company'])){
						echo '<b>' . $company["company"] . '</b><br>';
					}
					$addr = array();
					if (!empty($company["address1"]))
					{
						$addr[] = $company["address1"];
					}
					if (!empty($company["address2"]))
					{
						$addr[] = $company["address2"];
					}
					echo '<b>' . implode(",<br> ", $addr) . '</b>';
					$addr = array();

					$_city = '';
					if(!empty($company['city']))
					{
						$_city .= !empty($company["address2"]) ? ", " . $company['city'] :  $company['city'];
						if(!empty($company['zip']))
						{
							$_city .= ' - ' . $company['zip'];
						}
					}

					$state = $_city ? $_city . ', ' : '';
					if (!empty($company['stateName']))
					{
						$state .= $company['stateName'];
					}
					else if (!empty($company['pos']))
					{
						$state .= $company['pos'];
					}

					if (!empty($company['country']))
					{
						$state .= ($state ? ', ' : '') . $company['country'];
					}

					$addr[] = $state . '.';

					echo '<b>' . implode(",<br> ", $addr) . '</b>';
					$addr = array();
					if (!empty($company["phone"]))
					{
						$addr[] = mylang("Phone").':' . $company["phone"];
					}
					if (!empty($company["mobile"]))
					{
						$addr[] = mylang("Mobile").':' . $company["mobile"];
					}
					if (!empty($addr))
					{
						// echo '<td class="vat ar npt npb" colspan="3">';
						echo '<br>' . implode(", ", $addr);
						// echo '</td>';
					}
					if(!empty($company["addInfo"]))
					{
						
						if ($headColor == "transparent") {
							$borderColor = '#FFFFFF';
						}
						else{	
							$borderColor = $headColor;
						}
	
						echo '<br/><p class="addInfo" style="background-color:'.$headColor.';
border-width: 2px 5px;border-style: solid;border-color: '.$borderColor.'" >' . nl2br($company["addInfo"]) . '</p>';
					}
				?></td>
				<td width="15%"></td>
			</tr>
		</tbody>
	</table>
	<table cellspacing="0" cellpadding="0" class="vat noborder">
		<tbody>
			<tr>
				<td class="vab al npt" style="width:50%"><?php echo
					!empty($company["gstin"]) ? mylang("GSTIN") ." : " . $company["gstin"] : '';
				?><br>
				<?php echo !empty($company["pan"]) ? mylang("PAN") ." : " . $company["pan"] : '';?>
				</td>
				<td class="vab ar npt" style="width:50%"><?php
					if (!empty($company["email"]))
					{
						echo mylang("Email").':' . $company["email"];
					}
				?></td>
			</tr>
		</tbody>
	</table>
	<?php } ?>
	
<style>
		.headtxt, .invMeta {
			width: auto;
		}
		.invMeta td {
			padding:0px !important;
		}
		.addInfo, .extraCont {
			display: inline-block;
			margin: 0;
		}
<?php if ($headColor != "transparent") { ?>
		.addInfo, .extraCont {
			background: <?php echo $headColor; ?>;
			color: #FFFFFF;
			border-width: 2px 5px;
			border-style: solid;
			border-color: <?php echo $headColor; ?>;
		}
<?php } ?>

	</style>
</page>
