$location = new Location();
$doctors = $location->getDoctorsList();
if (isset($btnSubmit)) {
    if ($drpDoctor != 'noSelect') {
        //Location Object
        $location = new Location();
        //query to insert locations
        $result = $location->createLocation($txtLocationName, $drpLocationType, $txtReferenceName, $txtEmail, $txtPhone, $txtAddress, $txtCity, $drpProvince, $txtPostelCode, $drpDoctor);
        //insert session data only if location is created.
        if ($result) {
            $session = new Session();
            //loop through txtSessionDate array and set sessions if not null
            foreach ($txtSessionDate as $key => $date) {
                if ($date != null) {
                    //query to set session date
                    $sessionResult = $session->setSessionDateByLocation($result, $txtSessionDate[$key]);
                }
            }
            if (isset($sessionResult) && $sessionResult) {
                header('location: locationList.php');
            } elseif (!isset($sessionResult)) {
                header('location: locationList.php');
            }
        } elseif (!$result) {
            //error message from Location create expected
            $notifications['createError'] = "Sorry can not add this location. Check if this location already exist.";
        }
        unset($btnSubmit);
    } elseif ($drpDoctor === 'noSelect') {
        //error message from Location create expected
        $notifications['createError'] = "You forget to select Doctor. Please reset session dates.";
Example #2
0
$doctors = $location->getDoctorsList();
//get all scheduled dates for selected location
$session = new Session();
//Check for delete request
if ($Delete) {
    $session->deleteSessionBySessionId($SessionID);
}
//get All sessions for selected location
$sessions = $session->getSessionByLocationId($selectedLocation['location_id']);
//Update information on save
if (isset($btnSubmit)) {
    //create new sessions if any added first
    foreach ($txtSessionDate as $key => $date) {
        if ($date != null) {
            //query to set session date
            $result = $session->setSessionDateByLocation($btnSubmit, $txtSessionDate[$key]);
        }
    }
    //if there is session value and it is true then update location info
    if ($result && isset($result)) {
        // then query to update location by id
        $result = $location->updateLocationById($btnSubmit, $txtLocationName, $drpLocationType, $txtReferenceName, $txtEmail, $txtPhone, $txtAddress, $txtCity, $drpProvince, $txtPostelCode, $drpDoctor);
    } elseif (!isset($result)) {
        // then query to update location by id
        $result = $location->updateLocationById($btnSubmit, $txtLocationName, $drpLocationType, $txtReferenceName, $txtEmail, $txtPhone, $txtAddress, $txtCity, $drpProvince, $txtPostelCode, $drpDoctor);
    }
    //if result is true then redirect to location list with token true or error message.
    if (isset($result)) {
        //unset session variable
        unset($_SESSION['LocationID']);
        //redirect