function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.waitlist_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); $searchMap = array('a.waitlist_id', 'a.email', 'a.name', 'a.product_id', 'b.product_name', 'b.product_code'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('waitlist') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id ' . $filters . $order; $database->setQuery('SELECT *' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); $class = hikashop_get('class.product'); foreach ($rows as $i => $element) { if ($element->product_type == 'variant') { $database->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id=' . (int) $element->product_id . ' ORDER BY a.ordering'); $element->characteristics = $database->loadObjectList(); $parentProduct = $class->get((int) $element->product_parent_id); $class->checkVariant($element, $parentProduct); $rows[$i] = $element; } } if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'waitlist_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_waitlist_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_waitlist_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.currency_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $database = JFactory::getDBO(); $searchMap = array('a.currency_symbol', 'a.currency_code', 'a.currency_name', 'a.currency_id'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $query = 'FROM ' . hikashop_table('currency') . ' AS a'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery('SELECT a.* ' . $query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList('currency_id'); $currencyClass = hikashop_get('class.currency'); $currencyClass->getCurrencies(null, $rows); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'currency_id'); } $database->setQuery('SELECT count(*) ' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_currency_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'confirm', 'check' => false, 'msg' => JText::_('UPDATE_RATES_WARNING'), 'icon' => 'upload', 'alt' => JText::_('UPDATE_RATES'), 'task' => 'update', 'display' => $manage && hikashop_level(2)), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_currency_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('currency', $currencyClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.characteristic_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $searchMap = array('a.characteristic_value', 'a.characteristic_alias', 'a.characteristic_id'); $filters = array('a.characteristic_parent_id=0'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(' LIKE ' . $searchVal . ' OR ', $searchMap) . ' LIKE ' . $searchVal; } $extrafilters = array(); JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeCharacteristicListing', array($this->paramBase, &$extrafilters, &$pageInfo, &$filters)); $this->assignRef('extrafilters', $extrafilters); $query = ' FROM ' . hikashop_table('characteristic') . ' AS a'; if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'characteristic_id'); } $database->setQuery('SELECT count(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_characteristic_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_characteristic_view', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); }
function leads() { $this->paramBase = 'leads'; $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $fieldsClass = hikashop_get('class.field'); $fields = $fieldsClass->getData('backend_listing', 'user', false); $this->assignRef('fields', $fields); $this->assignRef('fieldsClass', $fieldsClass); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.user_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $user_id = hikashop_getCID('user_id'); $userClass = hikashop_get('class.user'); $user = $userClass->get($user_id); $this->assignRef('user', $user); $filters = array('a.user_partner_id=' . $user_id, 'a.user_partner_paid=0'); $searchMap = array('a.user_id', 'a.user_email', 'b.username', 'b.email', 'b.name'); foreach ($fields as $field) { $searchMap[] = 'a.' . $field->field_namekey; } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('user') . ' AS a LEFT JOIN ' . hikashop_table('users', false) . ' AS b ON a.user_cms_id=b.id ' . $filters . $order; $database->setQuery('SELECT a.*,b.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); $fieldsClass->handleZoneListing($fields, $rows); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'user_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $currencyClass = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyClass); }
function downloads() { $user = hikashop_loadUser(true); if (hikashop_loadUser() == null) { return false; } $app = JFactory::getApplication(); $db = JFactory::getDBO(); $config = hikashop_config(); $this->assignRef('config', $config); $order_statuses = explode(',', $config->get('order_status_for_download', 'shipped,confirmed')); foreach ($order_statuses as $k => $o) { $order_statuses[$k] = $db->Quote(trim($o)); } $download_time_limit = $config->get('download_time_limit', 0); $this->assignRef('download_time_limit', $download_time_limit); $paramBase = HIKASHOP_COMPONENT . '.' . $this->getName(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($paramBase . '.filter_order', 'filter_order', 'max_order_created', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($paramBase . '.filter_order_Dir', 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($paramBase . '.search', 'search', '', 'string'); $pageInfo->search = JString::strtolower($pageInfo->search); $pageInfo->limit->start = $app->getUserStateFromRequest($paramBase . '.limitstart', 'limitstart', 0, 'int'); $oldValue = $app->getUserState($paramBase . '.list_limit'); $searchMap = array('op.order_product_name', 'f.file_name'); $order = ''; if (!empty($pageInfo->filter->order->value)) { if ($pageInfo->filter->order->value == 'f.file_name') { $order = ' ORDER BY f.file_name ' . $pageInfo->filter->order->dir . ', f.file_path ' . $pageInfo->filter->order->dir; } else { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } } $filters = array('o.order_type = \'sale\'', 'o.order_status IN (' . implode(',', $order_statuses) . ')', 'f.file_ref_id > 0', 'f.file_type = \'file\'', 'o.order_user_id = ' . $user->user_id); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filter = '(' . implode(' LIKE ' . $searchVal . ' OR ', $searchMap) . ' LIKE ' . $searchVal . ')'; $filters[] = $filter; } $filters = implode(' AND ', $filters); if (empty($oldValue)) { $oldValue = $app->getCfg('list_limit'); } $pageInfo->limit->value = $app->getUserStateFromRequest($paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if ($oldValue != $pageInfo->limit->value) { $pageInfo->limit->start = 0; $app->setUserState($paramBase . '.limitstart', 0); } $select = 'o.order_id, o.order_created, p.*, f.*, op.* '; $selectSum = ', MIN(o.order_created) as min_order_created, MAX(o.order_created) as max_order_created, SUM(op.order_product_quantity) as file_quantity '; $selectUniq = ', IF( REPLACE(LEFT(f.file_path, 1) , \'#\', \'@\') = \'@\', CONCAT(f.file_id, \'@\', o.order_id), f.file_id ) as uniq_id'; $query = ' FROM ' . hikashop_table('order') . ' AS o ' . ' INNER JOIN ' . hikashop_table('order_product') . ' AS op ON op.order_id = o.order_id ' . ' INNER JOIN ' . hikashop_table('product') . ' AS p ON op.product_id = p.product_id ' . ' INNER JOIN ' . hikashop_table('file') . ' AS f ON (op.product_id = f.file_ref_id OR p.product_parent_id = f.file_ref_id) ' . ' WHERE ' . $filters; $groupBy = ' GROUP BY uniq_id '; $db->setQuery('SELECT ' . $select . $selectSum . $selectUniq . $query . $groupBy . $order, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $downloadData = $db->loadObjectList('uniq_id'); if (!empty($pageInfo->search)) { $downloadData = hikashop_search($pageInfo->search, $downloadData, 'order_id'); } $db->setQuery('SELECT COUNT(*) as all_results_count FROM (SELECT f.file_id ' . $selectUniq . $query . $groupBy . ') AS all_results'); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $db->loadResult('total'); $pageInfo->elements->page = count($downloadData); $file_ids = array(); $order_ids = array(); foreach ($downloadData as $k => $data) { if ((int) $data->order_id > 0) { $order_ids[(int) $data->order_id] = (int) $data->order_id; } $downloadData[$k]->download_total = 0; $downloadData[$k]->downloads = array(); $downloadData[$k]->orders = array(); if (strpos($k, '@') === false) { $file_ids[] = $k; } } if (!empty($file_ids)) { $db->setQuery('SELECT ' . $select . $query . ' AND f.file_id IN (' . implode(',', $file_ids) . ')'); $orders = $db->loadObjectList(); foreach ($orders as $o) { if (isset($downloadData[$o->file_id])) { $downloadData[$o->file_id]->orders[(int) $o->order_id] = $o; $downloadData[$o->file_id]->orders[(int) $o->order_id]->file_qty = 0; $downloadData[$o->file_id]->orders[(int) $o->order_id]->download_total = 0; } $order_ids[(int) $o->order_id] = (int) $o->order_id; } } if (!empty($order_ids)) { $db->setQuery('SELECT * FROM ' . hikashop_table('download') . ' WHERE order_id IN (' . implode(',', $order_ids) . ')'); $downloads = $db->loadObjectList(); foreach ($downloads as $download) { $uniq_id = $download->file_id . '@' . $download->order_id; if (isset($downloadData[$uniq_id])) { $downloadData[$uniq_id]->download_total += (int) $download->download_number; $downloadData[$uniq_id]->downloads[$download->file_pos] = $download; } else { if (isset($downloadData[$download->file_id])) { $downloadData[$download->file_id]->download_total += (int) $download->download_number; if (isset($downloadData[$download->file_id]->orders[$download->order_id])) { $downloadData[$download->file_id]->orders[$download->order_id]->file_qty++; $downloadData[$download->file_id]->orders[$download->order_id]->download_total += (int) $download->download_number; } } } } } jimport('joomla.html.pagination'); $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $pagination->hikaSuffix = ''; $this->assignRef('pagination', $pagination); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('downloadData', $downloadData); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', '', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $pageInfo->filter->filter_status = $app->getUserStateFromRequest($this->paramBase . ".filter_status", 'filter_status', '', 'array'); $pageInfo->filter->filter_end = $app->getUserStateFromRequest($this->paramBase . ".filter_end", 'filter_end', '', 'string'); $pageInfo->filter->filter_start = $app->getUserStateFromRequest($this->paramBase . ".filter_start", 'filter_start', '', 'string'); $database = JFactory::getDBO(); $searchMap = array('a.tax_namekey', 'a.tax_rate'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeTaxListing', array($this->paramBase, &$this->extrafilters, &$pageInfo, &$filters)); if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('tax') . ' AS a ' . $filters . $order; $database->setQuery('SELECT a.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList('tax_namekey'); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $filters = array('order_type=\'sale\''); if (is_array($pageInfo->filter->filter_status) && count($pageInfo->filter->filter_status) == 1) { $pageInfo->filter->filter_status = reset($pageInfo->filter->filter_status); } switch ($pageInfo->filter->filter_status) { case '': break; default: if (!is_array($pageInfo->filter->filter_status)) { $filters[] = 'order_status = ' . $database->Quote($pageInfo->filter->filter_status); break; } if (!count($pageInfo->filter->filter_status) || in_array('', $pageInfo->filter->filter_status)) { break; } $statuses = array(); foreach ($pageInfo->filter->filter_status as $status) { $statuses[] = $database->Quote($status); } $filters[] = 'order_status IN (' . implode(',', $statuses) . ')'; break; } switch ($pageInfo->filter->filter_start) { case '': switch ($pageInfo->filter->filter_end) { case '': break; default: $filter_end = explode('-', $pageInfo->filter->filter_end); $noHourDay = explode(' ', $filter_end[2]); $filter_end[2] = $noHourDay[0]; $filter_end = hikashop_getTime(mktime(23, 59, 59, $filter_end[1], $filter_end[2], $filter_end[0])); $filters[] = 'order_created <= ' . (int) $filter_end; $pageInfo->filter->filter_end = (int) $filter_end; break; } break; default: $filter_start = explode('-', $pageInfo->filter->filter_start); $noHourDay = explode(' ', $filter_start[2]); $filter_start[2] = $noHourDay[0]; $filter_start = hikashop_getTime(mktime(0, 0, 0, $filter_start[1], $filter_start[2], $filter_start[0])); switch ($pageInfo->filter->filter_end) { case '': $filters[] = 'order_created >= ' . hikashop_getTime((int) $filter_start); $pageInfo->filter->filter_start = (int) $filter_start; break; default: $filter_end = explode('-', $pageInfo->filter->filter_end); $noHourDay = explode(' ', $filter_end[2]); $filter_end[2] = $noHourDay[0]; $filter_end = hikashop_getTime(mktime(23, 59, 59, $filter_end[1], $filter_end[2], $filter_end[0])); $filters[] = 'order_created >= ' . (int) $filter_start . ' AND order_created <= ' . (int) $filter_end; $pageInfo->filter->filter_start = (int) $filter_start; $pageInfo->filter->filter_end = (int) $filter_end; break; } break; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $database->setQuery('SELECT order_tax_info, order_currency_id FROM ' . hikashop_table('order') . $filters); $orders_taxes = $database->loadObjectList(); $config = hikashop_config(); $main_currency = $config->get('main_currency'); $currencyClass = hikashop_get('class.currency'); $currency_ids = array($main_currency => $main_currency); $currencies = array(); if (count($orders_taxes)) { foreach ($orders_taxes as $k => $v) { $currency_ids[$v->order_currency_id] = $v->order_currency_id; } } $null = null; $currencies = $currencyClass->getCurrencies($currency_ids, $null); if (count($orders_taxes)) { foreach ($orders_taxes as $k => $v) { $orders_taxes[$k]->order_tax_info = unserialize($v->order_tax_info); $info =& $orders_taxes[$k]->order_tax_info; if (!$info) { continue; } foreach ($info as $k2 => $taxes_info) { $tax_amount = $taxes_info->tax_amount + @$taxes_info->tax_amount_for_shipping + @$taxes_info->tax_amount_for_payment - @$taxes_info->tax_amount_for_coupon; if (!isset($taxes_info->tax_rate)) { $taxes_info->tax_rate = $rows[$taxes_info->tax_namekey]->tax_rate; } if ($taxes_info->tax_rate != 0) { $info[$k2]->amount = round($tax_amount / $taxes_info->tax_rate, $currencyClass->getRounding($v->order_currency_id)); } else { $info[$k2]->amount = 0; } $info[$k2]->tax_amount = round($tax_amount, $currencyClass->getRounding($v->order_currency_id)); if ($main_currency != $v->order_currency_id) { $info[$k2]->tax_amount_main_currency = $currencyClass->convertUniquePrice($info[$k2]->tax_amount, $v->order_currency_id, $main_currency); $info[$k2]->amount_main_currency = $currencyClass->convertUniquePrice($info[$k2]->amount, $v->order_currency_id, $main_currency); } else { $info[$k2]->tax_amount_main_currency = $info[$k2]->tax_amount; $info[$k2]->amount_main_currency = $info[$k2]->amount; } } } } if ($pageInfo->elements->page) { foreach ($rows as $k => $tax) { $tax_amounts = array(); $amounts = array(); foreach ($currencies as $currency_id => $currency) { $tax_amount = 0; $amount = 0; if (count($orders_taxes)) { foreach ($orders_taxes as $order_taxes) { if ($order_taxes->order_currency_id != $currency_id || !$order_taxes->order_tax_info) { continue; } foreach ($order_taxes->order_tax_info as $order_tax) { if ($order_tax->tax_namekey != $tax->tax_namekey) { continue; } $tax_amount += $order_tax->tax_amount; $amount += $order_tax->amount; } } } $tax_amounts[$currency_id] = $tax_amount; $amounts[$currency_id] = $amount; } $rows[$k]->tax_amounts = $tax_amounts; $rows[$k]->amounts = $amounts; $tax_amount_main_currency = 0; $amount_main_currency = 0; if (count($orders_taxes)) { foreach ($orders_taxes as $order_taxes) { if (!$order_taxes->order_tax_info) { continue; } foreach ($order_taxes->order_tax_info as $order_tax) { if ($order_tax->tax_namekey != $tax->tax_namekey) { continue; } $tax_amount_main_currency += $order_tax->tax_amount_main_currency; $amount_main_currency += $order_tax->amount_main_currency; } } } $rows[$k]->tax_amount = $tax_amount_main_currency; $rows[$k]->amount = $amount_main_currency; } } $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->assignRef('currencies', $currencies); $this->assignRef('main_currency', $main_currency); $this->assignRef('currencyHelper', $currencyClass); $category = hikashop_get('type.categorysub'); $category->type = 'status'; $this->assignRef('category', $category); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $this->toolbar = array('addNew', 'editList', 'deleteList'); $return = JRequest::getString('return', ''); if (!empty($return)) { $this->toolbar[] = 'cancel'; } $this->assignRef('return', $return); $this->toolbar[] = '|'; $this->toolbar[] = array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'); $this->toolbar[] = 'dashboard'; }
function product_select() { $app = JFactory::getApplication(); $config =& hikashop_config(); $this->assignRef('config', $config); $this->paramBase .= "_product_select"; $element = new stdClass(); $element->order_id = JRequest::getInt('order_id'); $this->assignRef('element', $element); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 500; } $selectedType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', 0, 'int'); $pageInfo->filter->filter_id = $app->getUserStateFromRequest($this->paramBase . ".filter_id", 'filter_id', 0, 'string'); $pageInfo->filter->filter_product_type = $app->getUserStateFromRequest($this->paramBase . ".filter_product_type", 'filter_product_type', 'main', 'word'); $database = JFactory::getDBO(); $filters = array(); $searchMap = array('b.product_name', 'b.product_description', 'b.product_id', 'b.product_code'); if (empty($pageInfo->filter->filter_id) || !is_numeric($pageInfo->filter->filter_id)) { $pageInfo->filter->filter_id = 'product'; $class = hikashop_get('class.category'); $class->getMainElement($pageInfo->filter->filter_id); } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!$selectedType) { $filters[] = 'a.category_id=' . (int) $pageInfo->filter->filter_id; $select = 'SELECT a.ordering, b.*'; } else { $categoryClass = hikashop_get('class.category'); $categoryClass->parentObject =& $this; $children = $categoryClass->getChildren((int) $pageInfo->filter->filter_id, true, array(), '', 0, 0); $filter = 'a.category_id IN ('; foreach ($children as $child) { $filter .= $child->category_id . ','; } $filters[] = $filter . (int) $pageInfo->filter->filter_id . ')'; $select = 'SELECT DISTINCT b.*'; } if ($pageInfo->filter->filter_product_type == 'all') { if (!empty($pageInfo->filter->order->value)) { $select .= ',' . $pageInfo->filter->order->value . ' as sorting_column'; $order = ' ORDER BY sorting_column ' . $pageInfo->filter->order->dir; } } else { if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeProductListingLoad', array(&$filters, &$order, &$this, &$select, &$select2, &$a, &$b, &$on)); if ($pageInfo->filter->filter_product_type == 'all') { $query = '( ' . $select . ' FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id WHERE ' . implode(' AND ', $filters) . ' AND b.product_id IS NOT NULL ) UNION ( ' . $select . ' FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_parent_id WHERE ' . implode(' AND ', $filters) . ' AND b.product_parent_id IS NOT NULL ) '; $database->setQuery($query . $order, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); } else { $filters[] = 'b.product_type = ' . $database->Quote($pageInfo->filter->filter_product_type); if ($pageInfo->filter->filter_product_type != 'variant') { $lf = 'a.product_id=b.product_id'; } else { $lf = 'a.product_id=b.product_parent_id'; } $query = ' FROM ' . hikashop_table('product_category') . ' AS a LEFT JOIN ' . hikashop_table('product') . ' AS b ON ' . $lf . ' WHERE ' . implode(' AND ', $filters); $database->setQuery($select . $query . $order, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); } $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'product_id'); } if ($pageInfo->filter->filter_product_type == 'all') { $database->setQuery('SELECT COUNT(*) FROM (' . $query . ') as u'); } else { $database->setQuery('SELECT COUNT(DISTINCT(b.product_id))' . $query); } $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); if ($pageInfo->elements->page) { $this->_loadPrices($rows); } if ($pageInfo->limit->value == 500) { $pageInfo->limit->value = 100; } $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $childClass = hikashop_get('type.childdisplay'); $childDisplay = $childClass->display('filter_type', $selectedType, false); $this->assignRef('childDisplay', $childDisplay); $productClass = hikashop_get('type.product'); $this->assignRef('productType', $productClass); $breadcrumbClass = hikashop_get('type.breadcrumb'); $breadCrumb = $breadcrumbClass->display('filter_id', $pageInfo->filter->filter_id, 'product'); $this->assignRef('breadCrumb', $breadCrumb); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $currencyClass = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyClass); $doOrdering = !$selectedType; if ($doOrdering && !(empty($pageInfo->filter->filter_product_type) || $pageInfo->filter->filter_product_type == 'main')) { $doOrdering = false; } $this->assignRef('doOrdering', $doOrdering); if ($doOrdering) { $order = new stdClass(); $order->ordering = false; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.ordering') { $order->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); } }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.widget_ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); $searchMap = array('a.widget_id', 'a.widget_name'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } hikashop_addACLFilters($filters, 'widget_access', 'a'); if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('widget') . ' AS a ' . $filters . $order; $database->setQuery('SELECT a.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'widget_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $order = new stdClass(); $order->ordering = true; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.widget_ordering') { if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_report_manage', 'all')); $this->assignRef('manage', $manage); $viewAccess = hikashop_isAllowed($config->get('acl_report_view', 'all')); $this->assignRef('viewAccess', $viewAccess); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $viewAccess), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_report_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.category_ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->selectedType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', 0, 'int'); jimport('joomla.filter.filterinput'); $safeHtmlFilter =& JFilterInput::getInstance(null, null, 1, 1); $pageInfo->filter->filter_id = $safeHtmlFilter->clean(strip_tags($app->getUserStateFromRequest($this->paramBase . ".filter_id", 'filter_id', 0, 'string'))); $database = JFactory::getDBO(); $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $config =& hikashop_config(); $this->assignRef('config', $config); $category_image = $config->get('category_image', 1); $class = hikashop_get('class.category'); $type = ''; $categories = false; $category_id = $pageInfo->filter->filter_id; if (is_numeric($pageInfo->filter->filter_id)) { $cat = $class->get($pageInfo->filter->filter_id); if (@$cat->category_type != 'root') { $type = @$cat->category_type; } } else { $type = $pageInfo->filter->filter_id; $class->getMainElement($category_id); } if ($pageInfo->selectedType) { $childs = $class->getChildren((int) $category_id, true, array(), '', 0, 0); $cat_ids = array(); foreach ($childs as $child) { $cat_ids[$child->category_id] = $child->category_id; } } else { $cat_ids = array((int) $category_id); } $parent_cat_ids = array(); if (!empty($cat_ids)) { $parents = $class->getParents($cat_ids, true, array(), '', 0, 0); if (!empty($parents)) { foreach ($parents as $parent) { $parent_cat_ids[] = $parent->category_id; } } } $categories = array('originals' => $cat_ids, 'parents' => $parent_cat_ids); $searchMap = array('a.category_name', 'a.category_description', 'a.category_id'); $fieldsClass = hikashop_get('class.field'); $fields = $fieldsClass->getData('backend_listing', 'category', false, $categories); $this->assignRef('fields', $fields); $this->assignRef('fieldsClass', $fieldsClass); foreach ($fields as $field) { $searchMap[] = 'a.' . $field->field_namekey; } $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } if ($type == 'tax' || $type == 'status') { $category_image = false; } $this->assignRef('type', $type); $rows = $class->loadAllWithTrans($pageInfo->filter->filter_id, $pageInfo->selectedType, $filters, $order, $pageInfo->limit->start, $pageInfo->limit->value, $category_image); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'category_id'); } $database->setQuery('SELECT COUNT(*)' . $class->query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); if ($category_image) { $image = hikashop_get('helper.image'); $this->assignRef('image', $image); } $this->addHeader(); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $childClass = hikashop_get('type.childdisplay'); $childDisplay = $childClass->display('filter_type', $pageInfo->selectedType, false); $this->assignRef('childDisplay', $childDisplay); $breadcrumbClass = hikashop_get('type.breadcrumb'); $breadCrumb = $breadcrumbClass->display('filter_id', $pageInfo->filter->filter_id, $type); $this->assignRef('breadCrumb', $breadCrumb); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $order = new stdClass(); $order->ordering = false; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.category_ordering') { $order->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); $this->assignRef('category_image', $category_image); $this->getPagination(); }
function listing($doexport = false, $export = '') { $fieldsClass = hikashop_get('class.field'); $data = new stdClass(); $fields = $fieldsClass->getFields('backend_listing', $data, 'entry'); $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'b.entry_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 500; } $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $pageInfo->filter->filter_status = $app->getUserStateFromRequest($this->paramBase . '.filter_status', 'filter_status', '', 'string'); $database = JFactory::getDBO(); $filters = array(); $database->setQuery('SELECT COUNT(*) FROM ' . hikashop_table('field') . ' WHERE field_table = ' . $database->Quote('entry') . ' AND field_published = 1'); $nb_entries = (int) $database->loadResult(); if (empty($nb_entries) || $nb_entries == 0) { $app->enqueueMessage(JText::sprintf('ENTRIES_FIRST')); } if (!empty($export)) { JArrayHelper::toInteger($export); $filters[] = 'b.entry_id IN (' . implode(',', $export) . ')'; } switch ($pageInfo->filter->filter_status) { case '': break; default: $filters[] = 'a.order_status = ' . $database->Quote($pageInfo->filter->filter_status); break; } $searchMap = array('a.order_id', 'b.entry_id'); foreach ($fields as $field) { $searchMap[] = 'b.' . $field->field_namekey; } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $id = hikashop_decode($pageInfo->search); $filter = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; if (!empty($id)) { $filter .= " OR a.order_id LIKE '%" . hikashop_getEscaped($id, true) . '%\''; } $filters[] = $filter; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('entry') . ' AS b LEFT JOIN ' . hikashop_table('order') . ' AS a ON b.order_id=a.order_id ' . $filters . $order; if ($doexport) { $database->setQuery('SELECT b.*' . $query); } else { $database->setQuery('SELECT a.*,b.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); } $rows = $database->loadObjectList(); if (!$doexport) { if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'entry_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $displayNew = hikashop_isAllowed($config->get('acl_entry_manage', 'all')); if (empty($nb_entries) || $nb_entries == 0) { $displayNew = FALSE; } $this->toolbar = array(array('name' => 'custom', 'task' => 'export', 'icon' => 'upload', 'alt' => JText::_('HIKA_EXPORT')), array('name' => 'addNew', 'display' => $displayNew), array('name' => 'editList', 'display' => hikashop_isAllowed($config->get('acl_entry_manage', 'all'))), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_entry_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $manage = hikashop_isAllowed($config->get('acl_order_manage', 'all')); $this->assignRef('manage', $manage); $this->assignRef('fields', $fields); $this->assignRef('fieldsClass', $fieldsClass); $fieldsClass->handleZoneListing($fields, $rows); $category = hikashop_get('type.categorysub'); $category->type = 'status'; $this->assignRef('category', $category); } $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $this->assignRef('rows', $rows); }
function getTax($zone_id, $tax_category_id, $type = '') { static $calculated = array(); static $calculatedFullInfo = array(); if (empty($tax_category_id)) { return 0; } if (empty($zone_id)) { $zone_id = $this->mainTaxZone(); if (empty($zone_id)) { return 0; } } if (empty($type)) { $type = $this->getTaxType(); } $taxPlans = array(); while (empty($taxPlans) && !empty($tax_category_id)) { $key = $zone_id . '_' . $tax_category_id . '_' . $type; if (!isset($calculated[$key])) { $filter = ''; switch ($type) { default: $filter = '(taxation_type = ' . $this->database->Quote($type) . ' OR taxation_type LIKE \'%' . hikashop_getEscaped($type, true) . '%\')'; case '': $typeFilter = 'taxation_type = \'\''; if (!empty($filter)) { $typeFilter = '( ' . $typeFilter . ' OR ' . $filter . ' )'; } break; } $filters = array('a.category_id = ' . (int) $tax_category_id, 'b.taxation_published=1', $typeFilter, 'b.taxation_date_start <= ' . time(), '(b.taxation_date_end = 0 OR b.taxation_date_end > ' . time() . ')'); hikashop_addACLFilters($filters, 'taxation_access', 'b'); $query = 'SELECT b.*,c.* FROM ' . hikashop_table('category') . ' AS a ' . 'LEFT JOIN ' . hikashop_table('taxation') . ' AS b ON a.category_namekey=b.category_namekey ' . 'LEFT JOIN ' . hikashop_table('tax') . ' AS c ON b.tax_namekey=c.tax_namekey WHERE ' . implode(' AND ', $filters) . ' ORDER BY b.taxation_id ASC'; $this->database->setQuery($query); $taxPlans = $this->database->loadObjectList('taxation_id'); if (empty($taxPlans)) { $query = 'SELECT category_parent_id FROM ' . hikashop_table('category') . ' WHERE category_id = ' . (int) $tax_category_id; $this->database->setQuery($query); $category_parent_id = $this->database->loadResult(); if (!empty($category_parent_id)) { $tax_category_id = $category_parent_id; } else { break; } } } else { break; } } if (!isset($calculated[$key])) { $query = 'SELECT * FROM ' . hikashop_table('zone') . ' WHERE zone_id = ' . (int) $zone_id; $this->database->setQuery($query); $zone = $this->database->loadObject(); $quotedTaxNamekeys = array(); $this->taxRates = array(); $tax = 0; if (!empty($taxPlans) && !empty($zone)) { $matches = array(); $cumulative = false; $already = array($zone->zone_id => $zone); foreach ($taxPlans as $taxPlan) { if (empty($taxPlan->zone_namekey)) { continue; } $taxPlan->zone_namekey = explode(',', $taxPlan->zone_namekey); foreach ($taxPlan->zone_namekey as $zone_namekey) { $quotedTaxNamekeys[] = $this->database->Quote($zone_namekey); } if (in_array($zone->zone_namekey, $taxPlan->zone_namekey) && $this->_matchPostCode($taxPlan)) { $taxPlan->zone_type = $zone->zone_type; $matches[$taxPlan->taxation_id] = $taxPlan; if (!empty($taxPlan->taxation_cumulative)) { $cumulative = true; } } } if (count($quotedTaxNamekeys) && (count($matches) == 0 || $cumulative)) { $childs = array($this->database->Quote($zone->zone_namekey)); $this->_getParents($childs, $matches, $already, $quotedTaxNamekeys, $taxPlans); } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onHikashopGetTax', array(&$this, $zone_id, $tax_category_id, $type, &$matches, &$taxPlans)); if (count($matches) != 0) { $type = 'state'; $types = array('country', 'tax'); $found = false; while (!$found) { foreach ($matches as $match) { if ($match->zone_type == $type) { $tax += floatval(@$match->tax_rate); $this->taxRates[] = $match; if (empty($match->taxation_cumulative)) { $found = true; break; } } } if (!$found) { if (empty($types)) { $found = true; break; } $type = array_shift($types); } } } else { foreach ($taxPlans as $taxPlan) { if (!empty($taxPlan->zone_namekey)) { continue; } if (!$this->_matchPostCode($taxPlan)) { continue; } if ($taxPlan->taxation_cumulative) { $this->taxRates[] = $taxPlan; $tax += floatval(@$taxPlan->tax_rate); } else { $this->taxRates = array($taxPlan); $tax = floatval(@$taxPlan->tax_rate); } } } } $calculated[$key] = $tax; $calculatedFullInfo[$key] = array(); foreach ($this->taxRates as $k => $taxRate) { $calculatedFullInfo[$key][$k] = clone $taxRate; } } else { $this->taxRates = array(); foreach ($calculatedFullInfo[$key] as $k => $taxRate) { $this->taxRates[$k] = clone $taxRate; } } return $calculated[$key]; }
function listing() { $config = hikashop_config(); $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.vote_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array(); $searchMap = array('a.vote_id', 'a.vote_rating', 'a.vote_ref_id', 'a.vote_pseudo', 'a.vote_comment', 'a.vote_email', 'a.vote_user_id', 'a.vote_ip', 'a.vote_date'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE ' . implode(' AND ', $filters); } else { $filters = ''; } $query = ' FROM ' . hikashop_table('vote') . ' AS a ' . $filters . $order; $database->setQuery('SELECT a.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($rows)) { foreach ($rows as $k => $v) { if (function_exists('mb_substr')) { $rows[$k]->vote_comment_short = mb_substr($v->vote_comment, 0, 51); } else { $rows[$k]->vote_comment_short = substr($v->vote_comment, 0, 51); } if ($rows[$k]->vote_type == 'vendor') { $query2 = 'SELECT vendor_name FROM `#__hikamarket_vendor` WHERE vendor_id = ' . (int) $rows[$k]->vote_ref_id . ''; } else { $query2 = 'SELECT product_name FROM `#__hikashop_product` WHERE product_id = ' . (int) $rows[$k]->vote_ref_id . ''; } $database->setQuery($query2); $rows[$k]->item_name = $database->loadResult(); if ($rows[$k]->vote_pseudo == '0') { $userClass = hikashop_get('class.user'); $userInfos = $userClass->get($rows[$k]->vote_user_id); if (!empty($userInfos)) { $rows[$k]->username = $userInfos->username; $rows[$k]->email = $userInfos->email; } } } } $pageInfo->enabled = $this->isEnabled(); $pageInfo->manageProduct = hikashop_isAllowed($config->get('acl_product_manage', 'all')); $pageInfo->manageUser = hikashop_isAllowed($config->get('acl_user_manage', 'all')); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'vote_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $order = new stdClass(); $order->ordering = true; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.vote_ordering') { if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_vote_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_vote_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function onSearch($text, $phrase = '', $ordering = '', $areas = null) { if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) { return array(); } $db = JFactory::getDBO(); if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onSearchAreas()))) { return array(); } } $limit = $this->params->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } switch ($ordering) { case 'alpha': $order = 'a.product_name ASC'; break; case 'newest': $order = 'a.product_modified DESC'; break; case 'oldest': $order = 'a.product_created ASC'; break; case 'popular': $order = 'a.product_hit DESC'; break; case 'category': default: $order = 'a.product_name DESC'; break; } $trans = hikashop_get('helper.translation'); $multi = $trans->isMulti(); $trans_table = 'jf_content'; if ($trans->falang) { $trans_table = 'falang_content'; } $rows = array(); $filters = array('a.product_published=1'); $variants = (int) $this->params->get('variants', '0'); if (!$variants) { $filters[] = 'a.product_type=\'main\''; } $out_of_stock = (int) $this->params->get('out_of_stock_display', '1'); if (!$out_of_stock) { $filters[] = 'a.product_quantity!=0'; } hikashop_addACLFilters($filters, 'product_access', 'a'); $leftjoin = ''; $catFilters = array('category_published=1', 'category_type=\'product\''); hikashop_addACLFilters($catFilters, 'category_access'); $db->setQuery('SELECT category_id FROM ' . hikashop_table('category') . ' WHERE ' . implode(' AND ', $catFilters)); if (!HIKASHOP_J25) { $cats = $db->loadResultArray(); } else { $cats = $db->loadColumn(); } if (!empty($cats)) { $filters[] = 'b.category_id IN (' . implode(',', $cats) . ')'; } if ($variants) { $leftjoin = ' INNER JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_parent_id=b.product_id OR a.product_id=b.product_id'; } else { $leftjoin = ' INNER JOIN ' . hikashop_table('product_category') . ' AS b ON a.product_id=b.product_id'; } $filters2 = array(); if ($multi) { $registry = JFactory::getConfig(); if (!HIKASHOP_J25) { $code = $registry->getValue('config.jflang'); } else { $code = $registry->get('language'); } $lg = $trans->getId($code); $filters2[] = "b.reference_table='hikashop_product'"; $filters2[] = "b.published=1"; $filters2[] = 'b.language_id=' . $lg; } $fields = $this->params->get('fields', ''); if (empty($fields)) { $fields = array('product_name', 'product_description'); } else { $fields = explode(',', $fields); } switch ($phrase) { case 'exact': $text = $db->Quote('%' . hikashop_getEscaped($text, true) . '%', false); $filters1 = array(); foreach ($fields as $f) { $filters1[] = "a." . $f . " LIKE " . $text; } if ($multi) { $filters2[] = "b.value LIKE " . $text; } break; case 'all': case 'any': default: $words = explode(' ', $text); $wordFilters = array(); $subWordFiltersX = array(); $wordFilters2 = array(); foreach ($words as $word) { $word = $db->Quote('%' . hikashop_getEscaped($word, true) . '%', false); foreach ($fields as $i => $f) { $subWordFiltersX[$i][] = "a." . $f . " LIKE " . $word; } if ($multi) { $wordFilters2[] = "b.value LIKE " . $word; } } foreach ($subWordFiltersX as $i => $subWordFilters) { $wordFilters[$i] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $subWordFilters) . '))'; } $filters[] = '((' . implode(') OR (', $wordFilters) . '))'; if ($multi) { $filters2[] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wordFilters2) . '))'; } break; } $new_page = (int) $this->params->get('new_page', '1'); $select = ' a.product_id AS id, a.product_name, a.product_alias, a.product_canonical, a.product_created AS created , a.product_description, "' . $new_page . '" AS browsernav'; if ($variants) { $select .= ', a.product_type, a.product_parent_id'; } $count = 0; if ($multi && !empty($lg)) { $db->setQuery('SET SQL_BIG_SELECTS=1'); $db->query(); $query = ' SELECT DISTINCT ' . $select . ' FROM ' . hikashop_table($trans_table, false) . ' AS b LEFT JOIN ' . hikashop_table('product') . ' AS a ON b.reference_id=a.product_id WHERE ' . implode(' AND ', $filters2) . ' ORDER BY ' . $order; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList("id"); $count = count($rows); if ($count) { $limit = $limit - $count; $filters[] = 'a.product_id NOT IN (' . implode(',', array_keys($rows)) . ')'; } } if ($limit) { if (!empty($leftjoin)) { $select .= ', b.category_id as category_id'; } $db->setQuery('SET SQL_BIG_SELECTS=1'); $db->query(); $filters = implode(' AND ', $filters); if (isset($filters1)) { $filters = '(' . $filters . ') AND (' . implode(' OR ', $filters1) . ')'; } $query = ' SELECT DISTINCT ' . $select . ' FROM ' . hikashop_table('product') . ' AS a ' . $leftjoin . ' WHERE ' . $filters . ' GROUP BY (a.product_id) ORDER BY ' . $order; $db->setQuery($query, 0, $limit); $mainRows = $db->loadObjectList("id"); if (!empty($mainRows)) { foreach ($mainRows as $k => $main) { $rows[$k] = $main; } $count = count($rows); } } if ($count) { if ($multi && !empty($lg)) { $query = ' SELECT * FROM ' . hikashop_table($trans_table, false) . ' WHERE reference_table=\'hikashop_product\' AND language_id=\'' . $lg . '\' AND published=1 AND reference_id IN (' . implode(',', array_keys($rows)) . ')'; $db->setQuery($query); $trans = $db->loadObjectList(); foreach ($trans as $item) { foreach ($rows as $key => $row) { if ($row->id == $item->reference_id) { if ($item->reference_field == 'product_name') { $row->product_name = $item->value; } elseif ($item->reference_field == 'product_description') { $row->product_description = $item->value; } else { $row->product_name = $item->value; } break; } } } } $parent = ''; $item_id = $this->params->get('item_id', ''); $menuClass = hikashop_get('class.menus'); $config =& hikashop_config(); $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway'); $menus = array(); $Itemid = ''; if (!empty($item_id)) { $Itemid = '&Itemid=' . $item_id; if ($this->params->get('full_path', 1)) { $menuData = $menus[$item_id] = $menuClass->get($item_id); if (!empty($menuData->hikashop_params['selectparentlisting'])) { $parent = '&' . $pathway_sef_name . '=' . (int) $menuData->hikashop_params['selectparentlisting']; } } } $itemids = array(); $app = JFactory::getApplication(); $class = hikashop_get('class.product'); $ids = array(); foreach ($rows as $k => $row) { $ids[$row->id] = $row->id; if (!empty($row->category_id)) { if (empty($item_id)) { if (!isset($itemids[$row->category_id])) { $itemids[$row->category_id] = $menuClass->getItemidFromCategory($row->category_id); } $item_id = $itemids[$row->category_id]; } if (!empty($item_id)) { $Itemid = '&Itemid=' . $item_id; } if ($this->params->get('full_path', 1)) { $parent = '&' . $pathway_sef_name . '=' . (int) $row->category_id; } if (!$this->params->get('item_id', '')) { $item_id = ''; } } $class->addAlias($row); $row->title = $row->product_name; $row->text = $row->product_description; if ($variants && $row->product_type == 'variant') { $ids[$row->product_parent_id] = $row->product_parent_id; static $mains = array(); if (!isset($mains[$row->product_parent_id])) { $mains[$row->product_parent_id] = $class->get((int) $row->product_parent_id); $class->addAlias($mains[$row->product_parent_id]); } $db = JFactory::getDBO(); $db->setQuery('SELECT * FROM ' . hikashop_table('variant') . ' AS a LEFT JOIN ' . hikashop_table('characteristic') . ' AS b ON a.variant_characteristic_id=b.characteristic_id WHERE a.variant_product_id=' . (int) $row->id . ' ORDER BY a.ordering'); $row->characteristics = $db->loadObjectList(); $class->checkVariant($row, $mains[$row->product_parent_id]); if (empty($row->title)) { $row->title = $row->product_name; } if (empty($row->text)) { $row->text = $mains[$row->product_parent_id]->product_description; } } if (empty($row->product_canonical)) { $rows[$k]->href = JRoute::_('index.php?option=com_hikashop&ctrl=product&task=show&name=' . $row->alias . '&cid=' . $row->id . $Itemid . $parent); } else { $rows[$k]->href = $row->product_canonical; } $rows[$k]->href = hikashop_cleanURL($rows[$k]->href); $rows[$k]->section = JText::_('PRODUCT'); } if (!empty($ids)) { $imageHelper = hikashop_get('helper.image'); $height = (int) $config->get('thumbnail_y', '100'); $width = (int) $config->get('thumbnail_x', '100'); $image_options = array('default' => true, 'forcesize' => $config->get('image_force_size', true), 'scale' => $config->get('image_scale_mode', 'inside')); $db = JFactory::getDBO(); $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ref_id ASC, file_ordering DESC, file_id ASC'; $db->setQuery($queryImage); $images = $db->loadObjectList('file_ref_id'); foreach ($rows as $k => $row) { foreach ($images as $k2 => $image) { if ($k == $k2) { $result = $imageHelper->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options); if ($result->success) { $rows[$k]->image = $result->url; } break; } } if (!empty($rows[$k]->image)) { continue; } if (!$variants) { continue; } foreach ($images as $k2 => $image) { if ($row->product_parent_id == $k2) { $result = $imageHelper->getThumbnail(@$image->file_path, array('width' => $width, 'height' => $height), $image_options); if ($result->success) { $rows[$k]->image = $result->url; } break; } } } } } return $rows; }
function activate() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $usersConfig = JComponentHelper::getParams('com_users'); $userActivation = $usersConfig->get('useractivation'); $allowUserRegistration = $usersConfig->get('allowUserRegistration'); if ($user->get('id')) { $app->redirect(hikashop_completeLink('checkout', false, true)); } if ($allowUserRegistration == '0' || $userActivation == '0') { JError::raiseError(403, JText::_('Access Forbidden')); return; } $lang = JFactory::getLanguage(); $lang->load('com_user', JPATH_SITE); jimport('joomla.user.helper'); $activation = hikashop_getEscaped(JRequest::getVar('activation', '', '', 'alnum')); if (empty($activation)) { $app->enqueueMessage(JText::_('HIKA_REG_ACTIVATE_NOT_FOUND')); return; } if (version_compare(JVERSION, '1.6', '<')) { $result = JUserHelper::activateUser($activation); } else { if (HIKASHOP_J30) { JModelLegacy::addIncludePath(HIKASHOP_ROOT . DS . 'components' . DS . 'com_users' . DS . 'models'); } else { JModel::addIncludePath(HIKASHOP_ROOT . DS . 'components' . DS . 'com_users' . DS . 'models'); } $model = $this->getModel('Registration', 'UsersModel', array(), true); $language = JFactory::getLanguage(); $language->load('com_users', JPATH_SITE, $language->getTag(), true); if ($model) { $result = $model->activate($activation); } } if (!$result) { $app->enqueueMessage(JText::_('HIKA_REG_ACTIVATE_NOT_FOUND')); return; } else { $app->enqueueMessage(JText::_('HIKA_REG_ACTIVATE_COMPLETE')); $id = JRequest::getInt('id', 0); $class = hikashop_get('class.user'); $user = $class->get($id); if ($id && file_exists(JPATH_ROOT . DS . 'components' . DS . 'com_comprofiler' . DS . 'comprofiler.php') && $userActivation < 2) { $class->addAndConfirmUserInCB($user); } $infos = JRequest::getVar('infos', ''); global $Itemid; $url = ''; if (!empty($Itemid)) { $url = '&Itemid=' . $Itemid; } if (!empty($infos) && function_exists('json_decode')) { $infos = json_decode(base64_decode($infos), true); JPluginHelper::importPlugin('user'); if ($userActivation < 2 && !empty($infos['passwd']) && !empty($infos['username']) && $this->_doLogin($infos['username'], $infos['passwd'], false)) { $page = JRequest::getString('page', 'checkout'); if ($page == 'checkout') { $this->before_address(); $app->redirect(hikashop_completeLink('checkout' . $url, false, true)); } else { JRequest::setVar('layout', 'activate'); return parent::display(); } } elseif ($userActivation >= 2) { $app->enqueueMessage(JText::_('HIKA_ADMIN_CONFIRM_ACTIVATION')); } } if (version_compare(JVERSION, '1.6', '<')) { $url = 'index.php?option=com_user&view=login' . $url; } else { $url = 'index.php?option=com_users&view=login' . $url; } $app->redirect(JRoute::_($url, false)); } }
function showcarts() { $app = JFactory::getApplication(); $config = hikashop_config(); $menus = $app->getMenu(); $menu = $menus->getActive(); global $Itemid; if (empty($menu)) { if (!empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } } if (is_object($menu) && is_object($menu->params)) { $cart_type = $menu->params->get('cart_type'); } if (!empty($cart_type)) { JRequest::setVar('cart_type', $cart_type); } else { $cart_type = JRequest::getString('cart_type', 'cart'); if (!in_array($cart_type, array('cart', 'wishlist'))) { $cart_type = 'cart'; } } $this->assignRef('cart_type', $cart_type); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.cart_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $oldValue = $app->getUserState($this->paramBase . '.list_limit'); if (empty($oldValue)) { $oldValue = $app->getCfg('list_limit'); } $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if ($oldValue != $pageInfo->limit->value) { $pageInfo->limit->start = 0; $app->setUserState($this->paramBase . '.limitstart', 0); } $database = JFactory::getDBO(); $searchMap = array('a.cart_id', 'a.cart_name', 'a.cart_type'); if (hikashop_loadUser() == null) { global $Itemid; $url = ''; if (!empty($Itemid)) { $url = '&Itemid=' . $Itemid; } if (!HIKASHOP_J16) { $url = 'index.php?option=com_user&view=login' . $url; } else { $url = 'index.php?option=com_users&view=login' . $url; } if ($config->get('enable_multicart', '0')) { $app->redirect(JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))), false)); } else { $app->redirect(JRoute::_($url . '&return=' . base64_encode(hikashop_completeLink('cart&task=showcart&cart_type=' . $cart_type . '&Itemid=' . $Itemid, false, false, true)), false)); } return false; } $user = hikashop_loadUser(true); if (isset($user->user_cms_id)) { $user->id = $user->user_cms_id; } else { if (empty($user)) { $user = new stdClass(); } $user->id = 0; } $session = JFactory::getSession(); if ($session->getId()) { $user->session = $session->getId(); } else { $user->session = ''; } if (hikashop_loadUser() == null) { $filters = array('a.session_id=' . $database->Quote($user->session) . ' AND a.cart_type =' . $database->quote($cart_type)); } else { $filters = array('(a.user_id=' . (int) $user->id . ' OR a.session_id=' . $database->Quote($user->session) . ') AND a.cart_type =' . $database->quote($cart_type)); } $groupBy = 'GROUP BY a.cart_id'; $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = 'ORDER BY a.cart_id ASC'; } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filter = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; $filters[] = $filter; } $from = 'FROM ' . hikashop_table('cart') . ' AS a'; $cartProduct = 'LEFT JOIN ' . hikashop_table('cart_product') . ' AS b ON a.cart_id=b.cart_id'; $where = 'WHERE (' . implode(') AND (', $filters) . ') AND a.cart_type =' . $database->quote($cart_type); $query = $from . ' ' . $where . ' ' . $groupBy . ' ' . $order; //'.$cartProduct.' $database->setQuery('SELECT a.* ' . $query); $rows = $database->loadObjectList(); $database->setQuery('SELECT COUNT(*) ' . $from . ' ' . $where); $currencyClass = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyClass); $module = hikashop_get('helper.module'); $module->initialize($this); $currencyClass = hikashop_get('class.currency'); $class = hikashop_get('class.cart'); $productClass = hikashop_get('class.product'); $main_currency = (int) $config->get('main_currency', 1); $currency_id = hikashop_getCurrency(); if ($config->get('tax_zone_type', 'shipping') == 'billing') { $zone_id = hikashop_getZone('billing'); } else { $zone_id = hikashop_getZone('shipping'); } $discount_before_tax = (int) $config->get('discount_before_tax', 0); $cids = array(); foreach ($rows as $row) { if ($row->cart_id != null) { $cids[] = $row->cart_id; } } $filters = ''; $filters = array('a.cart_id IN(' . implode(",", $cids) . ')'); $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY cart_id ASC'; } $product = ' LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id'; $query = 'FROM ' . hikashop_table('cart_product') . ' AS a ' . $product . ' WHERE (' . implode(') AND (', $filters) . ') ' . $order; $database->setQuery('SELECT a.*,b.* ' . $query); if (!empty($cids)) { $products = $database->loadObjectList(); $ids = array(); foreach ($products as $row) { $ids[] = $row->product_id; } $row_1 = 0; foreach ($products as $k => $row) { $currencyClass->getPrices($row, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax); if (!isset($row->prices[0]->price_value)) { if (isset($row_1->prices[0])) { $row->prices[0] = $row_1->prices[0]; } } $products[$k]->hide = 0; if ($row->product_type == 'variant') { $l = --$k; if (isset($products[$l])) { if (!isset($products[$l]) || !is_object($products[$l])) { $products[$l] = new stdClass(); } $products[$l]->hide = 1; } } $row_1 = $row; } $currentId = 0; $values = null; $price = 0; $price_with_tax = 0; $quantity = 0; $currency = hikashop_getCurrency(); foreach ($products as $product) { if (isset($product->cart_id) && isset($product->product_id)) { if ($product->cart_id != $currentId) { $price = 0; $price_with_tax = 0; $quantity = 0; $currentId = $product->cart_id; if (isset($product->prices[0]->price_currency_id)) { $currency = $product->prices[0]->price_currency_id; } } if (isset($product->prices[0])) { $price += $product->cart_product_quantity * $product->prices[0]->price_value; } if (isset($product->prices[0]->price_value_with_tax)) { $price_with_tax += $product->cart_product_quantity * $product->prices[0]->price_value_with_tax; } if (!isset($product->prices[0]->price_value)) { $variant = new stdClass(); $variant->product_parent_id = $product->product_parent_id; $variant->quantity = $product->cart_product_quantity; } if (isset($variant) && isset($product->prices[0]) && $product->product_id == $variant->product_parent_id) { $price += $variant->quantity * $product->prices[0]->price_value; $price_with_tax += $variant->quantity * $product->prices[0]->price_value_with_tax; } $quantity += $product->cart_product_quantity; if (!isset($values[$currentId])) { $values[$currentId] = new stdClass(); } $values[$currentId]->price = $price; $values[$currentId]->price_with_tax = isset($price_with_tax) ? $price_with_tax : $price; $values[$currentId]->quantity = $quantity; $values[$currentId]->currency = $currency; } } $totalCart = 0; $limit = 0; foreach ($rows as $k => $row) { if ($limit >= (int) $pageInfo->limit->start && $limit < (int) $pageInfo->limit->value && isset($values[$row->cart_id]) && $values[$row->cart_id] != null) { $rows[$k]->price = $values[$row->cart_id]->price; $rows[$k]->price_with_tax = $values[$row->cart_id]->price_with_tax; $rows[$k]->quantity = $values[$row->cart_id]->quantity; $rows[$k]->currency = $values[$row->cart_id]->currency; $totalCart++; } else { unset($rows[$k]); $limit--; } $limit++; } } $pageInfo->elements = new stdClass(); $pageInfo->elements->total = count($rows); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'cart_id'); } $pageInfo->elements->page = count($rows); if (!$pageInfo->elements->page) { if (hikashop_loadUser() != null) { $app = JFactory::getApplication(); if ($cart_type == 'cart') { $app->enqueueMessage(JText::_('HIKA_NO_CARTS_FOUND')); } else { $app->enqueueMessage(JText::_('HIKA_NO_WISHLISTS_FOUND')); } } } jimport('joomla.html.pagination'); $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $pagination->hikaSuffix = ''; $this->assignRef('pagination', $pagination); $this->assignRef('pageInfo', $pageInfo); $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $this->assignRef('config', $config); $this->assignRef('carts', $rows); if ($cart_type == 'cart') { $title = JText::_('CARTS'); } else { $title = JText::_('WISHLISTS'); } hikashop_setPageTitle($title); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $filters = array('(module = \'mod_hikashop\' OR module = \'mod_hikashop_cart\' OR module = \'mod_hikashop_wishlist\')'); $searchMap = array('module', 'title'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('modules', false) . ' ' . $filters . $order; $database->setQuery('SELECT *' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $config =& hikashop_config(); foreach ($rows as $k => $row) { $rows[$k]->hikashop_params = $config->get('params_' . $row->id); if (empty($rows[$k]->hikashop_params)) { $rows[$k]->hikashop_params = $config->get('default_params'); } } $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_modules_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_modules_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function delete(&$elements) { if (!is_array($elements)) { $elements = array($elements); } foreach ($elements as $key => $val) { $elements[$key] = hikashop_getEscaped($val); } if (empty($elements)) { return false; } $this->database->setQuery('SELECT `field_namekey`,`field_id`,`field_table`,`field_type` FROM ' . hikashop_table('field') . ' WHERE `field_core` = 0 AND `field_id` IN (' . implode(',', $elements) . ')'); $fieldsToDelete = $this->database->loadObjectList('field_id'); if (empty($fieldsToDelete)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('CORE_FIELD_DELETE_ERROR')); return false; } $namekeys = array(); foreach ($fieldsToDelete as $oneField) { if ($oneField->field_type == 'customtext') { continue; } if ($oneField->field_table == 'item') { $namekeys['cart_product'][] = $oneField->field_namekey; $namekeys['order_product'][] = $oneField->field_namekey; } elseif ($oneField->field_table != 'contact') { $namekeys[$oneField->field_table][] = $oneField->field_namekey; } } foreach ($namekeys as $table => $fields) { $this->database->setQuery('ALTER TABLE ' . $this->fieldTable($table) . ' DROP `' . implode('`, DROP `', $fields) . '`'); $this->database->query(); } $this->database->setQuery('DELETE FROM ' . hikashop_table('field') . ' WHERE `field_id` IN (' . implode(',', array_keys($fieldsToDelete)) . ')'); $result = $this->database->query(); if (!$result) { return false; } $affectedRows = $this->database->getAffectedRows(); foreach ($namekeys as $table => $fields) { $orderClass = hikashop_get('helper.order'); $orderClass->pkey = 'field_id'; $orderClass->table = 'field'; $orderClass->groupMap = 'field_table'; $orderClass->groupVal = $table; $orderClass->orderingMap = 'field_ordering'; $orderClass->reOrder(); } return $affectedRows; }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.badge_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $database = JFactory::getDBO(); $filters = array(); $searchMap = array('a.badge_id', 'a.badge_name', 'a.badge_position'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('badge') . ' AS a' . $filters . $order; $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'badge_id'); } $database->setQuery('SELECT count(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); if ($pageInfo->elements->page) { $types = array('product', 'category', 'discount'); foreach ($types as $type) { $ids = array(); $key = 'badge_' . $type . '_id'; foreach ($rows as $row) { if (empty($row->{$key})) { continue; } $row->{$key} = explode(',', $row->{$key}); foreach ($row->{$key} as $v) { if (is_numeric($v)) { $ids[$v] = $v; } else { $ids[$v] = $database->Quote($v); } } } if (!count($ids)) { continue; } $primary = $type . '_id'; if ($type == 'discount') { $name = $type . '_code'; } else { $name = $type . '_name'; } $query = 'SELECT * FROM ' . hikashop_table($type) . ' WHERE ' . $primary . ' IN (' . implode(',', $ids) . ')'; $database->setQuery($query); $elements = $database->loadObjectList(); foreach ($rows as $k => $row) { if (empty($row->{$key})) { continue; } $display = array(); foreach ($row->{$key} as $el) { foreach ($elements as $element) { if ($element->{$primary} == $el) { $display[] = $element->{$name}; $found = true; break; } } } if (!count($display)) { $display = array(JText::_(strtoupper($type) . '_NOT_FOUND')); } $rows[$k]->{$key} = implode(', ', $display); } } } $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $image = hikashop_get('helper.image'); $this->assignRef('image', $image); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $order = new stdClass(); $order->ordering = true; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.badge_ordering') { if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_badge_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'check' => JText::_('HIKA_VALIDDELETEITEMS'), 'display' => hikashop_isAllowed($config->get('acl_badge_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
public function &getNameboxData($typeConfig, &$fullLoad, $mode, $value, $search, $options) { $ret = array(0 => array(), 1 => array()); $characteristics = null; if (isset($typeConfig['params']['value']) && $typeConfig['params']['value']) { if ((int) $options['url_params']['ID'] > 0) { $query = 'SELECT characteristic_value, characteristic_alias, characteristic_id FROM ' . hikashop_table('characteristic') . ' WHERE characteristic_parent_id = ' . (int) $options['url_params']['ID']; if (!empty($options['vendor'])) { $query .= ' AND characteristic_vendor_id IN (0, ' . (int) $options['vendor'] . ')'; } if (!empty($search)) { $query .= ' AND (characteristic_value LIKE \'%' . hikashop_getEscaped($search) . '%\' OR characteristic_alias LIKE \'%' . hikashop_getEscaped($search) . '%\')'; } $this->database->setQuery($query); $characteristics = $this->database->loadObjectList('characteristic_id'); } if (!empty($value)) { } } else { $query = 'SELECT characteristic_value, characteristic_alias, characteristic_id FROM ' . hikashop_table('characteristic') . ' WHERE characteristic_parent_id = 0'; if (!empty($options['vendor'])) { $query .= ' AND characteristic_vendor_id IN (0, ' . (int) $options['vendor'] . ')'; } $this->database->setQuery($query); $characteristics = $this->database->loadObjectList('characteristic_id'); if (!empty($value)) { } } if (!empty($characteristics)) { foreach ($characteristics as $k => $v) { $v->name = $v->characteristic_value; if (!empty($v->characteristic_alias) && $v->characteristic_value != $v->characteristic_alias) { $v->name .= ' (' . $v->characteristic_alias . ')'; } $ret[0][$k] = $v; } asort($ret[0]); } unset($characteristics); return $ret; }
function selectcategory() { $this->paramBase .= '_category'; $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.category_ordering', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $selectedType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', 0, 'int'); $pageInfo->filter->filter_id = $app->getUserStateFromRequest($this->paramBase . ".filter_id", 'filter_id', 'product', 'string'); $database = JFactory::getDBO(); $searchMap = array('a.category_name', 'a.category_description', 'a.category_id'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $class = hikashop_get('class.category'); $class->parentObject =& $this; $rows = $class->getChildren($pageInfo->filter->filter_id, $selectedType, $filters, $order, $pageInfo->limit->start, $pageInfo->limit->value, false); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'category_id'); } $database->setQuery('SELECT COUNT(*)' . $class->query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->toolbar = array('addNew', 'editList', 'deleteList', '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $childClass = hikashop_get('type.childdisplay'); $childDisplay = $childClass->display('filter_type', $selectedType, false); $this->assignRef('childDisplay', $childDisplay); $breadcrumbClass = hikashop_get('type.breadcrumb'); $breadcrumb = $breadcrumbClass->display('filter_id', $pageInfo->filter->filter_id, 'product'); $this->assignRef('breadCrumb', $breadcrumb); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $order = new stdClass(); $order->ordering = false; $order->orderUp = 'orderup'; $order->orderDown = 'orderdown'; $order->reverse = false; if ($pageInfo->filter->order->value == 'a.category_ordering') { $order->ordering = true; if ($pageInfo->filter->order->dir == 'desc') { $order->orderUp = 'orderdown'; $order->orderDown = 'orderup'; $order->reverse = true; } } $this->assignRef('order', $order); $config =& hikashop_config(); $this->assignRef('config', $config); $this->getPagination(); }
function productDisplay() { $app = JFactory::getApplication(); $db = JFactory::getDBO(); $editor_name = JRequest::getString('editor_name', 'jform_articletext'); $pageInfo = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest("com_content.productbutton.search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->value = $app->getUserStateFromRequest('com_content.productbutton.limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest('com_content.productbutton.limitstart', 'limitstart', 0, 'int'); if (JRequest::getVar('search') != $app->getUserState('com_content.productbutton.search') || JRequest::getVar('limit') != $app->getUserState('com_content.productbutton.limit')) { $pageInfo->limit->start = 0; $app->setUserState('com_content.productbutton.limitstart', 0); } $Select = 'SELECT * FROM ' . hikashop_table('product'); $Where = ' WHERE product_type=\'main\' AND product_access=\'all\' AND product_published=1 '; $orderBY = ' ORDER BY product_id ASC'; $searchMap = array('product_name', 'product_code', 'product_id'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filter = '(' . implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}" . ')'; $filters[] = $filter; } if (is_array($filters) && count($filters)) { $filters = ' AND ' . implode(' AND ', $filters); } else { $filters = ''; } $db->setQuery($Select . $Where . $filters . $orderBY, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $products = $db->loadObjectList(); $db->setQuery('SELECT COUNT(product_id) FROM ' . hikashop_table('product') . ' WHERE product_type=\'main\' AND product_access=\'all\' AND product_published=1' . $filters); $nbrow = $db->loadResult(); $db->setQuery('SELECT * FROM ' . hikashop_table('price') . ' ORDER BY price_product_id ASC'); $prices = $db->loadObjectList(); if (HIKASHOP_J30) { $pagination = hikashop_get('helper.pagination', $nbrow, $pageInfo->limit->start, $pageInfo->limit->value); } else { jimport('joomla.html.pagination'); $pagination = new JPagination($nbrow, $pageInfo->limit->start, $pageInfo->limit->value); } $scriptV1 = "function insertTag(tag){ window.parent.jInsertEditorText(tag,'text'); return true;}"; $scriptV2 = "function insertTag(tag){ window.parent.jInsertEditorText(tag,'" . str_replace(array('\\', '\''), array('\\\\', '\\\''), $editor_name) . "'); return true;}"; if (!HIKASHOP_PHP5) { $doc =& JFactory::getDocument(); } else { $doc = JFactory::getDocument(); } if (version_compare(JVERSION, '1.6.0', '<')) { $doc->addScriptDeclaration($scriptV1); } else { $doc->addScriptDeclaration($scriptV2); } $config =& hikashop_config(); $pricetaxType = hikashop_get('type.pricetax'); $discountDisplayType = hikashop_get('type.discount_display'); ?> <script language="JavaScript" type="text/javascript"> function divhidder(){ if (document.getElementById('price').checked) { document.getElementById('Priceopt').style.visibility = 'visible'; } else { document.getElementById('Priceopt').style.visibility = 'hidden'; } } function checkSelect(){ form = document.getElementById('adminForm'); inputs = form.getElementsByTagName('input'); nbbox = 0; nbboxOk = 0; nbboxProd = 0; for(i=0 ; i < inputs.length ; i++){ if(inputs[i].type == 'checkbox' && inputs[i].checked==true){ nbbox++; } } for(i=0 ; i < inputs.length ; i++){ if(inputs[i].type == 'checkbox' && inputs[i].checked==true){ nbboxOk++; if(inputs[i].id.match(/product_checkbox.*/)){ if (nbboxProd == 0) document.getElementById('product_insert').value = '{product '; nbboxProd++; document.getElementById('product_insert').value = document.getElementById('product_insert').value + inputs[i].name; if(nbbox > nbboxOk){ document.getElementById('product_insert').value = document.getElementById('product_insert').value + '|'; } } } } if( nbboxProd > 0 ) { if(document.getElementById('name').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|name'; } if(document.getElementById('cart').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|cart'; } if(document.getElementById('quantityfield').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|quantityfield'; } if(document.getElementById('description').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|description'; } if(document.getElementById('picture').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|picture'; } if(document.getElementById('link').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|link'; } if(document.getElementById('border').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|border'; } if(document.getElementById('badge').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|badge'; } if(document.getElementById('menuid').value.length != 0){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|menuid:' + document.getElementById('menuid').value; } if(document.getElementById('pricedisc').value==1 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|pricedis1'; } if(document.getElementById('pricedisc').value==2 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|pricedis2'; } if(document.getElementById('pricedisc').value==3 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|pricedis3'; } if(document.getElementById('pricetax').value==1 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|pricetax1'; } if(document.getElementById('pricetax').value==2 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|pricetax2'; } if(document.getElementById('pricedisc').value==0 && document.getElementById('pricetax').value==0 && document.getElementById('price').checked==true){ document.getElementById('product_insert').value =document.getElementById('product_insert').value + '|price'; } document.getElementById('product_insert').value=document.getElementById('product_insert').value + '}'; } if(document.getElementById('name').checked==false && document.getElementById('price').checked==false && document.getElementById('cart').checked==false && document.getElementById('description').checked==false && document.getElementById('picture').checked==false){ document.getElementById('product_insert').value=''; } } function checkAllBox(){ var checkAll = document.getElementById('checkAll'); var toCheck = document.getElementById('ToCheck').getElementsByTagName('input'); for (i = 0 ; i < toCheck.length ; i++) { if (toCheck[i].type == 'checkbox') { if(checkAll.checked == true){ toCheck[i].checked = true; }else{ toCheck[i].checked = false; } } } } </script> <form action="<?php echo hikashop_currentURL(); ?> " method="POST" name="adminForm" id="adminForm"> <table class="hikashop_no_border"> <tr> <td width="100%"> <?php echo JText::_('FILTER'); ?> : <input type="text" name="search" id="hikashop_search" value="<?php echo hikashop_getEscaped($pageInfo->search); ?> " class="inputbox" onchange="document.adminForm.submit();" /> <button class="btn" onclick="this.form.submit();"><?php echo JText::_('GO'); ?> </button> <button class="btn" onclick="document.getElementById('hikashop_search').value='';this.form.submit();"><?php echo JText::_('RESET'); ?> </button> </td> </tr> </table> <fieldset> <legend>OPTIONS</legend> <div id="productInsertOptions"> <input type="checkbox" name="name" id="name" value="1" checked/><?php echo JText::_('HIKA_NAME'); ?> <input type="checkbox" name="description" id="description" value="1" checked/><?php echo JText::_('PRODUCT_DESCRIPTION'); ?> <input type="checkbox" name="cart" id="cart" value="1" <?php if (!empty($_REQUEST['cart'])) { echo 'checked'; } ?> /><?php echo JText::_('HIKASHOP_CHECKOUT_CART'); ?> <input type="checkbox" name="quantity" id="quantityfield" value="1" <?php if (!empty($_REQUEST['quantityfield'])) { echo 'checked'; } ?> /><?php echo JText::_('HIKA_QUANTITY_FIELD'); ?> <input type="checkbox" name="picture" id="picture" value="1" <?php if (!empty($_REQUEST['picture'])) { echo 'checked'; } ?> /><?php echo JText::_('HIKA_IMAGE'); ?> <input type="checkbox" name="link" id="link" value="1" <?php if (!empty($_REQUEST['link'])) { echo 'checked'; } ?> /><?php echo JText::_('LINK_TO_PRODUCT_PAGE'); ?> <input type="checkbox" name="border" id="border" value="1" <?php if (!empty($_REQUEST['border'])) { echo 'checked'; } ?> /><?php echo JText::_('ITEM_BOX_BORDER'); ?> <input type="checkbox" name="badge" id="badge" value="1" <?php if (!empty($_REQUEST['badge'])) { echo 'checked'; } ?> /><?php echo JText::_('HIKA_BADGE'); ?> <br/> Menu ID : <input type="text" name="menuid" id="menuid" <?php if (!empty($_REQUEST['menuid'])) { echo 'value="' . $_REQUEST['menuid'] . '"'; } ?> /> <input type="checkbox" name="pricetax" id="pricetax" value="<?php echo $config->get('price_with_tax'); ?> " hidden/> <br/> <input type="checkbox" name="price" id="price" value="1" checked onclick="divhidder()"/><?php echo JText::_('DISPLAY_PRICE'); ?> <br/> <div id="Priceopt"> <tr id="show_discount_line"> <td class="key" valign="top"> <?php echo JText::_('SHOW_DISCOUNTED_PRICE'); ?> </td> <td> <?php $default_params = $config->get('default_params'); echo $discountDisplayType->display('pricedisc', 3); ?> </td> </tr> <div> </div> </fieldset> <fieldset> <table class="adminlist table table-striped" cellpadding="1" width="100%"> <thead> <tr> <th class="title titlenum"> <?php echo JText::_('HIKA_NUM'); ?> </th> <th class="title titlebox"> <input type="checkbox" name="checkAll" id="checkAll" value="" onclick="checkAllBox();"/> </th> <th class="title"> <?php echo JText::_('HIKA_NAME'); ?> </th> <th class="title"> <?php echo JText::_('PRODUCT_PRICE'); ?> </th> <th class="title"> <?php echo JText::_('PRODUCT_QUANTITY'); ?> </th> <th class="title"> <?php echo 'ID'; ?> </th> </tr> </thead> <tbody id="ToCheck"> <?php $i = 0; $row = ''; $currencyClass = hikashop_get('class.currency'); $currencies = new stdClass(); $currency_symbol = ''; foreach ($products as $product) { $i++; $row .= '<tr><td class="title titlenum">'; $row .= $i; $row .= '</td><td class="title titlebox"><input type="checkbox" id="product_checkbox' . $product->product_id . '" name="' . $product->product_id; $row .= '" value=""/></td><td class="center">'; $row .= $product->product_name; $row .= '</td><td class="center">'; foreach ($prices as $price) { if ($price->price_product_id == $product->product_id) { $row .= $price->price_value; $currency = $currencyClass->getCurrencies($price->price_currency_id, $currencies); foreach ($currency as $currrencie) { if ($price->price_currency_id == $currrencie->currency_id) { $currency_symbol = $currrencie->currency_symbol; } } $row .= ' ' . $currency_symbol; } } $row .= '</td><td class="center">'; if ($product->product_quantity > -1) { $row .= $product->product_quantity; } else { $row .= JText::_('UNLIMITED'); } $row .= '</td><td class="center">'; $row .= $product->product_id; $row .= '</td></tr>'; } echo $row; ?> </tbody> <tfoot> <tr> <td colspan="7"> <?php echo $pagination->getListFooter(); ?> <?php echo $pagination->getResultsCounter(); ?> </td> </tr> </tfoot> </table> </fieldset> <input type="hidden" name="product_insert" id="product_insert" value="" /> <button class="btn" onclick="checkSelect(); insertTag(document.getElementById('product_insert').value); window.parent.SqueezeBox.close();"><?php echo JText::_('HIKA_INSERT'); ?> </button> <?php global $Itemid; ?> <input type="hidden" name="Itemid" value="<?php echo $Itemid; ?> "/> <?php echo JHTML::_('form.token'); }
function select_coupon() { $badge = JRequest::getVar('badge', 'false'); $this->assignRef('badge', $badge); $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.discount_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->filter->filter_type = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', '', 'string'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 500; } $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $database = JFactory::getDBO(); $searchMap = array('a.discount_code', 'a.discount_id'); $filters = array(); if ($badge != 'false') { $filters[] = 'a.discount_type="discount"'; } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $query = ' FROM ' . hikashop_table('discount') . ' AS a'; if ($badge == 'false' && !empty($pageInfo->filter->filter_type)) { switch ($pageInfo->filter->filter_type) { case 'all': break; default: $filters[] = 'a.discount_type = ' . $database->Quote($pageInfo->filter->filter_type); break; } } if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'discount_id'); } $database->setQuery('SELECT count(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); if ($pageInfo->limit->value == 500) { $pageInfo->limit->value = 100; } hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_discount_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'custom', 'icon' => 'copy', 'task' => 'copy', 'alt' => JText::_('HIKA_COPY'), 'display' => $manage), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_discount_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $discountType = hikashop_get('type.discount'); $this->assignRef('filter_type', $discountType); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $currencyHelper = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyHelper); }
function onSearch($text, $phrase = '', $ordering = '', $areas = null) { if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) { return array(); } $db = JFactory::getDBO(); $types = array(); if (!empty($areas) && is_array($areas)) { $valid = array_keys($this->onSearchAreas()); $use = array_intersect($areas, $valid); if (!$use) { return array(); } if (in_array('categories', $valid)) { $types[] = '\'product\''; } if (in_array('manufacturers', $valid)) { $types[] = '\'manufacturer\''; } } else { $types[] = '\'product\''; if (1 == (int) $this->params->get('manufacturers', '1')) { $types[] = '\'manufacturer\''; } } $limit = $this->params->def('search_limit', 50); $text = trim($text); if ($text == '') { return array(); } switch ($ordering) { case 'alpha': $order = 'a.category_name ASC'; break; case 'newest': $order = 'a.category_modified DESC'; break; case 'oldest': $order = 'a.category_created ASC'; break; case 'category': case 'popular': default: $order = 'a.category_name DESC'; break; } $trans = hikashop_get('helper.translation'); $multi = $trans->isMulti(); $trans_table = 'jf_content'; if ($trans->falang) { $trans_table = 'falang_content'; } $rows = array(); $filters = array('a.category_published=1'); if (count($types)) { $filters[] = 'a.category_type IN (' . implode(',', $types) . ')'; } else { $filters[] = 'a.category_type NOT IN (\'status\',\'tax\')'; } hikashop_addACLFilters($filters, 'category_access', 'a'); $filters2 = array(); if ($multi) { $registry = JFactory::getConfig(); if (!HIKASHOP_J25) { $code = $registry->getValue('config.jflang'); } else { $code = $registry->get('language'); } $myLang = $trans->getId($code); $filters2[] = "b.reference_table='hikashop_category'"; $filters2[] = "b.published=1"; $filters2[] = 'b.language_id=' . $myLang; } switch ($phrase) { case 'exact': $text = $db->Quote('%' . hikashop_getEscaped($text, true) . '%', false); $filters1 = array(); $filters1[] = "a.category_name LIKE " . $text; $filters1[] = "a.category_description LIKE " . $text; if ($multi) { $filters2[] = "b.value LIKE " . $text; } break; case 'all': case 'any': default: $words = explode(' ', $text); $wordFilters = array(); $subWordFilters1 = array(); $subWordFilters2 = array(); $wordFilters2 = array(); foreach ($words as $word) { $word = $db->Quote('%' . hikashop_getEscaped($word, true) . '%', false); $subWordFilters1[] = "a.category_name LIKE " . $word; $subWordFilters2[] = "a.category_description LIKE " . $word; if ($multi) { $wordFilters2[] = "b.value LIKE " . $word; } } $wordFilters[0] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $subWordFilters1) . '))'; $wordFilters[1] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $subWordFilters2) . '))'; $filters[] = '((' . implode(') OR (', $wordFilters) . '))'; if ($multi) { $filters2[] = '((' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wordFilters2) . '))'; } break; } $new_page = (int) $this->params->get('new_page', '1'); $select = ' a.category_type AS section, a.category_id AS id, a.category_name AS title, a.category_created AS created , a.category_description AS text, "' . $new_page . '" AS browsernav, a.category_canonical, a.category_alias'; $count = 0; if ($multi && !empty($myLang)) { $query = ' SELECT DISTINCT ' . $select . ' FROM ' . hikashop_table($trans_table, false) . ' AS b LEFT JOIN ' . hikashop_table('category') . ' AS a ON b.reference_id=a.category_id WHERE ' . implode(' AND ', $filters2) . ' ORDER BY ' . $order; $db->setQuery($query, 0, $limit); $rows = $db->loadObjectList("id"); $count = count($rows); if ($count) { $limit = $limit - $count; $ids = array_keys($rows); JArrayHelper::toInteger($ids); $filters[] = 'a.category_id NOT IN (' . implode(',', $ids) . ')'; } } if ($limit) { $filters = implode(' AND ', $filters); if (isset($filters1)) { $filters = '(' . $filters . ') AND (' . implode(' OR ', $filters1) . ')'; } $query = ' SELECT ' . $select . ' FROM ' . hikashop_table('category') . ' AS a WHERE ' . $filters . ' ORDER BY ' . $order; $db->setQuery($query, 0, $limit); $mainRows = $db->loadObjectList("id"); if (!empty($mainRows)) { foreach ($mainRows as $k => $main) { $rows[$k] = $main; } $count = count($rows); } } if ($count) { if ($multi && !empty($myLang)) { $query = ' SELECT * FROM ' . hikashop_table($trans_table, false) . ' WHERE reference_table=\'hikashop_category\' AND language_id=\'' . $myLang . '\' AND published=1 AND reference_id IN (' . implode(',', array_keys($rows)) . ')'; $db->setQuery($query); $trans = $db->loadObjectList(); foreach ($trans as $item) { foreach ($rows as $key => $row) { if ($row->id == $item->reference_id) { if ($item->reference_field == 'category_name') { $row->title = $item->value; } elseif ($item->reference_field == 'category_description') { $row->text = $item->value; } break; } } } } $item_id = $this->params->get('item_id', ''); $menuClass = hikashop_get('class.menus'); if (!empty($item_id)) { $item_id = $menuClass->loadAMenuItemId('category', 'listing', $item_id); } $Itemid = ""; if (!empty($item_id)) { $Itemid = '&Itemid=' . $item_id; } $manu_item_id = $this->params->get('manu_item_id', ''); if (!empty($manu_item_id)) { $manu_item_id = $menuClass->loadAMenuItemId('manufacturer', 'listing', $manu_item_id); } $manu_Itemid = ''; if (!empty($manu_item_id)) { $manu_Itemid = '&Itemid=' . $manu_item_id; } $itemids = array(); $categoryClass = hikashop_get('class.category'); foreach ($rows as $k => $row) { $row->category_name = $row->title; $categoryClass->addAlias($row); if (!empty($row->category_canonical)) { $rows[$k]->href = $row->category_canonical; } else { if (empty($manu_item_id) && !empty($row->id) && $row->section == 'manufacturer') { if (!isset($itemids[$row->id])) { $itemids[$row->id] = $menuClass->getItemidFromCategory($row->id, $row->section); } $manu_item_id = $itemids[$row->id]; if (!empty($manu_item_id)) { $manu_Itemid = '&Itemid=' . $manu_item_id; } if (!$this->params->get('manu_item_id', '')) { $manu_item_id = ''; } } elseif (empty($item_id) && !empty($row->id) && $row->section != 'manufacturer') { if (!isset($itemids[$row->id])) { $itemids[$row->id] = $menuClass->getItemidFromCategory($row->id, 'category'); } $item_id = $itemids[$row->id]; if (!empty($item_id)) { $Itemid = '&Itemid=' . $item_id; } if (!$this->params->get('item_id', '')) { $item_id = ''; } } if ($row->section == 'manufacturer') { $rows[$k]->href = 'index.php?option=com_hikashop&ctrl=category&task=listing&name=' . $row->alias . '&cid=' . $row->id . $manu_Itemid; } else { $rows[$k]->href = 'index.php?option=com_hikashop&ctrl=category&task=listing&name=' . $row->alias . '&cid=' . $row->id . $Itemid; } } if ($row->section == 'manufacturer') { $rows[$k]->section = JText::_('MANUFACTURERS'); } else { $rows[$k]->section = JText::_('PRODUCT_CATEGORY'); } } } return $rows; }
function addFilter(&$filter, &$filters, &$select, &$select2, &$a, &$b, &$on, &$order, &$parent, $divName) { static $i = 0; $i++; $app = JFactory::getApplication(); $database = JFactory::getDBO(); $infoGet = array(); $config = hikashop_config(); static $pagination_reset = false; if (!$pagination_reset) { $new_filter = JRequest::getVar('filter_' . $filter->filter_namekey, null); $new_filter_with_post = false; if (isset($_POST['filter_' . $filter->filter_namekey])) { $new_filter_with_post = true; } $cid = JRequest::getInt("cid", 'itemid_' . JRequest::getInt("Itemid", 0)); $oldValue = $app->getUserState('com_hikashop.' . $cid . '_filter_' . $filter->filter_namekey, ''); if (!is_null($new_filter) && $new_filter != $oldValue && (!$config->get('redirect_post', 0) || $new_filter_with_post)) { $module = hikashop_get('helper.module'); $module->initialize($this); $cid = JRequest::getInt("cid", $this->params->get('selectparentlisting')); if ($this->params->get('content_type') != 'product') { foreach ($this->modules as $module) { $main_div_name = 'hikashop_category_information_module_' . $module->id; JRequest::setVar('limitstart_' . $main_div_name . '_' . $cid, 0); JRequest::setVar('limitstart_' . $main_div_name, 0); } } else { JRequest::setVar('limitstart_' . $this->params->get('main_div_name') . '_' . $cid, 0); JRequest::setVar('limitstart_' . $this->params->get('main_div_name'), 0); } $pagination_reset = true; } } $cid = JRequest::getInt("cid", 'itemid_' . JRequest::getInt("Itemid", 0)); if (JRequest::getVar('filtered') == 1 || $config->get('redirect_post', 0)) { $infoGet = JRequest::getVar('filter_' . $filter->filter_namekey); $app->setUserState('com_hikashop.' . $cid . '_filter_' . $filter->filter_namekey, $infoGet); } else { $infoGet = $app->getUserStateFromRequest('com_hikashop.' . $cid . '_filter_' . $filter->filter_namekey, 'filter_' . $filter->filter_namekey, $infoGet, 'array'); } if (JRequest::getVar('reseted') == 1 || is_string($infoGet) && $infoGet == 'filter_' . $filter->filter_namekey || isset($infoGet[0]) && $infoGet[0] == 'filter_' . $filter->filter_namekey) { $app->setUserState('com_hikashop.' . $cid . '_filter_' . $filter->filter_namekey, ''); return array(); } if (!empty($infoGet) && !is_array($infoGet)) { $infoGet = array($infoGet); } if (isset($infoGet[0])) { $infoGet[0] = trim($infoGet[0]); } if (!isset($infoGet) || empty($infoGet[0])) { return false; } if ($filter->filter_type == 'instockcheckbox' && $infoGet[0] == 'in_stock') { $filters[] = ' b.product_quantity!=0 '; } if ($filter->filter_type == 'text') { if ($filter->filter_name == $infoGet[0]) { return false; } if (!empty($filter->filter_options['max_char']) && strlen($infoGet[0]) > $filter->filter_options['max_char']) { $app->enqueueMessage(JTEXT::_('TEXT_ENTERED_TOO_LONG')); return false; } if (empty($filter->filter_data) || $filter->filter_data[0] == 'all') { $query = 'SELECT * FROM ' . hikashop_table('product') . ' LIMIT 1'; $database->setQuery($query); $object = $database->loadObject(); foreach ($object as $key => $obj) { $searchField[] = $key; } } else { $searchField = $filter->filter_data; } $list = array(); $translationFilters = array(); $translationList = array(); $fields = array(); $searchProcessing = 'any'; if (isset($filter->filter_options['searchProcessing'])) { $searchProcessing = $filter->filter_options['searchProcessing']; } $terms = $infoGet[0]; if ($searchProcessing == 'exact') { if (!empty($terms)) { foreach ($searchField as $column) { $list[] = ' b.' . $column . ' LIKE \'' . hikashop_getEscaped($terms, true) . '\''; $fields[] = ' reference_field = \'' . $column . '\' '; } $translationList[] = 'value LIKE \'' . hikashop_getEscaped($terms, true) . '\''; $filters[] = '(' . implode(' OR ', $list) . ')'; $translationFilters = '(' . implode(' OR ', $translationList) . ')'; } } else { if (!isset($filter->filter_options['searchProcessing'])) { $filter->filter_options['searchProcessing'] = 'any'; } if ($filter->filter_options['searchProcessing'] == 'operators') { $searchProcessing = 'any'; if (preg_match('*. .*', $infoGet[0])) { $searchProcessing = 'any'; } if (preg_match('*.\\+.*', $infoGet[0])) { $terms = str_replace('+', ' ', $terms); $searchProcessing = 'every'; } if (preg_match('#^(["\']).*\\1$#', $infoGet[0])) { $searchProcessing = 'complete'; $terms = trim($terms, '"'); } } if ($searchProcessing == 'complete') { $terms = array($terms); } else { $terms = explode(' ', $terms); } if (@$searchProcessing != 'any') { foreach ($terms as $term) { if (empty($term)) { continue; } $array = array(); foreach ($searchField as $column) { $array[] = ' b.' . $column . ' LIKE \'%' . hikashop_getEscaped($term, true) . '%\' '; $fields[] = ' reference_field = \'' . $column . '\' '; } $list[] = '(' . implode(' OR ', $array) . ')'; $translationList[] = 'value LIKE \'%' . hikashop_getEscaped($term, true) . '%\''; } $filters[] = '(' . implode(' AND ', $list) . ')'; $translationFilters = '(' . implode(' AND ', $translationList) . ')'; } else { foreach ($terms as $term) { if (empty($term)) { continue; } foreach ($searchField as $column) { $list[] = ' b.' . $column . ' LIKE \'%' . hikashop_getEscaped($term, true) . '%\' '; $fields[] = ' reference_field = \'' . $column . '\' '; } $translationList[] = 'value LIKE \'%' . hikashop_getEscaped($term, true) . '%\''; } $filters[] = '(' . implode(' OR ', $list) . ')'; $translationFilters = '(' . implode(' OR ', $translationList) . ')'; } } $translationHelper = hikashop_get('helper.translation'); if ($translationHelper->isMulti(true)) { $trans_table = 'jf_content'; if ($translationHelper->falang) { $trans_table = 'falang_content'; } $query = 'SELECT DISTINCT reference_id FROM ' . hikashop_table($trans_table, false) . ' WHERE reference_table=\'hikashop_product\' AND ' . $translationFilters . ' AND (' . implode(' OR ', $fields) . ') AND published=1 ORDER BY reference_id ASC'; $this->database->setQuery($query); if (!HIKASHOP_J25) { $translatedProducts = $database->loadResultArray(); } else { $translatedProducts = $database->loadColumn(); } if (!empty($translatedProducts)) { $filters[] = '(' . array_pop($filters) . ' OR b.product_id IN (' . implode(',', $translatedProducts) . '))'; } } } if ($filter->filter_data == 'category') { if (!($infoGet[0] == $filter->filter_namekey && count($infoGet) == 1)) { $categoriesList = ''; foreach ($infoGet as $cat) { if ($cat == $filter->filter_namekey || (int) $cat == 0) { continue; } if (is_numeric($cat)) { $categoriesList .= (int) $cat . ','; } elseif (is_string($cat)) { $cat = explode('::', $cat); foreach ($cat as $selectedCategory) { $categoriesList .= (int) $selectedCategory . ','; } } } if (!empty($categoriesList)) { $categoriesList = substr($categoriesList, 0, -1); $table = 'a'; if ($a == '#__hikashop_product AS b') { $table = 'b'; } elseif ($a[0] != '(' && strpos($a, ') AS b') && preg_match('#hikashop_product AS ([a-z0-9_]+)#i', $a, $matches)) { $table = $matches[1]; } $on .= ' INNER JOIN ' . hikashop_table('product_category') . ' AS ' . $filter->filter_namekey . $i . ' ON ' . $filter->filter_namekey . $i . '.product_id=' . $table . '.product_id AND ' . $filter->filter_namekey . $i . '.category_id IN (' . $categoriesList . ')'; } } } if (($filter->filter_data == 'information' || $filter->filter_data == 'price') && $filter->filter_type != 'cursor') { $limit = array(); $type = $filter->filter_options['product_information']; if ($filter->filter_data == 'price') { $type = 'price'; } $case = '( ' . $this->getUnitSelect($filter, $type, $i) . ' )'; $copyGet = $infoGet[0]; $result = explode(',', $copyGet); if (!($result[0] == $infoGet[0])) { foreach ($result as $key => $res) { $infoGet[(int) $key] = (int) $res; } } foreach ($infoGet as $slice) { $values = explode('::', $slice); if (empty($values[0])) { $limit[] = ' ' . $case . ' <= ' . (int) $values[1] . ' '; } else { if (empty($values[1])) { $limit[] = ' ' . $case . ' >= ' . (int) $values[0] . ' '; } else { $limit[] = ' ' . $case . ' BETWEEN ' . (int) $values[0] . ' AND ' . (int) $values[1] . ' '; } } } $filters[] = ' (' . implode('OR', $limit) . ') '; } if ($filter->filter_data == 'characteristic') { if ($infoGet[0] != $filter->filter_namekey && (int) $infoGet[0] != 0 || count($infoGet) > 1) { $charList = array(); foreach ($infoGet as $charac) { $charac = explode('::', $charac); foreach ($charac as $selectedValue) { $charList[] = (int) $selectedValue; } } if (strpos($on, ' LEFT JOIN ' . hikashop_table('product') . ' AS c ON b.product_id=c.product_parent_id') === false) { $on .= ' LEFT JOIN ' . hikashop_table('product') . ' AS c ON b.product_id=c.product_parent_id'; } $on .= ' LEFT JOIN ' . hikashop_table('variant') . ' AS ' . $filter->filter_namekey . $i . ' ON ' . $filter->filter_namekey . $i . '.variant_product_id=c.product_id'; $filters[] = ' ' . $filter->filter_namekey . $i . '.variant_characteristic_id IN (' . implode(',', $charList) . ') '; $filters[] = ' c.product_quantity!=0 '; } } if ($filter->filter_data == 'quantity' && !($infoGet[0] == $filter->filter_namekey && count($infoGet) == 1)) { $filters[] = ' b.product_quantity!=0 '; } if ($filter->filter_data == 'custom_field') { if (empty($filter->filter_value)) { if (!($infoGet[0] == $filter->filter_namekey && count($infoGet) == 1)) { $fieldsList = array(); foreach ($infoGet as $field) { if (!empty($field) && $field != $filter->filter_namekey && $field != ' ' && $field != $filter->filter_namekey && $field != 'none') { $selectedValues = explode('::', $field); foreach ($selectedValues as $oneValue) { $fieldCondition = '( b.' . $filter->filter_options['custom_field'] . ' = ' . $database->Quote($oneValue); $fieldCondition .= 'OR b.' . $filter->filter_options['custom_field'] . ' LIKE \'' . hikashop_getEscaped($oneValue, true) . ',%\''; $fieldCondition .= 'OR b.' . $filter->filter_options['custom_field'] . ' LIKE \'%,' . hikashop_getEscaped($oneValue, true) . '\''; $fieldCondition .= 'OR b.' . $filter->filter_options['custom_field'] . ' LIKE \'%,' . hikashop_getEscaped($oneValue, true) . ',%\' )'; $fieldsList[] = $fieldCondition; } } } if (!empty($fieldsList)) { $fieldsList = '(' . implode(' OR ', $fieldsList) . ')'; $filters[] = $fieldsList; } } } else { foreach ($infoGet as $slice) { $values = explode('::', $slice); if (empty($values[0])) { $limit[] = ' b.' . $filter->filter_options['custom_field'] . ' <= ' . (int) $values[1] . ' '; } else { if (empty($values[1])) { $limit[] = ' b.' . $filter->filter_options['custom_field'] . ' >= ' . (int) $values[0] . ' '; } else { $limit[] = ' b.' . $filter->filter_options['custom_field'] . ' BETWEEN ' . (int) $values[0] . ' AND ' . (int) $values[1] . ' '; } } } $filters[] = ' (' . implode('OR', $limit) . ') '; } } $infos = explode('--', $infoGet[0]); $sort_by_price = false; if (isset($filter->filter_options['sort_by'])) { if (!is_array($filter->filter_options['sort_by'])) { $temp = $filter->filter_options['sort_by']; $filter->filter_options['sort_by'] = array(); $filter->filter_options['sort_by'][] = $temp; } foreach ($filter->filter_options['sort_by'] as $sort_by) { if ($sort_by == "price") { $sort_by_price = true; } } } if (isset($infos[1]) && ($filter->filter_data == 'sort' && $sort_by_price && ($infos[1] == 'lth' || $infos[1] == 'htl')) || $filter->filter_data == 'price') { $subfilters = array(); $where = ''; hikashop_addACLFilters($subfilters, 'price_access', 'price' . $i, 2, true); $subfilters[] = 'product' . $i . '.product_type=\'main\''; $where = ' WHERE ' . implode(' AND ', $subfilters); $subquery = 'SELECT * FROM ' . hikashop_table('product') . ' AS product' . $i . ' LEFT JOIN ' . hikashop_table('price') . ' AS price' . $i . ' ON product' . $i . '.product_id=price' . $i . '.price_product_id ' . $where . ' GROUP BY product' . $i . '.product_id ORDER BY price' . $i . '.price_min_quantity ASC'; $a = '(' . $subquery . ') AS b'; } if ($filter->filter_data == 'sort' && isset($infoGet[0]) && $infoGet[0] != 'none') { $type = $infos[0]; $case = $this->getUnitSelect($filter, $type, $i); if (!empty($case)) { $select2 .= ' ,' . $case . ' as product_' . $type . '_normalized'; if ($infos[1] == 'lth') { $order = ' ORDER BY product_' . $type . '_normalized*1 ASC'; } else { $order = ' ORDER BY product_' . $type . '_normalized*1 DESC'; } } else { if ($infos[1] == 'lth') { $order = ' ORDER BY ' . $type . ' ASC'; } else { $order = ' ORDER BY ' . $type . ' DESC'; } } } if ($filter->filter_data == 'manufacturers') { if (!(in_array($infoGet[0], array($filter->filter_namekey, 0)) && count($infoGet) == 1)) { $manufacturerList = ''; foreach ($infoGet as $manufacturer_id) { $manufacturerList .= (int) $manufacturer_id . ','; } $manufacturerList = substr($manufacturerList, 0, -1); $on .= ' INNER JOIN ' . hikashop_table('category') . ' AS ' . $filter->filter_namekey . $i . ' ON ' . $filter->filter_namekey . $i . '.category_id=b.product_manufacturer_id AND b.product_manufacturer_id IN (' . $manufacturerList . ') '; } } if ($filter->filter_type == 'cursor') { if (empty($infoGet[0])) { return false; } $infoGet = $app->getUserStateFromRequest($parent->paramBase . 'filter_' . $filter->filter_namekey . '_values', 'filter_' . $filter->filter_namekey . '_values', $infoGet, 'array'); if (is_array($infoGet)) { $data =& $infoGet[0]; } else { $data =& $infoGet; } $values = explode(' - ', $data); if (count($values) != 2 || $values[0] == $filter->filter_options['cursor_min'] && $values[1] == $filter->filter_options['cursor_max']) { return false; } if (in_array($filter->filter_data, array('weight', 'length', 'width', 'height', 'surface', 'volume', 'price'))) { $type = $filter->filter_data; $column = $this->getUnitSelect($filter, $type, $i); if ($filter->filter_data == 'price') { $currencyClass = hikashop_get('class.currency'); $rounding = $currencyClass->getRounding(hikashop_getCurrency()); $typeClass = new hikashopFilterTypeClass(); $column = 'round(' . $column . ',' . $rounding . ')'; } $limit = ' ( ' . $column . ' ) BETWEEN ' . (double) $values[0] . ' AND ' . (double) $values[1] . ' '; } else { if (strpos($filter->filter_data, 'b.') !== 0) { $filter->filter_data = 'b.' . $filter->filter_data; } $limit = ' ' . $filter->filter_data . ' BETWEEN ' . (double) $values[0] . ' AND ' . (double) $values[1] . ' '; } $filters[] = $limit; } }
function listing() { $app = JFactory::getApplication(); $enabled = JPluginHelper::isEnabled('system', 'hikashopmassaction'); if (!$enabled) { if (HIKASHOP_J25) { $query = 'UPDATE ' . hikashop_table('extensions', false) . ' SET enabled = 1 WHERE type = "plugin" AND element = "hikashopmassaction" AND folder = "system";'; } else { $query = 'UPDATE ' . hikashop_table('plugins', false) . ' SET published = 1 WHERE element = "hikashopmassaction" AND folder = "system";'; } $db = JFactory::getDBO(); $db->setQuery($query); $success = $db->query(); if ($success) { $app->enqueueMessage(JText::_('HIKA_MASSACTION_SYSTEM_PLUGIN_PUBLISHED')); } } $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.massaction_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $selectedType = $app->getUserStateFromRequest($this->paramBase . ".massaction_table", 'massaction_table', '', 'string'); $database = JFactory::getDBO(); $filters = array(); if (!empty($selectedType)) { $filters[] = 'a.massaction_table=' . $database->Quote($selectedType); } $searchMap = array('a.massaction_id', 'a.massaction_name', 'a.massaction_description', 'a.massaction_table'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('massaction') . ' AS a ' . $filters . $order; $database->setQuery('SELECT a.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'massaction_id'); } $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $table = hikashop_get('type.masstable'); $this->assignRef('tabletype', $table); $this->assignRef('selectedType', $selectedType); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_massaction_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'custom', 'icon' => 'copy', 'alt' => JText::_('HIKA_COPY'), 'task' => 'copy', 'display' => $manage), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_massaction_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function listing() { $this->setName(); $app = JFactory::getApplication(); $database = JFactory::getDBO(); $config =& hikashop_config(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.cart_modified', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $popup = JRequest::getString('tmpl') === 'component'; $this->assignRef('popup', $popup); if (JRequest::getString('cart_type', 'cart') == 'cart') { $filters = array('a.cart_type=\'cart\''); } else { $filters = array('a.cart_type=\'wishlist\''); } $searchMap = array('a.cart_id', 'a.user_id', 'a.cart_name', 'a.cart_coupon', 'a.cart_type'); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $groupBy = 'GROUP BY a.cart_id'; $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE ' . implode(' AND ', $filters); } else { $filters = ''; } $from = 'FROM ' . hikashop_table('cart') . ' AS a'; $cartProduct = 'JOIN ' . hikashop_table('cart_product') . ' AS b ON a.cart_id=b.cart_id'; $query = $from . ' ' . $cartProduct . ' ' . $filters . ' ' . $groupBy . ' ' . $order; $database->setQuery('SELECT a.*, b.* ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'cart_id'); } $database->setQuery('SELECT COUNT(*) ' . $from . ' ' . $cartProduct . ' ' . $filters . ' ' . $groupBy); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $currencyClass = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyClass); $currencyClass = hikashop_get('class.currency'); $productClass = hikashop_get('class.product'); $main_currency = (int) $config->get('main_currency', 1); $currency_id = hikashop_getCurrency(); if ($config->get('tax_zone_type', 'shipping') == 'billing') { $zone_id = hikashop_getZone('billing'); } else { $zone_id = hikashop_getZone('shipping'); } $discount_before_tax = (int) $config->get('discount_before_tax', 0); $cartClass = hikashop_get('class.cart'); foreach ($rows as $k => $row) { if ($row->cart_id != null) { $cartClass->cart = new stdClass(); $cartClass->cart->cart_id = (int) $row->cart_id; $cartClass->cart->cart_type = JRequest::getString('cart_type', 'cart'); $rows[$k]->full_cart = $cartClass->loadFullCart(false, true, true); $rows[$k]->price = isset($rows[$k]->full_cart->full_total->prices[0]->price_value) ? $rows[$k]->full_cart->full_total->prices[0]->price_value : 0; $rows[$k]->quantity = isset($rows[$k]->full_cart->number_of_items) ? $rows[$k]->full_cart->number_of_items : 0; $rows[$k]->currency = isset($rows[$k]->full_cart->full_total->prices[0]->price_currency_id) ? $rows[$k]->full_cart->full_total->prices[0]->price_currency_id : $config->get('main_currency', 1); } } $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $this->assignRef('carts', $rows); $pageInfo->elements->total = count($rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); $manageUser = hikashop_isAllowed($config->get('acl_user_manage', 'all')); $this->assignRef('manageUser', $manageUser); $pageInfo->manageUser = $manageUser; $manage = hikashop_isAllowed($config->get('acl_wishlist_manage', 'all')); $this->assignRef('manage', $manage); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->toolbar = array(array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_wishlist_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); }
function listing() { $app = JFactory::getApplication(); $database = JFactory::getDBO(); $config =& hikashop_config(); $this->assignRef('config', $config); $module = hikashop_get('helper.module'); $module->initialize($this); $this->paramBase .= '_' . $this->params->get('main_div_name'); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $filters = array('b.product_published=1'); $category_selected = ''; $select = ''; $is_synchronized = false; $table = 'b'; $defaultParams = $config->get('default_params'); if (empty($defaultParams['add_to_wishlist'])) { $defaultParams['add_to_wishlist'] = 0; } $params = array('price_display_type' => 'inherit', 'random' => '-1', 'limit' => '', 'product_synchronize' => 4, 'div_item_layout_type' => 'inherit', 'columns' => '', 'margin' => '', 'text_center' => '-1', 'border_visible' => '-1', 'link_to_product_page' => '-1', 'show_price' => '-1', 'add_to_cart' => '-1', 'add_to_wishlist' => '-1', 'layout_type' => 'inherit', 'display_badges' => '-1', 'show_discount' => '3', 'show_quantity_field' => '-1'); $data = $this->params->get('data', new stdClass()); $moduleData = $this->params->get('hikashopmodule'); if (isset($data->hk_product) && is_object($data->hk_product)) { if (!empty($data->hk_product->category)) { $this->params->set('selectparentlisting', (int) $data->hk_product->category); } } elseif (isset($moduleData) && is_object($moduleData)) { foreach ($moduleData as $k => $v) { $this->params->set($k, $v); } } else { if (HIKASHOP_J30) { $this->params->set('content_synchronize', '1'); } $this->params->set('recently_viewed', '0'); } foreach ($params as $k => $v) { if ($this->params->get($k, $v) == $v) { $this->params->set($k, @$defaultParams[$k]); } } if ($this->params->get('product_order', 'inherit') == 'inherit') { if (!isset($defaultParams['product_order']) || $defaultParams['product_order'] == '' || $defaultParams['product_order'] == 'inherit') { $defaultParams['product_order'] = 'ordering'; } $this->params->set('product_order', $defaultParams['product_order']); } if ($this->params->get('order_dir', 'inherit') == 'inherit' || $this->params->get('order_dir', 'inherit') == '') { $this->params->set('order_dir', @$defaultParams['order_dir']); if ($this->params->get('order_dir', 'inherit') == 'inherit' || $this->params->get('order_dir', 'inherit') == '') { $this->params->set('order_dir', 'ASC'); } } if ($this->params->get('show_quantity_field', '0') == '1') { $this->params->set('show_quantity_field', 1); } if ((int) $this->params->get('limit') == 0) { $this->params->set('limit', 1); } if ($this->params->get('product_order', 'ordering') == 'ordering') { $table = 'a'; } $this->loadRef(array('fieldsClass' => 'class.field', 'quantityDisplayType' => 'type.quantitydisplay', 'badgeClass' => 'class.badge', 'currencyClass' => 'class.currency', 'toggleHelper' => 'helper.toggle', 'imageHelper' => 'helper.image')); $this->currencyHelper = $this->currencyClass; $this->toggleClass = $this->toggleHelper; $this->image = $this->imageHelper; $this->classbadge = $this->badgeClass; if (!empty($this->module)) { $pageInfo->search = ''; $force_recently_viewed = false; $pageInfo->filter->order->dir = $this->params->get('order_dir', 'ASC'); $pageInfo->filter->order->value = $table . '.' . $this->params->get('product_order', 'ordering'); $synchro = $this->params->get('content_synchronize'); if ($this->params->get('recently_viewed', '-1') == '-1') { $this->params->set('recently_viewed', @$defaultParams['recently_viewed']); } $recently_viewed = (int) $this->params->get('recently_viewed', 0); if ($synchro) { if (JRequest::getString('option', '') == HIKASHOP_COMPONENT && JRequest::getString('ctrl', 'category') == 'product') { $product_synchronize = (int) $this->params->get('product_synchronize', 0); if ($product_synchronize) { $product_id = hikashop_getCID('product_id'); if (!empty($product_id)) { $pageInfo->filter->cid = $this->params->get('selectparentlisting'); if ($product_synchronize == 2) { $filters[] = 'a.product_related_type=\'related\''; $filters[] = 'a.product_id=' . $product_id; $select = 'SELECT DISTINCT b.*'; $b = hikashop_table('product_related') . ' AS a LEFT JOIN '; $a = hikashop_table('product') . ' AS b'; $on = ' ON a.product_related_id=b.product_id'; if ($this->params->get('product_order') == 'ordering') { $pageInfo->filter->order->value = 'a.product_related_ordering'; } } elseif ($product_synchronize == 3) { $query = "SELECT product_manufacturer_id FROM " . hikashop_table('product') . ' WHERE product_id=' . $product_id . ' OR product_parent_id=' . $product_id; $database->setQuery($query); $filters[] = 'b.product_manufacturer_id =' . (int) $database->loadResult(); $filters[] = 'b.product_id!=' . $product_id; $filters[] = 'b.product_parent_id!=' . $product_id; $select = 'SELECT DISTINCT b.*'; $b = ''; $on = ''; $a = hikashop_table('product') . ' AS b'; $pageInfo->filter->order->value = ''; } elseif ($product_synchronize == 4) { $filters[] = 'b.product_parent_id=' . $product_id; $select = 'SELECT DISTINCT b.*'; $b = ''; $on = ''; $a = hikashop_table('product') . ' AS b'; $this->type = 'variant'; } else { $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway'); $pathway = JRequest::getInt($pathway_sef_name, 0); $filters[] = 'b.product_id!=' . $product_id; $filters[] = 'b.product_parent_id!=' . $product_id; if (empty($pathway)) { $query = "SELECT a.category_id FROM " . hikashop_table('product_category') . ' AS a INNER JOIN ' . hikashop_table('category') . ' AS b ON a.category_id=b.category_id WHERE b.category_published=1 AND a.product_id=' . $product_id . ' ORDER BY a.product_category_id ASC'; $database->setQuery($query); if (!HIKASHOP_J25) { $pageInfo->filter->cid = $database->loadResultArray(); } else { $pageInfo->filter->cid = $database->loadColumn(); } } else { $pageInfo->filter->cid = array($pathway); } } } } } elseif (JRequest::getString('option', '') == HIKASHOP_COMPONENT && JRequest::getString('ctrl', 'category') == 'category') { $pageInfo->filter->cid = JRequest::getInt("cid", $this->params->get('selectparentlisting')); $is_synchronized = true; } else { $pageInfo->filter->cid = $this->params->get('selectparentlisting'); } } elseif ($recently_viewed) { $force_recently_viewed = true; } else { $pageInfo->filter->cid = $this->params->get('selectparentlisting'); } if (!empty($pageInfo->filter->cid) && !is_array($pageInfo->filter->cid)) { $category_selected = '_' . $pageInfo->filter->cid; $this->paramBase .= $category_selected; } $pageInfo->filter->price_display_type = $this->params->get('price_display_type'); if (JRequest::getVar('hikashop_front_end_main', 0)) { $oldValue = $app->getUserState($this->paramBase . '.list_limit'); if (empty($oldValue)) { $oldValue = $this->params->get('limit'); } if ($config->get('redirect_post', 0)) { if (isset($_REQUEST['limit_' . $this->params->get('main_div_name') . $category_selected])) { $pageInfo->limit->value = JRequest::getInt('limit_' . $this->params->get('main_div_name') . $category_selected); } elseif (isset($_REQUEST['limit']) && (empty($this->module) || JRequest::getVar('hikashop_front_end_main', 0))) { $pageInfo->limit->value = JRequest::getInt('limit'); } else { $pageInfo->limit->value = $this->params->get('limit'); } } else { $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit_' . $this->params->get('main_div_name') . $category_selected, $this->params->get('limit'), 'int'); } if ($oldValue != $pageInfo->limit->value) { JRequest::setVar('limitstart_' . $this->params->get('main_div_name') . $category_selected, 0); JRequest::setVar('limitstart', 0); } } else { $pageInfo->limit->value = $this->params->get('limit'); $pageInfo->limit->start = 0; } if ($pageInfo->limit->value < 0) { $pageInfo->limit->value = 1; } if ($force_recently_viewed) { $i = $pageInfo->limit->value; if (!empty($_SESSION['hikashop_viewed_products'])) { $viewed_products_ids = $_SESSION['hikashop_viewed_products']; if (JRequest::getString('option', '') == HIKASHOP_COMPONENT && JRequest::getString('ctrl', 'category') == 'product') { $product_id = hikashop_getCID('product_id'); if (isset($viewed_products_ids[$product_id])) { unset($viewed_products_ids[$product_id]); } } $ids_for_the_query = array(); for ($i = $pageInfo->limit->value; $i > 0 && count($viewed_products_ids); $i--) { $ids_for_the_query[] = array_shift($viewed_products_ids); } if (count($ids_for_the_query)) { $filters[] = 'b.product_id IN (' . implode(',', $ids_for_the_query) . ')'; } else { $filters[] = 'b.product_id=0'; } } else { $filters[] = 'b.product_id=0'; } $select = 'SELECT DISTINCT b.*'; $b = ''; $on = ''; $a = hikashop_table('product') . ' AS b'; if ($this->params->get('product_order') == 'ordering') { $pageInfo->filter->order->value = 'b.product_id'; } } } else { $doc = JFactory::getDocument(); $pageInfo->filter->cid = JRequest::getInt("cid", $this->params->get('selectparentlisting')); if ($config->get('show_feed_link', 1) == 1) { if ($config->get('hikarss_format') != 'none') { $doc_title = $config->get('hikarss_name', ''); if (empty($doc_title)) { $categoryClass = hikashop_get('class.category'); $catData = $categoryClass->get($pageInfo->filter->cid); if ($catData) { $doc_title = $catData->category_name; } } if ($config->get('hikarss_format') != 'both') { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => $doc_title . ' RSS 2.0'); $doc->addHeadLink(JRoute::_($link . '&type=' . $config->get('hikarss_format')), 'alternate', 'rel', $attribs); } else { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => $doc_title . ' RSS 2.0'); $doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => $doc_title . ' Atom 1.0'); $doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } } } $category_selected = '_' . $pageInfo->filter->cid; $this->paramBase .= $category_selected; if (empty($pageInfo->filter->order->value)) { $pageInfo->filter->order->value = $table . '.' . $this->params->get('product_order', 'ordering'); } $pageInfo->filter->order->dir = $this->params->get('order_dir', 'ASC'); $oldValue = $app->getUserState($this->paramBase . '.list_limit'); if (empty($oldValue)) { $oldValue = $this->params->get('limit'); } if ($config->get('redirect_post', 0)) { if (isset($_REQUEST['limit_' . $this->params->get('main_div_name') . $category_selected])) { $pageInfo->limit->value = JRequest::getInt('limit_' . $this->params->get('main_div_name') . $category_selected); } elseif (isset($_REQUEST['limit']) && (empty($this->module) || JRequest::getVar('hikashop_front_end_main', 0))) { $pageInfo->limit->value = JRequest::getInt('limit'); } else { $pageInfo->limit->value = $this->params->get('limit'); } $app->setUserState($this->paramBase . '.list_limit', $pageInfo->limit->value); } else { $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit_' . $this->params->get('main_div_name') . $category_selected, $this->params->get('limit'), 'int'); } if ($oldValue != $pageInfo->limit->value) { JRequest::setVar('limitstart_' . $this->params->get('main_div_name') . $category_selected, 0); JRequest::setVar('limitstart', 0); } $pageInfo->filter->price_display_type = $app->getUserStateFromRequest($this->paramBase . '.price_display_type', 'price_display_type_' . $this->params->get('main_div_name') . $category_selected, $this->params->get('price_display_type'), 'word'); } $this->assignRef('category_selected', $category_selected); $pageInfo->currency_id = hikashop_getCurrency(); $pageInfo->zone_id = hikashop_getZone(null); $this->params->set('show_price_weight', (int) $config->get('show_price_weight', 0)); if (hikashop_level(2)) { $this->params->set('show_compare', (int) $config->get('show_compare', 0)); } else { $this->params->set('show_compare', 0); } if (!empty($pageInfo->filter->cid)) { $acl_filters = array(); hikashop_addACLFilters($acl_filters, 'category_access'); if (!empty($acl_filters)) { if (!is_array($pageInfo->filter->cid)) { $pageInfo->filter->cid = array($database->Quote($pageInfo->filter->cid)); } $acl_filters[] = 'category_id IN (' . implode(',', $pageInfo->filter->cid) . ')'; $query = 'SELECT category_id FROM ' . hikashop_table('category') . ' WHERE ' . implode(' AND ', $acl_filters); $database->setQuery($query); if (!HIKASHOP_J25) { $pageInfo->filter->cid = $database->loadResultArray(); } else { $pageInfo->filter->cid = $database->loadColumn(); } } } if (empty($pageInfo->filter->cid)) { $query = 'SELECT category_id FROM ' . hikashop_table('category') . ' WHERE category_type=\'product\' AND category_parent_id=0 LIMIT 1'; $database->setQuery($query); $pageInfo->filter->cid = $database->loadResult(); } $searchMap = array('b.product_name', 'b.product_description', 'b.product_id', 'b.product_code'); $filters[] = 'b.product_type = ' . $database->Quote($this->type); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } if (!is_array($pageInfo->filter->cid)) { $pageInfo->filter->cid = array((int) $pageInfo->filter->cid); } $this->assignRef('pageInfo', $pageInfo); if (hikashop_level(2)) { $this->filter(); } $categoryClass = hikashop_get('class.category'); $element = $categoryClass->get(reset($pageInfo->filter->cid), true); $this->assignRef('element', $element); if (empty($select)) { $parentCategories = implode(',', $pageInfo->filter->cid); $catName = 'a.category_id'; $type = 'product'; if (!empty($element->category_type) && $element->category_type == 'manufacturer') { if ($pageInfo->filter->order->value == 'a.ordering' || $pageInfo->filter->order->value == 'b.ordering') { $pageInfo->filter->order->value = 'b.product_name'; } $type = 'manufacturer'; $catName = 'b.product_manufacturer_id'; $b = ''; $a = hikashop_table('product') . ' AS b'; $on = ''; $select = 'SELECT DISTINCT b.*'; } else { if ($pageInfo->filter->order->value == 'b.ordering') { $pageInfo->filter->order->value = 'a.ordering'; } $b = hikashop_table('product_category') . ' AS a LEFT JOIN '; $a = hikashop_table('product') . ' AS b'; $on = ' ON a.product_id=b.product_id'; $select = 'SELECT DISTINCT b.*'; } if ($this->params->get('filter_type', 2) == 2) { $defaultParams = $config->get('default_params'); $this->params->set('filter_type', $defaultParams['filter_type']); } if (!$this->params->get('filter_type')) { if (!empty($parentCategories) && $parentCategories != '0') { $filters[] = $catName . ' IN (' . $parentCategories . ')'; } } else { $categoryClass->parentObject =& $this; $categoryClass->type = $type; $children = $categoryClass->getChildren($pageInfo->filter->cid, true, array(), '', 0, 0); $filter = $catName . ' IN ('; foreach ($children as $child) { $filter .= $child->category_id . ','; } $filters[] = $filter . $parentCategories . ')'; } } $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if ($this->params->get('add_to_cart', '-1') == '-1') { $defaultParams = $config->get('default_params'); $this->params->set('add_to_cart', $defaultParams['add_to_cart']); } if ($this->params->get('add_to_cart')) { $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $catalogue = (int) $config->get('catalogue', 0); $this->params->set('catalogue', $catalogue); $cart->cartCount(1); $cart->cartCount(1); $cart->getJS($this->init()); } if ($this->params->get('show_out_of_stock', '-1') == '-1') { $this->params->set('show_out_of_stock', @$config->get('show_out_of_stock')); } if ($this->params->get('show_out_of_stock') != '1') { $filters[] = 'b.product_quantity!=0'; } hikashop_addACLFilters($filters, 'product_access', 'b'); if ($this->params->get('random')) { $order = ' ORDER BY RAND()'; } $select2 = ''; if (hikashop_level(2) && JRequest::getVar('hikashop_front_end_main', 0) && JRequest::getVar('task', 'listing') != 'show') { foreach ($this->filters as $uniqueFitler) { $this->filterClass->addFilter($uniqueFitler, $filters, $select, $select2, $a, $b, $on, $order, $this, $this->params->get('main_div_name')); } } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeProductListingLoad', array(&$filters, &$order, &$this, &$select, &$select2, &$a, &$b, &$on)); $translationFilter = ''; if (isset($filters['translation'])) { $translationFilter = ' OR ' . $filters['translation'] . ' '; unset($filters['translation']); } if (preg_match('#(.*)(a|b)\\.(product_name|product_code) ?(ASC|DESC)(.*)#i', $order, $match)) { $translationHelper = hikashop_get('helper.translation'); if ($translationHelper->isMulti()) { $trans_table = 'jf_content'; if ($translationHelper->falang) { $trans_table = 'falang_content'; } $language = JFactory::getLanguage(); $language_id = (int) $translationHelper->getId($language->getTag()); $on .= ' LEFT JOIN #__' . $trans_table . ' AS trans_table ON trans_table.reference_table=\'hikashop_product\' AND trans_table.language_id=' . $language_id . ' AND trans_table.reference_field=\'' . $match[3] . '\' AND ' . $match[2] . '.product_id=trans_table.reference_id'; $order = $match[1] . 'trans_table.value ' . $match[4] . ', ' . $match[2] . '.' . $match[3] . ' ' . $match[4] . $match[5]; } } $query = $select2 . ' FROM ' . $b . $a . $on . ' WHERE ' . implode(' AND ', $filters) . $translationFilter . $order; if (hikashop_level(2) && JRequest::getVar('hikashop_front_end_main', 0) && JRequest::getVar('task', 'listing') != 'show') { $config->set('hikashopListingQuery', $query); $this->assignRef('listingQuery', $query); } if (!isset($pageInfo->limit->start)) { if ($config->get('redirect_post', 0)) { if (isset($_REQUEST['limitstart_' . $this->params->get('main_div_name') . $category_selected])) { $pageInfo->limit->start = JRequest::getInt('limitstart_' . $this->params->get('main_div_name') . $category_selected); } elseif (isset($_REQUEST['limitstart']) && (empty($this->module) || JRequest::getVar('hikashop_front_end_main', 0))) { $pageInfo->limit->start = JRequest::getInt('limitstart'); } else { $pageInfo->limit->start = 0; } } else { if (JRequest::getInt('limitstart')) { $app->setUserState($this->paramBase . '.limitstart', JRequest::getInt('limitstart')); } $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart_' . $this->params->get('main_div_name') . $category_selected, 0, 'int'); } } $this->checkBackButtonRedirect($this->params->get('main_div_name') . $category_selected); $database->setQuery($select . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($rows)) { $ids = array(); $productClass = hikashop_get('class.product'); foreach ($rows as $key => $row) { if (!is_null($row->product_id)) { $ids[] = $row->product_id; $productClass->addAlias($rows[$key]); } } if (empty($ids)) { $ids = array(0); } $queryImage = 'SELECT * FROM ' . hikashop_table('file') . ' WHERE file_ref_id IN (' . implode(',', $ids) . ') AND file_type=\'product\' ORDER BY file_ref_id ASC, file_ordering ASC, file_id ASC'; $database->setQuery($queryImage); $images = $database->loadObjectList(); foreach ($rows as $k => $row) { if (!empty($images)) { foreach ($images as $image) { if ($row->product_id != $image->file_ref_id) { continue; } if (!isset($row->file_ref_id)) { foreach (get_object_vars($image) as $key => $name) { $rows[$k]->{$key} = $name; } } else { if (empty($row->images)) { $row->images = array(); } $row->images[] = $image; } } } if (!isset($rows[$k]->file_name)) { $rows[$k]->file_name = $row->product_name; } } $database->setQuery('SELECT variant_product_id FROM ' . hikashop_table('variant') . ' WHERE variant_product_id IN (' . implode(',', $ids) . ')'); $variants = $database->loadObjectList(); if (!empty($variants)) { foreach ($rows as $k => $product) { foreach ($variants as $variant) { if ($product->product_id == $variant->variant_product_id) { $rows[$k]->has_options = true; break; } } } } $database->setQuery('SELECT product_id FROM ' . hikashop_table('product_related') . ' WHERE product_related_type = ' . $database->quote('options') . ' AND product_id IN (' . implode(',', $ids) . ')'); $options = $database->loadObjectList(); if (!empty($options)) { foreach ($rows as $k => $product) { foreach ($options as $option) { if ($product->product_id == $option->product_id) { $rows[$k]->has_options = true; break; } } } } $this->currencyClass->getListingPrices($rows, $pageInfo->zone_id, $pageInfo->currency_id, $pageInfo->filter->price_display_type); if ($this->params->get('filter_type') == 3) { $all_categories = array(); $q = 'SELECT product_category.product_id, category.* ' . ' FROM ' . hikashop_table('product_category') . ' as product_category ' . ' INNER JOIN ' . hikashop_table('category') . ' AS category ON product_category.category_id = category.category_id ' . ' INNER JOIN ' . hikashop_table('category') . ' AS main_category ON (category.category_left >= main_category.category_left AND category.category_right <= main_category.category_right AND category.category_depth >= main_category.category_depth) ' . ' WHERE product_category.product_id IN (' . implode(',', $ids) . ') AND main_category.category_id IN (' . implode(',', $pageInfo->filter->cid) . ')'; $database->setQuery($q); $product_categories = $database->loadObjectList(); $categories = array(); foreach ($product_categories as $product_category) { if (empty($categories[$product_category->category_id])) { $categories[$product_category->category_id] = array('category' => $product_category, 'products' => array()); } $categories[$product_category->category_id]['products'][] = $product_category->product_id; } $sortedCategories = array(); $this->_sortCategories($categories, $sortedCategories); $this->assignRef('categories', $sortedCategories); } $catQuery = 'SELECT * FROM ' . hikashop_table('category') . ' AS a LEFT JOIN ' . hikashop_table('product_category') . ' AS b ON a.category_id = b.category_id WHERE b.product_id IN (' . implode(',', $ids) . ');'; $database->setQuery($catQuery); $categories = $database->loadObjectList(); if (!empty($categories)) { foreach ($rows as $k => $product) { $rows[$k]->categories = array(); foreach ($categories as $category) { if ($product->product_id == $category->product_id) { $rows[$k]->categories[(int) $category->category_id] = $category; } } } } if ($this->params->get('display_badges', 1)) { foreach ($rows as $k => $row) { $this->badgeClass->loadBadges($rows[$k]); } } if (hikashop_level(2) && $this->params->get('display_custom_item_fields', 0)) { $itemFields = $this->fieldsClass->getFields('frontcomp', $rows, 'item', 'checkout&task=state'); if (!empty($itemFields)) { $cats = $this->fieldsClass->getCategories('item', $rows); $item_keys = array('field_categories', 'field_products'); foreach ($itemFields as &$itemField) { foreach ($item_keys as $k) { if (is_string($itemField->{$k}) && strpos($itemField->{$k}, ',') !== false) { $itemField->{$k} = explode(',', trim($itemField->{$k}, ',')); JArrayHelper::toInteger($itemField->{$k}); } else { if (!is_array($itemField->{$k}) && !empty($itemField->{$k})) { $itemField->{$k} = array((int) $itemField->{$k}); } } } $item_cats = array(); if (!empty($itemField->field_with_sub_categories)) { foreach ($itemField->field_categories as $c) { $item_cats[] = $c; foreach ($cats['children'] as $k => $v) { if (in_array($c, $v)) { $item_cats[] = $k; } } } array_unique($item_cats); } foreach ($rows as &$row) { if (!isset($row->itemFields)) { $row->itemFields = array(); } if (!empty($itemField->field_products) && in_array((int) $row->product_id, $itemField->field_products)) { $row->itemFields[$itemField->field_namekey] =& $itemField; continue; } if (!empty($itemField->field_categories)) { $prod_cats = array_keys($row->categories); if (empty($item_cats)) { $tmp = array_intersect($itemField->field_categories, $prod_cats); } else { $tmp = array_intersect($item_cats, $prod_cats); } if (!empty($tmp)) { $row->itemFields[$itemField->field_namekey] =& $itemField; } } } unset($row); unset($prod_cats); } unset($itemField); $null = array(); $this->fieldsClass->addJS($null, $null, $null); foreach ($rows as &$row) { if (empty($row->itemFields)) { continue; } $this->fieldsClass->jsToggle($row->itemFields, $row, 0); $extraFields = array('item' => &$row->itemFields); $requiredFields = array(); $validMessages = array(); $values = array('item' => $row); $this->fieldsClass->checkFieldsForJS($extraFields, $requiredFields, $validMessages, $values); $this->fieldsClass->addJS($requiredFields, $validMessages, array('item')); } unset($row); } } } $database->setQuery('SELECT COUNT( DISTINCT b.product_id )' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); global $Itemid; $menus = $app->getMenu(); $menu = $menus->getActive(); if (empty($menu)) { if (!empty($Itemid)) { $menus->setActive($Itemid); $menu = $menus->getItem($Itemid); } } $url_itemid = ''; if (!empty($Itemid)) { $url_itemid = '&Itemid=' . (int) $Itemid; } if (isset($data->hk_product)) { $this->modules = ''; } $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $pagination->hikaSuffix = '_' . $this->params->get('main_div_name') . $category_selected; $this->assignRef('pagination', $pagination); if (empty($this->module)) { $fields = $this->fieldsClass->getFields('frontcomp', $element, 'category', 'checkout&task=state'); $this->assignRef('fields', $fields); $title = $this->params->get('page_title'); if (empty($title)) { $title = $this->params->get('title'); } $use_module = $this->params->get('use_module_name'); if (empty($use_module) && !empty($element->category_name)) { $title = $element->category_name; } if (!empty($element->category_page_title)) { $page_title = $element->category_page_title; } else { $page_title = $title; } hikashop_setPageTitle($page_title); $this->params->set('page_title', $title); $document = JFactory::getDocument(); if (!empty($element->category_keywords)) { $document->setMetadata('keywords', $element->category_keywords); } if (!empty($element->category_meta_description)) { $document->setMetadata('description', $element->category_meta_description); } if (!$this->params->get('random')) { $this->params->set('show_limit', 1); } $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway'); if (empty($menu)) { $categoryClass = hikashop_get('class.category'); $pathway = $app->getPathway(); $category_pathway = '&' . $pathway_sef_name . '=' . JRequest::getVar('menu_main_category'); $categories = $categoryClass->getParents(reset($pageInfo->filter->cid)); $one = true; if (!empty($categories)) { foreach ($categories as $category) { if ($one) { $one = false; } else { $categoryClass->addAlias($category); $pathway->addItem($category->category_name, hikashop_completeLink('category&task=listing&cid=' . (int) $category->category_id . '&name=' . $category->alias)); } } } } else { $category_pathway = '&' . $pathway_sef_name . '=' . reset($pageInfo->filter->cid); } } else { $main = JRequest::getVar('hikashop_front_end_main', 0); if ($main) { if (!empty($product_id)) { $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway'); $related_sef_name = $config->get('related_sef_name', 'related_product'); $category_pathway = '&' . $pathway_sef_name . '=' . JRequest::getInt($pathway_sef_name, 0) . '&' . $related_sef_name . '=' . $product_id; } if (!$this->params->get('random')) { $this->params->set('show_limit', 1); } } $module_item_id = $this->params->get('itemid'); if (!empty($module_item_id)) { $url_itemid = '&Itemid=' . (int) $module_item_id; } if (empty($category_pathway) && !empty($menu) && strpos($menu->link, 'option=' . HIKASHOP_COMPONENT) !== false && (strpos($menu->link, 'view=category') !== false || strpos($menu->link, 'view=') === false) && !JRequest::getInt('no_cid', 0)) { $pathway_sef_name = $config->get('pathway_sef_name', 'category_pathway'); $category_pathway = '&' . $pathway_sef_name . '=' . reset($pageInfo->filter->cid); } } $this->assignRef('itemid', $url_itemid); if ($config->get('simplified_breadcrumbs', 1)) { $category_pathway = ''; } $this->assignRef('category_pathway', $category_pathway); $url = $this->init(true); $this->assignRef('redirect_url', $url); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.zone_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'asc', 'word'); $selectedType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', '', 'string'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if (JRequest::getVar('search') != $app->getUserState($this->paramBase . ".search")) { $app->setUserState($this->paramBase . '.limitstart', 0); $pageInfo->limit->start = 0; } else { $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); } $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); if (empty($pageInfo->limit->value)) { $pageInfo->limit->value = 500; } $database = JFactory::getDBO(); $searchMap = array('a.zone_code_3', 'a.zone_code_2', 'a.zone_name_english', 'a.zone_name', 'a.zone_id'); $filters = array(); if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped($pageInfo->search, true) . '%\''; $filters[] = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}"; } $query = ' FROM ' . hikashop_table('zone') . ' AS a'; if (!empty($selectedType)) { $filters[] = 'a.zone_type = ' . $database->Quote($selectedType); if ($selectedType == 'state') { $selectedCountry = $app->getUserStateFromRequest($this->paramBase . ".filter_country", 'filter_country', 0, 'int'); if ($selectedCountry) { $query = ' FROM ' . hikashop_table('zone') . ' AS c LEFT JOIN ' . hikashop_table('zone_link') . ' AS b ON c.zone_namekey=b.zone_parent_namekey LEFT JOIN ' . hikashop_table('zone') . ' AS a ON b.zone_child_namekey=a.zone_namekey'; $filters[] = 'c.zone_id = ' . $database->Quote($selectedCountry); } } } if (!empty($filters)) { $query .= ' WHERE (' . implode(') AND (', $filters) . ')'; } if (!empty($pageInfo->filter->order->value)) { $query .= ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'zone_id'); } $database->setQuery('SELECT count(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); if ($pageInfo->limit->value == 500) { $pageInfo->limit->value = 100; } hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $config =& hikashop_config(); $manage = hikashop_isAllowed($config->get('acl_zone_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'publishList', 'display' => $manage), array('name' => 'unpublishList', 'display' => $manage), '|', array('name' => 'custom', 'icon' => 'copy', 'alt' => JText::_('HIKA_COPY'), 'task' => 'copy', 'display' => $manage), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_zone_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); $filters = new stdClass(); $zoneType = hikashop_get('type.zone'); $filters->type = $zoneType->display('filter_type', $selectedType); if ($selectedType == 'state') { $countryType = hikashop_get('type.country'); $filters->country = $countryType->display('filter_country', $selectedCountry); } else { $filters->country = ''; } $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('filters', $filters); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $this->getPagination(); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.order_created', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'); $pageInfo->search = JString::strtolower(trim($pageInfo->search)); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $oldValue = $app->getUserState($this->paramBase . '.list_limit'); if (empty($oldValue)) { $oldValue = $app->getCfg('list_limit'); } $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); if ($oldValue != $pageInfo->limit->value) { $pageInfo->limit->start = 0; $app->setUserState($this->paramBase . '.limitstart', 0); } $database = JFactory::getDBO(); $searchMap = array('a.order_id', 'a.order_status', 'a.order_number'); $filters = array(); $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($pageInfo->search)) { $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\''; $filter = '(' . implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}" . ')'; $filters[] = $filter; } if (is_array($filters) && count($filters)) { $filters = ' AND ' . implode(' AND ', $filters); } else { $filters = ''; } $query = 'FROM ' . hikashop_table('order') . ' AS a WHERE a.order_type = ' . $database->Quote('sale') . ' AND a.order_user_id=' . (int) hikashop_loadUser() . $filters . $order; $database->setQuery('SELECT a.* ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); if (!empty($pageInfo->search)) { $rows = hikashop_search($pageInfo->search, $rows, 'order_id'); } $database->setQuery('SELECT COUNT(*) ' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $currencyClass = hikashop_get('class.currency'); $this->assignRef('currencyHelper', $currencyClass); if (!$pageInfo->elements->page) { $app->enqueueMessage(JText::_('NO_ORDERS_FOUND')); } $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value); $pagination->hikaSuffix = ''; $this->assignRef('pagination', $pagination); $this->assignRef('pageInfo', $pageInfo); $string = ''; $params = new HikaParameter($string); $params->set('show_quantity_field', 0); $config =& hikashop_config(); if (hikashop_level(1) && $config->get('allow_payment_button', 1)) { $unpaid_statuses = explode(',', $config->get('order_unpaid_statuses', 'created')); if (!empty($rows)) { foreach ($rows as $k => $order) { if (in_array($order->order_status, $unpaid_statuses)) { $rows[$k]->show_payment_button = true; } } } $payment_change = $config->get('allow_payment_change', 1); $this->assignRef('payment_change', $payment_change); $pluginsPayment = hikashop_get('type.plugins'); $pluginsPayment->type = 'payment'; $this->assignRef('payment', $pluginsPayment); } if ($config->get('cancellable_order_status', '') != '') { $cancellable_order_status = explode(',', $config->get('cancellable_order_status', '')); foreach ($rows as $k => $order) { if (in_array($order->order_status, $cancellable_order_status)) { $rows[$k]->show_cancel_button = true; } } } $this->assignRef('params', $params); $this->assignRef('rows', $rows); $this->assignRef('config', $config); $cart = hikashop_get('helper.cart'); $this->assignRef('cart', $cart); $category = hikashop_get('type.categorysub'); $category->type = 'status'; $category->load(true); $this->assignRef('order_statuses', $category); hikashop_setPageTitle('ORDERS'); }
function listing() { $app = JFactory::getApplication(); $pageInfo = new stdClass(); $pageInfo->filter = new stdClass(); $pageInfo->filter->order = new stdClass(); $pageInfo->limit = new stdClass(); $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.taxation_id', 'cmd'); $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word'); $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int'); $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int'); $pageInfo->filter->taxation_date_start = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.taxation_date_start', 'taxation_date_start', '', 'string'); $pageInfo->filter->taxation_date_end = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.taxation_date_end', 'taxation_date_end', '', 'string'); $pageInfo->filter->tax_namekey = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.tax_namekey', 'tax_namekey', '', 'string'); $pageInfo->filter->taxation_type = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.taxation_type', 'taxation_type', '', 'string'); $pageInfo->filter->taxation_site_id = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.taxation_site_id', 'taxation_site_id', '', 'string'); $database = JFactory::getDBO(); $filters = array(); if (!empty($pageInfo->filter->taxation_date_start)) { $filters[] = '(' . hikashop_getTime($pageInfo->filter->taxation_date_start) . '<=a.taxation_date_start' . ' OR ' . hikashop_getTime($pageInfo->filter->taxation_date_start) . '<=a.taxation_date_end' . ' OR a.taxation_date_end=0' . ')'; } if (!empty($pageInfo->filter->taxation_date_end)) { $filters[] = '(' . 'a.taxation_date_start<=' . hikashop_getTime($pageInfo->filter->taxation_date_end) . ' OR (a.taxation_date_start<=a.taxation_date_end AND a.taxation_date_end<=' . hikashop_getTime($pageInfo->filter->taxation_date_end) . ')' . ' OR a.taxation_date_start=0' . ')'; } if (!empty($pageInfo->filter->tax_namekey)) { $filters[] = 'a.tax_namekey=' . $database->Quote($pageInfo->filter->tax_namekey); } if (!empty($pageInfo->filter->taxation_type)) { $filters[] = '(a.taxation_type=' . $database->Quote($pageInfo->filter->taxation_type) . ' OR taxation_type LIKE \'%' . hikashop_getEscaped($pageInfo->filter->taxation_type, true) . '%\')'; } if (!empty($pageInfo->filter->taxation_site_id) && $pageInfo->filter->taxation_site_id != '[unselected]') { $filters[] = 'a.taxation_site_id=' . $database->Quote($pageInfo->filter->taxation_site_id); } JPluginHelper::importPlugin('hikashop'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onBeforeTaxationListing', array($this->paramBase, &$this->extrafilters, &$pageInfo, &$filters)); $order = ''; if (!empty($pageInfo->filter->order->value)) { $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir; } if (!empty($filters)) { $filters = ' WHERE (' . implode(') AND (', $filters) . ')'; } else { $filters = ''; } $query = ' FROM ' . hikashop_table('taxation') . ' AS a LEFT JOIN ' . hikashop_table('tax') . ' AS b ON a.tax_namekey=b.tax_namekey LEFT JOIN ' . hikashop_table('category') . ' AS c ON a.category_namekey=c.category_namekey AND a.category_namekey!=\'\' AND c.category_type=\'tax\'' . $filters . $order; $database->setQuery('SELECT b.*,c.*,a.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value); $rows = $database->loadObjectList(); $database->setQuery('SELECT COUNT(*)' . $query); $pageInfo->elements = new stdClass(); $pageInfo->elements->total = $database->loadResult(); $pageInfo->elements->page = count($rows); $config =& hikashop_config(); $this->assignRef('config', $config); if ($pageInfo->elements->page) { $zones = array(); foreach ($rows as $row) { if (empty($row->zone_namekey)) { continue; } $tax_zones = explode(',', $row->zone_namekey); foreach ($tax_zones as $zone) { if (!empty($zone)) { $zones[] = $database->Quote($zone); } } } if (count($zones)) { $database->setQuery('SELECT * FROM #__hikashop_zone WHERE zone_namekey IN (' . implode(',', $zones) . ');'); $zones = $database->loadObjectList('zone_namekey'); foreach ($rows as $k => $row) { if (empty($row->zone_namekey)) { continue; } $tax_zones = explode(',', $row->zone_namekey); $rows[$k]->zone_namekey = array(); foreach ($tax_zones as $zone) { if (empty($zone)) { continue; } if (isset($zones[$zone])) { $rows[$k]->zone_namekey[] = $zones[$zone]; } else { $rows[$k]->zone_namekey[] = $zone; } } } } foreach ($rows as $k => $row) { $restrictions = array(); if (!empty($row->zone_namekey)) { $zones = array(); foreach ($row->zone_namekey as $zone) { if (is_string($zone)) { $zones[] = $zone; continue; } if (hikashop_isAllowed($config->get('acl_zone_manage', 'all'))) { $zones[] = $zone->zone_name_english . '<a href="' . hikashop_completeLink('zone&task=edit&zone_id=' . $zone->zone_id) . '"><img class="hikashop_go" src="' . HIKASHOP_IMAGES . 'go.png" alt="go" /></a>'; } else { $zones[] = $zone->zone_name_english; } } if (count($zones)) { $restrictions['ZONE'] = implode(', ', $zones); } } if (!empty($row->taxation_post_code)) { $restrictions['POST_CODE'] = $row->taxation_post_code; } if (!empty($row->taxation_type)) { $row->taxation_type = explode(',', strtoupper(trim($row->taxation_type, ','))); $types = array(); foreach ($row->taxation_type as $type) { $types[] = JText::_($type); } $restrictions['CUSTOMER_TYPE'] = implode(', ', $types); } if (!empty($row->taxation_date_start)) { $restrictions['START_DATE'] = hikashop_getDate($row->taxation_date_start, '%Y-%m-%d %H:%M'); } if (!empty($row->taxation_end_start)) { $restrictions['END_DATE'] = hikashop_getDate($row->taxation_end_start, '%Y-%m-%d %H:%M'); } $rows[$k]->restrictions = $restrictions; } } $toggleClass = hikashop_get('helper.toggle'); $this->assignRef('toggleClass', $toggleClass); $this->assignRef('rows', $rows); $this->assignRef('pageInfo', $pageInfo); $taxType = hikashop_get('type.tax'); $this->assignRef('taxType', $taxType); $ratesType = hikashop_get('type.rates'); $this->assignRef('ratesType', $ratesType); hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl); $this->getPagination(); $manage = hikashop_isAllowed($config->get('acl_taxation_manage', 'all')); $this->assignRef('manage', $manage); $this->toolbar = array(array('name' => 'link', 'icon' => 'edit', 'alt' => JText::_('MANAGE_TAX_CATEGORIES'), 'url' => hikashop_completeLink('category&filter_id=tax'), 'display' => $manage), array('name' => 'link', 'icon' => 'edit', 'alt' => JText::_('MANAGE_RATES'), 'url' => hikashop_completeLink('tax&return=taxation'), 'display' => $manage), array('name' => '|', 'display' => $manage), array('name' => 'addNew', 'display' => $manage), array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_taxation_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard'); JHTML::_('behavior.modal'); }