{% load static %}
<!DOCTYPE html>
<html lang="es">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<head>
  <title> Cierre </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>
  <div class="row">
  <div style="margin-left:40px">
    <a class="btn btn-danger"  href="/Admin/CancelarCierre/" 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">{{ fc }}</strong> </label>
      </div>
      
      <div style="margin-left:25px">
        <h4> <strong> TRANSFERENCIAS Y DEPOSITOS </strong></h4>
      </div>

      <div style="margin-left:25px">
        <h5> BASE : <strong id="txtBase"> {{ oficina }}</strong></h5>
      </div>
      
      <div style="margin-left:25px">
        <h5> OPERADOR: <strong id="txtOperador"> {{ operador }} </strong></h5>
      </div>
      <div style="margin-left:25px">
        <h5>DESDE: <strong id="fechad" style="margin-right: 10px;">{{ fd }}</strong>
            HASTA: <strong id="fechah">{{ fh }}</strong></h5>
      </div>
  </div>

  <br>
  <div class="imp" style="text-align:center">
    <h5><strong> MOVIMIENTOS VENTANILLA - CUADRE CAJA</strong></h5>
  </div>
  <br>


{% ifnotequal tipoSis 'transferencia' %}
<div class="imp">
    <div >
      <table id="IEM" style="margin: 0 auto">
        <tr>
          <td width="48%">
            <strong>========================================================= MOVIMIENTOS MATERIAL ===============================================================</strong>
          </td>
           
          <td width="25%">
            <strong> =========================== GRAMOS DE MATERIAL =========================== </strong>
          </td> 
        </tr>   
      </table>
    </div>
    <br>
    <div >
      <table 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="10%">
            <label>FECHA</label>
          </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 id="sim">{{ sim }}</td>
          <td>&nbsp;</td> 
        </tr>
        
      </thead>
 
      <tbody id="listaIEM">
          
      </tbody>
      <tfoot>
          <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="10%" style="text-align:right" class="row">
              <label> SUB-TOTAL:</label>
            </td>
             <td width="9%" class="row">
              <label id="IM"></label>
            </td>
            <td width="8%" class="row">
              <label id="EM"></label>
            </td> 
        </tr>
        <tr>
            <td width="10%"></td>
            <td width="40%"></td>
            <td width="10%" style="text-align:right">
            </td>
             <td width="9%" class="row" style="text-align:right">
              <label> SALDO TOTAL: </label>
            </td>
            <td width="8%" class="row">
              <label id="SM"></label>
            </td>
        </tr>
 
      </tfoot>  
      </table>
    </div>
  </div>


{%endifnotequal%}


 
  <br>
  <div class="imp">
    <div >
       <table style="margin: 0 auto" id="headerDolares">
        <tr>
          <td width="48%">
            <strong id="titulo1MD">========================================================= DESCRIPCIÓN DE MOVIMIENTOS=============================================================== </strong>
          </td>
           
          <td width="25%">
            <strong  id="titulo2MD"> ================================== 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="45%" 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= "5%">TC</td><!-- tepo de cambio-->
           <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>&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="5%" class="row">
              <label id="tpromtc"></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="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="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">{{ 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>
  <div >
      <div align="center">
          <button type="button" class="btn btn-inverse bc" id="imprimir"><i class="fa fa-print"></i> Imprimir</button>
      </div>
      <br>
  </div>
