{% load static %}
<!DOCTYPE html>
<html lang="es">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
  <title> Cierre Forzado </title>
   <link href="{% static 'bootstrap/css/bootstrap-datetimepicker.css' %}" rel="stylesheet"/>

  <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"/> 
  <link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet"/>  

  <script src="{% static 'bootstrap/js/jquery.min.js' %}"></script>
  <script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
  <script src="{% static 'bootstrap/js/Moment.js' %}"></script>
  <script src="{% static 'bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
  <script src="{% static 'js/jspdf.min.js' %}"></script>
  <script src="{% static 'js/jspdf.plugin.autotable.js' %}"></script>


  <style type="text/css">
    td.row{
        padding: 2px;
        border-right-width: 1px;
        border-right-color: #4C4B4B;
        border-right-style: solid;
        margin-top: 0px;
        border-bottom-width: 1px;
        border-bottom-style:dashed;
        border-bottom-color: #7A7979;
    }
    body{
      font-size: 10px;
    }
  </style>
   
</head>
<body>
  <div class="row" >
    <p class="bg-success" align="center" id="ExitoMensaje">
    </p>
  </div>
  <br>
  <div class="row">
    <div style="margin-left:40px">
      <a class="btn btn-danger"  href="/" role="button"><i class="fa fa-mail-reply"></i> Atras</a> 
      <button type="button" class="btn btn-primary" id="refresh"><i class="fa fa-refresh"></i> Actualizar</button>
    </div>
  </div>
  <br>

