/**
  * Fetch custom Element view.
  *
  * @param   string  $name          Field Name.
  * @param   mixed   $value         Field value.
  * @param   mixed   $node          Field node.
  * @param   mixed   $control_name  Field control_name/Id.
  *
  * @since   2.2
  * @return   null
  */
 public function fetchElement($name, $value, $node, $control_name)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     // While edit: get profile store id
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $id = $jinput->get('id');
     $defaultStore_id = 0;
     // Load tax helper.
     $path = JPATH_SITE . DS . "components" . DS . "com_quick2cart" . DS . 'helpers' . DS . "taxHelper.php";
     if (!class_exists('taxHelper')) {
         JLoader::register('taxHelper', $path);
         JLoader::load('taxHelper');
     }
     $taxHelper = new taxHelper();
     if ($id) {
         $defaultStore_id = $taxHelper->getTaxProfileStoreId($id);
     }
     $storeList = $taxHelper->getStoreListForTaxprofile();
     $options = array();
     foreach ($storeList as $store) {
         $storename = ucfirst($store['title']);
         $options[] = JHtml::_('select.option', $store['store_id'], $storename);
     }
     $fieldName = $name;
     return JHtml::_('select.genericlist', $options, $fieldName, 'class="inputbox required"  size="1"  ', 'value', 'text', $defaultStore_id, $control_name);
 }
Exemplo n.º 2
0
 /**
  * Build an SQL query to load the list data.
  *
  * @return  JDatabaseQuery
  *
  * @since   1.6
  */
 protected function getListQuery()
 {
     $taxHelper = new taxHelper();
     // Getting user accessible store ids
     $storeList = $taxHelper->getStoreListForTaxprofile();
     $storeIds = array();
     foreach ($storeList as $store) {
         $storeIds[] = $store['store_id'];
     }
     $accessibleStoreIds = '';
     if (!empty($storeIds)) {
         $accessibleStoreIds = implode(',', $storeIds);
     }
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.*'));
     $query->select('s.title as storeName');
     $query->from('`#__kart_taxprofiles` AS a');
     $query->JOIN('INNER', ' `#__kart_store` AS s ON s.id=a.store_id');
     if (!empty($accessibleStoreIds)) {
         $query->where('(a.store_id IN (' . $accessibleStoreIds . '))');
     } else {
         // If tax rates are not set then Dont fetch data;
         $query->where('a.store_id = -1');
     }
     // Filter by published state
     $published = $this->getState('filter.state');
     if (is_numeric($published)) {
         $query->where('a.state = ' . (int) $published);
     } elseif ($published === '') {
         $query->where('(a.state IN (0, 1))');
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->Quote('%' . $db->escape($search, true) . '%');
             $query->where('( a.name LIKE ' . $search . ')');
         }
     }
     return $query;
 }