[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: sales_report23.php
<?php include("../admin/includes/functions/functions.php");?> <?php include("../admin/db/db.php");?> <?php if(!isset($_SESSION['username_Xw211qAAsq4'])) { header('Location: ../auth/'); exit(); } else{ $pageTitle1 = 'Sales Report'; $shopname = $_SESSION['business_name_Xw211qAAsq4']; $currency = mysqli_query($new,"SELECT currency from barber_admin WHERE business_name = '$shopname'"); $fechC = mysqli_fetch_array($currency); $qurtyCurrency = $fechC['currency']; if(isset($_POST['god'])){ $fdate= test_input($_POST['fdate']); $tdate= test_input($_POST['tdate']); $newF = date("Y-m-d", strtotime($fdate)); $newT = date("Y-m-d", strtotime($tdate)); $newstm = $con->prepare("SELECT s.service_name,sum(sb.price) as price,a.discount as discount,a.comRate as percentage 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 a.created between '$newF' AND '$newT' a.business_name = '$shopname'"); } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title> <?php echo $shopname;?> || <?php echo $pageTitle1;?></title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- App favicon --> <link rel="shortcut icon" href="../assets/icon.png" type="image/x-icon"> <link rel="icon" href="../assets/icon.png" type="image/x-icon"> <script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script> <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <link href="plugins/daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css" /> <!-- App css --> <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <link href="assets/css/theme.min.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .table-hover tbody tr:hover td, .table-hover tbody tr:hover th { background-color: #e6ecff; } </style> <style> #preloader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; background-color: #fff; } #loader { display: block; position: absolute; top: 50%; left: 50%; border: 16px solid #f3f3f3; border-top: 16px solid #3498db; border-radius: 50%; width: 70px; height: 70px; animation: spin 2s linear infinite; } .table-hover tbody tr:hover td, .table-hover tbody tr:hover th { background-color: #e6ecff; } </style> <style type="text/css"> .order-card { color: #fff; } .bg-c-blue { background: linear-gradient(45deg,#4099ff,#73b4ff); } .bg-c-green { background: linear-gradient(45deg,#2ed8b6,#59e0c5); } .bg-c-yellow { background: linear-gradient(45deg,#FFB64D,#ffcb80); } .bg-c-pink { background: linear-gradient(45deg,#FF5370,#ff869a); } .card { border-radius: 5px; -webkit-box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16); box-shadow: 0 1px 2.94px 0.06px rgba(4,26,55,0.16); border: none; margin-bottom: 30px; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .card .card-block { padding: 25px; } .order-card i { font-size: 26px; } .f-left { float: left; } .f-right { float: right; } </style> </head> <body> <div id="preloader"> <div id="loader"></div> </div> <!-- Begin page --> <div id="layout-wrapper"> <div class="header-border"></div> <?php include("includes/template/head.php");?> <?php include("includes/template/side.php");?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <div class="row no-print"> <div class="col-md-4 col-xl-4"> <div class="card bg-c-blue order-card"> <div class="card-block"> <h6 class="m-b-20" style="color:#fff">Today Sales</h6> <h2 class="text-right"><span style="color:#fff"> <?php $tdate = date('Y-m-d'); $stmtServices = $con->prepare("SELECT s.service_name, sum(sb.price) as price, a.discount as discount, a.comRate as percentage, a.tip as tip from services s, true_price sb, appointments a where s.service_id = sb.service_id and sb.appointment_id = a.appointment_id AND a.created = ? and a.canceled = '0' and a.active = 'Yes' and a.business_name = ?"); $stmtServices->execute(array($tdate, $shopname)); $rowsServices = $stmtServices->fetchAll(); $gross1 = 0; // Initialize gross1 foreach($rowsServices as $rowsService) { if ($rowsService) { $tt2 = $rowsService['price']; // Calculate discount $dds = $rowsService['discount']; $Disc = ($dds / 100) * $tt2; $afterDis = $tt2 - $Disc; // Calculate commission $ComRaetPer = $rowsService['percentage']; $commission = ($ComRaetPer / 100) * $afterDis; // Add tip after commission $tip = $rowsService['tip'] ?? 0; // Use 0 if tip is null $finalAmount = ($afterDis - $commission); $gross1 += $finalAmount; } } echo $todayss = number_format($gross1, 2) . ' ' . $qurtyCurrency; ?> </span></h2> </div> </div> </div> <div class="col-md-4 col-xl-4"> <div class="card bg-c-green order-card"> <div class="card-block"> <h6 class="m-b-20" style="color:#fff">A Week Sales</h6> <h2 class="text-right"><span style="color:#fff"> <?php $pastdate = date("Y-m-d", strtotime("-1 week")); $crrntdte = date("Y-m-d"); $stmtServices = $con->prepare("SELECT s.service_name, sum(sb.price) as price, a.discount as discount, a.comRate as commission, a.tip as tip from services s, true_price sb, appointments a where s.service_id = sb.service_id and sb.appointment_id = a.appointment_id AND a.created between ? AND ? and a.canceled = '0' and a.active = 'Yes' and a.business_name = ?"); $stmtServices->execute(array($pastdate, $crrntdte, $shopname)); $rowsServices = $stmtServices->fetchAll(); $grosss = 0; // Initialize grosss foreach($rowsServices as $rowsService) { if ($rowsService) { $tt = $rowsService['price']; // Calculate discount $dds = $rowsService['discount']; $Disc = ($dds / 100) * $tt; $afterDis = $tt - $Disc; // Calculate commission $ComRaetPer = $rowsService['commission']; $commission = ($ComRaetPer / 100) * $afterDis; // Add tip after commission $tip = $rowsService['tip'] ?? 0; // Use 0 if tip is null $finalAmount = ($afterDis - $commission); $grosss += $finalAmount; } } echo $week = number_format($grosss, 2) . ' ' . $qurtyCurrency; ?> </span></h2> </div> </div> </div> <div class="col-md-4 col-xl-4"> <div class="card bg-c-yellow order-card"> <div class="card-block"> <h6 class="m-b-20" style="color:#fff">A Month Sales</h6> <h2 class="text-right"><span style="color:#fff"> <?php $monthdate = date("Y-m-d", strtotime("-1 month")); $crrntdte = date("Y-m-d"); $stmtServices = $con->prepare("SELECT s.service_name, sum(sb.price) as price, a.discount as discount, a.comRate as commission, a.tip as tip from services s, true_price sb, appointments a where s.service_id = sb.service_id and sb.appointment_id = a.appointment_id AND a.created between ? AND ? and a.canceled = '0' and a.active = 'Yes' and a.business_name = ?"); $stmtServices->execute(array($monthdate, $crrntdte, $shopname)); $rowsServices = $stmtServices->fetchAll(); $gross = 0; // Initialize gross foreach($rowsServices as $rowsService) { if ($rowsService) { $ttt = $rowsService['price']; // Calculate discount $dds = $rowsService['discount']; $Disc = ($dds / 100) * $ttt; $afterDis = $ttt - $Disc; // Calculate commission $Com = $rowsService['commission']; $commission = ($Com / 100) * $afterDis; // Add tip after commission $tip = $rowsService['tip'] ?? 0; // Use 0 if tip is null $finalAmount = ($afterDis - $commission); $gross += $finalAmount; } } echo $monthly = number_format($gross, 2) . ' ' . $qurtyCurrency; ?> </span></h2> </div> </div> </div> </div> <div class="row"> <div class="col-12"> <div class="card" style="border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1);"> <div class="card-body"> <style> /* Table Styling */ .sales-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-family: 'Arial', sans-serif; background-color: #fff; } .sales-table th, .sales-table td { padding: 12px 15px; text-align: left; border: 1px solid #e0e0e0; } .sales-table th { background-color: #4a90e2; color: white; font-weight: 600; text-transform: uppercase; font-size: 14px; } .sales-table td { font-size: 14px; color: #333; } .sales-table tr:nth-child(even) { background-color: #f8f9fa; } .sales-table tr:hover { background-color: #e9ecef; } .sales-table .total-row { background-color: #f1f3f5; font-weight: bold; } .sales-table .total-row td { border-top: 2px solid #4a90e2; } .sales-table small { font-size: 12px; color: #555; } .sales-table a { color: #4a90e2; text-decoration: none; } .sales-table a:hover { text-decoration: underline; } /* Card and Form Styling */ .card-body { padding: 20px; } .form-inline .col-md-4, .form-inline .col-md-2 { padding: 10px; } .form-control { border-radius: 5px; border: 1px solid #ced4da; padding: 8px; } .btn-primary { background-color: #4a90e2; border-color: #4a90e2; border-radius: 5px; padding: 8px 15px; font-weight: 500; } .btn-primary:hover { background-color: #357abd; border-color: #357abd; } .table-responsive { border-radius: 8px; overflow-x: auto; } h3 { color: #333; font-weight: 600; margin-bottom: 10px; } p { color: #555; font-size: 16px; } /* Responsive Adjustments */ @media (max-width: 768px) { .sales-table th, .sales-table td { font-size: 12px; padding: 8px; } .form-inline .col-md-4, .form-inline .col-md-2 { width: 100%; } } </style> <form method="POST" class="form-inline"> <div class="col-md-4"> <label>Search from this Date</label> <div class="form-group"> <input type="date" class="form-control date" name="fdate" style="width:100%"> </div> </div> <div class="col-md-4"> <label>To that Date</label> <div class="form-group"> <input type="date" class="form-control date" name="tdate" style="width:100%"> </div> </div> <div class="col-md-2"> <div class="md-form"> <label>Click to search</label> <button type="submit" name="god" class="btn btn-primary" style="width:100%">Search</button> </div> </div> </form> <div class="table-responsive"> <table class="sales-table"> <center><h3>Sales Report</h3> <p>From <b><?php echo $newF; ?></b> to <b><?php echo $newT; ?></b></p></center> <thead> <tr> <th style="width:20%">Booked Services</th> <th>Total</th> <th>Discount rate(%)</th> <th>Commission</th> <th>Income Net</th> <th>Info</th> </tr> </thead> <tbody> <?php $stmt = $con->prepare("SELECT a.*, c.* FROM appointments a, clients c WHERE a.client_id = c.client_id AND a.canceled = 0 and a.active = 'Yes' and a.created between ? and ? and a.business_name = ?"); $stmt->execute(array($newF, $newT, $shopname)); $rows = $stmt->fetchAll(); $totalDis = 0; // Initialize total discount $TotalCom = 0; // Initialize total commission $netTotal = 0; // Initialize net total $totalTip = 0; // Initialize total tip foreach($rows as $service) { ?> <tr> <td> <?php $stmtServices = $con->prepare("SELECT service_name, price from services s, true_price sb where s.service_id = sb.service_id and sb.appointment_id = ?"); $stmtServices->execute(array($service['appointment_id'])); $rowsServices = $stmtServices->fetchAll(); foreach($rowsServices as $rowsService) { echo "-".$rowsService['service_name'].'-'.number_format($rowsService['price'], 2); if (next($rowsServices)) echo "<br>"; } ?></td> <td><?php $stmtServices = $con->prepare("SELECT service_name, sum(sb.price) as price from services s, true_price sb where s.service_id = sb.service_id and sb.appointment_id = ?"); $stmtServices->execute(array($service['appointment_id'])); $rowsServices = $stmtServices->fetchAll(); foreach($rowsServices as $rowsService) { $tt = $rowsService['price']; $dds = $service['discount']; $Disc = ($dds / 100) * $tt; $afterDis = $tt - $Disc; $percentage1 = $service['comRate']; $commission = ($percentage1 / 100) * $afterDis; // Split commission among employees $employee_ids = explode(',', $service['employee_id']); // Split comma-separated employee IDs $employee_count = count($employee_ids); // Number of employees $shared_commission = $employee_count > 0 ? $commission / $employee_count : $commission; // Divide commission equally // Add tip after commission $tip = $service['tip'] ?? 0; // Use 0 if tip is null $grossw = ($afterDis - $commission); } $grossTotal = number_format($grossw, 2); echo $grossTotal; ?></td> <td class="py-0 px-1"> <small>Discount: <?php if (empty($service['discount'])) { echo '0.00%'; } else { echo $service['discount'].'%'; }?></small><br> <small>Disc Amt: <?php echo number_format($Disc, 2).' '.$qurtyCurrency; $totalDis += $Disc; ?></small><br> <b><small>After Disc: <?php echo number_format($afterDis, 2).' '.$qurtyCurrency; ?> </small></b> </td> <td class="py-0 px-1"> <small>Comm Rate: <?php echo $percentage1.'%';?></small><br> <small>Comm Amt: <?php echo number_format($commission, 2).' '.$qurtyCurrency; $TotalCom += $commission; ?></small><br> <small>Shared Comm: <?php echo number_format($shared_commission, 2).' '.$qurtyCurrency.''; ?></small><br> <small>Tip: <?php echo number_format($tip, 2).' '.$qurtyCurrency; $totalTip += $tip; ?></small> <br> <small>Total: <?php echo number_format($shared_commission + $tip, 2).' '.$qurtyCurrency; ?></small> </td> <td><?php echo $prof = number_format($grossw, 2).' '.$qurtyCurrency; $netTotal += $grossw; ?></td> <td class="py-0 px-1"> <small>Employees: <?php $employee_ids = explode(',', $service['employee_id']); // Split employee IDs $employee_names = []; foreach ($employee_ids as $emp_id) { $emp_id = trim($emp_id); // Remove any whitespace if (!empty($emp_id)) { $stmtEmployee = $con->prepare("SELECT first_name, last_name FROM employees WHERE employee_id = ?"); $stmtEmployee->execute(array($emp_id)); $employee = $stmtEmployee->fetch(); if ($employee) { $employee_names[] = '<a href="receipt?appid='.$service['appointment_id'].'">'.$employee['first_name'].' '.$employee['last_name'].'</a>'; } } } echo implode(', ', $employee_names); // Display all employee names ?></small><br> <small>Status Done?: <?php echo $service['active'];?></small><br> <small>Payment mode: <?php echo $service['payment_mode'];?></small> </td> </tr> <?php } ?> <tr class="total-row"> <th scope="row"></th> <th></th> <td>Total: <b><?php echo number_format($totalDis, 2);?></b></td> <td>Total : <b><?php echo number_format($TotalCom + $totalTip, 2);?></b></td> <td>Net : <b><?php echo number_format($netTotal, 2);?></b></td> <th>Info</th> </tr> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("includes/template/newfooter.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <!-- Overlay--> <div class="menu-overlay"></div> <?php include("includes/modals/ServicesModal.php");?> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/bootstrap.bundle.min.js"></script> <script src="assets/js/metismenu.min.js"></script> <script src="assets/js/waves.js"></script> <script src="assets/js/simplebar.min.js"></script> <script src="plugins/raphael/raphael.min.js"></script> <script src="assets/pages/dashboard-demo.js"></script> <script src="assets/js/theme.js"></script> <script src="plugins/autonumeric/autoNumeric-min.js"></script> <script src="plugins/bootstrap-datepicker/bootstrap-datepicker.min.js"></script> <script src="plugins/daterangepicker/daterangepicker.js"></script> <script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js"></script> <script src="plugins/moment/moment.js"></script> <script src="plugins/daterangepicker/daterangepicker.js"></script> <script src="plugins/select2/select2.min.js"></script> <script src="plugins/switchery/switchery.min.js"></script> <script src="plugins/bootstrap-colorpicker/bootstrap-colorpicker.min.js"></script> <script src="plugins/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js"></script> <!-- Custom Js --> <script src="assets/pages/advanced-plugins-demo.js"></script> <script src="assets/pages/datatables-demo.js"></script> <script type="text/javascript"> document.onreadystatechange = function() { if (document.readyState !== "complete") { document.querySelector("#preloader").style.display = "block"; } else { document.querySelector("#preloader").style.display = "none"; } }; </script> <!-- jQuery --> </body> </html>
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