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); }
protected function getOptions() { $options = array(); if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $vendor_id = tsmartModelVendor::getLoggedVendor(); // set currency_id to logged vendor if (empty($this->value)) { $currency = tsmartModelVendor::getVendorCurrency($vendor_id); $this->value = $currency->tsmart_currency_id; } // why not logged vendor? shared is missing $db = JFactory::getDBO(); $query = 'SELECT `tsmart_currency_id` AS value, `currency_name` AS text FROM `#__tsmart_currencies` WHERE `tsmart_vendor_id` = "1" AND `published` = "1" ORDER BY `currency_name` ASC '; // default value should be vendor currency $db->setQuery($query); $values = $db->loadObjectList(); foreach ($values as $v) { $options[] = JHtml::_('select.option', $v->value, $v->text); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * @author Max Milbers */ function determineStoreOwner() { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $tsmart_user_id = tsmartModelVendor::getUserIdByVendorId(1); if (isset($tsmart_user_id) && $tsmart_user_id > 0) { $this->_user = JFactory::getUser($tsmart_user_id); } else { $this->_user = JFactory::getUser(); } return $this->_user->id; }
function onDisplayEditBECustom($tsmart_custom_id, &$customPlugin) { //if($this->plugin = $this->selectedThisByMethodId($this->_psType,$tsmart_custom_id)){ if ($this->plugin = $this->selectedThisByMethodId($tsmart_custom_id)) { if (empty($this->plugin)) { $this->plugin->custom_jplugin_id = NULL; return $this->plugin; } //Must use here the table to get valid params $this->plugin = $this->getVmPluginMethod($this->plugin->tsmart_custom_id); if (empty($this->plugin->tsmart_vendor_id)) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->plugin->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } $customPlugin = $this->plugin; // return $this->plugin; return TRUE; } }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } // get necessary models $model = tmsModel::getModel('manufacturer'); $categoryModel = tmsModel::getModel('manufacturercategories'); $this->SetViewTitle(); $layoutName = vRequest::getCmd('layout', 'default'); if ($layoutName == 'edit') { $this->manufacturer = $model->getManufacturer(); $isNew = $this->manufacturer->tsmart_manufacturer_id < 1; $model->addImages($this->manufacturer); /* Process the images */ $mediaModel = tmsModel::getModel('media'); $mediaModel->setId($this->manufacturer->tsmart_media_id); $image = $mediaModel->getFile('manufacturer', 'image'); $this->manufacturerCategories = $categoryModel->getManufacturerCategories(false, true); $this->addStandardEditViewCommands($this->manufacturer->tsmart_manufacturer_id); if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } else { $mainframe = JFactory::getApplication(); $categoryFilter = $categoryModel->getCategoryFilter(); $this->addStandardDefaultViewCommands(); $this->addStandardDefaultViewLists($model, 'mf_name'); $this->manufacturers = $model->getManufacturers(); $this->pagination = $model->getPagination(); $tsmart_manufacturercategories_id = $mainframe->getUserStateFromRequest('com_tsmart.tsmart_manufacturercategories_id', 'tsmart_manufacturercategories_id', 0, 'int'); $this->lists['tsmart_manufacturercategories_id'] = JHtml::_('select.genericlist', $categoryFilter, 'tsmart_manufacturercategories_id', 'class="inputbox" onchange="this.form.submit()"', 'value', 'text', $tsmart_manufacturercategories_id); } parent::display($tpl); }
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); }
/** * Sets the internal user id with given vendor Id * * @author Max Milbers * @param int $vendorId */ function getVendor($vendorId = 1, $return = TRUE) { $vendorModel = tmsModel::getModel('vendor'); $userId = tsmartModelVendor::getUserIdByVendorId($vendorId); if ($userId) { $this->setUserId($userId); if ($return) { return $this->getUser(); } } else { return false; } }
function getVendorAcceptedCurrrenciesList($vendorId = 0) { static $currencies = array(); if ($vendorId === 0) { $multix = tsmConfig::get('multix', 'none'); if (strpos($multix, 'payment') !== FALSE) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $vendorId = tsmartModelVendor::getLoggedVendor(); } else { $vendorId = 1; } } if (!isset($currencies[$vendorId])) { $db = JFactory::getDbo(); $q = 'SELECT `vendor_accepted_currencies`, `vendor_currency` FROM `#__tsmart_vendors` WHERE `tsmart_vendor_id`=' . $vendorId; $db->setQuery($q); $vendor_currency = $db->loadAssoc(); if (!$vendor_currency['vendor_accepted_currencies']) { $vendor_currency['vendor_accepted_currencies'] = $vendor_currency['vendor_currency']; vmWarn('No accepted currencies defined'); if (empty($vendor_currency['vendor_accepted_currencies'])) { $uri = JFactory::getURI(); $link = $uri->root() . 'administrator/index.php?option=com_tsmart&view=user&task=editshop'; vmWarn(tsmText::sprintf('com_tsmart_CONF_WARN_NO_CURRENCY_DEFINED', '<a href="' . $link . '">' . $link . '</a>')); $currencies[$vendorId] = false; return $currencies[$vendorId]; } } $q = 'SELECT `tsmart_currency_id`,CONCAT_WS(" ",`currency_name`,`currency_symbol`) as currency_txt FROM `#__tsmart_currencies` WHERE `tsmart_currency_id` IN (' . $vendor_currency['vendor_accepted_currencies'] . ')'; if ($vendorId != 1) { $q .= ' AND (`tsmart_vendor_id` = "' . $vendorId . '" OR `shared`="1")'; } $q .= ' AND published = "1" ORDER BY `ordering`,`currency_name`'; $db->setQuery($q); $currencies[$vendorId] = $db->loadObjectList(); } return $currencies[$vendorId]; }
public function store(&$data) { if (!vmAccess::manager('custom.edit')) { vmWarn('Insufficient permission to edit custom'); return false; } if (!empty($data['params'])) { foreach ($data['params'] as $k => $v) { $data[$k] = $v; } } //I think this is obsolete, note by Max if (empty($data['tsmart_vendor_id'])) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $data['tsmart_vendor_id'] = tsmartModelVendor::getLoggedVendor(); } else { $data['tsmart_vendor_id'] = (int) $data['tsmart_vendor_id']; } $table = $this->getTable('customs'); if (!empty($data['custom_jplugin_id'])) { $tb = '#__extensions'; $ext_id = 'extension_id'; $db = JFactory::getDBO(); $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $cElement = $db->loadResult(); if (empty($cElement)) { if (!empty($data['tsmart_custom_id'])) { $table->load($data['tsmart_custom_id']); $cElement = $table->custom_element; } else { if (!empty($data['custom_element'])) { $cElement = $data['custom_element']; } } $q = 'SELECT * FROM `' . $tb . '` WHERE `element` = "' . $cElement . '" '; $db->setQuery($q); if ($jids = $db->loadAssocList()) { $newJid = 0; foreach ($jids as $jid) { $newJid = $jid[$ext_id]; if ($jid['enabled'] == 1 and $jid['state'] == 0) { break; } } vmdebug('Available entries ', $newJid, $jids); if (!empty($newJid)) { $q = 'UPDATE `#__tsmart_customs` SET `custom_jplugin_id`="' . $jid . '" WHERE `custom_jplugin_id` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); $data['custom_jplugin_id'] = $newJid; vmInfo('Old Plugin id was not available, updated entries with ' . $ext_id . ' = ' . $newJid . ' found for the same element'); } } else { vmWarn('could not load custom_element for plugin, testing if current custom_jplugin_id is still available ' . $q); } } if (!empty($cElement)) { $data['custom_element'] = $cElement; } $q = 'UPDATE `#__extensions` SET `enabled`= 1, `state` = 0 WHERE `extension_id` = "' . $data['custom_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); } $table->field_type = $data['field_type']; if ($table->field_type == 'C') { //vmInfo(); //$data['is_cart_attribute'] = 1; } $table->custom_element = $data['custom_element']; $table->custom_jplugin_id = $data['custom_jplugin_id']; $table->_xParams = 'custom_params'; if (!empty($data['is_input'])) { if (empty($data['layout_pos'])) { $data['layout_pos'] = 'addtocart'; } } //We are in the custom and so the table contains the field_type, else not!! self::setParameterableByFieldType($table, $table->field_type); if (empty($data['tsmart_custom_id']) and !vmAccess::manager('custom.create')) { vmWarn('Insufficient permission to create custom'); return false; } $table->bindChecknStore($data); JPluginHelper::importPlugin('vmcustom'); $dispatcher = JDispatcher::getInstance(); $error = $dispatcher->trigger('plgVmOnStoreInstallPluginTable', array('custom', $data, $table)); return $table->tsmart_custom_id; }
/** * Bind the post data to the shipment tables and save it * * @author Max Milbers * @return boolean True is the save was successful, false otherwise. */ public function store(&$data) { if ($data) { $data = (array) $data; } if (!vmAccess::manager('shipmentmethod.edit')) { vmWarn('Insufficient permissions to store shipmentmethod'); return false; } else { if (empty($data['tsmart_shipment_id']) and !vmAccess::manager('shipmentmethod.create')) { vmWarn('Insufficient permission to create shipmentmethod'); return false; } } if (!empty($data['params'])) { foreach ($data['params'] as $k => $v) { $data[$k] = $v; } } if (empty($data['tsmart_vendor_id'])) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $data['tsmart_vendor_id'] = tsmartModelVendor::getLoggedVendor(); } else { $data['tsmart_vendor_id'] = (int) $data['tsmart_vendor_id']; } $tb = '#__extensions'; $ext_id = 'extension_id'; $q = 'SELECT `element` FROM `' . $tb . '` WHERE `' . $ext_id . '` = "' . $data['shipment_jplugin_id'] . '"'; $db = JFactory::getDBO(); $db->setQuery($q); $data['shipment_element'] = $db->loadResult(); $table = $this->getTable('shipmentmethods'); if (isset($data['shipment_jplugin_id'])) { $q = 'UPDATE `#__extensions` SET `enabled`= 1 WHERE `extension_id` = "' . $data['shipment_jplugin_id'] . '"'; $db->setQuery($q); $db->execute(); JPluginHelper::importPlugin('vmshipment'); $dispatcher = JDispatcher::getInstance(); //bad trigger, we should just give it data, so that the plugins itself can check the data to be stored //so this trigger is now deprecated and will be deleted in vm2.2 $retValue = $dispatcher->trigger('plgVmSetOnTablePluginParamsShipment', array($data['shipment_element'], $data['shipment_jplugin_id'], &$table)); $retValue = $dispatcher->trigger('plgVmSetOnTablePluginShipment', array(&$data, &$table)); } $table->bindChecknStore($data); $xrefTable = $this->getTable('shipmentmethod_shoppergroups'); $xrefTable->bindChecknStore($data); if (!class_exists('vmPSPlugin')) { require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php'; } JPluginHelper::importPlugin('vmshipment'); //Add a hook here for other shipment methods, checking the data of the choosed plugin $dispatcher = JDispatcher::getInstance(); $retValues = $dispatcher->trigger('plgVmOnStoreInstallShipmentPluginTable', array($data['shipment_jplugin_id'])); return $table->tsmart_shipmentmethod_id; }
function display($tpl = null) { // Load the helper(s) if (!class_exists('VmHTML')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php'; } $model = tmsModel::getModel(); $currentUser = JFactory::getUser(); tsmConfig::loadJLang('com_tsmart_shoppers', TRUE); $task = vRequest::getCmd('task', 'edit'); if ($task == 'editshop') { $isSuperOrVendor = vmAccess::isSuperVendor(); if (empty($isSuperOrVendor)) { JFactory::getApplication()->redirect('index.php?option=com_tsmart', tsmText::_('JERROR_ALERTNOAUTHOR'), 'error'); } else { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $userId = tsmartModelVendor::getUserIdByVendorId($isSuperOrVendor); } $this->SetViewTitle('STORE'); } else { if ($task == 'add') { $userId = 0; } else { $userId = vRequest::getVar('tsmart_user_id', 0); if (is_array($userId)) { $userId = $userId[0]; } $this->SetViewTitle('USER'); } } $userId = $model->setId($userId); //$layoutName = vRequest::getCmd('layout', 'default'); $layoutName = $this->getLayout(); if ($layoutName == 'edit' || $layoutName == 'edit_shipto') { $editor = JFactory::getEditor(); if (!class_exists('VmImage')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php'; } $userDetails = $model->getUser(); if ($task == 'editshop' && $userDetails->user_is_vendor) { // $model->setCurrent(); if (!empty($userDetails->vendor->vendor_store_name)) { $this->SetViewTitle('STORE', $userDetails->vendor->vendor_store_name, 'shop_mart'); } else { $this->SetViewTitle('STORE', tsmText::_('com_tsmart_NEW_VENDOR'), 'shop_mart'); } $vendorid = $userDetails->tsmart_vendor_id; if ($vendorid == 1) { $this->checkTCPDFinstalled(); } } else { $vendorid = 0; $this->SetViewTitle('USER', $userDetails->JUser->get('name')); } $_new = $userDetails->JUser->get('id') < 1; $this->addStandardEditViewCommands($vendorid); // User details $_contactDetails = $model->getContactDetails(); $this->lists['canBlock'] = $currentUser->authorise('com_users', 'block user') && $userDetails->JUser->get('id') != $currentUser->get('id'); // Can't block myself $this->lists['canSetMailopt'] = $currentUser->authorise('workflow', 'email_events'); $this->lists['block'] = JHtml::_('select.booleanlist', 'block', 'class="inputbox"', $userDetails->JUser->get('block'), 'com_tsmart_YES', 'com_tsmart_NO'); $this->lists['sendEmail'] = JHtml::_('select.booleanlist', 'sendEmail', 'class="inputbox"', $userDetails->JUser->get('sendEmail'), 'com_tsmart_YES', 'com_tsmart_NO'); $this->lists['params'] = $userDetails->JUser->getParameters(true); // Shopper info $this->lists['shoppergroups'] = ShopFunctions::renderShopperGroupList($userDetails->shopper_groups, true, 'tsmart_shoppergroup_id'); $this->lists['vendors'] = ''; if ($this->showVendors()) { $this->lists['vendors'] = ShopFunctions::renderVendorList($userDetails->tsmart_vendor_id); } $model->setId($userDetails->JUser->get('id')); $this->lists['custnumber'] = $model->getCustomerNumberById(); // Shipment address(es) $this->lists['shipTo'] = ShopFunctions::generateStAddressList($this, $model, 'addST'); $new = false; if (vRequest::getInt('new', '0') === 1) { $new = true; } $tsmart_userinfo_id_BT = $model->getBTuserinfo_id($userId); $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'BT', $tsmart_userinfo_id_BT, false); $userFieldsBT = $userFieldsArray[$tsmart_userinfo_id_BT]; // Load the required scripts if (count($userFieldsBT['scripts']) > 0) { foreach ($userFieldsBT['scripts'] as $_script => $_path) { JHtml::script($_script, $_path); } } // Load the required stylesheets if (count($userFieldsBT['links']) > 0) { foreach ($userFieldsBT['links'] as $_link => $_path) { JHtml::stylesheet($_link, $_path); } } $this->assignRef('userFieldsBT', $userFieldsBT); $this->assignRef('userInfoID', $tsmart_userinfo_id_BT); $addrtype = vRequest::getCmd('addrtype'); $tsmart_userinfo_id = 0; if ($layoutName == 'edit_shipto' or $task == 'addST' or $addrtype == 'ST') { $tsmart_userinfo_id = vRequest::getString('tsmart_userinfo_id', '0', ''); $userFieldsArray = $model->getUserInfoInUserFields($layoutName, 'ST', $tsmart_userinfo_id, false); if ($new) { $tsmart_userinfo_id = 0; } else { } $userFieldsST = $userFieldsArray[$tsmart_userinfo_id]; $this->assignRef('shipToFields', $userFieldsST); vmdebug('hm ST $tsmart_userinfo_id', $tsmart_userinfo_id); } $this->assignRef('shipToId', $tsmart_userinfo_id); $this->assignRef('new', $new); if (!$_new) { // Check for existing orders for this user $orders = tmsModel::getModel('orders'); $orderList = $orders->getOrdersList($userDetails->JUser->get('id'), true); } else { $orderList = null; } if (count($orderList) > 0 || !empty($userDetails->user_is_vendor)) { if (!class_exists('CurrencyDisplay')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php'; } $currency = CurrencyDisplay::getInstance(); $this->assignRef('currency', $currency); } if (!empty($userDetails->user_is_vendor)) { $vendorM = tmsModel::getModel('vendor'); //if(empty($userDetails->vendor->vendor_currency)){ $vendorCurrency = $vendorM->getVendorCurrency(1); if ($vendorCurrency) { $userDetails->vendor->vendor_currency = $vendorCurrency->vendor_currency; vmdebug('No vendor currency given, fallback to main vendor', $userDetails->vendor->vendor_currency); } //} $vendorM->setId($userDetails->tsmart_vendor_id); $vendorM->addImages($userDetails->vendor); $this->assignRef('vendor', $userDetails->vendor); $currencyModel = tmsModel::getModel('currency'); $_currencies = $currencyModel->getCurrencies(); $this->assignRef('currencies', $_currencies); $configModel = tmsModel::getModel('config'); $TCPDFFontsList = $configModel->getTCPDFFontsList(); $this->assignRef('pdfFonts', $TCPDFFontsList); } $this->assignRef('userDetails', $userDetails); $this->assignRef('orderlist', $orderList); $this->assignRef('contactDetails', $_contactDetails); $this->assignRef('editor', $editor); } else { JToolBarHelper::divider(); JToolBarHelper::custom('toggle.user_is_vendor.1', 'publish', '', 'com_tsmart_USER_ISVENDOR'); JToolBarHelper::custom('toggle.user_is_vendor.0', 'unpublish', '', 'com_tsmart_USER_ISNOTVENDOR'); JToolBarHelper::divider(); JToolBarHelper::deleteList(); JToolBarHelper::editList(); self::showACLPref('user'); //This is intentionally, creating new user via BE is buggy and can be done by joomla //JToolBarHelper::addNewX(); $this->addStandardDefaultViewLists($model, 'ju.id'); $userList = $model->getUserList(); $this->assignRef('userList', $userList); $this->pagination = $model->getPagination(); $shoppergroupmodel = tmsModel::getModel('shopperGroup'); $this->defaultShopperGroup = $shoppergroupmodel->getDefault(0)->shopper_group_name; } if (!empty($this->orderlist)) { tsmConfig::loadJLang('com_tsmart_orders', TRUE); } parent::display($tpl); }
public function getVendorAddressFields($vendorId = 0) { if ($vendorId != 0) { $this->_id = (int) $vendorId; } if (!$this->_vendorFields) { $userId = tsmartModelVendor::getUserIdByVendorId($this->_id); $userModel = tmsModel::getModel('user'); $tsmart_userinfo_id = $userModel->getBTuserinfo_id($userId); // this is needed to set the correct user id for the vendor when the user is logged $userModel->getVendor($this->_id, FALSE); $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $tsmart_userinfo_id, FALSE, TRUE); $this->_vendorFields = $vendorFieldsArray[$tsmart_userinfo_id]; } return $this->_vendorFields; }
/** * * @author Max Milbers * */ public function getData($id = 0) { if ($id != 0) { $this->_id = (int) $id; } if (empty($this->_cache[$this->_id])) { $this->_cache[$this->_id] = $this->getTable($this->_maintablename); $this->_cache[$this->_id]->load($this->_id); //just an idea if (isset($this->_cache[$this->_id]->tsmart_vendor_id) && empty($this->_data->tsmart_vendor_id)) { if (!class_exists('tsmartModelVendor')) { require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php'; } $this->_cache[$this->_id]->tsmart_vendor_id = tsmartModelVendor::getLoggedVendor(); } } return $this->_cache[$this->_id]; }