{% extends "base.html" %}
{% load static %}
{% block titulo %}
   Cierre de Caja
{% endblock titulo %}
{% block content_ci %} 
<div class="row" >
  <p class="bg-success" align="center" id="ExitoMensaje">
  </p>
</div>
<div class="row">
  <div class="col-md-12" id="body-cierre">
    <div class="panel panel-default">
      <div class="panel-heading panel-toolbar">
        <strong>Cierre de caja</strong>
        <button type="button" class="btn btn-default" id="refresh"><i class="fa fa-refresh"></i> Actualizar</button>
      </div>
      <div class="panel-body ">
        <div class="row" id="campoI">
          <div class="col-md-12" id="div-datos">
              <div  style="margin-left:25px">
                <H5> FECHA: <strong id="fechaOperacion"> </strong> </H5>
              </div>

              <div style="margin-left:25px">
                <h5> OFICINA: <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>CIERRE DESDE: <strong id="fechad" style="margin-right: 10px;">{{ FechaCierre }}</strong>
                HASTA: <strong id="fechah"></strong></h5>
              </div>
          </div>
          <div class="col-md-12">
            <div >
              <table id="IED" class="table table-striped" style="font-size:11px;">
              <thead>
                <tr >
                  <th colspan="10" style="text-align:center">MOVIMIENTOS DOLARES</th>
                </tr>
                <tr>
                  <th>
                    Operación
                  </th>
                  <th style="text-align:center">
                    Concepto
                  </th>
                  <th>ST</th>
                  <th>
                    Fecha
                  </th>
                  <th>Capital</th>
                  <th>Comision</th>
                  <th>C. Bancos</th>
                  <th>TC</th>
                   <th>
                    Ingreso
                  </th>
                  <th>
                    Egreso
                  </th>
                </tr>
              </thead>
              <tbody id="listaIED">
                
              </tbody>
              <tfoot>
                
                <tr>
                    <td>
                       &nbsp;
                    </td>
                    <td>
                      &nbsp;
                    </td>
                    <td>
                      &nbsp;
                    </td>
                    <td >
                      &nbsp;
                    </td>
                    <td >
                      <label id="tcapid"></label>
                    </td>
                    <td >
                      <label id="tcomid"></label>
                    </td>
                     <td >
                      <label id="tbancod"></label>
                    </td>
                    <td >
                      <label id="tpromtc"></label>
                    </td>
                    <td >
                     &nbsp;
                    </td>
                    <td >
                      &nbsp;
                    </td>
                </tr>
               
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td style="text-align:right" class="row">
                      <label> SUB-TOTAL</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                    <td>
                      <label> &nbsp;</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                     <td >
                      <label id="ID"></label>
                    </td>
                    <td >
                      <label id="ED"></label>
                    </td>
                </tr>
              </tfoot>  
              </table>
            </div>
          </div>

          <div class="col-md-12">
            <div >
              <table id="IES" class="table table-striped" style="font-size:11px;">
              <thead>
                <tr>
                  <th colspan="9" style="text-align:center">MOVIMIENTOS SOLES</th>
                </tr>
                <tr>
                  <th >
                    Operacion
                  </th>
                  <th>
                    Concepto
                  </th>
                  <th>ST</th>
                  <th>
                    Fecha
                  </th>
                  <th >Capital</th>
                  <th>Comision</th>
                  <th>C. Bancos</th>
                   <th>
                    Ingreso
                    </th>
                  <th>
                    Egreso
                  </th>
                </tr>
               
              </thead>
              <tbody id="listaIES">
               
              </tbody>
              <tfoot>
                
                <tr>
                    <td >
                       &nbsp;
                    </td>
                    <td >
                      &nbsp;
                    </td>
                    <td >
                      &nbsp;
                    </td>
                    <td >
                      &nbsp;
                    </td>
                    <td id="tcapis">
                      
                    </td>
                    <td >
                      <label id="tcomis"></label>
                    </td>
                     <td >
                      <label id="tbancos"></label>
                    </td>
                    <td width="9%">
                     &nbsp;
                    </td>
                    <td width="8%">
                      &nbsp;
                    </td>
                </tr>
               
                <tr>
                    <td ></td>
                    <td ></td>
                    <td ></td>
                    <td style="text-align:right">
                      <label> SUB-TOTAL</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                    <td >
                      <label> &nbsp;</label>
                    </td>
                     <td >
                      <label id="IS"></label>
                    </td>
                    <td >
                      <label id="ES"></label>
                    </td>
                </tr>
               
                
              </tfoot>  
              </table>
            </div>
          </div>
          <br>
          <div class="row myb-4">
            <div class="col-md-4 table-scroll">
              <div class="table-responsive" >
                <table class="table"style="font-size:12px;" id="resumen-soles">
                  <thead>
                    <tr>
                      <th colspan="2" class="center light-green lighten-4">
                        SOLES
                      </th>
                    </tr>
                    <tr>
                      <th>Detalle</th>
                      <th class="right">Monto</th>
                    </tr>
                  </thead>
                  <tbody >
                    <tr>
                      <td>Saldo Inicial</td>
                      <td style="color: green;" class="right" id="re-si-so">+ 0.00</td>
                    </tr>
                    <tr>
                      <td>Total Ingresos</td>
                      <td style="color: green;" class="right" id="re-i-so">+ 0.00</td>
                    </tr>
                    <tr>
                      <td>Total Egresos</td>
                      <td style="color: red;" class="right" id="re-e-so">- 0.00</td>
                    </tr>
                  </tbody>
                  <tfoot>
                    <tr style="border: 1px solid #616161;">
                      <th>Diferencia:</th>
                      <td style="color: blue;" class="right" id="re-t-so">0.00</td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>
            <div class="col-md-4 table-scroll">
              <div class="table-responsive" >
                <table class="table" style="font-size:12px;" id="resumen-dolares">
                  <thead>
                    <tr>
                      <th colspan="2" class="center light-blue lighten-4">
                        DOLARES
                      </th>
                    </tr>
                    <tr>
                      <th>Detalle</th>
                      <th class="right">Monto</th>
                    </tr>
                  </thead>
                  <tbody >
                    <tr>
                      <td>Saldo Inicial</td>
                      <td style="color: green;" class="right" id="re-si-do">+ 0.00</td>
                    </tr>
                    <tr>
                      <td>Total Ingresos</td>
                      <td style="color: green;" class="right" id="re-i-do">+ 0.00</td>
                    </tr>
                    <tr>
                      <td>Total Egresos</td>
                      <td style="color: red;" class="right" id="re-e-do">- 0.00</td>
                    </tr>
                  </tbody>
                  <tfoot>
                    <tr style="border: 1px solid #616161;">
                      <th>Diferencia:</th>
                      <td style="color: blue;" class="right" id="re-t-do">0.00</td>
                    </tr>
                  </tfoot>
                </table>
              </div>
            </div>
          </div>

          <div align="center" is="div-saldos">
              <p>Saldo del sistema | <label id="ssSistema" class="hidden">Soles: <span id="sis_S"></span></label> | <label id="sdSistema" class="hidden">Dolares: <span id="sis_D"></span>| <label id="smSistema" class="hidden">Gramos: <span id="sis_M"></span></label> |</p>
          </div>
          <br>

          <div align="center" id="div-obs">
            <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>
          <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>
      </div>
    </div>
  </div>
