<?
    global $vis_language;
    $invoice_info=$data[0];
    $invoice_details=$data[1];
    $domain=$data[3];
    $domain_details=$data[4];
    $client=$data[5];
	$transaction_info=$data[6];
	for($i=0; $i<count($domain_details); $i++) { 
		if($domain_details[$i]['title']=='vis_logo_url') $logo=$domain_details[$i]['content'];						
		if($domain_details[$i]['title']=='vis_company_name') $company_name=$domain_details[$i]['content'];
		if($domain_details[$i]['title']=='vis_website_url') $company_website=$domain_details[$i]['content'];
		if($domain_details[$i]['title']=='vis_email_add') $company_email=$domain_details[$i]['content'];
		if($domain_details[$i]['title']=='vis_pay_to_text') $company_address=$domain_details[$i]['content']; } 
		
	$inv_status = array( 0 => $vis_language['TXTUNPAID'], 1 => $vis_language['TXTPAID'], 2 => $vis_language['TXTCANCELED'], 3 => $vis_language['TXTINPROCESS'] );
	$payment_method = array( 0 => $vis_language['TXTOFFLINEPAYMENT'], 1 => $vis_language['TXTPAYPALEMAIL'], 2 => $vis_language['TXTAUTHORIZE']);
?>
<table cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td>
		<? if(trim($logo)!='' && is_array(@getimagesize($logo))): ?>	
			<img src="<?= $logo; ?>" class="no-borders img-thumbnail" alt="<?= $company_name; ?>" width="100px">
	    <? endif; ?>
		</td>
		<td align="right">
			  <h4><?= $company_name; ?></h4>
			  <p><a target="_blank" href="<?= $company_website; ?>"><?= $company_website; ?></a></p>
			  <p><?= $company_email; ?></p>
			  <p><?= nl2br($company_address); ?></p>
		</td>
	</tr>
</table>
<table width="100%" style="padding:2px;"><tr><td><br/></td></tr></table>
<div style="background-color: #f5f5f5;border: 1px solid #e3e3e3;border-radius:4px;">
<table cellpadding="3" cellspacing="3" width="100%">
	<tr>
		<td>
			<strong>TO:</strong><span>&nbsp;<? echo $invoice_info['first_name'].' '.$invoice_info['last_name']; ?></span><!--<br/>-->
			<?php /*?><span><? echo $invoice_info['first_name'].' '.$invoice_info['last_name']; ?></span><?php */?>
			<div ><?
				if($invoice_info['temporary_address']!='') echo $invoice_info['temporary_address'].', <br />';
				if($invoice_info['country']!='') echo $invoice_info['country'].' <br />';
				if($client['contact_number']!='') echo $vis_language['TXTPHONE'].': '.$client['contact_number'].'<br />';
				echo '<strong>'.$vis_language['TXTEMAIL'].'</strong>: '.$invoice_info['email']; ?>
			</div>
		</td>
		<td align="right">
			  <strong><?= $vis_language['TXTINVOICEID']; ?></strong>: <strong><?= '#'.$invoice_info['invoice_hash']; ?></strong><br/>
			  <? if($invoice_info['invoice_status']==0){$clr = "#e33244";}elseif($invoice_info['invoice_status']==1){$clr = "#1aae88";}else{$clr = "#788288";} ?>
			  <strong><?= $vis_language['TXTSTATUS']; ?></strong>: <strong style="color: <?= $clr; ?>;"><?= $inv_status[$invoice_info['invoice_status']]; ?></strong><br/>
			  <? if($invoice_info['invoice_status']!=0 && $invoice_info['invoice_status']!=2) { ?><strong><?= $vis_language['TXTPAIDDATE']; ?></strong>: <?= format_datetime($invoice_info['paid_date']); ?><br/><? } ?>
			  <strong><?= $vis_language['TXTCREATIONDATE']; ?></strong>: <?= format_datetime($invoice_info['entry_date']); ?><br/>
			  <strong><?= $vis_language['TXTDUEDATE']; ?></strong>: <?= format_datetime($invoice_info['due_date']); ?>
		</td>
	</tr>
