public static function select_service_class($list_service_class = array(), $name, $default = '0', $attrib = "onchange='submit();'", $zero = true, $chosenDropDowns = true, $tranlsate = true) { $doc = JFactory::getDocument(); $doc->addScript(JUri::root() . '/media/system/js/jquery.utility.js'); $doc->addScript(JUri::root() . '/media/system/js/select2-master/dist/js/select2.full.js'); $doc->addStyleSheet(JUri::root() . '/media/system/js/select2-master/dist/css/select2.css'); $doc->addScript(JUri::root() . 'administrator/components/com_tsmart/assets/js/controller/select_service_class/html_select_language.js'); $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/select_service_class/html_select_service_class.less'); $input = JFactory::getApplication()->input; if (empty($list_service_class)) { require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $list_service_class = tsmserviceclass::get_list_service_class(); } $id_element = 'html_select_service_class_' . $name; ob_start(); ?> <script type="text/javascript"> jQuery(document).ready(function ($) { $('#<?php echo $id_element; ?> ').html_select_service_class({ list_tour:<?php echo json_encode($list_service_class); ?> , select_name: "<?php echo $name; ?> ", tsmart_language_id:<?php echo $default ? $default : 0; ?> }); }); </script> <?php $script_content = ob_get_clean(); $script_content = TSMUtility::remove_string_javascript($script_content); $doc->addScriptDeclaration($script_content); ob_start(); ?> <div id="<?php echo $id_element; ?> "> <select disable_chosen="true" id="<?php echo $name; ?> " name="<?php echo $name; ?> "> <option value=""><?php echo JText::_('please select Service class'); ?> </option> <?php foreach ($list_service_class as $service_class) { ?> <option <?php echo $service_class->tsmart_service_class_id == $default ? ' selected ' : ''; ?> value="<?php echo $service_class->tsmart_service_class_id; ?> "><?php echo $service_class->service_class_name; ?> </option> <?php } ?> </select> </div> <?php $html = ob_get_clean(); return $html; }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model_promotion_price = tmsModel::getModel(); $app = JFactory::getApplication(); $input = $app->input; $config = JFactory::getConfig(); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $this->list_service_class = tsmserviceclass::get_list_service_class(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $tsmart_product_id = $input->get('tsmart_product_id', 0, 'int'); $this->tsmart_product_id = $tsmart_product_id; require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $this->list_group_size_by_tour_id = vmprice::get_list_group_size_by_tour_id($tsmart_product_id); $cid = vRequest::getInt('cid'); $model_product = tmsModel::getModel('product'); $this->product = $model_product->getProduct($this->tsmart_product_id, false, false, false); if ($this->product->tour_methor == 'tour_group') { $this->list_tour_price_by_tour_price_id = vmprice::get_list_tour_price_by_tour_price_id($cid[0]); } else { $this->tour_private_price_by_tour_price_id = vmprice::get_list_tour_price_by_tour_price_id_for_price($cid[0]); } $task = vRequest::getCmd('task', 'add'); if ($task != 'add' && !empty($cid) && !empty($cid[0])) { $cid = (int) $cid[0]; } else { $cid = 0; } $model_promotion_price->setId($cid); $this->price = $model_promotion_price->get_promotion_price(); $model_product = tmsModel::getModel('product'); $this->list_tour = $model_product->getProductListing(); $this->SetViewTitle('', $this->promotion->promotion_name); $this->addStandardEditViewCommands(); } else { require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $tsmart_product_id = $input->get('tsmart_product_id', 0, 'int'); $this->tsmart_product_id = $tsmart_product_id; $model_product = tmsModel::getModel('product'); $this->list_tour = $model_product->getItems(); $this->product = $model_product->getItem($this->tsmart_product_id); $tsmart_price_id = $input->get('tsmart_price_id', 0, 'int'); $model_promotion_price->setId($tsmart_price_id); $this->price = $model_promotion_price->get_promotion_price(); //get markup $this->list_mark_up = vmprice::get_list_mark_up_by_tour_price_id($tsmart_price_id); $this->list_mark_up = JArrayHelper::pivot($this->list_mark_up, 'type'); //end get markup require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $this->list_group_size_by_tour_id = vmprice::get_list_group_size_by_tour_id($tsmart_product_id); $this->SetViewTitle(); $this->addStandardDefaultViewLists($model_promotion_price, 0, 'ASC'); $this->addStandardDefaultViewCommandspromotion(); $model_tourclass = tmsModel::getModel('tourclass'); $this->list_service_class_by_tour_id = $model_tourclass->getItems(); $this->promotion_prices = $model_promotion_price->get_list_promotion_price($tsmart_product_id); //$this->prices=JArrayHelper::pivot($this->prices,'service_class_name'); } parent::display($tpl); }