Example #1
0
	public static function getDefaultTemplate(){

		if(self::$_home) return self::$_home;
		$app = JFactory::getApplication();

		if($app->isSite()){
			$template = $app->getTemplate(true);
			$template = (array) $template;
		} else {
			$q = 'SELECT id, home, template, s.params
			FROM #__template_styles as s
			LEFT JOIN #__extensions as e
			ON e.element=s.template
			AND e.type="template"
			AND e.client_id=s.client_id
			WHERE s.client_id = 0
			AND e.enabled = 1 AND s.home = 1';
			$db = JFactory::getDbo();
			$db->setQuery( $q );
			$template = $db->loadAssoc();
		}

		if(!$template){
			vmError( 'getDefaultTemplate failed ' );
			return false;
		} else {
			self::$_home = $template;
			self::$_templates[$template['id']] = $template;
			return self::$_templates[$template['id']];
		}
	}
Example #2
0
 public function display($tpl = null)
 {
     $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'virtuemart'));
     if ($view == 'virtuemart' or $view == 'about' or $this->canDo->get('core.admin') or $this->canDo->get('vm.' . $view)) {
         //Super administrators always have access
         if (JFactory::getApplication()->isSite()) {
             $unoverridable = array('category', 'manufacturer', 'user');
             //This views have the same name and must not be overridable
             if (!in_array($view, $unoverridable)) {
                 if (!class_exists('VmTemplate')) {
                     require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
                 }
                 $template = VmTemplate::getDefaultTemplate();
                 $this->addTemplatePath(VMPATH_ROOT . DS . 'templates' . DS . $template['template'] . DS . 'html' . DS . 'com_virtuemart' . DS . $this->_name);
             }
         }
         $result = $this->loadTemplate($tpl);
         if ($result instanceof Exception) {
             return $result;
         }
         echo $result;
         if ($this->writeJs) {
             vmJsApi::keepAlive();
             echo vmJsApi::writeJS();
         }
         return true;
     } else {
         JFactory::getApplication()->redirect('index.php?option=com_virtuemart', vmText::_('JERROR_ALERTNOAUTHOR'), 'error');
     }
 }
Example #3
0
 public function display($tpl = null)
 {
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $this->prepareContinueLink();
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     VmTemplate::setVmTemplate($this, 0, 0, $layoutName);
     parent::display($tpl);
 }
Example #4
0
	static public function getVmSubLayoutPath($name){
		$lPath = false;
		if(!class_exists('VmTemplate')) require(VMPATH_SITE.DS.'helpers'.DS.'vmtemplate.php');
		$vmStyle = VmTemplate::loadVmTemplateStyle();
		$template = $vmStyle['template'];
		// get the template and default paths for the layout if the site template has a layout override, use it
		$templatePath = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_virtuemart' . DS . 'sublayouts' . DS . $name . '.php';

		if(!class_exists('JFile')) require(VMPATH_LIBS.DS.'joomla'.DS.'filesystem'.DS.'file.php');
		if (JFile::exists ($templatePath)) {
			$lPath =  $templatePath;
		} else {
			if (JFile::exists (VMPATH_SITE . DS . 'sublayouts' . DS . $name . '.php')) {
				$lPath = VMPATH_SITE . DS . 'sublayouts' . DS . $name . '.php';
			}
		}
		return $lPath;
	}
