/** * Retrieve the detail record for the current $id if the data has not already been loaded. * * @author RickG */ function getShipment() { if (empty($this->_data)) { $this->_data = $this->getTable('shipmentmethods'); $this->_data->load((int) $this->_id); // set the plugin default, we add a new shipment if (!$this->_id) { $this->_data->shipment_jplugin_id = jRequest::getInt('shipment_jplugin_id', 0); $q = 'SELECT `element` FROM `#__extensions` WHERE `folder` = "vmshipment" AND `enabled`=1 '; $q .= ' AND `extension_id` = ' . $this->_data->shipment_jplugin_id; $this->_db->setQuery($q); $this->_data->shipment_element = $this->_db->loadResult(); } if ($this->_data->shipment_jplugin_id) { JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); $retValue = $dispatcher->trigger('plgVmDeclarePluginParamsShipment', array($this->_data->shipment_element, $this->_data->shipment_jplugin_id, &$this->_data)); } // vmdebug('$$this->_data getShipment',$this->_data); if (empty($this->_data->virtuemart_vendor_id)) { if (!class_exists('VirtueMartModelVendor')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php'; } $this->_data->virtuemart_vendor_id = VirtueMartModelVendor::getLoggedVendor(); } //if(!empty($this->_id)){ /* Add the shipmentcarreir shoppergroups */ $q = 'SELECT `virtuemart_shoppergroup_id` FROM #__virtuemart_shipmentmethod_shoppergroups WHERE `virtuemart_shipmentmethod_id` = "' . $this->_id . '"'; $this->_db->setQuery($q); $this->_data->virtuemart_shoppergroup_ids = $this->_db->loadColumn(); # if (empty($this->_data->virtuemart_shoppergroup_ids)) { $this->_data->virtuemart_shoppergroup_ids = 0; } if (!empty($this->_id) || $this->_data->shipment_element) { // set params $registry = new JRegistry(); $registry->loadString($this->_data->shipment_params); $this->_data->params = $registry->toArray(); // Get the shipment XML. $path = JPath::clean(JPATH_PLUGINS . '/vmshipment/' . $this->_data->shipment_element . '/' . $this->_data->shipment_element . '.xml'); if (file_exists($path)) { $this->_data->form = JForm::getInstance('plgForm', $path, array(), true, '//config'); // $this->_data->xml = simplexml_load_file($path); $this->_data->form->bind($this->_data); } else { $this->_data->form = null; } } else { $this->_data->form = null; } } return $this->_data; }
function _item_active(&$item) { $mainframe = JFactory::getApplication(); $item->link2 = str_replace("index.php", "index2.php", $item->link); $item->link2 = $item->link; //$pos = strpos($item->link2,"?"); //if (!$pos) //{ // $item->link2 .= "?tmpl=component&option=com_javoice&layout=paging"; //}else { $item->link2 .= "&tmpl=component&option=com_javoice&layout=paging"; //} if (jRequest::getInt('status')) { $item->link2 .= '&status=' . jRequest::getInt('status'); } if ($this->_link) { return "<li> <a href=\"" . $item->link . "\" title=\"" . $item->text . "\" onclick=\"jav_ajaxPagination('" . $item->link2 . "','" . $this->_divid . "'); return false;\">" . $item->text . "</a> </li>"; } //end return "<li> <a href=\"" . JRoute::_($item->link) . "\" title=\"" . $item->text . "\" onclick=\"jav_ajaxPagination('" . $item->link2 . "','" . $this->_divid . "'); return false;\">" . $item->text . "</a> </li>"; }
function display($tpl = null) { // Get the task $task = JRequest::getWord('task', $this->getLayout()); vmdebug('VirtuemartViewProduct ' . $task); $this->task = $task; // Load helpers $this->loadHelper('currencydisplay'); $this->loadHelper('html'); $this->loadHelper('image'); $model = VmModel::getModel(); // Handle any publish/unpublish switch ($task) { case 'add': case 'edit': VmConfig::loadJLang('com_virtuemart_orders', TRUE); VmConfig::loadJLang('com_virtuemart_shoppers', TRUE); $this->jsonPath = JFactory::getApplication()->isSite() ? juri::root() : ''; $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); $mf_model = VmModel::getModel('manufacturer'); $manufacturers = $mf_model->getManufacturerDropdown($product->virtuemart_manufacturer_id); $this->manufacturers = $manufacturers; // set category in front edit link if ($task == 'add') { if ($category_id = jRequest::getInt('virtuemart_category_id', 0)) { $product->categories = array($category_id); } } // Get the category tree if (isset($product->categories)) { $this->category_tree = ShopFunctions::categoryListTree($product->categories); } else { $this->category_tree = ShopFunctions::categoryListTree(); } //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility if (isset($product->shoppergroups)) { $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups); } else { $this->shoppergroupList = ''; } // Load the product price $this->loadHelper('calculationh'); $product_childIds = $model->getProductChildIds($virtuemart_product_id); $product_childs = array(); foreach ($product_childIds as $id) { $product_childs[] = $model->getProductSingle($id, false); } $this->assignRef('product_childs', $product_childs); JLoader::register('VirtueMartModelConfig', JPATH_VM_ADMINISTRATOR . '/models/config.php'); $this->productLayouts = VirtueMartModelConfig::getLayoutList('productdetails', $product->layout); // Load Images $model->addImages($product); if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) { $imagePath = VmConfig::get('vmtemplate') . '/images/availability/'; } else { $imagePath = '/components/com_virtuemart/assets/images/availability/'; } $this->imagePath = $imagePath; // Load the vendors $vendor_model = VmModel::getModel('vendor'); if (Vmconfig::get('multix', 'none') !== 'none') { if ($task == 'add') { $vendor_id = $this->adminVendor; } else { $vendor_id = $product->virtuemart_vendor_id; } $lists['vendors'] = Shopfunctions::renderVendorList($vendor_id); } // Load the currencies $currency_model = VmModel::getModel('currency'); $this->loadHelper('permissions'); $vendor_model->setId(Permissions::getInstance()->isSuperVendor()); $vendor = $vendor_model->getVendor(); if (empty($product->product_currency)) { $product->product_currency = $vendor->vendor_currency; } //STUDIO42 fix for currency, old method set 2 time same currency symbol // TODO verify all others $currencyModel = VmModel::getModel('currency'); $currencyModel->setId($vendor->vendor_currency); $currency = $currencyModel->getData(); $this->vendor_currency = $currency->currency_symbol; $currencyModel->setId($product->product_currency); $currency = $currencyModel->getData(); $this->product_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); } $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $task == 'add' ? VmConfig::get('weight_unit_default') : $product->product_weight_uom); $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $task == 'add' ? VmConfig::get('weight_unit_default') : $product->product_unit); $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $task == 'add' ? VmConfig::get('lwh_unit_default') : $product->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); /* Load product types lists */ if ($customsList = $field_model->getCustomsList()) { $emptyOption = JHTML::_('select.option', '', '- ' . JText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION') . ' :', 'value', 'text'); array_unshift($customsList, $emptyOption); $customlist = JHTML::_('select.genericlist', $customsList, 'customlist'); if ($task == "add") { if ($customfieldsDefault = $this->getBLankCustomfields()) { $product->customfields = $customfieldsDefault; // var_dump( $customfieldsDefault);jexit(); } } } $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)) { $text = '<a href="' . juri::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . $canonLink . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>'; } else { $text = $product->product_name . $sku; } $this->SetViewTitle('PRODUCT', $text); //JToolBarHelper::custom('sentproductemailtocustomer', 'email_32', 'email_32', 'COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPER' ,false); $this->addStandardEditViewCommands($product->virtuemart_product_id); break; case 'massxref_cats': case 'massxref_cats_exe': //TODO test if path is ok addpath is now in the constructor $this->addTemplatePath(JPATH_VM_ADMINISTRATOR . '/views' . DS . 'category' . DS . 'tmpl'); $this->SetViewTitle('PRODUCT_MASSXREF'); // $this->setLayout('massxref'); $this->loadHelper('permissions'); $this->perms = Permissions::getInstance(); $this->showVendors = $this->perms->check('admin'); $keyWord = ''; $catmodel = VmModel::getModel('category'); $this->catmodel = $catmodel; //$this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($catmodel, 'category_name'); $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search']); $this->pagination = $catmodel->getPagination(); // restore icon is good but not the word JToolBarHelper::custom('display', 'restore', 'restore', JText::_('JTOOLBAR_BACK'), false); JToolBarHelper::custom('massxref_cats_exe', 'assign', 'assign', JText::_('COM_VIRTUEMART_MASS_REPLACE'), false); JToolBarHelper::custom('massxref_cats_add', 'new', 'new', JText::_('COM_VIRTUEMART_MASS_ADD'), true); break; case 'massxref_sgrps': case 'massxref_sgrps_exe': $this->SetViewTitle('PRODUCT_MASSXREF'); //TODO test if path is ok addpath is now in the constructor $this->addTemplatePath(JPATH_VM_ADMINISTRATOR . '/views' . DS . 'shoppergroup' . DS . 'tmpl'); $this->loadHelper('permissions'); $this->perms = Permissions::getInstance(); $this->showVendors = $this->perms->check('admin'); $sgrpmodel = VmModel::getModel('shoppergroup'); $this->addStandardDefaultViewLists($sgrpmodel); $this->shoppergroups = $sgrpmodel->getShopperGroups(false, true); $this->pagination = $sgrpmodel->getPagination(); JToolBarHelper::custom('massxref_sgrps_exe', 'groups-add', '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('class' => 'hasTooltip', '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->loadHelper('permissions'); $this->SetViewTitle($title, $msg); $this->addStandardDefaultViewLists($model, 'created_on', 'DESC', 'filter_product'); $vendor_id = $this->adminVendor; if ($vendor_id == 1) { $vendor_id = null; } // fix ??? $catid = JRequest::getInt('uctlist = ', 0); /* Get the list of products */ $productlist = $model->getProductListing(false, false, false, false, true, true, $catid, $vendor_id); //The pagination must now always set AFTER the model load the listing $this->pagination = $model->getPagination(); /* Get the category tree */ $categoryId = $model->virtuemart_category_id; //OSP switched to filter in model, was JRequest::getInt('virtuemart_category_id'); $this->category_tree = ShopFunctions::categoryListTree(array($categoryId)); /* Load the product price */ $this->loadHelper('calculationh'); $vendor_model = VmModel::getModel('vendor'); $productreviews = VmModel::getModel('ratings'); foreach ($productlist as $virtuemart_product_id => $product) { if (isset($product->virtuemart_media_id)) { $product->mediaitems = count($product->virtuemart_media_id); } else { $product->mediaitems = 'none'; } $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'); $this->manufacturers = $mf_model->getManufacturerDropdown(); /* 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, 1, '', 'onchange="Joomla.ajaxSearch(this); return false;"', 'input-medium'); /* 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, 1, '', '', 'input-small'); // Toolbar //JToolBarHelper::save('sentproductemailtoshoppers', JText::_('COM_VIRTUEMART_PRODUCT_EMAILTOSHOPPERS')); 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', 'star-2', '', JText::_('COM_VIRTUEMART_ADD_RATING'), true); $this->addStandardDefaultViewCommands(); $this->productlist = $productlist; $this->virtuemart_category_id = $categoryId; $this->model = $model; break; } parent::display($tpl); }
function display($tpl = null) { $this->loadHelper('html'); $this->loadHelper('permissions'); if (!class_exists('shopFunctionsF')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php'; } $model = VmModel::getModel(); $layoutName = $this->getLayout(); $task = JRequest::getWord('task', $layoutName); $this->task = $task; $this->perms = Permissions::getInstance(); // to add in vmview ? $multivendor = Vmconfig::get('multix', 'none'); $this->multiX = $multivendor !== 'none' && $multivendor != '' ? true : false; if ($layoutName == 'edit') { $this->loadHelper('shopfunctions'); $category = $model->getCategory('', false); if (isset($category->category_name)) { $name = $category->category_name; } else { $name = ''; } $this->SetViewTitle('CATEGORY', $name); $model->addImages($category); if ($category->virtuemart_category_id) { $this->relationInfo = $model->getRelationInfo($category->virtuemart_category_id); } $this->parent = $model->getParentCategory($category->virtuemart_category_id); $this->jTemplateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_CATEGORY_TEMPLATE_DEFAULT')); if (!class_exists('VirtueMartModelConfig')) { require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'config.php'; } $this->productLayouts = VirtueMartModelConfig::getLayoutList('productdetails', $category->category_product_layout, 'category_product_layout'); $this->categoryLayouts = VirtueMartModelConfig::getLayoutList('category', $category->category_layout, 'categorylayout'); // front autoset parent category if (!$category->virtuemart_category_id) { $this->parent->virtuemart_category_id = jRequest::getInt('category_parent_id', 0); } //Nice fix by Joe, the 4. param prevents setting an category itself as child // Note Studio42, the fix is not suffisant, you can set the category in a children and get infinit loop in router for eg. $this->categorylist = ShopFunctions::categoryListTree(array($this->parent->virtuemart_category_id), 0, 0, (array) $category->virtuemart_category_id); if (Vmconfig::get('multix', 'none') !== 'none') { $this->vendorList = ShopFunctions::renderVendorList($category->virtuemart_vendor_id, false); } $this->category = $category; $this->addStandardEditViewCommands($category->virtuemart_category_id, $category); } else { $category_id = JRequest::getInt('filter_category_id'); if (JRequest::getWord('format', '') === 'raw') { $tpl = 'results'; } else { $this->SetViewTitle('CATEGORY_S'); $this->addStandardDefaultViewCommands(); $this->categorylist = ShopFunctions::categoryListTreeLoop((array) $category_id, 0, 0); if ($this->multiX && $this->adminVendor == 1) { JToolBarHelper::custom('toggle.shared.1', 'publish', 'yes', JText::_('COM_VIRTUEMART_SHARED'), true); JToolBarHelper::custom('toggle.shared.0', 'unpublish', 'no', JText::_('COM_VIRTUEMART_SHARED'), true); } } $this->catmodel = $model; $this->addStandardDefaultViewLists($model, 'category_name'); $this->categories = $model->getCategoryTree($category_id, 0, false, $this->lists['search']); $this->pagination = $model->getPagination(); //we need a function of the FE shopfunctions helper to cut the category descriptions jimport('joomla.filter.output'); } parent::display($tpl); if ($tpl === 'results') { echo $this->AjaxScripts(); } }