📁 File Manager
Editing:
/home/wedigitalindia/public_html/demo.wedigitalindia.com/dcl-erp/attendance.php
<?php include_once("include/head.php"); ?> <div class="main-panel"> <div class="content-wrapper"> <div class="card"> <div class="card-body"> <div class="row"> <div class="col-md-3"> <h4 class="card-title">EMPLOYEE LIST</h4> </div> <div class="col-md-7"></div> <div class="col-md-2"> <button type="button" class="btn btn-primary btn-sm mb-2" data-toggle="modal" data-target="#attendanceModal">Mark Attendance</button> </div> </div> <div class="row"> <div class="col-12"> <div class="table-responsive"> <table id="order-listing" class="table"> <thead> <tr> <th>Employee Id</th> <th>Date</th> <th>Check In</th> <th>Check Out</th> <th>Status</th> <th>Actions</th> </tr> </thead> <tbody> <?php $sql = "SELECT * FROM attendance ORDER BY id DESC"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { echo '<tr> <td>EMP00' . $row['employee_id'] . '</td> <td>' . $row['date'] . '</td> <td>' . $row['check_in'] . '</td> <td>' . $row['check_out'] . '</td> <td>' . $row['status'] . '</td> <td> <button class="btn btn-outline-primary edit-btn" data-id="' . $row['id'] . '" data-toggle="modal" data-target="#editAttendanceModal">Edit</button> </td> </tr>'; } } else { echo '<tr><td colspan="6">No employees found</td></tr>'; } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> </div> <div class="modal fade" id="attendanceModal" tabindex="-1" role="dialog" aria-labelledby="attendanceModalLabel" aria-hidden="true"> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="attendanceModalLabel">Mark Attendance</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form id="addAttendanceForm" method="POST" action="process_attendance.php?action=add"> <div class="form-row"> <div class="col-md-12 mb-3"> <label for="employee_id">Employee</label> <select id="employee_id" class="form-control" name="employee_id" required> <option value="">Choose Employee</option> <?php $sql = "SELECT employee_id, first_name, last_name FROM employees"; $result = mysqli_query($conn, $sql); while ($row = mysqli_fetch_assoc($result)) { echo '<option value="' . $row['employee_id'] . '">' . $row['first_name'] . ' '. $row['last_name'] . '</option>'; } ?> </select> </div> <div class="col-md-6 mb-3"> <label for="date">Date</label> <input type="date" name="date" class="form-control" id="date"> </div> <div class="col-md-6 mb-3"> <label for="check_in">Check In Time</label> <input type="time" name="check_in" class="form-control" id="check_in"> </div> <div class="col-md-6 mb-3"> <label for="check_out">Check Out Time</label> <input type="time" name="check_out" class="form-control" id="check_out"> </div> <div class="col-md-6 mb-3"> <label for="status">status</label> <select id="status" class="form-control" name="status" required> <option value="">Choose status</option> <option value="present">Present</option> <option value="absent">Absent</option> <option value="onleave">On Leave</option> </select> </div> </div> <!--<input type="hidden" name="edit_id" value="">--> <div class="modal-footer"> <button type="submit" name="save_edit" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button> </div> </form> </div> </div> </div> </div> <!-- Edit Attendance Modal --> <div class="modal fade" id="editAttendanceModal" tabindex="-1" role="dialog" aria-labelledby="editAttendanceModalLabel" aria-hidden="true"> <div class="modal-dialog modal-md" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="editAttendanceModalLabel">Edit Attendance</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form id="editAttendanceForm" method="POST" action="process_attendance.php?action=edit"> <input type="hidden" name="att_id" id="edit_att_id"> <div class="form-row"> <div class="col-md-12 mb-3"> <label for="edit_employee_id">Employee</label> <select id="edit_employee_id" class="form-control" name="employee_id" required> <option value="">Choose Employee</option> <?php $sql = "SELECT employee_id, first_name, last_name FROM employees"; $result = mysqli_query($conn, $sql); while ($row = mysqli_fetch_assoc($result)) { echo '<option value="' . $row['employee_id'] . '">' . $row['first_name'] . ' ' . $row['last_name'] . '</option>'; } ?> </select> </div> <div class="col-md-6 mb-3"> <label for="edit_date">Date</label> <input type="date" name="date" class="form-control" id="edit_date"> </div> <div class="col-md-6 mb-3"> <label for="edit_check_in">Check In Time</label> <input type="time" name="check_in" class="form-control" id="edit_check_in"> </div> <div class="col-md-6 mb-3"> <label for="edit_check_out">Check Out Time</label> <input type="time" name="check_out" class="form-control" id="edit_check_out"> </div> <div class="col-md-6 mb-3"> <label for="edit_status">Status</label> <select id="edit_status" class="form-control" name="status" required> <option value="present">Present</option> <option value="absent">Absent</option> <option value="onleave">On Leave</option> </select> </div> </div> <div class="modal-footer"> <button type="submit" name="save_edit" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-light" data-dismiss="modal">Close</button> </div> </form> </div> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { const editButtons = document.querySelectorAll('.edit-btn'); editButtons.forEach(button => { button.addEventListener('click', function() { const id = this.getAttribute('data-id'); document.getElementById('edit_att_id').value = id; // Fetch data and populate the form fetch('fetch_employee_data.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ 'id': id }) }) .then(response => response.json()) .then(data => { if (data.error) { alert(data.error); } else { document.getElementById('edit_employee_id').value = data.employee_id; document.getElementById('edit_date').value = data.date; document.getElementById('edit_check_in').value = data.check_in; document.getElementById('edit_check_out').value = data.check_out; document.getElementById('edit_status').value = data.status; } }) .catch(error => console.error('Error:', error)); }); }); }); </script> <?php include_once("include/footer.php"); ?>
Save
Cancel