<?php
$sessionData = new Zend_Session_Namespace('Alw');
$vendor_contact_id = $sessionData->S_VEND_CONTACT_ID;
$vendor_id = $sessionData->S_VENDOR_ID;
$contact_info = Model_VendContact::getContactFromID($vendor_contact_id);
$vendor_info = Model_Vendor::getVendorByVendorID($vendor_id);
$first_name = isset($contact_info->Contact->contact_first_name) ? $contact_info->Contact->contact_first_name : "";
$last_name = isset($contact_info->Contact->contact_last_name) ? $contact_info->Contact->contact_last_name : "";
$roleresourceprivilege_validator = new Web_Validate_Checkroleresourceprivilege();
$vendorLogo = Model_VendorLogo::getVendorLogoByVendorID($vendor_id);
?>
<!--Start Header-->
<div id="header">
	<div id="welcome" class="panel">
			<?=$first_name?> <?=$last_name?>,
		<?php if(Zend_Registry::get('UserObj')->isAllowed("","","accountcardsubaccountname")){ ?>
      <span class="userName"><b id="subaccount-name"><?=$sessionData->subaccount_name?></b></span>
      <span class="subtextlink2">ID: <?=$contact_info->subaccount_id?></span>
			&bull;
			<?php
			//for DA and regular vendor show vendor company name
			}else{$company = isset($vendor_info->company) ? $vendor_info->company : "";
			?>
				<span class="userName"><?=$company?></span>
			<span class="subtextlink2">ID: <?=$vendor_id?></span>
			&bull;
			<a href="/account/myprofile" title="Account">Account</a>
			&bull;
		<?php
		}
		?>
		<?php
		if($roleresourceprivilege_validator->isValid(array("resource"=>"account", "privilege"=>"manageusers"))){
		?>
			<a href="/account/admin" title="Admin">Admin</a>
			&bull;
		<?php
		}
		?>
			<a href="/logout" onClick="event.stopPropagation();">Log out</a>
	</div>
<!--for getting vendorlogo and vendorname(hover msg)if it exist otherwise TheOrchard logo and TheOrchard (hover msg) -->
	<!--UIManage check if have access to this-->
		<?php
		//If this vendor has a custom logo, show it
		if(isset($vendorLogo->image_asset_id)){
			if(!$sessionData->vendor_logo_path){//get the path once and save in session as ManageImageAssets loads it from DB each time
				$service_obj = new Service_ManageImageAssets();
				$imagePath = $service_obj->getImage($vendorLogo->image_asset_id);
				$sessionData->vendor_logo_path = $imagePath;
			}
		?>
			<h1 id="custom-logo-link">
				<a title="<?=$vendor_info->company?>" href="/"><img src="<?=$sessionData->vendor_logo_path?>" alt="<?=$vendor_info->company?>" height="50" /></a>
				<span><img src="/images/poweredby.png" height="60" alt="The Orchard" /></span>
			</h1>
		<?php
		}else{//else display the orchard logo -- common for all
		?>
	<h1 id="logoLink"><a href="/" title="The Orchard">The Orchards</a></h1>
		<?php
		}
		?>
	<div class="clear"></div>
</div>
<!--End Header-->