Example #5
0
    public function display($tpl = null)
    {
        $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart'));
        $doc = JFactory::getDocument();
        $input = JFactory::getApplication()->input;
        $this->add_new_popup = $input->get('add_new_popup', 0, 'string');
        $this->close_window_children = $input->get('close_window_children', 0, 'int');
        $this->show_in_parent_window = $input->get('show_in_parent_window', 0, 'int');
        $dialog_element_id = $input->get('dialog_element_id', '', 'string');
        $close_ui_dialog_id = $input->get('ui_dialog_id', '', 'string');
        $parent_ui_dialog_id = $input->get('ui_dialog_id', '', 'string');
        $link_reload = $input->get('link_redirect', base64_encode('index.php?option=com_tsmart&view=' . $view), 'string');
        $parent_iframe_id = $input->get('iframe_id', '', 'string');
        $reload_iframe_id = $input->get('reload_iframe_id', '', 'string');
        $remove_ui_dialog = $input->get('remove_ui_dialog', false, 'boolean');
        $small_form = $input->get('small_form', 0, 'int');
        if ($this->show_in_parent_window == 1) {
            $doc->addScript(JUri::root() . '/administrator/components/com_tsmart/assets/js/asianventure_edit_from.js');
            $doc->addScript(JUri::root() . '/media/system/js/base64.js');
            $doc->addLessStyleSheet(JUri::root() . '/administrator/components/com_tsmart/assets/less/view_component.less');
            $js_content = '';
            ob_start();
            ?>
            <script type="text/javascript">
                jQuery(document).ready(function ($) {
                    $('.admin.com_tsmart.view-<?php 
            echo $view;
            ?>
').asianventure_edit_from({
                        show_in_parent_window:<?php 
            echo $this->show_in_parent_window == 1 ? 1 : 0;
            ?>
,
                        view_height:<?php 
            echo $this->view_height ? $this->view_height : 0;
            ?>
,
                        close_window_children:<?php 
            echo $this->close_window_children;
            ?>
,
                        dialog_element_id:'<?php 
            echo $dialog_element_id;
            ?>
',
                        link_reload:'<?php 
            echo $link_reload;
            ?>
',
                        parent_iframe_id:'<?php 
            echo $parent_iframe_id;
            ?>
',
                        parent_ui_dialog_id:'<?php 
            echo $parent_ui_dialog_id;
            ?>
',
                        close_ui_dialog_id:'<?php 
            echo $close_ui_dialog_id;
            ?>
',
                        reload_iframe_id:'<?php 
            echo $reload_iframe_id;
            ?>
',
                        remove_ui_dialog:'<?php 
            echo json_encode($remove_ui_dialog);
            ?>
',
                        small_form:<?php 
            echo $small_form;
            ?>
                    });
                });
            </script>
            <?php 
            $js_content = ob_get_clean();
            require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/utility.php';
            $js_content = TSMUtility::remove_string_javascript($js_content);
            $doc->addScriptDeclaration($js_content);
        }
        if ($view == 'tsmart' or $view == 'about' or $this->manager($view)) {
            //or $this->canDo->get('core.admin')
            //or $this->canDo->get('vm.'.$view) ) { //Super administrators always have access
            if (JFactory::getApplication()->isSite()) {
                $unoverridable = array('category', 'manufacturer', 'user');
                //This views have the same name and must not be overridable
                if (!in_array($view, $unoverridable)) {
                    if (!class_exists('VmTemplate')) {
                        require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
                    }
                    $template = VmTemplate::getDefaultTemplate();
                    $this->addTemplatePath(VMPATH_ROOT . DS . 'templates' . DS . $template['template'] . DS . 'html' . DS . 'com_tsmart' . DS . $this->_name);
                }
            }
            $result = $this->loadTemplate($tpl);
            if ($result instanceof Exception) {
                return $result;
            }
            echo $result;
            if ($this->writeJs) {
                vmJsApi::keepAlive();
                echo vmJsApi::writeJS();
            }
            return true;
        } else {
            JFactory::getApplication()->redirect('index.php?option=com_tsmart', tsmText::_('JERROR_ALERTNOAUTHOR'), 'error');
        }
    }
