function processPayment() { $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $paymentMethod = JRequest::getVar("payment_method"); if (!$appSettings->is_enable_payment) { $paymentMethod = "cash"; } $paymentModel = $this->getModel("PaymentOptions"); $reservationDetails = $paymentModel->getReservationDetails(); $reservationDetails->paymentMethod = $paymentMethod; $confirmationModel = $this->getModel("Confirmation"); $confirmationId = $confirmationModel->saveConfirmation($reservationDetails); $reservationDetails->confirmation_id = $confirmationId; if ($confirmationId == -1) { $this->setMessage(JText::_('LNG_NO_ROOMS_AVAILABLE', true)); $this->setRedirect(JRoute::_('index.php?option=com_jhotelreservation&view=paymentoptions', $msg)); return; } $processor = PaymentService::createPaymentProcessor($paymentMethod); $paymentDetails = $processor->processTransaction($reservationDetails); PaymentService::addPayment($paymentDetails); if ($paymentDetails->status == PAYMENT_REDIRECT) { $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView("paymentoptions", $viewType, '', array('base_path' => $this->basePath, 'layout' => "redirect")); $view->paymentProcessor = $processor; $view->display("redirect"); } else { if ($paymentDetails->status == PAYMENT_IFRAME) { $document = JFactory::getDocument(); $viewType = $document->getType(); $view = $this->getView("paymentoptions", $viewType, '', array('base_path' => $this->basePath, 'layout' => "iframe")); $view->paymentProcessor = $processor; $view->display("iframe"); } else { if ($paymentDetails->status == PAYMENT_SUCCESS) { $reservationDetails = $confirmationModel->getReservation($confirmationId); $confirmationModel->sendConfirmationEmail($reservationDetails); UserDataService::initializeReservationData(); UserDataService::initializeExcursions(); $this->setRedirect(JRoute::_('index.php?option=com_jhotelreservation&task=confirmation.viewConfirmation&reservationId=' . $confirmationId, false)); } else { if ($paymentDetails->status == PAYMENT_WAITING) { $reservationDetails = $confirmationModel->getReservation($confirmationId); $confirmationModel->sendConfirmationEmail($reservationDetails); UserDataService::initializeReservationData(); UserDataService::initializeExcursions(); $this->setRedirect(JRoute::_('index.php?option=com_jhotelreservation&task=confirmation.viewConfirmation&reservationId=' . $confirmationId, false)); } else { if ($paymentDetails->status == PAYMENT_ERROR) { $app = JFactory::getApplication(); $app->enqueueMessage($paymentDetails->error_message, 'warning'); JRequest::setVar("view", "paymentoptions"); parent::display(); } } } } } }
function display($tpl = null) { $this->hotels = $this->get("Hotels"); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($this->appSettings->is_enable_reservation == 0) { JHotelUtil::getInstance()->showUnavailable(); } //if a single hotel redirect to hotel description if (count($this->hotels) == 1 && ENABLE_SINGLE_HOTEL == 1) { $hotelLink = JHotelUtil::getHotelLink($this->hotels[0]); $app = JFactory::getApplication(); $app->redirect($hotelLink); } JRequest::setVar('showFilter', 1); $voucher = JRequest::getVar('voucher'); $this->voucher = $voucher; $pagination = $this->get('Pagination'); $this->pagination = $pagination; $orderBy = JRequest::getVar('orderBy'); $this->orderBy = $orderBy; $session = JFactory::getSession(); $this->userData = $_SESSION['userData']; //dmp($this->userData); $this->searchFilter = $this->get('SearchFilter'); parent::display($tpl); }
public static function getDefaultCurrency() { $instance = JHotelUtil::getInstance(); if (!isset($instance->applicationSettings)) { $instance->applicationSettings = self::getApplicationSettings(); } return $instance->applicationSettings; }
function display($tpl = null) { $this->extraOptions = $this->get("ExtraOptions"); $this->state = $this->get('State'); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); //dmp($this->userData); parent::display($tpl); }
function countriesReport() { $this->setReportsToolbar(); $this->itemsRoomTypes = $this->get('RoomTypes'); $this->initFilterParams(); $this->includeCharts(); $this->appSetings = JHotelUtil::getInstance()->getApplicationSettings(); $tpl = "countries"; return $tpl; }
function getReservationDetails() { $userData = UserDataService::getUserData(); $reservationData = new stdClass(); $reservationData->userData = $userData; $reservationData->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $reservationData->hotel = HotelService::getHotel($userData->hotelId); $reservationService = new ReservationService(); $reservationDetails = $reservationService->generateReservationSummary($reservationData); UserDataService::setReservationDetails($reservationDetails); $reservationDetails->reservationData = $reservationData; return $reservationDetails; }
/** * Display the view */ public function display($tpl = null) { //$this->form = $this->get('Form'); $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->rate = $this->get('Rate'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); parent::display($tpl); $this->addToolbar(); }
function display($tpl = null) { $this->hotel = $this->get("Item"); $this->state = $this->get('State'); $this->offers = $this->get("Offers"); $this->rooms = $this->get("Rooms"); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($this->appSettings->is_enable_reservation == 0) { JHotelUtil::getInstance()->showUnavailable(); } $this->userData = UserDataService::getUserData(); $this->currencies = CurrencyService::getAllCurrencies(); //dmp($this->userData); parent::display($tpl); }
function display($tpl = null) { $lang = JFactory::getLanguage(); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $hotel_id = $this->get('HotelId'); $this->hotel_id = $hotel_id; $hotels = $this->get('Hotels'); $hotels = checkHotels(JFactory::getUser()->id, $hotels); $this->hotels = $hotels; parent::display($tpl); $this->addToolbar(); }
function display($tpl = null) { $this->state = $this->get('State'); $this->reservationDetails = $this->get("ReservationDetails"); $this->paymentMethods = $this->get('paymentMethods'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $doc = JFactory::getDocument(); $tag = JHotelUtil::getJoomlaLanguage(); $doc->addStyleSheet('administrator/components/' . getBookingExtName() . '/assets/js/validation/css/validationEngine.jquery.css'); $doc->addScript('administrator/components/' . getBookingExtName() . '/assets/js/validation/js/languages/jquery.validationEngine-' . $tag . '.js'); $doc->addScript('administrator/components/' . getBookingExtName() . '/assets/js/validation/js/jquery.validationEngine.js'); parent::display($tpl); }
/** * Display the view */ public function display($tpl = null) { $lang = JFactory::getLanguage(); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $this->roomTypes = $this->get('RoomTypesOptions'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $hotels = $this->get('Hotels'); $this->hotels = checkHotels(JFactory::getUser()->id, $hotels); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); $this->addToolbar(); }
function display($tpl = null) { $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $this->userData = $_SESSION['userData']; //dmp($this->userData); $this->searchFilter = $this->get('SearchFilter'); if (!$this->appSettings->enable_excursions) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_("LNG_EXCURSIONS_COURSES_DISABLED"), 'warning'); } // get the menu parameters for use $type = JRequest::getVar("excursion_type"); if (method_exists($this, $type)) { $tpl = $this->{$type}(); } $this->setLayout('default'); parent::display($tpl); }
/** * Display the view */ public function display($tpl = null) { $lang = JFactory::getLanguage(); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $hotels = $this->get('Hotels'); $this->hotels = checkHotels(JFactory::getUser()->id, $hotels); //var_dump($this->hotels); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } parent::display($tpl); $this->addToolbar(); }
function addGuestDetails() { $data = JRequest::get("post"); UserDataService::addGuestDetails($data); $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($appSettings->save_all_guests_data) { UserDataService::storeGuestDetails($data); } $reservedItems = JRequest::getVar("reservedItems"); $hotelId = JRequest::getVar("hotel_id"); if (!empty($reservedItems)) { UserDataService::updateRooms($hotelId, $reservedItems); /*echo "<pre>"; var_dump(UserDataService::updateRooms($hotelId, $reservedItems)); echo "</pre>"; die;*/ } $this->setRedirect(JRoute::_('index.php?option=com_jhotelreservation&task=paymentoptions.showPaymentOptions', false)); }
function display($tpl = null) { $this->rooms = $this->get("AllRooms"); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($this->appSettings->is_enable_reservation == 0) { JHotelUtil::getInstance()->showUnavailable(); } JRequest::setVar('showFilter', 0); $voucher = JRequest::getVar('voucher'); $this->voucher = $voucher; $pagination = $this->get('Pagination'); $this->pagination = $pagination; $orderBy = JRequest::getVar('orderBy'); $this->orderBy = $orderBy; $session = JFactory::getSession(); $this->userData = $_SESSION['userData']; $this->searchFilter = $this->get('SearchFilter'); parent::display($tpl); }
function display($tpl = null) { $this->state = $this->get('State'); $this->countries = $this->get('Countries'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $this->userData = UserDataService::getUserData(); $this->hotel = HotelService::getHotel($this->userData->hotelId); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); if ($this->appSettings->save_all_guests_data) { UserDataService::prepareGuestDetails(); } $hotelId = JRequest::getVar("hotel_id"); $reservedItems = JRequest::getVar("reservedItems"); if (!empty($reservedItems)) { UserDataService::updateRooms($hotelId, $reservedItems); } $this->reservationDetails = $this->get("ReservationDetails"); $this->showDiscounts = true; parent::display($tpl); }
function display($tpl = null) { $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $this->item = $this->get('Item'); $this->extraOptions = $this->get('ExtraOptions'); $this->pictures = $this->get('OfferPictures'); $this->excursions = $this->get('Excursions'); //get offer translations $hoteltranslationsModel = new JHotelReservationModelhoteltranslations(); $this->offerShortDescTranslations = $hoteltranslationsModel->getAllTranslations(OFFER_SHORT_TRANSLATION, $this->item->offer_id); $this->offerTranslations = $hoteltranslationsModel->getAllTranslations(OFFER_TRANSLATION, $this->item->offer_id); $this->offerContentTranslations = $hoteltranslationsModel->getAllTranslations(OFFER_CONTENT_TRANSLATION, $this->item->offer_id); $this->offerOtherInfoTranslations = $hoteltranslationsModel->getAllTranslations(OFFER_INFO_TRANSLATION, $this->item->offer_id); JToolBarHelper::title('J-Hotel Reservation : ' . JText::_($this->item->offer_id > 0 ? "LNG_EDIT" : "LNG_ADD_NEW", true) . ' ' . JText::_('LNG_OFFER', true), 'generic.png'); $hotel_id = $this->get('HotelId'); $this->hotel_id = $hotel_id; $this->includeFunctions(); parent::display($tpl); $this->addToolbar(); }
/** * Display the view */ public function display($tpl = null) { //$this->form = $this->get('Form'); $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->rate = $this->get('Rate'); $this->onlyAvailability = JRequest::getVar("onlyAvailability", false); $language = JFactory::getLanguage(); $language_tag = $language->getTag(); $language_tag = str_replace("-", "_", $language->getTag()); setlocale(LC_TIME, $language_tag . '.UTF-8'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); parent::display($tpl); $this->addToolbar(); }
function getNearByHotels($locationName, $searchParams, $hotels) { $location = JHotelUtil::getInstance()->getCoordinates($locationName); if (empty($location)) { return null; } $excludedIds = array(); foreach ($hotels as $hotel) { $excludedIds[] = $hotel->hotel_id; } $searchParams["nearByHotels"] = 1; $searchParams["latitude"] = $location["latitude"]; $searchParams["longitude"] = $location["longitude"]; $searchParams["distance"] = 100; if (!empty($excludedIds)) { $searchParams["excludedIds"] = implode(",", $excludedIds); } $hotelTable = $this->getTable('hotels'); $hotels = $hotelTable->getHotels($searchParams, 0, 5); return $hotels; }
/** * Display the view */ public function display($tpl = null) { //$this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->hotel = $this->get('Hotel'); $this->pictures = $this->get('ExcursionPictures'); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } //get hotel translations $hoteltranslationsModel = new JHotelReservationModelhoteltranslations(); $this->translations = $hoteltranslationsModel->getAllTranslations(EXCURSION_TRANSLATION, $this->item->id); $this->includeFunctions(); $appSettings = JHotelUtil::getApplicationSettings(); parent::display($tpl); $this->addToolbar(); }
function editReservation() { $this->item = $this->get('Item'); $this->state = $this->get('State'); $this->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $this->roomTypes = $this->get('RoomTypesOptions'); $this->guestTypes = JHotelReservationHelper::getGuestTypes(); $hotels = $this->get('Hotels'); $this->hotels = checkHotels(JFactory::getUser()->id, $hotels); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $doc = JFactory::getDocument(); $doc->addScriptDeclaration(' var baseUrl="' . (JURI::base() . '/administrator/index.php?option=' . getBookingExtName()) . '"; '); $doc->addScript('administrator/components/' . getBookingExtName() . '/assets/js/reservation.js'); $tpl = 'editreservation'; return $tpl; }
function secretizeCard($reservationId) { $creditCard = JRequest::getVar("card_number"); if (isset($creditCard)) { $creditCard = JHotelUtil::getInstance()->secretizeCreditCard($creditCard); $table = $this->getTable("ConfirmationsPayments"); $table->secretizeCard($reservationId, $creditCard); } return true; }
<?php //error_reporting(E_ALL); //ini_set('display_errors','On'); $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); ?> <div id="advanced-search" style="display:none"> <span title="Cancel" class="dialogCloseButton" onClick="revertValue();jQuery.unblockUI();"> <span title="Cancel" class="closeText">x</span> </span> <div class="mod_hotel_reservation" id="mod_hotel_reservation"> <form action="<?php echo JRoute::_('index.php?option=com_jhotelreservation'); ?> " method="post" name="userModuleAdvancedForm" id="userModuleAdvancedForm" > <input id="controller3" type='hidden' name='controller' value='hotels'/> <input id="task3" type='hidden' name='task' value='searchHotels'/> <input type="hidden" name="hotel_id" id="hotel_id3" value="" /> <input type='hidden' name='year_start' value=''/> <input type='hidden' name='month_start' value=''/> <input type='hidden' name='day_start' value=''/> <input type='hidden' name='year_end' value=''/> <input type='hidden' name='month_end' value=''/> <input type='hidden' name='day_end' value=''/> <input type='hidden' name='rooms' value='' /> <input type='hidden' name='guest_adult' value=''/> <input type='hidden' name='guest_child' value=''/> <input type='hidden' name='filterParams' id="filterParams" value='<?php
public static function sendReservationFailureEmail($reservation) { $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $mode = 1; //html $log = Logger::getInstance(); $log->LogDebug("Reservation failure " . serialize($reservation)); $email = JText::_('LNG_RESERVAION_FAILURE_EMAIL', true); $email = str_replace("<<reservation_id>>", $reservation->confirmation_id, $email); $email = str_replace("<<start_date>>", $reservation->start_date, $email); $email = str_replace("<<end_date>>", $reservation->end_date, $email); $email = str_replace("<<name>>", $reservation->last_name . ' ' . $reservation->first_name, $email); $email_subject = JText::_('LNG_RESERVAION_FAILURE_EMAIL_SUBJECT', true); $email_subject = str_replace("<<reservation_id>>", $reservation->confirmation_id, $email_subject); return self::sendEmail($appSettings->company_email, $appSettings->company_name, null, $appSettings->company_email, null, null, $email_subject, $email, $mode); }
/** * @copyright Copyright (C) 2008-2009 CMSJunkie. All rights reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ // no direct access defined('_JEXEC') or die('Restricted access'); JHTML::_('stylesheet', 'modules/mod_jreservationinfo/assets/css/style.css'); require_once JPATH_SITE . '/administrator/components/com_jhotelreservation/helpers/defines.php'; require_once JPATH_SITE . '/administrator/components/com_jhotelreservation/helpers/utils.php'; // Include the syndicate functions only once require_once dirname(__FILE__) . DS . 'helper.php'; $userData = UserDataService::getUserData(); $hotel = HotelService::getHotel($userData->hotelId); $reservationData = new stdClass(); $reservationData->userData = $userData; $reservationData->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $reservationData->hotel = $hotel; $reservationService = new ReservationService(); $reservationDetails = $reservationService->generateReservationSummary($reservationData); $moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx')); require JModuleHelper::getLayoutPath('mod_jreservationinfo', $params->get('layout', 'default'));
public function getPaymentDetails($paymentDetails, $amount, $cost) { $result = ""; $app = JFactory::getApplication(); $isAdmin = $app->isAdmin(); ob_start(); ?> <br/><br/> <TABLE> <TR> <TD align=left width=40% nowrap> <b><?php echo JText::_('LNG_PAYMENT_METHOD', true); ?> : </b> </TD> <TD> <?php echo $this->name; ?> </TD> </TR> <TR> <TD align=left width=40% nowrap> <b><?php echo JText::_('LNG_NAME_OF_CARD', true); ?> : </b> </TD> <TD> <?php echo $paymentDetails->card_name; ?> </TD> </TR> <TR> <TD align=left width=40% nowrap> <b><?php echo JText::_('LNG_CREDIT_CARD_NUMBER', true); ?> :</b> </TD> <TD> <input type="hidden" name="card_number" value="<?php echo $paymentDetails->card_number; ?> "> <?php echo $isAdmin ? $paymentDetails->card_number : JHotelUtil::getInstance()->secretizeCreditCard($paymentDetails->card_number); ?> </TD> </TR> <TR> <TD align=left width=40% nowrap> <b><?php echo JText::_('LNG_EXPIRATION_DATE', true); ?> :</b> </TD> <TD> <?php echo $paymentDetails->card_expiration_month . " - " . $paymentDetails->card_expiration_year; ?> </TD> </TR> <TR> <TD align=left width=40% nowrap> <b><?php echo JText::_('LNG_SECURITY_CODE', true); ?> :</b> </TD> <TD> <?php echo $paymentDetails->card_security_code; ?> </TD> </TR> <?php if ($isAdmin) { ?> <TR> <TD align=left width=40% nowrap> </TD> <TD> <button type="button" onClick="jQuery('#task').val('reservation.secretizeCard');jQuery('#adminForm').submit()">Secretize</button> </TD> </TR> <?php } ?> </TABLE> <br/><br/> <?php $result = $result . ob_get_contents(); ob_end_clean(); return $result; }
function getReservation($reservationId = null, $hotelId = null, $checkAvailability = true) { if (!isset($reservationId)) { $reservationId = JRequest::getInt("reservationId"); } $confirmationTable = JTable::getInstance('Confirmations', 'Table', array()); $reservation = $confirmationTable->getReservationData($reservationId); if (!$reservationId) { $reservation = UserDataService::createUserData(array()); $reservation->hotelId = $hotelId; } else { $reservation->reservedItems = explode(",", $reservation->items_reserved); $reservation->extraOptionIds = explode(",", $reservation->extraOptionIds); $reservation->hotelId = $reservation->hotel_id; $reservation->guestDetails = $this->prepareGuestDetails($reservation->guestDetails); $reservation->roomGuests = explode(",", $reservation->total_adults); $reservation->total_adults = 0; if (isset($reservation->roomGuests) && count($reservation->roomGuests) >= 1) { foreach ($reservation->roomGuests as $guestPerRoom) { $values = explode("|", $guestPerRoom); $reservation->total_adults += $values[0]; } } $reservation->roomGuestsChildren = explode(",", $reservation->children); $reservation->total_children = 0; if (isset($reservation->roomGuestsChildren) && count($reservation->roomGuestsChildren) >= 1) { foreach ($reservation->roomGuestsChildren as $guestPerRoom) { $values = explode("|", $guestPerRoom); $reservation->total_children += $values[0]; } } } //dmp($reservation->total_adults); //dmp($reservation->roomGuests); //dmp($reservation); if (!isset($reservation->totalPaid)) { $reservation->totalPaid = 0; } $hotel = HotelService::getHotel($reservation->hotelId); $reservation->currency = HotelService::getHotelCurrency($hotel); $reservationData = new stdClass(); $reservationData->userData = $reservation; $reservationData->appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $reservationData->hotel = $hotel; $extraOptionIds = isset($reservationData->userData->extraOptionIds) ? $reservationData->userData->extraOptionIds : null; $extraOptions = array(); if (is_array($extraOptionIds) && count($extraOptionIds) > 0) { foreach ($extraOptionIds as $key => $value) { if (strlen($value) > 1) { $extraOption = explode("|", $value); $extraOptions[$key] = $extraOption; } } } //dmp($_SESSION["extras"]); $reservationData->extraOptions = ExtraOptionsService::getHotelExtraOptions($reservationData->userData->hotelId, $reservationData->userData->start_date, $reservationData->userData->end_date, $_SESSION["extras"], 0, 0, false); $reservationDetails = new stdClass(); if ($reservationId) { $reservationDetails = $this->generateReservationSummary($reservationData, $checkAvailability); } $reservationDetails->reservationData = $reservationData; $reservationDetails->billingInformation = $this->getBillingInformation($reservationData->userData, $reservationData->appSettings->hide_user_email); $reservationDetails->confirmation_id = $reservation->confirmation_id; $paymentDetails = PaymentService::getConfirmationPaymentDetails($reservation->confirmation_id); if (isset($paymentDetails) && $paymentDetails->confirmation_id != 0) { $reservationDetails->paymentInformation = $this->getPaymentInformation($paymentDetails, $reservationDetails->total, $reservationDetails->cost); } //dmp($reservationDetails); return $reservationDetails; }
function addJoomlaUser($reservationDetails) { // "generate" a new JUser Object $user = JFactory::getUser(0); // it's important to set the "0" otherwise your admin user information will be loaded jimport('joomla.application.component.helper'); $usersParams =& JComponentHelper::getParams('com_users'); // load the Params $userdata = array(); // place user data in an array for storing. $userdata['name'] = $reservationDetails->reservationData->userData->last_name . ' ' . $reservationDetails->reservationData->userData->first_name; $userdata['email'] = $reservationDetails->reservationData->userData->email; $userdata['username'] = $reservationDetails->reservationData->userData->email; //set password $userdata['password'] = UserService::generatePassword($reservationDetails->reservationData->userData->email, true); $userdata['password2'] = $userdata['password']; //set default group. $usertype = $usersParams->get('new_usertype', 2); if (!$usertype) { $usertype = 'Registered'; } //default to defaultUserGroup i.e.,Registered $userdata['groups'] = array($usertype); $useractivation = $usersParams->get('useractivation'); // in this example, we load the config-setting if ($useractivation == 1) { $config = JFactory::getConfig(); $userdata['sitename'] = $config->get('sitename'); $userdata['siteurl'] = JUri::base(); $userdata['sitename'] = $config->get('sitename'); $userdata['siteurl'] = JUri::base(); jimport('joomla.user.helper'); // include libraries/user/helper.php $userdata['block'] = 1; // block the User $userdata['activation'] = JApplication::getHash(JUserHelper::genRandomPassword()); // set activation hash (don't forget to send an activation email) $uri = JURI::getInstance(); $base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); $userdata['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $userdata['activation'], false); $emailSubject = JText::sprintf('COM_USERS_EMAIL_ACCOUNT_DETAILS', $userdata['name'], $userdata['sitename']); $emailBody = JText::sprintf('COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $userdata['name'], $userdata['sitename'], $userdata['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $userdata['activation'], $userdata['siteurl'], $userdata['username'], $userdata['password']); $appSettings = JHotelUtil::getInstance()->getApplicationSettings(); $fromName = $appSettings->company_name; $confirmEmail = $appSettings->company_email; $mail = new JMail(); $response = $mail->sendMail($confirmEmail, $fromName, $userdata['email'], $emailSubject, $emailBody); if ($response !== true) { JError::raiseWarning('', JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED', true)); } } else { // no we need no activation $userdata['block'] = 0; // don't block the user } //now to add the new user to the dtabase. if (!$user->bind($userdata)) { $this->log->LogDebug("Exception when binding user - confirmtion" . JText::_($user->getError())); JError::raiseWarning('', JText::_($user->getError())); // something went wrong!! } if (!$user->save()) { // now check if the new user is saved $this->log->LogDebug("Exception when adding user_id to confirmtion" . JText::_($user->getError())); JError::raiseWarning('', JText::_($user->getError())); // something went wrong!! } return $user->id; }