/**
  * @param IReservationApprovalPage $approvePage
  * @param UserSession $userSession
  * @return ReservationApprovalPresenter
  */
 public function Approve(IReservationApprovalPage $approvePage, UserSession $userSession)
 {
     $persistenceFactory = new ReservationPersistenceFactory();
     $approveAction = ReservationAction::Approve;
     $handler = ReservationHandler::Create($approveAction, $persistenceFactory->Create($approveAction), $userSession);
     $auth = new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization());
     return new ReservationApprovalPresenter($approvePage, $persistenceFactory->Create($approveAction), $handler, $auth, $userSession);
 }
Exemplo n.º 2
0
 /**
  * @static
  * @param $reservationAction string|ReservationAction
  * @param $persistenceService null|IReservationPersistenceService
  * @param UserSession $session
  * @return IReservationHandler
  */
 public static function Create($reservationAction, $persistenceService, UserSession $session)
 {
     if (!isset($persistenceService)) {
         $persistenceFactory = new ReservationPersistenceFactory();
         $persistenceService = $persistenceFactory->Create($reservationAction);
     }
     $validationFactory = new ReservationValidationFactory();
     $validationService = $validationFactory->Create($reservationAction, $session);
     $notificationFactory = new ReservationNotificationFactory();
     $notificationService = $notificationFactory->Create($reservationAction, $session);
     return new ReservationHandler($persistenceService, $validationService, $notificationService);
 }
Exemplo n.º 3
0
 public function PageLoad()
 {
     try {
         $reservationAction = ReservationAction::Approve;
         $factory = new ReservationPersistenceFactory();
         $persistenceService = $factory->Create($reservationAction);
         $handler = ReservationHandler::Create($reservationAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession());
         $auth = new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization());
         $presenter = new ReservationApprovalPresenter($this, $persistenceService, $handler, $auth, ServiceLocator::GetServer()->GetUserSession());
         $presenter->PageLoad();
     } catch (Exception $ex) {
         Log::Error('ReservationApprovalPage - Critical error saving reservation: %s', $ex);
         $this->Display('Ajax/reservation/reservation_error.tpl');
     }
 }
Exemplo n.º 4
0
// load resource by contact_info or rid
$resourceRepository = new ResourceRepository();
$contact_info = trim($_REQUEST['contact_info']);
$rid = trim($_REQUEST['rid']);
if ($contact_info && $rid) {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "You must not set both contact_info and rid"));
    return;
}
if ($contact_info) {
    $resource = $resourceRepository->LoadByContactInfo($contact_info);
} elseif ($rid) {
    $resource = $resourceRepository->LoadByPublicId($rid);
}
$updateAction = ReservationAction::Update;
$persistenceFactory = new ReservationPersistenceFactory();
$persistenceService = $persistenceFactory->Create($updateAction);
$handler = ReservationHandler::Create($updateAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession());
$reservationRepository = new ReservationRepository();
$series = $reservationRepository->LoadByReferenceNumber($params['rn']);
if (!$series) {
    header('HTTP/1.1 404 Not Found', true, 404);
    $response = array('reference_number' => $rn, 'message' => 'Reservation could not be found');
    print json_encode($response);
    return;
}
$series->ApplyChangesTo(SeriesUpdateScope::FullSeries);
if ($params['starts_at'] || $params['ends_at']) {
    if (!$params['starts_at']) {
        $params['starts_at'] = $series->CurrentInstance()->Duration()->GetBegin();
    }
Exemplo n.º 5
0
    $resource = $resourceRepository->LoadByPublicId($rid);
} else {
    header('HTTP/1.1 406 Not Acceptable', true, 406);
    print json_encode(array('message' => "contact_info or rid has to be set"));
    return;
}
/*************************************************
 	date
 *************************************************/
$timing = DateRange::Create($starts_at, $ends_at, $tz);
/*************************************************
 	Action
 *************************************************/
$series = ReservationSeries::Create($user->Id(), $resource, $title, $description, $timing, new RepeatNone(), $user_session);
$reservationAction = ReservationAction::Create;
$pfactory = new ReservationPersistenceFactory();
$persistenceService = $pfactory->Create($reservationAction);
$vfactory = new ReservationValidationFactory();
$validationService = $vfactory->Create($reservationAction, $user_session);
$nfactory = new ReservationNotificationFactory();
$notificationService = $nfactory->Create($reservationAction, $user_session);
#	$handler = new ReservationHandler($persistenceService, $validationService, $notificationService);
$validationResult = $validationService->Validate($series);
$result = $validationResult->CanBeSaved();
if ($result) {
    try {
        $persistenceResult = $persistenceService->Persist($series);
        header('HTTP/1.1 200 Ok', true, 200);
        $response = array('series_id' => $series->SeriesId(), 'reference_number' => $series->CurrentInstance()->ReferenceNumber(), 'requires_approval' => $resource->GetRequiresApproval());
        print json_encode($response);
        return;