<?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){

?>
        
            <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;">
                                <form class="form" method="post"  id="frmForm" autocomplete="off">
                                    <div class="card">
                                        <div class="card-header">
                                            <h3 class="card-title" id="idtitle" >
                                                <i class="fas fa-plus"></i> <!-- Icono para agregar -->
                                                Registro Acuenta Productos<!-- Título del formulario -->
                                            </h3>
                                        </div>
                                        <div class="card-body" style="display: block;">
                                            <div class="container-fluid">
                                                <div class="row">
                                                    <div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-2">
                                                        <strong>NRO BOLETA: </strong><strong id="nrocorrelativo_texto" name="nrocorrelativo_texto" style="background-color: green; color: white; padding: 5px; border-radius: 3px;"></strong>
                                                    </div>
                                                </div>
                                                <input type="hidden" name="idventa" id="idventa">
                                                <div class="row">
                                                    <!-- Primera columna -->
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label for="idpersona">Nombre Cliente:</label>
                                                            <select id="idpersona" name="idpersona" class="form-control select2" data-live-search="true" readonly="" >
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label for="nroguia">Numero - Guia:</label>
                                                            <input type="text" class="form-control" name="nroguia" id="nroguia" readonly="" placeholder="Numero - Guia">
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-2">
                                                        <div class="form-group">
                                                            <label for="total">Total Venta:</label>
                                                            <input type="text" class="form-control" name="total_venta" id="total_venta" readonly="" placeholder="Total Venta">
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-2">
                                                        <div class="form-group">
                                                            <label for="total_acuenta">Total Acuenta:</label>
                                                            <input type="text" class="form-control" name="total_acuenta" id="total_acuenta" readonly="" placeholder="Acuenta">
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-2">
                                                        <div class="form-group">
                                                            <label>Fecha Venta(*):</label>
                                                            <input type="date" class="form-control" name="fecha_hora" id="fecha_hora" readonly="">
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label>Fecha Pago(*):</label>
                                                            <input type="date" class="form-control" name="fecha_pago" id="fecha_pago" requerid>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label for="monto">Monto:</label>
                                                            <input type="number" class="form-control" name="monto" id="monto"  placeholder="Monto a Pagar" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label for="descripcion">Descripcion:</label>
                                                            <input type="text" class="form-control" name="descripcion" id="descripcion"  placeholder="Descripcion" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="form-group">
                                                            <label for="monto">Tipo Pago:</label>
                                                            <select  class="form-control" name="tipopago" id="tipopago" data-live-search="true" data-style="btn-default" required >
                                                                    <option value="">Selecciones Tipo Pago</option>
                                                                    <option value="1">Efectivo</option>
                                                                    <option value="2">Transferencia</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3" id="titular-fields" style="display: none; text-align: left;">
                                                        <div class="form-group">
                                                            <label style="text-align: left; display: block;">Titular:</label>
                                                            <select class="form-control" type="text" name="idtitular" id="idtitular"></select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-6 col-md-3" id="deposito-fields" style="display: none; text-align: left;">
                                                        <div class="form-group">
                                                            <label style="text-align: left; display: block;">Banco:</label>
                                                            <select class="form-control" type="text" name="idbanco" id="idbanco"></select>
                                                        </div>
                                                    </div>
                                                    <br>
                                                    <div class="col-12 col-sm-6 col-md-3">
                                                        <div class="card-footer">
                                                            <!-- Botones de acción -->
                                                            <button type="submit" id="btnGuardar" class="btn btn-primary btn-flat">
                                                                <i class="fas fa-save"></i> Guardar pago
                                                            </button>
                                                            <a href="list.php" class="btn btn-danger btn-flat">
                                                                <i class="fas fa-times"></i> Cancelar
                                                            </a>
                                                        </div>
                                                    </div>
                                                    <div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12 table-responsive">
                                                        <table id="detalles_acuenta" class="table table-striped table-bordered table-condensed table-hover">
                                                            <thead>
                                                                <th style="background-color:#000000;color: white;">Opciones</th>
                                                                <th style="background-color:#000000;color: white;">Descripcion</th>
                                                                <th style="background-color:#000000;color: white;">Tipo Pago</th>
                                                                <th style="background-color:#000000;color: white;">Monto</th>
                                                                <th style="background-color:#000000;color: white;">Fecha Registro</th>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                            <tfoot>
                                                            </tfoot>
                                                        </table>
                                                     </div>
                                                </div>  
                                            </div>
                                        </div>
                                       
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>                
            </div>


               
<?php
}
require '../footer.php';
?>
<script type="text/javascript" src="../../scripts/acuenta.js"></script>

<?php 
}
ob_end_flush();
?>