Exemplo n.º 1
0
 function listing()
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $toggleClass = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $pageInfo = $this->getPageInfo('a.warehouse_id');
     $filters = array();
     $order = '';
     $searchMap = array('a.warehouse_id', 'a.warehouse_name', 'a.warehouse_description');
     $this->processFilters($filters, $order, $searchMap);
     $query = ' FROM ' . hikashop_table('warehouse') . ' AS a' . $filters . $order;
     $this->getPageInfoTotal($query, '*');
     $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value);
     $rows = $database->loadObjectList();
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'warehouse_id');
     }
     $database->setQuery('SELECT count(*)' . $query);
     $pageInfo->elements->page = count($rows);
     $toggleClass = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $this->getOrdering('a.warehouse_ordering', true);
     $this->assignRef('order', $order);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_warehouse_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_warehouse_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
 }
Exemplo n.º 2
0
 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');
 }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
 function listing()
 {
     $app = JFactory::getApplication();
     $database = JFactory::getDBO();
     $config =& hikashop_config();
     $pageInfo = $this->getPageInfo('a.email_log_id');
     $pageInfo->filter->filter_type = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', '', 'string');
     $filters = array();
     $order = '';
     $searchMap = array('a.email_log_recipient_email', 'a.email_log_id');
     if (!empty($pageInfo->filter->filter_type)) {
         switch ($pageInfo->filter->filter_type) {
             case 'all':
                 break;
             default:
                 $filters[] = 'a.email_log_name = ' . $database->Quote($pageInfo->filter->filter_type);
                 break;
         }
     }
     $filters[] = 'a.email_log_published = 1';
     $this->processFilters($filters, $order, $searchMap);
     $query = ' FROM ' . hikashop_table('email_log') . ' AS a' . $filters . $order;
     $this->getPageInfoTotal($query, '*');
     $database->setQuery('SELECT a.*' . $query, $pageInfo->limit->start, $pageInfo->limit->value);
     $rows = $database->loadObjectList();
     $fields = array('email_log_recipient_email', 'email_log_reply_email', 'email_log_subject');
     foreach ($rows as &$row) {
         foreach ($fields as $field) {
             if (isset($row->{$field})) {
                 $row->{$field} = $this->escape($row->{$field});
             }
         }
     }
     unset($row);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'email_log_id');
     }
     $emailType = hikashop_get('type.email_log');
     $this->assignRef('filter_type', $emailType);
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $this->getOrdering('a.email_log_date', true);
     $this->assignRef('order', $order);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $manage = hikashop_isAllowed($config->get('acl_email_log_delete', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($config->get('acl_email_log_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
 }
Exemplo n.º 6
0
    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);
        }
    }
Exemplo n.º 7
0
    if ($this->singleSelection) {
        if ($this->confirm) {
            $data = '{id:' . $product->product_id;
            foreach ($this->elemStruct as $s) {
                if ($s == 'id') {
                    continue;
                }
                $data .= ',' . $s . ':\'' . str_replace(array('\'', '"'), array('\\\'', '\\\''), $product->{$s}) . '\'';
            }
            $data .= '}';
            $extraTr = ' style="cursor:pointer" onclick="window.top.hikashop.submitBox(' . $data . ');"';
        } else {
            $extraTr = ' style="cursor:pointer" onclick="hikashop_setId(\'' . $product->product_id . '\');"';
        }
        if (!empty($this->pageInfo->search)) {
            $row = hikashop_search($this->pageInfo->search, $product, 'product_id');
        }
    } else {
        $lbl1 = '<label for="cb' . $i . '">';
        $lbl2 = '</label>';
        $extraTr = ' onclick="hikashop.checkRow(\'cb' . $i . '\');"';
    }
    ?>
			<tr class="row<?php 
    echo $k;
    ?>
"<?php 
    echo $extraTr;
    ?>
>
				<td align="center"><?php 
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 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');
 }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
 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');
 }
