/** * Show Customers */ function view_customers() { global $_ARRAYLANG; $template = isset($_GET['tpl']) ? $_GET['tpl'] : ''; if ($template == 'discounts') { return $this->view_customer_discounts(); } if ($template == 'groups') { return $this->view_customer_groups(); } $this->toggleCustomer(); $i = 0; self::$objTemplate->loadTemplateFile("module_shop_customers.html"); $customer_active = null; $customer_type = null; $searchterm = null; $listletter = null; $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop'); $group_id_reseller = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop'); $uri = \Html::getRelativeUri(); // TODO: Strip what URI parameters? \Html::stripUriParam($uri, 'active'); \Html::stripUriParam($uri, 'customer_type'); \Html::stripUriParam($uri, 'searchterm'); \Html::stripUriParam($uri, 'listletter'); $uri_sorting = $uri; $arrFilter = array(); if (isset($_REQUEST['active']) && $_REQUEST['active'] != '') { $customer_active = intval($_REQUEST['active']); $arrFilter['active'] = $customer_active; \Html::replaceUriParameter($uri_sorting, "active={$customer_active}"); } if (isset($_REQUEST['customer_type']) && $_REQUEST['customer_type'] != '') { $customer_type = intval($_REQUEST['customer_type']); switch ($customer_type) { case 0: $arrFilter['group'] = array($group_id_customer); break; case 1: $arrFilter['group'] = array($group_id_reseller); break; } \Html::replaceUriParameter($uri_sorting, "customer_type={$customer_type}"); } else { $arrFilter['group'] = array($group_id_customer, $group_id_reseller); } //DBG::log("Group filter: ".var_export($arrFilter, true)); if (!empty($_REQUEST['searchterm'])) { $searchterm = trim(strip_tags(contrexx_input2raw($_REQUEST['searchterm']))); \Html::replaceUriParameter($uri_sorting, "searchterm={$searchterm}"); } elseif (!empty($_REQUEST['listletter'])) { $listletter = contrexx_input2raw($_REQUEST['listletter']); \Html::replaceUriParameter($uri_sorting, "listletter={$listletter}"); } $arrSorting = array('id' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_ID'], 'company' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_COMPANY'], 'firstname' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_FIRSTNAME'], 'lastname' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_LASTNAME'], 'address' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_ADDRESS'], 'zip' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_ZIP'], 'city' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_CITY'], 'phone' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_PHONE'], 'email' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_EMAIL'], 'active' => $_ARRAYLANG['TXT_SHOP_CUSTOMER_ACTIVE']); $objSorting = new \Sorting($uri_sorting, $arrSorting, false, 'order_shop_customer'); self::$objTemplate->setVariable(array('SHOP_HEADING_CUSTOMER_ID' => $objSorting->getHeaderForField('id'), 'SHOP_HEADING_CUSTOMER_COMPANY' => $objSorting->getHeaderForField('company'), 'SHOP_HEADING_CUSTOMER_FIRSTNAME' => $objSorting->getHeaderForField('firstname'), 'SHOP_HEADING_CUSTOMER_LASTNAME' => $objSorting->getHeaderForField('lastname'), 'SHOP_HEADING_CUSTOMER_ADDRESS' => $objSorting->getHeaderForField('address'), 'SHOP_HEADING_CUSTOMER_ZIP' => $objSorting->getHeaderForField('zip'), 'SHOP_HEADING_CUSTOMER_CITY' => $objSorting->getHeaderForField('city'), 'SHOP_HEADING_CUSTOMER_PHONE' => $objSorting->getHeaderForField('phone'), 'SHOP_HEADING_CUSTOMER_EMAIL' => $objSorting->getHeaderForField('email'), 'SHOP_HEADING_CUSTOMER_ACTIVE' => $objSorting->getHeaderForField('active'))); $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_customers_per_page_backend', 'Shop'); $objCustomer = Customers::get($arrFilter, $listletter ? $listletter . '%' : $searchterm, array($objSorting->getOrderField() => $objSorting->getOrderDirection()), $limit, \Paging::getPosition()); $count = $objCustomer ? $objCustomer->getFilteredSearchUserCount() : 0; while ($objCustomer && !$objCustomer->EOF) { //DBG::log("Customer: ".var_export($objCustomer, true)); self::$objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_CUSTOMERID' => $objCustomer->getId(), 'SHOP_COMPANY' => $objCustomer->company(), 'SHOP_FIRSTNAME' => $objCustomer->firstname(), 'SHOP_LASTNAME' => $objCustomer->lastname(), 'SHOP_ADDRESS' => $objCustomer->address(), 'SHOP_ZIP' => $objCustomer->zip(), 'SHOP_CITY' => $objCustomer->city(), 'SHOP_PHONE' => $objCustomer->phone(), 'SHOP_EMAIL' => $objCustomer->email(), 'SHOP_CUSTOMER_STATUS_IMAGE' => $objCustomer->active() ? 'led_green.gif' : 'led_red.gif', 'SHOP_CUSTOMER_ACTIVE' => $objCustomer->active() ? $_ARRAYLANG['TXT_ACTIVE'] : $_ARRAYLANG['TXT_INACTIVE'])); self::$objTemplate->parse('shop_customer'); $objCustomer->next(); } // if ($count == 0) self::$objTemplate->hideBlock('shop_customers'); $paging = \Paging::get($uri_sorting, $_ARRAYLANG['TXT_CUSTOMERS_ENTRIES'], $count, $limit, true); self::$objTemplate->setVariable(array('SHOP_CUSTOMER_PAGING' => $paging, 'SHOP_CUSTOMER_TERM' => htmlentities($searchterm), 'SHOP_LISTLETTER_LINKS' => Orders::getListletterLinks($listletter), 'SHOP_CUSTOMER_TYPE_MENUOPTIONS' => Customers::getTypeMenuoptions($customer_type, true), 'SHOP_CUSTOMER_STATUS_MENUOPTIONS' => Customers::getActiveMenuoptions($customer_active, true))); return true; }