function DeleteEmployee($ID) { $result = 0; $statusMessage = ""; $employee = RetrieveEmployeeByID($ID); if ($employee != NULL) { if ($employee[EMP_MAIN_VACATION_REQ_ID] != NULL) { DeleteMainVacatioNRequest($employee[EMP_MAIN_VACATION_REQ_ID]); } $filter[AD_HOC_EMP_ID] = $ID; $adHocAbsenceRequests = RetrieveAdHocAbsenceRequests($filter); foreach ((array) $adHocAbsenceRequests as $value) { DeleteAdHocAbsenceRequest($value[AD_HOC_REQ_ID]); } unset($filter); $filter[APPR_ABS_EMPLOYEE_ID] = $ID; $approvedAbsenceBookings = RetrieveApprovedAbsenceBookings($filter); if ($approvedAbsenceBookings != NULL) { foreach ($approvedAbsenceBookings as $value) { DeleteApprovedAbsenceBooking($value[APPR_ABS_BOOKING_ID]); } } $sql = "DELETE FROM employeeTable WHERE employeeID=" . $ID . ";"; $result = performSQL($sql); $statusMessage .= "Record deleted.</br>"; GenerateStatus(true, $statusMessage); } return $result; }
function DeleteDate($ID) { $result = 0; $date = RetrieveDateByID($ID); if ($date != NULL) { $filter[APPR_ABS_BOOK_DATE_DATE_ID] = $date[DATE_TABLE_DATE_ID]; $approvedAbsenceBookingDates = RetrieveApprovedAbsenceBookingDates($filter); if ($approvedAbsenceBookingDates != NULL) { foreach ($approvedAbsenceBookingDates as $value) { DeleteApprovedAbsenceBooking($value[APPR_ABS_BOOK_DATE_ABS_BOOK_ID]); } } if ($date[DATE_TABLE_PUBLIC_HOL_ID] != NULL) { DeletePublicHoliday($date[DATE_TABLE_PUBLIC_HOL_ID]); } $sql = "DELETE FROM dateTable WHERE dateID=" . $ID . ";"; $result = performSQL($sql); } return $result; }
<?php include 'sessionmanagement.php'; $request = array(); if ($_GET["ID"] != NULL) { $request = RetrieveApprovedAbsenceBookingByID($_GET["ID"]); } if (isset($_POST["cancel"])) { $url = "Location:adminApprovedAbsenceBookings.php"; header($url); } if (isset($_POST["update"])) { DeleteApprovedAbsenceBooking($_GET["ID"]); $success = CreateApprovedAbsenceBooking($_POST["employeeID"], $_POST["startDate"], $_POST["endDate"], $_POST["absenceType"]); if ($success) { $url = "Location:adminApprovedAbsenceBookings.php"; header($url); } } function GenerateEmployeeSelect($request) { $employees = RetrieveEmployees(); if ($employees != NULL) { echo '<select class="form-control" name="employeeID">'; foreach ($employees as $Employee) { if ($Employee[EMP_ID] == $request[APPR_ABS_EMPLOYEE_ID]) { echo '<option selected="selected" ' . 'value="' . $Employee[EMP_ID] . '">' . $Employee[EMP_NAME] . '</option>'; } else { echo '<option value="' . $Employee[EMP_ID] . '">' . $Employee[EMP_NAME] . '</option>'; } }
if (isset($_POST["employeeID"])) { $employeeID = $_POST["employeeID"]; } $booking = CreateApprovedAbsenceBooking($employeeID, $_POST["startDate"], $_POST["endDate"], $_POST["absenceType"]); } // If user has clicked the amend button, redirect them to the edit approvced // booking page, using a GET parameter with the ID of the record to edit. if (isset($_POST["amend"])) { ClearStatus(); $url = "Location:editApprovedAbsenceBooking.php?ID=" . $_POST["amend"]; header($url); } // If user has clicked the delete button, delete the record from the table. if (isset($_POST["delete"])) { ClearStatus(); DeleteApprovedAbsenceBooking($_POST["delete"]); } //----------------------------------------------------------------------------- // This function will generate the HTML necessary for the employee select // drop down HTML element //----------------------------------------------------------------------------- function CreateEmployeeSelect() { echo '<select class="form-control" name="employeeID" id="employeeID" >'; echo '<option value="" disabled selected>Select Employee</option>'; $employees = RetrieveEmployees(); if ($employees != NULL) { foreach ($employees as $employee) { echo '<option value="' . $employee[EMP_ID] . '">' . $employee[EMP_NAME] . '</option>'; } }