<div class="main" id="campoI">
  <div class="imp">
      <div style="margin-left:25px">
        <h4> <strong> SISTEMA INTEGRAL </strong> </label></h4>  
        <label> FECHA: <strong id="fechaOperacion"> </strong> </label>
      </div>
      
      <div style="margin-left:25px">
        <h4> <strong> TRANSFERENCIAS Y DEPOSITOS </strong></h4>
      </div>

      <div style="margin-left:25px">
        <h5> BASE : <strong> {{ SITE_URL }}</strong></h5>
      </div>
      
      <div style="margin-left:25px">
        <h5> OPERADOR: <strong id="txtOperador">{{ usu_n_c }}</strong></h5>
      </div>
      <div style="margin-left:25px">
        <h5>DESDE: <strong id="fechad" style="margin-right: 10px;">{{ FechaCierre }}</strong>
            HASTA: <strong id="fechah"></strong></h5>
      </div>
  </div>
  <br>
  <div class="imp" style="text-align:center">
    <h5><strong> MOVIMIENTOS VENTANILLA - CUADRE CAJA</strong></h5>
  </div>

   


 
  <br>
  <div class="imp">
    <div >
       <table style="margin: 0 auto">
        <tr>
          <td width="48%">
            <strong>======================================================= DESCRIPCIÓN DE MOVIMIENTOS =============================================================</strong>
          </td>
           
          <td width="25%">
            <strong> ================================ DOLARES ================================ </strong>
          </td>
        </tr>   
      </table>
    </div>
    <br>
    <div >
      <table id="IED" class="table table-bordered table-striped">
      <thead>
        <tr>
          <td width="10%" style="text-align:center">
            <label> OPERACIÓN</label>
          </td>
          <td width="40%" style="text-align:center">
            <label>CONCEPTO DETALLE</label>
          </td>
          <td width= "5%">ST</td>
          <td width="10%">
            <label>FECHA</label>
          </td>
          <td width= "8%">Capital</td>
          <td width= "5%">Comision</td>
          <td width= "5%">C. Bancos</td>
           <td width="9%">
            <label> INGRESO</label>
          </td>
          <td width="8%">
            <label> EGRESO</label>
          </td>
        </tr>
      
        <tr>
          <td width="10%"></td>
          <td width="40%"> <LABEL> SALDO ANTERIOR</LABEL> </td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td id="sid"></td>
          <td>&nbsp;</td>
        </tr>
         
      </thead>
      <tbody id="listaIED">
        
      </tbody>
      <tfoot>
        
        <tr>
            <td width="10%">
               &nbsp;
            </td>
            <td width="40%">
              &nbsp;
            </td>
            <td width="5%">
              &nbsp;
            </td>
            <td width="10%" class="row">
              &nbsp;
            </td>
            <td width="8%" class="row">
              <label id="tcapid"></label>
            </td>
            <td width="5%" class="row">
              <label id="tcomid"></label>
            </td>
             <td width="5%" class="row">
              <label id="tbancod"></label>
            </td>
            <td width="9%">
             &nbsp;
            </td>
            <td width="8%">
              &nbsp;
            </td>
        </tr>
       
        <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="5%"></td>
            <td width="10%" style="text-align:right" class="row">
              <label> SUB-TOTAL</label>
            </td>
            <td width="8%" class="row">
              <label> &nbsp;</label>
            </td>
            <td width="5%" class="row">
              <label> &nbsp;</label>
            </td>
            <td width="5%" class="row">
              <label> &nbsp;</label>
            </td>
             <td width="9%" class="row">
              <label id="ID"></label>
            </td>
            <td width="8%" class="row">
              <label id="ED"></label>
            </td>
        </tr>
       
        <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="5%"></td>
            <td width="10%" style="text-align:right">
              <label> </label> 
            </td>
            <td width="8%"  style="text-align:right">
              <label> &nbsp;</label>
            </td>
             <td width="5%" style="text-align:right">
              <label> &nbsp;</label>
            </td>
             <td width="5%" style="text-align:right">
              <label> &nbsp;</label>
            </td>
             <td width="9%" class="row" style="text-align:right">
              <label> SALDO TOTAL: </label>
            </td>
            <td width="8%" class="row">
              <label id="SD"></label>
            </td>
        </tr>
      </tfoot>  
      </table>
    </div>
  </div>
  <br>






  <div class="imp">
    <div >
       <table style="margin: 0 auto">
        <tr>
          <td width="48%">
            <strong>======================================================= DESCRIPCIÓN DE MOVIMIENTOS=============================================================</strong>
          </td>
           
         <td width="25%">
            <strong> ================================== SOLES ================================== </strong>
          </td>
        </tr>   
      </table>
 
    </div>
    <br>
    <div >
      <table id="IES" class="table table-bordered table-striped">
      <thead>
        <tr>
          <td width="10%" style="text-align:center">
            <label> OPERACION</label>
          </td>
          <td width="40%" style="text-align:center">
            <label>CONCEPTO DETALLE</label>
          </td>
          <td width= "5%">ST</td>
          <td width="10%">
            <label>FECHA</label>
          </td>
          <td width= "8%">Capital</td>
          <td width= "5%">Comision</td>
          <td width= "5%">C. Bancos</td>
           <td width="9%">
            <label> INGRESO</label>
          </td>
          <td width="8%">
            <label> EGRESO</label>
          </td>
        </tr>
        
        <tr>
          <td width="10%"></td>
          <td width="40%"> <LABEL> SALDO ANTERIOR</LABEL> </td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td id="sis"></td>
          <td>&nbsp;</td>
        </tr>
         
      </thead>
      <tbody id="listaIES">
       
      </tbody>
      <tfoot>
        
        <tr>
            <td width="10%">
               &nbsp;
            </td>
            <td width="40%">
              &nbsp;
            </td>
            <td width="5%">
              &nbsp;
            </td>
            <td width="10%" class="row">
              &nbsp;
            </td>
            <td width="8%" class="row">
              <label id="tcapis"></label>
            </td>
            <td width="5%" class="row">
              <label id="tcomis"></label>
            </td>
             <td width="5%" class="row">
              <label id="tbancos"></label>
            </td>
            <td width="9%">
             &nbsp;
            </td>
            <td width="8%">
              &nbsp;
            </td>
        </tr>
       
        <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="5%"></td>
            <td width="10%" style="text-align:right" class="row">
              <label> SUB-TOTAL</label>
            </td>
            <td width="8%" class="row">
              <label> &nbsp;</label>
            </td>
            <td width="5%" class="row">
              <label> &nbsp;</label>
            </td>
            <td width="5%" class="row">
              <label> &nbsp;</label>
            </td>
             <td width="9%" class="row">
              <label id="IS"></label>
            </td>
            <td width="8%" class="row">
              <label id="ES"></label>
            </td>
        </tr>
       
        <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="5%"></td>
            <td width="10%" style="text-align:right">
              <label> </label> 
            </td>
            <td width="8%" style="text-align:right">
              <label> &nbsp;</label>
            </td>
             <td width="5%" style="text-align:right">
              <label> &nbsp;</label>
            </td>
             <td width="5%" style="text-align:right">
              <label>&nbsp;</label>
            </td>
             <td width="9%" class="row" style="text-align:right">
              <label>SALDO TOTAL </label>
            </td>
            <td width="8%" class="row">
              <label id="SS"></label>
            </td>
        </tr>
      </tfoot>  
      </table>
    </div>
  </div>
  <br>
  <div align="center">
    <div class="form-group">
      <label for="obse">OBSERVACIONES: </label>
      <textarea rows="2"  id="obse" placeholder="Observaciones de cierre" style="width:300px"></textarea >
      <p id="texto_obse" style="width:300px" ></p>
    </div>
  </div>
  <br>
  <div >

      <div align="center">
          <button type="button" class="btn btn-primary bc" id="CerrarC" data-toggle="modal" data-target="#myModal2">CERRAR CAJA</button>
      </div>
      <br>
  </div>
