/** * Retireve a list of coupons from the database. * * @return object List of coupon objects */ function getCoupons() { $virtuemart_vendor_id = vmAccess::getVendorId(); $whereString = ''; if (!empty($virtuemart_vendor_id)) { $whereString = 'WHERE virtuemart_vendor_id="' . $virtuemart_vendor_id . '"'; } return $this->_data = $this->exeSortSearchListQuery(0, '*', ' FROM `#__virtuemart_coupons`', $whereString, '', $this->_getOrdering()); }
/** * Select the products to list on the product list page */ public function getRatings() { $tables = ' FROM `#__virtuemart_ratings` AS `r` JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` AS `pr` USING (`virtuemart_product_id`) '; $whereString = ''; if (VmConfig::get('multix', 'none') != 'none') { $tables .= ' LEFT JOIN `#__virtuemart_products` as p USING (`virtuemart_product_id`)'; $virtuemart_vendor_id = vmAccess::getVendorId(); if (!empty($virtuemart_vendor_id)) { $whereString = ' WHERE virtuemart_vendor_id="' . $virtuemart_vendor_id . '"'; } } $this->_data = $this->exeSortSearchListQuery(0, ' r.*,pr.`product_name` ', $tables, $whereString, '', $this->_getOrdering()); return $this->_data; }
function display($tpl = null) { // Get the task $task = vRequest::getCmd('task', $this->getLayout()); $this->assignRef('task', $task); // Load helpers if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } $model = tmsModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': //this was in the controller for the edit tasks, we need this for the access by FE //$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl'); tsmConfig::loadJLang('com_tsmart_orders', TRUE); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); $model_country = tmsModel::getModel('country'); $this->countries = $model_country->getItemList(); $tsmart_product_id = vRequest::getInt('tsmart_product_id'); if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) { $tsmart_product_id = (int) $tsmart_product_id[0]; } else { $tsmart_product_id = (int) $tsmart_product_id; } $product = $model->getItem($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id); //$user = JFactory::getUser(); $superVendor = vmAccess::isSuperVendor(); if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) { vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id); JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error'); } if (!empty($product->product_parent_id)) { $product_parent = $model->getProductSingle($product->product_parent_id, false); } require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $this->tour_service_class = tsmserviceclass::get_list_tour_service_class(); $customfields = tmsModel::getModel('Customfields'); $product->allIds[] = $product->tsmart_product_id; if (!empty($product->product_parent_id)) { $product->allIds[] = $product->product_parent_id; } $product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds); // Get the category tree if (isset($product->categories)) { $this->category_tree = ShopFunctions::categoryListTree($product->categories); } else { $this->category_tree = ShopFunctions::categoryListTree(); } //Fallback for categories inherited by parent to correctly calculate the prices if (empty($product->categories) and !empty($product_parent->categories)) { $product->categories = $product_parent->categories; } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (!isset($product->shoppergroups)) { $product->shoppergroups = 0; } $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); // Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } //Do we need the children? If there is a C customfield, we dont want them $isCustomVariant = false; foreach ($product->customfields as $custom) { if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) { $isCustomVariant = true; break; } } if (!class_exists('tsmartModelConfig')) { require VMPATH_ADMIN . '/models/config.php'; } $productLayouts = tsmartModelConfig::getLayoutList('productdetails'); $this->productLayouts = $productLayouts; // Load Images $model->addImages($product); if (!class_exists('VmTemplate')) { require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php'; } $vmtemplate = VmTemplate::loadVmTemplateStyle(); $this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate); // Load the vendors $vendor_model = tmsModel::getModel('vendor'); $lists['vendors'] = ''; if ($this->showVendors()) { $lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id); } // Load the currencies $currency_model = tmsModel::getModel('currency'); $vendor_model->setId(vmAccess::isSuperVendor()); $this->vendor = $vendor_model->getVendor(); $currency = $currency_model->getItemList(); $this->vendor_currency_symb = $currency->currency_symbol; $lists['manufacturers'] = shopFunctions::renderManufacturerList($product->tsmart_manufacturer_id, true); if (!empty($product->product_weight_uom)) { $product_weight_uom = $product->product_weight_uom; } else { if (!empty($product_parent)) { $product_weight_uom = $product_parent->product_weight_uom; } else { $product_weight_uom = tsmConfig::get('weight_unit_default'); } } if (!empty($product->product_lwh_uom)) { $product_lwh_uom = $product->product_lwh_uom; } else { if (!empty($product_parent)) { $product_lwh_uom = $product_parent->product_lwh_uom; } else { $product_lwh_uom = tsmConfig::get('lwh_unit_default'); } } if (!empty($product->product_unit)) { $product_unit = $product->product_unit; } else { if (!empty($product_parent)) { $product_unit = $product_parent->product_unit; } else { $product_unit = tsmConfig::get('product_unit_default', 'KG'); } } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom); if (empty($product->product_available_date)) { $product->product_available_date = date("Y-m-d"); } $waitinglistmodel = tmsModel::getModel('waitinglist'); /* Load waiting list */ if ($product->tsmart_product_id) { //$waitinglist = $this->get('waitingusers', 'waitinglist'); $waitinglist = $waitinglistmodel->getWaitingusers($product->tsmart_product_id); $this->assignRef('waitinglist', $waitinglist); } $orderstatusModel = tmsModel::getModel('orderstatus'); $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE); // Add the tsmart_shoppergroup_ids $cid = JFactory::getUser()->id; $this->activeShoppergroups = shopfunctions::renderGuiList($cid, 'shoppergroups', 'shopper_group_name', 'category', 'vmuser_shoppergroups', 'tsmart_user_id'); if (!empty($this->activeShoppergroups)) { $shoppergroupModel = tmsModel::getModel('shoppergroup'); $this->activeShoppergroups = tsmText::_($shoppergroupModel->getDefault(0)->shopper_group_name); } // Load protocustom lists $customModel = tmsModel::getModel('custom'); $this->fieldTypes = tsmartModelCustom::getCustomTypes(); $customsList = $customModel->getCustomsList(); $attribs = 'style= "width: 300px;"'; $customlist = JHtml::_('select.genericlist', $customsList, 'customlist', $attribs, 'value', 'text', null, false, true); $this->assignRef('customsList', $customlist); if ($product->product_parent_id > 0) { // Set up labels $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_ITEM_MSG'); } else { if ($task == 'add') { $action = tsmText::_('com_tsmart_PRODUCT_FORM_NEW_PRODUCT_LBL'); } else { $action = tsmText::_('com_tsmart_PRODUCT_FORM_UPDATE_ITEM_LBL'); } $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_INFO_LBL'); $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_STATUS_LBL'); $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL'); $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_IMAGES_LBL'); $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_PRODUCT_MSG'); } //get countries require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $countries = tsmcountries::get_countries(); $this->assignRef('countries', $countries); //end get countries //get cities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmcities.php'; $cities = tsmcities::get_cities(); $this->assignRef('cities', $cities); //end get cities //get tour style require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourstyle.php'; $list_tour_style = tsmtourstyle::get_list_tour_style(); $this->assignRef('list_tour_style', $list_tour_style); //end get toursyle //get tour section require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtoursection.php'; $list_tour_section = tsmtoursection::get_list_tour_section(); $this->assignRef('list_tour_section', $list_tour_section); //end get toursyle //get tour physicalgrade require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmphysicalgrade.php'; $list_physical_grade = vmphysicalgrade::get_physical_grade(); $this->assignRef('list_physical_grade', $list_physical_grade); //end get physicalgrade //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourtype.php'; $list_tour_type = tsmtourtype::get_list_tour_type(); $this->assignRef('list_tour_type', $list_tour_type); //end get tour_type //get tour_type require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php'; $list_tour_service_class = tsmserviceclass::get_list_tour_service_class(); $product->list_tour_service_class_id = tsmserviceclass::get_list_service_class_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_tour_service_class', $list_tour_service_class); //end get tour_type //get activities require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmactivities.php'; $product->list_activity_id = tsmactivities::get_list_activity_id_by_tour_id($product->tsmart_product_id); $activities = tsmactivities::get_activities(); $this->assignRef('activities', $activities); //end get activities //get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php'; $list_group_size = tsmGroupSize::get_list_group_size(); $product->list_group_size_id = tsmGroupSize::get_list_group_size_ids_by_tour_id($product->tsmart_product_id); $this->assignRef('list_group_size', $list_group_size); //end get list group size //get list country require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php'; $product->list_tsmart_country_id = tsmcountries::get_list_tsmart_country_id_by_tour_id($product->tsmart_product_id); //end get list group size require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php'; $this->list_price_type = vmprice::get_list_price_type(); require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php'; $this->list_tour_method = vmproduct::get_list_tour_method(); $this->assignRef('product', $product); $this->assignRef('product_parent', $product_parent); /* Assign label values */ $this->assignRef('action', $action); $this->assignRef('info_label', $info_label); $this->assignRef('status_label', $status_label); $this->assignRef('dim_weight_label', $dim_weight_label); $this->assignRef('images_label', $images_label); $this->assignRef('delete_message', $delete_message); $this->assignRef('lists', $lists); // Toolbar if ($product->product_sku) { $sku = ' (' . $product->product_sku . ')'; } else { $sku = ""; } //if (!empty($product->canonCatLink)) $canonLink = '&tsmart_category_id=' . $product->canonCatLink; else $canonLink = ''; if (!empty($product->tsmart_product_id)) { if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag()); $canonLink = ''; if ($product->canonCatId) { $canonLink = '&tsmart_category_id=' . $product->canonCatId; } $text = '<a href="' . juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE_TO_PRODUCT', juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID); } } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); $this->addStandardEditViewCommandsNoValidate($product->tsmart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); $showVendors = $this->showVendors(); $this->assignRef('showVendors', $showVendors); $keyWord = ''; $catmodel = tmsModel::getModel('category'); $this->assignRef('catmodel', $catmodel); $this->addStandardDefaultViewCommandsNoValidate(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $session = JFactory::getSession(); $reset = $session->get('reset_pag', false, 'vm'); $limit = ''; if ($reset) { $limit = 0; $session->set('reset_pag', false, 'vm'); } $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search'], $limit); $catpagination = $catmodel->getPagination(); $this->assignRef('catpagination', $catpagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_CAT_EXE'), false); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $sgrpmodel = tmsModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->assignRef('shoppergroups', $shoppergroups); $sgrppagination = $sgrpmodel->getPagination(); $this->assignRef('sgrppagination', $sgrppagination); $this->setLayout('massxref'); JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_SGRPS_EXE'), false); break; default: if ($product_parent_id = vRequest::getInt('product_parent_id', false)) { $product_parent = $model->getProductSingle($product_parent_id, false); if ($product_parent) { $title = 'PRODUCT_CHILDREN_LIST'; $link_to_parent = JHtml::_('link', JRoute::_('index.php?view=product&task=edit&tsmart_product_id=' . $product_parent->tsmart_product_id . '&option=com_tsmart'), $product_parent->product_name, array('title' => tsmText::_('com_tsmart_EDIT_PARENT') . ' ' . $product_parent->product_name)); $msg = tsmText::_('com_tsmart_PRODUCT_OF') . " " . $link_to_parent; } else { $title = 'PRODUCT_CHILDREN_LIST'; $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found'; } } else { $title = 'PRODUCT'; $msg = ""; } $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on'); if ($cI = vRequest::getInt('tsmart_category_id', false)) { $app = JFactory::getApplication(); //$old_state = $app->getUserState('tsmart_category_id'); $old_state = $app->getUserState('tsmart_category_id'); if (empty($old_state) or $old_state != $cI) { vRequest::setVar('com_tsmart.product.filter_order', 'pc.ordering'); $model->filter_order = 'pc.ordering'; $old_state = $app->setUserState('tsmart_category_id', $cI); } } //Get the list of products $productlist = $model->getItemList(); //The pagination must now always set AFTER the model load the listing $this->pagination = $model->getPagination(); //Get the category tree $categoryId = $model->tsmart_category_id; //OSP switched to filter in model, was vRequest::getInt('tsmart_category_id'); $category_tree = ShopFunctions::categoryListTree(array($categoryId)); $this->assignRef('category_tree', $category_tree); //load service class //Load the product price if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $vendor_model = tmsModel::getModel('vendor'); $productreviews = tmsModel::getModel('ratings'); $this->mfTable = $model->getTable('manufacturers'); $this->catTable = $model->getTable('categories'); $this->lists['vendors'] = ''; if ($this->showVendors()) { $this->lists['vendors'] = Shopfunctions::renderVendorList(vmAccess::getVendorId()); } foreach ($productlist as $tsmart_product_id => $product) { $product->mediaitems = count($product->tsmart_media_id); $product->reviews = $productreviews->countReviewsForProduct($product->tsmart_product_id); $vendor_model->setId($product->tsmart_vendor_id); $vendor = $vendor_model->getVendor(); $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->tsmart_vendor_id); if (!empty($product->allPrices[$product->selectedPrice]['product_price']) && !empty($product->allPrices[$product->selectedPrice]['product_currency'])) { $product->product_price_display = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['product_price'], (int) $product->allPrices[$product->selectedPrice]['product_currency'], 1, true); } else { if (!empty($product->allPrices) and count($product->allPrices) > 1) { $product->product_price_display = tsmText::_('com_tsmart_MULTIPLE_PRICES'); } else { $product->product_price_display = tsmText::_('com_tsmart_NO_PRICE_SET'); } } // Write the first 5 categories in the list $product->categoriesList = ''; if (!empty($product->categories[0])) { $product->categoriesList = shopfunctions::renderGuiList($product->categories, 'categories', 'category_name', 'category'); } // Write the first 5 manufacturers in the list $product->manuList = ''; if (!empty($product->tsmart_manufacturer_id[0])) { $product->manuList = shopfunctions::renderGuiList($product->tsmart_manufacturer_id, 'manufacturers', 'mf_name', 'manufacturer'); } } $mf_model = tmsModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown(); $this->assignRef('manufacturers', $manufacturers); /* add Search filter in lists*/ /* Search type */ $options = array('' => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'), 'parent' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE')); $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options); /* Search order */ $options = array('bf' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')); $this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'), $options); // Toolbar /*if (vmAccess::manager('product.edit')) { JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_CAT'), true); JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_SGRPS'), true); } if (vmAccess::manager('product.create')) { JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('com_tsmart_PRODUCT_CHILD'), true); JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('com_tsmart_PRODUCT_CLONE'), true); }*/ // JToolBarHelper::custom('addrating', 'default', '', vmText::_('com_tsmart_ADD_RATING'), true); $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart')); JToolBarHelper::divider(); if (vmAccess::manager($view . '.edit.state')) { JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); } if (vmAccess::manager($view . '.delete')) { JToolBarHelper::spacer('10'); JToolBarHelper::deleteList(); } $this->assignRef('productlist', $productlist); $this->assignRef('tsmart_category_id', $categoryId); $this->assignRef('model', $model); break; } parent::display($tpl); }
: <input type="text" name="filter_ratings" value="<?php echo vRequest::getVar('filter_ratings', ''); ?> " /> <button class="btn btn-small" onclick="this.form.submit();"><?php echo vmText::_('COM_VIRTUEMART_GO'); ?> </button> <button class="btn btn-small" onclick="document.adminForm.filter_ratings.value='';"><?php echo vmText::_('COM_VIRTUEMART_RESET'); ?> </button> <?php if (VmConfig::get('multix', 'none') != 'none') { echo Shopfunctions::renderVendorList(vmAccess::getVendorId()); } ?> </td> </tr> </table> </div> <div id="resultscounter" ><?php echo $this->pagination->getResultsCounter(); ?> </div> </div> <div style="text-align: left;"> <table class="adminlist table table-striped" cellspacing="0" cellpadding="0"> <thead>
/** * New function for sorting, searching, filtering and pagination for product ids. * * @author Max Milbers */ function sortSearchListQuery($onlyPublished = TRUE, $virtuemart_category_id = FALSE, $group = FALSE, $nbrReturnProducts = FALSE, $langFields = array()) { $app = JFactory::getApplication(); $db = JFactory::getDbo(); //User Q.Stanley said that removing group by is increasing the speed of product listing in a bigger shop (10k products) by factor 60 //So what was the reason for that we have it? TODO experiemental, find conditions for the need of group by $groupBy = ' group by p.`virtuemart_product_id` '; //administrative variables to organize the joining of tables $joinLang = false; $joinCategory = FALSE; $joinCatLang = false; $joinMf = FALSE; $joinMfLang = false; $joinPrice = FALSE; $joinCustom = FALSE; $joinShopper = FALSE; $joinChildren = FALSE; //$joinLang = false; $orderBy = ' '; $where = array(); //$isSite = $app->isSite (); $isSite = true; if ($app->isAdmin() or vRequest::get('manage', false) and vmAccess::getVendorId()) { $isSite = false; } if (!empty($this->keyword) and $this->keyword !== '' and $group === FALSE) { $keyword = vRequest::filter(html_entity_decode($this->keyword, ENT_QUOTES, "UTF-8"), FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW); $keyword = '"%' . str_replace(array(' ', '-'), '%', $keyword) . '%"'; //$keyword = '"%' . $db->escape ($this->keyword, TRUE) . '%"'; vmdebug('Current search field', $this->valid_search_fields); foreach ($this->valid_search_fields as $searchField) { if ($searchField == 'category_name' || $searchField == 'category_description') { $joinCatLang = true; } else { if ($searchField == 'mf_name') { $joinMfLang = true; } else { if ($searchField == 'product_price') { $joinPrice = TRUE; } else { if ($searchField == 'product_name' or $searchField == 'product_s_desc' or $searchField == 'product_desc' or $searchField == 'slug') { $langFields[] = $searchField; //if (strpos ($searchField, '`') !== FALSE){ //$searchField = '`l`.'.$searchField; $keywords_plural = preg_replace('/\\s+/', '%" AND ' . $searchField . ' LIKE "%', $keyword); if ($app->isSite() and VmConfig::$defaultLang != VmConfig::$vmlang and !VmConfig::get('prodOnlyWLang', false)) { $filter_search[] = '`ld`.' . $searchField . ' LIKE ' . $keywords_plural; if (VmConfig::$defaultLang != VmConfig::$jDefLang) { $filter_search[] = '`ljd`.' . $searchField . ' LIKE ' . $keywords_plural; } } $searchField = '`l`.' . $searchField; //} } } } } if (strpos($searchField, '`') !== FALSE) { $keywords_plural = preg_replace('/\\s+/', '%" AND ' . $searchField . ' LIKE "%', $keyword); $filter_search[] = $searchField . ' LIKE ' . $keywords_plural; } else { $keywords_plural = preg_replace('/\\s+/', '%" AND `' . $searchField . '` LIKE "%', $keyword); $filter_search[] = '`' . $searchField . '` LIKE ' . $keywords_plural; //$filter_search[] = '`' . $searchField . '` LIKE ' . $keyword; } } if (!empty($filter_search)) { $where[] = '(' . implode(' OR ', $filter_search) . ')'; } else { $where[] = '`l`.product_name LIKE ' . $keyword; $langFields[] = 'product_name'; //If they have no check boxes selected it will default to product name at least. } } // vmdebug('my $this->searchcustoms ',$this->searchcustoms); if (!empty($this->searchcustoms)) { $joinCustom = TRUE; foreach ($this->searchcustoms as $key => $searchcustom) { $custom_search[] = '(pf.`virtuemart_custom_id`="' . (int) $key . '" and pf.`customfield_value` like "%' . $db->escape($searchcustom, TRUE) . '%")'; } $where[] = " ( " . implode(' OR ', $custom_search) . " ) "; } if ($isSite and !VmConfig::get('use_as_catalog', 0)) { if (VmConfig::get('stockhandle', 'none') == 'disableit_children') { $where[] = ' ( (p.`product_in_stock` - p.`product_ordered`) >"0" OR (children.`product_in_stock` - children.`product_ordered`) > "0") '; $joinChildren = TRUE; } else { if (VmConfig::get('stockhandle', 'none') == 'disableit') { $where[] = ' p.`product_in_stock` - p.`product_ordered` >"0" '; } } } if ($virtuemart_category_id > 0) { $joinCategory = TRUE; $where[] = ' `pc`.`virtuemart_category_id` = ' . $virtuemart_category_id; } else { if ($isSite) { if (!VmConfig::get('show_uncat_parent_products', TRUE)) { $joinCategory = TRUE; $where[] = ' ((p.`product_parent_id` = "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` > "0") '; } if (!VmConfig::get('show_uncat_child_products', TRUE)) { $joinCategory = TRUE; $where[] = ' ((p.`product_parent_id` > "0" AND `pc`.`virtuemart_category_id` > "0") OR p.`product_parent_id` = "0") '; } } } if ($isSite and !VmConfig::get('show_unpub_cat_products', TRUE)) { $joinCategory = TRUE; $where[] = ' `c`.`published` = 1 '; } if ($this->product_parent_id) { $where[] = ' p.`product_parent_id` = ' . $this->product_parent_id; } if ($isSite) { $usermodel = VmModel::getModel('user'); $currentVMuser = $usermodel->getCurrentUser(); $virtuemart_shoppergroup_ids = (array) $currentVMuser->shopper_groups; if (is_array($virtuemart_shoppergroup_ids)) { $sgrgroups = array(); foreach ($virtuemart_shoppergroup_ids as $key => $virtuemart_shoppergroup_id) { $sgrgroups[] = '`ps`.`virtuemart_shoppergroup_id`= "' . (int) $virtuemart_shoppergroup_id . '" '; } $sgrgroups[] = '`ps`.`virtuemart_shoppergroup_id` IS NULL '; $where[] = " ( " . implode(' OR ', $sgrgroups) . " ) "; $joinShopper = TRUE; } } if ($this->virtuemart_manufacturer_id) { $joinMf = TRUE; if (is_array($this->virtuemart_manufacturer_id)) { $mans = array(); foreach ($this->virtuemart_manufacturer_id as $key => $v) { $mans[] = '`#__virtuemart_product_manufacturers`.`virtuemart_manufacturer_id`= "' . (int) $v . '" '; } $where[] = " ( " . implode(' OR ', $mans) . " ) "; } else { $where[] = ' `#__virtuemart_product_manufacturers`.`virtuemart_manufacturer_id` = ' . $this->virtuemart_manufacturer_id; //$virtuemart_manufacturer_id = $this->virtuemart_manufacturer_id; } } // Time filter if ($this->search_type != '') { $search_order = $db->escape(vRequest::getCmd('search_order') == 'bf' ? '<' : '>'); switch ($this->search_type) { case 'parent': $where[] = 'p.`product_parent_id` = "0"'; break; case 'product': $where[] = 'p.`modified_on` ' . $search_order . ' "' . $db->escape(vRequest::getVar('search_date')) . '"'; break; case 'price': $joinPrice = TRUE; $where[] = 'pp.`modified_on` ' . $search_order . ' "' . $db->escape(vRequest::getVar('search_date')) . '"'; break; case 'withoutprice': $joinPrice = TRUE; $where[] = 'pp.`product_price` IS NULL'; break; case 'stockout': $where[] = ' p.`product_in_stock`- p.`product_ordered` < 1'; break; case 'stocklow': $where[] = 'p.`product_in_stock`- p.`product_ordered` < p.`low_stock_notification`'; break; } } //vmdebug('my filter ordering ',$this->filter_order); // special orders case $ff_select_price = ''; switch ($this->filter_order) { case '`p`.product_special': if ($isSite) { $where[] = ' p.`product_special`="1" '; // TODO Change to a individual button $orderBy = 'ORDER BY RAND()'; } else { $orderBy = 'ORDER BY p.`product_special`'; } break; case 'category_name': $orderBy = ' ORDER BY `category_name` '; $joinCategory = TRUE; $joinCatLang = true; break; case 'category_description': $orderBy = ' ORDER BY `category_description` '; $joinCategory = TRUE; $joinCatLang = true; break; case 'mf_name': case '`l`.mf_name': $orderBy = ' ORDER BY `mf_name` '; $joinMf = TRUE; $joinMfLang = true; break; case 'ordering': case 'pc.ordering': $orderBy = ' ORDER BY `pc`.`ordering` '; $joinCategory = TRUE; break; case 'pc.ordering,product_name': $orderBy = ' ORDER BY `pc`.`ordering`,`product_name` '; $joinCategory = TRUE; $joinLang = true; break; case 'product_price': $orderBy = ' ORDER BY `product_price` '; $ff_select_price = ' , IF(pp.override, pp.product_override_price, pp.product_price) as product_price '; $joinPrice = TRUE; break; case 'created_on': case '`p`.created_on': $orderBy = ' ORDER BY p.`created_on` '; break; default: if (!empty($this->filter_order)) { $orderBy = ' ORDER BY ' . $this->filter_order . ' '; } else { $this->filter_order_Dir = ''; } break; } //Group case from the modules if ($group) { $latest_products_days = VmConfig::get('latest_products_days', 7); $latest_products_orderBy = VmConfig::get('latest_products_orderBy', 'created_on'); $groupBy = 'group by p.`virtuemart_product_id` '; switch ($group) { case 'featured': $where[] = 'p.`product_special`="1" '; $orderBy = 'ORDER BY RAND()'; break; case 'latest': /*$date = JFactory::getDate (time () - (60 * 60 * 24 * $latest_products_days)); $dateSql = $date->toSQL (); $where[] = 'p.`' . $latest_products_orderBy . '` > "' . $dateSql . '" ';*/ //vmdebug('product model ',$latest_products_orderBy); $orderBy = 'ORDER BY p.`' . $latest_products_orderBy . '`'; $this->filter_order_Dir = 'DESC'; break; case 'random': $orderBy = ' ORDER BY RAND() '; //LIMIT 0, '.(int)$nbrReturnProducts ; //TODO set limit LIMIT 0, '.(int)$nbrReturnProducts; break; case 'topten': $orderBy = ' ORDER BY p.`product_sales` '; //LIMIT 0, '.(int)$nbrReturnProducts; //TODO set limitLIMIT 0, '.(int)$nbrReturnProducts; $joinPrice = true; $where[] = 'pp.`product_price`>"0.0" '; $this->filter_order_Dir = 'DESC'; break; case 'recent': $rSession = JFactory::getSession(); $rIds = $rSession->get('vmlastvisitedproductids', array(), 'vm'); // get recent viewed from browser session return $rIds; } // $joinCategory = false ; //creates error // $joinMf = false ; //creates error $joinPrice = TRUE; $this->searchplugin = FALSE; // $joinLang = false; } /*if ($onlyPublished and !empty($this->virtuemart_vendor_id) and vRequest::get('manage',false) and vmAccess::isSuperVendor()) { $where[] = ' p.`virtuemart_vendor_id` = "'.$this->virtuemart_vendor_id.'" '; } else {*/ if (!empty($onlyPublished) and $isSite) { $where[] = ' p.`published`="1" '; } if (!empty($this->virtuemart_vendor_id)) { $where[] = ' p.`virtuemart_vendor_id` = "' . $this->virtuemart_vendor_id . '" '; } //} $joinedTables = array(); //This option switches between showing products without the selected language or only products with language. if ($app->isSite() and !VmConfig::get('prodOnlyWLang', false)) { //Maybe we have to join the language to order by product name, description, etc,... $productLangFields = array('product_s_desc', 'product_desc', 'product_name', 'metadesc', 'metakey', 'slug'); foreach ($productLangFields as $field) { if (strpos($orderBy, $field, 6) !== FALSE) { $langFields[] = $field; $orderbyLangField = $field; $joinLang = true; break; } } } else { $joinLang = true; } $selectLang = ''; if ($joinLang or count($langFields) > 0) { if (!VmConfig::get('prodOnlyWLang', false) and VmConfig::$defaultLang != VmConfig::$vmlang and Vmconfig::$langCount > 1) { $this->useLback = true; $this->useJLback = false; $method = 'LEFT'; if ($isSite) { $method = 'INNER'; } if (VmConfig::$defaultLang != VmConfig::$jDefLang) { $joinedTables[] = ' ' . $method . ' JOIN `#__virtuemart_products_' . VmConfig::$jDefLang . '` as ljd using (`virtuemart_product_id`)'; $method = 'LEFT'; $this->useJLback = true; } $joinedTables[] = ' ' . $method . ' JOIN `#__virtuemart_products_' . VmConfig::$defaultLang . '` as ld using (`virtuemart_product_id`)'; $joinedTables[] = ' LEFT JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` as l using (`virtuemart_product_id`)'; $langFields = array_unique($langFields); if (count($langFields) > 0) { foreach ($langFields as $langField) { $expr2 = 'ld.' . $langField; if ($this->useJLback) { $expr2 = 'IFNULL(ld.' . $langField . ', ljd.' . $langField . ')'; } $selectLang .= ', IFNULL(l.' . $langField . ',' . $expr2 . ') as ' . $langField . ''; } } } else { $this->useLback = false; $joinedTables[] = ' INNER JOIN `#__virtuemart_products_' . VmConfig::$vmlang . '` as l using (`virtuemart_product_id`)'; } } $select = ' p.`virtuemart_product_id`' . $ff_select_price . $selectLang . ' FROM `#__virtuemart_products` as p '; if ($joinShopper == TRUE) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_shoppergroups` as ps ON p.`virtuemart_product_id` = `ps`.`virtuemart_product_id` '; //$joinedTables[] = ' LEFT OUTER JOIN `#__virtuemart_shoppergroups` as s ON s.`virtuemart_shoppergroup_id` = `#__virtuemart_product_shoppergroups`.`virtuemart_shoppergroup_id` '; } if ($joinCategory == TRUE or $joinCatLang) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_categories` as pc ON p.`virtuemart_product_id` = `pc`.`virtuemart_product_id` '; if ($isSite and !VmConfig::get('show_unpub_cat_products', TRUE)) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_categories` as c ON c.`virtuemart_category_id` = `pc`.`virtuemart_category_id` '; } if ($joinCatLang) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_categories_' . VmConfig::$vmlang . '` as cl ON cl.`virtuemart_category_id` = `pc`.`virtuemart_category_id`'; } } if ($joinMf == TRUE or $joinMfLang) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_manufacturers` ON p.`virtuemart_product_id` = `#__virtuemart_product_manufacturers`.`virtuemart_product_id` '; if ($joinMfLang) { $joinedTables[] = 'LEFT JOIN `#__virtuemart_manufacturers_' . VmConfig::$vmlang . '` as m ON m.`virtuemart_manufacturer_id` = `#__virtuemart_product_manufacturers`.`virtuemart_manufacturer_id` '; } } if ($joinPrice == TRUE) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_prices` as pp ON p.`virtuemart_product_id` = pp.`virtuemart_product_id` '; } if ($this->searchcustoms) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_customfields` as pf ON p.`virtuemart_product_id` = pf.`virtuemart_product_id` '; } if ($this->searchplugin !== 0) { if (!empty($PluginJoinTables)) { $plgName = $PluginJoinTables[0]; $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_custom_plg_' . $plgName . '` as ' . $plgName . ' ON ' . $plgName . '.`virtuemart_product_id` = p.`virtuemart_product_id` '; } } /*if ($joinShopper == TRUE) { $joinedTables[] = ' LEFT JOIN `#__virtuemart_product_shoppergroups` ON p.`virtuemart_product_id` = `#__virtuemart_product_shoppergroups`.`virtuemart_product_id` LEFT OUTER JOIN `#__virtuemart_shoppergroups` as s ON s.`virtuemart_shoppergroup_id` = `#__virtuemart_product_shoppergroups`.`virtuemart_shoppergroup_id`'; }/*/ if ($joinChildren) { $joinedTables[] = ' LEFT OUTER JOIN `#__virtuemart_products` children ON p.`virtuemart_product_id` = children.`product_parent_id` '; } if ($this->searchplugin !== 0) { JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('plgVmBeforeProductSearch', array(&$select, &$joinedTables, &$where, &$groupBy, &$orderBy, &$joinLang)); } if (count($where) > 0) { $whereString = ' WHERE (' . implode(' AND ', $where) . ') '; } else { $whereString = ''; } //vmdebug ( ' joined ? ',$select, $joinedTables, $whereString, $groupBy, $orderBy, $this->filter_order_Dir ); /* jexit(); */ $this->orderByString = $orderBy; if ($this->_onlyQuery) { return array($select, $joinedTables, $where, $orderBy, $joinLang); } $joinedTables = " \n" . implode(" \n", $joinedTables); vmSetStartTime('sortSearchQuery'); $product_ids = $this->exeSortSearchListQuery(2, $select, $joinedTables, $whereString, $groupBy, $orderBy, $this->filter_order_Dir, $nbrReturnProducts); vmTime('sortSearchQuery products', 'sortSearchQuery'); //vmdebug('exeSortSearchLIstquery orderby ',$product_ids); return $product_ids; }
function display($tpl = null) { $mainframe = Jfactory::getApplication(); $option = vRequest::getCmd('option'); //Load helpers if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } /* Get the review IDs to retrieve (input variable may be cid, cid[] or tsmart_rating_review_id */ $cids = vRequest::getInt('cid', vRequest::getVar('tsmart_rating_review_id', 0)); if ($cids && !is_array($cids)) { $cids = array($cids); } // Figure out maximum rating scale (default is 5 stars) $this->max_rating = tsmConfig::get('vm_maximum_rating_scale', 5); $model = tmsModel::getModel(); $this->SetViewTitle('REVIEW_RATE'); /* Get the task */ $task = vRequest::getCmd('task'); switch ($task) { case 'edit': /* Get the data $rating = $model->getRating($cids); $this->addStandardEditViewCommands(); break;*/ /* Get the data $rating = $model->getRating($cids); $this->addStandardEditViewCommands(); break;*/ case 'listreviews': /* Get the data */ $this->addStandardDefaultViewLists($model); $tsmart_product_id = vRequest::getInt('tsmart_product_id'); if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) { $tsmart_product_id = (int) $tsmart_product_id[0]; } else { $tsmart_product_id = (int) $tsmart_product_id; } $this->reviewslist = $model->getReviews($tsmart_product_id, vmAccess::getVendorId()); $lists = array(); $lists['filter_order'] = $mainframe->getUserStateFromRequest($option . 'filter_order', 'filter_order', '', 'cmd'); $lists['filter_order_Dir'] = $mainframe->getUserStateFromRequest($option . 'filter_order_Dir', 'filter_order_Dir', '', 'word'); $this->pagination = $model->getPagination(); $this->addStandardDefaultViewCommands(false, true); break; case 'edit_review': JToolBarHelper::divider(); // Get the data $this->rating = $model->getReview($cids); if (!empty($this->rating)) { $this->SetViewTitle('REVIEW_RATE', $this->rating->product_name . " (" . $this->rating->customer . ")"); JToolBarHelper::custom('saveReview', 'save', 'save', tsmText::_('com_tsmart_SAVE'), false); JToolBarHelper::custom('applyReview', 'apply', 'apply', tsmText::_('com_tsmart_APPLY'), false); } else { $this->SetViewTitle('REVIEW_RATE', 'ERROR'); } JToolBarHelper::custom('cancelEditReview', 'cancel', 'cancel', tsmText::_('com_tsmart_CANCEL'), false); break; default: $this->addStandardDefaultViewCommands(false, true); $this->addStandardDefaultViewLists($model); $this->ratingslist = $model->getRatings(); $this->pagination = $model->getPagination(); break; } parent::display($tpl); }
function display($tpl = null) { if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel('calc'); //@todo should be depended by loggedVendor $this->vendorId = vmAccess::getVendorId(); $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $calc = $model->getCalc(); $this->assignRef('calc', $calc); $isNew = $calc->virtuemart_calc_id < 1; if ($isNew) { $calc->virtuemart_vendor_id = $this->vendorId; $db = JFactory::getDBO(); //get default currency of the vendor, if not set get default of the shop $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id` = "' . $this->vendorId . '"'; $db->setQuery($q); $currency = $db->loadResult(); if (empty($currency)) { $q = 'SELECT `vendor_currency` FROM `#__virtuemart_vendors` WHERE `virtuemart_vendor_id` = "1" '; $db->setQuery($q); $currency = $db->loadResult(); $calc->calc_currency = $currency; } else { $calc->calc_currency = $currency; } } $this->entryPointsList = self::renderEntryPointsList($calc->calc_kind); $this->mathOpList = self::renderMathOpList($calc->calc_value_mathop); if (empty($calc->calc_categories)) { $calc->calc_categories = array(); } else { if (!is_array($calc->calc_categories)) { $calc->calc_categories = array($calc->calc_categories); } } $calc_categories = $calc->calc_categories; $this->categoryTree = ShopFunctions::categoryListTree($calc_categories); $currencyModel = VmModel::getModel('currency'); $this->currencies = $currencyModel->getCurrencies(); $this->shopperGroupList = ShopFunctions::renderShopperGroupList($calc->virtuemart_shoppergroup_ids, True); if (!class_exists('ShopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $this->countriesList = ShopFunctionsF::renderCountryList($calc->calc_countries, True); $this->statesList = ShopFunctionsF::renderStateList($calc->virtuemart_state_ids, '', True); $this->manufacturerList = ShopFunctions::renderManufacturerList($calc->virtuemart_manufacturers, true); if ($this->showVendors()) { $this->vendorList = ShopFunctions::renderVendorList($calc->virtuemart_vendor_id); } $this->addStandardEditViewCommands(); } else { if ($this->showVendors()) { JToolBarHelper::custom('toggle.shared.1', 'publish', 'yes', vmText::_('COM_VIRTUEMART_SHARED_TOGGLE_ON'), true); JToolBarHelper::custom('toggle.shared.0', 'unpublish', 'no', vmText::_('COM_VIRTUEMART_SHARED_TOGGLE_OFF'), true); } $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model); $search = vRequest::getCmd('search', false); $this->calcs = $model->getCalcs(false, false, $search); VmConfig::loadJLang('com_virtuemart_shoppers', true); foreach ($this->calcs as &$data) { $data->calcCategoriesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'categories', 'category_name', 'category', 'calc_categories', 'virtuemart_calc_id'); $data->calcShoppersList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'shoppergroups', 'shopper_group_name', 'shoppergroup', 'calc_shoppergroups', 'virtuemart_calc_id'); $data->calcCountriesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'countries', 'country_name', 'country', 'calc_countries', 'virtuemart_calc_id'); $data->calcStatesList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'states', 'state_name', 'states', 'calc_states', 'virtuemart_calc_id'); $data->calcManufacturersList = shopfunctions::renderGuiList($data->virtuemart_calc_id, 'manufacturers', 'mf_name', 'manufacturer', 'calc_manufacturers', 'virtuemart_calc_id'); } $this->pagination = $model->getPagination(); } parent::display($tpl); }
/** * This functions updates the variables of the model which are used in the sortSearchListQuery * with the variables from the Request * * @author Max Milbers */ protected function populateState() { $app = JFactory::getApplication(); $option = 'com_virtuemart'; $view = 'product'; $valid_search_fields = VmConfig::get('browse_search_fields'); if ($app->isSite() and !vRequest::getInt('manage', false)) { $filter_order = vRequest::getString('orderby', "0"); if ($filter_order == "0") { $filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering); $filter_order = $this->checkFilterOrder($filter_order_raw); } else { $filter_order = $this->checkFilterOrder($filter_order); $this->setLastProductOrdering($filter_order); } $filter_order_Dir = strtoupper(vRequest::getCmd('dir', VmConfig::get('prd_brws_orderby_dir', 'ASC'))); $this->product_parent_id = vRequest::getInt('product_parent_id', FALSE); $this->virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', FALSE); $this->keyword = vRequest::getString('keyword', ''); //vRequest::uword ('keyword', "", ' ,-,+,.,_,#,/'); if ($this->keyword === '') { $this->keyword = vRequest::getString('filter_product', ''); //vRequest::uword ('filter_product', "", ' ,-,+,.,_,#,/'); vRequest::setVar('filter_product', $this->keyword); } else { vRequest::setVar('keyword', $this->keyword); } } else { $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = strtoupper($app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word')); $valid_search_fields = array_unique(array_merge($this->valid_BE_search_fields, $valid_search_fields)); $view = vRequest::getCmd('view'); $stateTypes = array('virtuemart_category_id' => 'int', 'virtuemart_manufacturer_id' => 'int', 'product_parent_id' => 'int', 'filter_product' => 'string', 'search_type' => 'string', 'search_order' => 'string', 'search_date' => 'string', 'virtuemart_vendor_id' => 'int'); foreach ($stateTypes as $type => $filter) { $k = 'com_virtuemart.' . $view . '.' . $type; if ($filter == 'int') { $new_state = vRequest::getInt($type, false); } else { $new_state = vRequest::getVar($type, false); } if ($new_state === false) { $this->{$type} = $app->getUserState($k, ''); } else { $app->setUserState($k, $new_state); $this->{$type} = $new_state; } } $this->keyword = $this->filter_product; } $filter_order_Dir = $this->checkFilterDir($filter_order_Dir); $this->filter_order = $filter_order; $this->filter_order_Dir = $filter_order_Dir; $this->valid_search_fields = $valid_search_fields; $this->search_type = vRequest::getVar('search_type', ''); $this->searchcustoms = vRequest::getVar('customfields', false, true); $this->searchplugin = vRequest::getInt('custom_parent_id', 0); //$this->virtuemart_vendor_id = vmAccess::isSuperVendor(); $this->virtuemart_vendor_id = vmAccess::getVendorId(); $this->__state_set = true; }
function display($tpl = null) { if (!class_exists('VirtueMartModelConfig')) { require VMPATH_ADMIN . 'models/config.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = VmModel::getModel(); $layoutName = $this->getLayout(); $task = vRequest::getCmd('task', $layoutName); $this->assignRef('task', $task); $this->user = $user = JFactory::getUser(); if ($layoutName == 'edit') { $category = $model->getCategory('', false); // Toolbar $text = ''; if (isset($category->category_name)) { $name = $category->category_name; } else { $name = ''; } if (!empty($category->virtuemart_category_id)) { $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id . '" target="_blank" >' . $name . '<span class="vm2-modallink"></span></a>'; } $this->SetViewTitle('CATEGORY', $text); $model->addImages($category); if ($category->virtuemart_category_id > 1) { $relationInfo = $model->getRelationInfo($category->virtuemart_category_id); $this->assignRef('relationInfo', $relationInfo); } else { $category->virtuemart_vendor_id = vmAccess::getVendorId(); } $parent = $model->getParentCategory($category->virtuemart_category_id); $this->assignRef('parent', $parent); if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } $templateList = ShopFunctions::renderTemplateList(vmText::_('COM_VIRTUEMART_CATEGORY_TEMPLATE_DEFAULT')); $this->assignRef('jTemplateList', $templateList); $categoryLayoutList = VirtueMartModelConfig::getLayoutList('category'); $this->assignRef('categoryLayouts', $categoryLayoutList); $productLayouts = VirtueMartModelConfig::getLayoutList('productdetails'); $this->assignRef('productLayouts', $productLayouts); //Nice fix by Joe, the 4. param prevents setting an category itself as child $categorylist = ShopFunctions::categoryListTree(array($parent->virtuemart_category_id), 0, 0, (array) $category->virtuemart_category_id); if ($this->showVendors()) { $vendorList = ShopFunctions::renderVendorList($category->virtuemart_vendor_id); $this->assignRef('vendorList', $vendorList); } $this->assignRef('category', $category); $this->assignRef('categorylist', $categorylist); $this->addStandardEditViewCommands($category->virtuemart_category_id, $category); } else { $this->SetViewTitle('CATEGORY_S'); $keyWord = ''; $this->assignRef('catmodel', $model); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model, 'category_name'); $topCategory = vRequest::getInt('top_category_id', 0); $category_tree = ShopFunctions::categoryListTree(array($topCategory)); $this->assignRef('category_tree', $category_tree); $categories = $model->getCategoryTree($topCategory, 0, false, $this->lists['search']); $this->assignRef('categories', $categories); $pagination = $model->getPagination(); $this->assignRef('catpagination', $pagination); //we need a function of the FE shopfunctions helper to cut the category descriptions if (!class_exists('shopFunctionsF')) { require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } } parent::display($tpl); }
$listOptions[] = JHtml::_('select.option', 'permanent', vmText::_('COM_VIRTUEMART_COUPON_TYPE_PERMANENT')); $listOptions[] = JHtml::_('select.option', 'gift', vmText::_('COM_VIRTUEMART_COUPON_TYPE_GIFT')); echo VmHTML::row('select', 'COM_VIRTUEMART_COUPON_TYPE', 'coupon_type', $listOptions, $this->coupon->coupon_type, '', 'value', 'text', false); ?> <?php echo VmHTML::row('input', 'COM_VIRTUEMART_COUPON_VALUE_VALID_AT', 'coupon_value_valid', $this->coupon->coupon_value_valid, 'class="inputbox"', '', 10, 255, ' ' . $this->vendor_currency); ?> <?php echo VmHTML::row('raw', 'COM_VIRTUEMART_COUPON_START', vmJsApi::jDate($this->coupon->coupon_start_date, 'coupon_start_date')); ?> <?php echo VmHTML::row('raw', 'COM_VIRTUEMART_COUPON_EXPIRY', vmJsApi::jDate($this->coupon->coupon_expiry_date, 'coupon_expiry_date')); ?> <?php if ($this->showVendors()) { echo VmHTML::row('raw', 'COM_VIRTUEMART_VENDOR', Shopfunctions::renderVendorList(vmAccess::getVendorId())); } ?> </table> </fieldset> <input type="hidden" name="virtuemart_coupon_id" value="<?php echo $this->coupon->virtuemart_coupon_id; ?> " /> <?php echo $this->addStandardHiddenToForm(); ?> </form>
/** * This functions updates the variables of the model which are used in the sortSearchListQuery * with the variables from the Request * * @author Max Milbers */ function updateRequests() { $this->keyword = vRequest::getString('keyword', ''); //vRequest::uword ('keyword', "", ' ,-,+,.,_,#,/'); if ($this->keyword === '') { $this->keyword = vRequest::getString('filter_product', ''); //vRequest::uword ('filter_product', "", ' ,-,+,.,_,#,/'); vRequest::setVar('filter_product', $this->keyword); } else { vRequest::setVar('keyword', $this->keyword); } $app = JFactory::getApplication(); $option = 'com_virtuemart'; $view = 'product'; $valid_search_fields = VmConfig::get('browse_search_fields'); if ($app->isSite()) { $filter_order = vRequest::getString('orderby', "0"); if ($filter_order == "0") { $filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering); $filter_order = $this->checkFilterOrder($filter_order_raw); } else { $filter_order = $this->checkFilterOrder($filter_order); $this->setLastProductOrdering($filter_order); } $filter_order_Dir = strtoupper(vRequest::getCmd('dir', VmConfig::get('prd_brws_orderby_dir', 'ASC'))); } else { $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd')); $filter_order = $this->checkFilterOrder($filter_order); $filter_order_Dir = strtoupper($app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word')); $valid_search_fields = array_unique(array_merge($this->valid_BE_search_fields, $valid_search_fields)); } $filter_order_Dir = $this->checkFilterDir($filter_order_Dir); $this->filter_order = $filter_order; $this->filter_order_Dir = $filter_order_Dir; $this->valid_search_fields = $valid_search_fields; $this->product_parent_id = vRequest::getInt('product_parent_id', FALSE); $this->virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', FALSE); $this->search_type = vRequest::getVar('search_type', ''); $this->searchcustoms = vRequest::getVar('customfields', false, true); $this->searchplugin = vRequest::getInt('custom_parent_id', 0); //$this->virtuemart_vendor_id = vmAccess::isSuperVendor(); $this->virtuemart_vendor_id = vmAccess::getVendorId(); }