Example #1
0
<?php

include 'models/database.php';
include 'models/employees.php';
if (isset($_GET['employee_id'])) {
    $employee_id = $_GET['employee_id'];
    $exists = EmployeeExistsByID($employee_id);
    if ($exists) {
        $res = DeleteEmployee($employee_id);
        if ($res) {
            header('Location: employees_view.php?success=true');
        } else {
            header('Location: employees_view.php?failed=true');
        }
    } else {
        header('Location: employees_view.php?missing=true');
    }
} else {
    header('Location: employees_view.php');
}
function DeleteCompanyRole($ID)
{
    $statusMessage = "";
    $result = 0;
    $record = RetrieveCompanyRoleByID($ID);
    if ($record != NULL) {
        $filter[EMP_COMPANY_ROLE] = $ID;
        $employees = RetrieveEmployees($filter);
        if ($employees != NULL) {
            foreach ($employees as $employee) {
                DeleteEmployee($employee[EMP_ID]);
            }
        }
        $sql = "DELETE FROM companyroletable WHERE companyRoleID=" . $ID . ";";
        $result = performSQL($sql);
        $statusMessage = "Role Deleted.</br>";
        GenerateStatus(true, $statusMessage);
    }
    return $result;
}
    if (isset($_POST["isAdministrator"])) {
        $isAdministrator = 1;
    }
    if (isset($_POST["isManager"])) {
        $isManager = 1;
    }
    $employee = CreateEmployee($_POST["empName"], $_POST["eMail"], $_POST["password"], $_POST["dateJoin"], $_POST["annualLeave"], NULL, $_POST["companyRole"], $isAdministrator, $isManager);
}
if (isset($_POST["amend"])) {
    ClearStatus();
    $url = "Location:editEmployee.php?ID=" . $_POST["amend"];
    header($url);
}
if (isset($_POST["delete"])) {
    ClearStatus();
    DeleteEmployee($_POST["delete"]);
}
function DisplayEmployeeTableBody()
{
    $employees = RetrieveEmployees();
    if ($employees != NULL) {
        foreach ($employees as $employee) {
            $role = RetrieveCompanyRoleByID($employee[EMP_COMPANY_ROLE]);
            echo "<tr>";
            echo "<td>" . $employee[EMP_ID] . "</td>";
            echo "<td>" . $employee[EMP_NAME] . "</td>";
            echo "<td>" . $employee[EMP_EMAIL] . "</td>";
            echo "<td>" . $employee[EMP_DATEJOINED] . "</td>";
            echo "<td>" . $employee[EMP_LEAVE_ENTITLEMENT] . "</td>";
            echo "<td>" . $role[COMP_ROLE_NAME] . "</td>";
            echo "<td>" . $employee[EMP_MAIN_VACATION_REQ_ID] . "</td>";