Exemplo n.º 13
0
 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');
 }
Exemplo n.º 14
0
 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);
 }
Exemplo n.º 15
0
 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');
 }
Exemplo n.º 16
0
 function listing()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config =& hikashop_config();
     $this->assignRef('config', $config);
     $toggle = hikashop_get('helper.toggle');
     $this->assignRef('toggleClass', $toggle);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyClass', $currencyClass);
     $zoneClass = hikashop_get('class.zone');
     $this->assignRef('zoneClass', $zoneClass);
     $manage = hikashop_isAllowed($config->get('acl_plugins_manage', 'all'));
     $this->assignRef('manage', $manage);
     $type = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.plugin_type', 'plugin_type', 'shipping');
     $this->assignRef('plugin_type', $type);
     if (HIKASHOP_J16) {
         $query = 'SELECT * FROM ' . hikashop_table('extensions', false) . ' WHERE type=\'plugin\' AND enabled = 1 AND access <> 1 AND (folder=\'hikashoppayment\' OR folder=\'hikashopshipping\') ORDER BY ordering ASC';
         $db->setQuery($query);
         $plugins = $db->loadObjectList();
         if (!empty($plugins)) {
             $s = '(';
             foreach ($plugins as $p) {
                 $s .= $p->name . ', ';
             }
             $s = rtrim($s, ', ') . ')';
             $app->enqueueMessage(JText::sprintf('PLUGIN_ACCESS_WARNING', $s), 'warning');
         }
     }
     if (!in_array($type, array('shipping', 'payment', 'plugin'))) {
         hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
         return false;
     }
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl . '&plugin_type=' . $type);
     $cfg = array('table' => $type, 'main_key' => $type . '_id', 'order_sql_value' => 'plugin.' . $type . '_ordering');
     $searchMap = array('plugin.' . $type . '_name', 'plugin.' . $type . '_type', 'plugin.' . $type . '_id');
     $pageInfo = $this->getPageInfo($cfg['order_sql_value']);
     $filters = array();
     $order = '';
     $this->processFilters($filters, $order, $searchMap);
     JPluginHelper::importPlugin('hikashop');
     if (in_array($type, array('shipping', 'payment'))) {
         JPluginHelper::importPlugin('hikashop' . $type);
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeHikaPluginConfigurationListing', array($type, &$filters, &$order, &$searchMap, &$extrafilters, &$this));
     $query = 'FROM ' . hikashop_table($cfg['table']) . ' AS plugin ' . $filters . $order;
     $this->getPageInfoTotal($query, '*');
     $db->setQuery('SELECT * ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
     $rows = $db->loadObjectList();
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, array($cfg['main_key'], $type . '_params', $type . '_type'));
     }
     $this->assignRef('rows', $rows);
     $pageInfo->elements->page = count($rows);
     $listing_columns = array();
     $pluginInterfaceClass = null;
     switch ($type) {
         case 'payment':
             $pluginInterfaceClass = hikashop_get('class.payment');
             break;
         case 'shipping':
             $pluginInterfaceClass = hikashop_get('class.shipping');
             break;
         case 'plugin':
         default:
             $pluginInterfaceClass = hikashop_get('class.plugin');
             break;
     }
     if (!empty($pluginInterfaceClass) && method_exists($pluginInterfaceClass, 'fillListingColumns')) {
         $pluginInterfaceClass->fillListingColumns($rows, $listing_columns, $this);
     }
     $dispatcher->trigger('onAfterHikaPluginConfigurationListing', array($type, &$rows, &$listing_columns, &$this));
     $this->assignRef('listing_columns', $listing_columns);
     $this->getPagination();
     $this->getOrdering('plugin.' . $type . '_ordering', true);
     if (!HIKASHOP_J16) {
         $db->setQuery('SELECT id, published, name, element FROM ' . hikashop_table('plugins', false) . ' WHERE `folder` = ' . $db->Quote('hikashop' . $type));
     } else {
         $db->setQuery('SELECT extension_id as id, enabled as published, name, element FROM ' . hikashop_table('extensions', false) . ' WHERE `folder` = ' . $db->Quote('hikashop' . $type) . ' AND type=\'plugin\'');
     }
     $plugins = $db->loadObjectList('element');
     $this->assignRef('plugins', $plugins);
     $this->toolbar = array('|', array('name' => 'custom', 'icon' => 'copy', 'task' => 'copy', 'alt' => JText::_('HIKA_COPY'), 'display' => $manage), array('name' => 'publishList', 'display' => $manage), array('name' => 'unpublishList', 'display' => $manage), array('name' => 'addNew', 'display' => $manage), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     return true;
 }
