<?php include "Views/templates/header.php"; ?>

<?php if ($_SESSION['permisos']['agregar nuevo pedido']) { ?>
    <a class="btn btn-primary mb-2" href="<?php echo base_url; ?>pedidos" title='Agregar pedido'><i class="fas fa-plus"></i></a>   
<?php  }  ?>
<?php if ($_SESSION['permisos']['ver pdf 1']) { ?>
    <!--<button type='button' class="btn btn-success mb-2 btn-toolbar-status" disabled onclick="open_link(base_url +'pedidos/generarPedidoPdf/'+active_row)"><i class="fas fa-file-pdf"></i></button> -->
    <button type='button' class="btn btn-info mb-2 btn-toolbar-status" disabled onclick="open_link(base_url +'pedidos/generarPedidoPdfbodega/'+active_row+'/NC')" title='Imprimir Pedido'><i class="fa-solid fa-print"></i></button>
<?php  }  ?>
<?php if ($_SESSION['permisos']['ver pdf 2']) { ?>
    <button type='button' class="btn btn-success mb-2 btn-toolbar-status btn-estatus" disabled onclick="open_link(base_url +'pedidos/generarPedidoPdf/'+active_row)" title='Ver pedido'><i class="fas fa-file-pdf"></i></button>
    <button type='button' class="btn btn-outline-success mb-2 btn-toolbar-status btn-estatus" disabled onclick="open_link(base_url +'pedidos/generarPedidoPdf/'+active_row+'/NC')" title='Ver pedido'><i class="far fa-file-pdf"></i></button>
<?php  }  ?>
<?php if ($_SESSION['permisos']['cambiar tipo de pedido']) { ?>
    <button type="button" class="btn btn-primary mb-2 btn-toolbar-status btn-estatus btn-tipo" disabled onclick="btnType(active_row);" title='Cambiar Tipo'><i class="fa-solid fa-text-height"></i></button>    
<?php  }  ?>
<?php if ($_SESSION['permisos']['cambiar estado del pedido']) { ?>
    <button type="button" class="btn btn-warning mb-2 btn-toolbar-status btn-estatus" disabled onclick="btnStatus(active_row);" title='Cambiar Estado'><i class="fa-solid fa-text-height"></i></button>
<?php  }  ?>
<?php if ($_SESSION['permisos']['cambiar autorizacion del pedido']) { ?>
    <button type="button" class="btn btn-danger mb-2 btn-toolbar-status btn-estatus" disabled onclick="btnAutorizacion(active_row);" title='Cambiar Autorizacion'><i class="fa-solid fa-text-height"></i></button>
<?php  }  ?>
<?php if ($_SESSION['permisos']['cambiar etapa del pedido']) { ?>
    <button type="button" class="btn btn-success mb-2 btn-toolbar-status btn-estatus" disabled onclick="btnControl(active_row);" title='Cambiar Etapa del pedido'><i class="fa-solid fa-text-height"></i></button>
<?php  }  ?>
<?php if ($_SESSION['permisos']['crm del cliente pedidos']) { ?>
    <button type='button' class="btn btn-warning mb-2 btn-toolbar-status btn-estatus" disabled onclick="open_link(base_url +'pedidos/generarCrmCliente/'+active_row)"><i class="fas fa-chart-pie"></i></button>

<?php  }  ?>
<!-- <button type='button' class="btn btn-primary mb-2" onclick="open_link(base_url +'pedidos')"><i class="fas fa-plus"></i></button> -->

<!-- ESTADO PAGADO Y PENDIENTE -->
<!-- <button type="button" class="btn btn-success mb-2 btn-toolbar-status btn-autorizar" disabled onclick="btnFacturarFel(active_row);" style='display:none;'><i class="fas fa-file-invoice-dollar"></i></button> -->

<div class="card">
    <div class="card-body">
        <div class="row">
            <div class="col-md-2">
                <label for="">Desde</label>
                <input class="form-control" id="min" type="date" name="venta_desde">
            </div>
            <div class="col-md-2">
                <label for="">Hasta</label>
                <input class="form-control" id="max" type="date" name="venta_hasta">
            </div>
            <div class="col-md-2">
                <label for="tipo">Tipo</label>                
                <select class="form-control" id="tipo" name="tipo">
                    <option selected value=''>Selecciona una opción</option>
                    <option value="P">PEDIDO</option>
                    <option value="C">COMPLEMENTO</option>
                    <option value="T">RAPIDITO</option>
                </select>
            </div>     
            <div class="col-md-2">
                <label for="estados">Estado</label>                
                <select class="form-control" id="estados" name="estados">
                    <option selected value=''>Selecciona una opción</option>
                    <option value="P">PENDIENTE</option>
                    <option value="E">EMITIDO</option>
                    <option value="A">AUTORIZADO</option>
                    <option value="I">IMPRESO</option>
                    <option value="F">FACTURADO</option>
                    <option value="D">DESPACHADO</option>
                    <option value="R">RETENIDO</option>
                    <option value="X">ANULADO</option>                    
                </select>
            </div>
             <div class="col-md-2">
                <label for="etapa">Etapa</label>                
                <select class="form-control" id="etapa" name="etapa">
                    <option selected value=''>Selecciona una opción</option>
                    <option value="0">NO IMPRESO</option>
                    <option value="1">IMPRESO</option>
                    <option value="2">DESPACHADO</option>
                    <option value="3">ENVIADO</option>                 
                </select>
            </div>

                   

            <div class="col-md-2">
                <div class="form-group">
                    <label for="my-input">Registros</label><br>
                    <button class="btn btn-outline-primary btn-block" type="button" name="historial_ventas" onclick="limpiar_busqueda()">Mostrar Todo</button>
                </div>
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped table-hover display responsive nowrap" id="t_ventas" style="width: 100%;">
                <thead>
                    <tr>
                        <th>Pedido</th>
                        <th>Cliente</th>
                        <th>Nombre</th>
                        <th>Fecha</th>
                        <th>Total</th>
                        <th>Tipo</th>
                        <th>Estado</th>
                        <th>Etapa</th>                        
                        <th>Vendedor</th>
                        <th>Facturado</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
    </div>
</div>

<?php include "Views/templates/footer.php"; ?>