<?php

if($_SESSION["perfil"] == "Especial"){

  echo '<script>

    window.location = "inicio";

  </script>';

  return;

}

$data = json_decode($_SESSION['arregloD'],true);

?>
<div class="content-wrapper">
  <section class="content-header">
    <h1>Detalle Inscrito</h1>
    <ol class="breadcrumb">
      <li><a href=""><i class="fa fa-dashboard"></i>Inicio</a></li>
      <li class="active">Detalle contrato del diplomado</li>
    </ol>
  </section>

  <section class="content">

    <div class="row">
      <div class="col-lg-12 col-xs-12">
        <div class="box box-success">
          <form role="form" method="post" class="" enctype="multipart/form-data">
            <div class="row pt-4 mt-4">
              <div class="col-md-12 pt-4 sc"> 

                <div class="form-group form-space col-md-12">
                  <div class="panel panel-success">
                    <div class="panel-heading">
                      <center>
                      <h3 class="panel-title">Datos del usuario</h3>
                      </center>
                    </div>
                    <div class="panel-body" style="padding:0px">
                      <div class="form-row">
                        <div class="form-group col-md-5">
                          <label for="inputCity">Usuario:</label>

                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-user"></i></span>
                            <input type="text" class="form-control" id="nuevoUsuario" value="<?php echo $_SESSION["nombre"]; ?>" readonly>
                            <input type="hidden" class="form-control" id="IdUsuario" name="IdUsuario" value="<?php echo $_SESSION["id"]; ?>">
                          </div>

                        </div>
                      </div> 

                      <div class="form-group col-md-4">
                          <label for="inputCity">Código documento:</label>
                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-key"></i></span>
                            <input type="text" class="form-control" id="nuevoCodigo" name="nuevoCodigo" value="<?php echo $data[0]['codigo']?>" readonly>

                            
                          </div>
                        </div>
                        
                        
                        
                        <div class="form-group col-md-3">
                          <label for="inputCity">Estado del Servicio:</label>
                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-file-text"></i></span>

                            <?php
                              if($data[0]["estado"] == 0){
                                echo '<input type="text" class="form-control" name="nuevoEstado" 
                                value="Activo" required readonly>';

                              }else if($data[0]["estado"] == 1){
                                echo '<input type="text" class="form-control" name="nuevoEstado" 
                                value="Suspendido" required readonly>';

                              }else if ($data[0]["estado"] == 2) {
                                echo '<input type="text" class="form-control" name="nuevoEstado" 
                                value="Cancelado" required readonly>';
                                
                              }else if ($data[0]["estado"] == 4) {
                                echo '<input type="text" class="form-control" name="nuevoEstado" 
                                value="BAJA" required readonly>';
                                
                              }else if ($data[0]["estado"] == 5) {
                                echo '<input type="text" class="form-control" name="nuevoEstado" 
                                value="POR VALIDAR" required readonly>';
                                
                              }
                              
                            ?>
                            
                          </div>
                        </div>

                      </div>                        
                    </div>
                  </div>
                

                <div class="form-group form-space col-md-12">
                  <div class="panel panel-success">
                    <div class="panel-heading">
                      <center>
                        <h3 class="panel-title">Datos del Alumno</h3>
                      </center>
                    </div>
                    <div class="panel-body" style="padding:0px">
                      <div class="form-row">
                        <div class="form-group col-md-6">
                          <label for="inputCity">Nombres y Apellidos:</label>
                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-child"></i></span>

                            <input type="hidden" class="form-control" id="idpersona" name="idpersona" required>

                            <input type="text" class="form-control" id="nuevoNombreCliente" name="nuevoNombreCliente" value="<?php echo $data[0]["nombre"]?>" required readonly="">                           
                            
                          </div>

                        </div>
                      </div>


                      <div class="form-row">
                        <div class="form-group col-md-3">
                          <label for="inputCity">Matricula:</label>
                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-address-card"></i></span>
                            <input type="text" class="form-control" id="nuevoDocumento" name="nuevoDocumento" value="<?php echo $data[0]["documento"]?>"  readonly>
                          </div>
                        </div>

                        <div class="form-group col-md-3">
                          <label for="inputCity">Telefono:</label>
                          <div class="input-group">
                            <span class="input-group-addon"><i class="fa fa-volume-control-phone"></i></span>
                            <input type="text" class="form-control" id="nuevoTelefono" name="nuevoTelefono" value="<?php echo $data[0]["telefono"]?>"  readonly>
                          </div>
                        </div>                      
                        
                      </div>                    

                    </div>
                  </div>
                </div>                


                <div class="form-group form-space col-md-12">
                  <div class="panel panel-success">
                    <div class="panel-heading">
                      <center>
                        <h3 class="panel-title">Datos del Diplomado</h3>
                      </center>
                    </div>
                      <div class="panel-body" style="padding:0px">
                            <div class="form-row">

                              <div class="form-group col-md-3">
                                <label for="inputCity">Diplomado:</label>
                                <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-users"></i></span>

                                  <input type="hidden" class="form-control" id="idtipo_servicios" name="idtipo_servicios" required>

                                  <input type="text" class="form-control" id="nuevoDecripcionServ" name="nuevoDecripcionServ" value="<?php echo $data[0]["descripcion_servicio"]?>" required readonly>
                                      

                                </div>

                              </div>
                            </div>


                            <div class="form-row">
                              <div class="form-group col-md-3">
                                <label for="inputCity">Descripción del Diplomado:</label>
                                <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-audio-description"></i></span>
                                  <input type="text" class="form-control" id="nuevoTipoServicio" name="nuevoTipoServicio" value="<?php echo $data[0]["nombre_servicio"]?>" required readonly="">
                                  
                                </div>
                              </div>

                              <div class="form-group col-md-2">
                                <label for="inputCity">Meses:</label>
                                <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-align-center"></i></span>
                                  <input type="text" class="form-control" id="nuevoCantBolsa" name="nuevoCantBolsa" value="<?php echo $data[0]["cantidad_bolsa"]?>" required readonly>
                                </div>
                              </div>                      
                              
                              <div class="form-group col-md-2">
                                <label for="inputCity">Pago:</label>
                                <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-usd"></i></span>
                                  <input type="text" class="form-control" id="nuevoValorServicio" name="nuevoValorServicio" value="<?php echo number_format($data[0]["valor_servicio"],2,'.',',')?>" required readonly>
                                </div>
                              </div>

                              <div class="form-group col-md-2">
                                <label for="inputCity">N° de Meses:</label>
                                <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-file-text"></i></span>
                                  <input type="text" class="form-control" name="nuevoMeses" id="nuevoMeses" value="<?php echo $data[0]["numromeses"]?>" readonly >
                                </div>
                              </div>  

                              <div class="form-group col-sm-12 col-md-4">
                                <label for="inputCity">Bloque:</label>
                                <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-location-arrow"></i></span>
                                  <input type="text" class="form-control" name="direccion" placeholder="Bloque" value="<?php echo $data[0]["direccion_pago"]?>" readonly required>
                                </div>
                              </div>  

                              <div class="" style="display: flex; width: 300px;">
                                <div style="margin: 0 5px;">
                                  <label for="inputCity">Fecha de pago:</label>
                                  <div class="input-group">
                                
                                  <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="date" class="form-control" name="fechaInstalacion" placeholder="Fecha pago" value="<?php echo $data[0]["fecha_instalacion"]?>" readonly required>
                                  </div>
                                </div>

                                <div style="margin: 0 5px;">
                                  <label for="inputCity">Fecha facturación:</label>
                                  <div class="input-group">
                                  <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                    <input type="date" class="form-control" id="fechaFacturacion" name="fechaFacturacion" placeholder="Fecha de facturación" value="<?php echo $data[0]["fecha_facturacion"]?>" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" readonly required>
                                  </div>
                                </div>  
                                                
                              
                              </div>

                            </div>
                      </div>
                  </div>   
                
                  <div class="form-group form-space col-md-12">
                    <div class="panel panel-success">
                      <div class="panel-heading">
                        <center>
                          <h3 class="panel-title">Datos Adicionales</h3>
                        </center>
                      </div>
                      <div class="panel-body" style="padding:0px">
                      
                        <div class="form-row">
                          <div class="form-group col-md-12">
                            <label for="inputCity">¿Quien lo Inscribio?::</label>
                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-audio-description"></i></span>
                              <input type="text" class="form-control" id="equipos_asignados" name="equipos_asignados" value="<?= $data[0]["equipos_asignados"]?>" placeholder="¿Quien lo Inscribio?" required>
                            </div>
                          </div>


                          <div class="form-group col-md-12">
                            <label for="inputCity">Detalles Adicionales:</label>
                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-align-center"></i></span>
                              <textarea name="clausula_contrato" id="clausula_contrato" class="form-control" rows="3" placeholder="Detalles Adicionales" required><?= $data[0]["clausula_contrato"]?></textarea>
                            </div>
                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-12">
                            <button id="generarcronograma" class="btn btn-success pull-right" type="button"><i class="fa fa-file-text"></i> Genererar Cronograma de pago</button>
                          </div>
                        </div>

                        <div class="form-row">
                          <div class="box-body">

                            <table class="table table-bordered table-striped table-hover table-condensed vistaCronograma" id="vistaCronograma">
                    
                              <thead>
                              
                                <tr>
                                  
                                  <th style="width:10px">#</th>
                                  <th>Tipo de Servicio</th>
                                  <th>Descripcion de Servicio</th>
                                  <th>Monto</th>
                                  <th>Fechas de Pago</th>           
                                  <th>Estado</th>

                                </tr> 

                              </thead>

                              <tbody id="tablebody">
                                
                              
                                  <?php 

                                    foreach ($data as $key => $value) {
                                      echo '<tr id="fila">
                                              <td>'.($key+1).'</td>
                                              <td>'.$value["descripcion_servicio"].'</td>
                                              <td>'.$value["nombre_servicio"].'</td>
                                              <td>'.number_format($value["monto"],2,'.',',').'</td>
                                              <td>'.$value["fechas_pagos"].'</td>';
                                              if($value["estado_pago"] == 0){
                                                echo '<td><span class="badge bg-yellow">Pendiente</span></td>';
                                              }else if($value["estado_pago"] == 1){
                                                echo '<td><span class="badge bg-green">Pagado</span></td>';
                                              }else if($value["estado_pago"] == 2){
                                                echo '<td><span class="badge bg-red">Vencido</span></td>';
                                              }else if($value["estado_pago"] == 4){
                                                echo '<td><span class="badge bg-red">BAJA</span></td>';
                                              }else if($value["estado_pago"] == 5){
                                                echo '<td><span class="badge bg-blue">POR VALIDAR</span></td>';
                                              }
                                              
                                              

                                      echo '</tr>';
                                    }

                                  ?>

                                
                              </tbody id="cronogramapago">

                            </table>

                          </div>
                        </div>

                      </div>
                    </div>
                  </div>

                </div>


            </div>  
            <div class="box-footer">
              
             <a href="contratos"  class="btn btn-danger" ><i class="fa fa-arrow-circle-left"></i> Regresar</a>

          </div>
          </form>
        </div>
      </div>

    </div>
  </section>

</div>