Example #6
0
 /**
  *  Note: We have 2 subfolders for versions > J15 for 3rd parties developers, to avoid 2 installers
  *	Note: from Version 2.12: it is possible to have the tmpl folder directly in $pluginName folder
  * @author Max Milbers, Valérie Isaksen
  */
 private function _getLayoutPath($pluginName, $group, $layout = 'default')
 {
     $layoutPath = $templatePathWithGroup = $defaultPathWithGroup = '';
     jimport('joomla.filesystem.file');
     // First search in the new system
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     $vmStyle = VmTemplate::loadVmTemplateStyle();
     $template = $vmStyle['template'];
     $templatePath = VMPATH_ROOT . DS . 'templates' . DS . $template . DS . 'html' . DS . $group . DS . $pluginName . DS . $layout . '.php';
     $defaultPath = VMPATH_ROOT . DS . 'plugins' . DS . $group . DS . $pluginName . DS . 'tmpl' . DS . $layout . '.php';
     $defaultPathWithGroup = VMPATH_ROOT . DS . 'plugins' . DS . $group . DS . $pluginName . DS . $pluginName . DS . 'tmpl' . DS . $layout . '.php';
     if (JFile::exists($templatePath)) {
         $layoutPath = $templatePath;
     } elseif (JFile::exists($defaultPath)) {
         $layoutPath = $defaultPath;
     } elseif (JFile::exists($defaultPathWithGroup)) {
         $layoutPath = $defaultPathWithGroup;
     }
     if (empty($layoutPath)) {
         $warn = 'The layout: ' . $layout . ' does not exist in:';
         $warn .= '<br />' . $templatePath . '<br />' . $defaultPath;
         if (!empty($defaultPathWithGroup)) {
             $warn .= '<br />' . $defaultPathWithGroup . '<br />';
         }
         vmWarn($warn);
         return false;
     }
     return $layoutPath;
 }
Example #7
0
 /**
  * ADD some CSS if needed
  * Prevent duplicate load of CSS stylesheet
  * @author Max Milbers
  */
 static function cssSite()
 {
     if (!VmConfig::get('css', TRUE)) {
         return FALSE;
     }
     static $cssSite;
     if ($cssSite) {
         return;
     }
     // Get the Page direction for right to left support
     $document = JFactory::getDocument();
     $direction = $document->getDirection();
     $cssFile = 'vmsite-' . $direction;
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     $vmStyle = VmTemplate::loadVmTemplateStyle();
     $template = $vmStyle['template'];
     if ($template) {
         //Fallback for old templates
         $path = 'templates' . DS . $template . DS . 'css' . DS . $cssFile . '.css';
         if (file_exists($path)) {
             // If exist exit
             vmJsApi::css($cssFile);
         } else {
             $cssFile = 'vm-' . $direction . '-common';
             vmJsApi::css($cssFile);
             $cssFile = 'vm-' . $direction . '-site';
             vmJsApi::css($cssFile);
             $cssFile = 'vm-' . $direction . '-reviews';
             vmJsApi::css($cssFile);
         }
         $cssSite = TRUE;
     }
     return TRUE;
 }
Example #8
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 = 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);
 }
Example #9
0
 function getInvoicePDF($orderDetails = 0, $viewName = 'invoice', $layout = 'invoice', $format = 'html', $force = false)
 {
     // 		$force = true;
     $path = tsmConfig::get('forSale_path', 0);
     if (empty($path)) {
         vmError('No path set to store invoices');
         return false;
     } else {
         $path .= shopFunctionsF::getInvoiceFolderName() . DS;
         if (!file_exists($path)) {
             vmError('Path wrong to store invoices, folder invoices does not exist ' . $path);
             return false;
         } else {
             if (!is_writable($path)) {
                 vmError('Cannot store pdf, directory not writeable ' . $path);
                 return false;
             }
         }
     }
     $orderModel = tmsModel::getModel('orders');
     $invoiceNumberDate = array();
     if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
         return false;
     }
     if (!empty($invoiceNumberDate[0])) {
         $invoiceNumber = $invoiceNumberDate[0];
     } else {
         $invoiceNumber = FALSE;
     }
     if (!$invoiceNumber or empty($invoiceNumber)) {
         vmError('Cant create pdf, createInvoiceNumber failed');
         return 0;
     }
     if (shopFunctionsF::InvoiceNumberReserved($invoiceNumber)) {
         return 0;
     }
     //$path .= preg_replace('/[^A-Za-z0-9_\-\.]/', '_', 'vm'.$layout.'_'.$invoiceNumber.'.pdf');
     $path .= shopFunctionsF::getInvoiceName($invoiceNumber, $layout) . '.pdf';
     if (file_exists($path) and !$force) {
         return $path;
     }
     //We come from the be, so we need to load the FE language
     tsmConfig::loadJLang('com_virtuemart', true);
     $this->addViewPath(VMPATH_SITE . DS . 'views');
     $view = $this->getView($viewName, $format);
     $this->writeJs = false;
     $view->addTemplatePath(VMPATH_SITE . DS . 'views' . DS . $viewName . DS . 'tmpl');
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     $template = VmTemplate::loadVmTemplateStyle();
     $templateName = VmTemplate::setTemplate($template);
     if (!empty($templateName)) {
         $TemplateOverrideFolder = JPATH_SITE . DS . "templates" . DS . $templateName . DS . "html" . DS . "com_virtuemart" . DS . "invoice";
         if (file_exists($TemplateOverrideFolder)) {
             $view->addTemplatePath($TemplateOverrideFolder);
         }
     }
     $view->invoiceNumber = $invoiceNumberDate[0];
     $view->invoiceDate = $invoiceNumberDate[1];
     $view->orderDetails = $orderDetails;
     $view->uselayout = $layout;
     $view->showHeaderFooter = false;
     $vendorModel = tmsModel::getModel('vendor');
     $virtuemart_vendor_id = 1;
     //We could set this automatically by the vendorId stored in the order.
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $metadata = array('title' => tsmText::sprintf('COM_VIRTUEMART_INVOICE_TITLE', $vendor->vendor_store_name, $view->invoiceNumber, $orderDetails['details']['BT']->order_number), 'keywords' => tsmText::_('COM_VIRTUEMART_INVOICE_CREATOR'));
     return VmPdf::createVmPdf($view, $path, 'F', $metadata);
 }
