[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: comission_report.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 = 'Commssion 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']; $active = 1; $stmt1 = $con->prepare("SELECT rate FROM comm_rate WHERE business_name = ? and active = ?"); $stmt1->execute(array($shopname,$active)); $rows = $stmt1->fetchAll(); foreach($rows as $row) { $comRate1 = $row['rate']; if($comRate1 == 0){ $comRate = 0; } else { $comRate = $comRate1; } } } ?> <!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"> <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-3, .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; } h4 { color: #333; font-weight: 600; margin-bottom: 10px; } h5 { 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-3, .form-inline .col-md-2 { width: 100%; } } </style> <form method="POST" class="form-inline"> <div class="col-md-3"> <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-3"> <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-3"> <label>Employee</label> <div class="form-group"> <?php $stmt = $con->prepare("SELECT * FROM employees WHERE business_name = ?"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); ?> <select name="employee_id" class="form-control" style="width:100%"> <option value="">Select Employee</option> <?php foreach($rows_categories as $employee) { echo "<option value='".$employee['employee_id']."'>"; echo $employee['first_name'].' '.$employee['last_name']; echo "</option>"; } ?> </select> </div> </div> <div class="col-md-2"> <div class="md-form"> <label>Click to search</label> <button type="submit" name="emp" class="btn btn-primary" style="width:100%">Search</button> </div> </div> </form> <div class="table-responsive"> <table class="sales-table"> <center><h4>Commission Report</h4></center> <thead> <tr> <th style="width:28%">Services</th> <th>Total</th> <th style="width:15%">Discount rate(%)</th> <th>Commission</th> <th>Net Income</th> <th>Client Name</th> <th>Payment</th> </tr> </thead> <tbody> <?php if (isset($_POST['emp'])) { $fdate = test_input($_POST['fdate']); $tdate = test_input($_POST['tdate']); $employee_id = test_input($_POST['employee_id']); $newF = date("Y-m-d", strtotime($fdate)); $newto = date("Y-m-d", strtotime($tdate)); // Query appointments where the employee_id string contains the selected employee $stmt = $con->prepare("SELECT a.*, c.first_name AS cfname, c.last_name AS clname FROM appointments a JOIN clients c ON a.client_id = c.client_id WHERE a.canceled = 0 AND a.active = 'Yes' AND a.created BETWEEN ? AND ? AND a.business_name = ? AND FIND_IN_SET(?, a.employee_id)"); $stmt->execute(array($newF, $newto, $shopname, $employee_id)); $rows = $stmt->fetchAll(); $count = $stmt->rowCount(); $totalDis = 0; // Initialize total discount $totalCom = 0; // Initialize total commission $totalTip = 0; // Initialize total tip $proof = 0; // Initialize total net income 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>"; } echo "<br>-".date("Y-m-d", strtotime($service['date_created'])); ?> </td> <td> <?php $stmtServices = $con->prepare("SELECT service_name, SUM(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->fetch(); $tt = $rowsServices['price'] ?? 0; $dds = $service['discount'] ?? 0; $Disc = ($dds / 100) * $tt; $afterDis = $tt - $Disc; $percentage = $service['comRate'] ?? 0; $commission = ($percentage / 100) * $afterDis; // Split commission among employees $employee_ids = explode(',', $service['employee_id']); $employee_count = count($employee_ids); $shared_commission = $employee_count > 0 ? $commission / $employee_count : $commission; // Add tip after commission $tip = $service['tip'] ?? 0; $grossw = ($afterDis - $commission); echo number_format($tt, 2).' '.$qurtyCurrency; ?> </td> <td class="py-0 px-1"> <small>Discount: <?php echo empty($service['discount']) ? '0.00%' : $service['discount'].'%'; ?></small><br> <small>Disc Amt: <?php echo number_format($Disc, 2).' '.$qurtyCurrency; $totalDis += $Disc; ?></small><br> <small>After Disc: <?php echo number_format($afterDis, 2).' '.$qurtyCurrency; ?></small> </td> <td class="py-0 px-1"> <small>Comm Rate: <?php echo $percentage.'%';?></small><br> <small>Comm Amt: <?php echo number_format($shared_commission + $tip, 2).' '.$qurtyCurrency; $totalCom += $shared_commission; // Accumulate only this employee's share ?></small><br> <small>Tip: <?php echo number_format($tip, 2).' '.$qurtyCurrency; $totalTip += $tip; ?></small> </td> <td> <?php echo number_format($grossw, 2).' '.$qurtyCurrency; $proof += $grossw; ?> </td> <td> <?php echo $service['cfname'].' '.$service['clname']; ?> </td> <td> <?php echo $service['payment_mode']; ?> </td> </tr> <?php } ?> <tr class="total-row"> <th scope="row"></th> <td></td> <td>Total: <b><?php echo number_format($totalDis, 2);?></b></td> <td>Total : <b><?php echo number_format($totalCom + $totalTip, 2);?></b><br> <td>Total: <b><?php echo number_format($proof, 2);?></b></td> <td colspan="2"></td> </tr> <?php $stmt = $con->prepare("SELECT first_name, last_name FROM employees WHERE employee_id = ?"); $stmt->execute(array($employee_id)); $employee = $stmt->fetch(); $name = $employee ? $employee['first_name'].' '.$employee['last_name'] : 'Unknown'; ?> <tr> <td colspan="7"> <center> <h5>Employee Name: <?php echo $name; ?><br> Date: From <?php echo $newF; ?> To <?php echo $newto; ?></h5> </center> </td> </tr> <?php } ?> </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.06 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