<?php 
$sql=$db->fetch_custom('SELECT MAX(factura.numfact) as max FROM factura');
foreach ($sql as $max) {
  $num = str_pad($max->max + 1, 6, "0", STR_PAD_LEFT);
}



//include("modal/registro_clientes.php");
//include("modal/registro_productos.php");

?>
           
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                     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">Añadir Nuevafactura</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
<div class="row">
    <div class="col-lg-12"> 
        <div class="box box-solid box-primary">
                                 <div class="box-header">
                                    <h3 class="box-title">Añadir Nuevafactura</h3>
                                    <div class="box-tools pull-right">
                                        <button class="btn btn-info btn-sm" data-widget="collapse"><i class="fa fa-minus"></i></button>
                                        <button class="btn btn-info btn-sm" data-widget="remove"><i class="fa fa-times"></i></button>
                                    </div>
                                </div>

                  <div class="box-body">
                     <!--<form id="input" method="post" class="form-horizontal foto_banyak col-lg-12" action="<?=base_admin();?>modul/nuevafactura/nuevafactura_action.php?act=in">-->
                      <form id="datos_factura" class="form-horizontal foto_banyak">
                        <div class=" col-lg-3">
                      <div class="form-group">
                        <label for="Número" class="control-label">Número</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-hashtag"></i>
                          </div>
                          <input id="numfact" type="text" name="numfact" placeholder="Número" class="form-control" value="<?=$num?>" readonly> 
                        </div>
                      </div><!-- /.form-group -->
                    </div>
                      <div class=" col-lg-3 col-lg-offset-1">
<div class="form-group  ">
                        <label for="Fecha" class="control-label">Fecha</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-calendar"></i>
                          </div>
                          <input type="text" name="fecha"  id="tgl1" data-rule-date="true" placeholder="Fecha" class="form-control" value="<?php date_default_timezone_set('America/Bogota'); echo date('Y-m-d'); ?>"> 
                        </div>
                      </div><!-- /.form-group -->
                      </div>
                      <div class=" col-lg-3 col-lg-offset-1">
<div class="form-group ">
                        <label for="Clientes" class="control-label">Clientes</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-user"></i>
                          </div>
                          <select id="clientes_idclientes" name="clientes_idclientes" data-placeholder="Seleccione Clientes ..." class="form-control chzn-select" tabindex="2" >
               <option value=""></option>
               <?php foreach ($db->fetch_all("clientes") as $isi) {
                  echo "<option value='$isi->idclientes'>$isi->nombres $isi->apellidos</option>";
               } ?>
              </select>
                        </div>
                      </div><!-- /.form-group -->
                    </div>
                    <div class=" col-lg-3">
<div class="form-group ">
                        <label for="Condiciones" class="control-label">Condiciones</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-file"></i>
                          </div>
                          <input id="condiciones" type="text" name="condiciones" placeholder="Condiciones" class="form-control" > 
                        </div>
                      </div><!-- /.form-group -->
                    </div>
<!--<div class="form-group">
                        <label for="Total" class="control-label">Total</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-id-card-o"></i>
                          </div>
                          <input type="text" name="total_venta" placeholder="Total" class="form-control" > 
                        </div>
                      </div> /.form-group -->
                      <div class=" col-lg-3 col-lg-offset-1">
<div class="form-group ">
                        <label for="Estado" class="control-label">Estado</label>
                        <div class="input-group">
                          <div class="input-group-addon">
                            <i class="fa fa-check"></i>
                          </div>
                          <select id="estado" name="estado" data-placeholder="Seleccione Estado ..." class="form-control chzn-select" tabindex="2" >
                           <option value="P">Pagada</option>
                           <option value="D">Sin Pagar</option>
                           <option value="A">Anulada</option>
                          </select> 
                        </div>
                      </div><!-- /.form-group -->
                    </div>

                      
                      <!-- <div class="form-group col-lg-4">
                        <label for="tags" class="control-label">&nbsp;</label>
                        <div class="input-group">
                          <input type="submit" class="btn btn-primary btn-flat" value="Enviar">
                          <a href="<?=base_index();?>nuevafactura" class="btn btn-success btn-flat"><i class="fa fa-step-backward"></i> Volver</a>
                        </div>
                      </div>/.form-group -->

                      <div class="col-lg-12">
                        <div class="pull-right">
                          <!--<button type="button" class="btn btn-info" data-toggle="modal" data-target="#nuevoProducto">
                           <span class="fa fa-plus"></span> Nuevo producto
                          </button>-->
                          <?php// require_once('inc/modal/registro_productos.php') ?>
                          <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#nuevoCliente">
                           <span class="fa fa-user"></span> Nuevo cliente
                          </button>
                          <?php require_once('inc/modal/registro_clientes.php'); ?>
                          <button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal">
                           <span class="fa fa-search"></span> Agregar productos
                          </button>
                          <?php require_once('inc/modal/buscar_productos.php'); ?>
                          <button id="datosfact" type="submit" class="btn btn-primary">
                            <span class="fa fa-print"></span> Imprimir
                          </button>
                          <!--<input type="submit" class="btn btn-primary " value="Guardar">-->
                          <a href="<?=base_index();?>nuevafactura" class="btn btn-danger "><i class="fa fa-step-backward"></i> Cancelar</a>
                        </div>  
                      </div>
                    </form>
                    <div id="resultados" class='col-md-12' style="margin-top:10px"></div>
          
                  </div>
                  </div>
              </div>
</div>               
                </section><!-- /.content -->
<script type="text/javascript" src="../../inc/js/VentanaCentrada.js"></script>                  
<script type="text/javascript" src="../../inc/js/nueva_factura.js"></script>