</table>
</div>
<table width="100%" style="padding:3px;"><tr><td><br/></td></tr></table>
<table cellpadding="5" cellspacing="0" width="100%" style="border:1px solid #ddd;color:#788288;font:normal 13px courier;">
    <tr><th style="border:1px solid #ddd;background-color:#f2f4f8;" width="85%"><strong><? echo $vis_language['TXTDESCRIPTION']; ?></strong></th><th align="right" style="border:1px solid #ddd;background-color:#f2f4f8;" width="15%"><strong><? echo $vis_language['TXTAMOUNT'].' ('.VIS_DOMAIN_CURRENCY.')'; ?></strong></th></tr><?
    if($invoice_details!=-1) for($i=0;$i<count($invoice_details);$i++) {
        echo '<tr><td style="border:1px solid #ddd;" width="85%">'.str_replace("\n", '<br />',  $invoice_details[$i]['description']).'</td><td align="right" style="border:1px solid #ddd;" width="15%">'.$invoice_details[$i]['amount'].'</td></tr>';
    }?>
    <tr><td align="right" width="85%" style="border:1px solid #ddd;"><strong><? echo $vis_language['TXTSUBTOTAL']; ?></strong></td><td width="15%" align="right" style="border:1px solid #ddd;"><? echo $invoice_info['subtotal']; ?></td></tr>
    <tr><td align="right" width="85%" style="border:1px solid #ddd;"><strong><? echo $vis_language['TXTTAXX']; ?></strong></td><td width="15%" align="right" style="border:1px solid #ddd;"><? echo $invoice_info['tax']; ?></td></tr>
    <tr><td align="right" width="85%" style="border:1px solid #ddd;"><strong><? echo $vis_language['TXTCREDIT'].' ('.$client['currency'].')'; ?></strong></td><td width="15%" align="right" style="border:1px solid #ddd;"><? echo $invoice_info['invoiceCredit']; ?></td></tr>
    <tr><td align="right" width="85%" style="border:1px solid #ddd;"><strong><? echo $vis_language['TXTTOTALDUE']; ?></strong></td><td width="15%" align="right" style="border:1px solid #ddd;"><? echo ($invoice_info['total']-$invoice_info['invoiceCredit']); ?></td></tr>
</table>
<table width="100%" style="padding:8px;"><tr><td><br/></td></tr></table>
<? if($transaction_info!=-1) { ?>
  <table cellpadding="5" cellspacing="0" width="100%" style="border:1px solid #ddd;color:#788288;font:normal 12px courier;">
	  <tr>
		  <th style="border:1px solid #ddd;background-color:#f2f4f8;"><strong><?= $vis_language['TXTTRANSACTIONID']; ?></strong></th><th style="border:1px solid #ddd;background-color:#f2f4f8;"><strong><?= $vis_language['TXTDESCRIPTION']; ?></strong></th>
		  <th style="border:1px solid #ddd;background-color:#f2f4f8;"><strong><?= $vis_language['TXTTRANSACTIONDATE']; ?></strong></th><th style="border:1px solid #ddd;background-color:#f2f4f8;"><strong><?= $vis_language['TXTPAYMENTMETHOD']; ?></strong></th><th style="border:1px solid #ddd;background-color:#f2f4f8;"><strong><?= $vis_language['TXTAMOUNT'].' ('.$client['currency'].')'; ?></strong></th>
	  </tr>
	<? for($i=0;$i<count($transaction_info);$i++) { ?>
	  <tr>
		<td style="border:1px solid #ddd;"><?= $transaction_info[$i]['balance_id']; ?></td>
		<td style="border:1px solid #ddd;"><?= $transaction_info[$i]['content']; ?></td>
		<td style="border:1px solid #ddd;"><?= format_datetime($transaction_info[$i]['entry_date']); ?></td>
		<td style="border:1px solid #ddd;"><?= $payment_method[$transaction_info[$i]['gateway_id']]; ?></td>
		<td style="border:1px solid #ddd;"><?= $transaction_info[$i]['amount']; ?></td>
	  </tr>
	 <? } ?>
  </table>
<? } ?>
</br>
<div style="text-align:right;color:#788288;"><strong><? echo $vis_language['TXTBALANCE'].' ('.$client['currency'].')'; ?> : <? echo $invoice_info['balance']; ?></strong></div>