</div>

<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>
        <label class="modal-title" id="myModalLabel">ALERTA</label>
      </div>
      <div class="modal-body">
        <div class="row myb-4">
          <div class="col-md-12">
            <div  class="alert alert-warning" role="alert" align="center" id="modaltitulo">
              <label>¿DESEA CERRA LA CAJA DE TODOS MODOS?</label>
            </div>
          </div>
        </div>
        <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-info btn-block bc" id="cerraCaja" data-dismiss="modal">SI</button>
          </div>
        </div>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- impresion -->
<div id="modal-detalle-trans" class="modal">
  <div class="modal-content">
    <div id="impresion">
      <style type="text/css">
        table.tablep{
          border-collapse: collapse;
          border-color: grey;
          width: 100%;
            max-width: 100%;
            margin-bottom: 20px;
            background-color: transparent;
            display: table;
            border-top: 1px solid #ddd;
            font-size: 11px;
        }
        .tablep>thead>tr {
            color: #707070;
            font-weight: normal;
            background-color: #f8f8f8;
            background-image: -webkit-linear-gradient(top, #f8f8f8 0, #ececec 100%);
            background-image: linear-gradient(to bottom, #f8f8f8 0, #ececec 100%);
            background-repeat: repeat-x;
        }
        .tablep>tbody>tr>td, .tablep>tbody>tr>th, .tablep>tfoot>tr>td, .tablep>tfoot>tr>th, .tablep>thead>tr>td, .tablep>thead>tr>th {
              padding: 2px;
              padding-left: 5px;
              line-height: 1.42857143;
              vertical-align: top;
              border: 1px solid #ddd;
        }
        .titulos{
          font-size: 14px;
          margin-top:5px;
          margin-bottom:5px;
        }
      </style>
      <table style="width: 100%;">
        <tr>
          <td style="border-bottom: 1px solid #ddd;" align="center"><b>CIERRE DE CAJA</b></td>
        </tr>
      </table>
      
      <table  style="font-size: 12px;">
        <tr>
          <td id="im-datos">></td>

        </tr>
      </table>
      <br>
      <span class="titulos">RESUMEN DE CIERRE</span>
      <table class="tablep">
        <tr>
          <td  width="40%">
            <div >
              <table class="tablep" style="font-size:12px;" id="re-soles">
                
              </table>
            </div>
          </td>
          <td width="40%">
            <div>
              <table class="tablep" style="font-size:12px;" id="re-dolares">
                
              </table>
            </div>
          </td>
        </tr>
      </table>
      <br>
      <span class="titulos">DETALLE SOLES</span>
      <table class="tablep" id="det-soles">
       
      </table>
      <br>
      <span class="titulos">DETALLE DOLARES</span>
      <table class="tablep" id="det-dolares">
        
      </table>
      <br>
      <br>
      <table>
        <tr>
          <td id="im-saldos"></td>
        </tr>
      </table>
      <br>
      <table>
        <tr>
          <td id="im-obs"></td>
        </tr>
      </table>
      <br>

      <table style="width: 100%">
        <tr align="center">
          <td>
            _____________________________________________
          </td>
        </tr>
        <tr align="center">
          <td>{{usu_n_c}}</td>
        </tr>
      </table>
    </div>
  </div>
</div>
<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' %}";
  var i_so=0;
  var si_so=0;
  var i_do=0;
  var si_do=0;
  var e_so=0;
  var e_do=0;
  var sa_so=0;
  var sa_do=0;
  $(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(){
        $("#im-datos").html($("#div-datos").html());
        $("#re-soles").html($("#resumen-soles").html());
        $("#re-dolares").html($("#resumen-dolares").html());
        $("#det-soles").html($("#IES").html());
        $("#det-dolares").html($("#IED").html());
        $("#im-obs").html($("#div-obs").html());
        $("#im-saldos").html($("#div-saldos").html());
        printElem('impresion');
      }
    function printElem(divId) {
        var content = document.getElementById(divId).innerHTML;
        var mywindow = window.open('about:blank', '_new', 'height=600,width=800');
        mywindow.document.write('<html><head><title>Print</title>');
        mywindow.document.write('</head><body>');
        mywindow.document.write('<style>body{font-family: "Lucida Console";}</style>');
        mywindow.document.write(content);
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.focus()
        setTimeout(function(){ mywindow.print(); mywindow.close(); window.location.href = "/";}, 500);
        return true;
    }

    $("#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><label> '+data[i].tipodoc+' - '+data[i].nroR+'  '+data[i].usuGlo+'</label></td><td><label>'+data[i].concepto+'</label></td><td><label> &nbsp;</label></td><td ><label>'+data[i].fecha+'</label></td><td>'+data[i].capi+'</td><td>'+data[i].comision+'</td><td>'+data[i].comi_banco+'</td><td><label>'+data[i].monto+'</label></td><td><label></label></td></tr>';
            }
            else{
              html2 += '<tr><td ><label> '+data[i].tipodoc+' - '+data[i].nroR+'  '+data[i].usuGlo+'</label></td><td ><label>'+data[i].concepto+'</label></td><td ><label> &nbsp;</label></td><td ><label>'+data[i].fecha+'</label></td><td ><label>'+data[i].capi+'</label></td><td ><label>'+data[i].comision+'</label></td><td ><label>'+data[i].comi_banco+'</label></td><td ><label>'+data[i].tcd+'</label></td><td width="9%" class="row"><label>'+data[i].monto+'</label></td><td ><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);
          //---
          $("#re-i-so").text("+ "+data[data.length-1].total_soles);
          $("#re-i-do").text("+ "+data[data.length-1].total_dolares);
          i_so = parseFloat(data[data.length-1].total_soles);
          i_do = parseFloat(data[data.length-1].total_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 ><label> '+data[i].tipodoc+' - '+data[i].nroR+'  </label></td><td ><label>'+data[i].concepto+'</label></td><td ><label>'+data[i].st +'</label></td><td ><label>'+data[i].fecha+'</label></td><td ><label> &nbsp;</label></td><td ><label> &nbsp;</label></td><td ><label> &nbsp;</label></td><td width="9%" class="row"><label>&nbsp;</label></td><td ><label>'+data[i].monto+'</label></td></tr>';
            }
            else{
              html2 += '<tr><td ><label> '+data[i].tipodoc+' - '+data[i].nroR+'  </label></td><td ><label>'+data[i].concepto+'</label></td><td ><label>'+data[i].st +'</label></td><td ><label>'+data[i].fecha+'</label></td><td ><label> &nbsp;</label></td><td ><label> &nbsp;</label></td><td ><label> &nbsp;</label></td><td ><label> '+data[i].tcd+'</label></td><td width="9%" class="row"><label>&nbsp;</label></td><td ><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();
          //---
          $("#re-e-so").text("- "+data[data.length-1].total_soles);
          $("#re-e-do").text("- "+data[data.length-1].total_dolares);
          e_so = parseFloat(data[data.length-1].total_soles);
          e_do = parseFloat(data[data.length-1].total_dolares);
          calcular_totales();
        },
         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);
          //---
          sa_so = data.saldo_soles;
          sa_do = 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);
         //--
         si_so=parseFloat(data[0].sis);
         si_do=parseFloat(data[0].sid);
         $("#re-si-so").text("+ "+data[0].sis);
         $("#re-si-do").text("+ "+data[0].sid);
         //--
         ajax_Ingreso();
        },
         error: function(xhr, textStatus, errorThrown) {
              console.log(xhr.responseText);
        },
      });
    };
    function calcular_totales(){
      $("#re-t-so").text(round( si_so +i_so -e_so ,2));
      $("#re-t-do").text(round( si_do+i_do -e_do ,2));
    }
    //---
    function round(value, decimals) {
      return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
    }


       function cierreSolesDolares_ajax(){
        $.ajax({
          data:{'fd':$('#fechad').text(),'fh':$('#fechah').text(),'IS':$('#IS').text(),'ID':$('#ID').text(),'ES':$('#ES').text(),'ED':$('#ED').text(),'SS':sa_so,'SD':sa_do,'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_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>
 

 
{% endblock content_ci %}