Example #1
0
 function ajax_get_list_state_by_country_id()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $tsmart_country_id = $input->get('tsmart_country_id', 0, 'int');
     require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmstates.php';
     $list_state = tmartstates::get_list_state_by_country_id($tsmart_country_id);
     echo json_encode($list_state);
     jexit();
 }
Example #2
0
 function display($tpl = null)
 {
     // Load the helper(s)
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = tmsModel::getModel();
     $config = JFactory::getConfig();
     $layoutName = vRequest::getCmd('layout', 'default');
     if ($layoutName == 'edit') {
         $cid = vRequest::getInt('cid');
         $task = vRequest::getCmd('task', 'add');
         if ($task != 'add' && !empty($cid) && !empty($cid[0])) {
             $cid = (int) $cid[0];
         } else {
             $cid = 0;
         }
         $model->setId($cid);
         $this->item = $model->getItem();
         $this->SetViewTitle('', $this->item->title);
         $this->addStandardEditViewCommands();
         //get state
         require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmstates.php';
         $states = tmartstates::get_states();
         $this->assignRef('states', $states);
         //end get state
     } else {
         $this->SetViewTitle();
         $this->addStandardDefaultViewCommandsEditInline(true, false, true);
         $this->addStandardDefaultViewLists($model, 0, 'ASC');
         //get state
         require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmstates.php';
         $list_state = tmartstates::get_states();
         $this->assignRef('list_state', $list_state);
         //end get state
         //get country
         require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
         $list_country = tsmcountries::get_countries();
         $this->assignRef('list_country', $list_country);
         //end get country
         $this->items = $model->getItemList(vRequest::getCmd('search', false));
         $this->pagination = $model->getPagination();
     }
     parent::display($tpl);
 }
Example #3
0
    public static function select_state_province($name, $list_state, $default = '0', $attrib = "onchange='submit();'", $key = 'value', $text = 'text', $country_element = '', $zero = true, $chosenDropDowns = true, $tranlsate = true)
    {
        $doc = JFactory::getDocument();
        $doc->addScript(JUri::root() . '/media/system/js/jquery.utility.js');
        $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/select_state_province/html_select_state_province.js');
        $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/js/controller/select_state_province/html_select_state_province.less');
        $input = JFactory::getApplication()->input;
        if (empty($list_state)) {
            require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmstates.php';
            $list_state = tmartstates::get_states();
        }
        ob_start();
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function ($) {
                $('select[name="<?php 
        echo $name;
        ?>
"]').html_select_state_province({
                    state_element: '<?php 
        echo $country_element;
        ?>
',
                    tsmart_state_id:<?php 
        echo $default;
        ?>
                });
            });
        </script>
        <?php 
        $script_content = ob_get_clean();
        $script_content = TSMUtility::remove_string_javascript($script_content);
        $doc->addScriptDeclaration($script_content);
        if ($zero == true) {
            $option = array($key => "0", $text => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'));
            $list_state = array_merge(array($option), $list_state);
        }
        if ($chosenDropDowns) {
            vmJsApi::chosenDropDowns();
            $attrib .= ' class="vm-chzn-select"';
        }
        return VmHtml::genericlist($list_state, $name, $attrib, $key, $text, $default, false, $tranlsate);
    }