[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: employee-schedule.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 = 'Employees Schedule'; $shopname = $_SESSION['business_name_Xw211qAAsq4']; $notificationType = "Employees Schedule"; echo "<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script>"; ?> <div id="layout-wrapper"> <div class="header-border"></div> <header id="page-topbar"> <?php include("includes/template/header.php");?> </header> <title><?php echo $shopname?> | <?php echo $pageTitle1;?></title> <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" /> <link rel="shortcut icon" href="../assets/icon.png" type="image/x-icon"> <link rel="icon" href="../assets/icon.png" type="image/x-icon"> <div class="vertical-menu"> <?php include("includes/template/sidebar.php");?> </div> <div class="main-content"> <div class="container-fluid"> <br /><br /> <!-- Page Heading --> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Employees Schedule</h1> </div> <div class="card shadow mb-4"> <div class="card-body"> <div class="sb-entity-selector" style="max-width:300px;"> <form action="employee-schedule.php" method="POST"> <div class="form-group"> <label class="control-label" for="emloyee_schedule_select"> Select employee to set up the schedule: </label> <div style="display:inline-block;margin-bottom: 10px;"> <?php $stmt = $con->prepare('select * from employees WHERE business_name = ?'); $stmt->execute(array($shopname)); $employees = $stmt->fetchAll(); echo "<select class='form-control' name='employee_selected'>"; foreach ($employees as $employee) { echo "<option value=".$employee['employee_id']." ".((isset($_POST['employee_selected']) && $_POST['employee_selected'] == $employee['employee_id'])?'selected':'').">".$employee['first_name']." ".$employee['last_name']."</option>"; } echo "</select>"; ?> </div> <button type="submit" name="show_schedule_sbmt" class="btn btn-primary">Show schedule</button> </div> </form> </div> <div class="alert alert-info"> Configure your week settings here. Just select start time and end time to set up employees working hours. </div> <!-- SECHEDULE PART --> <div class="sb-content" style="min-height: 500px;"> <?php /** WHEN SHOW SCHEDULE BUTTON CLICKED **/ if(isset($_POST['show_schedule_sbmt'])) { ?> <form method="POST" action="employee-schedule.php"> <input type="hidden" name="employee_id" value="<?php echo $_POST['employee_selected'];?>" hidden> <div class="worktime-days"> <?php $employee_id = $_POST['employee_selected']; $stmt = $con->prepare('select * from employees e, employees_schedule es where es.employee_id = e.employee_id and e.employee_id = ?'); $stmt->execute(array($employee_id)); $employees = $stmt->fetchAll(); $days = array("1"=>"Monday", "2"=>"Tuesday", "3"=>"Wednsday", "4"=>"Thursday", "5"=>"Friday", "6"=>"Saturday", "7"=>"Sunday") ; //Available days $av_days = array(); foreach($employees as $employee) { $av_days[] = $employee['day_id']; } foreach($days as $key => $value) { echo "<div class='worktime-day row'>"; if(in_array($key,$av_days)) { echo "<div class='form-group col-md-4'>"; echo "<input name='".$value."' id='".$key."' class='sb-worktime-day-switch' type='checkbox' checked>"; echo "<span class='day-name'>"; echo $value; echo "</span>"; echo "</div>"; foreach($employees as $employee) { if(in_array($key,$av_days) && $employee['day_id'] == $key) { echo "<div class='time_ col-md-8 row'>"; echo "<div class='form-group col-md-6'>"; echo "<input type='time' name='".$value."-from' value='".$employee['from_hour']."' class='form-control'>"; echo "</div>"; echo "<div class='form-group col-md-6'>"; echo "<input type='time' name='".$value."-to' value='".$employee['to_hour']."' class='form-control'>"; echo "</div>"; echo "</div>"; } } } else { echo "<div class='form-group col-md-4'>"; echo "<input name='".$value."' id='".$key."' class='sb-worktime-day-switch' type='checkbox'>"; echo "<span class='day-name'>"; echo $value; echo "</span>"; echo "</div>"; echo "<div class='time_ col-md-8 row' style='display:none;'>"; echo "<div class='form-group col-md-6'>"; echo "<input type='time' name='".$value."-from' value = '08:00' class='form-control'>"; echo "</div>"; echo "<div class='form-group col-md-6'>"; echo "<input type='time' name='".$value."-to' value = '9:00' class='form-control'>"; echo "</div>"; echo "</div>"; } echo "</div>"; } ?> </div> <!-- SAVE SCHEDULE BUTTON --> <div class="form-group"> <button type="submit" name="save_schedule_sbmt" class="btn btn-info">Save schedule</button> </div> </form> <?php } ?> </div> <?php /** WHEN SAVE SCHEDULE BUTTON CLICKED **/ if(isset($_POST['save_schedule_sbmt'])) { $days = array("1"=>"Monday", "2"=>"Tuesday", "3"=>"Wednsday", "4"=>"Thursday", "5"=>"Friday", "6"=>"Saturday", "7"=>"Sunday") ; $stmt = $con->prepare("delete from employees_schedule where employee_id = ?"); $stmt->execute(array($_POST['employee_id'])); foreach($days as $key=>$value) { if(isset($_POST[$value])) { $stmt = $con->prepare("insert into employees_schedule(employee_id,day_id,from_hour,to_hour,business_name) values(?, ?, ?,?,?)"); $stmt->execute(array($_POST['employee_id'],$key,$_POST[$value.'-from'],$_POST[$value.'-to'],$shopname)); $message = "You have successfully updated employee schedule!"; ?> <script type="text/javascript"> swal("Set Employee Schedule","You have successfully set the employee schedule!", "success").then((value) => {}); </script> <?php } } } ?> </div> </div> </div> </div> </div> </div> </div> </div> </div> <?php include("includes/template/footer.php");?> </div> </div> <div class="menu-overlay"></div> <script src="assets/js/theme.js"></script> <script src="https://code.jquery.com/jquery-3.5.1.js"></script> <script type="text/javascript"> $(".sb-worktime-day-switch").click(function() { if(!$(this).prop('checked')) { $(this).closest('div.worktime-day').children(".time_").css('display','none'); } else $(this).closest('div.worktime-day').children(".time_").css('display','flex'); }); </script> </body> </html> <?php }?>
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.72 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