<script src="https://cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.1/js/buttons.print.min.js"></script>
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        Gestionar Nuevafactura
                    </h1>
                       <ol class="breadcrumb">
                        <li><a href="<?=base_index();?>"><i class="fa fa-dashboard"></i> Inicio</a></li>
                        <li><a href="<?=base_index();?>nuevafactura">Nuevafactura</a></li>
                        <li class="active">Listado Nuevafactura</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                                <div class="box-header">
                                  <h3 class="box-title">Lista Nuevafactura</h3>
                                  <?php
       foreach ($db->fetch_all("sys_menu") as $isi) {
                      if ($path_url==$isi->url) {
                          if ($role_act["insert_act"]=="Y") {
                    ?>
          <a href="<?=base_index();?>nuevafactura/tambah" class="btn btn-primary btn-flat col-lg-offset-9 col-md-offset-8 col-sm-offset-6 col-xs-offset-6"><i class="fa fa-plus"></i> Nuevo</a>
                          <?php
                          } 
                       } 
}
?> 
                                </div><!-- /.box-header -->
                                <div class="box-body table-responsive">
                                    <table id="dtb_manual" class="table table-bordered table-striped">
                                   <thead>
                                     <tr>
                           <th style="width:25px" align="center">No</th>
                          <th>Número</th>
													<th>Fecha</th>
													<th>Condiciones</th>
													<th>Total</th>
													<th>Estado</th>
													<th>Cliente</th>
													
                          <th>Acción</th>
                         
                        </tr>
                                      </thead>
                                        <tbody>
                                         <?php 
      $dtb=$db->fetch_custom("select factura.numfact,factura.fecha,factura.condiciones,factura.total_venta,factura.estado,clientes.nombres,factura.idfactura from factura  inner join clientes on factura.clientes_idclientes=clientes.idclientes");
      $i=1;
      foreach ($dtb as $isi) {
        ?><tr id="line_<?=$isi->idfactura;?>">
        <td align="center"><?=$i;?></td><td><?=$isi->numfact;?></td>
<td><?=$isi->fecha;?></td>
<td><?=$isi->condiciones;?></td>
<td><?=$isi->total_venta;?></td>
<td><?php switch ($isi->estado) { 
  case 'D': ?>
    <span class="badge bg-red">Sin Pagar</span>
    <?php
    break;
  case 'P': ?>
    <span class="badge bg-green">Pagada</span>
    <?php
    break;
    case 'A': ?>
    <span class="badge bg-warning">Anulada</span>
    <?php
    break;
  default:
    break;
} ?></td>
<td><?=$isi->nombres;?></td>

        <td>
        <a href="<?=base_index();?>nuevafactura/detail/<?=$isi->idfactura;?>" class="btn btn-success btn-flat"><i class="fa fa-eye"></i></a> 
        <?=($role_act["up_act"]=="Y")?'<a href="'.base_index().'nuevafactura/edit/'.$isi->idfactura.'" class="btn btn-primary btn-flat"><i class="fa fa-pencil"></i></a>':"";?>  
        <?=($role_act["del_act"]=="Y")?'<button class="btn btn-danger hapus btn-flat" data-uri="'.base_admin().'modul/nuevafactura/nuevafactura_action.php" data-id="'.$isi->idfactura.'"><i class="fa fa-trash-o"></i></button>':"";?>
        </td>
        </tr>
        <?php
        $i++;
      }
      ?>
                                        </tbody>
                                    </table>
                                </div><!-- /.box-body -->
                            </div><!-- /.box -->
                        </div>
                    </div>
        <?php
       /*foreach ($db->fetch_all("sys_menu") as $isi) {
                      if ($path_url==$isi->url) {
                          if ($role_act["insert_act"]=="Y") {
                    ?>
          <a href="<?=base_index();?>nuevafactura/tambah" class="btn btn-primary btn-flat"><i class="fa fa-plus"></i> Nuevo</a>
                          <?php
                          } 
                       } 
}*/
?>  
                </section><!-- /.content -->
<script>
$(document).ready(function() {
    $('#dtb_manual').DataTable( {
        dom: 'Blfrtip',
        buttons: [
            {
                extend: 'excelHtml5',
                autoFilter: true,
                text:'<i class="fa fa-file-excel-o"></i> Excel',
                title: 'facturas'
            },
            {
                extend: 'pdfHtml5',
                text:'<i class="fa fa-file-pdf-o"></i> PDF',
                title: 'facturas'
            }
        ]
    } );
} );
</script>        
