function fetchElement($name, $value, &$node, $control_name) { $cid = vRequest::getvar('cid', NULL, 'array'); if (is_Array($cid)) { $virtuemart_paymentmethod_id = $cid[0]; } else { $virtuemart_paymentmethod_id = $cid; } $http = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=notify&nt=ipn&tmpl=component&pm=' . $virtuemart_paymentmethod_id; $https = str_replace('http://', 'https://', $http); $class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="text_area"'; if ($node->attributes('editable') == 'true') { $size = $node->attributes('size') ? 'size="' . $node->attributes('size') . '"' : ''; return '<input type="text" name="' . $control_name . '[' . $name . ']" id="' . $control_name . $name . '" value="' . $value . '" ' . $class . ' ' . $size . ' />'; } else { $string = "<div " . $class . ">"; $string .= '<div class="ipn-sandbox">' . $http . ' <br /></div>'; if (strcmp($https, $http) !== 0) { $string .= '<div class="ipn-sandbox">' . vmText::_('VMPAYMENT_AMAZON_OR') . '<br /></div>'; $string .= $https; $string .= "</div>"; } return $string; } }
/** * Paste the table in json format * */ public function paste() { // TODO Test user ? $json = array(); $json['fields'] = 'error'; $json['msg'] = 'Invalid Token'; $json['structure'] = 'empty'; if (!vRequest::vmCheckToken(-1)) { echo json_encode($json); jexit(); } $lang = vRequest::getvar('lg'); $langs = VmConfig::get('active_languages', array()); $language = JFactory::getLanguage(); if (!in_array($lang, $langs)) { $json['msg'] = 'Invalid language ! ' . $lang; $json['langs'] = $langs; echo json_encode($json); jexit(); } $lang = strtolower($lang); // Remove tag if defaut or // if ($language->getDefault() == $lang ) $dblang =''; $dblang = strtr($lang, '-', '_'); $id = vRequest::getInt('id', 0); $viewKey = vRequest::getCmd('editView'); // TODO temp trick for vendor if ($viewKey == 'vendor') { $id = 1; } $tables = array('category' => 'categories', 'product' => 'products', 'manufacturer' => 'manufacturers', 'manufacturercategories' => 'manufacturercategories', 'vendor' => 'vendors', 'paymentmethod' => 'paymentmethods', 'shipmentmethod' => 'shipmentmethods'); if (!array_key_exists($viewKey, $tables)) { $json['msg'] = "Invalid view " . $viewKey; echo json_encode($json); jExit(); } $tableName = '#__virtuemart_' . $tables[$viewKey] . '_' . $dblang; $db = JFactory::getDBO(); $q = 'select * FROM `' . $tableName . '` where `virtuemart_' . $viewKey . '_id` =' . $id; $db->setQuery($q); if ($json['fields'] = $db->loadAssoc()) { $json['structure'] = 'filled'; $json['msg'] = vmText::_('COM_VIRTUEMART_SELECTED_LANG') . ':' . $lang; } else { $json['structure'] = 'empty'; $db->setQuery('SHOW COLUMNS FROM ' . $tableName); $tableDescribe = $db->loadAssocList(); array_shift($tableDescribe); $fields = array(); foreach ($tableDescribe as $key => $val) { $fields[$val['Field']] = $val['Field']; } $json['fields'] = $fields; $json['msg'] = vmText::sprintf('COM_VIRTUEMART_LANG_IS_EMPTY', $lang, vmText::_('COM_VIRTUEMART_' . strtoupper($viewKey))); } echo json_encode($json); jExit(); }
function getInput() { $js = ' //<![CDATA[ jQuery(document).ready(function( $ ) { jQuery("#heidelpay_getheidelpay_link").click( function() { if ( $("#heidelpay_getheidelpay_show_hide").is(":visible") ) { $("#heidelpay_getheidelpay_show_hide").hide("slow"); $("#heidelpay_getheidelpay_link").html("' . addslashes(vmText::_('VMPAYMENT_HEIDELPAY_CREATE_ACCOUNT')) . '"); } else { $("#heidelpay_getheidelpay_show_hide").show("slow"); $("#heidelpay_getheidelpay_link").html("' . addslashes(vmText::_('VMPAYMENT_HEIDELPAY_GET_HEIDELPAY_HIDE')) . '"); } }); }); //]]> '; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); $cid = vRequest::getvar('cid', NULL, 'array'); if (is_Array($cid)) { $virtuemart_paymentmethod_id = $cid[0]; } else { $virtuemart_paymentmethod_id = $cid; } $query = "SELECT payment_params FROM `#__virtuemart_paymentmethods` WHERE virtuemart_paymentmethod_id = '" . $virtuemart_paymentmethod_id . "'"; $db = JFactory::getDBO(); $db->setQuery($query); $params = $db->loadResult(); $payment_params = explode("|", $params); foreach ($payment_params as $payment_param) { if (empty($payment_param)) { continue; } $param = explode('=', $payment_param); $payment_params[$param[0]] = substr($param[1], 1, -1); } $id = ""; if (isset($payment_params['HEIDELPAY_SECURITY_SENDER']) and ($payment_params['HEIDELPAY_SECURITY_SENDER'] == '31HA07BC8124AD82A9E96D9A35FAFD2A' or $payment_params['HEIDELPAY_SECURITY_SENDER'] == '')) { $id = "heidelpay_getheidelpay_link"; $display = ''; $html = '<a href="#" id="' . $id . '">' . vmText::_('VMPAYMENT_HEIDELPAY_ALREADY_ACCOUNT') . '</a>'; } else { $id = "heidelpay_getheidelpay_link"; $display = ' style="display: none;"'; $html = '<a href="#" id="' . $id . '">' . vmText::_('VMPAYMENT_HEIDELPAY_CREATE_ACCOUNT') . '</a>'; } $lang = $this->getLang(); $html .= '<div id="heidelpay_getheidelpay_show_hide" align=""' . $display . ' >'; $url = "http://demoshops.heidelpay.de/contactform/?campaign=vituemart&shop=vituemart&lang=" . $lang; $html .= '<iframe src="' . $url . '" scrolling="yes" style="x-overflow: none;" frameborder="0" height="1400px" width="300px"></iframe>'; $html .= "</div>"; return $html; }
function getInput() { $js = ' //<![CDATA[ jQuery(document).ready(function( $ ) { jQuery("#paybox_getpaybox_link").click( function() { if ( $("#paybox_getpaybox_show_hide").is(":visible") ) { $("#paybox_getpaybox_show_hide").hide("slow"); $("#paybox_getpaybox_link").html("' . addslashes(vmText::_('VMPAYMENT_PAYBOX_ALREADY_ACCOUNT')) . '"); } else { $("#paybox_getpaybox_show_hide").show("slow"); $("#paybox_getpaybox_link").html("' . addslashes(vmText::_('VMPAYMENT_PAYBOX_GET_PAYBOX_HIDE')) . '"); } }); }); //]]> '; vmJsApi::addJScript("vm.getPaybox", $js); vmJsApi::addJScript('/plugins/vmpayment/paybox/paybox/assets/js/admin.js'); vmJsApi::css('admin', 'plugins/vmpayment/paybox/paybox/assets/css/'); $cid = vRequest::getvar('cid', NULL, 'array'); if (is_Array($cid)) { $virtuemart_paymentmethod_id = $cid[0]; } else { $virtuemart_paymentmethod_id = $cid; } $query = "SELECT * FROM `#__virtuemart_paymentmethods` WHERE virtuemart_paymentmethod_id = '" . $virtuemart_paymentmethod_id . "'"; $db = JFactory::getDBO(); $db->setQuery($query); $params = $db->loadObject(); $html = '<img src="http://virtuemart.boutique-paybox.com/PayboxLogo.jpg" width="200px"/><br />'; if ($params->created_on == $params->modified_on) { $id = "paybox_getpaybox_link"; $html .= '<a href="#" id="' . $id . '">' . vmText::_('VMPAYMENT_PAYBOX_GET_PAYBOX_HIDE') . '</a>'; $display = ''; $html .= '<div id="paybox_getpaybox_show_hide" align=""' . $display . ' >'; } else { $id = "paybox_getpaybox_link"; $html .= '<a href="#" id="' . $id . '">' . vmText::_('VMPAYMENT_PAYBOX_ALREADY_ACCOUNT') . '</a>'; $display = ' style="display: none;"'; $html .= '<div id="paybox_getpaybox_show_hide" align=""' . $display . ' >'; } $id = ""; $lang = $this->getLang(); if ($lang == 'fr') { $url = "http://virtuemart.boutique-paybox.com/PayboxPres.html"; } else { $url = "http://virtuemart.boutique-paybox.com/PayboxPres.html"; } $html .= '<iframe src="' . $url . '" scrolling="yes" style="x-overflow: none;" frameborder="0" height="1400px" width="800px"></iframe>'; $html .= "</div>"; return $html; }
protected function getInput() { $cid = vRequest::getvar('cid', NULL, 'array'); if (is_Array($cid)) { $virtuemart_paymentmethod_id = $cid[0]; } else { $virtuemart_paymentmethod_id = $cid; } $http = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=notify&nt=ipn&tmpl=component&pm=' . $virtuemart_paymentmethod_id; $https = str_replace('http://', 'https://', $http); $string = '<div class="' . $this->class . '">'; $string .= '<div class="ipn-sandbox">' . $http . ' <br /></div>'; if (strcmp($https, $http) !== 0) { $string .= '<div class="ipn-sandbox">' . vmText::_('VMPAYMENT_AMAZON_OR') . '<br /></div>'; $string .= $https; } $string .= "</div>"; return $string; }
public function display($cachable = false, $urlparams = false) { if (vRequest::getvar('search')) { $view = $this->getView('category', 'html'); $view->display(); } else { // Display it all $document = JFactory::getDocument(); $viewType = $document->getType(); $viewName = vRequest::getCmd('view', $this->default_view); $viewLayout = vRequest::getCmd('layout', 'default'); $view = $this->getView($viewName, $viewType, '', array('layout' => $viewLayout)); $view->assignRef('document', $document); $view->display(); } if ($categoryId = vRequest::getInt('virtuemart_category_id', 0)) { shopFunctionsF::setLastVisitedCategoryId($categoryId); } return $this; }
function display($tpl = null) { //Load helpers if (!class_exists('CurrencyDisplay')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php'; } if (!class_exists('VmHTML')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php'; } if (!class_exists('vmPSPlugin')) { require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'; } // Load addl models $orderModel = VmModel::getModel(); $userFieldsModel = VmModel::getModel('userfields'); $productModel = VmModel::getModel('product'); /* Get the data */ $virtuemart_order_id = vRequest::getvar('virtuemart_order_id'); $order = $orderModel->getOrder($virtuemart_order_id); //$order = $this->get('Order'); $orderNumber = $order['details']['BT']->virtuemart_order_number; $orderbt = $order['details']['BT']; $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt; $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id); $this->assignRef('currency', $currency); $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt); $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type')); $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst); // Create an array to allow orderlinestatuses to be translated // We'll probably want to put this somewhere in ShopFunctions... $_orderStats = $this->get('OrderStatusList'); $_orderStatusList = array(); foreach ($_orderStats as $orderState) { $_orderStatusList[$orderState->order_status_code] = vmText::_($orderState->order_status_name); } /*foreach($order['items'] as $_item) { if (!empty($_item->product_attribute)) { $_attribs = preg_split('/\s?<br\s*\/?>\s?/i', $_item->product_attribute); $product = $productModel->getProduct($_item->virtuemart_product_id); $_productAttributes = array(); $_prodAttribs = explode(';', $product->attribute); foreach ($_prodAttribs as $_pAttr) { $_list = explode(',', $_pAttr); $_name = array_shift($_list); $_productAttributes[$_item->virtuemart_order_item_id][$_name] = array(); foreach ($_list as $_opt) { $_optObj = new stdClass(); $_optObj->option = $_opt; $_productAttributes[$_item->virtuemart_order_item_id][$_name][] = $_optObj; } } } }*/ //$_shipmentInfo = ShopFunctions::getShipmentRateDetails($orderbt->virtuemart_shipmentmethod_id); /* Assign the data */ $this->assignRef('orderdetails', $order); $this->assignRef('orderNumber', $orderNumber); $this->assignRef('userfields', $userfields); $this->assignRef('shipmentfields', $shipmentfields); $this->assignRef('orderstatuslist', $_orderStatusList); $this->assignRef('orderbt', $orderbt); $this->assignRef('orderst', $orderst); $this->assignRef('virtuemart_shipmentmethod_id', $orderbt->virtuemart_shipmentmethod_id); error_reporting(0); parent::display($tpl); }
function getRevenueSortListOrderQuery($sold = FALSE, $items = FALSE) { $selectFields = array(); $mainTable = ''; $joinTables = array(); $joinedTables = ''; $where = array(); // group always by intervals (day,week, ... or ID) and set grouping and defaut ordering $intervals = vRequest::getCmd('intervals', 'day'); switch ($intervals) { case 'day': $this->intervals = 'DATE( o.created_on )'; break; case 'week': $this->intervals = 'WEEK( o.created_on )'; break; case 'month': $this->intervals = 'MONTH( o.created_on )'; break; case 'year': $this->intervals = 'YEAR( o.created_on )'; break; default: // invidual grouping $this->intervals = 'o.created_on'; break; } // if(!empty($this->intervals)){ // $orderBy = $this->_getOrdering('o.`created_on`'); // } $selectFields['intervals'] = $this->intervals . ' AS intervals, CAST( o.`created_on` AS DATE ) AS created_on'; vmdebug('getRevenueSortListOrderQuery ' . $intervals); if ($intervals == 'product_s') { $selectFields[] = '`order_item_name`'; $selectFields[] = '`virtuemart_product_id`'; $groupBy = 'GROUP BY `virtuemart_product_id` '; } else { $groupBy = 'GROUP BY intervals '; } //$selectFields[] = 'COUNT(virtuemart_order_id) as number_of_orders'; //with tax => brutto //$selectFields[] = 'SUM(product_subtotal_with_tax) as order_total'; //without tax => netto //$selectFields[] = 'SUM(product_item_price) as order_subtotal'; $selectFields[] = 'SUM(product_discountedPriceWithoutTax * product_quantity) as order_subtotal_netto'; $selectFields[] = 'SUM(product_subtotal_with_tax) as order_subtotal_brutto'; $this->dates = ' DATE( o.created_on ) BETWEEN "' . $this->from_period . '" AND "' . $this->until_period . '" '; $statusList = array(); // Filter by statut if ($orderstates = vRequest::getVar('order_status_code', array('C', 'S'))) { $query = 'SELECT `order_status_code` FROM `#__virtuemart_orderstates` WHERE published=1 '; $db = JFactory::getDBO(); $db->setQuery($query); $list = $db->loadColumn(); foreach ($orderstates as $val) { if (in_array($val, $list)) { $statusList[] = '`i`.`order_status` = "' . $val . '"'; } } if ($statusList) { $where[] = '(' . implode(' OR ', $statusList) . ')'; } } //getRevenue // select wich table to order sum ordered $filterorders = vRequest::getvar('filter_order', 'intervals'); $orderdir = vRequest::getCmd('filter_order_Dir', NULL) == 'desc' ? 'desc' : ''; switch ($filterorders) { case 'o.virtuemart_order_id': $orderBy = ' ORDER BY count_order_id ' . $orderdir; $groupBy = 'GROUP BY intervals '; break; case 'product_quantity': // GROUP BY product_quantity, intervals // ORDER BY `product_quantity` ASC // TODO grouping and ordering $orderBy = ' ORDER BY product_quantity ' . $orderdir; $groupBy = 'GROUP BY intervals '; //$selectFields['intervals'] = $this->intervals.' AS intervals, i.`created_on` '; break; case 'o.order_subtotal': $orderBy = ' ORDER BY order_subtotal'; break; //getOrderItemsSumGrouped($this->intervals , $filterorders); break; default: // invidual grouping $orderBy = $this->_getOrdering(); vmdebug('default case', $orderBy); //$this->intervals= '`o`.`created_on`'; // $orderBy = ' ORDER BY '.$filterorders.' '.$orderdir; break; } $selectFields[] = 'COUNT(DISTINCT o.virtuemart_order_id) as count_order_id'; $selectFields[] = 'SUM(product_quantity) as product_quantity'; $mainTable = '`#__virtuemart_order_items` as i'; $joinTables['orders'] = ' LEFT JOIN `#__virtuemart_orders` as o ON o.virtuemart_order_id=i.virtuemart_order_id '; if (count($selectFields) > 0) { $select = implode(', ', $selectFields) . ' FROM ' . $mainTable; //$selectFindRows = 'SELECT COUNT(*) FROM '.$mainTable; if (count($joinTables) > 0) { foreach ($joinTables as $table) { $joinedTables .= $table; } } } else { vmError('No select fields given in getRevenueSortListOrderQuery', 'No select fields given'); return FALSE; } $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', FALSE); if ($virtuemart_product_id) { $where[] = 'i.virtuemart_product_id = "' . $virtuemart_product_id . '" '; } if (VmConfig::get('multix', 'none') != 'none') { $vendorId = vRequest::getInt('virtuemart_vendor_id', 0); if ($vendorId != 0) { $where[] = 'i.virtuemart_vendor_id = "' . $vendorId . '" '; } } if (count($where) > 0) { $this->whereItem = ' WHERE ' . implode(' AND ', $where) . ' AND '; } else { $this->whereItem = ' WHERE '; } // $this->whereItem; /* WHERE differences with orders and items from orders are only date periods and ordering */ $whereString = $this->whereItem . $this->dates; return $this->exeSortSearchListQuery(1, $select, $joinedTables, $whereString, $groupBy, $orderBy); }
/** * Retrieve a list of report items from the database. * * @param string $noLimit True if no record count limit is used, false otherwise * @return object List of order objects */ function getRevenue($cache = 0) { $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manager', 'com_virtuemart')) { $vendorId = vRequest::getInt('virtuemart_vendor_id'); } else { $vendorId = VmConfig::isSuperVendor(); } $orderstates = vRequest::getVar('order_status_code', array('C', 'S')); $intervals = vRequest::getCmd('intervals', 'day'); $filterorders = vRequest::getvar('filter_order', 'intervals'); $orderdir = vRequest::getCmd('filter_order_Dir', NULL) == 'desc' ? 'desc' : ''; $virtuemart_product_id = vRequest::getInt('virtuemart_product_id', FALSE); if ($cache) { $c = JFactory::getCache('com_virtuemart_revenue'); $c->setCaching(1); $c->setLifeTime($cache); return $c->call(array('VirtuemartModelReport', 'getRevenueDiag'), $vendorId, $orderstates, $intervals, $filterorders, $orderdir, $virtuemart_product_id, $this->from_period, $this->until_period); } else { return $this->getRevenueSortListOrderQuery($vendorId, $orderstates, $intervals, $filterorders, $orderdir, $virtuemart_product_id); } }
function display($tpl = null) { $filter = vRequest::getVar('q', vRequest::getVar('term', false)); $id = vRequest::getInt('id', false); $tsmart_product_id = vRequest::getInt('tsmart_product_id', array()); if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) { $product_id = (int) $tsmart_product_id[0]; } else { $product_id = (int) $tsmart_product_id; } //$customfield = $this->model->getcustomfield(); /* Get the task */ if ($this->type == 'relatedproducts') { $query = "SELECT tsmart_product_id AS id, CONCAT(product_name, '::', product_sku) AS value\n\t\t\t\tFROM #__tsmart_products_" . tsmConfig::$vmlang . "\n\t\t\t\t JOIN `#__tsmart_products` AS p using (`tsmart_product_id`)"; if ($filter) { $query .= " WHERE product_name LIKE '%" . $this->db->escape($filter, true) . "%' or product_sku LIKE '%" . $this->db->escape($filter, true) . "%' limit 0,10"; } self::setRelatedHtml($product_id, $query, 'R'); } else { if ($this->type == 'relatedcategories') { $query = "SELECT tsmart_category_id AS id, CONCAT(category_name, '::', tsmart_category_id) AS value\n\t\t\t\tFROM #__tsmart_categories_" . tsmConfig::$vmlang; if ($filter) { $query .= " WHERE category_name LIKE '%" . $this->db->escape($filter, true) . "%' limit 0,10"; } self::setRelatedHtml($product_id, $query, 'Z'); } else { if ($this->type == 'custom') { $query = "SELECT CONCAT(tsmart_custom_id, '|', custom_value, '|', field_type) AS id, CONCAT(custom_title, '::', custom_tip) AS value\n\t\t\t\tFROM #__tsmart_customs"; if ($filter) { $query .= " WHERE custom_title LIKE '%" . $filter . "%' limit 0,50"; } $this->db->setQuery($query); $this->json['value'] = $this->db->loadObjectList(); $this->json['ok'] = 1; } else { if ($this->type == 'fields') { if (!class_exists('tsmartModelCustom')) { require VMPATH_ADMIN . DS . 'models' . DS . 'custom.php'; } $fieldTypes = tsmartModelCustom::getCustomTypes(); $model = tmsModel::getModel('custom'); $q = 'SELECT `tsmart_custom_id` FROM `#__tsmart_customs` WHERE (`custom_parent_id`=' . $id . ') '; $q .= 'order by `ordering` asc'; $this->db->setQuery($q); $ids = $this->db->loadColumn(); if ($ids) { array_unshift($ids, $id); } else { $ids = array($id); } foreach ($ids as $k => $i) { $p = $model->getCustom($i); if ($p) { $p->value = $p->custom_value; $rows[] = $p; } } $html = array(); foreach ($rows as $field) { if ($field->field_type == 'deprecatedwasC') { $this->json['table'] = 'childs'; $q = 'SELECT `tsmart_product_id` FROM `#__tsmart_products` WHERE `published`=1 AND `product_parent_id`= ' . vRequest::getInt('tsmart_product_id'); //$this->db->setQuery(' SELECT tsmart_product_id, product_name FROM `#__tsmart_products` WHERE `product_parent_id` ='.(int)$product_id); $this->db->setQuery($q); if ($childIds = $this->db->loadColumn()) { // Get childs foreach ($childIds as $childId) { $field->custom_value = $childId; $display = $this->model->displayProductCustomfieldBE($field, $childId, $this->row); if ($field->is_cart_attribute) { $cartIcone = 'default'; } else { $cartIcone = 'default-off'; } $html[] = '<div class="removable"> <td>' . $field->custom_title . '</td> <td>' . $display . $field->custom_tip . '</td> <td>' . tsmText::_($fieldTypes[$field->field_type]) . ' ' . $this->model->setEditCustomHidden($field, $this->row) . ' </td> <td><span class="vmicon vmicon-16-' . $cartIcone . '"></span></td> <td></td> </div>'; $this->row++; } } } else { //if ($field->field_type =='E') { $this->json['table'] = 'customPlugins'; $colspan = ''; if ($field->field_type == 'E') { $this->model->bindCustomEmbeddedFieldParams($field, 'E'); } else { if ($field->field_type == 'C') { $colspan = 'colspan="2" '; } } $display = $this->model->displayProductCustomfieldBE($field, $product_id, $this->row); if ($field->is_cart_attribute) { $cartIcone = 'default'; } else { $cartIcone = 'default-off'; } $field->tsmart_product_id = $product_id; $html[] = ' <tr class="removable"> <td> <b>' . tsmText::_($fieldTypes[$field->field_type]) . '</b> ' . tsmText::_($field->custom_title) . '</span><br/> <span class="vmicon vmicon-16-' . $cartIcone . '"></span> <span class="vmicon vmicon-16-move"></span> <span class="vmicon vmicon-16-remove"></span> ' . $this->model->setEditCustomHidden($field, $this->row) . ' </td> <td ' . $colspan . '>' . $display . '</td> </tr> </tr>'; $this->row++; } } $this->json['value'] = $html; $this->json['ok'] = 1; } else { if ($this->type == 'userlist') { $status = vRequest::getvar('status'); $productShoppers = 0; if ($status) { $productModel = tmsModel::getModel('product'); $productShoppers = $productModel->getProductShoppersByStatus($product_id, $status); } if (!class_exists('ShopFunctions')) { require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php'; } $html = ShopFunctions::renderProductShopperList($productShoppers); $this->json['value'] = $html; } else { $this->json['ok'] = 0; } } } } } if (empty($this->json)) { $this->json['value'] = null; $this->json['ok'] = 1; } echo vmJsApi::safe_json_encode($this->json); }
function display($tpl = null) { $filter = vRequest::getVar('q', vRequest::getVar('term', false) ); $id = vRequest::getInt('id', false); $virtuemart_product_id = vRequest::getInt('virtuemart_product_id',array()); if(is_array($virtuemart_product_id) && count($virtuemart_product_id) > 0){ $product_id = (int)$virtuemart_product_id[0]; } else { $product_id = (int)$virtuemart_product_id; } //$customfield = $this->model->getcustomfield(); /* Get the task */ if ($this->type=='relatedproducts') { $query = "SELECT virtuemart_product_id AS id, CONCAT(product_name, '::', product_sku) AS value FROM #__virtuemart_products_".VmConfig::$vmlang." JOIN `#__virtuemart_products` AS p using (`virtuemart_product_id`)"; if ($filter) $query .= " WHERE product_name LIKE '%". $this->db->escape( $filter, true ) ."%' or product_sku LIKE '%". $this->db->escape( $filter, true ) ."%' limit 0,10"; self::setRelatedHtml($product_id,$query,'R'); } else if ($this->type=='relatedcategories') { $query = "SELECT virtuemart_category_id AS id, CONCAT(category_name, '::', virtuemart_category_id) AS value FROM #__virtuemart_categories_".VmConfig::$vmlang; if ($filter) $query .= " WHERE category_name LIKE '%". $this->db->escape( $filter, true ) ."%' limit 0,10"; self::setRelatedHtml($product_id,$query,'Z'); } else if ($this->type=='custom') { $query = "SELECT CONCAT(virtuemart_custom_id, '|', custom_value, '|', field_type) AS id, CONCAT(custom_title, '::', custom_tip) AS value FROM #__virtuemart_customs"; if ($filter) $query .= " WHERE custom_title LIKE '%".$filter."%' limit 0,50"; $this->db->setQuery($query); $this->json['value'] = $this->db->loadObjectList(); $this->json['ok'] = 1 ; } else if ($this->type=='fields') { if (!class_exists ('VirtueMartModelCustom')) { require(VMPATH_ADMIN . DS . 'models' . DS . 'custom.php'); } $fieldTypes = VirtueMartModelCustom::getCustomTypes(); $query = 'SELECT *,`custom_value` as value FROM `#__virtuemart_customs` WHERE (`virtuemart_custom_id`='.$id.' or `custom_parent_id`='.$id.') '; $query .= 'order by `ordering` asc'; $this->db->setQuery($query); $rows = $this->db->loadObjectlist(); $html = array (); foreach ($rows as $field) { if ($field->field_type =='deprecatedwasC' ){ $this->json['table'] = 'childs'; $q='SELECT `virtuemart_product_id` FROM `#__virtuemart_products` WHERE `published`=1 AND `product_parent_id`= '.vRequest::getInt('virtuemart_product_id'); //$this->db->setQuery(' SELECT virtuemart_product_id, product_name FROM `#__virtuemart_products` WHERE `product_parent_id` ='.(int)$product_id); $this->db->setQuery($q); if ($childIds = $this->db->loadColumn()) { // Get childs foreach ($childIds as $childId) { $field->custom_value = $childId; $display = $this->model->displayProductCustomfieldBE($field,$childId,$this->row); if ($field->is_cart_attribute) $cartIcone= 'default'; else $cartIcone= 'default-off'; $html[] = '<div class="removable"> <td>'.$field->custom_title.'</td> <td>'.$display.$field->custom_tip.'</td> <td>'.vmText::_($fieldTypes[$field->field_type]).' '.$this->model->setEditCustomHidden($field, $this->row).' </td> <td><span class="vmicon vmicon-16-'.$cartIcone.'"></span></td> <td></td> </div>'; $this->row++; } } } elseif ($field->field_type =='E') { $this->json['table'] = 'customPlugins'; $this->model->bindCustomEmbeddedFieldParams($field,'E'); $display = $this->model->displayProductCustomfieldBE($field,$product_id,$this->row); if ($field->is_cart_attribute) { $cartIcone= 'default'; } else { $cartIcone= 'default-off'; } $field->virtuemart_product_id=$product_id; $html[] = ' <tr class="removable"> <td><span class="hasTip" title="'.vmText::_($field->custom_tip).'">'.$field->custom_title.'</td> <td>'.$display.' '.$this->model->setEditCustomHidden($field, $this->row).' <p>'.vmText::_('COM_VIRTUEMART_CUSTOM_ACTIVATE_JAVASCRIPT').'</p></td> <td><span class="vmicon vmicon-16-'.$cartIcone.'"></span>'.vmText::_('COM_VIRTUEMART_CUSTOM_EXTENSION').'</td> <td><span class="vmicon vmicon-16-move"></span> <span class="vmicon vmicon-16-remove"></span><input class="ordering" type="hidden" value="'.$this->row.'" name="field['.$this->row .'][ordering]" /> </td> </tr>'; $this->row++; } else { $this->json['table'] = 'fields'; $display = $this->model->displayProductCustomfieldBE($field,$product_id,$this->row); if ($field->is_cart_attribute) $cartIcone= 'default'; else $cartIcone= 'default-off'; if(isset($fieldTypes[$field->field_type])){ $type =vmText::_($fieldTypes[$field->field_type]); } else { $type = 'deprecated'; } $html[] = '<tr class="removable"> <td><span class="hasTip" title="'.vmText::_($field->custom_tip).'">'.$field->custom_title.'</td> <td>'.$display.'</td> <td><span class="vmicon vmicon-16-'.$cartIcone.'"></span>'.vmText::_($fieldTypes[$field->field_type]).' '.$type.$this->model->setEditCustomHidden($field, $this->row).' </td> <td><span class="vmicon vmicon-16-move"></span><span class="vmicon vmicon-16-remove"></span><input class="ordering" type="hidden" value="'.$this->row.'" name="field['.$this->row .'][ordering]" /></td> </tr>'; $this->row++; } } $this->json['value'] = $html; $this->json['ok'] = 1 ; } else if ($this->type=='userlist') { $status = vRequest::getvar('status'); $productShoppers=0; if ($status) { $productModel = VmModel::getModel('product'); $productShoppers = $productModel->getProductShoppersByStatus($product_id ,$status); } if(!class_exists('ShopFunctions'))require(VMPATH_ADMIN.DS.'helpers'.DS.'shopfunctions.php'); $html = ShopFunctions::renderProductShopperList($productShoppers); $this->json['value'] = $html; } else $this->json['ok'] = 0 ; if ( empty($this->json)) { $this->json['value'] = null; $this->json['ok'] = 1 ; } echo json_encode($this->json); }
/** * Paste the table in json format * */ public function paste() { // TODO Test user ? $json = array(); $json['fields'] = 'error'; $json['msg'] = 'Invalid Token'; $json['structure'] = 'empty'; if (!vRequest::vmCheckToken(-1)) { echo json_encode($json); jexit(); } $lang = vRequest::getvar('lg'); $langs = tsmConfig::get('active_languages', array()); $language = JFactory::getLanguage(); if (!in_array($lang, $langs)) { $json['msg'] = 'Invalid language ! ' . $lang; $json['langs'] = $langs; echo json_encode($json); jexit(); } $lang = strtolower($lang); // Remove tag if defaut or // if ($language->getDefault() == $lang ) $dblang =''; $dblang = strtr($lang, '-', '_'); tsmConfig::$vmlang = $dblang; $id = vRequest::getInt('id', 0); $viewKey = vRequest::getCmd('editView'); // TODO temp trick for vendor if ($viewKey == 'vendor') { $id = 1; } $tables = array('category' => 'categories', 'product' => 'products', 'manufacturer' => 'manufacturers', 'manufacturercategories' => 'manufacturercategories', 'vendor' => 'vendors', 'paymentmethod' => 'paymentmethods', 'shipmentmethod' => 'shipmentmethods'); if (!array_key_exists($viewKey, $tables)) { $json['msg'] = "Invalid view " . $viewKey; echo json_encode($json); jExit(); } $tableName = '#__tsmart_' . $tables[$viewKey] . '_' . $dblang; $m = tmsModel::getModel('coupon'); $table = $m->getTable($tables[$viewKey]); //Todo create method to load lang fields only $table->load($id); $vs = $table->loadFieldValues(); $lf = $table->getTranslatableFields(); $json['fields'] = array(); foreach ($lf as $v) { if (isset($vs[$v])) { $json['fields'][$v] = $vs[$v]; } } //if ($json['fields'] = $db->loadAssoc()) { if ($table->getLoaded()) { $json['structure'] = 'filled'; $json['msg'] = tsmText::_('com_tsmart_SELECTED_LANG') . ':' . $lang; } else { $db = JFactory::getDBO(); $json['structure'] = 'empty'; $db->setQuery('SHOW COLUMNS FROM ' . $tableName); $tableDescribe = $db->loadAssocList(); array_shift($tableDescribe); $fields = array(); foreach ($tableDescribe as $key => $val) { $fields[$val['Field']] = $val['Field']; } $json['fields'] = $fields; $json['msg'] = tsmText::sprintf('com_tsmart_LANG_IS_EMPTY', $lang, tsmText::_('com_tsmart_' . strtoupper($viewKey))); } echo vmJsApi::safe_json_encode($json); jExit(); }
/** * Retrieve a list of report items from the database. * * @param string $noLimit True if no record count limit is used, false otherwise * @return object List of order objects */ function getRevenue($cache = 0) { if (!vmAccess::manager('report')) { return false; } $vendorId = vmAccess::isSuperVendor(); if (vmAccess::manager('managevendors')) { $vendorId = vRequest::getInt('tsmart_vendor_id', $vendorId); } $orderstates = vRequest::getVar('order_status_code', array('C', 'S')); $intervals = vRequest::getCmd('intervals', 'day'); $filterorders = vRequest::getvar('filter_order', 'intervals'); $orderdir = vRequest::getCmd('filter_order_Dir', NULL) == 'desc' ? 'desc' : ''; $tsmart_product_id = vRequest::getInt('tsmart_product_id', FALSE); if ($cache) { $c = JFactory::getCache('com_tsmart_revenue'); $c->setCaching(1); $c->setLifeTime($cache); return $c->call(array('tsmartModelReport', 'getRevenueDiag'), $vendorId, $orderstates, $intervals, $filterorders, $orderdir, $tsmart_product_id, $this->from_period, $this->until_period); } else { return $this->getRevenueSortListOrderQuery($vendorId, $orderstates, $intervals, $filterorders, $orderdir, $tsmart_product_id); } }