Example #10
0
 function display($tpl = null)
 {
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     $model = tmsModel::getModel();
     $usermodel = tmsModel::getModel('user');
     JToolBarHelper::title(tsmText::_('com_tsmart_CONFIG'), 'head vm_config_48');
     $this->addStandardEditViewCommands();
     $this->config = tsmConfig::loadConfig();
     if (!empty($this->config->_params)) {
         unset($this->config->_params['pdf_invoice']);
         // parameter remove and replaced by inv_os
     }
     $this->userparams = JComponentHelper::getParams('com_users');
     $this->jTemplateList = ShopFunctions::renderTemplateList(tsmText::_('com_tsmart_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT'));
     $this->vmLayoutList = $model->getLayoutList('tsmart');
     $this->cartLayoutList = $model->getLayoutList('cart', array('padded.php', 'perror.php'));
     $this->categoryLayoutList = $model->getLayoutList('category');
     $this->productLayoutList = $model->getLayoutList('productdetails');
     $this->productsFieldList = $model->getFieldList('products');
     $this->noimagelist = $model->getNoImageList();
     $this->orderStatusModel = tmsModel::getModel('orderstatus');
     $this->os_Options = $this->osWoP_Options = $this->osDel_Options = $this->orderStatusModel->getOrderStatusNames();
     $emptyOption = JHtml::_('select.option', -1, tsmText::_('com_tsmart_NONE'), 'order_status_code', 'order_status_name');
     array_unshift($this->os_Options, $emptyOption);
     unset($this->osWoP_Options['P']);
     array_unshift($this->osWoP_Options, $emptyOption);
     $deldate_inv = JHtml::_('select.option', 'm', tsmText::_('com_tsmart_DELDATE_INV'), 'order_status_code', 'order_status_name');
     unset($this->osDel_Options['P']);
     array_unshift($this->osDel_Options, $deldate_inv);
     array_unshift($this->osDel_Options, $emptyOption);
     //vmdebug('my $this->os_Options',$this->osWoP_Options);
     $this->currConverterList = $model->getCurrencyConverterList();
     $this->activeLanguages = $model->getActiveLanguages(tsmConfig::get('active_languages'));
     $this->orderByFieldsProduct = $model->getProductFilterFields('browse_orderby_fields');
     tmsModel::getModel('category');
     foreach (tsmartModelCategory::$_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 = tsmText::_('com_tsmart_' . strtoupper(str_replace(array(',', ' '), array('_', ''), $fieldWithoutPrefix)));
         $orderByFieldsCat[] = JHtml::_('select.option', $field, $text);
     }
     $this->orderByFieldsCat = $orderByFieldsCat;
     $this->searchFields = $model->getProductFilterFields('browse_search_fields');
     $this->aclGroups = $usermodel->getAclGroupIndentedTree();
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     $this->vmtemplate = VmTemplate::loadVmTemplateStyle();
     $this->imagePath = shopFunctions::getAvailabilityIconUrl($this->vmtemplate);
     $this->listShipment = $this->listIt('shipment');
     $this->listPayment = $this->listIt('payment');
     shopFunctions::checkSafePath();
     $this->checkTCPDFinstalled();
     $this->checkVmUserVendor();
     //$this -> checkClientIP();
     parent::display($tpl);
 }
