<? global $vis_language; 
   $payment_method ='';
   if($paymentMethod != -1)
    {
   	  for($i=0; $i < count($paymentMethod);$i++)
   	  { 
   		  if($paymentMethod[$i]['gateway_type'] == 1) $payment_method[1] = $vis_language['TXTPAYPALEMAIL'];
   		  if($paymentMethod[$i]['gateway_type'] == 2) $payment_method[2] = $vis_language['TXTAUTHORIZE'];
             if($paymentMethod[$i]['gateway_type'] == 3) $payment_method[3] = $vis_language['TXTSTRIPE'];
        }
    }
   //$payment_method = array( 0 => $vis_language['TXTOFFLINEPAYMENT'], 1 => $vis_language['TXTPAYPALEMAIL'], 2 => $vis_language['TXTAUTHORIZE']);
   $inv_status = array( 0 => $vis_language['TXTUNPAID'], 1 => $vis_language['TXTPAID'], 2 => $vis_language['TXTCANCELED'], 3 => $vis_language['TXTINPROCESS'] ); ?>
   
<section class="container m-t-md">
   <div class="row">
      <div class="col-md-12">
         <section class="container m-t-md">
            <div class="panel-heading b-b  ">
              
                  <?php  if($invoice_info['invoice_status']==0 && $payment_method!='') { ?>
                  <form class="pull-right-lg m-b" role="listitem">
                     <div class="btn-group">
                        <label class="pull-left m-r m-t-xs"><?= $vis_language['TXTGATEWAY']; ?></label>
                        <div class="pull-left">
                           <select name="vis_gateway" id="vis_gateway" class="form-control input-sm <? if(!is_mobile()) echo 'selectpicker'; ?>" onchange="get_pay_mode_details(this.value);">
                              <?php
                                 foreach($payment_method as $kay=> $value) 
                                 {
                                 ?>
                              <option value="<? echo $kay; ?>"><? echo $value; ?></option>
                              <?
                                 }
                                                      ?>
                           </select>
                        </div>
                     </div>
                  </form>
                  <? }  ?>
                  <h4 class="panel-title1"><?= '#'.$invoice_info['invoice_hash']; ?></h4>
             
            </div>
            <section id="content">
               <section class="vbox bg-white b-t b-light">
                  <header class="header b-b b-light m-t hidden-print">
                     <span id="vis_gateway_details"><?php  if($invoice_info['invoice_status']==0) { 
                        include(VIS_PATH_TEMPLATE.'gateway.php'); } ?></span>
                     <!--<span><button href="#" class="btn btn-default btn-sm pull-right m-l" onClick="window.print();">Print</button> </span>-->
                     <span><a class="btn btn-sm btn-default pull-right m-l" href="?/billing/invoice-pdf/<? echo $invoice_info['invoice_hash'].'/'.$invoice_info['invoice_id']; ?>" target="_blank"><? echo $vis_language['TXTGETPDF']; ?></a> </span>
                  </header>
                  <section class="scrollable wrapper">
                     <? for($i=0; $i<count($domain_details); $i++) { 
                        if($domain_details[$i]['title']=='vis_logo_url') $logo=trim($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']; } ?>
                     <div class="row">
                        <div class="col-xs-6">
                           <div class="m-t-lg">
                              <? if(trim($logo)!='' && is_array(@getimagesize($logo))): ?><img src="<?= $logo; ?>" class="no-borders img-thumbnail" alt="<?= $company_name; ?>" width="150" height="150"><? endif; ?>
                           </div>
                        </div>
                        <div class="col-xs-6 text-right">
                           <h4><?= $company_name; ?></h4>
                           <p><a href="<?= $company_website; ?>"><?= $company_website; ?></a></p>
                           <p><?= $company_email; ?></p>
                           <p><?= nl2br($company_address); ?></p>
                        </div>
                     </div>
                     <div class="well m-t">
                        <div class="row">
                           <div class="col-xs-6">
                              <strong><?= $vis_language['TXTTO']; ?>:</strong>
                              <h4><?= $client['first_name'].' '.$client['last_name']; ?></h4>
                              <p><?= $client['temporary_address']; ?><br>
                                 <?= $client['country']; ?><br>
                                 <span class="font-bold"><?= $vis_language['TXTPHONE']; ?></span>: <?= $client['contact_number']; ?><br>
                                 <span class="font-bold"><?= $vis_language['TXTEMAIL']; ?></span>: <?= $client['email']; ?><br>
                              </p>
                           </div>
                           <div class="col-xs-6">
                              <div class="text-right">
                                 <p><span class="font-bold"><?= $vis_language['TXTSTATUS']; ?></span>:<span class="<? if(!is_mobile()) echo 'h3'; else echo '';?> <?= ($invoice_info['invoice_status']==0)?'vh-red':'vh-green'; ?> <? if(!is_mobile()) echo 'v-middle'; else echo '';?> m-l-sm font-bold"><?= $inv_status[$invoice_info['invoice_status']]; ?></span></p>
                                 <? if($invoice_info['invoice_status']!=0 && $invoice_info['invoice_status']!=2) { ?>
                                 <p><span class="font-bold"><?= $vis_language['TXTPAIDDATE']; ?></span>: <span><?= format_datetime($invoice_info['paid_date']); ?></span></p>
                                 <? } ?>
                                 <p><span class="font-bold"><?= $vis_language['TXTCREATIONDATE']; ?></span>: <span><?= format_datetime($invoice_info['entry_date']); ?></span></p>
                                 <p><span class="font-bold"><?= $vis_language['TXTDUEDATE']; ?></span>: <span><?= format_datetime($invoice_info['due_date']); ?></span></p>
                              </div>
                           </div>
                        </div>
                     </div>
                     <div class="line"></div>
                     <table class="table table-bordered">
                        <thead class="bg-light">
                           <tr>
                              <th><?= $vis_language['TXTDESCRIPTION']; ?></th>
                              <th width="140"><? echo $vis_language['TXTAMOUNT'].' ('.VIS_DOMAIN_CURRENCY.')'; ?></th>
                           </tr>
                        </thead>
                        <tbody>
                           <? if($invoice_details!=-1) for($i=0;$i<count($invoice_details);$i++) {
                              echo '<tr><td>'.nl2br($invoice_details[$i]['description']).'</td><td>'.$invoice_details[$i]['amount'].'</td></tr>'; }?>
                           <tr>
                              <td class="text-right"><strong><? echo ($tax_details['compound_tax']==1)?'Compounded Tax ':' Simple tax '; ?></strong></td>
                              <td><? echo $invoice_info['tax']; ?></td>
                           </tr>
                           <tr>
                           <tr>
                              <td class="text-right"><strong><? echo $vis_language['TXTCREDIT'].' ('.$domain['currency'].')';?></strong></td>
                              <td><? echo $invoice_info['invoiceCredit']; ?></td>
                           </tr>
                           <td class="text-right no-border"><strong><? echo $vis_language['TXTTOTALDUE']; ?></strong></td>
                           <td><? echo $invoice_info['total']-$invoice_info['invoiceCredit']; ?></td>
                           </tr>
                        </tbody>
                     </table>
                     <div class="line"></div>
                     <? if($transaction_info!=-1) { ?>
                     <table class="table table-bordered">
                        <thead class="bg-light">
                           <tr>
                              <th><?= $vis_language['TXTTRANSACTIONID']; ?></th>
                              <th><?= $vis_language['TXTDESCRIPTION']; ?></th>
                              <th><?= $vis_language['TXTTRANSACTIONDATE']; ?></th>
                              <th><? echo $vis_language['TXTPAYMENTMETHOD'];?></th>
                              <th><?= $vis_language['TXTAMOUNT']; ?></th>
                           </tr>
                        </thead>
                        <tbody>
                           <? for($i=0;$i<count($transaction_info);$i++) { ?>
                           <tr>
                              <td><?= $transaction_info[$i]['transaction_id']; ?></td>
                              <td><?= $transaction_info[$i]['content']; ?></td>
                              <td><?= format_datetime($transaction_info[$i]['entry_date']); ?></td>
                              <td><?= $payment_method[$transaction_info[$i]['gateway_id']]; ?></td>
                              <td><?= $transaction_info[$i]['amount']; ?></td>
                           </tr>
                           <? } ?>
                        </tbody>
                     </table>
                     <span class="col-sm-1 m-r-lg pull-right font-bold"> <? echo $invoice_info['balance']; ?></span><span class="col-sm-2 pull-right font-bold"><? echo $vis_language['TXTBALANCE'].' ('.$client['currency'].')'; ?></span>
                     <? } ?>
                  </section>
               </section>
            </section>
         </section>
      </div>
   </div>
</section>
<script>
   function get_pay_mode_details(m) {
       $.ajax({
           url: 'index.php',
           data: { 'vis_module': "billing", 'vis_operation': "edit_invoice", 'vis_gateway':m, 'vis_invoice_id': <? echo $invoice_info['invoice_id']; ?> },
           type: "POST",
           success: function(data) {
               $("#vis_gateway_details").html(data);
           }
       });
   }
</script>

