function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $layoutName = $this->getLayout(); $task = vRequest::getCmd('task', $layoutName); $this->assignRef('task', $task); if ($layoutName == 'edit') { //For shoppergroup specific price display tsmConfig::loadJLang('com_tsmart_config'); tsmConfig::loadJLang('com_tsmart_shoppers', true); $shoppergroup = $model->getShopperGroup(); $this->SetViewTitle('SHOPPERGROUP', $shoppergroup->shopper_group_name); if ($this->showVendors()) { $this->vendorList = ShopFunctions::renderVendorList($shoppergroup->tsmart_vendor_id); } $this->assignRef('shoppergroup', $shoppergroup); $this->addStandardEditViewCommands(); } else { $this->SetViewTitle(); $showVendors = $this->showVendors(); $this->assignRef('showVendors', $showVendors); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model); $shoppergroups = $model->getShopperGroups(false, true); $this->assignRef('shoppergroups', $shoppergroups); $pagination = $model->getPagination(); $this->assignRef('sgrppagination', $pagination); } parent::display($tpl); }
function display($tpl = null) { // Load the helper(s) $this->addHelperPath(VMPATH_ADMIN . DS . 'helpers'); if (!class_exists('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $layoutName = vRequest::getCmd('layout', 'default'); $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { tsmConfig::loadJLang('plg_vmpsplugin', false); JForm::addFieldPath(VMPATH_ADMIN . DS . 'fields'); $shipment = $model->getShipment(); // Get the payment XML. $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmshipment' . DS . $shipment->shipment_element . DS . $shipment->shipment_element . '.xml'); if (file_exists($formFile)) { $shipment->form = JForm::getInstance($shipment->shipment_element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $shipment->params = new stdClass(); $varsToPush = vmPlugin::getVarsToPushFromForm($shipment->form); tsmTable::bindParameterableToSubField($shipment, $varsToPush); $shipment->form->bind($shipment->getProperties()); } else { $shipment->form = null; } if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $vendor_id = 1; $currency = tsmartModelVendor::getVendorCurrency($vendor_id); $this->assignRef('vendor_currency', $currency->currency_symbol); if ($this->showVendors()) { $vendorList = ShopFunctions::renderVendorList($shipment->tsmart_vendor_id); $this->assignRef('vendorList', $vendorList); } $this->pluginList = self::renderInstalledShipmentPlugins($shipment->shipment_jplugin_id); $this->assignRef('shipment', $shipment); $this->shopperGroupList = ShopFunctions::renderShopperGroupList($shipment->tsmart_shoppergroup_ids, true); $this->addStandardEditViewCommands($shipment->tsmart_shipmentmethod_id); } else { JToolBarHelper::custom('cloneshipment', 'copy', 'copy', tsmText::_('com_tsmart_SHIPMENT_CLONE'), true); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model); $this->shipments = $model->getShipments(); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); foreach ($this->shipments as &$data) { // Write the first 5 shoppergroups in the list $data->shipmentShoppersList = shopfunctions::renderGuiList($data->tsmart_shoppergroup_ids, 'shoppergroups', 'shopper_group_name', 'shopper'); } $this->pagination = $model->getPagination(); } parent::display($tpl); }
public function __construct() { parent::__construct(); $this->useSSL = tsmConfig::get('useSSL', 0); $this->useXHTML = false; tsmConfig::loadJLang('com_virtuemart_shoppers', TRUE); }
function display($tpl = null) { tsmConfig::loadJLang('com_tsmart_countries'); //co if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel('language'); $zoneModel = tmsModel::getModel('worldzones'); $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->language = $model->getData(); $this->wzsList = $zoneModel->getWorldZonesSelectList(); $this->addStandardEditViewCommands(); } else { $this->addStandardDefaultViewCommandsEditInline(true, false); //First the view lists, it sets the state of the model $this->addStandardDefaultViewLists($model, 0, 'ASC'); $filter_language = vRequest::getCmd('filter_language', false); $this->items = $model->getItemList(); $this->pagination = $model->getPagination(); } parent::display($tpl); }
function getInput() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); $model = tmsModel::getModel('Manufacturer'); $manufacturers = $model->getManufacturers(true, true, false); return JHtml::_('select.genericlist', $manufacturers, $this->name, 'class="inputbox" ', 'value', 'text', $this->value, $this->id); }
/** * Method to get the field input markup. Use as name the view of the desired layout list + "layout". * For example <field name="categorylayout" for all layouts of hte category view. * * @author Max Milbers * @return string The field input markup. * @since 2.0.24a */ function getInput() { tsmConfig::loadJLang('com_tsmart'); $view = substr($this->fieldname, 0, -6); $model = tmsModel::getModel('config'); $vmLayoutList = $model->getFieldList('products'); $html = JHtml::_('Select.genericlist', $vmLayoutList, $this->name, 'size=1 width=200', 'value', 'text', array($this->value)); return $html; }
function getInput() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); $key = $this->element['key_field'] ? $this->element['key_field'] : 'value'; $val = $this->element['value_field'] ? $this->element['value_field'] : $this->name; $model = tmsModel::getModel('vendor'); $vendors = $model->getVendors(true, true, false); return JHtml::_('select.genericlist', $vendors, $this->name, 'class="inputbox" size="1"', 'tsmart_vendor_id', 'vendor_name', $this->value, $this->id); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); $categorylist = ShopFunctions::categoryListTree(array($this->value)); $html = '<select class="inputbox" name="' . $this->name . '" >'; $html .= '<option value="0">' . tsmText::_('com_tsmart_CATEGORY_FORM_TOP_LEVEL') . '</option>'; $html .= $categorylist; $html .= "</select>"; return $html; }
function display($tpl = null) { $db = JFactory::getDBO(); if ($tsmart_media_id = vRequest::getInt('tsmart_media_id')) { //$db = JFactory::getDBO(); $query = 'SELECT `file_url`,`file_title` FROM `#__tsmart_medias` where `tsmart_media_id`=' . $tsmart_media_id; $db->setQuery($query); $json = $db->loadObject(); if (isset($json->file_url)) { $json->file_url = JURI::root() . $json->file_url; $json->msg = 'OK'; echo vmJsApi::safe_json_encode($json); } else { $json->msg = '<b>' . tsmText::_('com_tsmart_NO_IMAGE_SET') . '</b>'; echo json_encode($json); } } elseif ($custom_jplugin_id = vRequest::getInt('custom_jplugin_id')) { $table = '#__extensions'; $ext_id = 'extension_id'; $q = 'SELECT `params`,`element` FROM `' . $table . '` WHERE `' . $ext_id . '` = "' . $custom_jplugin_id . '"'; $db->setQuery($q); $this->jCustom = $db->loadObject(); $customModel = tmsModel::getModel('custom'); $this->custom = $customModel->getCustom(); // Get the payment XML. $formFile = vRequest::filterPath(VMPATH_ROOT . DS . 'plugins' . DS . 'vmcustom' . DS . $this->jCustom->element . DS . $this->jCustom->element . '.xml'); if (file_exists($formFile)) { tsmConfig::loadJLang('plg_vmpsplugin', false); if (!class_exists('vmPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmplugin.php'; } $filename = 'plg_vmcustom_' . $this->jCustom->element; vmPlugin::loadJLang($filename, 'vmcustom', $this->jCustom->element); $this->custom = tmsModel::getModel('custom')->getCustom(); $varsToPush = vmPlugin::getVarsToPushByXML($formFile, 'customForm'); $this->custom->form = JForm::getInstance($this->jCustom->element, $formFile, array(), false, '//vmconfig | //config[not(//vmconfig)]'); $this->custom->params = new stdClass(); foreach ($varsToPush as $k => $field) { if (strpos($k, '_') != 0) { $this->custom->params->{$k} = $field[0]; } } $this->custom->form->bind($this->custom->getProperties()); $form = $this->custom->form; include VMPATH_ADMIN . DS . 'fields' . DS . 'formrenderer.php'; echo '<input type="hidden" value="' . $this->jCustom->element . '" name="custom_value">'; } else { $this->custom->form = null; //VmConfig::$echoDebug = 1; vmdebug('File does not exist ' . $formFile); } } jExit(); }
protected function getOptions() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart', false); $cModel = tmsModel::getModel('currency'); $values = $cModel->getVendorAcceptedCurrrenciesList(); $options[] = JHtml::_('select.option', 0, tsmText::_('com_tsmart_DEFAULT_VENDOR_CURRENCY')); $options[] = JHtml::_('select.option', -1, tsmText::_('com_tsmart_SELECTED_MODULE_CURRENCY')); foreach ($values as $v) { $options[] = JHtml::_('select.option', $v->tsmart_currency_id, $v->currency_txt); } return $options; }
/** * Method to get the field input markup. Use as name the view of the desired layout list + "layout". * For example <field name="categorylayout" for all layouts of hte category view. * * @author Max Milbers * @return string The field input markup. * @since 2.0.24a */ function getInput() { tsmConfig::loadJLang('com_tsmart'); $this->view = (string) $this->element['view']; if (empty($this->view)) { $view = substr($this->fieldname, 0, -6); } else { $view = $this->view; } $vmLayoutList = tsmartModelConfig::getLayoutList($view); $html = JHtml::_('Select.genericlist', $vmLayoutList, $this->name, 'size=1 width=200', 'value', 'text', array($this->value)); return $html; }
/** * Method to get the field input markup. * * @return string The field input markup. * * @since 11.1 */ protected function getInput() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); $option = vRequest::getCmd('option'); if (!function_exists('curl_init') or !function_exists('curl_exec')) { return tsmText::_('com_tsmart_PS_CURL_LIBRARY_NOT_INSTALLED'); } else { $js = "\n jQuery(document).ready(function( \$ ) {\n \$( '#vmcurl' ) .closest('.control-group').hide();\n });\n "; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); return '<span id="vmcurl"></span>'; } }
/** * Todo do we need that anylonger? that way. * @see JController::display() */ public function display($cachable = false, $urlparams = false) { $format = vRequest::getCmd('format', 'html'); if ($format == 'pdf') { $viewName = 'pdf'; } else { $viewName = 'orders'; } tsmConfig::loadJLang('com_virtuemart_orders', TRUE); tsmConfig::loadJLang('com_virtuemart_shoppers', TRUE); $view = $this->getView($viewName, $format); // Display it all $view->display(); }
/** * constructs a VmModel * setMainTable defines the maintable of the model * @author Max Milbers */ function __construct() { parent::__construct('tsmart_userfield_id'); $this->setMainTable('userfields'); $this->setToggleName('required'); $this->setToggleName('cart'); $this->setToggleName('shipment'); $this->setToggleName('account'); // Instantiate the Helper class self::$_cache_ordered = null; self::$_cache_named = array(); $this->_selectedOrdering = 'ordering'; $this->_selectedOrderingDir = 'ASC'; tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); }
protected function getOptions() { tsmConfig::loadJLang('com_tsmart_orders', TRUE); $options = array(); $db = JFactory::getDBO(); $query = 'SELECT `order_status_code` AS value, `order_status_name` AS text FROM `#__tsmart_orderstates` WHERE `tsmart_vendor_id` = 1 ORDER BY `ordering` ASC '; $db->setQuery($query); $values = $db->loadObjectList(); foreach ($values as $value) { $options[] = JHtml::_('select.option', $value->value, tsmText::_($value->text)); } return $options; }
function getInput() { defined('DS') or define('DS', DIRECTORY_SEPARATOR); if (!class_exists('tsmConfig')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_tsmart' . DS . 'helpers' . DS . 'config.php'; } if (!class_exists('tmsModel')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'tsmmodel.php'; } tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); $key = $this->element['key_field'] ? $this->element['key_field'] : 'value'; $val = $this->element['value_field'] ? $this->element['value_field'] : $this->name; $model = tmsModel::getModel('Orderstatus'); $orderStatus = $model->getOrderStatusList(true); foreach ($orderStatus as $orderState) { $orderState->order_status_name = tsmText::_($orderState->order_status_name); } return JHtml::_('select.genericlist', $orderStatus, $this->name, 'class="inputbox" multiple="true" size="1"', 'order_status_code', 'order_status_name', $this->value, $this->id); }
protected function getInput() { tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart'); if (!is_array($this->value)) { $this->value = array($this->value); } $categorylist = ShopFunctions::categoryListTree($this->value); $name = $this->name; if ($this->multiple) { $name = $this->name; $this->multiple = ' multiple="multiple" '; } $html = '<select class="inputbox" name="' . $name . '" ' . $this->multiple . ' >'; if (!$this->multiple) { $html .= '<option value="0">' . tsmText::_('com_tsmart_CATEGORY_FORM_TOP_LEVEL') . '</option>'; } $html .= $categorylist; $html .= "</select>"; return $html; }
function display($tpl = null) { // Load the helper(s) jimport('joomla.filesystem.file'); $config = JFactory::getConfig(); $log_path = $config->get('log_path', VMPATH_ROOT . "/log"); $layoutName = vRequest::getCmd('layout', 'default'); tsmConfig::loadJLang('com_tsmart_log'); if ($layoutName == 'edit') { $logFile = basename(vRequest::filterPath(vRequest::getString('logfile', ''))); $this->SetViewTitle('LOG', $logFile); $fileContent = file_get_contents($log_path . DS . $logFile); $this->fileContentByLine = explode("\n", $fileContent); JToolBarHelper::cancel(); } else { if (!class_exists('JFolder')) { require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php'; } $this->logFiles = JFolder::files($log_path, $filter = '.', true, false, array('index.html')); $this->SetViewTitle('LOG'); $this->path = $log_path; } parent::display($tpl); }
function display($tpl = null) { if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } tsmConfig::loadJLang('com_tsmart_orders', TRUE); if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } $layout = $this->getLayout(); if ($this->manager('report')) { vmSetStartTime('report'); $model = tmsModel::getModel('tsmart'); $nbrCustomers = $model->getTotalCustomers(); $this->nbrCustomers = $nbrCustomers; $nbrActiveProducts = $model->getTotalActiveProducts(); $this->nbrActiveProducts = $nbrActiveProducts; $nbrInActiveProducts = $model->getTotalInActiveProducts(); $this->nbrInActiveProducts = $nbrInActiveProducts; $nbrFeaturedProducts = $model->getTotalFeaturedProducts(); $this->nbrFeaturedProducts = $nbrFeaturedProducts; $ordersByStatus = $model->getTotalOrdersByStatus(); $this->ordersByStatus = $ordersByStatus; $recentOrders = $model->getRecentOrders(); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } /* Apply currency This must be done per order since it's vendor specific */ $_currencies = array(); // Save the currency data during this loop for performance reasons foreach ($recentOrders as $tsmart_order_id => $order) { //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code if (!array_key_exists('v' . $order->tsmart_vendor_id, $_currencies)) { $_currencies['v' . $order->tsmart_vendor_id] = CurrencyDisplay::getInstance('', $order->tsmart_vendor_id); } $order->order_total = $_currencies['v' . $order->tsmart_vendor_id]->priceDisplay($order->order_total); } $this->recentOrders = $recentOrders; $recentCustomers = $model->getRecentCustomers(); $this->recentCustomers = $recentCustomers; $reportModel = tmsModel::getModel('report'); vRequest::setvar('task', ''); $myCurrencyDisplay = CurrencyDisplay::getInstance(); $revenueBasic = $reportModel->getRevenue(60, true); $this->report = $revenueBasic['report']; vmJsApi::addJScript("jsapi", "//google.com/jsapi", false, false, ''); vmJsApi::addJScript('vm.stats_chart', $revenueBasic['js'], false, true); vmTime('Created report', 'report'); } //if($layout=='default'){ $j = 'jQuery("#feed").ready(function(){ var datas = ""; vmSiteurl = "' . JURI::root() . '" jQuery.ajax({ type: "GET", async: true, cache: false, dataType: "json", url: vmSiteurl + "index.php?option=com_tsmart&view=tsmart&task=feed", data: datas, dataType: "html" }) .done(function( data ) { jQuery("#feed").append(data); }); })'; vmJsApi::addJScript('getFeed', $j, false, true); //} self::showACLPref($this); parent::display($tpl); }
/** * Bind the post data to the JUser object and the VM tables, then saves it * It is used to register new users * This function can also change already registered users, this is important when a registered user changes his email within the checkout. * * @author Max Milbers * @author Oscar van Eijk * @return boolean True is the save was successful, false otherwise. */ public function store(&$data) { $message = ''; vRequest::vmCheckToken('Invalid Token, while trying to save user'); if (empty($data)) { vmError('Developer notice, no data to store for user'); return false; } //To find out, if we have to register a new user, we take a look on the id of the usermodel object. //The constructor sets automatically the right id. $new = false; if (empty($this->_id) or $this->_id < 1) { $new = true; $user = new JUser(); //thealmega http://forum.tsmart.net/index.php?topic=99755.msg393758#msg393758 } else { $cUser = JFactory::getUser(); if (!vmAccess::manager('user.edit') and $cUser->id != $this->_id) { vmWarn('Insufficient permission'); return false; } $user = JFactory::getUser($this->_id); } $gid = $user->get('gid'); // Save original gid // Preformat and control user datas by plugin JPluginHelper::importPlugin('vmuserfield'); $dispatcher = JDispatcher::getInstance(); $valid = true; $dispatcher->trigger('plgVmOnBeforeUserfieldDataSave', array(&$valid, $this->_id, &$data, $user)); // $valid must be false if plugin detect an error if (!$valid) { return false; } // Before I used this "if($cart && !$new)" // This construction is necessary, because this function is used to register a new JUser, so we need all the JUser data in $data. // On the other hand this function is also used just for updating JUser data, like the email for the BT address. In this case the // name, username, password and so on is already stored in the JUser and dont need to be entered again. if (empty($data['email'])) { $email = $user->get('email'); if (!empty($email)) { $data['email'] = $email; } } else { $data['email'] = vRequest::getEmail('email', ''); } //$data['email'] = str_replace(array('\'','"',',','%','*','/','\\','?','^','`','{','}','|','~'),array(''),$data['email']); //This is important, when a user changes his email address from the cart, //that means using view user layout edit_address (which is called from the cart) $user->set('email', $data['email']); if (empty($data['name'])) { $name = $user->get('name'); if (!empty($name)) { $data['name'] = $name; } } else { $data['name'] = vRequest::getWord('name', ''); } $data['name'] = str_replace(array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $data['name']); if (empty($data['username'])) { $username = $user->get('username'); if (!empty($username)) { $data['username'] = $username; } else { $data['username'] = vRequest::getWord('username', ''); } } if (empty($data['password'])) { $data['password'] = vRequest::getCmd('password', ''); if ($data['password'] != vRequest::get('password')) { vmError('Password contained invalid character combination.'); return false; } } if (empty($data['password2'])) { $data['password2'] = vRequest::getCmd('password2'); if ($data['password2'] != vRequest::get('password2')) { vmError('Password2 contained invalid character combination.'); return false; } } if (!$new and empty($data['password2'])) { unset($data['password']); unset($data['password2']); } if (!vmAccess::manager('core')) { $whiteDataToBind = array(); if (isset($data['name'])) { $whiteDataToBind['name'] = $data['name']; } if (isset($data['username'])) { $whiteDataToBind['username'] = $data['username']; } if (isset($data['email'])) { $whiteDataToBind['email'] = $data['email']; } if (isset($data['language'])) { $whiteDataToBind['language'] = $data['language']; } if (isset($data['editor'])) { $whiteDataToBind['editor'] = $data['editor']; } if (isset($data['password'])) { $whiteDataToBind['password'] = $data['password']; } if (isset($data['password2'])) { $whiteDataToBind['password2'] = $data['password2']; } unset($data['isRoot']); } else { $whiteDataToBind = $data; } // Bind Joomla userdata if (!$user->bind($whiteDataToBind)) { vmdebug('Couldnt bind data to joomla user'); //array('user'=>$user,'password'=>$data['password'],'message'=>$message,'newId'=>$newId,'success'=>false); } if ($new) { // If user registration is not allowed, show 403 not authorized. // But it is possible for admins and storeadmins to save $usersConfig = JComponentHelper::getParams('com_users'); $cUser = JFactory::getUser(); if ($usersConfig->get('allowUserRegistration') == '0' and !vmAccess::manager('user')) { tsmConfig::loadJLang('com_tsmart'); vmError(tsmText::_('com_tsmart_ACCESS_FORBIDDEN')); return; } // Initialize new usertype setting $newUsertype = $usersConfig->get('new_usertype'); if (!$newUsertype) { $newUsertype = 2; } // Set some initial user values $user->set('usertype', $newUsertype); $user->groups[] = $newUsertype; $date = JFactory::getDate(); $user->set('registerDate', $date->toSQL()); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); $doUserActivation = false; if ($useractivation == '1' or $useractivation == '2') { $doUserActivation = true; } if ($doUserActivation) { jimport('joomla.user.helper'); $user->set('activation', vRequest::getHash(JUserHelper::genRandomPassword())); $user->set('block', '1'); //$user->set('lastvisitDate', '0000-00-00 00:00:00'); } } $option = vRequest::getCmd('option'); // If an exising superadmin gets a new group, make sure enough admins are left... if (!$new && $user->get('gid') != $gid && $gid == __SUPER_ADMIN_GID) { if ($this->getSuperAdminCount() <= 1) { vmError(tsmText::_('com_tsmart_USER_ERR_ONLYSUPERADMIN')); return false; } } if (isset($data['language'])) { $user->setParam('language', $data['language']); } // Save the JUser object if (!$user->save()) { $msg = tsmText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $user->getError()); vmError($msg, $msg); return false; } else { $data['name'] = $user->get('name'); $data['username'] = $user->get('username'); $data['email'] = $user->get('email'); $data['language'] = $user->get('language'); $data['editor'] = $user->get('editor'); } $newId = $user->get('id'); $data['tsmart_user_id'] = $newId; //We need this in that case, because data is bound to table later $this->setUserId($newId); //Save the VM user stuff if (!$this->saveUserData($data) || !self::storeAddress($data)) { vmError('com_tsmart_NOT_ABLE_TO_SAVE_USER_DATA'); // vmError(vmText::_('com_tsmart_NOT_ABLE_TO_SAVE_USERINFO_DATA')); } else { if ($new) { $user->userInfo = $data; $password = ''; if ($usersConfig->get('sendpassword', 1)) { $password = $user->password_clear; } $this->sendRegistrationEmail($user, $password, $doUserActivation); if ($doUserActivation) { vmInfo('com_tsmart_REG_COMPLETE_ACTIVATE'); } else { vmInfo('com_tsmart_REG_COMPLETE'); $user->set('activation', ''); $user->set('block', '0'); $user->set('guest', '0'); } } else { vmInfo('com_tsmart_USER_DATA_STORED'); } } //The extra check for isset vendor_name prevents storing of the vendor if there is no form (edit address cart) if ((int) $data['user_is_vendor'] == 1 and isset($data['vendor_currency'])) { vmdebug('vendor recognised ' . $data['tsmart_vendor_id']); if ($this->storeVendorData($data)) { if ($new) { if ($doUserActivation) { vmInfo('com_tsmart_REG_VENDOR_COMPLETE_ACTIVATE'); } else { vmInfo('com_tsmart_REG_VENDOR_COMPLETE'); } } else { vmInfo('com_tsmart_VENDOR_DATA_STORED'); } } } return array('user' => $user, 'password' => $data['password'], 'message' => $message, 'newId' => $newId, 'success' => true); }
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); }
* @subpackage modules * * @copyright (C) 2010-2014 The VirtueMart Team * @author Valerie Isaksen, Max Milbers * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * VirtueMart is Free Software. * VirtueMart comes with absolute no warranty. * * www.tsmart.net */ defined('DS') or define('DS', DIRECTORY_SEPARATOR); if (!class_exists('tsmConfig')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } tsmConfig::loadConfig(); tsmConfig::loadJLang('mod_virtuemart_search', true); // Load the tsmart main parse code $button = $params->get('button', 0); $imagebutton = $params->get('imagebutton', 0); $button_pos = $params->get('button_pos', 'left'); $button_text = $params->get('button_text', tsmText::_('MOD_VIRTUEMART_SEARCH_GO')); $width = intval($params->get('width', 20)); $maxlength = $width > 20 ? $width : 20; $text = $params->get('text', tsmText::_('MOD_VIRTUEMART_SEARCH_TEXT_TXT')); $set_Itemid = intval($params->get('set_itemid', 0)); $moduleclass_sfx = $params->get('moduleclass_sfx', ''); if ($params->get('filter_category', 0)) { $category_id = vRequest::getInt('virtuemart_category_id', 0); } else { $category_id = 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); }
public static function getVMComponent($authCheck = true) { $lang = JFactory::getLanguage(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $q = 'SELECT m.id, m.title, m.alias, m.link, m.parent_id, m.img, e.element FROM `#__menu` as m LEFT JOIN #__extensions AS e ON m.component_id = e.extension_id WHERE m.client_id = 1 AND e.enabled = 1 AND m.id > 1 AND e.element = \'com_virtuemart\' AND (m.parent_id=1 OR m.parent_id = (SELECT m.id FROM `#__menu` as m LEFT JOIN #__extensions AS e ON m.component_id = e.extension_id WHERE m.parent_id=1 AND m.client_id = 1 AND e.enabled = 1 AND m.id > 1 AND e.element = \'com_virtuemart\')) ORDER BY m.lft'; $db->setQuery($q); $vmComponentItems = $db->loadObjectList(); $result = new stdClass(); if (!class_exists('tsmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } tsmConfig::loadConfig(); if ($vmComponentItems) { if (!class_exists('tsmConfig')) { require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } tsmConfig::loadJLang('com_virtuemart.sys'); // Parse the list of extensions. foreach ($vmComponentItems as &$vmComponentItem) { $vmComponentItem->link = vRequest::vmSpecialChars(trim($vmComponentItem->link)); if ($vmComponentItem->parent_id == 1) { if ($authCheck == false || $authCheck && $user->authorise('core.manage', $vmComponentItem->element)) { $result = $vmComponentItem; if (!isset($result->submenu)) { $result->submenu = array(); } if (empty($vmComponentItem->link)) { $vmComponentItem->link = 'index.php?option=' . $vmComponentItem->element; } $vmComponentItem->text = $lang->hasKey($vmComponentItem->title) ? JText::_($vmComponentItem->title) : $vmComponentItem->alias; } } else { // Sub-menu level. if (isset($result)) { // Add the submenu link if it is defined. if (isset($result->submenu) && !empty($vmComponentItem->link)) { $vmComponentItem->text = $lang->hasKey($vmComponentItem->title) ? JText::_($vmComponentItem->title) : $vmComponentItem->alias; $class = preg_replace('#\\.[^.]*$#', '', basename($vmComponentItem->img)); $class = preg_replace('#\\.\\.[^A-Za-z0-9\\.\\_\\- ]#', '', $class); if (JVM_VERSION < 3) { $vmComponentItem->class = "icon-16-" . $class; } else { $vmComponentItem->class = ''; } $result->submenu[] =& $vmComponentItem; } } } } $props = get_object_vars($result); if (!empty($props)) { return $result; } } return false; }
$manage = vRequest::getCmd('manage', $session->get('manage', false, 'vm')); if (!$manage) { $session->set('manage', 0, 'vm'); } $feViews = array('askquestion', 'cart', 'invoice', 'pdf', 'pluginresponse', 'productdetails', 'recommend', 'vendor', 'vmplg'); $app = JFactory::getApplication(); if ($manage and $task != 'feed' and !in_array($_controller, $feViews)) { if (shopFunctionsF::isFEmanager()) { $session->set('manage', 1, 'vm'); vRequest::setVar('manage', '1'); vRequest::setVar('tmpl', 'component'); tsmConfig::loadJLang('com_virtuemart'); $jlang = JFactory::getLanguage(); $tag = $jlang->getTag(); $jlang->load('', JPATH_ADMINISTRATOR, $tag, true); tsmConfig::loadJLang('com_virtuemart'); $basePath = VMPATH_ADMIN; $trigger = 'onVmAdminController'; vmJsApi::jQuery(false); vmJsApi::loadBECSS(); $router = $app->getRouter(); $router->setMode(0); } else { $session->set('manage', 0, 'vm'); vRequest::setVar('manage', 0); $basePath = VMPATH_SITE; $app->redirect('index.php?option=com_virtuemart', tsmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS')); } } elseif ($_controller) { if ($_controller != 'productdetails') { $session->set('manage', 0, 'vm');
/** * Method to display the view * * @access public * @author */ function __construct() { tsmConfig::loadJLang('com_tsmart_orders', TRUE); parent::__construct(); }
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * VirtueMart is Free Software. * VirtueMart comes with absolute no warranty. * * www.tsmart.net *---------------------------------------------------------------------- * This code creates a list of the bestselling products * and displays it wherever you want *---------------------------------------------------------------------- */ defined('DS') or define('DS', DIRECTORY_SEPARATOR); if (!class_exists('tsmConfig')) { require JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php'; } tsmConfig::loadConfig(); tsmConfig::loadJLang('mod_virtuemart_category', true); vmJsApi::jQuery(); vmJsApi::cssSite(); /* Setting */ $categoryModel = tmsModel::getModel('Category'); $category_id = $params->get('Parent_Category_id', 0); $class_sfx = $params->get('class_sfx', ''); $moduleclass_sfx = $params->get('moduleclass_sfx', ''); $layout = $params->get('layout', 'default'); $active_category_id = vRequest::getInt('virtuemart_category_id', '0'); $vendorId = '1'; $categories = $categoryModel->getChildCategoryList($vendorId, $category_id); // We dont use image here //$categoryModel->addImages($categories); if (empty($categories)) { return false;
function display($tpl = null) { //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('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } $orderStatusModel = tmsModel::getModel('orderstatus'); $orderStates = $orderStatusModel->getOrderStatusList(true); $this->SetViewTitle('ORDER'); $orderModel = tmsModel::getModel(); $curTask = vRequest::getCmd('task'); if ($curTask == 'edit') { tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); tsmConfig::loadJLang('com_tsmart_orders', true); //For getOrderStatusName if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } // Load addl models $userFieldsModel = tmsModel::getModel('userfields'); // Get the data $tsmart_order_id = vRequest::getInt('tsmart_order_id'); $order = $orderModel->getOrder($tsmart_order_id); if (empty($order['details'])) { JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=orders', tsmText::_('com_tsmart_ORDER_NOTFOUND')); } $_orderID = $order['details']['BT']->tsmart_order_id; $orderbt = $order['details']['BT']; $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt; $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->tsmart_order_id); $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->tsmart_vendor_id); $this->assignRef('currency', $currency); $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'name', 'password', 'password2', 'agreed', 'address_type')); $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type')); $_userFields = array_merge($userFieldsCart, $_userFields); //Fallback for customer_note if (empty($orderbt->customer_note) and !empty($orderbt->oc_note)) { $orderbt->customer_note = $orderbt->oc_note; } $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_'); $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_'); // Create an array to allow orderlinestatuses to be translated // We'll probably want to put this somewhere in ShopFunctions... $_orderStatusList = array(); foreach ($orderStates as $orderState) { //$_orderStatusList[$orderState->tsmart_orderstate_id] = $orderState->order_status_name; //When I use update, I have to use this? $_orderStatusList[$orderState->order_status_code] = tsmText::_($orderState->order_status_name); } $_itemStatusUpdateFields = array(); $_itemAttributesUpdateFields = array(); foreach ($order['items'] as $_item) { $_itemStatusUpdateFields[$_item->tsmart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[" . $_item->tsmart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->tsmart_order_item_id, true); } if (!isset($_orderStatusList[$orderbt->order_status])) { if (empty($orderbt->order_status)) { $orderbt->order_status = 'unknown'; } $_orderStatusList[$orderbt->order_status] = tsmText::_('com_tsmart_UNKNOWN_ORDER_STATUS'); } $this->lists['search'] = ''; /* Assign the data */ $this->assignRef('orderdetails', $order); $this->assignRef('orderID', $_orderID); $this->assignRef('userfields', $userfields); $this->assignRef('shipmentfields', $shipmentfields); $this->assignRef('orderstatuslist', $_orderStatusList); $this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields); $this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields); $this->assignRef('orderbt', $orderbt); $this->assignRef('orderst', $orderst); $this->assignRef('tsmart_shipmentmethod_id', $orderbt->tsmart_shipmentmethod_id); /* Data for the Edit Status form popup */ $_currentOrderStat = $order['details']['BT']->order_status; // used to update all item status in one time $_orderStatusSelect = JHtml::_('select.genericlist', $orderStates, 'order_status', 'style="width:100px;"', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status', true); $this->assignRef('orderStatSelect', $_orderStatusSelect); $this->assignRef('currentOrderStat', $_currentOrderStat); /* Toolbar */ if (JVM_VERSION < 3) { $backward = "back"; $list = 'back'; } else { $backward = 'backward'; $list = 'list'; } JToolBarHelper::custom('prevItem', $backward, '', 'com_tsmart_ITEM_PREVIOUS', false); JToolBarHelper::custom('nextItem', 'forward', '', 'com_tsmart_ITEM_NEXT', false); JToolBarHelper::divider(); JToolBarHelper::custom('cancel', $list, '', 'com_tsmart_ORDER_LIST_LBL', false, false); } else { if ($curTask == 'editOrderItem') { if (!class_exists('calculationHelper')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php'; } $this->assignRef('orderstatuses', $orderStates); $model = tmsModel::getModel(); $orderId = vRequest::getString('orderId', ''); $orderLineItem = vRequest::getVar('orderLineId', ''); $this->assignRef('tsmart_order_id', $orderId); $this->assignRef('tsmart_order_item_id', $orderLineItem); $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem); $this->assignRef('orderitem', $orderItem); } else { $this->setLayout('orders'); $model = tmsModel::getModel(); $this->addStandardDefaultViewLists($model, 'created_on'); $orderStatusModel = tmsModel::getModel('orderstatus'); $orderstates = vRequest::getCmd('order_status_code', ''); $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" '); $orderslist = $model->getOrdersList(); $this->assignRef('orderstatuses', $orderStates); if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } /* Apply currency This must be done per order since it's vendor specific */ $_currencies = array(); // Save the currency data during this loop for performance reasons if ($orderslist) { foreach ($orderslist as $tsmart_order_id => $order) { if (!empty($order->order_currency)) { $currency = $order->order_currency; } else { if ($order->tsmart_vendor_id) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $currObj = tsmartModelVendor::getVendorCurrency($order->tsmart_vendor_id); $currency = $currObj->tsmart_currency_id; } } //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code if (!array_key_exists('curr' . $currency, $_currencies)) { $_currencies['curr' . $currency] = CurrencyDisplay::getInstance($currency, $order->tsmart_vendor_id); } $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total); $order->invoiceNumber = $model->getInvoiceNumber($order->tsmart_order_id); } } //update order items button /*$q = 'SELECT * FROM #__tsmart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL '; $db = JFactory::getDBO(); $db->setQuery($q); //$res = $db->loadRow(); if(true) { JToolBarHelper::custom('updateCustomsOrderItems', 'new', 'new', vmText::_('com_tsmart_REPORT_UPDATEORDERITEMS'),false); vmError('com_tsmart_UPDATEORDERITEMS_WARN'); }*/ /* * UpdateStatus removed from the toolbar; don't understand how this was intented to work but * the order ID's aren't properly passed. Might be readded later; the controller needs to handle * the arguments. */ /* Toolbar */ //JToolBarHelper::customX( 'CreateOrderHead', 'new','new','New',false); JToolBarHelper::save('updatestatus', tsmText::_('com_tsmart_UPDATE_STATUS')); if (vmAccess::manager('orders.delete')) { JToolBarHelper::spacer('80'); JToolBarHelper::deleteList(); } /* Assign the data */ $this->assignRef('orderslist', $orderslist); $this->pagination = $model->getPagination(); } } if (JFactory::getApplication()->isSite()) { $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0'); } shopFunctions::checkSafePath(); parent::display($tpl); }
function showhelp() { /* http://docs.joomla.org/Help_system/Adding_a_help_button_to_the_toolbar */ $task = vRequest::getCmd('task', ''); $view = vRequest::getCmd('view', ''); if ($task) { if ($task == "add") { $task = "edit"; } $task = "_" . $task; } if (!class_exists('tsmConfig')) { require VMPATH_ADMIN . '/helpers/config.php'; } tsmConfig::loadConfig(); tsmConfig::loadJLang('com_tsmart_help'); $lang = JFactory::getLanguage(); $key = 'com_tsmart_HELP_' . $view . $task; if ($lang->hasKey($key)) { $help_url = tsmText::_($key) . "?tmpl=component"; $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Popup', 'help', 'JTOOLBAR_HELP', $help_url, 960, 500); } }
function lOrderlist() { // Check for existing orders for this user $orders = tmsModel::getModel('orders'); if ($this->_model->getId() == 0) { // getOrdersList() returns all orders when no userID is set (admin function), // so explicetly define an empty array when not logged in. $this->_orderList = array(); } else { $this->_orderList = $orders->getOrdersList($this->_model->getId(), true); if (empty($this->currency)) { if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); } } if ($this->_orderList) { tsmConfig::loadJLang('com_virtuemart_orders', TRUE); } $this->assignRef('orderlist', $this->_orderList); }