</div>
<br>
</body>
   <script type="text/javascript">
                        var listIM="",listaEM="";
                        var listaSI="",listaSE="";
                        var listaDI="",listaDE="";
                        var urlbtt="{% static 'img/btt.png' %}";
                        $(document).ready(function(){
                          
                          ajax_validar(); 

                          function imprimirHibrido(){

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

                              var base='{{ oficina }}';
                              var operador='{{ operador }}';

                              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 MATERIAL (GRAMOS)", 10, doc.autoTableEndPosY()+85);
                              doc.autoTable(resm.columns, resm.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 DOLARES", 10, doc.autoTableEndPosY()+20);
                              doc.autoTable(resd.columns, resd.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("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.save('reporteCierreCajaH.pdf'); 
                          }



                           function imprimirSD(){

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

                              var base='{{ oficina }}';
                              var operador='{{ operador }}';

                              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.save('reporteCierreCajaSD.pdf'); 
                          }


                          function imprimir(){
                            {% ifequal tipoSis 'hibrido'  %}
                              imprimirHibrido();
                            {% else %}
                              {% ifequal tipoSis 'material'  %}
                                imprimirHibrido();
                              {% else %}
                                {% ifequal tipoSis 'transferencia' %}
                                    imprimirSD();
                                {%endifequal%}
                              {%endifequal%}
                            {%endifequal%}  
                          }
  
                          $("#refresh").click(function(){
                            $("#listaIES").html(" ");
                            $("#listaIED").html(" ");
                            $("#listaIEM").html(" ");
                            ajax_validar();
                          })
                          //

                          function ajax_Ingreso_Material(){
                                $.ajax({
                                  data:{'filtro':"f",'F1':$('#fechad').text(),'F2':$('#fechah').text(),'pkC':{{ pkc }}},
                                  url:'/consultaIngresoMaterialCierre_oficina_admin_ajax',
                                  type:'GET',
                                  dataType:'json',
                                  success: function(data){
                                    var html1 ="";
                                    bi=false;
                                    for(var i=0;i<data.length-1;i++){
                                        html1 += '<tr><td width="15%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+'<img src="'+urlbtt+'" width="10%" height="7%" style="margin-left:8px;margin-right:1px"></label></td><td width="45%" class="row"><label>'+data[i].concepto+'</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="10%" class="row"><label> &nbsp;</label></td><td width="10%" class="row"><label>'+data[i].pesoGramo+'</label></td><td width="10%" class="row"><label>&nbsp;</label></td></tr>';
                                    }
                                    listaMI = html1;
                                    $("#IM").text(data[data.length-1].total_material); 
                                    bi=true;
                                    ajax_Egreso_Material(html1);
                                   
                                  },
                                  error: function(xhr, textStatus, errorThrown) { 
                                          console.log(xhr.responseText);
                                  },
                                });
                              };


                          function ajax_Egreso_Material(listaIm){
                                $.ajax({
                                  data:{'filtro':"f",'F1':$('#fechad').text(),'F2':$('#fechah').text(),'pkC':{{ pkc }}},
                                  url:'/consultaEgresoMaterial_cierre/',
                                  type:'GET',
                                  dataType:'json',
                                  success: function(data){
                                    var html1 ="";
                                    var html2 ="";
                                    be=false;
                                    for(var i=0;i<data.length-1;i++){ 
                                        html1 += '<tr><td width="15%" class="row"><label> '+data[i].tipodoc+' - '+data[i].nroR+' <img src="'+urlbtt+'" width="10%" height="7%" style="margin-left:8px;margin-right:1px"></label></td><td width="45%" class="row"><label>'+data[i].concepto+'</label></td><td width="10%" class="row"><label>'+data[i].fecha+'</label></td><td width="10%" class="row"><label> &nbsp;</label></td><td width="10%" class="row"><label>&nbsp;</label></td><td width="10%" class="row"><label>'+data[i].pesoGramo+'</label></td></tr>';
                                    }
                                    listaME=html1; 
                                    //$('#listaE').html(html);
                                    $("#EM").text(data[data.length-1].total_material); 
                                    be=true;
                                    var aux1=listaIm+html1 
                                    $("#listaIEM").html(aux1); 
                                    calcular_Saldo_Material();
                                  },
                                   error: function(xhr, textStatus, errorThrown) { 
                                          console.log(xhr.responseText);
                                  },
                                });
                              };



                          function ajax_Ingreso(){
                                $.ajax({
                                  data:{'filtro':"f",'F1':$('#fechad').text(),'F2':$('#fechah').text(),'pkC':{{ pkc }}},
                                  url:'/consultaIngresoCierre_oficina_admin_ajax/',
                                  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+' &#9658 '+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="5%" class="row"><label>'+data[i].tcd+'</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;
                                    //$('#listaI').html(html);
                                    $("#IS").text(data[data.length-1].total_soles);
                                    $("#ID").text(data[data.length-1].total_dolares);
                                    //$("#CS").text(data[data.length-1].util_soles);
                                    //$("#CD").text(data[data.length-1].util_dolares);
                                    bi=true;
                                    ajax_Egreso(html1,html2);
                                  }
                                });
                              };
                              ///
                               
                              //
                              function ajax_Egreso(listaIs,listaId){
                                $.ajax({
                                  data:{'filtro':"f",'F1':$('#fechad').text(),'F2':$('#fechah').text(),'pkC':{{ pkc }}},
                                  url:'/consultaEgresoCierre_oficina_admin_ajax/',
                                  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+' &#9658 </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="5%" class="row"><label> '+data[i].tcd+'</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+listaSE
                                      var aux2=listaId+listaDE
                                      $("#listaIES").html(aux1);
                                      $("#listaIED").html(aux2);
                                      //ajax_saldo_inicial();
                                      calcular_Saldo();
                                  }
                                });
                              };
                         
                           function ajax_validar(){//falta

                              {% ifnotequal tipoSis 'material'  %}
                                          
                                $("#listaIES").html("");
                                $("#listaIED").html("");
                                 ajax_Ingreso();

                              {%endifnotequal%}

                              {% ifnotequal tipoSis 'transferencia' %}

                                $("#listaIES").html("");
                                $("#listaIED").html("");
                                ajax_Ingreso(); 
                                
                                $("#listaIEM").html(""); 
                                ajax_Ingreso_Material(); 

                              {%endifnotequal%}

                              
                            };
                          //
                          $("#imprimir").click(function(){
                            imprimir();
                          })

                          function calcular_Saldo_Material(){
                            var saldomaterial= parseFloat($("#IM").text())-parseFloat($("#EM").text())+parseFloat($("#sim").text());
                            $("#SM").text(saldomaterial.toString()); 
                          }
                          //
                          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>
<script src="{% static 'Bootstrap/js/Moment.js' %}"></script>
<script src="{% static 'Bootstrap/js/bootstrap.min.js' %}"></script>
<script src="{% static 'Bootstrap/js/bootstrap-datetimepicker.js' %}"></script>
<script src="{% static 'est/jquery.printarea.js' %}"></script>
<script src="{% static 'js/jspdf.min.js' %}"></script>
<script src="{% static 'js/jspdf.plugin.autotable.js' %}"></script>
</html>
 
