{% extends "baseAdmin.html" %}
{% load static %}
{% block titulo %}
  .::Configuración de Cajas
{% endblock titulo %}
{% block content1 %}
    <style type="text/css">

      .list-group-item {
          position: relative;
          display: block;
          padding: 2px 2px;
          margin-bottom: -1px;
          background-color: #fff;
          border: 1px solid #ddd;
      }

      .clickedit{
          width: 70%;
          border-style: none;
          background-color: transparent;
          text-align: center;
        }

        .clickedit:hover {
            background-color: #fff;
            border-radius: 4px;
            border-style: groove;
        }

        .clickedit:focus {
            background-color: #fff;
            border-radius: 4px;
            border-style: groove;
        }
 
   
      [data-toggle="buttons"] > input[type="checkbox"],
      [data-toggle="buttons"] > label > input[type="checkbox"] {
        display: none;
      }
      .btn[class^="btn-radio"],
      .btn[class^="btn-checkbox"],
      .btn[class*=" btn-radio"],
      .btn[class*=" btn-checkbox"] {
        padding: 6px 0;
        -webkit-box-shadow: none;
        box-shadow: none;
        vertical-align: middle;
      }
      .btn[class^="btn-radio"]:hover,
      .btn[class^="btn-checkbox"]:hover,
      .btn[class*=" btn-radio"]:hover,
      .btn[class*=" btn-checkbox"]:hover {
        color: inherit;
        text-decoration: underline;
      }
      .btn[class^="btn-radio"]:before,
      .btn[class^="btn-checkbox"]:before,
      .btn[class*=" btn-radio"]:before,
      .btn[class*=" btn-checkbox"]:before {
        position: relative;
        display: inline-block;
        margin-right: 4px;
        font-style: normal;
        text-align: center;
        color: #fff;
        border: 1px solid #999999;
        background: #fff;
      }
      .active.btn[class^="btn-radio"]:before,
      .active.btn[class^="btn-checkbox"]:before,
      .active.btn[class*=" btn-radio"]:before,
      .active.btn[class*=" btn-checkbox"]:before {
        color: #555555;
      }
      :hover.btn[class^="btn-radio"]:before,
      :hover.btn[class^="btn-checkbox"]:before,
      :hover.btn[class*=" btn-radio"]:before,
      :hover.btn[class*=" btn-checkbox"]:before {
        border-color: #555555;
      }
      .btn[class^="btn-radio"]:before,
      .btn[class*=" btn-radio"]:before {
        content: "\2022";
        top: 3px;
        padding: 2px;
        width: 14px;
        height: 14px;
        font-family: arial;
        font-weight: bold;
        font-size: 22px;
        line-height: 9px;
        border-radius: 999px;
      }
      .btn[class^="btn-checkbox"]:before,
      .btn[class*=" btn-checkbox"]:before {
        content: "\f00c";
        top: -1px;
        padding: 0;
        width: 16px;
        height: 16px;
        font-family: FontAwesome;
        font-weight: normal;
        font-size: 11px;
        line-height: 13px;
      }
      .btn.active.btn-checkbox-primary:before,
      .btn.active.btn-radio-primary:before {
        color: #35a6f1;
      }
      .btn:hover.btn-checkbox-primary:before,
      .btn:hover.btn-radio-primary:before {
        border-color: #0c71b4;
      }
      .btn.active.btn-checkbox-success:before,
      .btn.active.btn-radio-success:before {
        color: #339933;
      }
      .btn:hover.btn-checkbox-success:before,
      .btn:hover.btn-radio-success:before {
        border-color: #194d19;
      }
      .btn.active.btn-checkbox-warning:before,
      .btn.active.btn-radio-warning:before {
        color: #f09609;
      }
      .btn:hover.btn-checkbox-warning:before,
      .btn:hover.btn-radio-warning:before {
        border-color: #8e5905;
      }
      .btn.active.btn-checkbox-danger:before,
      .btn.active.btn-radio-danger:before {
        color: #e51400;
      }
      .btn:hover.btn-checkbox-danger:before,
      .btn:hover.btn-radio-danger:before {
        border-color: #7f0b00;
      }
      .btn.active.btn-checkbox-info:before,
      .btn.active.btn-radio-info:before {
        color: #0d8dd7;
      }
      .btn:hover.btn-checkbox-info:before,
      .btn:hover.btn-radio-info:before {
        border-color: #074e77;
      }
      .btn.active.btn-checkbox-#000000:before,
      .btn.active.btn-radio-#000000:before {
        color: #0c0c0c;
      }
      .btn:hover.btn-checkbox-#000000:before,
      .btn:hover.btn-radio-#000000:before {
        border-color: #000000;
      }
      .btn.active.btn-checkbox-#ffffff:before,
      .btn.active.btn-radio-#ffffff:before {
        color: #ffffff;
      }
      .btn:hover.btn-checkbox-#ffffff:before,
      .btn:hover.btn-radio-#ffffff:before {
        border-color: #cccccc;
      }
      .btn.active.btn-checkbox-#808080:before,
      .btn.active.btn-radio-#808080:before {
        color: #eeeeee;
      }
      .btn:hover.btn-checkbox-#808080:before,
      .btn:hover.btn-radio-#808080:before {
        border-color: #bbbbbb;
      }
      .btn.active.btn-checkbox-inverse:before,
      .btn.active.btn-radio-inverse:before {
        color: #2e383d;
      }
      .btn:hover.btn-checkbox-inverse:before,
      .btn:hover.btn-radio-inverse:before {
        border-color: #020303;
      }
      .btn.active.btn-checkbox-body:before,
      .btn.active.btn-radio-body:before {
        color: #f2f2f2;
      }
      .btn:hover.btn-checkbox-body:before,
      .btn:hover.btn-radio-body:before {
        border-color: #bfbfbf;
      }
      .btn.active.btn-checkbox-support1:before,
      .btn.active.btn-radio-support1:before {
        color: #70bc99;
      }
      .btn:hover.btn-checkbox-support1:before,
      .btn:hover.btn-radio-support1:before {
        border-color: #3f8766;
      }
      .btn.active.btn-checkbox-support2:before,
      .btn.active.btn-radio-support2:before {
        color: #f8576c;
      }
      .btn:hover.btn-checkbox-support2:before,
      .btn:hover.btn-radio-support2:before {
        border-color: #e00925;
      }
      .btn.active.btn-checkbox-support3:before,
      .btn.active.btn-radio-support3:before {
        color: #6bafbd;
      }
      .btn:hover.btn-checkbox-support3:before,
      .btn:hover.btn-radio-support3:before {
        border-color: #3c7986;
      }
      .btn.active.btn-checkbox-support4:before,
      .btn.active.btn-radio-support4:before {
        color: #ab93eb;
      }
      .btn:hover.btn-checkbox-support4:before,
      .btn:hover.btn-radio-support4:before {
        border-color: #683ddb;
      }
      .btn.active.btn-checkbox-support5:before,
      .btn.active.btn-radio-support5:before {
        color: #45677f;
      }
      .btn:hover.btn-checkbox-support5:before,
      .btn:hover.btn-radio-support5:before {
        border-color: #21313d;
      }
      .btn.btn-checkbox-default-inverse:before {
        border-color: #494949;
      }
      .active.btn.btn-checkbox-default-inverse:before {
        color: #fff;
        background: #555555;
      }
      :hover.btn.btn-checkbox-default-inverse:before {
        border-color: #222222;
      }
      .btn.btn-radio-default-inverse:before {
        border-color: #3c3c3c;
        background: #fff;
      }
      .active.btn.btn-radio-default-inverse:before {
        background: #555555;
        color: #555555;
      }
      :hover.btn.btn-radio-default-inverse:before {
        border-color: #222222;
      }
      .btn.btn-checkbox-primary-inverse:before {
        border-color: #1d9bef;
      }
      .active.btn.btn-checkbox-primary-inverse:before {
        color: #fff;
        background: #35a6f1;
      }
      :hover.btn.btn-checkbox-primary-inverse:before {
        border-color: #0c71b4;
      }
      .btn.btn-radio-primary-inverse:before {
        border-color: #108fe3;
        background: #fff;
      }
      .active.btn.btn-radio-primary-inverse:before {
        background: #35a6f1;
        color: #35a6f1;
      }
      :hover.btn.btn-radio-primary-inverse:before {
        border-color: #0c71b4;
      }
      .btn.btn-checkbox-success-inverse:before {
        border-color: #2d862d;
      }
      .active.btn.btn-checkbox-success-inverse:before {
        color: #fff;
        background: #339933;
      }
      :hover.btn.btn-checkbox-success-inverse:before {
        border-color: #194d19;
      }
      .btn.btn-radio-success-inverse:before {
        border-color: #267326;
        background: #fff;
      }
      .active.btn.btn-radio-success-inverse:before {
        background: #339933;
        color: #339933;
      }
      :hover.btn.btn-radio-success-inverse:before {
        border-color: #194d19;
      }
      .btn.btn-checkbox-warning-inverse:before {
        border-color: #d78708;
      }
      .active.btn.btn-checkbox-warning-inverse:before {
        color: #fff;
        background: #f09609;
      }
      :hover.btn.btn-checkbox-warning-inverse:before {
        border-color: #8e5905;
      }
      .btn.btn-radio-warning-inverse:before {
        border-color: #bf7707;
        background: #fff;
      }
      .active.btn.btn-radio-warning-inverse:before {
        background: #f09609;
        color: #f09609;
      }
      :hover.btn.btn-radio-warning-inverse:before {
        border-color: #8e5905;
      }
      .btn.btn-checkbox-danger-inverse:before {
        border-color: #cc1200;
      }
      .active.btn.btn-checkbox-danger-inverse:before {
        color: #fff;
        background: #e51400;
      }
      :hover.btn.btn-checkbox-danger-inverse:before {
        border-color: #7f0b00;
      }
      .btn.btn-radio-danger-inverse:before {
        border-color: #b21000;
        background: #fff;
      }
      .active.btn.btn-radio-danger-inverse:before {
        background: #e51400;
        color: #e51400;
      }
      :hover.btn.btn-radio-danger-inverse:before {
        border-color: #7f0b00;
      }
      .btn.btn-checkbox-info-inverse:before {
        border-color: #0c7dbf;
      }
      .active.btn.btn-checkbox-info-inverse:before {
        color: #fff;
        background: #0d8dd7;
      }
      :hover.btn.btn-checkbox-info-inverse:before {
        border-color: #074e77;
      }
      .btn.btn-radio-info-inverse:before {
        border-color: #0a6da7;
        background: #fff;
      }
      .active.btn.btn-radio-info-inverse:before {
        background: #0d8dd7;
        color: #0d8dd7;
      }
      :hover.btn.btn-radio-info-inverse:before {
        border-color: #074e77;
      }
      .btn.btn-checkbox-black-inverse:before {
        border-color: #000000;
      }
      .active.btn.btn-checkbox-black-inverse:before {
        color: #fff;
        background: #0c0c0c;
      }
      :hover.btn.btn-checkbox-black-inverse:before {
        border-color: #000000;
      }
      .btn.btn-radio-black-inverse:before {
        border-color: #000000;
        background: #fff;
      }
      .active.btn.btn-radio-black-inverse:before {
        background: #0c0c0c;
        color: #0c0c0c;
      }
      :hover.btn.btn-radio-black-inverse:before {
        border-color: #000000;
      }
      .btn.btn-checkbox-white-inverse:before {
        border-color: #f2f2f2;
      }
      .active.btn.btn-checkbox-white-inverse:before {
        color: #fff;
        background: #666666;
      }
      :hover.btn.btn-checkbox-white-inverse:before {
        border-color: #cccccc;
      }
      .btn.btn-radio-white-inverse:before {
        border-color: #e6e6e6;
        background: #fff;
      }
      .active.btn.btn-radio-white-inverse:before {
        background: #ffffff;
        color: #ffffff;
      }
      :hover.btn.btn-radio-white-inverse:before {
        border-color: #cccccc;
      }
      .btn.btn-checkbox-gray-inverse:before {
        border-color: #313534;
      }
      .active.btn.btn-checkbox-gray-inverse:before {
        color: #fff;
        background: #555555;
      }
      :hover.btn.btn-checkbox-gray-inverse:before {
        border-color: #313534;
      }
      .btn.btn-radio-gray-inverse:before {
        border-color: #d5d5d5;
        background: #fff;
      }
      .active.btn.btn-radio-gray-inverse:before {
        background: #eeeeee;
        color: #eeeeee;
      }
      :hover.btn.btn-radio-gray-inverse:before {
        border-color: #bbbbbb;
      }
      .btn.btn-checkbox-inverse-inverse:before {
        border-color: #232b2e;
      }
      .active.btn.btn-checkbox-inverse-inverse:before {
        color: #fff;
        background: #2e383d;
      }
      :hover.btn.btn-checkbox-inverse-inverse:before {
        border-color: #020303;
      }
      .btn.btn-radio-inverse-inverse:before {
        border-color: #181d20;
        background: #fff;
      }
      .active.btn.btn-radio-inverse-inverse:before {
        background: #2e383d;
        color: #2e383d;
      }
      :hover.btn.btn-radio-inverse-inverse:before {
        border-color: #020303;
      }
      .btn.btn-checkbox-support1-inverse:before {
        border-color: #5fb48d;
      }
      .active.btn.btn-checkbox-support1-inverse:before {
        color: #fff;
        background: #70bc99;
      }
      :hover.btn.btn-checkbox-support1-inverse:before {
        border-color: #3f8766;
      }
      .btn.btn-radio-support1-inverse:before {
        border-color: #4faa80;
        background: #fff;
      }
      .active.btn.btn-radio-support1-inverse:before {
        background: #70bc99;
        color: #70bc99;
      }
      :hover.btn.btn-radio-support1-inverse:before {
        border-color: #3f8766;
      }
      .btn.btn-checkbox-support2-inverse:before {
        border-color: #f73f57;
      }
      .active.btn.btn-checkbox-support2-inverse:before {
        color: #fff;
        background: #f8576c;
      }
      :hover.btn.btn-checkbox-support2-inverse:before {
        border-color: #e00925;
      }
      .btn.btn-radio-support2-inverse:before {
        border-color: #f62641;
        background: #fff;
      }
      .active.btn.btn-radio-support2-inverse:before {
        background: #f8576c;
        color: #f8576c;
      }
      :hover.btn.btn-radio-support2-inverse:before {
        border-color: #e00925;
      }
      .btn.btn-checkbox-support3-inverse:before {
        border-color: #59a5b5;
      }
      .active.btn.btn-checkbox-support3-inverse:before {
        color: #fff;
        background: #6bafbd;
      }
      :hover.btn.btn-checkbox-support3-inverse:before {
        border-color: #3c7986;
      }
      .btn.btn-radio-support3-inverse:before {
        border-color: #4c99a9;
        background: #fff;
      }
      .active.btn.btn-radio-support3-inverse:before {
        background: #6bafbd;
        color: #6bafbd;
      }
      :hover.btn.btn-radio-support3-inverse:before {
        border-color: #3c7986;
      }
      .btn.btn-checkbox-support4-inverse:before {
        border-color: #9a7de7;
      }
      .active.btn.btn-checkbox-support4-inverse:before {
        color: #fff;
        background: #ab93eb;
      }
      :hover.btn.btn-checkbox-support4-inverse:before {
        border-color: #683ddb;
      }
      .btn.btn-radio-support4-inverse:before {
        border-color: #8a68e3;
        background: #fff;
      }
      .active.btn.btn-radio-support4-inverse:before {
        background: #ab93eb;
        color: #ab93eb;
      }
      :hover.btn.btn-radio-support4-inverse:before {
        border-color: #683ddb;
      }
      .btn.btn-checkbox-support5-inverse:before {
        border-color: #3c5a6e;
      }
      .active.btn.btn-checkbox-support5-inverse:before {
        color: #fff;
        background: #45677f;
      }
      :hover.btn.btn-checkbox-support5-inverse:before {
        border-color: #21313d;
      }
      .btn.btn-radio-support5-inverse:before {
        border-color: #334c5e;
        background: #fff;
      }
      .active.btn.btn-radio-support5-inverse:before {
        background: #45677f;
        color: #45677f;
      }
      :hover.btn.btn-radio-support5-inverse:before {
        border-color: #21313d;
      }
      .btn-switch {
        -webkit-box-shadow: none;
        box-shadow: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        width: 60px;
        position: relative;
        overflow: hidden;
        padding: 0;
        margin: 0;
        background: #E1E1E8;
      }
      .btn-switch label {
        padding: 0;
        margin: 0;
        white-space: nowrap;
        width: 200%;
        cursor: pointer;
        margin-bottom: -4px;
        margin-left: 0;
        -webkit-transition: margin-left 0.2s ease-out;
        transition: margin-left 0.2s ease-out;
      }
      .btn-switch label span {
        display: inline-block;
        float: left;
        padding: 6px 18px 6px 0;
        text-align: center;
        width: 50%;
        background: #55baf5;
      }
      .btn-switch label span + span {
        padding: 6px 0 6px 18px;
      }
      .btn-switch:after {
        content: ".";
        position: absolute;
        left: 100%;
        display: inline-block;
        padding: 5px 0;
        margin-left: -20px;
        width: 20px;
        background: #fff;
        color: #fff;
        border: 1px solid #999999;
        -webkit-transition: all 0.2s ease-out;
        transition: all 0.2s ease-out;
      }
      .btn-switch.active:after {
        left: 0;
        margin-left: 0;
        -webkit-transition: all 0.2s ease-out;
        transition: all 0.2s ease-out;
      }
      .btn-switch.active label {
        margin-left: -100%;
        -webkit-transition: margin-left 0.2s ease-out;
        transition: margin-left 0.2s ease-out;
      }
      .btn-group-vertical.full-width {
        width: 100%;
      }
      .btn-group-vertical.full-width .btn,
      .btn-group-vertical.full-width .btn-group {
        width: 100%;
      }
      
      .list-group .btn[class^="btn-radio"],
      .list-group .btn[class^="btn-checkbox"],
      .list-group .btn[class*=" btn-radio"],
      .list-group .btn[class*=" btn-checkbox"] {
        padding: 0;
      }
      .list-group-item {
        color: #333333;
      }
 




    </style>

    <div class="container">
      <script type="text/javascript">
        $("#navOficinas").attr('class','dropdown active');
        $("#navConfigGralCaja").attr('class','active');
      </script>
        <div class="row">
          <div class="col-md-12 col-sm-12" >
              <div class="panel panel-primary">
                <div class="panel-heading"> <b>OFICINAS</b></div>
                <div class="panel-body">
                <p></p>
                  <div class="row">
                    <div class="col-md-2 col-md-offset-1">
                      <button type="button" class="btn btn-primary btn-block" id="btnRefrescar"><span class="fa fa-refresh"></span> Actualizar</button>
                    </div>
                  </div>
                  <p></p>
                  <div class="row">
                     <div class="row" id="Result">
                    {% ifnotequal resultado None %}
                    {% ifnotequal resultado '' %}
                    {% ifequal resultado 'exito' %}
                    <div class="alert alert-success" role="alert" align="center">
                      <h4>OPERACION EXITOSA!!</h4>
                    </div>
                    {% else %}
                    <div class="alert alert-danger" role="alert" align="center">
                      <h4>FALLO OPERACIÓN :( {{resultado}}</h4>
                    </div>
                    {% endifequal %}
                    {% endifnotequal %}
                    {% endifnotequal %}
                  </div>
                  <div class="row">
                    <div class="col-md-10 col-md-offset-1">
                      <div class="alert alert-warning alert-dismissible" role="alert" align="left">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close" style=" font-size:30px;"><span aria-hidden="true">&times;</span></button>
                        <strong>Recuerde!</strong> <br>Si esta configurando <b>Cajas Independientes</b><br> <b>(*)</b>  Verificar (o cambiar) el nombre de la caja en <a href="/Admin/ConsultaGeneralCajas/" class="btn btn-primary btn-xs" role="button">Oficinas > Ver Oficinas</a>, para evitar errores en la configuracion.<br>
                        <b>(**)</b> Los <b>nombres de las cajas independientes</b> apareceran como destinos en la ventana de <u>crear Transferencia</u>.
                      </div>
                    </div>
                  </div>
                  <p></p>
                    <div class="col-md-10 col-md-offset-1">
                        <div class="table-responsive m-b-10">
                          <table class="table table-bordered">
                              <thead>
                                <tr>
                                  <th>Nro</th>
                                  <th>Oficina</th>
                                  <th>Tipo</th>
                                </tr>
                              </thead>
                              <tbody id="listaR">
                                  
                              </tbody>
                          </table>
                        </div>
                        <div class="row">
                          <!--
                           <div class="col-md-3 col-md-offset-7 m-b-10">
                            <button id="btnConfigComisiones" data-toggle="modal" data-target="#modalConfiguracionComisiones" class="btn btn-primary btn-block">Configuración Comisiones</button>
                          </div>
                        -->

                          <div class="col-md-2  m-b-10">
                            <button href="#" data-toggle="modal" data-target="#modalOficinaCentral" class="btn btn-danger btn-block">Oficina Central</button>
                          </div>
                        </div>
                    </div>
                    
                  </div>
                </div>
              </div>
          </div>
        </div>
    </div>

    <div id="modalOficinaCentral" 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">Opciones</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                <div class="col-md-4 col-md-offset-1" align="right"> 
                   <h5>Oficina Central:</h5> 
                </div>
                <div class="col-md-5">  
                 <div class="fg-line">
                  <div class="select">
                  <select class="form-control" id="ComboOficina">    
                  </select>
                  </div>
                  </div>
                </div>
              </div>
              <p></p>
              <div class="row">
                <div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4">
                  <button type="button" class="btn btn-primary btn-block" id="cambiarOfi">Guardar</button>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-md-2 col-md-offset-10">
                   <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
              </div>
            </div>

          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

  
  <div id="modalComisionesGuardadas" 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">Comisiones Configuradas</h4>
            </div>
            <div class="modal-body">
              
              <div class="row">
                 <div class="col-md-12">
                    <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                  <tr >
                                    <th>Monto Mínimo</th>
                                    <th>Monto Máximo</th>
                                    <th>Comisión</th>
                                    <th></th> 
                                  </tr>
                                </thead>
                                <tbody id="listaComisionesGuardadas">
                                 
                                </tbody>
                            </table>
                          </div>
                 </div> 
             
              </div>

            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-md-2 col-md-offset-10">
                   <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Cerrar</button>
                </div>
              </div>
            </div>

          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->


      <div id="modalComisionesGuardadas1" 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">Comisiones Configuradas SubBases</h4>
            </div>
            <div class="modal-body">
              
              <div class="row">
                 <div class="col-md-12">
                    <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                  <tr >
                                    <th>Monto Mínimo</th>
                                    <th>Monto Máximo</th>
                                    <th>Comisión</th>
                                    <th></th> 
                                  </tr>
                                </thead>
                                <tbody id="listaComisionesGuardadas1">
                                 
                                </tbody>
                            </table>
                          </div>
                 </div> 
             
              </div>

            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-md-2 col-md-offset-10">
                   <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Cerrar</button>
                </div>
              </div>
            </div>

          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->



    <div id="modalCopiar" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
          <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">Copiar a:</h4>
            </div>
            <div class="modal-body">
              
              <div class="row">
                 <div class="col-md-12">
                    <div id="accordionCopiar">
                        <div class="row">
                          <div class="col-md-12">
                             <div class="panel " id="divConfigCopiar">
                               
                              </div>

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

            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-md-12">
                   <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Cerrar</button>
                </div>
              </div>
            </div>

          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->


   <div id="modalConfiguracionComisiones" 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">Configurar Comisiones</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                <div class="col-md-4" id="divOficina"> 
                  <strong>Oficina</strong> 
                  <select class="form-control" id="ComboOficinaC" >
                  </select>
                </div> 
                 <div class="col-md-4" id="divCaja"> 
                  <strong>Caja</strong>  
                  <select class="form-control" id="ComboCajaC" >               
                    </select>
                </div>
                  <div class="col-md-4" id="divBase"> 
                  <strong>Base</strong>  
                  <select class="form-control" id="ComboBase" >               
                    </select>
                </div>
              </div>
              <p></p>
              <div class="row">
                <div class="col-md-12">
                  <div class="col-md-3"> 
                    Monto Mínimo <input type="text" class="form-control" id="txtmonmin">
                  </div>
                  <div class="col-md-3">  
                    Monto Máximo <input type="text" class="form-control" id="txtmonmax">
                  </div>
                  <div class="col-md-3">
                    Comisión  
                    <input type="text" class="form-control" id="txtcomision">
                  </div>
                  <div class="col-md-3">
                    <div style="margin-top:15px"> <a href="#" id="btnCopiar" data-toggle="modal" data-target="#modalCopiar"><i class="fa fa-files-o fa-2x" aria-hidden="true"></i> COPIAR</a> 
                  </div>

                </div>   
              </div>
              <p></p>
            </div>
 
              <div class="row">
                 <div class="col-md-12">
                    <div id="accordion">
                      <div class="card-body">
                        <div class="row">
                          <div class="col-md-12">
                             <div class="panel panel-default" id="divConfig">
                              
                              </div>

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

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

            </div>
            <div class="modal-footer">
              <div class="row">
                <div class="col-md-4 col-md-offset-2">
                    <button type="button" class="btn btn-primary" id="btnLimpiar"><i class="fa fa-check"></i> Guardar </button> 
                </div>
                <div class="col-md-2">
                   <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Cerrar</button>
                </div>
              </div>
            </div>

          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->




     <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
          <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">Detalles</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">
                              <h4 class="bg-success" align="center">
                                <!--&nbsp;-->
                                Configuración Cajas
                              </h4>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-10" align="right">
                              <h5>Oficina: </h5>
                            </div>
                            <div class="col-md-2">
                              <input type="text" class="form-control" id="txtidOfi" >
                              <p></p>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="table-responsive">
                                <table class="table table-bordered table-striped">
                                    <thead>
                                      <tr>
                                        <th>Nombre</th>
                                        <th>Operador</th>
                                        <th>Cierre Forzado</th>
                                        <th>Transferencias Globales</th>
                                        <th>Transferencias Creadas Globales</th>
                                        <th>Autorización Retiro Transferencia</th>
                                        <th>Monto Tope</th>
                                        <th>Comisión Mínima</th>
                                        <th>Otros Conceptos Mínimos</th>
                                        <th>Extorno Total</th>
                                      </tr>
                                    </thead>
                                    <tbody id="listaCa">
                                    </tbody>
                                </table>
                              </div>
                            </div>
                          </div>

                        </div><!--fin panel body-->
                      </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>

      <div id="ModalOf" 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">Autorizar Oficinas</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="panel-body">
                              <div class="row">
                                <div class="col-md-12">
                                    <div class="table-responsive">
                                      <table class="table table-bordered table-striped">
                                          <thead>
                                            <tr>
                                              <th>Nro</th>
                                              <th>Oficina</th>
                                              <th>Marque las oficinas permitidas</th>
                                              <th>Cajas Permitidas</th>
                                            </tr>
                                          </thead>
                                          <tbody id="listaO">
                                            <!--<tr class="filaOf">
                                              <td scope="row">1</td>
                                              <td>CUSCO</td>
                                              <td align="center"> 
                                                <div data-toggle="buttons">
                                                    <label class="btn checkbox-inline btn-checkbox-success-inverse active">
                                                      <input type="checkbox" value="success-inverse1"> Checked
                                                    </label>
                                                    
                                                  </div>
                                              </td>
                                            </tr>-->
                                              
                                          </tbody>
                                      </table>
                                    </div>
                                </div>
                              </div>
                            </div>
                        </div><!--fin panel body-->
                      </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
      <div id="ModalCajaGlo" 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">Autorizar Cajas</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                <div class="col-md-12">
                    <div class="table-responsive">
                      <table class="table table-bordered table-striped">
                          <thead>
                            <tr>
                              <th>Nro</th>
                              <th>Caja</th>
                              <th>Operador</th>
                              <th>Marque las Cajas permitidas</th>
                             
                            </tr>
                          </thead>
                          <tbody id="listaCaglo">
                          </tbody>
                      </table>
                    </div>
                </div>
              </div>     
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
      <div id="Modalmovi" 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">Detalles</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                <div class="col-md-12">
                  <div class="panel panel-default">
                        <div class="panel-body">
                          <form id="formConfiguracion" action="/Admin/configurarTransGlobalesCaja/" method="POST" data-toggle="validator" role="form"> {% csrf_token %}
                            <div class="row">
                              <div class="col-md-12">
                                <h4 class="bg-success" align="center">
                                  <!--&nbsp;-->
                                  Información de la Caja
                                </h4>
                              </div>
                            </div>
                            <div class="row">
                                <div class="col-md-2">
                                  <input type="text" class="form-control" id="txtpkC" name ="pkC" readonly="readonly" required>
                                  <p></p>
                                </div>
                            </div>
                            <div class="row">
                              <div class="col-md-2" align="right">
                                <h5>Caja: </h5>
                              </div>
                              <div class="col-md-5">
                                <input type="text" class="form-control" id="txtnombreCa" readonly>
                                <p></p>
                              </div>
                              <div class="col-md-2" align="right">
                                <h5>Id Caja: </h5>
                              </div>
                              <div class="col-md-3">
                                <input type="text" class="form-control" name="pkC" id="txtidCa" readonly>
                                <p></p>
                              </div>

                              <input type="text" class="form-control hidden" id="txtpkConf" readonly="readonly">
                                   
                            </div>
                            <div class="row">
                              <div class="col-md-2" align="right">
                                <h5>Encargado: </h5>
                              </div>
                              <div class="col-md-8">
                                <input type="text" class="form-control" id="txtencargadoCa" readonly>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-12">
                                <h4 class="bg-success" align="center">
                                  <!--&nbsp;-->
                                  Configuración General de la Caja
                                </h4>
                              </div>
                            </div>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Cierre Obligatorio: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="cf" id="txtcf" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                                </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-4 col-md-offset-1" align="right">
                                <h5>Crear Transferencias Globales: </h5>
                              </div>
                              <div class="col-md-3">
                              <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="tg" id="txttg">
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                              <div class="col-md-4  col-xs-4 ">
                                <button class="btn btn-success btn-block" type="button" id="btnOficinas" data-toggle="modal" data-target="#ModalOf">Oficinas Permitidas</button>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-4 col-md-offset-1" align="right">
                                <h5>Pedir autorizacion de pago de PT: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="rta" id="txtrta">
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                             <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver Transferencias Globales Creadas: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="tgc" id="txttgc" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                             <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Extorno: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="ce" id="txtce" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Monto Tope: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <input type="text" class="form-control"  name ="mt" id="txtmt"  required>
                                </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Monto Maximo en ST: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <input type="text" class="form-control"  name ="mt_st" id="txtmt_st">
                                </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver Saldo en Oficina central: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="verSaldo" id="txtvs" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                             <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Autorizar Sobregiros Ctas Ctes: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="autSCtaCtes" id="txtscta" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Dar Clave para PT:</h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="PerAutRetTR" id="txtPerAutReTR" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Comisión mínima: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 

                                <input type="text" class="form-control" name ="cm" id="txtcm"  required>
                                </div>
                                <p></p>
                              </div>
                            </div>
                             <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Otros Conceptos Mínimos: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 

                                <input type="text" class="form-control"  name ="ocm" id="txtocm"  required>
                                </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver Saldo de Oficinas: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="VerSaldoOfi" id="txtVersaldoOfi" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Caja Independiente: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="CajaInd" id="txtCajaInd" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Egreso: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="egreso" id="txtEgreso" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver Saldo de Cajas Alternas: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="saldoalt" id="txtsaldoalterna" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>PT sin DNI: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="ptsindni" id="txtptsindni" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Comision por cambio de destino: </h5>
                              </div>
                              <div class="col-md-3">
                                <input type="text" class="form-control"  name="comiCambioD" id="txtcomiCambioD" required>
                                </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver recibos desde el inicio del sistema: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="filtrodesdeReinicio" id="txtfiltrodesdeReinicio" >
                                    <option value="no">si</option>
                                    <option value="si">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                            <div class="row">
                              <div class="col-md-3 col-md-offset-2" >
                                <h5>Ver intercambios recibidos: </h5>
                              </div>
                              <div class="col-md-3">
                               <div class="fg-line"> 
                                <div class="select"> 
                                  <select class="form-control" name="verinter" id="txtverinter" >
                                    <option value="si">si</option>
                                    <option value="no">no</option>
                                  </select>
                                </div>
                              </div>
                                <p></p>
                              </div>
                            </div>
                            <p></p>
                             <div class="row">
                                <div class="col-md-4 col-md-offset-2 col-xs-2 col-xs-offset-2">
                                  <button class="btn btn-primary btn-block" id="btnActualizar" type="button">Actualizar</button>
                                </div>
                                 <div class="col-md-4  col-xs-4 ">
                                  <input class="btn btn-danger btn-block" id="btnOficinasAr" value="Conf. Porcentajes" data-toggle="modal" data-target="#ModalOfifinaArq">
                                </div>
                              </div>
                           </form>  
                        </div><!--fin panel body-->
                      </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
      <div id="ModalOfifinaArq" 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">Configuración</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="panel-body">
                              <div class="row">
                                <div class="col-md-12">
                                    <div class="table-responsive">
                                      <table class="table table-hover">
                                          <thead>
                                            <tr>
                                              <th>Nro</th>
                                              <th>Oficina</th>
                                            </tr>
                                          </thead>
                                          <tbody id="listaR7">
                                              
                                          </tbody>
                                      </table>
                                    </div>
                                </div>
                              </div>
                            </div>
                        </div><!--fin panel body-->
                      </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
      <div id="myModal7" 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">Detalles</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">
                              <p class="bg-success" align="center" id="ActPrj">
                              </p>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <p class="bg-success" align="center">
                                <!--&nbsp;-->
                                Consulta Cajas
                              </p>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-10" align="right">
                              <h5>Oficina: <span id="spOfi"></span></h5>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                      <tr>
                                        <th>Nombre</th>
                                        <th>Operador</th>
                                        <th>Tipo de caja</th>
                                      </tr>
                                    </thead>
                                    <tbody id="listaCa7">
                                    </tbody>
                                </table>
                              </div>
                            </div>
                          </div>

                        </div><!--fin panel body-->
                      </div>
                </div>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
  <!--
  <div id="ModalDetConficArq" 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">Configuracion</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="panel-body">
                          <div class="row">
                            <div class="col-md-12">
                              <p class="bg-success" align="center">
                                 <label>Oficina: <span id="txtoficonfigArq"></span></label>
                              </p>
                            </div>
                          </div>
                          <p></p>
                          
                          <div class="row">
                            <div class="col-md-8 col-md-offset-1">
                              <label>Caja: <span id="txtca7"></span></label>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-3 col-md-offset-1" align="right">
                              <h5>id Caja: </h5>
                            </div>
                            <div class="col-md-2">
                              <input type="text" class="form-control" id="txtpkC7" name ="pkC1" readonly="readonly" required>
                              <p></p>
                            </div>
                            <div class="col-md-3" align="right">
                              <h5>id Conf: </h5>
                            </div>
                            <div class="col-md-2">
                              <input type="text" class="form-control" id="txtpkConf7" name="pkConf"readonly="readonly">
                              <p></p>
                            </div>
                          </div>
                          <p></p>
                          <div class="row">
                            <div class="col-md-4 col-md-offset-1" align="right">
                              <h5>Tipo de Pficina/Caja </h5>
                            </div>
                            <div class="col-md-6">
                                <label class="radio-inline">
                                      <input type="radio" name="tipocaja" id="rbPropia" value="p" checked><b> Propia</b>
                                    </label>
                                    <label class="radio-inline">
                                      <input type="radio" name="tipocaja" id="rbCompartida" value="c"><b> Compartida</b>
                                </label>
                              <p></p>
                            </div>
                          </div>
                          <p></p>
                          <div class="row">
                            <div class="col-md-5" align="right">
                              <h5>% Para: <span id="spOO"></span>-<span id="spCaO"></span></h5>
                            </div>
                            <div class="col-md-3">
                                <input type="text" class="form-control" id="po" name="po">
                              <p></p>
                            </div>
                          </div>
                          <p></p>
                          <div class="row" id="campoofic">
                            <div class="col-md-4 col-md-offset-1" align="right">
                              <h5>% Para Oficina Central </h5>
                            </div>
                            <div class="col-md-3">
                                <input type="text" class="form-control" id="pc" name="pc">
                              <p></p>
                            </div>
                          </div>
                          <p></p>
                          <div class="row">
                            <div class="col-md-4 col-md-offset-1" align="right" >
                              <h5>% Para: <span id="spO"></span>-<span id="spCa"></span></h5>
                            </div>
                            <div class="col-md-3">
                                <input type="text" class="form-control" id="pe" name="pe"readonly>
                              <p></p>
                            </div>
                          </div>
                          <p></p>

                          <p></p>
                          <div class="row">
                            <div class="col-md-4 colmd-offset-4 col-xs-4 col-xs-offset-2">
                              <input class="btn btn-primary btn-block" id="btnActprj" value="Guardar Cambios" >
                            </div>
                          </div>
                        </div>
                    </div>
                  </div>
            </div>
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
        </div>
      </div>
    </div>
  </div>
-->
     <div id="ModalDetConficArq" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
          <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">Configuración</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">
                          <p class="bg-success" align="center">
                             <label>Configuracion de Porcentajes</label>
                          </p>
                        </div>
                      </div>
                      <p></p>
                      
                      <div class="row">
                        <div class="col-md-12">
                          <label>Confi. con: <span id="txtoficonfigArq"></span>-<span id="txtca7"></span></label>
                        </div>
                      </div>
                      <div class="row">
                        <div class="col-md-3" align="right">
                          <h5>id Caja: </h5>
                        </div>
                        <div class="col-md-3">
                          <input type="text" class="form-control" id="txtpkC7" name ="pkC1" readonly="readonly" required>
                          <p></p>
                        </div>
                        <div class="col-md-3" align="right">
                          <h5>id Conf: </h5>
                        </div>
                        <div class="col-md-3">
                          <input type="text" class="form-control" id="txtpkConf7" name="pkConf"readonly="readonly">
                          <p></p>
                        </div>
                      </div>
                      <p></p>
                      <div class="row">
                        <div class="col-md-3" align="right">
                          <h5>Tipo:</h5>
                        </div>
                        <div class="col-md-6">
                            <label class="radio-inline">
                                  <input type="radio" name="tipocaja" id="rbPropia" value="p" checked><b> Propia</b>
                                </label>
                                <label class="radio-inline">
                                  <input type="radio" name="tipocaja" id="rbCompartida" value="c"><b> Compartida</b>
                            </label>
                          <p></p>
                        </div>
                      </div>
                      <p></p>
                      <div class="row">
                        <div class="col-md-5" align="right">
                          <h5>% Para: <span id="spOO"></span>-<span id="spCaO"></span></h5>
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="po" name="po">
                          <p></p>
                        </div>
                      </div>
                      <p></p>
                      <div class="row" id="campoofic">
                        <div class="col-md-4 col-md-offset-1" align="right">
                          <h5>% Para Oficina Central </h5>
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="pc" name="pc">
                          <p></p>
                        </div>
                      </div>
                      <p></p>
                      <div class="row">
                        <div class="col-md-4 col-md-offset-1" align="right" >
                          <h5>% Para: <span id="spO"></span>-<span id="spCa"></span></h5>
                        </div>
                        <div class="col-md-4">
                            <input type="text" class="form-control" id="pe" name="pe"readonly>
                          <p></p>
                        </div>
                      </div>
                      <p></p>

                      <p></p>
                      <div class="row">
                        <div class="col-md-4 col-md-offset-4 col-xs-4 col-xs-offset-4">
                          <input class="btn btn-primary btn-block" id="btnActprj" value="Guardar Cambios" >
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                 
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
      
      <div id="ModalUpdComi" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
          <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">Detalle Comision</h4>
            </div>
            <div class="modal-body">
              <div class="row">
                <div class="col-md-3 col-md-6" align="right">
                  <h5>ID: </h5>
                </div>
                <div class="col-md-3">
                  <input type="text" class="form-control" id="actpk" disabled>
                  <p></p>
                </div>
              </div>
              <p></p>
              <div class="row">
                <div class="col-md-6" align="right">
                  <h5>Desde Monto: </h5>
                </div>
                <div class="col-md-6">
                  <input type="text" class="form-control" id="actmonmin" >
                  <p></p>
                </div>
              </div>
              <p></p>
              <div class="row">
                <div class="col-md-6" align="right">
                  <h5>Hasta Monto: </h5>
                </div>
                <div class="col-md-6">
                  <input type="text" class="form-control" id="actmonmax">
                  <p></p>
                </div>
              </div>
              <p></p>
              
              <div class="row">
                <div class="col-md-6" align="right">
                  <h5>Comisión: </h5>
                </div>
                <div class="col-md-6">
                  <input type="text" class="form-control" id="actComision">
                  <p></p>
                </div>
              </div>
              <p></p>
              <div class="row">
                <button type="button" class="btn btn-success" id="actualizarComi">Modificar</button>
              </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
            </div>
          </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
      </div>
    <script type="text/javascript">
       Aux=[];
      Aux3=[];
      Aux7=[];
      Aux8=[];
      AuxCo=[];
      filaCo=0;
      filaI3=0;

      

      $("#btnActualizar").click(function(){
          $("#formConfiguracion").submit();
      });

      //function submitForm(){
        //console.log("data");
        //$("#formConfiguracion").submit();
      //}

      $(document).ready(function (){

        arrayOficinas=[];
        arrayBases=[];

        $("#txtmt").numeric();
        $("#txtmt_st").numeric();
        $("#txtcm").numeric();
        $("#txtocm").numeric();
         $('#po').numeric(".");
        $('#pe').numeric(".");
        $('#pc').numeric(".");
        $('#ppo').numeric(".");
        $('#ppe').numeric(".");
        //---comisiones--
        $("#txtmonmin").numeric("."); 
        $("#txtmonmax").numeric(".");
        $("#txtcomision").numeric(".");
        $("#actmonmin").numeric(".");
        $("#actmonmax").numeric(".");
        $("#actComision").numeric(".");
        
        $("#txtcomiCambioD").numeric(".");

        //--------------- transferencias globales

         $("#btnLimpiar").click(function(){
          $("#txtmonmin").prop('value',null); 
          $("#txtmonmax").prop('value',null);
          $("#txtcomision").prop('value',null);
          arrayBases=[];
          arrayOficinas=[];
          ajax_oficinas_cajas();
          bootbox.alert("Configuración guardada");
        });

        $("#btnConfigComisiones").click(function(){
          $("#txtmonmin").val("");
          $("#txtmonmax").val("");
          $("#txtcomision").val(""); 
          ajax_oficinas_cajas();
        });

        $("#btnCopiar").click(function(){
          ajax_oficinas_cajas_copiar();
          /*var html_copy="";

            html_copy+='<li class="list-group-item">'
                            +'<div class="row">'
                            +'<div class="col-md-12">'
                              +'<div class="col-md-4">'
                                +'<div class="col-md-2">'
                                  +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse">'
                                    +'<input type="checkbox" id="'+data[i].pk+'" class="chbo">'
                                  +'</div>'
                                +'</div>'
                                +'<div class="col-md-6 text-left" style="margin-top:4px">'
                                  +'<span>'+data[i].of+'</span>'
                                +'</div>'
                              +'</div>'
                              +'<div class="col-md-4">'
                              +'</div>'
                              +'<div class="col-md-4">'
                              +'</div>'
                            +'</div>'
                            +'</div>'
                          +'</li>';*/

        });

        $("#ComboOficinaC").change(function(){
          arrayOficinas=[];
          arrayBases=[];
          ajax_caja($("#ComboOficinaC").val());
          ajax_oficinas_cajas(); 
          $("#txtmonmin").val("");
          $("#txtmonmax").val("");
          $("#txtcomision").val(""); 
        });


        $("#ComboCajaC").change(function(){
          arrayOficinas=[];
          arrayBases=[];
          ajax_base($(this).val(),$("#ComboOficinaC").val()); 
          $("#txtmonmin").val("");
          $("#txtmonmax").val("");
          $("#txtcomision").val(""); 
        });



        $("#btnLimpiar").click(function(){
          $("#txtmonmin").prop('value',null);
          $("#txtmonmax").prop('value',null);
          $("#txtcomision").prop('value',null);
          ajax_oficinas_cajas();
        });

         $("#listaR").on("click",".filaOf",function(){
          var num = $(this).prop('id');
          filaI2 = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaOf');
          $(this).prop('class','filaOf warning');
          ajax_caja(Aux[filaI2].pk);
          //insertando datos en el modal
          $("#txtidOfi").prop('value',Aux[filaI2].pk);
          $("#txtof").text(Aux[filaI2].of);
          $("#spOO").text(Aux[filaI2].of);
        });
        $("#listaCa").on("click",".filaCa",function(){
          $("#listaO").html("");
          $("#grupo_f").hide();
          var num = $(this).prop('id');
          filaI3 = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaCa');
          $(this).prop('class','filaCa warning');
          //insertando datos al modal
          $("#txtidCa").prop('value',Aux3[filaI3].c_id);
          $("#txtpkC").prop('value',Aux3[filaI3].c_id);
          $("#txttg").prop('value',Aux3[filaI3].transGl);
          $("#txttgc").prop('value',Aux3[filaI3].transCGl);
          $("#txtrta").prop('value',Aux3[filaI3].rta);
          $("#txtcf").prop('value',Aux3[filaI3].cf);
          $("#txtce").prop('value',Aux3[filaI3].et);
          $("#txtmt").prop('value',Aux3[filaI3].mt);
          $("#txtmt_st").prop('value',Aux3[filaI3].mt_st);
          $("#txtvs").prop('value',Aux3[filaI3].vs);
          $("#txtscta").prop('value',Aux3[filaI3].as);
          $("#txtPerAutReTR").prop('value',Aux3[filaI3].prST);
          $("#txtcm").prop('value',Aux3[filaI3].cm);
          $("#txtocm").prop('value',Aux3[filaI3].ocm);
          $("#txtVersaldoOfi").prop('value',Aux3[filaI3].vso);
          $("#txtCajaInd").prop('value',Aux3[filaI3].cajaI);
          $("#txtEgreso").prop('value',Aux3[filaI3].eg);
          $("#txtptsindni").prop('value',Aux3[filaI3].ptsindni);
          $("#txtcomiCambioD").prop('value',Aux3[filaI3].comiCambioD);
          $("#txtfiltrodesdeReinicio").prop('value',Aux3[filaI3].filtrodesdeReinicio);
          $("#txtverinter").prop('value',Aux3[filaI3].verinterre);
          $("#txtsaldoalterna").prop('value',Aux3[filaI3].saldoalt);
          $("#txtpkConf").prop('value',Aux3[filaI3].pkConfigPermisos);
          if (Aux3[filaI3].pkConfigPermisos=='' || Aux3[filaI3].pkConfigPermisos==null){
             ajax_oficinas_transfGlobal(-1);
          }else{
             ajax_oficinas_transfGlobal(Aux3[filaI3].pkConfigPermisos);
          }
          
          $("#txtnombreCa").prop('value',Aux3[filaI3].c_nombre);
          $("#txtencargadoCa").prop('value',Aux3[filaI3].p_nombre+' '+Aux3[filaI3].p_ap+' '+Aux3[filaI3].p_am);
          $("#txtca").text(Aux3[filaI3].c_nombre);
          $("#txtop").text(Aux3[filaI3].p_nombre+' '+Aux3[filaI3].p_ap+' '+Aux3[filaI3].p_am);
           $("#spCaO").text(Aux3[filaI3].c_nombre);
        });
 
        
        function ajax_caja(idOf){
          $.ajax({
            url:'/Admin/CajasPersonalConfig_ajax/',
            data:{'idOfi':idOf},
            type:'GET',
            dataType:'json',
            success: function(data){
              Aux3 = data;
              var html ="";
              var html_caja="";
              var esta='';
              var sty ='';  
              console.log(data);       

              for(var i=0;i<data.length;i++){
                html_caja += '<option value="'+data[i].c_id+'">'+data[i].c_nombre+'</option>';

                html += '<tr data-toggle="modal" data-target="#Modalmovi" class="filaCa" '+sty+' id="'+i+'"><td>'+data[i].c_nombre+'</td><td>'+data[i].p_nombre+' '+data[i].p_ap+' '+data[i].p_am+'</td><td>'+data[i].cf+'</td><td>'+data[i].transGl+'</td><td>'+data[i].transCGl+'</td><td>'+data[i].rta+'</td><td>'+data[i].mt+'</td><td>'+data[i].cm+'</td><td>'+data[i].ocm+'</td><td>'+data[i].et+'</td></tr>';
              }                        
              ajax_base(data[0].c_id,idOf);
              $('#listaCa').html(html);
              $('#ComboCajaC').html(html_caja);
            },
            error: function(xhr, textStatus, errorThrown) {

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


        function ajax_base(idC,idOf){ 
          $.ajax({
            url:'/CajasBases_ajax/',
            data:{'idOfi':idOf,'idCa':idC},
            type:'GET',
            dataType:'json',
            success: function(data){
              var html_base=""; 
              console.log(data);
              $('#ComboBase').html("");
              if (data.length>0){ 
                $('#divOficina').removeClass();
                $('#divCaja').removeClass();
                $('#divBase').removeClass();
                $('#divOficina').addClass('col-md-4');
                $('#divCaja').addClass('col-md-4');
                $('#divBase').addClass('col-md-4');

                for(var i=0;i<data.length;i++){
                  html_base += '<option value="'+data[i].b_id+'">'+data[i].b_nombre+'</option>';
                }
                $('#ComboBase').html(html_base);
              }else{
                $('#divOficina').removeClass();
                $('#divCaja').removeClass();
                $('#divOficina').addClass('col-md-4 col-md-offset-2');
                $('#divCaja').addClass('col-md-4');
                $('#divBase').addClass('hidden');
              }
              //console.log(data);
            },
            error: function(xhr, textStatus, errorThrown) {

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

        function ajax_saldo_oficinas(){
          $.ajax({
            url:'/ver_saldo_oficinas_admin_ajax/',
            type:'GET',
            dataType:'json',
            success: function(data){
              Aux = data;
              console.log(data);
              var html ="",html1="",id_oficinaCentral="";
              for(var i=0;i<data.length;i++){
                html1 += '<option value="'+data[i].pk+'" data-value="'+data[i].be+'">'+data[i].of+'</option>';

                if(data[i].categoria=="central"){
                  html += '<tr data-toggle="modal" data-target="#myModal" class="filaOf" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td><td><span class="badge">CENTRAL</span></td></tr>';
                    if(data[i].categoria=="central"){
                      id_oficinaCentral=data[i].pk;
                    }
                }else{
                    html += '<tr data-toggle="modal" data-target="#myModal" class="filaOf" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td><td></td></tr>';
                }
              }                        
              $('#listaR').html(html);
              $('#ComboOficina').html(html1);
              $("#ComboOficina").prop('value',id_oficinaCentral);

              $('#ComboOficinaC').html(html1);
              ajax_caja($("#ComboOficinaC").val());

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

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

    //**** agrgado configuracion cajas globales
    function ajax_cajas_transfGlobal(pkconf,pkO){
          $.ajax({
            url:'/ver_cajas_TransfGlobal_ajax/',
            data:{'pkConf':pkconf,'idOf':pkO},
            type:'GET',
            dataType:'json',
            success: function(data){
              console.log(data);
              Aux = data;
              var html ="";
              for(var i=0;i<data.length;i++){
                if(data[i].trG != 'si'){
                  html += '<tr class="filaOfGlo" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].ca+'</td><td>'+data[i].op+'</td><td align="center"><label class="checkbox"><input class="chbCajaGlo" type="checkbox" value="option1" id="ca'+data[i].pk+'"></label></td></tr>';
                }
                else{
                  html += '<tr class="filaOfGlo" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].ca+'</td><td>'+data[i].op+'</td><td align="center"> <label class="checkbox"><input class="chbCajaGlo" type="checkbox" value="option1" id="ca'+data[i].pk+'" checked></label></td></tr>';
                }

              }                        
              $('#listaCaglo').html(html);

              $(".chbCajaGlo").click(function(){ 
                var num = $(this).prop('id'); 
                if($("#"+num).prop('checked')){
                    console.log("checked");
                    //var num = $(this).prop('id'); 
                    ajax_AddCa($("#txtpkConf").val(),num.substring(2),pkO);
                }else{
                     //var num = $(this).prop('id');
                      console.log("no checked");
                      ajax_SubCa($("#txtpkConf").val(),num.substring(2),pkO);
                }

              });

            },
            error: function(xhr, textStatus, errorThrown) {
                        console.log(xhr.responseText);
                },
          });
        };

        function ajax_AddCa(pkcf,pkc,pko){
          $.ajax({
            url:'/Admin/configurar_cajaTransGlobales_caja_ajax/',
            data:{'pkConf':pkcf,'pkc':pkc},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=="exito"){
              ajax_cajas_transfGlobal(pkcf,pko);
             }
            },
            error: function(xhr, textStatus, errorThrown) {

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


        function ajax_SubCa(pkcf,pkc,pko){
          $.ajax({
            url:'/Admin/quitar_cajasTransGlobales_caja_ajax/',
            data:{'pkConf':pkcf,'pkc':pkc},
            type:'GET',
            dataType:'text',
            success: function(data){
             if(data=="exito"){
              ajax_cajas_transfGlobal(pkcf,pko);
             }
            },
            error: function(xhr, textStatus, errorThrown) {

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

         function ajax_AddOf(pkcf,pkO){
          $.ajax({
            url:'/Admin/configurar_oficinasTransGlobalesCaja/',
            data:{'pkConf':pkcf,'pkO':pkO},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=="exito"){
              ajax_oficinas_transfGlobal(pkcf);
             }
            },
            error: function(xhr, textStatus, errorThrown) {

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


        function ajax_SubOf(pkcf,pkO){
          $.ajax({
            url:'/Admin/quitar_oficinasTransGlobalesCaja/',
            data:{'pkConf':pkcf,'pkO':pkO},
            type:'GET',
            dataType:'text',
            success: function(data){
             if(data=="exito"){
              ajax_oficinas_transfGlobal(pkcf);
             }
            },
            error: function(xhr, textStatus, errorThrown) {

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



         function ajax_oficinas_transfGlobal(pkconf){
          $.ajax({
            url:'/ver_oficinas_TransfGlobal_ajax/',
            data:{'pkConf':pkconf},
            type:'GET',
            dataType:'json',
            success: function(data){
              idofi=0
              //console.log(data);
              Aux = data;
              var html ="";
              for(var i=0;i<data.length;i++){
                if(data[i].trG != 'si'){
                  html += '<tr class="filaOfGlo" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td><td align="center"><label class="checkbox"><input class="chbOficina" type="checkbox" value="option1" id="c'+data[i].pk+'">'+
                    '<i class="input-helper"></i></label>'+
                    '</td><td><button type="button" class="btn btn-warning cajasGlo" data-toggle="modal" data-target="#ModalCajaGlo" id="b'+data[i].pk+'"> Cajas</button></td></tr>';
                }
                else{
                  html += '<tr class="filaOfGlo" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td><td align="center"> <label class="checkbox"><input class="chbOficina" type="checkbox" value="option1" id="c'+data[i].pk+'" checked>'+
                  '<i class="input-helper"></i></label></td><td><button type="button" class="btn btn-warning cajasGlo" data-toggle="modal" data-target="#ModalCajaGlo"id="b'+data[i].pk+'"> Cajas</button></td></tr>';
                }

              }                        
              $('#listaO').html(html);

              $(".chbOficina").click(function(){ 
                var num = $(this).prop('id'); 
                //idofi=num.substring(1);
                if($("#"+num).prop('checked')){
                    console.log("checked");
                    //var num = $(this).prop('id'); 
                    ajax_AddOf($("#txtpkConf").val(),num.substring(1));
                }else{
                     //var num = $(this).prop('id');
                      console.log("no checked");
                      ajax_SubOf($("#txtpkConf").val(),num.substring(1));
                }
                //}
                /*if ($('.chbOficina').is(':checked')) {
                      console.log("checked");
                      var num = $(this).prop('id'); 
                      ajax_AddOf($("#txtpkConf").val(),num.substring(1));
                  }else{
                      var num = $(this).prop('id');
                      console.log("no checked");
                      ajax_SubOf($("#txtpkConf").val(),num.substring(1));
                  }*/
                 //cajas globales

              });
      $(".cajasGlo").click(function(){
                  var idofglo = $(this).prop('id'); 
                  //idofi=num.substring(1);
          ajax_cajas_transfGlobal(Aux3[filaI3].pkConfigPermisos,idofglo.substring(1));
          
          });

            },
            error: function(xhr, textStatus, errorThrown) {
                        console.log(xhr.responseText);
                },
          });
        };
        /*
        $("#listaO").on("click",".filaOfGlo",function(){
          alert("click glo");
        });
    */


        //---------------------------------------------------------------


        $('#txtfecha').datetimepicker({
          locale: 'es',
          format: 'YYYY-MM-DD'
        });
        
        
        
        $("#listaCa").on("click",".filaCa",function(){
          $("#grupo_f").hide();
          var num = $(this).prop('id');
          filaI3 = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaCa');
          $(this).prop('class','filaCa warning');
          //insertando datos al modal
          $("#txtidCa").prop('value',Aux3[filaI3].c_id);
          $("#txtidCa2").prop('value',Aux3[filaI3].c_id);
          $("#txtnombreCa").prop('value',Aux3[filaI3].c_nombre);
          $("#txtencargadoCa").prop('value',Aux3[filaI3].p_nombre+' '+Aux3[filaI3].p_ap+' '+Aux3[filaI3].p_am);
        });
        
        $("#movF").click(function(){
           $("#grupo_f").show();
        });
        $("#movHoy").click(function(){
          $("#form_mov").submit();
        });
        $("#mov_fe").click(function(){
          $("#form_mov").submit();
        });
        $("#arqueoOfi").click(function(){
          $("#arqueo_oficina").submit();
        });
        
       
        
        ajax_saldo_oficinas();
        
        $("#btnRefrescar").click(function(){
          ajax_saldo_oficinas();
        });
        
        

        function ajax_cambiar_ofi(){
          $.ajax({
            data:{'ofiC':$("#ComboOficina").val()},
            url:'/cambiar_ofi_central_ajax/',
            type:'GET',
            dataType:'text',
            success: function(data){
              if(data=='exito'){
                $("#modalOficinaCentral").modal('hide');
                ajax_saldo_oficinas();

                bootbox.alert({ 
                  message: "Operación exitosa",
                  className: 'bb-alternate-modal'
                });
 
              }
              else{
                 bootbox.alert({ 
                  message: "La Operación fallo",
                  className: 'bb-alternate-modal'
                });

              }
            }
          });
        }

        $("#cambiarOfi").click(function(){
          ajax_cambiar_ofi();
        });

        $(document).on('show.bs.modal', '.modal', function () {
            var zIndex = 1040 + (10 * $('.modal:visible').length);
            $(this).css('z-index', zIndex);
            setTimeout(function() {
                $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
            }, 0);
        });
        $(document).on('hidden.bs.modal', '.modal', function () {
            $('.modal:visible').length && $(document.body).addClass('modal-open');
        });
      });
      //**********************************************************************
        $("#btnOficinasAr").click(function(){
          $.ajax({
            url:'/ver_saldo_oficinas_admin_ajax/',
            type:'GET',
            dataType:'json',
            success: function(data){
              Aux7 = data;
              var html ="";
              for(var i=0;i<data.length;i++){
                  html += '<tr data-toggle="modal" data-target="#myModal7" class="filaOfiA" id="'+i+'" ><th scope="row">'+(i+1)+'</th><td>'+data[i].of+'</td></tr>';

              }                        
              $('#listaR7').html(html);
            }
          });
        });
        $("#listaR7").on("click",".filaOfiA",function(){
          var num = $(this).prop('id');
          filaI4 = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaOfiA');
          $(this).prop('class','filaOfiA info');
          ajax_cajaAr(Aux7[filaI4].pk);
          //insertando datos en el modal
          //$("#txtidOfi").prop('value',Aux[filaI2].pk);
          $("#spOfi").text(Aux[filaI4].of);
          $("#spO").text(Aux[filaI4].of);
          $("#txtoficonfigArq").text(Aux[filaI4].of);
        });
        function ajax_cajaAr(idOf){
          $.ajax({
            url:'/CajasPersonalConfigArqueo_ajax/',
            data:{'idOfi':idOf,'idCa':$("#txtpkC").val()},
            type:'GET',
            dataType:'json',
            success: function(data){
              Aux8 = data;
              var html ="";
              var esta='';
              var sty ='';
              var tc='';

              for(var i=0;i<data.length;i++){
                tc='';
                if (data[i].tc =='p'){
                  tc='Propia';
                }
                if (data[i].tc =='c'){
                  tc='Compartida';
                }
                  html += '<tr data-toggle="modal" data-target="#ModalDetConficArq" class="filaCaAr" '+sty+' id="'+i+'"><td>'+data[i].c_nombre+'</td><td>'+data[i].p_nombre+' '+data[i].p_ap+' '+data[i].p_am+'</td><td>'+tc+'</td></tr>';
              }                        
              $('#listaCa7').html(html);
            }
          });
        };//end funcion ajax
        $("#listaCa7").on("click",".filaCaAr",function(){
          var num = $(this).prop('id');
          filaI41 = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaCaAr');
          $(this).prop('class','filaCaAr info');
          //insertando datos en el modal
          //$("#txtidOfi").prop('value',Aux[filaI2].pk);
          $("#txtca7").text(Aux8[filaI41].c_nombre);
          $("#spCa").text(Aux8[filaI41].c_nombre);
          $("#txtpkC7").prop('value',Aux8[filaI41].c_id);
          $("#txtpkConf7").prop('value',Aux8[filaI41].pkConf);
          if(Aux8[filaI41].tc=='p'){
            $("#rbPropia").prop("checked", true);
            $("#campoofic").hide();
          }
          else{
            $("#rbCompartida").prop("checked", true);
            $("#campoofic").show();
          }
          $("#po").prop('value',Aux8[filaI41].po);
          $("#pc").prop('value',Aux8[filaI41].pc);
          $("#pe").prop('value',Aux8[filaI41].pe);
          ajax_Comisiones();
        });
          $("input[name=tipocaja]").click(function(){
              if($(this).val()=="p"){
                  $("#campoofic").hide();
              }
              else{
                  $("#campoofic").show();
              }
          });
        $("#btnActprj").click(function(){
          ajax_guardarprj();
        });
        function ajax_guardarprj(){
          $.ajax({
            url:'/configurarPorcentajes_caja/',
            data:{'pkConf':$("#txtpkConf7").val(),'pkC1':$("#txtpkC7").val(),'tipo_caja':$('input:radio[name=tipocaja]:checked').val(),'po':$("#po").val(),'pc':$("#pc").val(),'pe':$("#pe").val()},
            type:'GET',
            dataType:'text',
            success: function(data){
             if(data=='exito'){
                $("#ActPrj").prop('class','bg-info');
                $("#ActPrj").text("Modificacion Exitosa");
                $("#ModalDetConficArq").modal('hide');
                ajax_cajaAr(Aux7[filaI4].pk);
             }
             else{
              $("#ActPrj").prop('class','bg-danger');
              $("#ActPrj").text("Error" + data);
              $("#ModalDetConficArq").modal('hide');
              ajax_cajaAr(Aux7[filaI4].pk);
             }
            }
          });
        };
         
        function limpiar_comi(){
          $("#txtmonmin").prop('value',null);
          $("#txtmonmax").prop('value',null);
          $("#txtComision").prop('value',null);
        }
        

        function ajax_guardarComiBaseOficina(idOficina){
          $.ajax({
            url:'/AgregarComisionBaseOficina_ajax/',
            data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idBase':$("#ComboBase").val(),'idOf':idOficina},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=='exito'){
                arrayOficinas.push(idOficina);
                //alert("long1 "+arrayOficinas.length);
                //$("#ActCo").prop('class','bg-info');
                //$("#ActCo").text("Operacion Exitosa");
                //$("#ModalAddComi").modal('hide'); 
                //limpiar_comi();
                //ajax_Comisiones();
             }
             else{
              bootbox.alert(data);
              ajax_oficinas_cajas();
              //$("#ActCo").prop('class','bg-danger');
              //$("#ActCo").text("Error" + data);
              //$("#ModalAddComi").modal('hide'); 
              //ajax_Comisiones();
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                      console.log(xhr.responseText);
              },
          });
        };


            function ajax_guardarComiBaseBase(idB){
          $.ajax({
            url:'/AgregarComisionBaseBase_ajax/',
            data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idBase1':$("#ComboBase").val(),'idBase2':idB},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=='exito'){
                arrayBases.push(idB);
                //alert("long bases"+arrayBases.length);
                //$("#ActCo").prop('class','bg-info');
                //$("#ActCo").text("Operacion Exitosa");
                //$("#ModalAddComi").modal('hide'); 
                //limpiar_comi();
                //ajax_Comisiones();
             }
             else{
              bootbox.alert(data);
              ajax_oficinas_cajas();
              //$("#ActCo").prop('class','bg-danger');
              //$("#ActCo").text("Error" + data);
              //$("#ModalAddComi").modal('hide'); 
              //ajax_Comisiones();
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                      console.log(xhr.responseText);
              },
          });
        };



         function ajax_guardarComiCajaBase(idB){
          $.ajax({
            url:'/AgregarComisionCajaBase_ajax/',
            data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idCa':$("#ComboCajaC").val(),'idBase':idB},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=='exito'){
                arrayBases.push(idB);
                //alert("lon bases"+arrayBases.length);
                //$("#ActCo").prop('class','bg-info');
                //$("#ActCo").text("Operacion Exitosa");
                //$("#ModalAddComi").modal('hide'); 
                //limpiar_comi();
                //ajax_Comisiones();
             }
             else{
              bootbox.alert(data);
              ajax_oficinas_cajas();
              //$("#ActCo").prop('class','bg-danger');
              //$("#ActCo").text("Error" + data);
              //$("#ModalAddComi").modal('hide'); 
              //ajax_Comisiones();
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                      console.log(xhr.responseText);
              },
          });
        };



        function ajax_guardarComi(idOficina){
          $.ajax({
            url:'/AgragarComision_ajax/',
            data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idCa':$("#ComboCajaC").val(),'idOf':idOficina},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);
             if(data=='exito'){
                arrayOficinas.push(idOficina);
                //alert("long oficinas"+arrayOficinas.length);
                //$("#ActCo").prop('class','bg-info');
                //$("#ActCo").text("Operacion Exitosa");
                //$("#ModalAddComi").modal('hide'); 
                //limpiar_comi();
                //ajax_Comisiones();
             }
             else{
              bootbox.alert(data);
              ajax_oficinas_cajas();
              //$("#ActCo").prop('class','bg-danger');
              //$("#ActCo").text("Error" + data);
              //$("#ModalAddComi").modal('hide'); 
              //ajax_Comisiones();
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                      console.log(xhr.responseText);
              },
          });
        };

           function ajax_oficinas_cajas_copiar(){
            $.ajax({
            url:'/ver_oficinas_cajas_copiar/',
            type:'GET',
            dataType:'json',
            success: function(data){
              console.log(data);
               var html_copy=""; 
              for(var i=0;i<data.length;i++){

                html_copy+='<li class="list-group-item">'
                                +'<div class="row">'
                                +'<div class="col-md-12">'
                                  +'<div class="col-md-4">'
                                    +'<div class="col-md-2">'
                                      +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse chbOfCopiar">'
                                        +'<input type="checkbox" id="'+data[i].pkO+'" class="chbo">'
                                      +'</div>'
                                    +'</div>'
                                    +'<div class="col-md-6 text-left" style="margin-top:4px">'
                                      +'<span>'+data[i].nombre_o+'</span>'
                                    +'</div>'
                                  +'</div>'
                                  +'<div class="col-md-4">'
                                    +'<select class="form-control" id="ComboCajaCopiar">';

                for(var k=0;k<data[i].listaCajas.length;k++){
                  html_copy+='<option value="'+data[i].listaCajas[k].pkC+'">'+data[i].listaCajas[k].nombre_c+'</option>';
                }
 
                html_copy+='</select>'
                          +'</div>'
                          +'<div class="col-md-4">' 
                html_copy+='<select class="form-control" id="ComboBaseCopiar">';

                for(var k=0;k<data[i].listaBases.length;k++){
                  html_copy+='<option value="'+data[i].listaBases[k].pkB+'">'+data[i].listaBases[k].nombre_b+'</option>';
                }

                html_copy+='</select>'; 
                html_copy+='</div>'
                        +'</div>'
                        +'</div>'
                      +'</li>';
                
              }
              $("#divConfigCopiar").html(html_copy);

              $("#ComboCajaCopiar").change(function(){
                 var idOf=$(this).closest('li').find('input.chbo').attr('id');
                 var idC=$(this).val();
                 var combo=$(this).closest('li').find('select#ComboBaseCopiar');
                 $.ajax({
                    url:'/CajasBases_ajax/',
                    data:{'idOfi':idOf,'idCa':idC},
                    type:'GET',
                    dataType:'json',
                    success: function(data){
                      console.log(data);
                      var html_base="";
                      combo.html("");
                      if (data.length>0){ 
                        for(var i=0;i<data.length;i++){
                          html_base += '<option value="'+data[i].b_id+'">'+data[i].b_nombre+'</option>';
                        }
                        combo.html(html_base);
                      }
                  
                    },
                    error: function(xhr, textStatus, errorThrown) {

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

              $(".chbOfCopiar").click(function(){ 
                  if ($(this).find('input[type="checkbox"]').is(':checked')) {
                      // no esta checkado
                      //alert('You have Checked it');
                  } else {
                      // si esta checkado
                      if($(this).closest('li').find('select#ComboBaseCopiar').val()==null || $(this).closest('li').find('select#ComboBaseCopiar').val()=='null'){
                         if(parseFloat($("#txtmonmin").val())>0 && parseFloat($("#txtmonmax").val())>0 && parseFloat($("#txtcomision").val())>0){
                        //alert($(this).closest('li').find('select#ComboBaseCopiar').val());
                              var idCaja=$(this).closest('li').find('select#ComboCajaCopiar').val();

                              //alert(arrayOficinas.length);
                              //alert(arrayBases.length);

                              if(arrayOficinas.length<=0 && arrayBases.length<=0){
                                bootbox.alert("No existe ninguna configuración para copiar");
                              }


                              if(arrayOficinas.length>0){
                                for(var i=0;i<arrayOficinas.length;i++){

                                    $.ajax({
                                      url:'/AgragarComision_ajax/',
                                      data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idCa':idCaja,'idOf':arrayOficinas[i]},
                                      type:'GET',
                                      dataType:'text',
                                      success: function(data){
                                        console.log(data);
                                       if(data=='exito'){
                                          bootbox.alert("Copiado correctamente");
                                       }
                                       else{
                                        bootbox.alert(data); 
                                       }
                                      },
                                      error: function(xhr, textStatus, errorThrown) {
                                                console.log(xhr.responseText);
                                        },
                                    }); 
                                } 
                              } 

                              if(arrayBases.length>0){
                                  for(var i=0;i<arrayBases.length;i++){
                                     $.ajax({
                                        url:'/AgregarComisionCajaBase_ajax/',
                                        data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idCa':idCaja,'idBase':arrayBases[i]},
                                        type:'GET',
                                        dataType:'text',
                                        success: function(data){
                                          console.log(data);
                                         if(data=='exito'){
                                            bootbox.alert("Copiado correctamente");
                                         }
                                         else{
                                          bootbox.alert(data);
                                         }
                                        },
                                        error: function(xhr, textStatus, errorThrown) {
                                                  console.log(xhr.responseText);
                                          },
                                      });
                                  }

                              }
                              arrayBases=[];
                            arrayOficinas=[];

                        }else{ 
                          bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        }
                      }else{

                        if(parseFloat($("#txtmonmin").val())>0 && parseFloat($("#txtmonmax").val())>0 && parseFloat($("#txtcomision").val())>0){
                        
                            var idBase=$(this).closest('li').find('select#ComboBaseCopiar').val();

                            if(arrayOficinas.length<=0 && arrayBases.length<=0){
                              bootbox.alert("No existe ninguna configuración para copiar");
                            }

                             //alert(arrayOficinas.length);
                             // alert(arrayBases.length);

                            if(arrayOficinas.length>0){
                              for(var i=0;i<arrayOficinas.length;i++){
                                    
                                     $.ajax({
                                        url:'/AgregarComisionBaseOficina_ajax/',
                                        data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idBase':$(this).closest('li').find('select#ComboBaseCopiar').val(),'idOf':arrayOficinas[i]},
                                        type:'GET',
                                        dataType:'text',
                                        success: function(data){
                                          console.log(data);
                                         if(data=='exito'){ 
                                            bootbox.alert("Copiado correctamente");
                                         }
                                         else{
                                            bootbox.alert(data); 
                                         }
                                        },
                                        error: function(xhr, textStatus, errorThrown) {
                                                  console.log(xhr.responseText);
                                          },
                                      });

                              } 
                            }

                            if(arrayBases.length>0){
                              for(var i=0;i<arrayBases.length;i++){
                                     $.ajax({
                                        url:'/AgregarComisionBaseBase_ajax/',
                                        data:{'montomin':$("#txtmonmin").val(),'montomax':$("#txtmonmax").val(),'comi':$("#txtcomision").val(),'idBase1':$(this).closest('li').find('select#ComboBaseCopiar').val(),'idBase2':arrayBases[i]},
                                        type:'GET',
                                        dataType:'text',
                                        success: function(data){
                                          console.log(data);
                                         if(data=='exito'){ 
                                          bootbox.alert("Copiado correctamente");
                                         }
                                         else{
                                          bootbox.alert(data); 
                                         }
                                        },
                                        error: function(xhr, textStatus, errorThrown) {
                                                  console.log(xhr.responseText);
                                          },
                                      });
                              }
                            }

                            arrayBases=[];
                            arrayOficinas=[];

                        }else{ 
                          bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        }
                        
                      }
                  }
              });
              

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

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

         function ajax_oficinas_cajas(){
            $.ajax({
            url:'/ver_oficinas_cajas/',
            type:'GET',
            data:{'pk':$("#ComboOficinaC").val()},
            dataType:'json',
            success: function(data){
              console.log(data);
              var html_collapse=""; 
              var html_collapse_copy="";

              for(var i=0;i<data.length;i++){
                html_collapse+='<div class="panel-heading">' 
                              +'<div class="row">' 
                              +'<div class="col-md-3">'
                                  +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse chbOf">'
                                    +  '<input type="checkbox" id="'+data[i].pkO+'" class="chbo">'
                                    +  '<span> '+data[i].nombre_o+' </span>'
                                  +'</div>' 
                              +'</div>'
                              +'<div class="col-md-4 col-md-offset-4" style="margin-top: 4px;">' 
                                +'<button data-toggle="modal" data-target="#modalComisionesGuardadas" type="button" '
                                +'class="btn btn-xs btn-danger verMO" id="'+data[i].pkO+'">Ver montos </button>'
                              +'</div>'
                              +'</div>'
                              +'</div>';


                /*html_collapse_copy+='<div class="panel-heading">' 
                              +'<div class="row">' 
                              +'<div class="col-md-4">'
                                  +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse chbOfC">'
                                    +  '<input type="checkbox" id="'+data[i].pkO+'" class="chbo">'
                                    +  '<span> '+data[i].nombre_o+' </span>'
                                  +'</div>' 
                              +'</div>'
                              +'</div>'
                              +'</div>';*/



                html_collapse+='<div class="panel-collapse collapse in" aria-expanded="true">'
                              +'<div class="panel-body">';

                 /*html_collapse_copy+='<div class="panel-collapse collapse in" aria-expanded="true">'
                              +'<div class="panel-body">';*/

                  for(var k=0;k<data[i].listaBases.length;k++){

                      html_collapse+='<li class="list-group-item done">'
                                      +'<div class="row">'
                                        +'<div class="col-md-2">'
                                          +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse chbBa">'
                                            +'<input type="checkbox" id="'+data[i].listaBases[k].pkB+'" class="chbo"></div>'
                                          +'</div>'
                                        +'<div class="col-md-6 text-left" style="margin-top:4px">' 
                                          +'<span>'+data[i].listaBases[k].nombre_b+'</span>'
                                        +'</div>'
                                        +'<div class="col-md-4" style="margin-top:4px">'
                                          +'<button data-toggle="modal" data-target="#modalComisionesGuardadas1" type="button" '
                                          +' class="btn btn-xs btn-success verMB" id="'+data[i].listaBases[k].pkB+'"> Ver montos ' 
                                          +'</button>' 
                                        +'</div>'
                                      +'</div>'
                                    +'</li>'; 

                      /*html_collapse_copy+='<li class="list-group-item done">'
                                      +'<div class="row">'
                                        +'<div class="col-md-2">'
                                          +'<div data-toggle="buttons" class="btn btn-checkbox-gray-inverse chbBaC">'
                                            +'<input type="checkbox" id="'+data[i].listaBases[k].pkB+'" class="chbo"></div>'
                                          +'</div>'
                                        +'<div class="col-md-6 text-left" style="margin-top:4px">' 
                                          +'<span>'+data[i].listaBases[k].nombre_b+'</span>'
                                        +'</div>'
                                      +'</div>'
                                    +'</li>'; */
                  }
                html_collapse+='</div></div>';
                //html_collapse_copy+='</div></div>';
              }

              $('#divConfig').html(html_collapse); 
              //$('#divConfigCopiar').html(html_collapse_copy); 
 

              /*$(".chbOfC").click(function(){
                alert("click1");
              });


              $(".chbBaC").click(function(){
                alert("click2");
              });*/

              $(".chbOf").click(function(){
                 if ($(this).find('input[type="checkbox"]').is(':checked')) {
                 }else{

                  if($("#ComboBase").val()==null || $("#ComboBase").val()=="null"){
                      var id=$(this).find("input").prop("id"); 
                      if(parseFloat($("#txtmonmin").prop('value'))>0 && parseFloat($("#txtmonmax").prop('value'))>0 && parseFloat($("#txtcomision").prop('value'))>0){
                        ajax_guardarComi(id);
                      }else{ 
                        bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        ajax_oficinas_cajas(); 
                      }
                  }else{
                      var id=$(this).find("input").prop("id"); 
                      if(parseFloat($("#txtmonmin").prop('value'))>0 && parseFloat($("#txtmonmax").prop('value'))>0 && parseFloat($("#txtcomision").prop('value'))>0){
                        ajax_guardarComiBaseOficina(id);
                      }else{ 
                        bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        ajax_oficinas_cajas(); 
                      }
                  }
                }
              });



              $(".chbBa").click(function(){
                 if ($(this).find('input[type="checkbox"]').is(':checked')) {
                 }else{
                  if($("#ComboBase").val()==null || $("#ComboBase").val()=="null"){
                      var id=$(this).find("input").prop("id"); 
                      if(parseFloat($("#txtmonmin").prop('value'))>0 && parseFloat($("#txtmonmax").prop('value'))>0 && parseFloat($("#txtcomision").prop('value'))>0){
                        ajax_guardarComiCajaBase(id);
                      }else{ 
                        bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        ajax_oficinas_cajas(); 
                      }
                  }else{
                      var id=$(this).find("input").prop("id"); 
                      if(parseFloat($("#txtmonmin").prop('value'))>0 && parseFloat($("#txtmonmax").prop('value'))>0 && parseFloat($("#txtcomision").prop('value'))>0){
                        ajax_guardarComiBaseBase(id);
                      }else{ 
                        bootbox.alert("Es necesario que ingrese el monto máximo, monto mínimo y la comisión");
                        ajax_oficinas_cajas(); 
                      }
                  }
                }
              });


              $(".verMO").click(function(){  
                  ajax_comisiones_guardadas($("#ComboCajaC").val(),$("#ComboBase").val(),$(this).prop("id")); 
              });

              $(".verMB").click(function(){ 
                  ajax_comisiones_guardadas_subbase($("#ComboCajaC").val(),$("#ComboBase").val(),$(this).prop("id")); 
              });
              


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

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


function ajax_actualizarComiBase(montomin,montomax,montocom,idConf,idC,idBO,idBD){ 
    $.ajax({
      url:'/ActualizarComisionBase_ajax/',
      data:{'montomin':montomin,'montomax':montomax,'comi':montocom,'pk':idConf},
      type:'GET',
      dataType:'text',
      success: function(data){
        console.log(data); 
        if(data=='exito'){
          ajax_comisiones_guardadas_subbase(idC,idBO,idBD);
        }
        else{
         bootbox.alert(data);  
       }
      },
      error: function(xhr, textStatus, errorThrown) {
            console.log(xhr.responseText);
      },
    });
  };  



function ajax_actualizarComi(montomin,montomax,montocom,idConf,idOf,idC,idB){ 
          $.ajax({
            url:'/AactualizarComision_ajax/',
            data:{'montomin':montomin,'montomax':montomax,'comi':montocom,'pk':idConf,'idOficina': idOf},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data); 
              if(data=='exito'){
                ajax_comisiones_guardadas(idC,idB,idOf);
              }
              else{
               bootbox.alert(data);  
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                  console.log(xhr.responseText);
            },
          });
        };  


        function ajax_eliminarComi(idConf,idOf,idC,idB){ 
          $.ajax({
            url:'/EliminarComision_ajax/',
            data:{'pk':idConf,'idOficina': idOf},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);  
              if(data=='exito'){
                ajax_comisiones_guardadas(idC,idB,idOf);
              }
              else{
               bootbox.alert(data);  
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                  console.log(xhr.responseText);
            },
          });
        }; 


         function ajax_eliminarComiBase(idConf,idC,idBO,idBD){ 
          $.ajax({
            url:'/EliminarComisionBases_ajax/',
            data:{'pk':idConf},
            type:'GET',
            dataType:'text',
            success: function(data){
              console.log(data);  
              if(data=='exito'){
                ajax_comisiones_guardadas_subbase(idC,idBO,idBD);
              }
              else{
               bootbox.alert(data);  
             }
            },
            error: function(xhr, textStatus, errorThrown) {
                  console.log(xhr.responseText);
            },
          });
        }; 



        function ajax_comisiones_guardadas_subbase(idCaja,idBaseO,idBaseD){
          $.ajax({
            url:'/ver_comisiones_guardadas_subbase/',
            data:{'idBaseO':idBaseO,'idCaja':idCaja,'idBaseD':idBaseD},
            type:'GET',
            dataType:'json',
            success: function(data){ 
              console.log(data);
              $("#listaComisionesGuardadas1").html("");
              html_c="";
              //listaComisionesGuardadas
              for(var i=0;i<data.length;i++){
                 html_c += '<tr><td><input class="clickedit montomin" value="'+data[i].montomin+'" type="text"/></td>'
                 +'<td><input class="clickedit montomax" value="'+data[i].montomax+'" type="text"/></td>'
                 +'<td><input class="clickedit comision" value="'+data[i].comision+'" type="text"/></td>'
                 +'<td style="white-space: nowrap">'
                 +'<button type="button" class="btn btn-xs editarCB btn-primary btn-icon-text" '
                 +'data-loading-text="Modificando..." data-value="'+data[i].pk+'">'+'<i class="fa fa-pencil"></i></button> '
                  +' <button type="button" class="btn btn-xs eliminarCB btn-danger btn-icon-text '+
                      'waves-effect" data-value="'+data[i].pk+'">'+'<i class="fa fa-times"></i></button></td></tr>';
              }
               $('.clickedit').numeric('.'); 

              $("#listaComisionesGuardadas1").html(html_c);

              $(".editarCB").click(function(){
                  $(this).button('loading');
                  var mmin=$(this).closest('tr').find("input.montomin").val();
                  var mmax=$(this).closest('tr').find("input.montomax").val();
                  var com=$(this).closest('tr').find("input.comision").val();
                  ajax_actualizarComiBase(mmin,mmax,com,$(this).attr('data-value'),idCaja,idBaseO,idBaseD);
              });

              $(".eliminarCB").click(function(){
                ajax_eliminarComiBase($(this).attr('data-value'),idCaja,idBaseO,idBaseD);
                //ajax_eliminarComi($(this).attr('data-value'),idOficinaC,idCaja);
              });

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

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



        function ajax_comisiones_guardadas(idCaja,idBase,idOficinaC){
          $.ajax({
            url:'/ver_comisiones_guardadas/',
            data:{'idOficina':idOficinaC,'idCaja':idCaja,'idBase':idBase},
            type:'GET',
            dataType:'json',
            success: function(data){ 
              console.log(data);
              html_c="";
              //listaComisionesGuardadas
              for(var i=0;i<data.length;i++){
                 html_c += '<tr><td><input class="clickedit montomin" value="'+data[i].montomin+'" type="text"/></td>'
                 +'<td><input class="clickedit montomax" value="'+data[i].montomax+'" type="text"/></td>'
                 +'<td><input class="clickedit comision" value="'+data[i].comision+'" type="text"/></td>'
                 +'<td style="white-space: nowrap">'
                 +'<button type="button" class="btn btn-xs editarC btn-primary btn-icon-text" '
                 +'data-loading-text="Modificando..." data-value="'+data[i].pk+'">'+'<i class="fa fa-pencil"></i></button> '
                  +' <button type="button" class="btn btn-xs eliminarC btn-danger btn-icon-text '+
                      'waves-effect" data-value="'+data[i].pk+'">'+'<i class="fa fa-times"></i></button></td></tr>';
              }
               $('.clickedit').numeric('.'); 

              $("#listaComisionesGuardadas").html(html_c);

              $(".editarC").click(function(){
                  $(this).button('loading');
                  var mmin=$(this).closest('tr').find("input.montomin").val();
                  var mmax=$(this).closest('tr').find("input.montomax").val();
                  var com=$(this).closest('tr').find("input.comision").val() 
                  ajax_actualizarComi(mmin,mmax,com,$(this).attr('data-value'),idOficinaC,idCaja,idBase);
              });

              $(".eliminarC").click(function(){
                ajax_eliminarComi($(this).attr('data-value'),idOficinaC,idCaja,idBase);
              });



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

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



        function ajax_Comisiones(){
           $('#listaComi').html('');
          $.ajax({
            url:'/Admin/listaComisiones_ajax/',
            data:{'idCa':$("#txtidCa").val(),'idCaDes':$("#txtpkC7").val()},
            type:'GET',
            dataType:'json',
            success: function(data){
              AuxCo = data;
              var html ="";
              for(var i=0;i<data.length;i++){
                  html += '<tr data-toggle="modal" data-target="#ModalUpdComi" class="filaCaCo" id="'+i+'"><td>'+data[i].montomin+'</td><td>'+data[i].montomax+'</td><td>'+data[i].comision+'</td></tr>';
              }                        
              $('#listaComi').html(html);
            }
          });
        };
        $("#listaComi").on("click",".filaCaCo",function(){
          $("#actmonmin").prop('value',null);
          $("#actmonmax").prop('value',null);
          $("#actComision").prop('value',null);
          $("#actpk").prop('value',null);
          var num = $(this).prop('id');
          filaCo = num;
          var fila= $(this).prop('class');
          $("."+fila).prop('class','filaCaCo');
          $(this).prop('class','filaCaCo info');
          $("#actmonmin").prop('value',AuxCo[filaCo].montomin);
          $("#actmonmax").prop('value',AuxCo[filaCo].montomax);
          $("#actComision").prop('value',AuxCo[filaCo].comision);
          $("#actpk").prop('value',AuxCo[filaCo].pk);
        });
        
        //************************************************
         function calcularPrjCom(){
          var po,pc,pe;
          if($("#po").val()==null || $("#po").val().toString().trim()==''){
            po=0;
          }
          else{
            po=parseFloat($("#po").val())
          }
          if($("#pc").val()==null || $("#pc").val().toString().trim()==''){
            pc=0;
          }
          else{
            pc=parseFloat($("#pc").val())
          }
          //------
          if ($("#rbPropia").prop("checked")){
            if(po>=100){
              swal("Error!", "La suma  no debe de superar el 100%", "error");
              $(this).prop('value',0);
            }
            else{
              pe=100-po
              $("#pe").prop('value',pe);
            }
          }
          if ($("#rbCompartida").prop("checked")){
            if(po+pc >=100){
              swal("Error!", "La suma  no debe de superar el 100%", "error");
              $(this).prop('value',0);
            }
            else{
              pe=100-(po+pc)
              $("#pe").prop('value',pe);
            }
          }
          
        }
        /*
        function calcularPrjPro(){
          var ppo,ppe;
          if($("#ppo").val()==null || $("#ppo").val().toString().trim()==''){
            ppo=0;
          }
          else{
            ppo=parseFloat($("#ppo").val())
          }
          //------
          if(ppo>=100){
            swal("Error!", "La suma  no debe de superar el 100%", "error");
            $(this).prop('value',0);
          }
          else{
            ppe=100-ppo
            $("#ppe").prop('value',ppe);
          }
        }*/
        $("#po").keyup(calcularPrjCom);
        $("#pc").keyup(calcularPrjCom);
     
    </script>
{% endblock content1 %}