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/sigedo-qas.allup.com.co/resources/js/views/programmings.js
$(document).ready(function() {
  function getData() {
    var automaticprocess_id = document.getElementById("automaticprocess_id").value;
    var minutes = document.getElementById("minutes").value;
    var hour = document.getElementById("hour").value;
    var day = document.getElementById("day").value;
    var month = document.getElementById("month").value;
    var weekday = document.getElementById("weekday").value;
    var active = document.getElementById("active").value == "true" ? true : false;

    if (!automaticprocess_id || automaticprocess_id == 0) {
      Swal.fire({
        type: "error",
        title: "Oops...",
        text: Lang.get("fronjs.automaticprocess_required"),
      });
      return;
    }

    var str1 = "0";
    var str2 = "0";
    var str3 = "*";

    if (minutes != "") {
      str1 = minutes;
    }

    if (hour != "") {
      str2 = hour;
    }

    if (day != "") {
      str3 = day;
    }

    var cron = str1 + " " + str2 + " " + str3 + " " + month + " " + weekday;

    var data = {
      automaticprocess_id,
      cron,
      active,
    };

    return data;
  }

  $("#button_create").on("click", function(e) {
    e.preventDefault();
    if ((data = getData())) {
      Swal.fire({
        title: Lang.get("fronjs.title_create"),
        text: Lang.get("fronjs.text_create"),
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#3085d6",
        cancelButtonColor: "#d33",
        confirmButtonText: Lang.get("fronjs.yes"),
        cancelButtonText: Lang.get("fronjs.not"),
      }).then((result) => {
        if (result.value) {
          var laddaBtn = e.currentTarget;
          var ladda = Ladda.create(laddaBtn);
          ladda.start();
          $.ajax({
            url: "/programmings",
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            data: JSON.stringify(data),
            success: function(response) {
              if (response.status) {
                ladda.stop();
                Swal.fire({
                  type: response.type,
                  title: response.title,
                  text: response.message,
                  showConfirmButton: true,
                }).then((val) => {
                  $(location).attr("href", "/programmings");
                });
              } else {
                ladda.stop();
                Swal.fire({
                  type: response.type,
                  title: response.title,
                  text: response.message,
                });
              }
            },
          });
        }
      });
    }
  });

  $("#button_update").on("click", function(e) {
    e.preventDefault();
    var data = getData();
    if (data) {
      var programming_id = $("#form_edit").attr("programming_id");
      const newData = Object.assign({ _method: $("input[name=_method]").val() }, data);

      Swal.fire({
        title: Lang.get("fronjs.title_update"),
        text: Lang.get("fronjs.text_update"),
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#3085d6",
        cancelButtonColor: "#d33",
        confirmButtonText: Lang.get("fronjs.yes"),
        cancelButtonText: Lang.get("fronjs.not"),
      }).then((result) => {
        if (result.value) {
          var laddaBtn = e.currentTarget;
          var ladda = Ladda.create(laddaBtn);
          ladda.start();
          $.ajax({
            url: "/programmings/" + programming_id,
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            data: JSON.stringify(newData),
            success: function(response) {
              if (response.status) {
                ladda.stop();
                Swal.fire({
                  type: response.type,
                  title: response.title,
                  text: response.message,
                  showConfirmButton: true,
                }).then((val) => {
                  $(location).attr("href", "/programmings");
                });
              } else {
                ladda.stop();
                Swal.fire({
                  type: response.type,
                  title: response.title,
                  text: response.message,
                });
              }
            },
          });
        }
      });
    }
  });
});

window.deleteRegistry = function(programming_id) {
  var data = {
    _method: "DELETE",
  };

  Swal.fire({
    title: Lang.get("fronjs.title_delete"),
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#3085d6",
    cancelButtonColor: "#d33",
    confirmButtonText: Lang.get("fronjs.yes"),
    cancelButtonText: Lang.get("fronjs.not"),
    showLoaderOnConfirm: true,
    allowOutsideClick: false,
    allowEscapeKey: false,
    preConfirm: (login) => {
      return new Promise((resolve, reject) => {
        $.ajax({
          url: "/programmings/" + programming_id,
          type: "POST",
          dataType: "json",
          contentType: "application/json",
          data: JSON.stringify(data),
          success: function(response) {
            if (response.status) {
              Swal.fire({
                type: response.type,
                title: response.title,
                text: response.message,
                showConfirmButton: true,
              }).then((val) => {
                $(location).attr("href", "/programmings");
              });
            } else {
              Swal.fire({
                type: response.type,
                title: response.title,
                text: response.message,
              });
            }
          },
        });
      });
    },
  }).then((result) => {
    console.log(result);
  });
};