Example #1
0
 function display($tpl = null)
 {
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     $model = VmModel::getModel();
     $usermodel = VmModel::getModel('user');
     JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48');
     $this->addStandardEditViewCommands();
     $config = VmConfig::loadConfig();
     if (!empty($config->_params)) {
         unset($config->_params['pdf_invoice']);
         // parameter remove and replaced by inv_os
     }
     $this->assignRef('config', $config);
     $mainframe = JFactory::getApplication();
     $this->assignRef('joomlaconfig', $mainframe);
     $userparams = JComponentHelper::getParams('com_users');
     $this->assignRef('userparams', $userparams);
     $templateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT'));
     $this->assignRef('jTemplateList', $templateList);
     $vmLayoutList = $model->getLayoutList('virtuemart');
     $this->assignRef('vmLayoutList', $vmLayoutList);
     $categoryLayoutList = $model->getLayoutList('category');
     $this->assignRef('categoryLayoutList', $categoryLayoutList);
     $productLayoutList = $model->getLayoutList('productdetails');
     $this->assignRef('productLayoutList', $productLayoutList);
     $noimagelist = $model->getNoImageList();
     $this->assignRef('noimagelist', $noimagelist);
     $orderStatusModel = VmModel::getModel('orderstatus');
     $this->assignRef('orderStatusModel', $orderStatusModel);
     $currConverterList = $model->getCurrencyConverterList();
     $this->assignRef('currConverterList', $currConverterList);
     $moduleList = $model->getModuleList();
     $this->assignRef('moduleList', $moduleList);
     $activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages'));
     $this->assignRef('activeLanguages', $activeLanguages);
     $orderByFieldsProduct = $model->getProductFilterFields('browse_orderby_fields');
     $this->assignRef('orderByFieldsProduct', $orderByFieldsProduct);
     VmModel::getModel('category');
     foreach (VirtueMartModelCategory::$_validOrderingFields as $key => $field) {
         if ($field == 'c.category_shared') {
             continue;
         }
         $fieldWithoutPrefix = $field;
         $dotps = strrpos($fieldWithoutPrefix, '.');
         if ($dotps !== false) {
             $prefix = substr($field, 0, $dotps + 1);
             $fieldWithoutPrefix = substr($field, $dotps + 1);
         }
         $text = JText::_('COM_VIRTUEMART_' . strtoupper($fieldWithoutPrefix));
         $orderByFieldsCat[] = JHTML::_('select.option', $field, $text);
     }
     //$orderByFieldsCat = $model->get;
     $this->assignRef('orderByFieldsCat', $orderByFieldsCat);
     $searchFields = $model->getProductFilterFields('browse_search_fields');
     $this->assignRef('searchFields', $searchFields);
     $aclGroups = $usermodel->getAclGroupIndentedTree();
     $this->assignRef('aclGroups', $aclGroups);
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $vmtemplate = shopFunctionsF::loadVmTemplateStyle();
     if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) {
         $imagePath = '/templates/' . $vmtemplate . '/images/availability/';
     } else {
         $imagePath = '/components/com_virtuemart/assets/images/availability/';
     }
     $this->assignRef('imagePath', $imagePath);
     shopFunctions::checkSafePath();
     $this->checkVmUserVendor();
     parent::display($tpl);
 }
