<style>
 .table>tbody>tr>td {
    vertical-align: top!important; 
    line-height: 20px;
}
</style>
<?
 if(!empty($xero_result)){
		if($operation['type']=='profile'){
	 	 ?>
		<div class="popover-content">
 		   <table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
				<tr>
					<td>  <b>  <?php echo $vis_language['TXTCONAME']; ?>  : </b></td>
					<td><?php echo $xero_result['Name']; ?> </td>
					<td> <b> <?php echo $vis_language['TXTFULLNAME']; ?> : </b> </td>
					<td><?php echo $xero_result['FirstName']; ?>  <?php echo $xero_result['LastName']; ?> </td>
				</tr>
				<tr>
					<td>  <b><?php echo $vis_language['TXTSTREET']; ?> <?php echo $vis_language['TXTADDRESS']; ?>  : </b></td>
					<td><?php echo $xero_result['Addresses']['Address'][0]['AddressLine1']." 
						<br>".$vis_language['TXTCITY']." : ".$xero_result['Addresses']['Address'][1]['City']."
						<br>".$vis_language['TXTREGION']." : ".$xero_result['Addresses']['Address'][1]['Region']."
						<br> ".$vis_language['TXTPOSTAL']." : ".$xero_result['Addresses']['Address'][1]['PostalCode']."
						<br> ".$vis_language['TXTCOUNTRY']." : ".$xero_result['Addresses']['Address'][1]['Country']; ?></td>
						
					<td>  <b> <?php echo $vis_language['TXTPOSTAL']; ?> <?php echo $vis_language['TXTADDRESS']; ?> : </b></td>
					<td><?php echo $xero_result['Addresses']['Address'][1]['AddressLine1']." 
						<br>".$vis_language['TXTCITY']." : ".$xero_result['Addresses']['Address'][1]['City']."
						<br>".$vis_language['TXTREGION']." : ".$xero_result['Addresses']['Address'][1]['Region']."
						<br> ".$vis_language['TXTPOSTAL']." : ".$xero_result['Addresses']['Address'][1]['PostalCode']."
						<br> ".$vis_language['TXTCOUNTRY']." : ".$xero_result['Addresses']['Address'][1]['Country']; ?></td>
				</tr>
				<tr>
					<td> <b><?php echo $vis_language['TXTEMAIL'];?> :  </b></td>
					<td><?php echo $xero_result['FirstName']; ?>  <?php echo $xero_result['LastName']; ?> </td>
					<td> <b><?php echo $vis_language['TXTSKYPENAME']; ?>: </b></td>
					<td><?php echo $xero_result['SkypeUserName']; ?></td>
				</tr>
				<tr>
					<td><b><?php echo $vis_language['TXTPHONE']; ?> : </b> </td>
					<td><?php echo $xero_result['Phones']['Phone'][0]['PhoneNumber']; ?> </td>
					<td><b><?php echo $vis_language['TXTFAX']; ?> : </b> </td>
					<td><?php echo $xero_result['Phones']['Phone'][1]['PhoneNumber']; ?> </td>
				</tr>
				<tr>
					<td><b><?php echo $vis_language['TXTMOBILENUMBER']; ?> : </b> </td>
					<td><?php echo $xero_result['Phones']['Phone'][2]['PhoneNumber']; ?> </td>
					<td> <b><?php echo $vis_language['TXTDIRECT']; ?> <?php echo $vis_language['TXTCALL']; ?> : </b> </td>
					<td><?php echo $xero_result['Phones']['Phone'][3]['PhoneNumber']; ?> </td>
				</tr>
		   </table>
		</div>
		<?php } 
		elseif($operation['type']=='activity' || $operation['type']=='pdf' ) { 
		$current_path=dirname(__FILE__);
		$dir_path = substr(VIS_CURRENT_PATH,0,-3);		
		?>
		<div class="popover-content" id="xero_pdf">
		   <table class="table table-hover b-t b-light m-b-none" data-ride="datatables">
			   <thead class="table_head">
				<tr>
					<th class="txt_nowrap"><? echo $vis_language['TXTNUMBER']; ?>#</th>
					<th class="txt_nowrap"><? echo $vis_language['TXTREF']; ?> #</th>
					<th class="txt_nowrap"><? echo $vis_language['TXTDATE']; ?></th>
					<th class="txt_nowrap"><?php echo $vis_language['TXTDUEDATE']; ?></th>
					<th class="txt_nowrap"><?php echo $vis_language['TXTPAID']; ?></th>
					<th class="txt_nowrap"><? echo $vis_language['TXTTAXX'];?></th>					 
					<th class="txt_nowrap"><? echo $vis_language['TXTTOTAL']; ?></th>
					<th class="txt_nowrap"><? echo $vis_language['TXTSTATUS']; ?></th>
					<th class="txt_nowrap"><? echo $vis_language['TXTACTION']; ?></th>
				</tr>
			   </thead>
			   <tbody>
			   <?php  
			   $status ='-';
			        for($i=0;$i<count($xero_result['Invoice']);$i++){ 
					$filename  = $download_link = '';
			        if($xero_result['Invoice'][$i]['InvoiceNumber']!=''){
					$filename = $dir_path.'/'.$xero_result['Invoice'][$i]['InvoiceID'].'.pdf';
						$download_link = VIS_PATH_MANAGE.$xero_result['Invoice'][$i]['InvoiceID'].'.pdf';
						if($xero_result['Invoice'][$i]['Status'] == 'AUTHORISED' )
						{
							$status = 'Awaiting Payment';
						}elseif($xero_result['Invoice'][$i]['Status'] == 'SUBMITTED'){
							$status = 'Awaiting Approval';
						}else{
							$status = $xero_result['Invoice'][$i]['Status'];
						}
					echo '<tr><td>'; ?><a   onclick="test('<?php echo $xero_result['Invoice'][$i]['InvoiceNumber']; ?>')" ><?php echo $xero_result['Invoice'][$i]['InvoiceNumber'].'</a></td>';
				    echo '<td>'.$xero_result['Invoice'][$i]['Reference'].'</td>';
					echo '<td>'.format_datetime(strtotime($xero_result['Invoice'][$i]['Date'])).'</td>';
 					echo '<td>'.$xero_result['Invoice'][$i]['AmountPaid'].'</td>'; 
					echo '<td>'.$xero_result['Invoice'][$i]['AmountDue'].'</td>';
					echo '<td>'.$xero_result['Invoice'][$i]['TotalTax'].'</td>';
					echo '<td>'.round($xero_result['Invoice'][$i]['Total'], '2').' '.$xero_result['Invoice'][$i]['CurrencyCode'].'</td>';
					echo '<td>'.ucfirst(strtolower($status)).'</td>';  
					echo '<td>'; ?><a  onclick="test('<?php echo $xero_result['Invoice'][$i]['InvoiceNumber']; ?>')" > <?php  if(file_exists($filename)){ ?> <a target='_blank' href="<?php echo $download_link; ?>"> View </a> <?php }else{ echo "Download"; } ?> <?php echo '</a></td></tr>';
			   }  }  ?>    
			   </tbody>
			</table>
		</div>
	<?php	} 	
}else include(VIS_PATH_TEMPLATE.'no_record_yet.php');?>
 <script language="javascript">
 function test(invoiceid)
 {
	$('#vis_details_list').visExecution('load_operations',{'vis_module':'ticket', 'vis_operation':'xero_client_profile','vis_domain':'<?php echo $operation['vis_domain']; ?>','vis_email':'<?php echo $operation['vis_email'];?>','vis_domain':'<?php echo $operation['vis_domain']; ?>','contact_name_xero':'<?php echo $operation['contact_name_xero'];?>','type':'pdf','vis_invoice':invoiceid});
 }
 </script>
 