<script type="text/javascript">
    $(document).ready(function(){
        supplierInvoices();
    });
    function supplierInvoices(){
      $("#invoicesAp tbody tr").remove();   
      $.ajax({
        type: "POST",
            url: '<?php echo base_url();?>home/openPurchaseInvoice',
        dataType:"json",
        success: function(content){
          if(content.status == "success") {
            $("#invCount").html("+"+content.message.length);
            if(content.message.length > 5){
              var lengthRec = 5;
            }else{
              var lengthRec = content.message.length;
            }
            for ( var i = 0; i < lengthRec; i++) {
                  $("#invoicesAp tbody").append(
                "<tr><td style='display:none'>"+content.message[i].ID+"</td>" +
                      "<td><a href='<?php echo base_url(); ?>apreports/purchaseInvoiceDetail/"+ content.message[i].ID +"' target='_blank'>"+(content.message[i].invoiceDate).substr(8, 2) + 
                  "-" + (content.message[i].invoiceDate).substr(5, 2) +
                  "-" + (content.message[i].invoiceDate).substr(0, 4) + "</a></td>" +
                "<td><a href='<?php echo base_url(); ?>aptransaction/payment/"+ content.message[i].supplierID+"/"+content.message[i].supplierInvoiceNo+"' target='_blank'>"+content.message[i].supplierInvoiceNo+"</a></td>" +
                    "<td>"+content.message[i].supplierName+' ['+content.message[i].formNo+"]</td>" +
                    "<td>"+content.message[i].phoneNumber1+' ['+content.message[i].attention+"]</td>" +
                    "<td class='tar'>"+content.message[i].fldcurr_code + ' ' + accounting.formatNumber(content.message[i].totalPayable,2)+"</td>" +
                    "</tr>");
            }
          }
        }
      });
    }
</script>

<div class="row-fluid scRow">
    <div class="span12 scCol">
      <div class="block">
        <div class="head">                                   
          <h2>Due Purchase Amount</h2>                                        
                                <ul class="buttons">
                                    <li><a href="#" class="block_loading"><span class="i-cycle"></span></a></li>
                                    <li><a href="#" class="block_toggle"><span class="i-arrow-down-3"></span></a></li>
                                    <li><a href="#" class="block_remove"><span class="i-cancel-2"></span></a></li>
                                </ul>                                        
                                <!-- <div class="side fr">
                                    <span class="label label-important" id="invCount"></span>
                                </div> -->                                        
                        </div>                                                                    
        <div class="content np">
          <table cellpadding="0" cellspacing="0" width="100%" class="list" id="invoicesAp">
            <thead>
              <tr>
                <th width="10%"><?php echo $this->lang->line('date')?></th>
                                        <th width="25%"><?php echo $this->lang->line('supplierInvoiceNo')?></th>
                                        <th width="25%"><?php echo $this->lang->line('supplier')?></th>
                                        <th width="20%"><?php echo $this->lang->line('contact')?></th>
                                        <th width="20%" class="tar"><?php echo $this->lang->line('outstandAmount')?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
            <tfoot>
              <tr>
                  <td colspan="5" align="right">
                      <a class="btn-form btn-info-form" href="<?php echo base_url(); ?>aptransaction/payment" target="_blank"><?php echo $this->lang->line('supplierPayment')?></a>
                  </td>
              </tr>
                                </tfoot>
          </table>
                        </div>
                        
                                                                        
      </div>                                
    </div>
  </div>
</div><!-- row -->