Exemplo n.º 17
0
 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);
 }
Exemplo n.º 18
0
 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');
 }
Exemplo n.º 19
0
 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';
 }
Exemplo n.º 20
0
 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');
     $database = JFactory::getDBO();
     if (version_compare(JVERSION, '1.6', '<')) {
         $query = 'SELECT id FROM ' . hikashop_table('components', false) . ' WHERE link=\'option=' . HIKASHOP_COMPONENT . '\' LIMIT 1';
         $database->setQuery($query);
         $filters = array('(componentid=' . $database->loadResult() . ' OR (componentid=0 AND link LIKE \'%option=' . HIKASHOP_COMPONENT . '%\'))', 'type=\'component\'');
         $searchMap = array('alias', 'link', 'name');
     } else {
         $query = 'SELECT extension_id FROM ' . hikashop_table('extensions', false) . ' WHERE type=\'component\' AND element=\'' . HIKASHOP_COMPONENT . '\' LIMIT 1';
         $database->setQuery($query);
         $filters = array('(component_id=' . $database->loadResult() . ' OR (component_id=0 AND link LIKE \'%option=' . HIKASHOP_COMPONENT . '%\'))', 'type=\'component\'', 'client_id=0');
         $searchMap = array('alias', 'link', 'title');
     }
     $filters[] = 'published>-2';
     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('menu', false) . ' ' . $filters . $order;
     $database->setQuery('SELECT *' . $query);
     $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);
     $unset = array();
     foreach ($rows as $k => $row) {
         if (strpos($row->link, 'view=product') !== false && strpos($row->link, 'layout=show') === false) {
             $rows[$k]->hikashop_params = $this->config->get('menu_' . $row->id);
             $rows[$k]->hikashop_params['content_type'] = 'product';
         } elseif (strpos($row->link, 'view=category') !== false || strpos($row->link, 'view=') === false) {
             $rows[$k]->hikashop_params = $this->config->get('menu_' . $row->id);
             $rows[$k]->hikashop_params['content_type'] = 'category';
         } else {
             $unset[] = $k;
             continue;
         }
         if (empty($rows[$k]->hikashop_params)) {
             $rows[$k]->hikashop_params = $this->config->get('default_params');
         }
         $rows[$k]->content_type = $rows[$k]->hikashop_params['content_type'];
     }
     foreach ($unset as $u) {
         unset($rows[$u]);
     }
     $this->assignRef('rows', $rows);
     $this->assignRef('pageInfo', $pageInfo);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $manage = hikashop_isAllowed($this->config->get('acl_menus_manage', 'all'));
     $this->assignRef('manage', $manage);
     $this->toolbar = array(array('name' => 'editList', 'display' => $manage), array('name' => 'deleteList', 'display' => hikashop_isAllowed($this->config->get('acl_menus_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
 }
Exemplo n.º 21
0
 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);
 }
Exemplo n.º 22
0
 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.limit_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->limit_type = $app->getUserStateFromRequest($this->paramBase . ".limit_type", 'limit_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.limit_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('limit') . ' AS a';
     if (!empty($pageInfo->filter->limit_type)) {
         switch ($pageInfo->filter->limit_type) {
             case 'all':
                 break;
             default:
                 $filters[] = 'a.limit_type = ' . $database->Quote($pageInfo->filter->limit_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, 'limit_id');
     }
     $database->setQuery('SELECT count(*)' . $query);
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = $database->loadResult();
     $pageInfo->elements->page = count($rows);
     if ($pageInfo->elements->page) {
         $productIds = array();
         $categoryIds = array();
         $zoneIds = array();
         foreach ($rows as $row) {
             if (!empty($row->limit_product_id)) {
                 $productIds[] = $row->limit_product_id;
             }
             if (!empty($row->limit_category_id)) {
                 $categoryIds[] = $row->limit_category_id;
             }
         }
         if (!empty($productIds)) {
             $query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $productIds) . ')';
             $database->setQuery($query);
             $products = $database->loadObjectList();
             foreach ($rows as $k => $row) {
                 if (!empty($row->limit_product_id)) {
                     $found = false;
                     foreach ($products as $product) {
                         if ($product->product_id == $row->limit_product_id) {
                             foreach (get_object_vars($product) as $field => $value) {
                                 $rows[$k]->{$field} = $product->{$field};
                             }
                             $found = true;
                         }
                     }
                     if (!$found) {
                         $rows[$k]->product_name = JText::_('PRODUCT_NOT_FOUND');
                     }
                 }
             }
         }
         if (!empty($categoryIds)) {
             $query = 'SELECT * FROM ' . hikashop_table('category') . ' WHERE category_id IN (' . implode(',', $categoryIds) . ')';
             $database->setQuery($query);
             $categories = $database->loadObjectList();
             foreach ($rows as $k => $row) {
                 if (!empty($row->limit_category_id)) {
                     $found = false;
                     foreach ($categories as $category) {
                         if ($category->category_id == $row->limit_category_id) {
                             foreach (get_object_vars($category) as $field => $value) {
                                 $rows[$k]->{$field} = $category->{$field};
                             }
                             $found = true;
                         }
                     }
                     if (!$found) {
                         $rows[$k]->category_name = JText::_('CATEGORY_NOT_FOUND');
                     }
                 }
             }
         }
     }
     if ($pageInfo->limit->value == 500) {
         $pageInfo->limit->value = 0;
     }
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_limit_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_limit_delete', 'all'))), '|', array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     $limitType = hikashop_get('type.limit');
     $this->assignRef('limit_type', $limitType);
     $weightType = hikashop_get('type.weight');
     $this->assignRef('limit_unit', $weightType);
     $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);
 }
