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

$addressTmpl = array();
if (!empty($address1))
{
	/*
	if (!empty($address2))
	{
		$address1 .= ', ' . $address2;
	}
	*/
	$addressTmpl[] = $address1;
}
	if (!empty($address2)){
	$addressTmpl[] = $address2;
}

$_city = '';
if(!empty($city))
{
	$_city .= $city;
	if($zip)
	{
		$_city .= ' - ' . $zip;
	}
	// $addressTmpl[] = $_city;
}

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

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

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

$addressTmpl = implode(",<br>", $addressTmpl);

$addressTmpl2 = array();
if(!empty($mobile))
{
	$addressTmpl2[] = 'Mobile : ' . $mobile;
}

if(!empty($phone))
{
	$addressTmpl2[] = 'Phone : ' . $phone;
}

if (!empty($addressTmpl2))
{
	$addressTmpl .= '<br>' . implode(", ", $addressTmpl2);
}

if(!empty($email))
{
	// $addressTmpl2[] = 'Email : ' . $email;
	$addressTmpl .= '<br>Email : ' . $email;
}

if(!empty($gstin))
{
	$addressTmpl .= '<br>GSTIN : ' . $gstin;
}
if(!empty($pan))
{
	$addressTmpl .= '<br>PAN : ' . $pan;
}
if(!empty($isRegisteredMSME))
{
	$addressTmpl .= '<br>'.mylang("MSME") .' '. $msmet  .' : ' . $msmen ;
}
if(!empty($addInfo))
{
	$addressTmpl .= '<br>' . nl2br($addInfo);
}
if(!empty($extraCont))
{
	$addressTmpl .= '<br>' . nl2br($extraCont);
}
if(!empty($below_addr) ) {
	$addressTmpl .= ',<br>'	;	
	$i = 0;
	foreach($below_addr as $row) {
		$addcomma = '';
		if($i < count($below_addr)-1) {
			$addcomma = ',<br>';
		}
		$addressTmpl .= empty($row) ? "" : ($row.$addcomma);
		$i++;
	}
}
echo '<p class="address nm">';

if (!empty($name))
{
	$class = '';
	if(!empty($headColor) && $headColor != "transparent"){
		$class = 'txtclr';
	}
	// echo $name . '<br>';
	echo '<b class="'.$class.'">'.$name . '</b><br>';
}
//Branch name/Franchise name  given in Settings>Branches/Warehouse company name input
if (!empty($company)){
	echo '<b>'.$company.'</b>';
	echo '<br>';
}
if(!empty($above_addr)) {
	foreach($above_addr as $row) {
		$row = empty($row) ? "" : $row;
		$row .= ',<br>';
		echo $row;
	}
}
echo $addressTmpl;

?></p>
<style>
	.txtclr {
	color: <?php echo $headColor; ?>;
	}
</style>
