function RetrieveMainVacationRequests($filter = NULL)
{
    $inputIsValid = TRUE;
    //-------------------------------------------------------------------------
    // Validate Input parameters
    //-------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, MAIN_VACATION_REQ_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid MAIN_VACATION_REQ_ID of " . $value . " passed to RetrieveMainVacationRequests.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, MAIN_VACATION_EMP_ID) == 0) {
                    if (!is_numeric($value)) {
                        error_log("Invalid MAIN_VACATION_EMP_ID of " . $value . " passed to RetrieveMainVacationRequests.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, MAIN_VACATION_1ST_START) == 0) {
                        if (!isValidDate($value)) {
                            error_log("Invalid MAIN_VACATION_1ST_START of " . $value . " passed to RetrieveMainVacationRequests.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        if (strcmp($key, MAIN_VACATION_1ST_END) == 0) {
                            if (!isValidDate($value)) {
                                error_log("Invalid MAIN_VACATION_1ST_END of " . $value . " passed to RetrieveMainVacationRequests.");
                                $inputIsValid = FALSE;
                            }
                        } else {
                            if (strcmp($key, MAIN_VACATION_2ND_START) == 0) {
                                if (!isValidDate($value)) {
                                    error_log("Invalid MAIN_VACATION_2ND_START of " . $value . " passed to RetrieveMainVacationRequests.");
                                    $inputIsValid = FALSE;
                                }
                            } else {
                                if (strcmp($key, MAIN_VACATION_2ND_END) == 0) {
                                    if (!isValidDate($value)) {
                                        error_log("Invalid MAIN_VACATION_2ND_END of " . $value . " passed to RetrieveMainVacationRequests.");
                                        $inputIsValid = FALSE;
                                    }
                                } else {
                                    error_log("Unknown Filter " . $key . " passed to RetrieveMainVacationRequests.");
                                    $inputIsValid = FALSE;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //-------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters
    // are ok.
    //-------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(MAIN_VACATION_REQUEST_TABLE, $filter);
    }
    return $result;
}
function RetrievePublicHolidays($filter = NULL)
{
    $inputIsValid = TRUE;
    //-------------------------------------------------------------------------
    // Validate Input parameters
    //-------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, PUB_HOL_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid PUB_HOL_ID of " . $value . " passed to RetrievePublicHolidays.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, PUB_HOL_NAME) == 0) {
                    if (isNullOrEmptyString($value)) {
                        error_log("Invalid PUB_HOL_NAME passed to " . "RetrievePublicHolidays.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, PUB_HOL_DATE_ID) == 0) {
                        if (!is_numeric($value)) {
                            error_log("Invalid PUB_HOL_DATE_ID of " . $value . " passed toRetrievePublicHolidays.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        error_log("Unknown Filter " . $key . " passed to " . "RetrievePublicHolidays.");
                        $inputIsValid = FALSE;
                    }
                }
            }
        }
    }
    //-------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters
    // are ok.
    //-------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(PUBLIC_HOLIDAY_TABLE, $filter);
    }
    return $result;
}
function RetrieveEmployees($filter = NULL)
{
    $inputIsValid = TRUE;
    //-------------------------------------------------------------------------
    // Validate Input parameters
    //-------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, EMP_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid EMP_ID of " . $value . " passed to RetrieveEmployees.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, EMP_NAME) == 0) {
                    if (isNullOrEmptyString($value)) {
                        error_log("Invalid EMP_NAME passed to RetrieveEmployees.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, EMP_EMAIL) == 0) {
                        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                            error_log("Invalid EMP_EMAIL of " . $value . " passed to RetrieveEmployees.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        if (strcmp($key, EMP_PASSWORD) == 0) {
                            if (isNullOrEmptyString($value)) {
                                error_log("Invalid EMP_PASSWORD passed to RetrieveEmployees.");
                                $inputIsValid = FALSE;
                            }
                        } else {
                            if (strcmp($key, EMP_DATEJOINED) == 0) {
                                if (!isValidDate($value)) {
                                    error_log("Invalid EMP_DATEJOINED of " . $value . " passed to RetrieveEmployees.");
                                    $inputIsValid = FALSE;
                                }
                            } else {
                                if (strcmp($key, EMP_LEAVE_ENTITLEMENT) == 0) {
                                    if (!is_numeric($value)) {
                                        error_log("Invalid EMP_LEAVE_ENTITLEMENT of " . $value . " passed to RetrieveEmployees.");
                                        $inputIsValid = FALSE;
                                    }
                                } else {
                                    if (strcmp($key, EMP_MAIN_VACATION_REQ_ID) == 0) {
                                        if (!is_numeric($value)) {
                                            error_log("Invalid EMP_MAIN_VACATION_REQ_ID of " . $value . " passed to RetrieveEmployees.");
                                            $inputIsValid = FALSE;
                                        }
                                    } else {
                                        if (strcmp($key, EMP_COMPANY_ROLE) == 0) {
                                            if (!is_numeric($value)) {
                                                error_log("Invalid EMP_COMPANY_ROLE of " . $value . " passed to RetrieveEmployees.");
                                                $inputIsValid = FALSE;
                                            }
                                        } else {
                                            error_log("Unknown Filter " . $key . " passed to RetrieveEmployees.");
                                            $inputIsValid = FALSE;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //--------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters
    // are ok.
    //--------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(EMPLOYEE_TABLE, $filter);
    }
    return $result;
}
function RetrieveCompanyRoles($filter = NULL)
{
    $inputIsValid = TRUE;
    //--------------------------------------------------------------------------------
    // Validate Input parameters
    //--------------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, COMP_ROLE_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid COMP_ROLE_ID of " . $value . " passed to RetrieveCompanyRoles.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, COMP_ROLE_NAME) == 0) {
                    if (isNullOrEmptyString($value)) {
                        error_log("Invalid COMP_ROLE_NAME of " . $value . " passed to RetrieveCompanyRoles.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, COMP_ROLE_MIN_STAFF) == 0) {
                        if (!is_numeric($value)) {
                            error_log("Invalid COMP_ROLE_MIN_STAFF of " . $value . " passed to RetrieveCompanyRoles.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        error_log("Unknown Filter " . $key . " passed to RetrieveCompanyRoles.");
                        $inputIsValid = FALSE;
                    }
                }
            }
        }
    }
    //--------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters are
    // ok.
    //--------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(COMPANY_ROLE_TABLE, $filter);
    }
    return $result;
}
function RetrieveApprovedAbsenceBookings($filter = NULL)
{
    $inputIsValid = TRUE;
    //--------------------------------------------------------------------------------
    // Validate Input parameters
    //--------------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, APPR_ABS_BOOKING_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid APPR_ABS_BOOKING_ID of " . $value . " passed to RetrieveApprovedAbsenceBookings.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, APPR_ABS_EMPLOYEE_ID) == 0) {
                    if (!is_numeric($value)) {
                        error_log("Invalid APPR_ABS_EMPLOYEE_ID of " . $value . " passed to RetrieveApprovedAbsenceBookings.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, APPR_ABS_START_DATE) == 0) {
                        if (!isValidDate($value)) {
                            error_log("Invalid APPR_ABS_START_DATE of " . $value . " passed to RetrieveApprovedAbsenceBookings.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        if (strcmp($key, APPR_ABS_END_DATE) == 0) {
                            if (!isValidDate($value)) {
                                error_log("Invalid APPR_ABS_END_DATE of " . $value . " passed to RetrieveApprovedAbsenceBookings.");
                                $inputIsValid = FALSE;
                            }
                        } else {
                            if (strcmp($key, APPR_ABS_ABS_TYPE_ID) == 0) {
                                if (!is_numeric($value)) {
                                    error_log("Invalid APPR_ABS_ABS_TYPE_ID of " . $value . " passed to RetrieveApprovedAbsenceBookings.");
                                    $inputIsValid = FALSE;
                                }
                            } else {
                                error_log("Unknown Filter " . $key . " passed to " . "RetrieveApprovedAbsenceBookings.");
                                $inputIsValid = FALSE;
                            }
                        }
                    }
                }
            }
        }
    }
    //--------------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters are ok.
    //--------------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(APPROVED_ABSENCE_BOOKING_TABLE, $filter);
    }
    return $result;
}
function RetrieveAdHocAbsenceRequests($filter = NULL)
{
    $inputIsValid = TRUE;
    //--------------------------------------------------------------------------
    // Validate Input parameters
    //--------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, AD_HOC_REQ_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid AdHocRequestID of " . $value . " passed to RetrieveAdHocAbsenceRequests.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, AD_HOC_EMP_ID) == 0) {
                    if (!is_numeric($value)) {
                        error_log("InvalidAD_HOC_EMP_ID of " . $value . " passed to RetrieveAdHocAbsenceRequests.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, AD_HOC_START) == 0) {
                        if (!isValidDate($value)) {
                            error_log("Invalid AD_HOC_START of " . $value . " passed to RetrieveAdHocAbsenceRequests.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        if (strcmp($key, AD_HOC_END) == 0) {
                            if (!isValidDate($value)) {
                                error_log("Invalid AD_HOC_END of " . $value . " passed to RetrieveAdHocAbsenceRequests.");
                                $inputIsValid = FALSE;
                            }
                        } else {
                            if (strcmp($key, AD_HOC_ABSENCE_TYPE_ID) == 0) {
                                if (!is_numeric($value)) {
                                    error_log("Invalid AD_HOC_ABSENCE_TYPE_ID of " . $value . " passed to RetrieveAdHocAbsenceRequests.");
                                    $inputIsValid = FALSE;
                                }
                            } else {
                                error_log("Unknown Filter " . $key . " passed to " . "RetrieveAdHocAbsenceRequests.");
                                $inputIsValid = FALSE;
                            }
                        }
                    }
                }
            }
        }
    }
    //-------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters
    // are ok.
    //------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(ADHOC_ABSENCE_REQUEST_TABLE, $filter);
    }
    return $result;
}
function RetrieveDates($filter = NULL)
{
    $inputIsValid = TRUE;
    //--------------------------------------------------------------------------------
    // Validate Input parameters
    //--------------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, DATE_TABLE_DATE_ID) == 0) {
                if (!is_numeric($value)) {
                    printCallStackAndDie();
                    error_log("Invalid DATE_TABLE_DATE_ID of " . $value . " passed to RetrieveDates.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, DATE_TABLE_DATE) == 0) {
                    if (!isValidDate($value)) {
                        error_log("Invalid DATE_TABLE_DATE of " . $value . " passed to RetrieveDates.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, DATE_TABLE_PUBLIC_HOL_ID) == 0) {
                        if (!is_numeric($value)) {
                            error_log("Invalid DATE_TABLE_PUBLIC_HOL_ID of " . $value . " passed to RetrieveDates.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        error_log("Unknown Filter " . $key . " passed to RetrieveDates.");
                        $inputIsValid = FALSE;
                    }
                }
            }
        }
    }
    //--------------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters are ok.
    //--------------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(DATE_TABLE, $filter);
    }
    return $result;
}
function RetrieveAbsenceTypes($filter = NULL)
{
    $inputIsValid = TRUE;
    //-------------------------------------------------------------------------
    // Validate Input parameters
    //-------------------------------------------------------------------------
    if ($filter != NULL) {
        foreach ($filter as $key => $value) {
            if (strcmp($key, ABS_TYPE_ID) == 0) {
                if (!is_numeric($value)) {
                    error_log("Invalid AbsenceTypeID of " . $value . " passed to RetrieveAbsenceTypes.");
                    $inputIsValid = FALSE;
                }
            } else {
                if (strcmp($key, ABS_TYPE_NAME) == 0) {
                    if (isNullOrEmptyString($value)) {
                        error_log("Invalid ABS_TYPE_NAME passed to RetrieveAbsenceTypes.");
                        $inputIsValid = FALSE;
                    }
                } else {
                    if (strcmp($key, ABS_TYPE_USES_LEAVE) == 0) {
                        if ($value != 0 and $value != 1) {
                            error_log("Invalid ABS_TYPE_USES_LEAVE of " . $value . " passed to RetrieveAbsenceTypes.");
                            $inputIsValid = FALSE;
                        }
                    } else {
                        if (strcmp($key, ABS_TYPE_CAN_BE_DENIED) == 0) {
                            if ($value != 0 and $value != 1) {
                                error_log("Invalid ABS_TYPE_CAN BE DENIED of " . $value . " passed to RetrieveAbsenceTypes.");
                                $inputIsValid = FALSE;
                            }
                        } else {
                            error_log("Unknown Filter " . $key . " passed to RetrieveAbsenceTypes.");
                            $inputIsValid = FALSE;
                        }
                    }
                }
            }
        }
    }
    //-------------------------------------------------------------------------
    // Only attempt to perform query in the database if the input parameters
    // are ok.
    //-------------------------------------------------------------------------
    $result = NULL;
    if ($inputIsValid) {
        $result = performSQLSelect(ABSENCE_TYPE_TABLE, $filter);
    }
    return $result;
}