function ajax_save_dateavailability_item() { $app = JFactory::getApplication(); $dateavailability_model = $this->getModel('dateavailability'); $data = $app->input->getArray(); $days_seleted = $data['days_seleted']; require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $days_seleted = up_json_decode($days_seleted, false, 512, JSON_PARSE_JAVASCRIPT); $tsmart_service_class_id = $data['tsmart_service_class_id']; $tsmart_product_id = $data['tsmart_product_id']; $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->delete('#__tsmart_date_availability')->where('tsmart_service_class_id=' . (int) $tsmart_service_class_id . ' AND tsmart_product_id=' . (int) $tsmart_product_id); $db->setQuery($query); $ok = $db->execute(); $response = new stdClass(); $response->e = 0; if (!$ok) { $response->e = 1; throw new Exception($db->getErrorMsg()); } foreach ($days_seleted as $date) { $data1 = $data; $data1['date'] = $date; $tsmart_dateavailability_id = $dateavailability_model->store($data1); if (!$tsmart_dateavailability_id) { echo $dateavailability_model->getErrors(); } } echo json_encode($response); die; }
/** * Collect all data to show on the template * * @author RolandD, Max Milbers */ function display($tpl = null) { $app = JFactory::getApplication(); $input = $app->input; $session = JFactory::getSession(); $virtuemart_price_id = $session->get('virtuemart_price_id', 0); $booking_date = $input->getString('booking_date', ''); $privategrouptrip_model = tmsModel::getModel('privategrouptrip'); $item_private_group_trip = $privategrouptrip_model->getData($virtuemart_price_id); $virtuemart_product_id = $item_private_group_trip->virtuemart_product_id; $input->set('virtuemart_product_id', $virtuemart_product_id); $privategrouptrip_model->setState('filter.virtuemart_price_id', $virtuemart_price_id); $this->privategrouptrip = reset($privategrouptrip_model->getItems()); $this->privategrouptrip->allow_passenger = 'infant,child_1,child_2,teen,adult,senior'; $this->privategrouptrip->departure_date = $booking_date; $product_model = tmsModel::getModel('product'); $this->product = $product_model->getItem($this->privategrouptrip->virtuemart_product_id); require_once JPATH_ROOT . '/components/com_virtuemart/helpers/vmjointgroup.php'; $this->rooming_select_type = Vmjointgroup::get_list_rooming_type(); require_once JPATH_ROOT . '/libraries/php-loremipsum-master/src/LoremIpsum.php'; $this->lipsum = new joshtronic\LoremIpsum(); require_once JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/tsmtransferaddon.php'; $transfer_addon_model = tmsModel::getModel('transferaddon'); require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $this->pre_transfer_item = $transfer_addon_model->getItem(12); $this->pre_transfer_item->data_price = base64_decode($this->pre_transfer_item->data_price); $this->pre_transfer_item->data_price = up_json_decode($this->pre_transfer_item->data_price, false, 512, JSON_PARSE_JAVASCRIPT); $this->pre_transfer_item->sale_price = $this->pre_transfer_item->data_price->item_flat->net_price; $this->post_transfer_item = clone $transfer_addon_model->getItem(14); $this->post_transfer_item->data_price = base64_decode($this->post_transfer_item->data_price); $this->post_transfer_item->data_price = up_json_decode($this->post_transfer_item->data_price, false, 512, JSON_PARSE_JAVASCRIPT); $this->post_transfer_item->asale_price = $this->post_transfer_item->data_price->item_flat->net_price; $hotel_addon_model = tmsModel::getModel('hoteladdon'); require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $this->pre_night_item = $hotel_addon_model->getItem(14); $this->pre_night_item->data_price = base64_decode($this->pre_night_item->data_price); $this->pre_night_item->data_price = up_json_decode($this->pre_night_item->data_price, false, 512, JSON_PARSE_JAVASCRIPT); $this->pre_night_item->sale_price = $this->pre_night_item->data_price->item_flat->net_price; $this->post_night_item = clone $hotel_addon_model->getItem(15); $this->post_night_item->data_price = base64_decode($this->post_night_item->data_price); $this->post_night_item->data_price = up_json_decode($this->post_night_item->data_price, false, 512, JSON_PARSE_JAVASCRIPT); $this->post_night_item->asale_price = $this->post_transfer_item->data_price->item_flat->net_price; $transfer_excursion_addon = tmsModel::getModel('excursionaddon'); $this->list_excursion_addon = $transfer_excursion_addon->getItemList(); parent::display($tpl); }
/** * Retireve a list of currencies from the database. * * This is written to get a list for selecting currencies. Therefore it asks for enabled * @author Max Milbers * @return object List of currency objects */ function store(&$data) { if (!vmAccess::manager('hotel')) { vmWarn('Insufficient permissions to store hotel'); return false; } $db = JFactory::getDbo(); $tsmart_hotel_addon_id = parent::store($data); if ($tsmart_hotel_addon_id) { //inser to excusionaddon $query = $db->getQuery(true); $query->delete('#__tsmart_tour_id_hotel_addon_id')->where('tsmart_hotel_addon_id=' . (int) $tsmart_hotel_addon_id); $db->setQuery($query)->execute(); $err = $db->getErrorMsg(); if (!empty($err)) { vmError('can not delete tour in hotel_addon', $err); } $list_tour_id = $data['list_tour_id']; foreach ($list_tour_id as $tsmart_product_id) { $query->clear()->insert('#__tsmart_tour_id_hotel_addon_id')->set('tsmart_product_id=' . (int) $tsmart_product_id)->set('tsmart_hotel_addon_id=' . (int) $tsmart_hotel_addon_id); $db->setQuery($query)->execute(); $err = $db->getErrorMsg(); if (!empty($err)) { vmError('can not insert tour in this hotel_addon', $err); } } $hotel_addon_type = $data['hotel_addon_type']; $hotel_addon_date_price_table = $this->getTable('hotel_addon_date_price'); //end insert group size $data_price = $data['data_price']; $data_price = base64_decode($data_price); require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $data_price = up_json_decode($data_price, false, 512, JSON_PARSE_JAVASCRIPT); $item_mark_up_type = $data_price->item_mark_up_type; foreach ($list_tour_id as $tour_id) { $vail_from = JFactory::getDate($data['vail_from']); $vail_to = JFactory::getDate($data['vail_to']); $single_room = $data_price->items->single_room; $double_twin_room = $data_price->items->double_twin_room; $triple_room = $data_price->items->triple_room; while ($vail_from->getTimestamp() <= $vail_to->getTimestamp()) { $date = $vail_from->format('Y-m-d'); $hotel_addon_date_price_table->id = 0; $hotel_addon_date_price_table->jload(array('date' => $date, 'tsmart_product_id' => $tour_id, 'hotel_addon_type' => $hotel_addon_type)); $hotel_addon_date_price_table->date = $date; $hotel_addon_date_price_table->tsmart_hotel_addon_id = $tsmart_hotel_addon_id; $hotel_addon_date_price_table->tsmart_product_id = $tour_id; $hotel_addon_date_price_table->hotel_addon_type = $hotel_addon_type; $hotel_addon_date_price_table->single_room_net_price = $single_room->net_price; $hotel_addon_date_price_table->doulble_twin_room_net_price = $double_twin_room->net_price; $hotel_addon_date_price_table->triple_room_net_price = $triple_room->net_price; //tax $hotel_addon_date_price_table->single_room_tax = $single_room->tax; $hotel_addon_date_price_table->doulble_twin_room_tax = $double_twin_room->tax; $hotel_addon_date_price_table->triple_room_tax = $triple_room->tax; if ($item_mark_up_type == 'percent') { $hotel_addon_date_price_table->single_room_mark_up_percent = $single_room->mark_up_percent; $hotel_addon_date_price_table->doulble_twin_room_mark_up_percent = $double_twin_room->mark_up_percent; $hotel_addon_date_price_table->triple_room_mark_up_percent = $triple_room->mark_up_percent; } else { $hotel_addon_date_price_table->single_room_mark_up_amout = $single_room->mark_up_amount; $hotel_addon_date_price_table->doulble_twin_room_mark_up_amount = $double_twin_room->mark_up_amount; $hotel_addon_date_price_table->triple_room_mark_up_amout = $triple_room->mark_up_amount; } $ok = $hotel_addon_date_price_table->store(); if (!$ok) { throw new Exception($hotel_addon_date_price_table->getError()); } $vail_from->modify('+1 day'); } } } return $tsmart_hotel_addon_id; }
function ajax_save_departure_item() { $app = JFactory::getApplication(); $departure_model = $this->getModel('departure'); $data = $app->input->getArray(); $min_max_space = $data['min_max_space']; $min_max_space = explode(';', $min_max_space); $data['min_space'] = $min_max_space[0]; $data['max_space'] = $min_max_space[1]; $data['allow_passenger'] = implode(',', $data['allow_passenger']); $data['weekly'] = implode(',', $data['weekly']); $days_seleted = $data['days_seleted']; require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $days_seleted = up_json_decode($days_seleted, false, 512, JSON_PARSE_JAVASCRIPT); $data['days_seleted'] = implode(',', $days_seleted); if (!$data['tsmart_departure_id']) { $data['departure_code'] = JUserHelper::genRandomPassword(); } $tsmart_departure_id = $departure_model->store($data); if (!$tsmart_departure_id) { echo $departure_model->getError(); die; } $item = $departure_model->getdeparture($tsmart_departure_id); if (!$item->tsmart_departure_parent_id) { $departure_model->create_children_departure($tsmart_departure_id); } echo json_encode($item); die; }
public static function edit_price_hotel_add_on($name, $data = '') { $doc = JFactory::getDocument(); $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/plugin/BobKnothe-autoNumeric/autoNumeric.js'); $doc->addScript(JUri::root() . '/media/system/js/jquery.utility.js'); $doc->addScript(JUri::root() . '/media/system/js/base64.js'); $doc->addScript(JUri::root() . "/media/system/js/cassandraMAP-cassandra/lib/cassandraMap.js"); $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/edit_price_hotel_add_on/html_edit_price_hotel_add_on.js'); $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/edit_price_hotel_add_on/html_edit_price_hotel_add_on.less'); $input = JFactory::getApplication()->input; $edit_price_add_on = 'edit_price_hotel_add_on_' . $name; $data1 = base64_decode($data); require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $data1 = up_json_decode($data1, false, 512, JSON_PARSE_JAVASCRIPT); $items = $data1->items; for ($i = 0; $i < count($items); $i++) { if ($i > 19) { unset($data1->items[$i]); } } ob_start(); ?> <script type="text/javascript"> jQuery(document).ready(function ($) { $('#<?php echo $edit_price_add_on; ?> ').html_edit_price_hotel_add_on({ output_name: "<?php echo $name; ?> ", <?php if ($data1) { ?> data:<?php echo json_encode($data1); ?> <?php } ?> }); }); </script> <?php $script_content = ob_get_clean(); $script_content = TSMUtility::remove_string_javascript($script_content); $doc->addScriptDeclaration($script_content); $list_room = array('single_room' => 'Single room', 'double_twin_room' => 'Double/twin room', 'triple_room' => 'Triple room'); ob_start(); ?> <div id="<?php echo $edit_price_add_on; ?> " class="edit-price-hotel-add-on"> <table> <thead> <tr> <th></th> <th>Net Price</th> <th>Mark up %</th> <th>Mark up amount</th> <th>Tax</th> <th>Sale price</th> </tr> </thead> <tbody> <?php foreach ($list_room as $key => $room) { ?> <tr class="item" data-key-room="<?php echo $key; ?> "> <td><span class="index"><?php echo $room; ?> </td> <td><input type="text" class="auto net-price" data-a-sign="US$ " placeholder="US$" data-v-min="0" data-v-max="999999"></td> <td><input type="text" class="auto mark-up-percent" data-a-sign="%" placeholder="%" data-v-min="0" data-v-max="100"></td> <td><input type="text" class="auto mark-up-amount" data-a-sign="US$ " placeholder="US$"></td> <td><input type="text" class="auto tax" data-a-sign="%" placeholder="%" data-v-min="0" data-v-max="100"></td> <td><input type="text" class="auto sale-price" readonly data-a-sign="US$ " placeholder="US$"> </td> </tr> <?php } ?> </tbody> </table> <input type="hidden" name="<?php echo $name; ?> " value="<?php echo $data; ?> "> </div> <?php $htm = ob_get_clean(); return $htm; }
JHtml::_('jquery.framework'); $doc = JFactory::getDocument(); JHtml::_('jquery.ui'); $doc->addScript(JUri::root() . '/media/system/js/datepicker/js/datepicker.js'); $doc->addScript(JUri::root() . '/media/system/js/jquery-dateFormat-master/src/dateFormat.js'); $doc->addScript(JUri::root() . '/media/system/js/jquery-dateFormat-master/src/jquery.dateFormat.js'); $doc->addScript(JUri::root() . '/media/system/js/cassandraMAP-cassandra/lib/cassandraMap.js'); $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/departure.js'); $doc->addStyleSheet(JUri::root() . '/media/system/js/datepicker/css/base.css'); $doc->addStyleSheet(JUri::root() . '/media/system/js/datepicker/css/clean.css'); $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/less/departure.less'); AdminUIHelper::startAdminArea($this); AdminUIHelper::imitateTabs('start', 'com_tsmart_CURRENCY_DETAILS'); require_once JPATH_ROOT . '/libraries/upgradephp-19/upgrade.php'; $list_data = $this->departure->days_seleted; $list_data = (array) up_json_decode($list_data, false, 512, JSON_PARSE_JAVASCRIPT); ?> <form action="index.php" method="post" name="adminForm" id="adminForm"> <div class="col50"> <div class="row-fluid"> <div class="span6 "> <table class="admintable table"> <tr> <td>Departure name</td> <td colspan="4"><input type="text" size="16" value="<?php echo $this->departure->departure_name; ?> " id="departure_name" required="true" name="departure_name" class="inputbox"></td>