<footer class="main-footer">
  <strong>Copyright &copy; 2022 <a href="https://ydsystems.com.ve/" target="_blank">Ydsystems</a>.</strong>
  All rights reserved.
</footer>

<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
  <!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- jQuery -->
<script src="<?php echo $url_admin;?>plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="<?php echo $url_admin;?>plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Select2 -->
<script src="<?php echo $url_admin;?>plugins/select2/js/select2.full.min.js"></script>

<script src="<?php echo $url_admin;?>plugins/summernote/summernote-bs4.min.js"></script>

<script src="<?php echo $url_admin;?>plugins/bootstrap-switch/js/bootstrap-switch.min.js"></script>
<!-- AdminLTE App -->
<script src="<?php echo $url_admin;?>dist/js/adminlte.min.js"></script>

<!-- AdminLTE for demo purposes -->
<script src="<?php echo $url_admin;?>dist/js/demo.js"></script>
<!-- Page script -->
<script src="<?php echo $url_admin;?>plugins/datatables/jquery.dataTables.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/dataTables.responsive.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/dataTables.rowReorder.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- <script src="<?php echo $url_admin;?>plugins/chart.js/Chart.min.js"></script>
-->
<!-- Toastr -->
<script src="<?php echo $url_admin;?>plugins/toastr/toastr.min.js"></script>

<!-- date-range-picker -->
<script src="<?php echo $url_admin;?>plugins/moment/moment.min.js"></script>

<script src="<?php echo $url_admin;?>plugins/daterangepicker/daterangepicker.js"></script>

<script src="<?php echo $url_admin;?>plugins/inputmask/jquery.maskMoney.js"></script>

<?php if ($_SESSION['active'] === $url_admin.'reporte_transacciones/') {?>  

<script src="<?php echo $url_admin;?>plugins/datatables/dataTables.buttons.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/jszip.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/pdfmake.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/vfs_fonts.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/buttons.html5.min.js"></script>
<script src="<?php echo $url_admin;?>plugins/datatables/buttons.print.min.js"></script>
<?php } ?>


<script type="text/javascript">
  $(function () {

//Detalles de propiedad//
$(document).ready(function(e) {
  data = {'option':'<?php echo $decryp->encryptroute('view/home/view_avatar')?>'};
  $.post('<?php echo $url_admin;?>core/process.php', data)
  .done(function(resp){ 
    $.each(resp.datos, function (k, v) {
      $('#imagenmuestra_avatar').attr('src', '<?php echo $url_admin;?>dist/img/avatar/'+v.avatar+ '?' + Math.random());
      $( "#avatar_desc_"+v.avatar).prop( "checked", true );
    });
  }).fail( function(jqXHR, textStatus, errorThrown) {
   var resp=jqXHR.responseJSON;
   var status=jqXHR.status;
   if(status == 401){
    toastr.error(resp.msg);
    logout();
  }else{
   toastr.error(resp.msg);
 }
});
});

$(document).on('click', '#logout', function(e){
  data = {'option':'<?php echo $decryp->encryptroute('general/home/logout')?>'};
  $.post('<?php echo $url_admin;?>core/process.php', data)
  .done(function(resp){
    if(resp.status == "F"){
      toastr.error(resp.msg)
    }else{
      var url = window.location.href;
      var url2=window.location.pathname;
      var url = url.split(url2);
      window.location.href=url[0]+'<?php echo $url_admin;?>'+'login/';
    }
  });

});

$(document).on('click', '#clave_cambio1', function(e){
  submit('#clave_cambio1');
  var clave = $("#clave_cambio").val();
  if (typeof clave == 'undefined' || clave === null || clave === '') {  
   toastr.error('<?php echo $_SESSION['lang']['REQUERIDOS1']?>');
   finish('#clave_cambio1');
 } else {
  data = {'option':'<?php echo $decryp->encryptroute('general/home/cambio_clave')?>','clave':clave};
  $.post('<?php echo $url_admin;?>core/process.php', data)
  .done(function(resp){
   $('#clave_cambio_app').modal('hide'); 
   toastr.success(resp.msg);
 }).fail( function(jqXHR, textStatus, errorThrown) {
   var resp=jqXHR.responseJSON;
   var status=jqXHR.status;
   if(status == 401){
    toastr.error(resp.msg);
    logout();
  }else{
   toastr.error(resp.msg);
 }
}).always( function() {
  finish('#clave_cambio1');
});
}
});

//Funcion para registrar propiedades//
$(document).on('click', '#avatar_save', function(e){
  submit('#avatar_save');
  var name = $("input[name='avatar_desc']:checked").val();
  console.log(name);
  if (typeof name == 'undefined' || name === null || name === '') {  
   toastr.error('<?php echo $_SESSION['lang']['REQUERIDOS1']?>');
   finish('#avatar_save');
 }else {
  data = {'option':'<?php echo $decryp->encryptroute('add/home/avatar_change')?>','name':name};
  $.post('<?php echo $url_admin;?>core/process.php', data)
  .done(function(resp){
   $('#avatarimg').modal('hide'); 
   toastr.success(resp.msg);
   $('#imagenmuestra_avatar').attr('src', '<?php echo $url_admin;?>dist/img/avatar/'+name+ '?' + Math.random());
 }).fail( function(jqXHR, textStatus, errorThrown) {
   var resp=jqXHR.responseJSON;
   var status=jqXHR.status;
   if(status == 401){
    toastr.error(resp.msg);
    logout();
  }else{
   //$('#addcat').modal('hide'); 
   toastr.error(resp.msg);
 }
}).always( function() {
  finish('#avatar_save');
});
}
});

//Cierre de caja //

//Funcion abrir modal para eliminar cuenta// 
$(document).on('click', '#cierre_cajageneral', function(e){
  $('#cierre_caja_modal').modal('show'); 
});
//Funcion eliminar cuenta// 
$(document).on('click', '#cierre_caja_general', function(e){
  submit('#cierre_caja_general');
  data = {'option':'<?php echo $decryp->encryptroute('edit/home/close_cash_register')?>'};
  $.post('<?php echo $url_admin;?>core/process.php', data)
  .done(function(resp){
   toastr.success(resp.msg);
 }).fail( function(jqXHR, textStatus, errorThrown) {
   var resp=jqXHR.responseJSON;
   var status=jqXHR.status;
   if(status == 401){
    toastr.error(resp.msg);
    logout();
  }else{
   toastr.error(resp.msg); 
 }
}).always( function() {
  $('#cierre_caja_modal').modal('hide');
  finish('#cierre_cajageneral');
});

});


});

  function logout(){
    var url = window.location.href;
    var url2=window.location.pathname;
    var url = url.split(url2);
    window.location.href=url[0]+'<?php echo $url_admin;?>'+'login/';
  }
  var idioma="<?php echo $_SESSION['language_large'];?>";
  function submit(target){
    var title=$(target).html();
    $(target).html(title+"<div class='loader'><i class='fas fa-circle-notch' style='color:white;width:100%;'></i></div>");
    $(target).prop("disabled", true);
    var progreso = 0;
    var idIterval = setInterval(function(){
  // Aumento en 10 el progeso
  progreso +=1;
  $('#save_progress').css('width', progreso + '%');
  //Si llegó a 100 elimino el interval
  if(progreso == 100){
  progreso =0;
  $('#save_progress').css('width', 0 + '%');
  }
   },2000);
  }
  function finish(target){
    $(".loader").remove();
    var title=$(target).html();
    $(target).html(title);
    $(target).prop("disabled", false);
    $('#save_progress').css('width', 100 + '%');
  }
</script>
