Пример #1
0
	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 = 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 = vRequest::getInt('virtuemart_product_id');

				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);
				//$user = JFactory::getUser();
				$superVendor =  VmConfig::isSuperVendor();
				if( $superVendor !=1 and $superVendor!=$product->virtuemart_vendor_id){
					JFactory::getApplication()->redirect( 'index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error');
				}
				if(!empty($product->product_parent_id)){
					$product_parent= $model->getProductSingle($product->product_parent_id,false);
				}


				$customfields = VmModel::getModel ('Customfields');

				$product->allIds[] = $product->virtuemart_product_id;
				if(!empty($product->product_parent_id)) $product->allIds[] = $product->product_parent_id;

				$product->customfields = $customfields->getCustomEmbeddedProductCustomFields ($product->allIds);
				//vmdebug('my customfields',$product->customfields);

				// 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);
				//$this->assignRef('shoppergroupList', $shoppergroupList);

				// Load the product price
				if(!class_exists('calculationHelper')) require(VMPATH_ADMIN.DS.'helpers'.DS.'calculationh.php');

				$product_childIds = $model->getProductChildIds($virtuemart_product_id);

				$product_childs = array();
				$childs = 0;
				$maxChilds = 50;
				foreach($product_childIds as $id){
					if($childs++>$maxChilds) break;
					$product_childs[] = $model->getProductSingle($id,false);
				}
				$this->product_childs = $product_childs;

				if(!class_exists('VirtueMartModelConfig')) require(VMPATH_ADMIN .'/models/config.php');
				$productLayouts = VirtueMartModelConfig::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 = 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');

				$vendor_model->setId(VmConfig::isSuperVendor());
				$this->vendor = $vendor_model->getVendor();

				$currency = $currency_model->getCurrency($this->vendor->vendor_currency);
				$this->vendor_currency_symb = $currency->currency_symbol;


				$lists['manufacturers'] = shopFunctions::renderManufacturerList($product->virtuemart_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 = 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);

				// Add the virtuemart_shoppergroup_ids
				$cid = JFactory::getUser()->id;

				$this->activeShoppergroups = shopfunctions::renderGuiList($cid,'shoppergroups','shopper_group_name','category','vmuser_shoppergroups','virtuemart_user_id');
				if(!empty($this->activeShoppergroups) ){
					//vmdebug('$this->activeShoppergroups',$this->activeShoppergroups);
					$shoppergroupModel = VmModel::getModel('shoppergroup');
					$this->activeShoppergroups = vmText::_($shoppergroupModel->getDefault(0)->shopper_group_name);
				}

				// Load protocustom lists
				$customModel = VmModel::getModel ('custom');

				$this->fieldTypes = VirtueMartModelCustom::getCustomTypes();

				$customsList = $customModel->getCustomsList ();
				$attribs='style= "width: 300px;"';
				$customlist = JHtml::_('select.genericlist', $customsList,'customlist', $attribs);

				$this->assignRef('customsList', $customlist);

				if ($product->product_parent_id > 0) {

					// Set up labels
					$info_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_INFO_LBL');
					$status_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_STATUS_LBL');
					$dim_weight_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL');
					$images_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_ITEM_IMAGES_LBL');
					$delete_message = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_DELETE_ITEM_MSG');
				}
				else {
					if ($task == 'add') $action = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_NEW_PRODUCT_LBL');
					else $action = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_UPDATE_ITEM_LBL');

					$info_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_INFO_LBL');
					$status_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_STATUS_LBL');
					$dim_weight_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL');
					$images_label = vmText::_('COM_VIRTUEMART_PRODUCT_FORM_PRODUCT_IMAGES_LBL');
					$delete_message = vmText::_('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(VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
					$menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag());
					$canonLink='';
					if($product->canonCatId) $canonLink = '&virtuemart_category_id='.$product->canonCatId;

					$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>';
					if(JFactory::getApplication()->isSite()){
						$bar = JToolBar::getInstance('toolbar');
						$bar->appendButton('Link', 'back', 'COM_VIRTUEMART_LEAVE_TO_PRODUCT', juri::root().'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.$canonLink.'&Itemid='. $menuItemID);
					}
				} 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');

				$showVendors = $this->showVendors();
				$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', vmText::_('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', vmText::_('COM_VIRTUEMART_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&virtuemart_product_id='.$product_parent->virtuemart_product_id.'&option=com_virtuemart'), $product_parent->product_name, array('title' => vmText::_('COM_VIRTUEMART_EDIT_PARENT').' '.$product_parent->product_name));
					$msg= vmText::_('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->SetViewTitle($title, $msg );

			$this->addStandardDefaultViewLists($model,'created_on');

			/* Get the list of products */
			$productlist = $model->getProductListing(false,false,false,false,true);
			//vmdebug('my product listing',$productlist);
			//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 vRequest::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(VMPATH_ADMIN.DS.'helpers'.DS.'calculationh.php');

			$vendor_model = VmModel::getModel('vendor');
			$productreviews = VmModel::getModel('ratings');

			$loaded_virtuemart_manufacturer_id = array();
			$this->mfTable = $model->getTable ('manufacturers');

			$this->catTable = $model->getTable ('categories');

			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->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 = vmText::_('COM_VIRTUEMART_MULTIPLE_PRICES');
				} else {
					$product->product_price_display = vmText::_('COM_VIRTUEMART_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->virtuemart_manufacturer_id[0])) {
					$product->manuList = shopfunctions::renderGuiList($product->virtuemart_manufacturer_id,'manufacturers','mf_name','manufacturer');
				}
			}

			$mf_model = VmModel::getModel('manufacturer');
			$manufacturers = $mf_model->getManufacturerDropdown();
			$this->assignRef('manufacturers',	$manufacturers);

			/* add Search filter in lists*/
			/* Search type */
			$options = array( '' => vmText::_('COM_VIRTUEMART_LIST_EMPTY_OPTION'),
		    				'parent' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'),
							'product' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'),
							'price' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'),
							'withoutprice' => vmText::_('COM_VIRTUEMART_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' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'),
								  'af' => vmText::_('COM_VIRTUEMART_PRODUCT_LIST_SEARCH_BY_DATE_AFTER')
			);
			$this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'),$options);

			// Toolbar
			if ($this->canDo->get('core.admin') or $this->canDo->get('vm.product.edit')) {
				JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_XREF_CAT'), true);
				JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_XREF_SGRPS'), true);
			}
			if ($this->canDo->get('core.admin') || $this->canDo->get('vm.product.create')) {
				JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('COM_VIRTUEMART_PRODUCT_CHILD'), true);
				JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('COM_VIRTUEMART_PRODUCT_CLONE'), true);
			}
			JToolBarHelper::custom('addrating', 'default', '', vmText::_('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);
	}
Пример #2
0
    function display($tpl = null)
    {
        // Load the helper(s)
        if (!class_exists('VmHTML')) {
            require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
        }
        if (!class_exists('vmCustomPlugin')) {
            require VMPATH_PLUGINLIBS . DS . 'vmcustomplugin.php';
        }
        $model = VmModel::getModel('custom');
        // TODO Make an Icon for custom
        $this->SetViewTitle('PRODUCT_CUSTOM_FIELD');
        $layoutName = vRequest::getCmd('layout', 'default');
        if ($layoutName == 'edit') {
            $this->addStandardEditViewCommands();
            $this->customPlugin = '';
            $this->custom = $model->getCustom();
            $this->fieldTypes = VirtueMartModelCustom::getCustomTypes();
            $this->customfields = VmModel::getModel('customfields');
            //vmdebug('VirtuemartViewCustom',$this->custom);
            JPluginHelper::importPlugin('vmcustom');
            $dispatcher = JDispatcher::getInstance();
            $retValue = $dispatcher->trigger('plgVmOnDisplayEdit', array($this->custom->virtuemart_custom_id, &$this->customPlugin));
            $this->SetViewTitle('PRODUCT_CUSTOM_FIELD', $this->custom->custom_title);
            $selected = 0;
            $this->custom->form = false;
            if (!empty($this->custom->custom_jplugin_id)) {
                VmConfig::loadJLang('plg_vmpsplugin', false);
                JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields');
                $selected = $this->custom->custom_jplugin_id;
                // Get the payment XML.
                $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->custom->custom_element . DS . $this->custom->custom_element . '.xml');
                if (file_exists($formFile)) {
                    $this->custom->form = JForm::getInstance($this->custom->custom_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                    $this->custom->params = new stdClass();
                    $varsToPush = vmPlugin::getVarsToPushFromForm($this->custom->form);
                    VmTable::bindParameterableToSubField($this->custom, $varsToPush);
                    $this->custom->form->bind($this->custom->getProperties());
                }
            } else {
                $varsToPush = VirtueMartModelCustom::getVarsToPush($this->custom->field_type);
                if (!empty($varsToPush)) {
                    $formString = '<vmconfig>' . chr(10) . '<fields name="params">' . chr(10) . '<fieldset name="extraParams">' . chr(10);
                    //vmdebug('$varsToPush',$varsToPush);
                    foreach ($varsToPush as $key => $push) {
                        if ('_' == substr($key, 0, 1)) {
                            continue;
                        }
                        //$default = 0;
                        $formString .= '<field
						name="' . $key . '"
        				id="' . $key . 'Field"
        				label="COM_VIRTUEMART_CUSTOM_PARAM_' . strtoupper($key) . '"
        				description="COM_VIRTUEMART_CUSTOM_PARAM_' . strtoupper($key) . '_DESC"
        				default="' . $push[0] . '"
						';
                        if ($push[1] == 'int') {
                            $formString .= 'type="radio" >
    											<option value="0">JNO</option>
    											<option value="1">JYES</option>';
                        } else {
                            if ($push[1] == 'string') {
                                $formString .= 'type="text" >' . chr(10);
                            }
                        }
                        $formString .= chr(10) . '</field>' . chr(10);
                    }
                    $formString .= '</fieldset>' . chr(10) . '</fields>' . chr(10) . '</vmconfig>';
                    $this->custom->form = JForm::getInstance($this->custom->field_type, $formString, array(), false, '//vmconfig | //config[not(//vmconfig)]');
                    $this->custom->params = new stdClass();
                    VmTable::bindParameterableToSubField($this->custom, $varsToPush);
                    $this->custom->form->bind($this->custom->getProperties());
                }
            }
            if (!empty($this->custom->custom_parent_id)) {
                $list = ShopFunctions::renderOrderingList('customs', 'custom_title', $this->custom->ordering, 'WHERE custom_parent_id ="' . (int) $this->custom->custom_parent_id . '" ');
                $this->ordering = VmHTML::row('raw', 'COM_VIRTUEMART_ORDERING', $list);
            } else {
                $this->ordering = '';
                $this->addHidden('ordering', $this->custom->ordering);
            }
            $this->pluginList = self::renderInstalledCustomPlugins($selected);
        } else {
            JToolBarHelper::custom('createClone', 'copy', 'copy', vmText::_('COM_VIRTUEMART_CLONE'), true);
            JToolBarHelper::custom('toggle.admin_only.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true);
            JToolBarHelper::custom('toggle.admin_only.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_ADMIN'), true);
            JToolBarHelper::custom('toggle.is_hidden.1', 'publish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true);
            JToolBarHelper::custom('toggle.is_hidden.0', 'unpublish', '', vmText::_('COM_VIRTUEMART_TOGGLE_HIDDEN'), true);
            $this->addStandardDefaultViewCommands();
            $this->addStandardDefaultViewLists($model);
            $this->custom_parent_id = vRequest::getInt('custom_parent_id', false);
            $this->customs = $model->getCustoms($this->custom_parent_id, vRequest::getCmd('keyword'));
            $this->pagination = $model->getPagination();
        }
        parent::display($tpl);
    }
Пример #3
0
    function display($tpl = null)
    {
        $filter = vRequest::getVar('q', vRequest::getVar('term', false));
        $id = vRequest::getInt('id', false);
        $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', array());
        if (is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0) {
            $product_id = (int) $virtuemart_product_id[0];
        } else {
            $product_id = (int) $virtuemart_product_id;
        }
        //$customfield = $this->model->getcustomfield();
        /* Get the task */
        if ($this->type == 'relatedproducts') {
            $query = "SELECT virtuemart_product_id AS id, CONCAT(product_name, '::', product_sku) AS value\n\t\t\t\tFROM #__virtuemart_products_" . VmConfig::$vmlang . "\n\t\t\t\t JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)";
            if ($filter) {
                $query .= " WHERE product_name LIKE '%" . $this->db->escape($filter, true) . "%' or product_sku LIKE '%" . $this->db->escape($filter, true) . "%' limit 0,10";
            }
            self::setRelatedHtml($product_id, $query, 'R');
        } else {
            if ($this->type == 'relatedcategories') {
                $query = "SELECT virtuemart_category_id AS id, CONCAT(category_name, '::', virtuemart_category_id) AS value\n\t\t\t\tFROM #__virtuemart_categories_" . VmConfig::$vmlang;
                if ($filter) {
                    $query .= " WHERE category_name LIKE '%" . $this->db->escape($filter, true) . "%' limit 0,10";
                }
                self::setRelatedHtml($product_id, $query, 'Z');
            } else {
                if ($this->type == 'custom') {
                    $query = "SELECT CONCAT(virtuemart_custom_id, '|', custom_value, '|', field_type) AS id, CONCAT(custom_title, '::', custom_tip) AS value\n\t\t\t\tFROM #__virtuemart_customs";
                    if ($filter) {
                        $query .= " WHERE custom_title LIKE '%" . $filter . "%' limit 0,50";
                    }
                    $this->db->setQuery($query);
                    $this->json['value'] = $this->db->loadObjectList();
                    $this->json['ok'] = 1;
                } else {
                    if ($this->type == 'fields') {
                        if (!class_exists('VirtueMartModelCustom')) {
                            require VMPATH_ADMIN . DS . 'models' . DS . 'custom.php';
                        }
                        $fieldTypes = VirtueMartModelCustom::getCustomTypes();
                        $query = 'SELECT *,`custom_value` as value FROM `#__virtuemart_customs`
			WHERE (`virtuemart_custom_id`=' . $id . ' or `custom_parent_id`=' . $id . ') ';
                        $query .= 'order by `ordering` asc';
                        $this->db->setQuery($query);
                        $rows = $this->db->loadObjectlist();
                        $html = array();
                        foreach ($rows as $field) {
                            if ($field->field_type == 'deprecatedwasC') {
                                $this->json['table'] = 'childs';
                                $q = 'SELECT `virtuemart_product_id` FROM `#__virtuemart_products` WHERE `published`=1
					AND `product_parent_id`= ' . vRequest::getInt('virtuemart_product_id');
                                //$this->db->setQuery(' SELECT virtuemart_product_id, product_name FROM `#__virtuemart_products` WHERE `product_parent_id` ='.(int)$product_id);
                                $this->db->setQuery($q);
                                if ($childIds = $this->db->loadColumn()) {
                                    // Get childs
                                    foreach ($childIds as $childId) {
                                        $field->custom_value = $childId;
                                        $display = $this->model->displayProductCustomfieldBE($field, $childId, $this->row);
                                        if ($field->is_cart_attribute) {
                                            $cartIcone = 'default';
                                        } else {
                                            $cartIcone = 'default-off';
                                        }
                                        $html[] = '<div class="removable">
								<td>' . $field->custom_title . '</td>
								 <td>' . $display . $field->custom_tip . '</td>
								 <td>' . vmText::_($fieldTypes[$field->field_type]) . '
								' . $this->model->setEditCustomHidden($field, $this->row) . '
								 </td>
								 <td><span class="vmicon vmicon-16-' . $cartIcone . '"></span></td>
								 <td></td>
								</div>';
                                        $this->row++;
                                    }
                                }
                            } else {
                                //if ($field->field_type =='E') {
                                $this->json['table'] = 'customPlugins';
                                $colspan = '';
                                if ($field->field_type == 'E') {
                                    $this->model->bindCustomEmbeddedFieldParams($field, 'E');
                                } else {
                                    if ($field->field_type == 'C') {
                                        $colspan = 'colspan="2" ';
                                    }
                                }
                                $display = $this->model->displayProductCustomfieldBE($field, $product_id, $this->row);
                                if ($field->is_cart_attribute) {
                                    $cartIcone = 'default';
                                } else {
                                    $cartIcone = 'default-off';
                                }
                                $field->virtuemart_product_id = $product_id;
                                $html[] = '
					<tr class="removable">
						<td>
							<b>' . vmText::_($fieldTypes[$field->field_type]) . '</b> ' . vmText::_($field->custom_title) . '</span><br/>

								<span class="vmicon vmicon-16-' . $cartIcone . '"></span>
								<span class="vmicon vmicon-16-move"></span>
								<span class="vmicon vmicon-16-remove"></span>

						' . $this->model->setEditCustomHidden($field, $this->row) . '
					 	</td>
							<td ' . $colspan . '>' . $display . '</td>
						 </tr>
					</tr>';
                                $this->row++;
                            }
                        }
                        $this->json['value'] = $html;
                        $this->json['ok'] = 1;
                    } else {
                        if ($this->type == 'userlist') {
                            $status = vRequest::getvar('status');
                            $productShoppers = 0;
                            if ($status) {
                                $productModel = VmModel::getModel('product');
                                $productShoppers = $productModel->getProductShoppersByStatus($product_id, $status);
                            }
                            if (!class_exists('ShopFunctions')) {
                                require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
                            }
                            $html = ShopFunctions::renderProductShopperList($productShoppers);
                            $this->json['value'] = $html;
                        } else {
                            $this->json['ok'] = 0;
                        }
                    }
                }
            }
        }
        if (empty($this->json)) {
            $this->json['value'] = null;
            $this->json['ok'] = 1;
        }
        echo vmJsApi::safe_json_encode($this->json);
    }