HEX
Server: Apache
System: Linux vpshost11508.publiccloud.com.br 5.15.179-grsec-vpshost-10.lc.el8.x86_64 #1 SMP Mon Apr 7 12:04:45 -03 2025 x86_64
User: wicomm2 (10002)
PHP: 8.3.0
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: /home/storage/5/78/dd/wicomm2/public_html_backup/clientes/dashboard/scripts.js
document.addEventListener("DOMContentLoaded", () => {
    const baseUrl = "https://www.wicomm.com.br/clientes/dashboard/api.php";
  
    const showLoading = () => {
      document.getElementById("loading").style.display = "block";
    };
  
    const hideLoading = () => {
      document.getElementById("loading").style.display = "none";
    };
  
    const loadAccountData = (accountData) => {
      const container = document.getElementById("dashboard-container");
  
      // Cria uma seção para a conta
      const section = document.createElement("div");
      section.classList.add("account-section");
  
      section.innerHTML = `
        <h2>${accountData.account}</h2>
        <p><strong>Total de Transações:</strong> ${accountData.totalTransactions}</p>
        <p><strong>Faturamento Total:</strong> R$ ${parseFloat(accountData.totalRevenue).toLocaleString('pt-BR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</p>
        <p><strong>Meio de Pagamento Mais Utilizado:</strong> ${accountData.mostUsedPayment}</p>
        <canvas id="chart-${accountData.account}"></canvas>
        <h3>Campanhas</h3>
        <table>
          <thead>
            <tr>
              <th>Promoção</th>
              <th>Quantidade</th>
            </tr>
          </thead>
          <tbody>
            ${accountData.campaigns
              .map(
                (campaign) =>
                  `<tr><td>${campaign.promotion}</td><td>${campaign.count}</td></tr>`
              )
              .join("")}
          </tbody>
        </table>
      `;
  
      container.appendChild(section);
  
      // Renderiza o gráfico
      const ctx = section.querySelector(`#chart-${accountData.account}`).getContext("2d");
      new Chart(ctx, {
        type: "bar",
        data: {
          labels: accountData.chartData.labels,
          datasets: [
            {
              label: "Valor",
              data: accountData.chartData.values,
              borderWidth: 1,
            },
          ],
        },
        options: {
          responsive: true,
          scales: {
            y: { beginAtZero: true },
          },
        },
      });
    };
  
    const updateDashboard = (filters) => {
      showLoading(); // Mostra o loading
  
      fetch(
        `${baseUrl}?action=getData&filters=${encodeURIComponent(
          JSON.stringify(filters)
        )}`
      )
        .then((response) => response.json())
        .then((data) => {
          const container = document.getElementById("dashboard-container");
          container.innerHTML = ""; // Limpa o conteúdo existente
          data.forEach(loadAccountData);
        })
        .catch((err) => console.error("Erro ao carregar os dados:", err))
        .finally(() => {
          hideLoading(); // Esconde o loading
        });
    };
  
    document.querySelectorAll(".filters button").forEach((button) => {
      button.addEventListener("click", () => {
        const range = button.getAttribute("data-range");
        const filters = { range: parseInt(range) };
        updateDashboard(filters);
      });
    });
  
    document.getElementById("applyFilters").addEventListener("click", () => {
      const startDate = document.getElementById("startDate").value;
      const endDate = document.getElementById("endDate").value;
      const paymentMethod = document.getElementById("paymentFilter").value;
      const filters = { startDate, endDate, paymentMethod };
      updateDashboard(filters);
    });
  });