public function resetlistcriteriaAction() { $criteria = new RM_Unit_Search_Criteria($data); $criteria->publishedOnly = true; RM_Reservation_Manager::getInstance()->resetCriteria()->setCriteria($criteria); $this->_redirect('Unit', 'list'); }
public function successAction() { if (RM_Reservation_Manager::getInstance()->getPaymentStatus() !== RM_Payments_Status::TRANSACTION_END_SUCCESSFULLY) { $this->_redirect('Reservations', 'notcomplete'); } $this->_redirect('Reservations', 'success'); }
function treeJsonAction() { $iso = $this->_translate->getAdapter()->getLocale(); $selectedCategoriesIDs = RM_Reservation_Manager::getInstance()->getCriteria()->categories; if (is_array($selectedCategoriesIDs) == false) { $selectedCategoriesIDs = array(); } $model = new RM_Categories(); $jsonCategories = $this->_createNodes($model, RM_Categories::ROOT_NAME, $selectedCategoriesIDs, $iso); return array('data' => $jsonCategories); }
public function formAction() { $this->_withoutView(); $bookingref = RM_Reservation_Manager::getInstance()->getReservationID(); $billingModel = new RM_Billing(); $billingRow = $billingModel->createRow(); $billingRow->reservation_id = $bookingref; $billingRow->total_paid = '0.00'; $billingRow->save(); RM_Reservation_Manager::getInstance()->setPaymentTotal('0.00')->setPaymentStatus(RM_Payments_Status::TRANSACTION_END_SUCCESSFULLY); $this->_forward('success', 'Payments'); }
/** * Validate information from reservation manager object, 'cause we are on the final step * before payment process. * * @param Zend_Request_Interface $request * @return bool */ function validate($request) { $this->_request = $request; $valid = true; $state = $this->_form->getState(); foreach ($state as $column) { foreach ($column as $panel) { if (in_array($panel->id, $this->_neeedToBeValidatedPanelsIDs)) { $methodName = '_' . $panel->id . '_validate'; $valid &= $this->{$methodName}(); } } } $manager = RM_Reservation_Manager::getInstance(); $savedDetails = $manager->getAllDetails(); $unitModel = new RM_Units(); foreach ($savedDetails as $details) { $valid &= $unitModel->isAvailableUnitbyDate($details->getUnit(), $details->getPeriod()); } return $valid; }
function _validatePeriod() { if ($this->_request->getParam('rm_calendar_dates', null) != null) { // get the dates from the calendar selection $datesString = $this->_request->getParam('rm_calendar_dates'); $dates = explode(',', $datesString); if (is_array($dates) == false || count($dates) == 0) { $this->_errors[] = 'PeriodSelectionIsWrong'; return false; } $startDateMySQL = $dates[0]; $endDateMySQL = $dates[count($dates) - 1]; } else { // get the saved criteria this is from the search module etc. $criteria = RM_Reservation_Manager::getInstance()->getCriteria(); if ($criteria == null) { $this->_errors[] = 'DatesNotSelected'; return false; } $startDateMySQL = $criteria->start_datetime; $endDateMySQL = $criteria->end_datetime; } if ($startDateMySQL == null) { $this->_errors[] = 'StartDateNotSelected'; return false; } if ($endDateMySQL == null) { $this->_errors[] = 'EndDateNotSelected'; return false; } $period = new RM_Reservation_Period(new RM_Date(strtotime($startDateMySQL)), new RM_Date(strtotime($endDateMySQL))); $unitModel = new RM_Units(); $unit = $unitModel->find($this->_request->getParam('unit_id', null))->current(); if ($unit == null) { $this->_errors[] = 'SelectedUnitDoesNotExists'; return false; } return $unitModel->isAvailableUnitbyDate($unit, $period); }
/** * This method should check if user is already loginned into CMS and if * we have linked user in the Resmania we need to set this user object to RM_Reservation_Manager class. * * @return bool */ public function initUser() { $config = new RM_Config(); if ($this->_module == 'admin' && (int) $config->getValue('rm_config_enable_user_groups') === 0) { return; } $user = RM_Reservation_Manager::getInstance()->getUser(); if ($user !== null) { return; } if ($config->getValue('rm_config_enable_cms_integration')) { $cmsUser = RM_Environment::getConnector()->getUser(); if ($cmsUser->isGuest()) { return; } $user = $cmsUser->findResmaniaUser(); if ($user == null) { $user = $cmsUser->convertToResmaniaUser(); } RM_Reservation_Manager::getInstance()->setUser($user); } }
private function _fireUserCreationEvent() { $manager = RM_Reservation_Manager::getInstance(); if ($manager->getCriteria() === null) { return false; } // fire the notification event return RM_Notifications_Manager::getInstance()->fire('CustomerRegistrationSuccessful', $manager); }
function setdatecriteriaJsonAction() { $this->_withoutView(); $unitID = $this->_getParam('unit_id', null); $unitModel = new RM_Units(); $unit = $unitModel->get($unitID, RM_Environment::getInstance()->getLocale(), array("summary", "description")); if ($unit == null) { return array('data' => array('success' => false, 'error' => $this->_translate->_('User.DatePicker', 'SelectedUnitDoesNotExists'))); } //TODO: we need to check dates for null $startdate = $this->_getParam('startdate', null); $enddate = $this->_getParam('enddate', null); $quantity = (int) $this->_getParam('qty', 1); //TODO: we need to check dates for rigth format to parse them into objects //check if start date is after end date $startDateObject = new RM_Date(strtotime($startdate)); $endDateObject = new RM_Date(strtotime($enddate)); if ($endDateObject->isEarlier($startDateObject)) { return array('data' => array('success' => false, 'error' => $this->_translate->_('User.DatePicker', 'StartAfterEnd'))); } // check if the dates are available... $period = new RM_Reservation_Period($startDateObject, $endDateObject); $adults = $this->_getParam("adults", 1); $children = $this->_getParam("children", 0); $infants = $this->_getParam("infants", 0); $persons = new RM_Reservation_Persons(array("adults" => $adults, "children" => $children, "infants" => $infants)); // get otherinfo - this is non-standard price system information. $otherinfo = Zend_Json::decode($this->_getParam("otherinfo", "{}")); // while we don't need the price here, getTotalUnitPrice will also check the // period selected is valid. $information = new RM_Prices_Information($unit, $period, $persons, $otherinfo); $priceSystem = RM_Environment::getInstance()->getPriceSystem(); try { $calculatedTotalPrice = $priceSystem->getTotalUnitPrice($information); } catch (RM_Exception $e) { return array('data' => array('success' => false, 'error' => $e->getMessage())); } // get the default start/end times... $startArray = explode(" ", $startdate); $endArray = explode(" ", $enddate); $realPriceSystem = $priceSystem->getRealPriceSystem($unit); $configObjectName = "RM_Unit" . $realPriceSystem->name . "Config"; // ie: RM_UnitDailyPricesConfig $priceConfigObject = new $configObjectName(); $recreatePeriod = false; // if the start time is null or 00:00:00 load the default price system times if (!isset($startArray[1]) || $startArray[1] === "" || $startArray[1] === "00:00:00") { try { // placed in a try so that if the price module returns an exception for default_end_time it does not crash this $defaultStartTime = $priceConfigObject->fetchValueByUnit($unitID, 'default_start_time'); $startdate = $startArray[0] . " " . $defaultStartTime; $startDateObject = new RM_Date(strtotime($startdate)); $recreatePeriod = true; } catch (Exception $e) { } } // if the end time is null or 00:00:00 load the default price system times if (!isset($endArray[1]) || $endArray[1] === "" || $endArray[1] === "23:30:00") { try { // placed in a try so that if the price module returns an exception for default_end_time it does not crash this $defaultEndTime = $priceConfigObject->fetchValueByUnit($unitID, 'default_end_time'); $enddate = $endArray[0] . " " . $defaultEndTime; $endDateObject = new RM_Date(strtotime($enddate)); $recreatePeriod = true; } catch (Exception $e) { } } // if the times have been added re-create the period object with the times... if ($recreatePeriod) { $period = new RM_Reservation_Period($startDateObject, $endDateObject); } // get the unit setting for the setting availablity_check // this could fail if the price system doesn't have this setting so it is wrapped in a try try { $availabilityCheck = $priceConfigObject->fetchValueByUnit($unitID, 'availablity_check'); } catch (Exception $e) { $availabilityCheck = "1"; } // check availability if ($availabilityCheck == "1") { $isAvailable = $unitModel->isAvailableUnitbyDate($unit, $period); if (!$isAvailable) { return array('data' => array('success' => false, 'error' => $this->_translate->_('User.DatePicker', 'ReselectDates'))); } } $data = array(); $data['start_datetime'] = $startdate; $data['end_datetime'] = $enddate; $data['adults'] = $adults; $data['children'] = $children; $data['infants'] = $infants; $data['otherinfo'] = $otherinfo; $data['quantity'] = $quantity; $criteria = new RM_Unit_Search_Criteria($data); $criteria->publishedOnly = true; RM_Reservation_Manager::getInstance()->resetCriteria()->setCriteria($criteria); // handle groups $isGroup = $unit->isGroup(); $groupID = $unit->getGroupId(); // if this is a group we need to get an available unit from the 'pool' if ($isGroup) { // get available sub units $AllavailableSubUnits = $unit->getAllSubUnits($criteria, $unit); foreach ($AllavailableSubUnits as $subunit) { if ($subunit->getGroupId() === $unit->getGroupId()) { $availableSubUnits[] = $subunit; } } // set a temporary session variable this is used in the groups row class $_SESSION["returnAllUnits"] = true; $units = array(); $subunits = array(); $selectedCount = 0; // if there is a unit available take the first one from the returned units... foreach ($availableSubUnits as $potentialUnit) { if ($selectedCount >= $quantity) { break; } $details = new RM_Reservation_Details($potentialUnit, $period, $persons, $otherinfo); RM_Reservation_Manager::getInstance()->addDetails($details); $selectedCount += 1; } // if the number of units saved to the reservation are not equal to the quantity also add the master unit if ($selectedCount < $quantity) { // add the master unit also $details = new RM_Reservation_Details($unit, $period, $persons, $otherinfo); RM_Reservation_Manager::getInstance()->addDetails($details); } } else { $details = new RM_Reservation_Details($unit, $period, $persons); RM_Reservation_Manager::getInstance()->addDetails($details); } // remove the temporary session variable unset($_SESSION["returnAllUnits"]); return array('data' => array('success' => true)); }
public function successAction() { // we must mark the reservation as completed successfully. // however the payment is not truely passed until the ipn is passed back // but this is asyncronus, so we have to set a success state here to the // user is directed to the final post booking page RM_Reservation_Manager::getInstance()->setPaymentStatus(RM_Payments_Status::TRANSACTION_END_SUCCESSFULLY); $this->_forward('success', 'Payments'); }
/** * Action for validating unit details form parameters. * If some of the parameters are invalid this method will redirect user to previous page with error * text messages about every wrong parameter. * If all unit detail information is valid this method will save unit information into global * reservation manager object and will redirect user to the next step of the reservation process. */ function detailsvalidateAction() { $this->_withoutView(); $unitID = $this->_getParam('unit_id', null); if ($unitID == null) { $this->_redirect('Unit', 'list'); return; } // this is the subunits if groups is being implemented $selectedUnitIds = json_decode($this->_getParam('selected_unit_ids', "[]")); $quantity = $this->_getParam('quantity', 1); $formModel = new RM_Forms(); $form = $formModel->find('unitdetails')->current(); $valid = $form->validate($this->getRequest()); if ($valid == false) { RM_Reservation_Manager::getInstance()->setFormErrors('unitdetails', $form->getErrors())->save(); $this->_redirect('Unit', 'details', array('unit_id' => $unitID)); } //We have a priority to use a user selected dates on the page, not from criteria if ($this->_request->getParam('rm_calendar_dates', null) != null) { // get the dates from the calendar selection $datesString = $this->_request->getParam('rm_calendar_dates'); $dates = explode(',', $datesString); $startDateMySQL = $dates[0]; $endDateMySQL = $dates[count($dates) - 1]; $adults = $this->_getParam("adults", 1); $children = $this->_getParam("children", 0); $infants = $this->_getParam("infants", 0); $persons = new RM_Reservation_Persons(array("adults" => $adults, "children" => $children, "infants" => $infants)); } else { $criteria = RM_Reservation_Manager::getInstance()->getCriteria(); $startDateMySQL = $criteria->start_datetime; $endDateMySQL = $criteria->end_datetime; $persons = new RM_Reservation_Persons(array("adults" => $criteria->adults, "children" => $criteria->children, "infants" => $criteria->infants)); } $period = new RM_Reservation_Period(new RM_Date(strtotime($startDateMySQL)), new RM_Date(strtotime($endDateMySQL))); $unitModel = new RM_Units(); $otherinfo = $this->_getParam("otherInfo", array()); $manager = RM_Reservation_Manager::getInstance(); // use a temporary session to pass a value to the groups module init $_SESSION["returnAllUnits"] = true; // get price... $unit = $unitModel->get($unitID, RM_Environment::getInstance()->getLocale(), array("summary", "description")); $information = new RM_Prices_Information($unit, $period, $persons, $otherinfo); $priceSystem = RM_Environment::getInstance()->getPriceSystem(); try { $calculatedTotalPrice = $priceSystem->getTotalUnitPrice($information); } catch (RM_Exception $e) { RM_Reservation_Manager::getInstance()->setFormErrors('unitdetails', array($e->getMessage()))->save(); $this->_redirect('Unit', 'details', array('unit_id' => $selectedUnitId)); } $selectedCount = 1; // loop through the selected units and save these foreach ($selectedUnitIds as $selectedUnitId) { if ($selectedCount >= $quantity) { break; } $selectedUnit = $unitModel->get($selectedUnitId, RM_Environment::getInstance()->getLocale()); $details = new RM_Reservation_Details($selectedUnit, $period, $persons, $otherinfo, $calculatedTotalPrice); $manager->addDetails($details); $selectedCount += 1; } $manager->resetFormErrors('unitdetails')->save(); $details = $manager->getAllDetails(); // reset the returnAllUnits if it's set unset($_SESSION["returnAllUnits"]); $cmsUser = RM_Environment::getConnector()->getUser(); if ($cmsUser->isGuest() == false) { $user = $cmsUser->findResmaniaUser(); if ($user !== null) { RM_Reservation_Manager::getInstance()->setUser($user); $this->_redirect('Reservations', 'summary'); } } elseif (RM_Reservation_Manager::getInstance()->getUser() !== null) { $this->_redirect('Reservations', 'summary'); } $this->_redirect('User', 'userdetails'); }
/** * Validate user captcha information. Depending on what * captcha enabled in system. * * @return bool */ private function _captcha_user_validate() { $user = RM_Reservation_Manager::getInstance()->getUser(); if ($user) { return true; } $result = RM_Environment::getInstance()->getCaptcha()->validate(); if (!$result) { $this->_errors[] = 'CaptchaCodeIsInvalid'; } return $result; }