public function fetchExtraServices($params)
 {
     $this->extraServices = array();
     if (isset($params['extraServices'])) {
         $extraServices = $params['extraServices'];
         foreach ($extraServices as $serviceId => $quantity) {
             if ($quantity > 0) {
                 $extraService = ExtraService::fetchFromDb($serviceId);
                 if ($extraService != null) {
                     $extraServiceDetails = array();
                     $extraServiceDetails[0] = $extraService;
                     $extraServiceDetails[1] = $quantity;
                     $extraServiceDetails[2] = floatval($extraService) * intval($quantity);
                     $this->extraServices[] = $extraServiceDetails;
                 }
             }
         }
     }
 }
示例#2
0
    $logger->LogError("Session object could not be found ...");
    header("Location: booking-failure.php?error_code=9");
}
// Get booking details from session
$bookingDetails = unserialize($_SESSION['bookingDetails']);
// Get selected extra bed
if (isset($_POST['extraBed']) && is_numeric($_POST['extraBed']) && intval($_POST['extraBed']) > 0) {
    $logger->LogInfo("Extra bed was selected!");
    $bookingDetails->extraBedRequested = true;
}
// Get selected services
if (isset($_POST['extraServices'])) {
    $logger->LogInfo("Extra services were selected!");
    $bookingDetails->extraServices = array();
    foreach ($_POST['extraServices'] as $serviceId => $quantity) {
        $extraService = ExtraService::fetchFromDb(intval($serviceId));
        if ($extraService == null) {
            $logger->LogError("No extra service could be found for id: " . intval($serviceId));
            $_SESSION['errors'] = array(0 => BOOKING_FAILURE_INVALID_REQUEST);
            header("Location: booking-failure.php");
        }
        if (intval($quantity) > 0) {
            $logger->LogInfo("Extra service " . $extraService->getName($language_selected) . " selected for quantity: " . intval($quantity));
            $extraServiceDetails = array(0 => $extraService, 1 => $quantity, 2 => floatval($extraService->price * $quantity));
            $bookingDetails->extraServices[] = $extraServiceDetails;
        } else {
            $logger->LogWarn("Extra service has a quntity of 0. Skipping!");
        }
    }
}
// Calculate price details
include "../includes/SystemConfiguration.class.php";
global $logger;
$extraService = new ExtraService();
$errors = array();
// If we have id, then we are trying to edit
if (isset($_POST['SBMT_REG'])) {
    $extraService = ExtraService::fetchFromParameters($_POST);
    if (!$extraService->save()) {
        $errors = $extraService->errors;
    } else {
        header("Location: extra_services_list.php");
    }
} else {
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $id = $_GET['id'];
        $extraService = ExtraService::fetchFromDb($id);
        if ($extraService == null) {
            $logger->LogError("Invalid request. No extra service with id: {$id} exists.");
            $errors[] = "Invalid request. No extra service with id: {$id} exists.";
        }
    }
}
include "header.php";
?>



</td>
</tr>
<tr>
	<td valign="top" align="left" width="100%">