Example #2
0
 function display($tpl = null)
 {
     // Get the task
     $task = JRequest::getWord('task', $this->getLayout());
     $this->assignRef('task', $task);
     // Load helpers
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('VmImage')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php';
     }
     $model = VmModel::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');
             VmConfig::loadJLang('com_virtuemart_orders', TRUE);
             VmConfig::loadJLang('com_virtuemart_shoppers', TRUE);
             $virtuemart_product_id = JRequest::getVar('virtuemart_product_id', array());
             if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) {
                 $virtuemart_product_id = (int) $virtuemart_product_id[0];
             } else {
                 $virtuemart_product_id = (int) $virtuemart_product_id;
             }
             $product = $model->getProductSingle($virtuemart_product_id, false);
             //$product_parent= $model->getProductParent($product->product_parent_id);
             $product_parent = false;
             if (!empty($product->product_parent_id)) {
                 $product_parent = $model->getProductSingle($product->product_parent_id, false);
             }
             $mf_model = VmModel::getModel('manufacturer');
             $manufacturers = $mf_model->getManufacturerDropdown($product->virtuemart_manufacturer_id);
             $this->assignRef('manufacturers', $manufacturers);
             // Get the category tree
             if (isset($product->categories)) {
                 $category_tree = ShopFunctions::categoryListTree($product->categories);
             } else {
                 $category_tree = ShopFunctions::categoryListTree();
             }
             $this->assignRef('category_tree', $category_tree);
             //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)) {
                 $shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups);
             }
             $this->assignRef('shoppergroupList', $shoppergroupList);
             // Load the product price
             if (!class_exists('calculationHelper')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
             }
             $product_childIds = $model->getProductChildIds($virtuemart_product_id);
             $product_childs = array();
             $childs = 0;
             $maxChilds = 30;
             foreach ($product_childIds as $id) {
                 if ($childs++ > $maxChilds) {
                     break;
                 }
                 $product_childs[] = $model->getProductSingle($id, false);
             }
             $this->assignRef('product_childs', $product_childs);
             if (!class_exists('VirtueMartModelConfig')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'config.php';
             }
             $productLayouts = VirtueMartModelConfig::getLayoutList('productdetails');
             $this->assignRef('productLayouts', $productLayouts);
             // Load Images
             $model->addImages($product);
             if (!class_exists('shopFunctionsF')) {
                 require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
             }
             $vmtemplate = shopFunctionsF::loadVmTemplateStyle();
             if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) {
                 $imagePath = '/templates/' . $vmtemplate . '/images/availability/';
             } else {
                 $imagePath = '/components/com_virtuemart/assets/images/availability/';
             }
             $this->assignRef('imagePath', $imagePath);
             // Load the vendors
             $vendor_model = VmModel::getModel('vendor');
             if (Vmconfig::get('multix', 'none') !== 'none') {
                 $lists['vendors'] = Shopfunctions::renderVendorList($product->virtuemart_vendor_id);
             }
             // Load the currencies
             $currency_model = VmModel::getModel('currency');
             if (!class_exists('Permissions')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
             }
             $vendor_model->setId(Permissions::getInstance()->isSuperVendor());
             $vendor = $vendor_model->getVendor();
             if (empty($product->product_currency)) {
                 $product->product_currency = $vendor->vendor_currency;
             }
             //$currencies = JHTML::_('select.genericlist', $currency_model->getCurrencies(), 'product_currency', '', 'virtuemart_currency_id', 'currency_name', $product->product_currency);
             $currency = $currency_model->getCurrency($product->product_currency);
             $this->assignRef('product_currency', $currency->currency_symbol);
             $currency = $currency_model->getCurrency($vendor->vendor_currency);
             $this->assignRef('vendor_currency', $currency->currency_symbol);
             if (count($manufacturers) > 0) {
                 $lists['manufacturers'] = JHTML::_('select.genericlist', $manufacturers, 'virtuemart_manufacturer_id', 'class="inputbox"', 'value', 'text', $product->virtuemart_manufacturer_id);
             }
             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 = VmConfig::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 = VmConfig::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 = VmConfig::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 = VmModel::getModel('waitinglist');
             /* Load waiting list */
             if ($product->virtuemart_product_id) {
                 //$waitinglist = $this->get('waitingusers', 'waitinglist');
                 $waitinglist = $waitinglistmodel->getWaitingusers($product->virtuemart_product_id);
                 $this->assignRef('waitinglist', $waitinglist);
             }
             $productShoppers = $model->getProductShoppersByStatus($product->virtuemart_product_id, array('S'));
             $this->assignRef('productShoppers', $productShoppers);
             $orderstatusModel = VmModel::getModel('orderstatus');
             $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE);
             $field_model = VmModel::getModel('customfields');
             $fieldTypes = $field_model->getField_types();
             $this->assignRef('fieldTypes', $fieldTypes);
             // Add the virtuemart_shoppergroup_ids
             $cid = JFactory::getUser()->id;
             $this->activeShoppergroups = shopfunctions::renderGuiList('virtuemart_shoppergroup_id', '#__virtuemart_vmuser_shoppergroups', 'virtuemart_user_id', $cid, 'shopper_group_name', '#__virtuemart_shoppergroups', 'virtuemart_shoppergroup_id', 'category', 4, 0);
             if (!$this->activeShoppergroups or is_array($this->activeShoppergroups) and count($this->activeShoppergroups) == 0) {
                 //vmdebug('$this->activeShoppergroups',$this->activeShoppergroups);
                 $shoppergroupModel = VmModel::getModel('shoppergroup');
                 $this->activeShoppergroups = vmText::_($shoppergroupModel->getDefault(0)->shopper_group_name);
             }
             /* Load protocustom lists */
             $customsList = $field_model->getCustomsList();
             $attribs = 'style= "width: 300px;"';
             $customlist = JHTML::_('select.genericlist', $customsList, 'customlist', $attribs);
             $this->assignRef('customsList', $customlist);
             $ChildCustomRelation = $field_model->getProductChildCustomRelation();
             $this->assignRef('ChildCustomRelation', $ChildCustomRelation);
             if ($product->product_parent_id > 0) {
                 $parentRelation = $field_model->getProductParentRelation($product->virtuemart_product_id);
                 $this->assignRef('parentRelation', $parentRelation);
                 // Set up labels
                 $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL');
                 $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL');
                 $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL');
                 $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL');
                 $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG');
             } else {
                 if ($task == 'add') {
                     $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL');
                 } else {
                     $action = JText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL');
                 }
                 $info_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL');
                 $status_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL');
                 $dim_weight_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL');
                 $images_label = JText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL');
                 $delete_message = JText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_PRODUCT_MSG');
             }
             $this->assignRef('product', $product);
             $product_empty_price = array('virtuemart_product_price_id' => 0, 'virtuemart_product_id' => $virtuemart_product_id, 'virtuemart_shoppergroup_id' => NULL, 'product_price' => NULL, 'override' => NULL, 'product_override_price' => NULL, 'product_tax_id' => NULL, 'product_discount_id' => NULL, 'product_currency' => $vendor->vendor_currency, 'product_price_publish_up' => NULL, 'product_price_publish_down' => NULL, 'price_quantity_start' => NULL, 'price_quantity_end' => NULL);
             $this->assignRef('product_empty_price', $product_empty_price);
             $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 = '&virtuemart_category_id=' . $product->canonCatLink;
             } else {
                 $canonLink = '';
             }
             if (!empty($product->virtuemart_product_id)) {
                 if (!class_exists('shopFunctionsF')) {
                     require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                 }
                 $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag());
                 $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>';
             } else {
                 $text = $product->product_name . $sku;
             }
             $this->SetViewTitle('PRODUCT', $text);
             $this->addStandardEditViewCommands($product->virtuemart_product_id);
             break;
         case 'massxref_cats':
         case 'massxref_cats_exe':
             $this->SetViewTitle('PRODUCT_MASSXREF');
             if (!class_exists('Permissions')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
             }
             $showVendors = Permissions::getInstance()->check('admin');
             $this->assignRef('showVendors', $showVendors);
             $keyWord = '';
             $catmodel = VmModel::getModel('category');
             $this->assignRef('catmodel', $catmodel);
             //$this->addStandardDefaultViewCommands();
             $this->addStandardDefaultViewLists($catmodel, 'category_name');
             $categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search']);
             $this->assignRef('categories', $categories);
             $catpagination = $catmodel->getPagination();
             $this->assignRef('catpagination', $catpagination);
             //$this->addStandardDefaultViewCommands();
             $this->setLayout('massxref');
             JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT_EXE'), false);
             break;
         case 'massxref_sgrps':
         case 'massxref_sgrps_exe':
             $sgrpmodel = VmModel::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', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS_EXE'), false);
             break;
         default:
             if ($product_parent_id = JRequest::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&virtuemart_product_id=' . $product_parent->virtuemart_product_id . '&option=com_virtuemart'), $product_parent->product_name, array('title' => JText::_('COM_VIRTUEMART_EDIT_PARENT') . ' ' . $product_parent->product_name));
                     $msg = JText::_('COM_VIRTUEMART_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->db = JFactory::getDBO();
             $this->SetViewTitle($title, $msg);
             $this->addStandardDefaultViewLists($model, 'created_on');
             /* Get the list of products */
             $productlist = $model->getProductListing(false, false, false, false, true);
             //The pagination must now always set AFTER the model load the listing
             $pagination = $model->getPagination();
             $this->assignRef('pagination', $pagination);
             /* Get the category tree */
             $categoryId = $model->virtuemart_category_id;
             //OSP switched to filter in model, was JRequest::getInt('virtuemart_category_id');
             $category_tree = ShopFunctions::categoryListTree(array($categoryId));
             $this->assignRef('category_tree', $category_tree);
             /* Load the product price */
             if (!class_exists('calculationHelper')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
             }
             $vendor_model = VmModel::getModel('vendor');
             $productreviews = VmModel::getModel('ratings');
             foreach ($productlist as $virtuemart_product_id => $product) {
                 $product->mediaitems = count($product->virtuemart_media_id);
                 $product->reviews = $productreviews->countReviewsForProduct($product->virtuemart_product_id);
                 $vendor_model->setId($product->virtuemart_vendor_id);
                 $vendor = $vendor_model->getVendor();
                 $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->virtuemart_vendor_id);
                 if (!empty($product->product_price) && !empty($product->product_currency)) {
                     $product->product_price_display = $currencyDisplay->priceDisplay($product->product_price, (int) $product->product_currency, 1, true);
                 }
                 /* Write the first 5 categories in the list */
                 $product->categoriesList = shopfunctions::renderGuiList('virtuemart_category_id', '#__virtuemart_product_categories', 'virtuemart_product_id', $product->virtuemart_product_id, 'category_name', '#__virtuemart_categories', 'virtuemart_category_id', 'category');
             }
             $mf_model = VmModel::getModel('manufacturer');
             $manufacturers = $mf_model->getManufacturerDropdown();
             $this->assignRef('manufacturers', $manufacturers);
             /* add Search filter in lists*/
             /* Search type */
             $options = array('' => JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'), 'parent' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE'));
             $this->lists['search_type'] = VmHTML::selectList('search_type', JRequest::getVar('search_type'), $options);
             /* Search order */
             $options = array('bf' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => JText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER'));
             $this->lists['search_order'] = VmHTML::selectList('search_order', JRequest::getVar('search_order'), $options);
             // Toolbar
             JToolBarHelper::custom('massxref_cats', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT'), true);
             JToolBarHelper::custom('massxref_sgrps', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS'), true);
             JToolBarHelper::custom('createchild', 'new', 'new', JText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true);
             JToolBarHelper::custom('cloneproduct', 'copy', 'copy', JText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true);
             JToolBarHelper::custom('addrating', 'default', '', JText::_('COM_VIRTUEMART_ADD_RATING'), true);
             $this->addStandardDefaultViewCommands();
             $this->assignRef('productlist', $productlist);
             $this->assignRef('virtuemart_category_id', $categoryId);
             $this->assignRef('model', $model);
             break;
     }
     parent::display($tpl);
 }
Example #3
0
 function getAvai()
 {
     jimport('joomla.filesystem.folder');
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (method_exists('shopFunctionsF', 'loadVmTemplateStyle')) {
         $vmtemplate = shopFunctionsF::loadVmTemplateStyle();
         if (is_Dir(JPATH_ROOT . DS . 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS)) {
             $imagePath = 'templates' . DS . $vmtemplate . DS . 'images' . DS . 'availability' . DS;
         } else {
             $imagePath = 'components' . DS . 'com_virtuemart' . DS . 'assets' . DS . 'images' . DS . 'availability' . DS;
         }
     } else {
         $imagePath = 'components' . DS . 'com_virtuemart' . DS . 'assets' . DS . 'images' . DS . 'availability' . DS;
     }
     $imagePath = JPATH_SITE . DS . $imagePath;
     jimport('joomla.filesystem.file');
     $avail = JFolder::files($imagePath, '.gif|.png|.jpg|.jpeg', false, false);
     $ret = array();
     foreach ($avail as $img) {
         $obj = new stdClass();
         $pattern = '/[^\\w]+/';
         //'[^a-zA-Z\s]';
         $key2 = preg_replace($pattern, '_', $img);
         //var_dump($key2);
         //var_dump($img); die();
         //$key2 .= md5($img);
         $obj->{$key2} = $img;
         $obj->img = $img;
         //1-2m.gif
         switch ($img) {
             case "24h.gif":
                 $avai = 24;
                 $deliverydate = "24 hours";
                 break;
             case "ihned.gif":
                 $avai = 24;
                 $deliverydate = "24 hours";
                 break;
             case "2-3d.gif":
                 $avai = 60;
                 $deliverydate = "2-3 days";
                 break;
             case "48h.gif":
                 $avai = 48;
                 $deliverydate = "48 hours";
                 break;
             case "1-2m.gif":
                 $avai = 60;
                 $deliverydate = "1 to 2 months";
                 break;
             case "1-4w.gif":
                 $avai = 14;
                 $deliverydate = "1 to 4 weeks";
                 break;
             case "14d.gif":
                 $avai = 14;
                 $deliverydate = "2 weeks";
                 break;
             case "24h.gif":
                 $avai = 1;
                 $deliverydate = "24 hours";
                 break;
             case "3-5d.gif":
                 $avai = 4;
                 $deliverydate = "3 to 5 days";
                 break;
             case "48h.gif":
                 $avai = 2;
                 $deliverydate = "48 hours";
                 break;
             case "7d.gif":
                 $avai = 7;
                 $deliverydate = "7 days";
                 break;
             case "not_available.gif":
                 $avai = 60;
                 $deliverydate = "Not available";
                 break;
             case "on-order.gif":
                 $avai = 168;
                 $deliverydate = "1 week";
                 break;
             default:
                 $avai = 60;
                 $deliverydate = "2-3 days";
         }
         $obj->avai = $avai;
         $obj->deliverytext = $deliverydate;
         $ret[$key2] = $obj;
     }
     return $ret;
 }