HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/dev-telemedicina.teky.com.co/public/js/centers/centers.js
$(document).ready(function() {
  $("#example2").DataTable({
    paging: true,
    lengthChange: true,
    searching: true,
    ordering: true,
    info: true,
    autoWidth: true,
    language: {
      url: Lang.get('messages.datatable.url_language')
    },
    buttons: ["copyHtml5", "excelHtml5", "csvHtml5", "pdfHtml5"]
  });
});
/**Activar/Desactivar Hospitales usando switch*/
$(".chkcenter").change(function() {
  var estado;
  var id = $(this).attr("data-id");

  if (this.checked) {
    estado = 1;
  } else {
    estado = 0;
  }

  var info = {
    id: id,
    estado: estado
  };

  $.ajax({
    url: "/centers/active",
    type: "POST",
    contentType: "application/json",
    headers: {
      "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
      "Content-Type": "application/json"
    },
    data: JSON.stringify(info),
    success: function(r) {
      if (r[0]["respuesta"]) {
        swal("Ok", Lang.get('messages.centers.update_ok'));
      } else {
        swal("Ok", Lang.get('messages.centers.error_update'), "error");
      }
    }
  });
});

$('#country_id').change(function () {
  valor = $(this).val();
  if(!valor){
      $('#department_id').empty();
      $('#city_id').empty();
      return;
  }
  $('#modalLoader').modal('show');

  $.ajax({
      url: "/states/get/" + valor,
      type: "GET",
      contentType: 'application/json',
      headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
          'Content-Type': 'application/json'
      },
      success: function (r) {
          if (r[0]["respuesta"]) {
              $('#modalLoader').modal('hide');
              var states = r[0]["states"];

              $('#department_id').empty();
              var sel = '<option value="">' + Lang.get('messages.select') + '</option>';
              $('#department_id').append(sel);
              for (var i in states) {
                  var row = '<option value="' + states[i].id + '">' + states[i].name + '</option>';
                  $('#department_id').append(row);

              }
          } else {
              $('#department_id').empty();
              $('#city_id').empty();
          }
      },
      error: function(err){
          $('#modalLoader').modal('hide');
      }
  });
});

$("#department_id").change(function() {
  var department_id = $("#department_id").val();

  if (!department_id) {
    $("#city_id").empty();
    var sel = '<option value="">' + Lang.get('messages.centers.select') + '</option>';
    $("#city_id").append(sel);
    return;
  }

  $.ajax({
    url: "/city/get/" + department_id,
    type: "GET",
    contentType: "application/json",
    headers: {
      "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
      "Content-Type": "application/json"
    },
    success: function(res) {
      var cities = res[0]["cities"];

      $("#city_id").empty();
      var sel = '<option value="">' + Lang.get('messages.centers.select') + '</option>';
      $("#city_id").append(sel);
      for (var i in cities) {
        var row = '<option value="' + cities[i].id + '">' + cities[i].name + "</option>";
        $("#city_id").append(row);
      }

    }
  });
});