Example #11
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $this->prepareContinueLink();
     if (VmConfig::get('use_as_catalog', 0)) {
         vmInfo('This is a catalogue, you cannot access the cart');
         $app->redirect($this->continue_link);
     }
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->addTemplatePath(dirname(__FILE__) . DS . 'tmpl' . DS);
     $path = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/plg_content_onepage_generic/';
     $this->addTemplatePath($path);
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = vRequest::getCmd('format');
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $cart->prepareVendor();
     $this->cart = $cart;
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         vRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     if ($layoutName == 'select_shipment') {
         $cart->prepareCartData();
         $this->lSelectShipment();
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             $cart->prepareCartData();
             $this->lSelectPayment();
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->lOrderDone();
                 $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->renderCompleteAddressList();
                 if (!class_exists('VirtueMartModelUserfields')) {
                     require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php';
                 }
                 $userFieldsModel = VmModel::getModel('userfields');
                 $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
                 $this->userFieldsCart = $userFieldsModel->getUserFieldsFilled($userFieldsCart, $cart->cartfields);
                 if (!class_exists('CurrencyDisplay')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $this->currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency);
                 $currency = $this->currencyDisplay;
                 $customfieldsModel = VmModel::getModel('Customfields');
                 $this->assignRef('customfieldsModel', $customfieldsModel);
                 $this->lSelectCoupon();
                 $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                 $checkoutAdvertise = $this->getCheckoutAdvertise();
                 if ($cart->getDataValidated()) {
                     if ($cart->_inConfirm) {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM');
                         $this->checkout_task = 'cancel';
                     } else {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $this->checkout_task = 'confirm';
                     }
                 } else {
                     $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $document->setTitle(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $text = vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                     $this->checkout_task = 'checkout';
                 }
                 $this->checkout_link_html = '<button type="submit"  id="checkoutFormSubmit" name="' . $this->checkout_task . '" value="1" class="vm-button-correct" ><span>' . $text . '</span> </button>';
                 if (!class_exists('vmPSPlugin')) {
                     require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                 }
                 JPluginHelper::importPlugin('vmshipment');
                 JPluginHelper::importPlugin('vmpayment');
                 vmdebug('cart view oncheckout_opc ');
                 $this->lSelectShipment();
                 $this->lSelectPayment();
                 if (VmConfig::get('oncheckout_opc', 1)) {
                 } else {
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                 }
                 if ($cart->virtuemart_shipmentmethod_id) {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                 } else {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                 }
                 $this->assignRef('select_shipment_text', $shippingText);
                 if ($cart->virtuemart_paymentmethod_id) {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                 } else {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                 }
                 $this->assignRef('select_payment_text', $paymentText);
                 $cart->prepareAddressFieldsInCart();
                 $layoutName = $cart->layout;
                 //set order language
                 $lang = JFactory::getLanguage();
                 $order_language = $lang->getTag();
                 $this->assignRef('order_language', $order_language);
             }
         }
     }
     $this->useSSL = VmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     VmTemplate::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if ($cart->_inConfirm) {
         vmInfo('COM_VIRTUEMART_IN_CONFIRM');
     }
     if ($cart->layoutPath) {
         $this->addTemplatePath($cart->layoutPath);
     }
     if (isset($_POST["tos"])) {
         $_POST["agreed"] = $_POST["tos"];
     } else {
         $_POST["agreed"] = 0;
     }
     $current = JFactory::getUser();
     $this->allowChangeShopper = false;
     $this->adminID = false;
     if (VmConfig::get('oncheckout_change_shopper')) {
         if ($current->authorise('core.admin', 'com_virtuemart') or $current->authorise('vm.user', 'com_virtuemart')) {
             $this->allowChangeShopper = true;
         } else {
             $this->adminID = JFactory::getSession()->get('vmAdminID', false);
             if ($this->adminID) {
                 if (!class_exists('vmCrypt')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
                 }
                 $this->adminID = vmCrypt::decrypt($this->adminID);
                 $adminIdUser = JFactory::getUser($this->adminID);
                 if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                     $this->allowChangeShopper = true;
                 }
             }
         }
     }
     if ($this->allowChangeShopper) {
         $this->userList = $this->getUserList();
     }
     $task = $input->getString("vmtask");
     if (file_exists(dirname(__FILE__) . "/" . $task . ".php")) {
         require_once dirname(__FILE__) . "/" . $task . ".php";
     }
     if ($task == "completecheckout") {
         require_once dirname(__FILE__) . "/updatecartaddress.php";
         $checkout = $cart->checkoutData(false);
         $app = JFactory::getApplication();
         $messageQueue = $app->getMessageQueue();
         $return_error = "";
         if (count($messageQueue) > 0) {
             foreach ($messageQueue as $message) {
                 $return_error .= $message['message'];
             }
         }
         $returnarray = array();
         if ($checkout) {
             $returnarray["success"] = 1;
         } else {
             $returnarray["success"] = 0;
         }
         $returnarray['message'] = $return_error;
         echo json_encode($returnarray);
         exit;
     }
     if ($task == "ajaxshipment") {
         $this->lSelectShipment();
         echo json_encode($this->shipments_shipment_rates);
         exit;
     }
     if ($task == "ajaxpayment") {
         $this->lSelectPayment();
         echo json_encode($this->paymentplugins_payments);
         exit;
     }
     if ($task == "setsession") {
         $payid = JRequest::getVar("payid", 0);
         if ($payid > 0) {
             $cart->setPaymentMethod(false, false, $payid);
             $cart->setCartIntoSession();
         }
         echo "success";
         exit;
     }
     if ($task == "klarnaupdate") {
         $post = JRequest::get("post");
         $address = array();
         $address['shipto_address_type_name'] = 'ST';
         if (!empty($post['given_name'])) {
             $address['shipto_first_name'] = $post['given_name'];
         }
         if (!empty($post['family_name'])) {
             $address['shipto_last_name'] = $post['family_name'];
         }
         if (!empty($post['street_address'])) {
             $address['shipto_address_1'] = $post['street_address'];
         }
         if (!empty($post['street_address2'])) {
             $address['shipto_address_2'] = $post['street_address2'];
         }
         if (!empty($post['postal_code'])) {
             $address['shipto_zip'] = $post['postal_code'];
         }
         if (!empty($post['city'])) {
             $address['shipto_city'] = $post['city'];
         }
         if (!empty($post['country'])) {
             $address['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($post['country']);
         } else {
             if (!empty($cart->BT['virtuemart_country_id'])) {
                 $address['shipto_virtuemart_country_id'] = $cart->BT['virtuemart_country_id'];
             }
         }
         if (!empty($post['region'])) {
             $address['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($post['region']);
         }
         if (!empty($post['phone'])) {
             $address['shipto_phone_1'] = $post['phone'];
         }
         $address['tos'] = 1;
         $cart->saveAddressInCart($address, 'ST', true, 'shipto_');
         $cart->setCartIntoSession(false, true);
         $return = array();
         $return['response'] = "success";
         echo json_encode($return);
         exit;
     }
     $cart->setCartIntoSession();
     parent::display($tpl);
 }
Example #12
0
 /**
  * This function sets the right template on the view
  * @author Max Milbers
  * @deprecated use class VmTemplates instead
  */
 static function setVmTemplate($view, $catTpl = 0, $prodTpl = 0, $catLayout = 0, $prodLayout = 0)
 {
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     return VmTemplate::setVmTemplate($view, $catTpl, $prodTpl, $catLayout, $prodLayout);
 }
Example #13
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);
	}
