/** * 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(); $comquick2cartHelper = new comquick2cartHelper(); // Getting user accessible store ids $storeList = $comquick2cartHelper->getStoreIds(); $options = array(); $app = JFactory::getApplication(); $jinput = $app->input; $zone_id = $jinput->get('id'); $defaultSstore_id = 0; if ($zone_id) { // Load Zone helper. $path = JPATH_SITE . DS . "components" . DS . "com_quick2cart" . DS . 'helpers' . DS . "zoneHelper.php"; if (!class_exists('zoneHelper')) { JLoader::register('zoneHelper', $path); JLoader::load('zoneHelper'); } $zoneHelper = new zoneHelper(); $defaultSstore_id = $zoneHelper->getZoneStoreId($zone_id); } 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', $defaultSstore_id, $control_name); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); if (!$user->id) { ?> <div class="<?php echo Q2C_WRAPPER_CLASS; ?> my-coupons"> <div class="well" > <div class="alert alert-error"> <span><?php echo JText::_('QTC_LOGIN'); ?> </span> </div> </div> </div> <?php return false; } $zoneHelper = new zoneHelper(); // Check whether view is accessible to user if (!$zoneHelper->isUserAccessible()) { return; } $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $app->getParams('com_quick2cart'); // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors)); } $this->publish_states = array('' => JText::_('JOPTION_SELECT_PUBLISHED'), '1' => JText::_('JPUBLISHED'), '0' => JText::_('JUNPUBLISHED')); // Get toolbar path $comquick2cartHelper = new comquick2cartHelper(); $this->toolbar_view_path = $comquick2cartHelper->getViewpath('vendor', 'toolbar'); // get store id (list))from model and pass to getManagecoupon() $this->store_role_list = $store_role_list = $comquick2cartHelper->getStoreIds(); if ($this->store_role_list) { $this->store_id = $store_id = !empty($change_storeto) ? $change_storeto : $store_role_list[0]['store_id']; $this->selected_store = $store_id; if ($this->store_id) { //$this->authorized_store_id= storeid of user $this->authorized_store_id = $authorized_store_id = $comquick2cartHelper->createCouponAuthority($store_id); } } // Setup TJ toolbar $this->addTJtoolbar(); $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { $comquick2cartHelper = new comquick2cartHelper(); $input = JFactory::getApplication()->input; $layout = $input->get('layout', 'default'); $option = $input->get('option', ''); $this->params = JFactory::getApplication()->getParams('com_quick2cart'); // check for multivender COMPONENT PARAM // vm: commented for task #20773 /* $isMultivenderOFFmsg=$comquick2cartHelper->isMultivenderOFF(); if(!empty($isMultivenderOFFmsg)) { print $isMultivenderOFFmsg; return false; }*/ if ($layout == 'default') { // product page //DECLARATION SECTION $this->client = $client = "com_quick2cart"; $this->pid = 0; $this->item_id = $item_id = $input->get('item_id', ''); JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); if (empty($item_id)) { // # if entry is not present in kart_item return false; } // retrun store_id,role etc with order by role,store_id $this->store_role_list = $comquick2cartHelper->getStoreIds(); // GETTING AUTHORIZED STORE ID $storeHelper = new storeHelper(); $this->store_list = $storeHelper->getuserStoreList(); // GETTING PRICE $this->price = $price = $model->getPrice($item_id, 1); // return array of price //GETTING ITEM COMPLEATE DETAIL (attributes and its option wil get) //$itemDetail=$model->getItemCompleteDetail($item_id); //getting stock min max,cat,store_id $this->itemdetail = $model->getItemRec($item_id); if (!empty($this->itemdetail)) { ///get attributes $this->attributes = $model->getAttributes($item_id); // for RELEATED PROD FROM CATEGORY $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php'; if (!class_exists('productHelper')) { //require_once $path; JLoader::register('productHelper', $product_path); JLoader::load('productHelper'); } $productHelper = new productHelper(); // get free products media file $this->mediaFiles = $productHelper->getProdmediaFiles($item_id); $this->prodFromCat = $productHelper->getSimilarProdFromCat($this->itemdetail->category, $this->item_id); $this->prodFromSameStore = $productHelper->prodFromSameStore($this->itemdetail->store_id, $this->item_id); $this->peopleAlsoBought = $productHelper->peopleAlsoBought($this->item_id); $this->peopleWhoBought = $productHelper->peopleWhoBought($this->item_id); //print_r($this->peopleWhoBought);die; $social_options = ''; $route = $comquick2cartHelper->getProductLink($this->item_id); // Jilke $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('onProductDisplaySocialOptions', array($this->item_id, 'com_quick2cart.productpage', $this->itemdetail->name, $route)); //Call the plugin and get the result if (!empty($result)) { $social_options = $result[0]; } $this->social_options = $social_options; $this->showBuyNowBtn = $productHelper->isInStockProduct($this->itemdetail); } } elseif ($layout == 'popupslide') { $this->item_id = $item_id = $input->get('qtc_prod_id', ''); JLoader::import('cart', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelcart(); if (empty($item_id)) { // # if entry is not present in kart_item return false; } $this->itemdetail = $model->getItemRec($item_id); } $this->item = $this->itemdetail; $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $input = $mainframe->input; $comquick2cartHelper = new comquick2cartHelper(); // check for multivender COMPONENT PARAM $isMultivenderOFFmsg = $comquick2cartHelper->isMultivenderOFF(); if (!empty($isMultivenderOFFmsg)) { print $isMultivenderOFFmsg; return false; } $option = $input->get('option'); $filter_order_Dir = $mainframe->getUserStateFromRequest("{$option}.filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $filter_type = $mainframe->getUserStateFromRequest("{$option}.filter_type", 'filter_type', 0, 'string'); $filter_state = $mainframe->getUserStateFromRequest($option . 'search_list', 'search_list', '', 'string'); $search = $mainframe->getUserStateFromRequest($option . 'search', 'search', '', 'string'); $search = JString::strtolower($search); $limit = ''; $limitstart = ''; $cid[0] = ''; if ($search == null) { $search = ''; } $edit = $input->get('edit', ''); $layout = $input->get('layout', ''); $cid = $input->get('cid', '', 'ARRAY'); $model = $this->getModel('Managecoupon'); // get store id (list))from model and pass to getManagecoupon() $this->store_role_list = $store_role_list = $comquick2cartHelper->getStoreIds(); // retrun store_id,role etc with order by role,store_id $change_store = $input->get->get('change_store', 0, 'INT'); // $this->authorized_store_id=$comquick2cartHelper->store_authorize("managecoupon_default",isset($change_storeto)?$change_storeto:$store_role_list[0]['store_id']); $this->store_id = $store_id = !empty($change_storeto) ? $change_storeto : $store_role_list[0]['store_id']; $this->selected_store = $store_id; // if user has store OR has ROLE to create then only create coupon or view list :: following coupon return store_id if EXIST if ($cid) { //$total = $this->get( 'Total'); $pagination = $this->get('Pagination'); $this->authorized_store_id = $authorized_store_id = $comquick2cartHelper->createCouponAuthority($store_id, $cid[0]); //$this->authorized_store_id= storeid of user $coupons = $model->Editlist($cid[0]); $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', 'limit', 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . 'limitstart', 'limitstart', 0, 'int'); $model->setState('limit', $limit); // Set the limit variable for query later on $model->setState('limitstart', $limitstart); } else { /************ list view and new *******************/ $this->authorized_store_id = $authorized_store_id = $comquick2cartHelper->createCouponAuthority($store_id); //$this->authorized_store_id= storeid of user if (!empty($authorized_store_id)) { if (!empty($store_id)) { $coupons = $model->getManagecoupon($store_id); //($authorized_store_id); $pagination = $model->getPagination($store_id); } /*if( !empty($change_storeto)) // fetch coupon list according to new store { $coupons = $model->getManagecoupon($change_storeto);//($authorized_store_id); $this->selected_store=$change_storeto; } else if( !empty($store_role_list)) { $this->selected_store=$store_role_list[0]['store_id']; $coupons = $model->getManagecoupon($store_role_list[0]['store_id']);//($authorized_store_id); }*/ } $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', 'limit', 'int'); $limitstart = $mainframe->getUserStateFromRequest($option . 'limitstart', 'limitstart', 0, 'int'); $model->setState('limit', $limit); // Set the limit variable for query later on $model->setState('limitstart', $limitstart); } // search filter $lists['search_select'] = $search; $lists['search'] = $search; $lists['search_list'] = $filter_state; $lists['order'] = $filter_type; $lists['order_Dir'] = $filter_order_Dir; $lists['limit'] = $limit; $lists['limitstart'] = $limitstart; // Get data from the model $this->assignRef('lists', $lists); $this->assignRef('pagination', $pagination); if (!empty($coupons)) { $this->assignRef('coupons', $coupons); } $this->_setToolBar(); parent::display($tpl); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $this->params = JComponentHelper::getParams('com_quick2cart'); $comquick2cartHelper = new comquick2cartHelper(); $storeHelper = new storeHelper(); $model = $this->getModel('vendor'); $mainframe = JFactory::getApplication(); $input = $mainframe->input; $option = $input->get('option'); $task = $input->get('task'); $layout = $input->get('layout', 'cp'); $this->adminCall = $adminCall = $input->get('adminCall', 0, 'INTEGER'); $store_id = $input->get('store_id', '0'); $this->storeinfo = ''; if ($layout != "contactus") { $specialAccess = 0; if ($layout == "createstore") { $user = JFactory::getUser(); if (!$user->id) { echo "<div class=\"techjoomla-bootstrap\" >\n\t\t\t\t\t<div class=\"well\" >\n\t\t\t\t\t\t<div class=\"alert alert-error\">\n\t\t\t\t\t\t\t<span >" . JText::_('QTC_LOGIN') . " </span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; return false; } if (!empty($adminCall)) { $specialAccess = $comquick2cartHelper->isSpecialAccess(); } } // Check for multivender COMPONENT PARAM $isMultivenderOFFmsg = $comquick2cartHelper->isMultivenderOFF(); if (!empty($isMultivenderOFFmsg)) { if (!empty($adminCall)) { // CALLED FROM ADMIN if ($specialAccess == 0) { echo $this->specialAccessMsg(); return false; } } else { print $isMultivenderOFFmsg; return false; } } } /*if($layout=="default") { $this->site=1; $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', 'desc', 'word' ); $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' ); $filter_state = $mainframe->getUserStateFromRequest( $option.'search_list', 'search_list', '', 'string' ); $search = $mainframe->getUserStateFromRequest( $option.'search', 'search','', 'string' ); $search = JString::strtolower( $search ); $limit = ''; $limitstart = ''; $cid[0]=''; if($search==null) $search=''; $model = $this->getModel( 'vendor' ); $task = $input->get('task'); $total = $model->getTotal(); $this->pagination = $pagination = $model->getPagination(); $this->storeinfo = $storeinfo = $comquick2cartHelper->getStoreDetail(); $lists['search_select'] = $search; $lists['search'] = $search; $lists['search_list'] = $filter_state; $lists['order'] = $filter_type; $lists['order_Dir'] = $filter_order_Dir; $lists['limit'] = $limit; $lists['limitstart'] = $limitstart; $this->lists = $lists; }// end of $layout=="mystores" if else */ if ($layout == "createstore") { $this->orders_site = 1; $store_id = $input->get('store_id', '0'); // DEFAULT ALLOW TO CREAT STORE $this->allowToCreateStore = 1; // Means edit task if (!empty($store_id)) { $this->store_authorize = $comquick2cartHelper->store_authorize("vendor_createstore", $store_id); $this->editview = 1; $this->storeinfo = $storeinfo = $comquick2cartHelper->editstore($store_id); // Get weight and length select box $this->legthList = $storeHelper->getLengthClassSelectList($storeid = 0, $this->storeinfo[0]->length_id); $this->weigthList = $storeHelper->getWeightClassSelectList($storeid = 0, $this->storeinfo[0]->weight_id); } else { // NEW STORE TASK:: CK FOR WHETHER WE HV TO ALLOW OR NOT $storeHelper = new storeHelper(); $this->allowToCreateStore = $storeHelper->isAllowedToCreateNewStore(); // Get weight and length select box $this->legthList = $storeHelper->getLengthClassSelectList($storeid = 0, 0); $this->weigthList = $storeHelper->getWeightClassSelectList($storeid = 0, 0); } // START Q2C Sample development $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('system'); $result = $dispatcher->trigger('qtcOnBeforeCreateStore', array($store_id)); // Call the plugin and get the result $beforecart = ''; $OnBeforeCreateStore = ''; if (!empty($result)) { // If more than one plugin returns // $OnBeforeCreateStore = $result[0]; // $OnBeforeCreateStore = join('', $result); $OnBeforeCreateStore = trim(implode("\n", $result)); } $this->OnBeforeCreateStore = $OnBeforeCreateStore; } elseif ($layout == "managestore") { $this->storeDetailInfo = $comquick2cartHelper->getSoreInfoInDetail($store_id); } elseif ($layout == "cp") { $this->catpage_Itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=category'); $this->orders_itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders'); $this->store_customers_itemid = $comquick2cartHelper->getitemid('index.php?option=com_quick2cart&view=orders&layout=mycustomer'); $user = JFactory::getUser(); if ($user->id) { // Chck whetere there is any product or not // Retrun store_id,role etc with order by role,store_id $this->store_role_list = $store_role_list = $comquick2cartHelper->getStoreIds(); // Store_id is changed from manage storeorder view $change_storeto = $input->get('change_store', ''); // When chage store,get latest storeid otherwise( on first load) set first storeid as default $firstStore = !empty($store_role_list[0]['store_id']) ? $store_role_list[0]['store_id'] : ''; $this->store_id = $store_id = !empty($change_storeto) ? $change_storeto : $firstStore; } if (!empty($this->store_id)) { $this->prodcountprodCount = $model->storeProductCount($this->store_id); // $allincome = $this->get( 'AllOrderIncome'); $this->getPeriodicIncomeGrapthData = $model->getPeriodicIncomeGrapthData($store_id); // Get revenue ,total order, and qty $this->getPeriodicIncome = $model->getPeriodicIncome($store_id); // GETTING TOATL SALES $this->totalSales = $model->getTotalSales($store_id); // GETTING TOtal orders $this->totalOrdersCount = $model->getTotalOrdersCount($store_id); // GETTING LAST 5 ORDERS $this->last5orders = $model->getLast5orders($store_id); // Getting store detail $this->storeDetailInfo = $comquick2cartHelper->getSoreInfoInDetail($store_id); // Get customer count for store. $this->storeCustomersCount = $model->getStoreCustomersCount($store_id); // Get top seller products. $product_path = JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'product.php'; if (!class_exists('productHelper')) { JLoader::register('productHelper', $product_path); JLoader::load('productHelper'); } $productHelper = new productHelper(); $this->topSellerProducts = $productHelper->getTopSellerProducts($store_id, '', 5); } } elseif ($layout == "store") { global $mainframe; $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; // Store_id is changed from STORE view // $change_storeto= $mainframe->getUserStateFromRequest( 'current_store', 'current_store','', 'INTEGER' ); $this->change_prod_cat = $jinput->get('store_cat', '', 'INTEGER'); // GET STORE ID $this->store_id = $store_id = $input->get('store_id'); // RESET ENTITIES // $mainframe->setUserState('store_cat', ''); if (!empty($this->store_id)) { $this->storeDetailInfo = $comquick2cartHelper->getSoreInfoInDetail($store_id); // ALL FETCH ALL CATEGORIES $storeHelper = new storeHelper(); $this->cats = $storeHelper->getStoreCats($this->store_id, $this->change_prod_cat, 1, 'store_cat'); // FETCH ALL STORE PRODUCT JLoader::import('store', JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'models'); $model = new Quick2cartModelstore(); $this->allStoreProd = $model->getAllStoreProducts('com_quick2cart', $this->store_id); $pagination = $model->getPagination('com_quick2cart', $this->store_id); $this->pagination = $pagination; } } elseif ($layout == "contactus") { $this->store_id = $input->get('store_id', '0', 'INTEGER'); $this->item_id = $input->get('item_id', '0', 'INTEGER'); } elseif ($layout == "storeinfo") { $this->store_id = $input->get('store_id'); if (!empty($this->store_id)) { $this->storeDetailInfo = $comquick2cartHelper->getSoreInfoInDetail($this->store_id); } } $this->_setToolBar(); parent::display($tpl); }
/** * Display the view * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return void */ public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = JComponentHelper::getParams('com_quick2cart'); $user = JFactory::getUser(); $this->logged_userid = $user->id; // Check for errors. $errors = $this->get('Errors'); if (count($errors)) { throw new Exception(implode("\n", $errors)); } $jinput = JFactory::getApplication()->input; $layout = $jinput->get('layout', 'default', 'STRING'); $option = $jinput->get('option', '', 'STRING'); $storeOwner = $jinput->get('qtcStoreOwner', 0, 'INTEGER'); $comquick2cartHelper = new comquick2cartHelper(); //$client='com_quick2cart'; //$client='*'; //$products = $model->getProducts($client); //Get all stores. $this->store_details = $comquick2cartHelper->getAllStoreDetails(); $this->categoryPage = 1; global $mainframe; $mainframe = JFactory::getApplication(); $model = $this->getModel('category'); //store_id is changed from STORE view $change_storeto = $mainframe->getUserStateFromRequest('$option.current_store', 'current_store', '', 'INTEGER'); $storeOwner = $jinput->get('qtcStoreOwner', 0, 'INTEGER'); // FOR STORE OWNER if (!empty($storeOwner)) { $storehelper = new storehelper(); $change_storeto = $storehelper->isVendorsStoreId($change_storeto); } $this->change_prod_cat = $mainframe->getUserStateFromRequest('prod_cat', 'prod_cat', '0', 'INTEGER'); //vm: #25029 $this->change_prod_cat = $jinput->get('prod_cat', 0, 'INTEGER'); // retrun store_id,role etc with order by role,store_id $this->store_role_list = $store_role_list = $comquick2cartHelper->getStoreIds(); $this->store_list = array(); foreach ($this->store_role_list as $store) { $this->store_list[] = $store['store_id']; } //$this->products = $model->getAllProducts(); $this->products = $this->items = $this->get('Items'); //$mainframe->setUserState('$option.current_store', '0'); // VM:commentted for store owner product view // when chage store,get latest storeid otherwise( on first load) set first storeid as default $this->store_id = $store_id = !empty($change_storeto) ? $change_storeto : ''; //$store_role_list[0]['store_id']; $pagination = $model->getPagination(); // ALL FETCH ALL CATEGORIES $this->cats = $comquick2cartHelper->getQ2cCatsJoomla($this->change_prod_cat); $this->pagination = $pagination; //Added by Sneha $filter_state = $mainframe->getUserStateFromRequest($option . 'search_list', 'search_list', '', 'string'); $lists['search_list'] = $filter_state; $this->assignRef('lists', $lists); //End added by Sneha $this->_setToolBar(); // Get toolbar path $this->toolbar_view_path = $comquick2cartHelper->getViewpath('vendor', 'toolbar'); if ($layout == 'my') { if (!$this->logged_userid) { $msg = JText::_('QTC_LOGIN'); $uri = JFactory::getApplication()->input->get('REQUEST_URI', '', 'server', 'string'); $url = base64_encode($uri); $mainframe->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url), $msg); } // Creating status filter. $statuses = array(); $statuses[] = JHtml::_('select.option', '', JText::_('COM_QUICK2CART_SELONE')); $statuses[] = JHtml::_('select.option', 1, JText::_('COM_QUICK2CART_PUBLISH')); $statuses[] = JHtml::_('select.option', 0, JText::_('COM_QUICK2CART_UNPUBLISH')); $this->statuses = $statuses; // Setup toolbar $this->addTJtoolbar(); } $this->_prepareDocument(); parent::display($tpl); }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__kart_coupon` AS a'); // Filter by published state. $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.published = ' . (int) $published); } elseif ($published === '') { $query->where('(a.published 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 . ' OR a.code LIKE ' . $search . ' OR a.value LIKE ' . $search . ' )'); } } // Filter by store. $filter_store = $this->state->get("filter.store"); // Get all stores by logged in user $comquick2cartHelper = new comquick2cartHelper(); $my_stores = $comquick2cartHelper->getStoreIds($user->id); if (count($my_stores)) { // Get all store ids foreach ($my_stores as $key => $value) { $stores[] = $value["store_id"]; } // If store filter is selected, check it in my stores array if ($filter_store) { if (in_array($filter_store, $stores)) { $query->where("a.store_id = '" . $db->escape($filter_store) . "'"); } } else { $stores = implode(',', $stores); if (!empty($stores)) { $query->where(" a.store_id IN (" . $stores . ")"); } } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // 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->from('`#__kart_taxrates` AS a'); // Get all rec that having store in store table. $query->select('z.name as zonename, z.store_id'); $query->select('s.title'); // Query $query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by'); $query->join('INNER', '#__kart_zone AS z ON z.id = a.zone_id'); $query->join('INNER', '#__kart_store AS s ON s.id = z.store_id'); // Getting user accessible store ids $comquick2cartHelper = new comquick2cartHelper(); $storeList = $comquick2cartHelper->getStoreIds(); $storeIds = array(); foreach ($storeList as $store) { $storeIds[] = $store['store_id']; } $accessibleStoreIds = ''; if (!empty($storeIds)) { $accessibleStoreIds = implode(',', $storeIds); $query->where('(z.store_id IN (' . $accessibleStoreIds . '))'); } // 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 . ' OR z.name LIKE ' . $search . ' )'); } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; }
class="input-large bill inputbox required validate-name" placeholder="<?php echo Jtext::_('PLG_QTC_DEFAULT_ZONESHIPPING_METH_NAME_TOOLTIP'); ?> " type="text" value="<?php echo !empty($shipFormData['name']) ? $shipFormData['name'] : ''; ?> "> </div> </div> <!-- STORE LIST --> <?php // Getting user accessible store ids $storeList = $comquick2cartHelper->getStoreIds(); $defaultSstore_id = !empty($shipFormData['store_id']) ? $shipFormData['store_id'] : ''; $options = array(); $options[] = JHtml::_('select.option', "", JText::_('PLG_QTC_DEFAULT_SELECT_STORE')); foreach ($storeList as $store) { $storename = ucfirst($store['title']); $options[] = JHtml::_('select.option', $store['store_id'], $storename); } ?> <div class="control-group"> <label for="qtcShipMethStoreId" class="control-label" title="<?php echo JText::_('PLG_QTC_DEFAULT_ZONESHIPPING_STORE_NAME_DESC'); ?> "> <?php echo JText::_('PLG_QTC_DEFAULT_ZONESHIPPING_STORE_NAME');
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); $jinput = JFactory::getApplication()->input; $layout = $jinput->get('layout', 'default', 'STRING'); // Select the required fields from the table. $query->select($this->getState('list.select', 'a.*')); $query->from('`#__kart_items` AS a'); $query->JOIN('LEFT', '`#__categories` AS c ON c.id=a.category'); // Filter by search in title. $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.item_id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('( a.name LIKE ' . $search . ')'); } } // Filter by published state. $published = $this->getState('filter.published'); if (is_numeric($published)) { $query->where('a.state = ' . (int) $published); } elseif ($published === '') { if ($layout == 'my') { $query->where('(a.state IN (0, 1))'); } else { $query->where('(a.state = 1)'); } } // Filter by category. $filter_menu_category = $this->state->get("filter.menu_category"); if ($filter_menu_category) { $filter_show_subcat_products = $this->state->get("filter.show_subcat_products"); if ($filter_show_subcat_products) { $catWhere = $this->getWhereCategory($filter_menu_category); if ($catWhere) { foreach ($catWhere as $cw) { $query->where($cw); } } } else { $query->where("a.category = '" . $db->escape($filter_menu_category) . "'"); } } else { $filter_category = $this->state->get("filter.category"); if ($filter_category) { $catWhere = $this->getWhereCategory($filter_category); if ($catWhere) { foreach ($catWhere as $cw) { $query->where($cw); } } } } if ($layout == 'default') { // Show only the native products and published category, $query->where(" c.published = 1"); $query->where(" a.parent = 'com_quick2cart'"); $storeHelper = new storeHelper(); $storeIds = $storeHelper->getStoreIds(1); if (!empty($storeIds)) { $storeidStr = implode(',', $storeIds); $query->where(" a.store_id IN (" . $storeidStr . ')'); } else { // If all stores are unpublished then dont show $query->where(" a.store_id = -1"); } $filter_category = $this->state->get("filter.category"); if ($filter_category) { // Show from decedor category $catWhere = $this->getWhereCategory($filter_category); if ($catWhere) { foreach ($catWhere as $cw) { $query->where($cw); } } } } else { // My stores view. // Filter by store. $filter_store = $this->state->get("filter.store"); // Get all published stores by logged in user $comquick2cartHelper = new comquick2cartHelper(); $my_stores = $comquick2cartHelper->getStoreIds($user->id); if (count($my_stores)) { // Get all store ids foreach ($my_stores as $key => $value) { $stores[] = $value["store_id"]; } // If store filter is selected, check it in my stores array if ($filter_store) { if (in_array($filter_store, $stores)) { $query->where("a.store_id = '" . $db->escape($filter_store) . "'"); } } else { // If selected store filter is not found in my stores array, show products from all stores for logged in user $stores = implode(',', $stores); if (!empty($stores)) { $query->where(" a.store_id IN (" . $stores . ")"); } } } else { // Unauthorized access $query->where(" a.store_id=0"); } } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; }
/** * FOR STORE OWNER :: ALL PRODUCT VIEW * This public function checks whether current_store is releated to logged in user (vendpor) * * @param integer $change_storeto store id. * * @since 2.2 * @return boolean. */ public function isVendorsStoreId($change_storeto) { $comquick2cartHelper = new comquick2cartHelper(); $store_role_list = $comquick2cartHelper->getStoreIds(); $store_list = array(); if (empty($store_role_list)) { return 0; } foreach ($store_role_list as $store) { $store_list[] = $store['store_id']; } // FOR STORE OWNER :: ALL PRODUCT VIEW, check change_storeto if (!in_array($change_storeto, $store_list)) { // Change store does not beloning to store owners then set vendors first store id as.. $change_storeto = $store_role_list[0]['store_id']; } elseif (empty($change_storeto)) { // If current_store=0 $change_storeto = $store_role_list[0]['store_id']; // Not previously set in main frame } return $change_storeto; }
/** * Method check whether view is accessible or not. * * @param string $view view name. * @param string $layout layout name. * @param string $viewTpe viewTpe. * * @since 2.2 * @return boolean true or false. */ public function isUserAccessible($view = '', $layout = "default", $viewTpe = "list") { $comquick2cartHelper = new comquick2cartHelper(); // Getting user accessible store ids @TO DO use store_authorize FUNCTIPN HERE $storeList = $comquick2cartHelper->getStoreIds(); if (empty($storeList)) { ?> <div class="<?php echo Q2C_WRAPPER_CLASS; ?> " > <div class="well" > <div class="alert alert-error"> <span ><?php echo JText::_('COM_QUICK2CART_TAXTRATES_S_STORE_NOT_FOUND'); ?> </span> </div> </div> </div> <?php return false; } return true; }