public function postRequest()
 {
     $token = JSession::checkToken();
     if (!$token) {
         die('Invail request');
     }
     $app = jfactory::getApplication();
     AImporter::helper('email');
     AImporter::classes('order/custom');
     $order = new BookproCustomOrder();
     $order->orderinfo = $this->input->get('orderinfo', array(), 'array');
     $order->customer = $_POST;
     $db = JFactory::getDbo();
     if ($order->save()) {
         $mail = new EmailHelper($order->table->id);
         $mail->sendMail();
         $app->enqueueMessage(JText::_('COM_BOOKPRO_CUSTOM_THANKS_FOR_BOOKING'));
     }
     $app->redirect('index.php?option=com_bookpro&view=customservice');
     return;
 }
 function calendar()
 {
     $date = JDate::createFromFormat('Y', $_POST['year']);
     $min_date = clone $date;
     $min_date = $min_date->modify('-1 year');
     $max_date = $date->modify('+1 year');
     $calendar_attributes = array('min_select_year' => $min_date->format('Y'), 'max_select_year' => $max_date->format('Y'));
     if (isset($_REQUEST['action']) and $_REQUEST['action'] == 'pn_get_month_cal') {
         AImporter::classes('dayoffcalendar');
         AImporter::css('calendar');
         $calendar = new PN_Calendar($calendar_attributes);
         echo $calendar->draw(array(), $_REQUEST['year'], $_REQUEST['month']);
         exit;
     }
 }
 function register()
 {
     AImporter::helper('bookpro');
     JSession::checkToken() or die(JText::_('Invalid Token'));
     $config = JBFactory::getConfig();
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $params = JComponentHelper::getParams('com_users');
     $useractivation = $params->get('useractivation');
     $input = $mainframe->input;
     $post = $input->getArray($_POST);
     $db = JFactory::getDbo();
     try {
         $db->transactionStart();
         $post['name'] = $post['firstname'] . ' ' . $post['lastname'];
         $cuser = new JUser();
         $cuser->bind($post);
         $cuser->name = $post['name'];
         //check Username
         if (!$this->checkUsernamePHP($post['username'])) {
             $mainframe->enqueueMessage(JText::_('COM_BOOKPRO_USERNAME_EXISTS'), 'warning');
             $view = $this->getView('register', 'html', 'BookProView');
             $view->assign('customer', (object) $post);
             $view->display();
             return;
         }
         if (!$this->checkEmailPHP($post['email'])) {
             $mainframe->enqueueMessage(JText::_('COM_BOOKPRO_EMAIL_EXISTS'), 'warning');
             $view = $this->getView('register', 'html', 'BookProView');
             $view->assign('obj', (object) $post);
             $view->display();
             return;
         }
         $cuser->activation = $useractivation;
         if ($post['group_id']) {
             $cuser->groups = array($post['group_id']);
         } else {
             $cuser->groups = array($config->get('customer_usergroup', 2));
         }
         $cuser->sendEmail = 1;
         $cuser->registerDate = JFactory::getDate()->toSql();
         $cuser->save();
         AImporter::classes('customer');
         $jbuser = new BookproCustomer();
         $post['user'] = $cuser->id;
         $post['state'] = 1;
         $jbuser->saveNewCustomer($post);
         $db->transactionCommit();
     } catch (Exception $e) {
         $mainframe->enqueueMessage($e->getMessage());
         $db->transactionRollback();
         $this->setRedirect(JUri::base() . 'index.php?option=com_bookpro&view=register');
     }
     if ($useractivation == 1 || $useractivation == 2) {
         $post['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
         $post['block'] = 1;
     }
     //handle email notification
     if ($useractivation == 1) {
         $config = JFactory::getConfig();
         $post['fromname'] = $config->get('fromname');
         $post['mailfrom'] = $config->get('mailfrom');
         $post['sitename'] = $config->get('sitename');
         $post['siteurl'] = JUri::root();
         $post['activate'] = JUri::base() . 'index.php?option=com_users&task=registration.activate&token=' . $post['activation'];
         $emailSubject = JText::sprintf('COM_BOOKPRO_EMAIL_ACCOUNT_DETAILS', $post['name'], JUri::base());
         $emailBody = JText::sprintf('COM_BOOKPRO_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $post['name'], $post['sitename'], $post['activate'], JUri::base(), $post['username']);
         $return = JFactory::getMailer()->sendMail($post['mailfrom'], $post['fromname'], $post['email'], $emailSubject, $emailBody);
     }
     //redirect to complete view
     if ($useractivation == 1 || $useractivation == 2) {
         $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
         $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
         return;
     }
     AImporter::helper('email');
     $mailer = new EmailHelper();
     if (isset($config->sendRegistrationsEmails) && $config->sendRegistrationsEmails > 0) {
         $mailer->registerNotify($id);
     }
     if ($config->get('auto_login')) {
         $options = array();
         $options['remember'] = JRequest::getBool('remember', true);
         $credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
         $credentials['password'] = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
         $error = $mainframe->login($credentials, $options);
     }
     $return = JRequest::getVar('return');
     if ($return) {
         $mainframe->redirect(base64_decode($return));
     } else {
         $mainframe->redirect(JURI::base() . 'index.php');
     }
 }
 public function confirm()
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $input = $app->input;
     AImporter::classes('order/transport');
     AImporter::model('addons');
     $addon_ids = $input->get('depart_addon', '', 'array');
     $addon_ids_return = $input->get('return_addon', '', 'array');
     $addonModel = new BookProModelAddons();
     $cart = $this->getCart();
     $this->checkCart($cart);
     $order = new BookproTransportOrder();
     $order->customer = $input->getArray($_POST);
     $order->addons['depart'] = $addonModel->getDataByIds($addon_ids);
     $order->addons['return'] = $addonModel->getDataByIds($addon_ids_return);
     $order->passengers = $input->get('person', array(), 'array');
     $order->cart = $cart;
     $order->trips = $cart->trips;
     if ($order->save()) {
         //process payment
         require_once JPATH_ROOT . '/components/com_bookpro/controllers/payment.php';
         $payment = new BookProControllerPayment();
         $payment->input->set('order_id', $order->table->id);
         $payment->process();
         $order = null;
         return;
     } else {
         return false;
     }
 }
 function postpayment()
 {
     $app = JFactory::getApplication();
     $plugin = $app->input->getString('method');
     $pluginsms = $app->input->get('methodsms', 'product_sms', 'string');
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('bookpro');
     $values = new JObject();
     $results = $dispatcher->trigger("onBookproPostPayment", array($plugin, $values));
     /// Send email
     if ($results) {
         AImporter::model('order');
         $model = new BookProModelOrder();
         $orderComplex = $model->getComplexItem($results[0]->id);
         //$smsresult=$dispatcher->trigger('onBookproSendSms',array($results[0]));
         if (!$results[0]->sendemail) {
             //$this->sendMail($results[0]->id);
             $url = JUri::root() . 'index.php?option=com_bookpro&controller=payment&task=urlsendmail&order_id=' . $results[0]->id;
             $response = BookProHelper::pingUrl($url);
         }
     }
     if ($app->input->getString('message') == 'cancelled') {
         $app->enqueseMessage(JText::_('COM_BOOKPRO_YOUR_BOOKING_HAS_BEEN_CANCELLED'));
         return;
     }
     if ($results[0]->order_status == 'CONFIRMED') {
         AImporter::classes('customer');
         $user = new BookproCustomer();
         $user->saveSunpassPoint($results[0]);
         $app->redirect('index.php?option=com_bookpro&view=postpayment&order=' . $results[0]->order_number . '&email=' . $orderComplex->customer->email);
     } else {
         $app->enqueseMessage(JText::_('COM_BOOKPRO_YOUR_BOOKING_HAS_NOT_BEEN_CONFIRMED'));
     }
     return;
 }
<?php

/**
 * @package 	Bookpro
 * @author 		Ngo Van Quan
 * @link 		http://joombooking.com
 * @copyright 	Copyright (C) 2011 - 2012 Ngo Van Quan
 * @license 	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * @version 	$Id: default.php 26 2012-07-08 16:07:54Z quannv $
 **/
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.modal');
AImporter::css('calendar');
$document = JFactory::getDocument();
$document->addScript(JUri::base() . 'components/com_bookpro/assets/js/pncalendar.js');
AImporter::classes('dayoffcalendar');
?>
<script type="text/javascript">
var ajaxurl = "<?php 
echo JUri::base() . 'index.php?option=com_bookpro&controller=transportdayoff&task=calendar';
?>
";
var pn_appointments_calendar = null;
jQuery(function() {
    pn_appointments_calendar = new PN_CALENDAR();
    pn_appointments_calendar.init();
});

</script>
<script type="text/javascript">
function deleteRate(id,month,year){