<?php
ob_start();
ini_set('session.gc_maxlifetime', 14400);
session_set_cookie_params(14400);
session_start();

if (!isset($_SESSION["nombre"]))
{
  header("Location: index.php");
}
else
{
    require '../header.php';

if($_SESSION['ventas']==1 and $_SESSION['nombrecargo']!== "Vendedor"){

?>

            <div class="content-wrapper">
                <!-- Breadcrumb Section -->
                <section class="content-header">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <nav aria-label="breadcrumb">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item">
                                            <a href="#"><i class="fas fa-home"></i> Panel</a>
                                        </li>
                                        <li class="breadcrumb-item active" aria-current="page">
                                            <a href="list.php">
                                                <i class="module-icon"></i> Venta
                                            </a>
                                        </li>
                                    </ol>
                                </nav>
                            </div>
                          
                            <div class="col-sm-12" style="margin-top: 20px;">
                                <div class="card  ">
                                    <div class="card-header bg-primary">
                                        <h3 class="card-title">
                                            <i class="fas fa-search"></i>
                                            Consulta Venta del Dia
                                        </h3>
                                    </div>
                                    <div class="card-body" style="display: block;">
                                        <div class="container-fluid">
                                        <div class="row">
                                            <div class="col-12 col-sm-12 col-md-1">
                                            </div>
                                            <div class="col-12 col-sm-12 col-md-2">
                                                <div class="form-group">
                                                    <br>
                                                    <select id="idusuario" name="idusuario" class="form-control select2" data-live-search="true" required="" >
                                                        </select>
                                                </div>
                                            </div>
                                            <div class="col-12 col-sm-12 col-md-2">
                                                <div class="form-group">
                                                    <br>
                                                    <select id="idtitular" name="idtitular" class="form-control select2" data-live-search="true" required="" >
                                                        </select>
                                                </div>
                                            </div>
                                            <div class="col-12 col-sm-12 col-md-2">
                                                <div class="form-group">
                                                    <br>
                                                    <input name="fecha_inicio" id="fecha_inicio" class="form-control" type="date" required>
                                                </div>
                                            </div>
                                            <div class="col-12 col-sm-12 col-md-2">
                                                <div class="form-group">
                                                    <br>
                                                    <input name="fecha_fin" id="fecha_fin" class="form-control" type="date" required>
                                                </div>
                                            </div>
                                            <div class="form-group col-lg-3 col-md-3 col-sm-3 col-xs-12">
                                                <br>
                                                <button class="btn btn-success btn-flat " style="margin-bottom:-10px" onclick="listar_dia()">Consultar Venta </button>
                                               <button class="btn btn-primary btn-flat " style="margin-bottom:-10px" onclick="generarExcel()"><i class="fa fa-table"></i> Excel</button>
                                                <button class="btn btn-danger btn-flat" style="margin-bottom:-10px" onclick="generarPDF()"><i class="fa fa-file"></i> PDF</button>
                                            </div>
                                            </div>
                                                <div id="contenedor_movimientos"></div>
                                                <div id="contenedor_resumen"></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>                
            </div>
            <?php
}else if($_SESSION['ventas']==1 and $_SESSION['nombrecargo']== "Vendedor"){
?>     
             <div class="content-wrapper">
                <!-- Breadcrumb Section -->
                <section class="content-header">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-sm-12">
                                <nav aria-label="breadcrumb">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item">
                                            <a href="#"><i class="fas fa-home"></i> Panel</a>
                                        </li>
                                        <li class="breadcrumb-item active" aria-current="page">
                                            <a href="list.php">
                                                <i class="module-icon"></i> Venta
                                            </a>
                                        </li>
                                    </ol>
                                </nav>
                            </div>
                          
                            <div class="col-sm-12" style="margin-top: 20px;">
                                <div class="card  ">
                                    <div class="card-header bg-primary">
                                        <h3 class="card-title">
                                            <i class="fas fa-search"></i>
                                            Consulta Venta del Dia
                                        </h3>
                                    </div>
                                    <br>
                                    <div class="form-group col-lg-3 col-md-3 col-sm-3 col-xs-12">
                                    <button class="btn btn-danger btn-flat " style="margin-bottom:-10px" onclick="generar_reporte_usuario()"> <i class="fa-solid fa-pdf"></i> Reporte Venta</button>
                                    </div>
                                    <div class="card-body" style="display: block;">
                                        <div class="container-fluid">
                                            <table style="width:100%;" class="table table-bordered" id="listar_dia_vendedor">
                                                <thead>
                                                <tr>
                                                    <th>Fecha</th>
                                                    <th>Responsable</th>
                                                    <th>Nombre Cliente</th>
                                                    <th>Nro Guia Tienda</th>
                                                    <th>Total Venta</th>
                                                    <th>Tipo Pago</th>
                                                    <th>Banco</th>
                                                    <th>Titular</th>
                                                    <th>Tipo Venta</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                </tbody>
                                            </table>
                                            <br>
                                            <div class="row">
                                                <br>
                                                <div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12" align="center" >
                                                    <div style="text-align:center; font-size:large;font-weight: 500;" class="alert alert-success" >
                                                        <label>Venta Total Efectivo </label>
                                                        <p>
                                                        <span id="sumaefectivo">0.00</span><span> Soles</span>
                                                        </p>
                                                    </div>
                                                </div>
                                                <div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12" align="center" >
                                                    <div style="text-align:center; font-size:large;font-weight: 500;" class="alert alert-danger" >
                                                        <label>Venta Total Transferencia </label>
                                                        <p>
                                                        <span id="sumatransferencia">0.00</span><span> Soles</span>
                                                        </p>
                                                    </div>
                                                </div>
                                                <div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12" align="center" >
                                                    <div style="text-align:center; font-size:large;font-weight: 500;" class="alert alert-dark" >
                                                        <label>Total Venta </label>
                                                        <p>
                                                        <span id="sumatotal">0.00</span><span> Soles</span>
                                                        </p>
                                                    </div>
                                                </div>
                                            </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>                
            </div>


<?php
}
require '../footer.php';
?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/exceljs/dist/exceljs.min.js"></script>
<script type="text/javascript" src="../../scripts/venta.js"></script>
<?php 
}
ob_end_flush();
?>
   