Example #14
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->prepareContinueLink();
     if (VmConfig::get('use_as_catalog', 0)) {
         vmInfo('This is a catalogue, you cannot access the cart');
         $app->redirect($this->continue_link);
     }
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->addTemplatePath(dirname(__FILE__) . DS . 'tmpl' . DS);
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = vRequest::getCmd('format');
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $this->cart->prepareVendor();
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         vRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     if ($layoutName == 'select_shipment') {
         $this->cart->prepareCartData();
         $this->lSelectShipment();
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             $this->cart->prepareCartData();
             $this->lSelectPayment();
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->lOrderDone();
                 $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->renderCompleteAddressList();
                 if (!class_exists('VirtueMartModelUserfields')) {
                     require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php';
                 }
                 $userFieldsModel = VmModel::getModel('userfields');
                 $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
                 $this->userFieldsCart = $userFieldsModel->getUserFieldsFilled($userFieldsCart, $this->cart->cartfields);
                 if (!class_exists('CurrencyDisplay')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $this->currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
                 $customfieldsModel = VmModel::getModel('Customfields');
                 $this->assignRef('customfieldsModel', $customfieldsModel);
                 $this->lSelectCoupon();
                 $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                 $checkoutAdvertise = $this->getCheckoutAdvertise();
                 if ($this->cart->getDataValidated()) {
                     if ($this->cart->_inConfirm) {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM');
                         $this->checkout_task = 'cancel';
                     } else {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $this->checkout_task = 'confirm';
                     }
                 } else {
                     $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $document->setTitle(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $text = vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                     $this->checkout_task = 'checkout';
                 }
                 $this->checkout_link_html = '<button type="submit"  id="checkoutFormSubmit" name="' . $this->checkout_task . '" value="1" class="vm-button-correct" ><span>' . $text . '</span> </button>';
                 if (VmConfig::get('oncheckout_opc', 1)) {
                     if (!class_exists('vmPSPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                     }
                     JPluginHelper::importPlugin('vmshipment');
                     JPluginHelper::importPlugin('vmpayment');
                     vmdebug('cart view oncheckout_opc ');
                     if (!$this->lSelectShipment() or !$this->lSelectPayment()) {
                         vmInfo('COM_VIRTUEMART_CART_ENTER_ADDRESS_FIRST');
                         $this->pointAddress = true;
                     }
                 } else {
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                 }
                 if ($this->cart->virtuemart_shipmentmethod_id) {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                 } else {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                 }
                 $this->assignRef('select_shipment_text', $shippingText);
                 if ($this->cart->virtuemart_paymentmethod_id) {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                 } else {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                 }
                 $this->assignRef('select_payment_text', $paymentText);
                 $this->cart->prepareAddressFieldsInCart();
                 $layoutName = $this->cart->layout;
                 //set order language
                 $lang = JFactory::getLanguage();
                 $order_language = $lang->getTag();
                 $this->assignRef('order_language', $order_language);
             }
         }
     }
     $this->useSSL = VmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     VmTemplate::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if ($this->cart->_inConfirm) {
         vmInfo('COM_VIRTUEMART_IN_CONFIRM');
     }
     if ($this->cart->layoutPath) {
         $this->addTemplatePath($this->cart->layoutPath);
     }
     $current = JFactory::getUser();
     $this->allowChangeShopper = false;
     $this->adminID = false;
     if (VmConfig::get('oncheckout_change_shopper')) {
         if ($current->authorise('core.admin', 'com_virtuemart') or $current->authorise('vm.user', 'com_virtuemart')) {
             $this->allowChangeShopper = true;
         } else {
             $this->adminID = JFactory::getSession()->get('vmAdminID', false);
             if ($this->adminID) {
                 if (!class_exists('vmCrypt')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
                 }
                 $this->adminID = vmCrypt::decrypt($this->adminID);
                 $adminIdUser = JFactory::getUser($this->adminID);
                 if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                     $this->allowChangeShopper = true;
                 }
             }
         }
     }
     if ($this->allowChangeShopper) {
         $this->userList = $this->getUserList();
     }
     parent::display($tpl);
 }