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

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

if($_SESSION['contratos']==1){
    $idcontrato=$_GET['idcontrato'];
?>
            <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>Contrato
                                            </a>
                                        </li>
                                    </ol>
                                </nav>
                            </div>
                          
                            <div class="col-sm-12" style="margin-top: 20px;">
                                <form class="form" method="post"  id="frmForm_contrato" autocomplete="off">
                                    <div class="card">
                                        <div class="card-header">
                                            <h3 class="card-title" id="idtitle" >
                                                <i class="fas fa-plus"></i> <!-- Icono para agregar -->
                                                Consulta Contrato<!-- Título del formulario -->
                                            </h3>
                                            &nbsp;&nbsp;
                                            <button type='button'  class='btn btn-primary btn-flat btn-xs' onclick='mostrarExtender(<?php echo $idcontrato ?>)'  data-toggle="modal" data-target="#modal_extender" ><i class="fa fa-plus-circle"></i>&nbsp;&nbsp;Extender Contrato</button>
                                            <button type='button'  class='btn btn-flat btn-xs modallamada' onclick='mostrarLlamada(<?php echo $idcontrato ?>)'  data-toggle="modal" data-target="#modal_llamada" style='background-color:#3e038c;color: #FFFFFF' ><i class="fa fa-phone"></i>&nbsp;&nbsp;Historial de Llamada</button>
                                        </div>
                                        <div class="card-body" style="display: block;">
                                            <div class="container-fluid">
                                                <input type="hidden" name="idcontrato" id="idcontrato">
                                                <div class="row">
                                                    <!-- Primera columna -->
                                                    <div class="col-12 col-sm-12 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-12 col-md-2">
                                                        <div class="form-group">
                                                            <label for="iddireccion">Direcciones:</label>
                                                            <select id="iddireccion" name="iddireccion" 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">
                                                            <label for="estado_contrato">Situacion Contrato:</label>
                                                            <input id="estado_contrato" name="estado_contrato" class="form-control" onclick="cambiarContrato()" readonly>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-12 col-md-2">
                                                        <div class="form-group">
                                                            <label for="sit_contrato">Situacion Linea:</label>
                                                            <input type="text" class="form-control" id="sit_contrato" name="sit_contrato" onclick="cambiarEstado()" readonly>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="col-12 col-sm-12 col-md-3">
                                                        <div class="form-group">
                                                            <label for="fecha_hora">Fecha Contrato:</label>
                                                            <input type="date" class="form-control" name="fecha_hora" id="fecha_hora"  readonly="">
                                                        </div>
                                                    </div>

                                                    <div class="col-12 col-sm-12 col-md-3">
                                                        <div class="form-group">
                                                            <label for="nrocontrato">Nro Contrato:</label>
                                                            <input type="text" class="form-control" name="nrocontrato" id="nrocontrato"  readonly="">
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="col-12 col-sm-12 col-md-2">
                                                        <div class="form-group">
                                                            <label >Servicio:</label>
                                                            <select id="idservicio" name="idservicio" 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">
                                                            <label >Tecnologia:</label>
                                                            <select id="idtecnologia" name="idtecnologia" 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">
                                                            <label >OLT:</label>
                                                            <select id="idolt" name="idolt" class="form-control select2" data-live-search="true" >
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-12 col-md-3">
                                                        <div class="form-group">
                                                            <label >Plan:</label>
                                                            <select id="idplan" name="idplan" class="form-control select2" data-live-search="true" required>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-3">
                                                        <div class="form-group">
                                                            <label >Mensualidad:</label>
                                                            <input type="text" id="mensualidad" name="mensualidad" class="form-control" placeholder="Mensualidad"  readonly="" >
                                                            <input type="hidden" id="upload_servicio" name="upload_servicio">
                                                            <input type="hidden" id="download_servicio" name="download_servicio">
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-12 col-md-2">
                                                        <div class="form-group">
                                                            <label >Torre:</label>
                                                            <select id="idtorre" name="idtorre" 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">
                                                            <label >Repetidor:</label>
                                                            <select id="idrepetidor" name="idrepetidor" class="form-control select2" data-live-search="true" >
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-2">
                                                        <div class="form-group">
                                                            <label for="tipo" >Tipo Contrato:</label>
                                                            <select  name="tipo" id="tipo" class="form-control"  data-live-search="true" data-style="btn-default"  readonly="">
                                                                <option value="">Seleccione Tipo</option>
                                                                <option value="6">6 Meses</option>
                                                                <option value="12">12 Meses</option>      
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-3">
                                                        <div class="form-group">
                                                            <label for="modalidad" >Modalidad Pago:</label>
                                                            <select  name="modalidad" id="modalidad" class="form-control"  data-live-search="true" data-style="btn-default"  readonly="">
                                                                <option value="">Seleccione Modalidad</option>
                                                                <option value="Equipo de Venta">Equipo de Venta</option>
                                                                <option value="Equipo de Prestamo">Equipo de Prestamo </option>
                                                                <option value="Equipo Propio Cliente">Equipo Propio Cliente</option>     
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-3">
                                                        <div class="form-group">
                                                            <label for="fechapago" >Fecha Pago:</label>
                                                            <select  name="fechapago" id="fechapago" class="form-control"  data-live-search="true" data-style="btn-default" required>
                                                                <option value="">Seleccione Fecha</option>
                                                                <option value="1">01 de Mes</option>
                                                                <option value="5">05 de Mes</option>
                                                                <option value="10">10 de Mes</option>
                                                                <option value="15">15 de Mes</option>
                                                                <option value="20">20 de Mes</option>
                                                                <option value="25">25 de Mes</option> 
                                                                <option value="30">30 de Mes</option>      
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-3">
                                                        <div class="form-group">
                                                            <label for="paga" >Paga:</label>
                                                            <select  name="paga" id="paga" class="form-control"  data-live-search="true" data-style="btn-default"  >
                                                                <option value="">Seleccione Tipo</option>
                                                                <option value="Mes Cumplido">Mes Cumplido</option>
                                                                <option value="Mes Adelantado">Mes Adelantado</option>      
                                                            </select>
                                                        </div>
                                                    </div>
                                                    
                                                    <div class="col-12 col-sm-3 col-md-6">
                                                        <div class="form-group">
                                                            <label for="descripcion" >Descripcion Contrato</label>
                                                            <input type="text" id="descripcion" name="descripcion" class="form-control" placeholder="Descripcion" required>
                                                        </div>
                                                    </div>
                                                    <div class="col-12 col-sm-3 col-md-3">
                                                    <div class="card-footer">
                                                        <button type="submit" id="btnGuardar" class="btn btn-primary btn-flat">
                                                            <i class="fas fa-save"></i> Guardar registro
                                                        </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="detallecuotas" class="table table-striped table-bordered table-condensed table-hover">
                                                            <thead>
                                                                <th style="background-color:#4564ff;color: white; width: 10%">Opciones</th>
                                                                <th style="background-color:#4564ff;color: white;">Nro</th>
                                                                <th style="background-color:#4564ff;color: white;">Situacion</th>
                                                                <th style="background-color:#4564ff;color: white;">Mes</th>
                                                                <th style="background-color:#4564ff;color: white; width: 12%">Ciclo Facturacion</th>
                                                                <th style="background-color:#4564ff;color: white;">Fecha Corte</th>
                                                                <th style="background-color:#4564ff;color: white;">Monto</th>
                                                                <th style="background-color:#4564ff;color: white;">Cuotas</th>
                                                                <th style="background-color:#4564ff;color: white;">Descripcion Cuota</th>
                                                                <th style="background-color:#4564ff;color: white;">Pagado</th>
                                                                <th style="background-color:#4564ff;color: white;">Recibo</th>
                                                                <th style="background-color:#4564ff;color: white;">Comentario</th>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                     </div>
                                                </div>  
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>                
            </div>

           
        

            <div class="modal fade" id="refacturacionModal" tabindex="-1" role="dialog" aria-labelledby="editCuotaLabel" >
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header bg-danger">
                            <h5 class="modal-title" id="refacturacionModalLabel">Facturacion Cuota</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span>&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form id="refacturacionForm">
                                <input type="hidden" id="idcuota1" name="idcuota1">
                                <input type="hidden" id="idcontrato1" name="idcontrato1">
                                <input type="hidden" id="idtecnologia1" name="idtecnologia1">
                                <input type="hidden" id="idcliente" name="idcliente">
                                <div class="row">
                                        <div class="col-md-12">
                                                <div class="form-group"> 
                                                    <label>Tipo Pago:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <input  type="radio"  name="tipo" id="pago_acuenta" value="1"><label>ACUENTA</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;             
                                                    <input checked="checked"  type="radio"  name="tipo" id="pago_completo" value="2"><label>&nbsp;COMPLETO</label><br/>  
                                                </div>
                                        </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label>Ciclo Facturacion:</label>                          
                                            <input class="form-control" type="date" name="fechainicial" id="fechainicial" readonly=""   />  
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label>&nbsp</label> 
                                            <input class="form-control" type="date" name="fechavencimiento" id="fechavencimiento" readonly=""   /> 
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label>Fecha Corte:</label>                          
                                            <input class="form-control" type="date" name="fecha_pago" id="fecha_pago" />  
                                            <br />
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label>Situaccion Linea:</label>                          
                                            <input class="form-control" type="text" name="sit_contratof" id="sit_contratof"  readonly />  
                                            <br />
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group"> 
                                            <label>Forma de Pago:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input  type="radio" class="incorrecto" value="2" name="pago" id="pago_efectivo"><label>EFECTIVO</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;             
                                            <input checked="checked" type="radio" class="correcto" value="3" name="pago" id="pago_deposito"><label>&nbsp;DEPOSITO</label><br/>  
                                        </div>
                                    </div>
                                    
                                    <div class="col-md-12" id="div1">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label for="idbanco">Banco:</label>
                                                    <select class="form-contro select2" name="idbanco" id="idbanco">
                                                    </select>
                                                </div>
                                            </div>
                                            <input type="hidden" id="nombre_banco" name="nombre_banco">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label for="nrooperacion">Nro Operación:</label>
                                                    <input type="text" name="nrooperacion" id="nrooperacion" class="form-control" placeholder="Escriba nro Operación">
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="col-md-12">
                                        <div class="form-group">  
                                            <label>Fecha y Hora:</label>  
                                                <input type="datetime-local"  class="form-control" name="fecha" id="fecha" required  >                     
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <input type="hidden" id="averia"  ></input>
                                            <table border="1" class="table table-striped table-bordered table-condensed table-hover">
                                            <thead style="background-color:#A9D0F5">
                                                <tr>
                                                <th ></th>
                                                    <th width="60%">Descripcion</th>
                                                    <th>Monto</th>                
                                                </tr>
                                                    <tbody>
                                                        <?php 
                                                        echo "<tr>   
                                                        <td></td>             
                                                        <td><input id='descripcionf' class='form-control' name='descripcionf' readonly  ></input> </td>               
                                                        <td><input class='form-control' name='montof' id='montof' readonly  ></input></td>                                     
                                                        </tr>";
                                                        echo "<tr>
                                                        <td> <a target='_blank' href='../vistas/vistaatencion.php?id=' id='averia1'  class='btn btn-warning btn-sm'><i class='fa fa-file' ></i></a> </td>                
                                                        <td> <input id='descripcionmonto' class='form-control' name='descripcionmonto' ></input></td>               
                                                        <td> <input class='form-control' name='cuota' id='cuota'></input></td>                                     
                                                        </tr>";
                                                        ?>
                                                    </tbody>
                                            </thead>
                                            </table>
                                    </div>
                                    <div class="col-md-12" id="div2" style="display: none;">
                                        <div class="row">
                                            <div class="col-md-4">
                                                <div class="form-group">
                                                    <label>Monto Acuenta: </label>  
                                                    <input  type="number" step="0.01" class='form-control' name="montoacuenta" id="montoacuenta" readonly placeholder="Escriba el monto acuenta"> </input> 
                                                </div>
                                            </div>
                                            <div class="col-md-4">
                                                <div class="form-group">
                                                    <label>Monto a Pagar: </label>                            
                                                    <input class='form-control' name='monto_pagar' id='monto_pagar' readonly ></input>
                                                </div>
                                            </div>
                                            <div class="col-md-4">
                                                <div class="form-group">  
                                                    <label>Cancela: </label>  
                                                    <input  type="number" name="paga"  id="paga" step="0.01" class="form-control" value='0.00'/> </input>  
                                                </div>
                                            </div> 
                                        </div>
                                    </div>
                                    <div class="col-md-12">
                                        <div class="form-group">  
                                            <label>Comentario:</label>  
                                            <input  type="text" class="form-control" name="comentario" id="comentario"    placeholder="Ingrese un Comentario" ></input>   
                                        </div> 
                                    </div>
                                </div>
                            
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary  btn-flat" data-dismiss="modal">Cerrar</button>
                            <button type="submit" id="btnActualizar" class="btn btn-danger btn-flat">Registrar Cuota</button>
                        </div>
                        </form>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="modal_llamada" tabindex="-1" role="dialog"  >
                <div class="modal-dialog modal-lg " role="document">
                    <div class="modal-content">
                        <div class="modal-header"  style="background:#3e038c; color:white">
                            <h5 class="modal-title" id="modal_llamadaLabel">Chat Llamada</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span>&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form id="chatmodalForm">
                                <div class="row">
                                     <input type="hidden" id="idcontrato" name="idcontrato" value="<?php echo $idcontrato?>">
                                        <div class="col-md-12">
                                            <div class="form-group"> 
                                                <div id="tblarticuloss" class="table table-striped table-bordered table-condensed table-hover">                       
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-12">
                                            <div class="form-group"> 
                                                <textarea id="descripcion" name="descripcion" rows="5" cols="100" required="" placeholder="Escribe una descripcion"></textarea>
                                            </div>
                                        </div>
                                        <div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-6">                
                                            <label>Monto de Equipo(*)</label>                           
                                            <input type="number" class="form-control" name="montoequipo" id="" value="0.00" required="" placeholder="Monto Equipo">
                                        </div> 
                                        <div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-6">                
                                            <label>Monto de Mensualidad(*)</label>                           
                                            <input type="number" class="form-control" name="montomensualidad" id="" value="0.00"  required="" placeholder="Monto Mensualidad">
                                        </div>               
                                        <div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                            <label>Enviar a Lista Negra(*):</label>                           
                                            <input type="checkbox" name="estado" value="10" id="estado">
                                        </div> 
                                    </div>
                                 </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary  btn-flat" data-dismiss="modal">Cerrar</button>
                                    <button type="submit" id="btnLlamada" class="btn btn-flat" style='background-color:#3e038c;color: #FFFFFF'>Registrar Llamada</button>
                                </div>
                         </form>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="modal_extender" tabindex="-1" role="dialog"  >
                <div class="modal-dialog modal-lg " role="document">
                    <div class="modal-content">
                        <div class="modal-header bg-dark" >
                            <h5 class="modal-title" id="modal_extenderLabel">Extender Contrato</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span>&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form id="extendermodalForm">
                                <div class="row">
                                     <input type="hidden" id="idcontrato" name="idcontrato" value="<?php echo $idcontrato?>">
                                        <div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-6">                
                                            <label>Ingrese Periodo de Meses(*)</label>                           
                                            <select  name="tipo" id="tipo" class="form-control"  data-live-search="true" data-style="btn-default" required>
                                                <option value="">Seleccione Tipo</option>
                                                <option value="6">6 Meses</option>
                                                <option value="12">12 Meses</option>      
                                            </select>
                                        </div> 
                                        <div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-6">                
                                            <label>Fecha Inicial(*)</label>                           
                                            <input type="date" class="form-control" name="fecha_hora" id="fecha_hora"  required>
                                        </div>               
                                        <div class="form-group col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                            <label>Fecha Pago(*):</label>                           
                                            <select  name="fechapago" id="fechapago" class="form-control"  data-live-search="true" data-style="btn-default" required>
                                                <option value="">Seleccione Fecha</option>
                                                <option value="1">01 de Mes</option>
                                                <option value="5">05 de Mes</option>
                                                <option value="10">10 de Mes</option>
                                                <option value="15">15 de Mes</option>
                                                <option value="20">20 de Mes</option>
                                                <option value="25">25 de Mes</option> 
                                                <option value="30">30 de Mes</option>      
                                            </select>
                                        </div> 
                                    </div>
                                 </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary  btn-flat" data-dismiss="modal">Cerrar</button>
                                    <button type="submit" id="btnExtender" class="btn btn-danger btn-flat" >Registrar Extencion</button>
                                </div>
                         </form>
                    </div>
                </div>
            </div>
               
<?php
}
require '../footer.php';
?>
<script type="text/javascript" src="../../scripts/contrato.js">
</script>

<?php 
}
ob_end_flush();
?>