</div>
<br>
<div id="myModal1" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">º
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">ALERTA</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-12">
            <div class="panel panel-default">
              <div class="panel-body">  
                <div class="row">
                  <div class="col-md-12">
                    <div class="alert alert-danger" role="alert" align="center" id="modaltitulo">
                      <br>
                      <br>
                      <h4 id="modalTexto">TU CAJA YA ESTA CERRADA</h4>
                      <br>
                      <br>
                    </div>
                  </div>
                </div>

              </div>
            </div> 
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Ok</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="myModal2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">ALERTA</h4>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-md-12">
            <div class="panel panel-default">
              <div class="panel-body">  
                <div class="row">
                  <div class="col-md-12">
                    <div  class="alert alert-info" role="alert" align="center" id="modaltitulo">
                      <h4 id="tituC"> CERRAR CAJA? </h4>
                    </div>
                  </div>
                </div>
                <br>
                <div class="row">
                  <div class="col-md-3 col-md-offset-3">
                    <button type="button" class="btn btn-danger btn-block bc" data-dismiss="modal">NO</button>
                  </div>
                  <div class="col-md-3">
                    <button type="button" class="btn btn-primary btn-block bc" id="cerraCaja" data-dismiss="modal">SI</button>
                  </div>
                </div>
                <br>
                <div class="row">
                  <div  id="colorc" class="" role="alert" align="center">
                      <h4 id="loadc"></h4>
                  </div>
                </div>

              </div>
            </div> 
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary bc" data-dismiss="modal" >Cerrar</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
<script type="text/javascript">
  var bi=false,be=false;
  var listaSI="",listaSE="";
  var listaMI="",listaME="";
  var listaDI="",listaDE="";
  var operadorGlobal="";
  var urlbtt="{% static 'img/btt.png' %}";
  $(document).ready(function(){
    var fecha = new Date();
    var mes = [
        "Enero",
        "Febrero",
        "Marzo",
        "Abril",
        "Mayo",
        "Junio",
        "Julio",
        "Agosto",
        "Septiembre",
        "Octubre",
        "Noviembre",
        "Diciembre"
        ];
    var textofecha= fecha.getDate() + " de " + mes[fecha.getMonth()] + " del " + fecha.getFullYear();
    var hora = new Date();
    var textohora = hora.getHours() + ":" + hora.getMinutes();
    $("#fechaOperacion").text(textofecha+" "+textohora);
    var aux='';

    ajax_validar();
    
    $("#imprime").prop('disabled',true);

    $("#cerraCaja").click(function(){
        $(".bc").prop('disabled',true);
        $("#tituC").text("CERRANDO");
        $("#colorc").prop('class',"alert alert-warning");
        $("#loadc").text("ESPERE....")
        $("#texto_obse").text($("#obse").val());
        $("#obse").hide();

        cierreSolesDolares_ajax();
            
      })

      function imprimirSD(){

          var doc = new jsPDF('p', 'pt'); 
          var resd= doc.autoTableHtmlToJson(document.getElementById("IED"));
          var ress= doc.autoTableHtmlToJson(document.getElementById("IES"));

          var base='{{ SITE_URL }}';
          var operador='{{ usu_n_c }}';

          doc.setFontSize(10);
          doc.setFontStyle('bold');
          doc.text("SISTEMA INTEGRAL - CIERRE CAJA", 10, 20);
          doc.setFontSize(8);
          doc.setFontStyle('normal');
          doc.text("BASE : " + base, 10, doc.autoTableEndPosY()+35);
          doc.text("OPERADOR: "+ operador, 10, doc.autoTableEndPosY()+50);
          doc.text("FECHA DESDE : "+$("#fechad").text(), 10, doc.autoTableEndPosY()+65);
          doc.text("FECHA HASTA : "+$("#fechah").text(), 140, doc.autoTableEndPosY()+65);
          
          doc.setFontSize(8);
          doc.setFontStyle('bold');


          doc.text("MOVIMIENTOS DOLARES", 10, doc.autoTableEndPosY()+85);
          doc.autoTable(resd.columns, resd.data, {
              startY: 95,
              margin: {horizontal: 10},
              headerStyles: {rowHeight: 12, fontSize: 7,valign: 'middle'},
              styles: {overflow: 'linebreak'},
              bodyStyles: {rowHeight: 12, fontSize: 8, valign: 'middle'}, 
              theme: 'grid',
              pageBreak: 'avoid',
          });

          doc.text("MOVIMIENTOS SOLES", 10, doc.autoTableEndPosY()+20);

          doc.autoTable(ress.columns, ress.data, {
              startY: doc.autoTableEndPosY()+30,
              margin: {horizontal: 10},
              headerStyles: {rowHeight: 12, fontSize: 7,valign: 'middle'},
              styles: {overflow: 'linebreak'},
              bodyStyles: {rowHeight: 12, fontSize: 8, valign: 'middle'}, 
              theme: 'grid',
              pageBreak: 'avoid',
          });

          doc.text("Saldo que aparece en el sistema SOLES : "+ $("#sis_S").text()+ " DOLARES : "+$("#sis_D").text(), 10, doc.autoTableEndPosY()+30);

          doc.text("Observaciones : "+ $("#obse").val(), 10, doc.autoTableEndPosY()+50);

          doc.save('reporteCierreCajaSD.pdf'); 
      }
    
    $("#campoCierre").hide();
    //
    $("#refresh").click(function(){
        $("#listaIES").html(" ");
        $("#listaIED").html(" ");
        $("#listaIEM").html(" ");
        ajax_validar();
      })
    //
    function ajax_Ingreso(){
            $.ajax({
              data:{'filtro':'f','F1':$('#fechad').text(),'F2':$('#fechah').text()},
              url:'/consultaIngreso_cierre/',
              type:'GET',
              dataType:'json',
              success: function(data){
                var html1 ="";
                var html2 ="";
                bi=false;
                for(var i=0;i<data.length-1;i++){
                 if (data[i].moneda =="soles"){
                    html1 += '<tr><td width="10%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+'<img src="'+urlbtt+'" width="8%" height="5%" style="margin-left:8px;margin-right:1px">'+data[i].usuGlo+'</label></td><td width="40%" class="row"><label>'+data[i].concepto+'</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="8%" class="row"><label>'+data[i].capi+'</label></td><td width="5%" class="row"><label>'+data[i].comision+'</label></td><td width="5%" class="row"><label>'+data[i].comi_banco+'</label></td><td width="9%" class="row"><label>'+data[i].monto+'</label></td><td width="8%" class="row"><label>&nbsp;</label></td></tr>';
                  }
                  else{
                    html2 += '<tr><td width="10%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+'<img src="'+urlbtt+'" width="8%" height="5%" style="margin-left:8px;margin-right:1px">'+data[i].usuGlo+'</label></td><td width="40%" class="row"><label>'+data[i].concepto+'</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="8%" class="row"><label>'+data[i].capi+'</label></td><td width="5%" class="row"><label>'+data[i].comision+'</label></td><td width="5%" class="row"><label>'+data[i].comi_banco+'</label></td><td width="9%" class="row"><label>'+data[i].monto+'</label></td><td width="8%" class="row"><label>&nbsp;</label></td></tr>';
                  }
                }
                listaSI = html1;
                listaDI = html2;
                //console.log(html1);
                //console.log(html2);
                //$('#listaI').html(html);
                $("#IS").text(data[data.length-1].total_soles);
                $("#ID").text(data[data.length-1].total_dolares);
                $("#tcapis").text(data[data.length-1].tcapis);
                $("#tcapid").text(data[data.length-1].tcapid);
                $("#tbancos").text(data[data.length-1].tbancos);
                $("#tbancod").text(data[data.length-1].tbancod);
                $("#tcomis").text(data[data.length-1].util_soles);
                $("#tcomid").text(data[data.length-1].util_dolares);
                //$("#CS").text(data[data.length-1].util_soles);
                //$("#CD").text(data[data.length-1].util_dolares);
                bi=true;
                ajax_Egreso(html1,html2);
                /*
                if(bi&&be){
                  $("#listaIES").html(listaSI+listaSE);
                  $("#listaIED").html(listaDI+listaDE);
                  ajax_saldo_inicial();
                  calcular_Saldo();
                }*/
              }, 
              error: function(xhr, textStatus, errorThrown) {
                    console.log(xhr.responseText);
              },
            });
          };
          ///
           


          //
          function ajax_Egreso(listaIs,listaId){
            $.ajax({
              data:{'filtro':'f','F1':$('#fechad').text(),'F2':$('#fechah').text()},
              url:'/consultaEgreso_cierre/',
              type:'GET',
              dataType:'json',
              success: function(data){
                var html1 ="";
                var html2 ="";
                be=false;
                for(var i=0;i<data.length-1;i++){
                  if (data[i].moneda =="soles"){
                  html1 += '<tr><td width="10%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+' <img src="'+urlbtt+'" width="8%" height="5%" style="margin-left:8px;margin-right:1px"></label></td><td width="40%" class="row"><label>'+data[i].concepto+'</label></td><td width="5%" class="row"><label>'+data[i].st +'</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="8%" class="row"><label> &nbsp;</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="9%" class="row"><label>&nbsp;</label></td><td width="8%" class="row"><label>'+data[i].monto+'</label></td></tr>';
                }
                else{
                  html2 += '<tr><td width="10%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+' <img src="'+urlbtt+'" width="8%" height="5%" style="margin-left:8px;margin-right:1px"></label></td><td width="40%" class="row"><label>'+data[i].concepto+'</label></td><td width="5%" class="row"><label>'+data[i].st +'</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="8%" class="row"><label> &nbsp;</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="5%" class="row"><label> &nbsp;</label></td><td width="9%" class="row"><label>&nbsp;</label></td><td width="8%" class="row"><label>'+data[i].monto+'</label></td></tr>';
                }
                }
                listaSE=html1;
                listaDE=html2;
                //$('#listaE').html(html);
                $("#ES").text(data[data.length-1].total_soles);
                $("#ED").text(data[data.length-1].total_dolares);
                be=true;
                var aux1=listaIs+html1
                var aux2=listaId+html2
                $("#listaIES").html(aux1);
                $("#listaIED").html(aux2);
                  //ajax_saldo_inicial();
                calcular_Saldo();
              },
               error: function(xhr, textStatus, errorThrown) {
                    console.log(xhr.responseText);
              },
            });
          };
      //

      
      //
      function ajax_saldo(){
            $.ajax({
              url:'/SaldoCaja_ajax/',
              //async:false,
              type:'GET',
              dataType:'json',
              success: function(data){
                $("#sis_S").text(data.saldo_soles);
                $("#sis_D").text(data.saldo_dolares);
              },
              error: function(xhr, textStatus, errorThrown) {
                    console.log(xhr.responseText);
                },
            });
          };



      //
      function ajax_saldo_inicial(){
            $.ajax({
              url:'/SaldoInicialCaja_ajax/',
              //async:false,
              type:'GET',
              dataType:'json',
              success: function(data){
               $('#sis').text(data[0].sis);
               $("#sid").text(data[0].sid);
               calcular_Saldo();
              },
               error: function(xhr, textStatus, errorThrown) {
                    console.log(xhr.responseText);
              },
            });
          };
      


       function cierreSolesDolares_ajax(){
        $.ajax({
          data:{'fd':$('#fechad').text(),'fh':$('#fechah').text(),'IS':$('#IS').text(),'ID':$('#ID').text(),'ES':$('#ES').text(),'ED':$('#ED').text(),'SS':$('#SS').text(),'SD':$('#SD').text(),'obs':$('#obse').val()},
          url:'/cierreCajaSD_ajax/',
          //async:false,
          type:'GET',
          dataType:'text',
          success: function(data){
            if(data=='exito'){
                $("#ExitoMensaje").prop('class',"alert alert-success");
                $("#texto").text("CAJA CERRADA!");  
                imprimirSD();
                //ajax_validar();
                window.location.href='/';
            }
            else{
                $('#myModal2').modal('hide');
                $(".bc").prop('disabled',false);
                $("#tituC").text("CERRAR CAJA?");
                $("#colorc").prop('class',"");
                $("#loadc").text("");
                $("#ExitoMensaje").prop('class',"alert alert-danger");
                $("#texto").text("la operacion fallo" + data);
                $("#modaltitulo").prop('class',"alert alert-danger");
                $("#modalTexto").text("la operacion fallo " + data);
                $('#myModal1').modal('show');
            }

          },
           error: function(xhr, textStatus, errorThrown) {

                    console.log(xhr.responseText);
            },
        });
      };


      //
     
       function ajax_validar(){//falta
              $.ajax({
                data:{'F1':$('#txtfecha1').val(),'F2':$('#txtfecha2').val()},
                url:'/validaCierre/',
                //async:false,
                type:'GET',
                dataType:'text',
                success: function(data){
                  if(data=='exito'){
                    $("#ExitoMensaje").prop('class','');
                    $("#texto").text("");
                    bi=false;
                    be=false;
                      $("#listaIES").html("");
                      $("#listaIED").html("");
                      ajax_Ingreso(); 
                      ajax_saldo();
                      ajax_saldo_inicial();
                      $("#CerrarC").show();
                      $("#sdSistema").removeClass("hidden");
                      $("#ssSistema").removeClass("hidden");
                  
                    //$("#detalle").show();
                   }
                 else{
                    $("#ExitoMensaje").prop('class','alert alert-danger');
                    $("#texto").text("TU CAJA YA ESTA CERRADA!!");
                    $("#CerrarC").hide();

                    //$("#detalle").hide();
                    //$("#myModal").modal('show');
                   }
                },
                error: function(xhr, textStatus, errorThrown) {
                  console.log(xhr.responseText);
                },
              });
            };
      //
      //
      function calcular_Saldo()
      {
        //alert($("#IS").html());
        var saldosoles= parseFloat($("#IS").text())-parseFloat($("#ES").text())+parseFloat($("#sis").text());
        var saldodolares= parseFloat($("#ID").text())-parseFloat($("#ED").text())+parseFloat($("#sid").text());
        $("#SS").text(saldosoles.toString());
        $("#SD").text(saldodolares.toString());
      }

     
    //
  });
</script>
 
</html>
 