Exemplo n.º 23
0
 function listing()
 {
     $app = JFactory::getApplication();
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->client_id = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.client_id', 'client_id', 2, 'int');
     $pageInfo->filter->template = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.template', 'template', '', 'string');
     $pageInfo->filter->component = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.component', 'component', '', 'string');
     $pageInfo->filter->viewType = $app->getUserStateFromRequest(HIKASHOP_COMPONENT . '.viewType', 'viewType', '', 'string');
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.limit', 'limit', $app->getCfg('list_limit'), 'int');
     if (empty($pageInfo->limit->value)) {
         $pageInfo->limit->value = 500;
     }
     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->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');
     $views = array();
     switch ($pageInfo->filter->client_id) {
         case 0:
             $views[0] = HIKASHOP_FRONT . 'views' . DS;
             break;
         case 1:
             $views[1] = HIKASHOP_BACK . 'views' . DS;
             break;
         default:
             $views[0] = HIKASHOP_FRONT . 'views' . DS;
             $views[1] = HIKASHOP_BACK . 'views' . DS;
             break;
     }
     JPluginHelper::importPlugin('hikashop');
     $dispatcher = JDispatcher::getInstance();
     $pluginViews = array();
     $dispatcher->trigger('onViewsListingFilter', array(&$pluginViews, $pageInfo->filter->client_id));
     if (!empty($pluginViews)) {
         $i = 2;
         foreach ($pluginViews as $pluginView) {
             $views[$i++] = $pluginView;
         }
     }
     $this->assignRef('pluginViews', $pluginViews);
     jimport('joomla.filesystem.folder');
     if (version_compare(JVERSION, '1.6', '<')) {
         require_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_templates' . DS . 'helpers' . DS . 'template.php';
     }
     $templates = array();
     $templateValues = array();
     foreach ($views as $client_id => $view) {
         $component_name = '';
         $component = HIKASHOP_COMPONENT;
         if (is_array($view)) {
             $client_id = $view['client_id'];
             $component_name = $view['name'];
             $component = $view['component'];
             $view = $view['view'];
         }
         if (!empty($pageInfo->filter->component) && $pageInfo->filter->component != $component) {
             continue;
         }
         $folders = JFolder::folders($view);
         if (empty($folders)) {
             continue;
         }
         $clientTemplates = array();
         foreach ($folders as $folder) {
             if (JFolder::exists($view . $folder . DS . 'tmpl')) {
                 $files = JFolder::files($view . $folder . DS . 'tmpl');
                 if (!empty($files)) {
                     foreach ($files as $file) {
                         if (substr($file, -4) == '.php') {
                             $obj = new stdClass();
                             $obj->path = $view . $folder . DS . 'tmpl' . DS . $file;
                             $obj->filename = $file;
                             $obj->folder = $view . $folder . DS . 'tmpl' . DS;
                             $obj->client_id = $client_id;
                             $obj->view = $folder;
                             $obj->type = 'component';
                             $obj->type_name = $component;
                             $obj->file = substr($file, 0, strlen($file) - 4);
                             $clientTemplates[] = $obj;
                         }
                     }
                 }
             }
         }
         if ($client_id == 0 && $component == HIKASHOP_COMPONENT) {
             $plugins_folder = rtrim(JPATH_PLUGINS, DS) . DS . 'hikashoppayment';
             if (Jfolder::exists($plugins_folder)) {
                 $files = Jfolder::files($plugins_folder);
                 foreach ($files as $file) {
                     if (preg_match('#^.*_(?!configuration).*\\.php$#', $file)) {
                         $obj = new stdClass();
                         $obj->path = $plugins_folder . DS . $file;
                         $obj->filename = $file;
                         $obj->folder = $plugins_folder;
                         $obj->client_id = $client_id;
                         $obj->type = 'plugin';
                         $obj->view = '';
                         $obj->type_name = 'hikashoppayment';
                         $obj->file = substr($file, 0, strlen($file) - 4);
                         $clientTemplates[] = $obj;
                     }
                 }
             }
         }
         if (!empty($clientTemplates)) {
             $client = JApplicationHelper::getClientInfo($client_id);
             $tBaseDir = $client->path . DS . 'templates';
             if (version_compare(JVERSION, '1.6', '<')) {
                 $joomlaTemplates = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);
             } else {
                 $query = 'SELECT * FROM ' . hikashop_table('extensions', false) . ' WHERE type=\'template\' AND client_id=' . (int) $client_id;
                 $db = JFactory::getDBO();
                 $db->setQuery($query);
                 $joomlaTemplates = $db->loadObjectList();
                 foreach ($joomlaTemplates as $k => $v) {
                     $joomlaTemplates[$k]->assigned = $joomlaTemplates[$k]->protected;
                     $joomlaTemplates[$k]->published = $joomlaTemplates[$k]->enabled;
                     $joomlaTemplates[$k]->directory = $joomlaTemplates[$k]->element;
                 }
             }
             for ($i = 0; $i < count($joomlaTemplates); $i++) {
                 if (version_compare(JVERSION, '1.6', '<')) {
                     $joomlaTemplates[$i]->assigned = TemplatesHelper::isTemplateAssigned($joomlaTemplates[$i]->directory);
                     $joomlaTemplates[$i]->published = TemplatesHelper::isTemplateDefault($joomlaTemplates[$i]->directory, $client->id);
                 }
                 if ($joomlaTemplates[$i]->published || $joomlaTemplates[$i]->assigned) {
                     if (!empty($pageInfo->filter->template) && $joomlaTemplates[$i]->directory != $pageInfo->filter->template) {
                         continue;
                     }
                     $templateValues[$joomlaTemplates[$i]->directory] = $joomlaTemplates[$i]->directory;
                     $templateFolder = $tBaseDir . DS . $joomlaTemplates[$i]->directory . DS;
                     foreach ($clientTemplates as $template) {
                         $templatePerJoomlaTemplate = clone $template;
                         $templatePerJoomlaTemplate->template = $joomlaTemplates[$i]->directory;
                         $templatePerJoomlaTemplate->component = $component_name;
                         $templatePerJoomlaTemplate->override = $templateFolder . 'html' . DS . $template->type_name . DS;
                         if ($template->type == 'component') {
                             $templatePerJoomlaTemplate->override .= $template->view . DS;
                         }
                         $templatePerJoomlaTemplate->override .= $template->filename;
                         $templatePerJoomlaTemplate->overriden = false;
                         if (file_exists($templatePerJoomlaTemplate->override)) {
                             $templatePerJoomlaTemplate->overriden = true;
                         }
                         $templatePerJoomlaTemplate->id = $templatePerJoomlaTemplate->client_id . '|' . $templatePerJoomlaTemplate->template . '|' . $templatePerJoomlaTemplate->type . '|' . $templatePerJoomlaTemplate->type_name . '|' . $templatePerJoomlaTemplate->view . '|' . $templatePerJoomlaTemplate->filename;
                         $key = $templatePerJoomlaTemplate->client_id . '|' . $templatePerJoomlaTemplate->template . '|' . $templatePerJoomlaTemplate->type_name . '|' . $templatePerJoomlaTemplate->view . '|' . $templatePerJoomlaTemplate->filename;
                         if (!empty($pageInfo->filter->viewType) && $templatePerJoomlaTemplate->view != $pageInfo->filter->viewType) {
                             continue;
                         }
                         $templates[$key] = $templatePerJoomlaTemplate;
                     }
                     if (JFolder::exists($templateFolder . 'html' . DS . $component . DS)) {
                         $folders = JFolder::folders($templateFolder . 'html' . DS . $component . DS);
                         if (!empty($folders)) {
                             foreach ($folders as $folder) {
                                 $files = JFolder::files($templateFolder . 'html' . DS . $component . DS . $folder);
                                 if (empty($files)) {
                                     continue;
                                 }
                                 foreach ($files as $file) {
                                     if (substr($file, -4) != '.php') {
                                         continue;
                                     }
                                     $filename = $templateFolder . 'html' . DS . $component . DS . $folder . DS . $file;
                                     $found = false;
                                     foreach ($templates as $tpl) {
                                         if ($tpl->override == $filename) {
                                             $found = true;
                                             break;
                                         }
                                     }
                                     if (!$found) {
                                         $obj = new stdClass();
                                         $obj->path = $view . $folder . DS . 'tmpl' . DS . $file;
                                         $obj->filename = $file;
                                         $obj->folder = $view . $folder . DS . 'tmpl' . DS;
                                         $obj->client_id = $client_id;
                                         $obj->view = $folder;
                                         $obj->template = $joomlaTemplates[$i]->directory;
                                         $obj->type = 'component';
                                         $obj->type_name = $component;
                                         $obj->file = substr($file, 0, strlen($file) - 4);
                                         $obj->override = $filename;
                                         $obj->overriden = true;
                                         $obj->id = $obj->client_id . '|' . $obj->template . '|' . $obj->type . '|' . $obj->type_name . '|' . $obj->view . '|' . $obj->filename;
                                         $key = $obj->client_id . '|' . $obj->template . '|' . $obj->view . '|' . $obj->filename;
                                         $templates[$key] = $obj;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     ksort($templates);
     $searchMap = array('filename', 'view', 'template');
     if (!empty($pageInfo->search)) {
         $unset = array();
         foreach ($templates as $k => $template) {
             $found = false;
             foreach ($searchMap as $field) {
                 if (strpos($template->{$field}, $pageInfo->search) !== false) {
                     $found = true;
                 }
             }
             if (!$found) {
                 $unset[] = $k;
             }
         }
         if (!empty($unset)) {
             foreach ($unset as $u) {
                 unset($templates[$u]);
             }
         }
         $templates = hikashop_search($pageInfo->search, $templates, 'id');
     }
     $viewTypes = array('0' => JHTML::_('select.option', 0, JText::_('ALL_VIEWS')));
     foreach ($templates as $temp) {
         if (!isset($viewTypes[strip_tags($temp->view)]) && !empty($temp->view)) {
             $viewTypes[strip_tags($temp->view)] = JHTML::_('select.option', strip_tags($temp->view), strip_tags($temp->view));
         }
     }
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = count($templates);
     if ($pageInfo->limit->value == 500) {
         $pageInfo->limit->value = 100;
     }
     $this->assignRef('pageInfo', $pageInfo);
     $this->getPagination();
     $templates = array_slice($templates, $this->pagination->limitstart, $this->pagination->limit);
     $pageInfo->elements->page = count($templates);
     $this->assignRef('viewTypes', $viewTypes);
     $this->assignRef('rows', $templates);
     $this->assignRef('templateValues', $templateValues);
     $viewType = hikashop_get('type.view');
     $this->assignRef('viewType', $viewType);
     $templateType = hikashop_get('type.template');
     $this->assignRef('templateType', $templateType);
     hikashop_setTitle(JText::_($this->nameListing), $this->icon, $this->ctrl);
     $config =& hikashop_config();
     $manage = hikashop_isAllowed($config->get('acl_view_manage', 'all'));
     $this->assignRef('manage', $manage);
     $delete = hikashop_isAllowed($config->get('acl_view_delete', 'all'));
     $this->assignRef('delete', $delete);
     $this->toolbar = array(array('name' => 'pophelp', 'target' => $this->ctrl . '-listing'), 'dashboard');
     jimport('joomla.client.helper');
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $this->assignRef('ftp', $ftp);
 }
Exemplo n.º 24
0
 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();
 }
Exemplo n.º 25
0
 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();
 }
Exemplo n.º 26
0
                    continue;
                }
                $data .= ',' . $s . ':\'' . str_replace(array('\'', '"'), array('\\\'', '\\\''), $row->{$s}) . '\'';
            }
            $data .= '}';
            $extraTr = ' style="cursor:pointer" onclick="window.top.hikashop.submitBox(' . $data . ');"';
        } else {
            $extraTr = ' style="cursor:pointer" onclick="hikashop_setId(\'' . $row->user_id . '\');"';
        }
    } else {
        $lbl1 = '<label for="cb' . $i . '">';
        $lbl2 = '</label>';
        $extraTr = ' onclick="hikashop.checkRow(\'cb' . $i . '\');"';
    }
    if (!empty($this->pageInfo->search)) {
        $row = hikashop_search($this->pageInfo->search, $row, 'user_id');
    }
    ?>
			<tr class="row<?php 
    echo $k;
    ?>
"<?php 
    echo $extraTr;
    ?>
>
				<td align="center">
					<?php 
    echo $this->pagination->getRowOffset($i);
    ?>
				</td>
<?php 
Exemplo n.º 27
0
 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');
 }
Exemplo n.º 28
0
 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');
 }