public function renderView() { $this->tpl_view_vars['query'] = Tools::safeOutput($this->query); $this->tpl_view_vars['show_toolbar'] = true; if (count($this->errors)) { return parent::renderView(); } else { $nb_results = 0; foreach ($this->_list as $list) { if ($list != false) { $nb_results += count($list); } } $this->tpl_view_vars['nb_results'] = $nb_results; if (isset($this->_list['features']) && count($this->_list['features'])) { $this->tpl_view_vars['features'] = $this->_list['features']; } if (isset($this->_list['categories']) && count($this->_list['categories'])) { $categories = array(); foreach ($this->_list['categories'] as $category) { $categories[] = getPath($this->context->link->getAdminLink('AdminCategories', false), $category['id_category']); } $this->tpl_view_vars['categories'] = $categories; } if (isset($this->_list['products']) && count($this->_list['products'])) { $view = ''; $this->initProductList(); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; $helper->identifier = 'id_product'; $helper->actions = array('edit'); $helper->show_toolbar = false; $helper->table = 'product'; $helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false); $helper->token = Tools::getAdminTokenLite('AdminProducts'); if ($this->_list['products']) { $view = $helper->generateList($this->_list['products'], $this->fields_list['products']); } $this->tpl_view_vars['products'] = $view; } if (isset($this->_list['customers']) && count($this->_list['customers'])) { $view = ''; $this->initCustomerList(); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; $helper->identifier = 'id_customer'; $helper->actions = array('edit', 'view'); $helper->show_toolbar = false; $helper->table = 'customer'; $helper->currentIndex = $this->context->link->getAdminLink('AdminCustomers', false); $helper->token = Tools::getAdminTokenLite('AdminCustomers'); if ($this->_list['customers']) { foreach ($this->_list['customers'] as $key => $val) { $this->_list['customers'][$key]['orders'] = Order::getCustomerNbOrders((int) $val['id_customer']); } $view = $helper->generateList($this->_list['customers'], $this->fields_list['customers']); } $this->tpl_view_vars['customers'] = $view; } if (isset($this->_list['orders']) && count($this->_list['orders'])) { $view = ''; $this->initOrderList(); $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; $helper->identifier = 'id_order'; $helper->actions = array('view'); $helper->show_toolbar = false; $helper->table = 'order'; $helper->currentIndex = $this->context->link->getAdminLink('AdminOrders', false); $helper->token = Tools::getAdminTokenLite('AdminOrders'); if ($this->_list['orders']) { $view = $helper->generateList($this->_list['orders'], $this->fields_list['orders']); } $this->tpl_view_vars['orders'] = $view; } if (isset($this->_list['modules']) && count($this->_list['modules'])) { $this->tpl_view_vars['modules'] = $this->_list['modules']; } if (isset($this->_list['addons']) && count($this->_list['addons'])) { $this->tpl_view_vars['addons'] = $this->_list['addons']; } return parent::renderView(); } }
public function viewgroup() { global $cookie; $currentIndex = 'index.php?tab=AdminGroups'; $obj = $this->loadObject(true); $group = new Group(intval($obj->id)); $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); echo ' <fieldset style="width: 400px"> <div style="float: right"><a href="' . $currentIndex . '&updategroup&id_group=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a></div> <span style="font-weight: bold; font-size: 14px;">' . strval($obj->name[intval($cookie->id_lang)]) . '</span> <div class="clear"> </div> ' . $this->l('Reduction:') . ' ' . floatval($obj->reduction) . $this->l('%') . ' </fieldset> <div class="clear"> </div>'; $customers = $obj->getCustomers(); $this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'sex' => array('title' => $this->l('Sex')), 'name' => array('title' => $this->l('Name')), 'e-mail' => array('title' => $this->l('e-mail')), 'birthdate' => array('title' => $this->l('Birth date')), 'register_date' => array('title' => $this->l('Register date')), 'orders' => array('title' => $this->l('Orders')), 'status' => array('title' => $this->l('Status')), 'actions' => array('title' => $this->l('Actions'))); if (isset($customers) and !empty($customers) and $nbCustomers = sizeof($customers)) { echo '<h2>' . $this->l('Customers member of this group') . ' (' . $nbCustomers . ')</h2> <table cellspacing="0" cellpadding="0" class="table widthfull"> <tr>'; foreach ($this->fieldsDisplay as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo ' </tr>'; $irow = 0; foreach ($customers as $k => $customer) { $imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="' . $this->l('Male') . '" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="' . $this->l('Female') . '" />' : ''); echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . $customer['id_customer'] . '</td> <td class="center">' . $imgGender . '</td> <td>' . stripslashes($customer['lastname']) . ' ' . stripslashes($customer['firstname']) . '</td> <td>' . stripslashes($customer['email']) . '<a href="mailto:' . stripslashes($customer['email']) . '"> <img src="../img/admin/email_edit.gif" alt="' . $this->l('Write to this customer') . '" /></a></td> <td>' . Tools::displayDate($customer['birthday'], intval($cookie->id_lang)) . '</td> <td>' . Tools::displayDate($customer['date_add'], intval($cookie->id_lang)) . '</td> <td>' . Order::getCustomerNbOrders($customer['id_customer']) . '</td> <td class="center"><img src="../img/admin/' . ($customer['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></td> <td class="center" width="60px"> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/details.gif" alt="' . $this->l('View orders') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&addcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this customer') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&deletecustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this customer') . '" /></a> </td> </tr>'; } echo '</table>'; } }
public function display() { global $cookie; $currentIndex = 'index.php'; $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $query = trim(Tools::getValue('bo_query')); $nbCategories = $nbProducts = $nbCustomers = 0; /* Display categories if any has been matching */ if (isset($this->_list['categories']) and $nbCategories = sizeof($this->_list['categories'])) { echo '<h3>' . $nbCategories . ' ' . ($nbCategories > 1 ? $this->l('categories found with') : $this->l('category found with')) . ' <b>"' . Tools::htmlentitiesUTF8($query) . '"</b></h3>'; echo '<table cellspacing="0" cellpadding="0" class="table">'; $irow = 0; foreach ($this->_list['categories'] as $k => $category) { echo '<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"><td>' . rtrim(getPath($currentIndex . '?tab=AdminCatalog', $category['id_category'], '', $query), ' >') . '</td></tr>'; } echo '</table> <div class="clear"> </div>'; } /* Display products if any has been matching */ if (isset($this->_list['products']) and !empty($this->_list['products']) and $nbProducts = sizeof($this->_list['products'])) { echo '<h3>' . $nbProducts . ' ' . ($nbProducts > 1 ? $this->l('products found with') : $this->l('product found with')) . ' <b>"' . Tools::htmlentitiesUTF8($query) . '"</b></h3> <table class="table" cellpadding="0" cellspacing="0"> <tr>'; foreach ($this->fieldsDisplay['catalog'] as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo '</tr>'; foreach ($this->_list['products'] as $k => $product) { echo ' <tr> <td>' . $product['id_product'] . '</td> <td align="center">' . ($product['manufacturer_name'] != NULL ? stripslashes($product['manufacturer_name']) : '--') . '</td> <td>' . $product['reference'] . '</td> <td><a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '">' . stripslashes($product['nameh']) . '</a></td> <td>' . Tools::displayPrice($product['price'], $currency) . '</td> <td>' . stripslashes($product['tax_name']) . '</td> <td align="center">' . $product['quantity'] . '</td> <td align="center">' . $product['weight'] . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td align="center"><a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&status&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '"> <img src="../img/admin/' . ($product['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></a></td> <td> <a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this product') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Do you want to delete this product?', __CLASS__, true, false) . ' (' . addslashes($product['name']) . ')\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" /></a> </td> </tr>'; } echo '</table> <div class="clear"> </div>'; } /* Display customers if any has been matching */ if (isset($this->_list['customers']) and !empty($this->_list['customers']) and $nbCustomers = sizeof($this->_list['customers'])) { echo '<h3>' . $nbCustomers . ' ' . ($nbCustomers > 1 ? $this->l('customers') : $this->l('customer')) . ' ' . $this->l('found with') . ' <b>"' . Tools::htmlentitiesUTF8($query) . '"</b></h3> <table cellspacing="0" cellpadding="0" class="table widthfull"> <tr>'; foreach ($this->fieldsDisplay['customers'] as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo '</tr>'; $irow = 0; foreach ($this->_list['customers'] as $k => $customer) { $imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="' . $this->l('Male') . '" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="' . $this->l('Female') . '" />' : ''); echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . $customer['id_customer'] . '</td> <td class="center">' . $imgGender . '</td> <td>' . stripslashes($customer['lastname']) . ' ' . stripslashes($customer['firstname']) . '</td> <td>' . stripslashes($customer['email']) . '<a href="mailto:' . stripslashes($customer['email']) . '"> <img src="../img/admin/email_edit.gif" alt="' . $this->l('Write to this customer') . '" /></a></td> <td>' . Tools::displayDate($customer['birthday'], (int) $cookie->id_lang) . '</td> <td>' . Tools::displayDate($customer['date_add'], (int) $cookie->id_lang) . '</td> <td>' . Order::getCustomerNbOrders($customer['id_customer']) . '</td> <td class="center"><img src="../img/admin/' . ($customer['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></td> <td class="center" width="60px"> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/details.gif" alt="' . $this->l('View orders') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&addcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this customer') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&deletecustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this customer') . '" /></a> </td> </tr>'; } echo '</table> <div class="clear"> </div>'; } /* Display error if nothing has been matching */ if (!$nbCategories and !$nbProducts and !$nbCustomers) { echo '<h3>' . $this->l('Nothing found for') . ' "' . Tools::htmlentitiesUTF8($query) . '"</h3>'; } }
public function viewgroup() { global $cookie; $currentIndex = 'index.php?tab=AdminGroups'; if (!($obj = $this->loadObject(true))) { return; } $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); echo ' <fieldset style="width: 400px"> <div style="float: right"><a href="' . $currentIndex . '&updategroup&id_group=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a></div> <span style="font-weight: bold; font-size: 14px;">' . strval($obj->name[(int) $cookie->id_lang]) . '</span> <div class="clear"> </div> ' . $this->l('Discount:') . ' ' . (double) $obj->reduction . $this->l('%') . ' </fieldset> <div class="clear"> </div>'; $this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'sex' => array('title' => $this->l('Sex')), 'name' => array('title' => $this->l('Name')), 'e-mail' => array('title' => $this->l('e-mail')), 'birthdate' => array('title' => $this->l('Birth date')), 'register_date' => array('title' => $this->l('Registration date')), 'orders' => array('title' => $this->l('Orders')), 'status' => array('title' => $this->l('Status')), 'actions' => array('title' => $this->l('Actions'))); if ($nbCustomers = $obj->getCustomers(true)) { echo '<h2>' . $this->l('Customer members of this group') . ' (' . $nbCustomers . ')</h2>'; // Pagination Begin $customersPerPage = Tools::getValue('customerPerPage') ? (int) Tools::getValue('customerPerPage') : 50; $totalPages = ceil($nbCustomers / $customersPerPage); $perPageOptions = array(20, 50, 100, 300); $customerPageIndex = Tools::getValue('customerPageIndex') && Tools::getValue('customerPageIndex') <= $totalPages ? (int) Tools::getValue('customerPageIndex') : 1; $from = Tools::getValue('customerPageIndex') ? ((int) $customerPageIndex - 1) * (int) $customersPerPage : 0; $customers = $obj->getCustomers(false, $from, $customersPerPage); echo '<table><tr> <form method="post" action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '"> <td style="vertical-align: bottom;"><span style="float: left; height:30px">'; if ($customerPageIndex > 1) { echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=1" src="../img/admin/list-prev2.gif"> '; echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . ($customerPageIndex - 1) . '" src="../img/admin/list-prev.gif"> '; } echo 'Page <b><select onChange="submit()" name="customerPageIndex" id="customerPageIndex">'; for ($i = 1; $i <= $totalPages; $i++) { echo '<option value="' . $i . '"' . ((int) $customerPageIndex === $i ? 'selected="selected"' : '') . '>' . $i . '</option>'; } echo '</select></b> / ' . $totalPages; if ($customerPageIndex < $totalPages) { echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . ((int) $customerPageIndex + 1) . '" src="../img/admin/list-next.gif">'; echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . $totalPages . '" src="../img/admin/list-next2.gif">'; } echo ' | Display <select onchange="document.getElementById(\'customerPageIndex\').value=1; submit();" name="customerPerPage">'; foreach ($perPageOptions as $option) { echo '<option value="' . $option . '"' . ((int) $customersPerPage == $option ? 'selected="selected"' : '') . '>' . $option . '</option>'; } echo ' </select> / ' . $nbCustomers . ' result(s) </span><span class="clear"></span></td> </form> </tr> </table> <div class="clear"></div>'; // Pagination End echo '<table cellspacing="0" cellpadding="0" class="table widthfull"> <tr>'; foreach ($this->fieldsDisplay as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo ' </tr>'; $irow = 0; foreach ($customers as $k => $customer) { $imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="' . $this->l('Male') . '" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="' . $this->l('Female') . '" />' : ''); echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . $customer['id_customer'] . '</td> <td class="center">' . $imgGender . '</td> <td>' . stripslashes($customer['lastname']) . ' ' . stripslashes($customer['firstname']) . '</td> <td>' . stripslashes($customer['email']) . '<a href="mailto:' . stripslashes($customer['email']) . '"> <img src="../img/admin/email_edit.gif" alt="' . $this->l('Write to this customer') . '" /></a></td> <td>' . Tools::displayDate($customer['birthday'], (int) $cookie->id_lang) . '</td> <td>' . Tools::displayDate($customer['date_add'], (int) $cookie->id_lang) . '</td> <td>' . Order::getCustomerNbOrders($customer['id_customer']) . '</td> <td class="center"><img src="../img/admin/' . ($customer['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></td> <td class="center" width="60px"> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/details.gif" alt="' . $this->l('View orders') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&addcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this customer') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&deletecustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this customer') . '" /></a> </td> </tr>'; } echo '</table>'; } else { echo '<p><img src="../img/admin/information.png" style="float:left;margin-right:5px;" alt="" /> ' . $this->l('No user in this group.') . '</p>'; } }
public function viewgroup() { global $cookie; global $smarty; $currentIndex = 'index.php?tab=AdminGroups'; if (!($obj = $this->loadObject(true))) { return; } $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); echo ' <fieldset style="width: 400px"> <div style="float: right"><a href="' . $currentIndex . '&updategroup&id_group=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/edit.gif" /></a></div> <span style="font-weight: bold; font-size: 14px;">' . strval($obj->name[(int) $cookie->id_lang]) . '</span> <div class="clear"> </div> ' . $this->l('Discount:') . ' ' . (double) $obj->reduction . $this->l('%') . ' </fieldset> <div class="clear"> </div>'; $id_group1 = $_GET['id_group']; echo ' <div style="margin:20 auto;"> <fieldset style="margin-bottom:10px;"> <legend><img src="../img/admin/tab-tools.gif" />Set FREE SHIP</legend> <form enctype="multipart/form-data" action=" " method="post" id="productImport" style="display:width:520px;margin-left:200px"> <input type="hidden" name="setFreeShip" value="1" /> Select Customer file: <input name="free_ship_file" type="file" /><br /> <input type="submit" value="Upload" /> </form> </fieldset> </div>'; if (!empty($_FILES)) { $target_path = _PS_ADMIN_DIR_ . "/product-uploads/"; $target_path = $target_path . basename($_FILES['free_ship_file']['name']); if (move_uploaded_file($_FILES['free_ship_file']['tmp_name'], $target_path)) { $f = fopen($target_path, 'r'); //read header to get the search strings $line = fgetcsv($f); $lines = array(); while ($line = fgetcsv($f)) { $lines[] = $line; } $updatedCustomerIds = array(); foreach ($lines as $line) { $customerEmail = $line[0]; $sql = "select cus.id_customer , cusg.id_group from ps_customer cus left join ps_customer_group cusg on (cusg.id_customer = cus.id_customer) where cus.email = '" . $customerEmail . "'"; $result = Db::getInstance()->ExecuteS($sql); $customerId = null; $groups = array(); foreach ($result as $k => $row) { if (!empty($row['id_group'])) { array_push($groups, $row['id_group']); } $customerId = $row['id_customer']; } if (!in_array($id_group1, $groups)) { $sql = "insert into ps_customer_group values ({$customerId} , {$id_group1})"; $result = Db::getInstance()->ExecuteS($sql); array_push($updatedCustomerIds, $customerId); } } $smarty->assign('updated_rows', count($customerId)); } } $this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'sex' => array('title' => $this->l('Sex')), 'name' => array('title' => $this->l('Name')), 'e-mail' => array('title' => $this->l('e-mail')), 'birthdate' => array('title' => $this->l('Birth date')), 'register_date' => array('title' => $this->l('Registration date')), 'orders' => array('title' => $this->l('Orders')), 'status' => array('title' => $this->l('Status')), 'actions' => array('title' => $this->l('Actions'))); if ($nbCustomers = $obj->getCustomers(true)) { echo '<h2>' . $this->l('Customer members of this group') . ' (' . $nbCustomers . ')</h2>'; // Pagination Begin $customersPerPage = Tools::getValue('customerPerPage') ? (int) Tools::getValue('customerPerPage') : 50; $totalPages = ceil($nbCustomers / $customersPerPage); $perPageOptions = array(20, 50, 100, 300); $customerPageIndex = Tools::getValue('customerPageIndex') && Tools::getValue('customerPageIndex') <= $totalPages ? (int) Tools::getValue('customerPageIndex') : 1; $from = Tools::getValue('customerPageIndex') ? ((int) $customerPageIndex - 1) * (int) $customersPerPage : 0; $customers = $obj->getCustomers(false, $from, $customersPerPage); echo '<tr> <form method="post" action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '"> <td style="vertical-align: bottom;"><span style="float: left; height:30px">'; if ($customerPageIndex > 1) { echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=1" src="../img/admin/list-prev2.gif"> '; echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . ($customerPageIndex - 1) . '" src="../img/admin/list-prev.gif"> '; } echo 'Page <b><select onChange="submit()" name="customerPageIndex" id="customerPageIndex">'; for ($i = 1; $i <= $totalPages; $i++) { echo '<option value="' . $i . '"' . ((int) $customerPageIndex === $i ? 'selected="selected"' : '') . '>' . $i . '</option>'; } echo '</select></b> / ' . $totalPages; if ($customerPageIndex < $totalPages) { echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . ((int) $customerPageIndex + 1) . '" src="../img/admin/list-next.gif">'; echo ' <input type="image" onclick="document.getElementById(\'customerPageIndex\').value=' . $totalPages . '" src="../img/admin/list-next2.gif">'; } echo ' | Display <select onchange="document.getElementById(\'customerPageIndex\').value=1; submit();" name="customerPerPage">'; foreach ($perPageOptions as $option) { echo '<option value="' . $option . '"' . ((int) $customersPerPage == $option ? 'selected="selected"' : '') . '>' . $option . '</option>'; } echo ' </select> / ' . $nbCustomers . ' result(s) </span><span class="clear"></span></td> </form> </tr>'; // Pagination End echo '<table cellspacing="0" cellpadding="0" class="table widthfull"> <tr>'; foreach ($this->fieldsDisplay as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo ' </tr>'; $irow = 0; foreach ($customers as $k => $customer) { $imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="' . $this->l('Male') . '" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="' . $this->l('Female') . '" />' : ''); echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . $customer['id_customer'] . '</td> <td class="center">' . $imgGender . '</td> <td>' . stripslashes($customer['lastname']) . ' ' . stripslashes($customer['firstname']) . '</td> <td>' . stripslashes($customer['email']) . '<a href="mailto:' . stripslashes($customer['email']) . '"> <img src="../img/admin/email_edit.gif" alt="' . $this->l('Write to this customer') . '" /></a></td> <td>' . Tools::displayDate($customer['birthday'], (int) $cookie->id_lang) . '</td> <td>' . Tools::displayDate($customer['date_add'], (int) $cookie->id_lang) . '</td> <td>' . Order::getCustomerNbOrders($customer['id_customer']) . '</td> <td class="center"><img src="../img/admin/' . ($customer['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></td> <td class="center" width="60px"> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/details.gif" alt="' . $this->l('View orders') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&addcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this customer') . '" /></a> <a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&deletecustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this customer') . '" /></a> </td> </tr>'; } echo '</table>'; } else { echo '<p><img src="../img/admin/information.png" style="float:left;margin-right:5px;" alt="" /> ' . $this->l('No user in this group.') . '</p>'; } }
public function display() { global $cookie; $currentIndex = 'index.php'; $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $query = isset($_POST['bo_query']) ? trim(strval($_POST['bo_query'])) : ''; /* Display categories if any has been matching */ if (isset($this->_list['categories']) and $nbCategories = sizeof($this->_list['categories'])) { echo '<h3>' . $nbCategories . ' ' . ($nbCategories > 1 ? $this->l('categories found with') : $this->l('category found with')) . ' <b>"' . $query . '"</b></h3>'; echo ' <table cellspacing="0" cellpadding="0" class="table">'; $irow = 0; foreach ($this->_list['categories'] as $k => $category) { echo '<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"><td>' . rtrim(getPath($currentIndex . '?tab=AdminCatalog', $category['id_category'], '', $query), ' >') . '</td></tr>'; } echo '</table><br /><br />'; } else { $nbCategories = 0; } /* Display products if any has been matching */ if (isset($this->_list['products']) and !empty($this->_list['products']) and $nbProducts = sizeof($this->_list['products'])) { echo '<h3>' . $nbProducts . ' ' . ($nbProducts > 1 ? $this->l('products found with') : $this->l('product found with')) . ' <b>"' . $query . '"</b></h3> <table class="table" cellpadding="0" cellspacing="0"> <tr>'; foreach ($this->fieldsDisplay as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo ' </tr>'; foreach ($this->_list['products'] as $k => $product) { echo ' <tr> <td>' . $product['id_product'] . '</td> <td align="center">' . ($product['manufacturer_name'] != NULL ? stripslashes($product['manufacturer_name']) : '--') . '</td> <td>' . $product['reference'] . '</td> <td><a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '">' . stripslashes($product['nameh']) . '</a></td> <td>' . Tools::displayPrice($product['price'], $currency) . '</td> <td>' . stripslashes($product['tax_name']) . '</td> <td align="center">' . $product['quantity'] . '</td> <td align="center">' . $product['weight'] . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td align="center"><a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&status&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/' . ($product['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></a></td> <td> <a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this product') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCatalog&id_product=' . $product['id_product'] . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Do you want to delete', __CLASS__, true, false) . ' ' . addslashes($product['name']) . $this->l('?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" /></a> </td> </tr>'; } echo '</table>'; } else { $nbProducts = 0; } /* Display customers if any has been matching */ if (isset($this->_list['customers']) and !empty($this->_list['customers']) and $nbCustomers = sizeof($this->_list['customers'])) { echo '<h3>' . $nbCustomers . ' ' . ($nbCustomers > 1 ? $this->l('customers') : $this->l('customer')) . ' ' . $this->l('found with') . ' <b>"' . $query . '"</b></h3> <table cellspacing="0" cellpadding="0" class="table widthfull"> <tr>'; foreach ($this->fieldsDisplay as $field) { echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>'; } echo ' </tr>'; $irow = 0; foreach ($this->_list['customers'] as $k => $customer) { $imgGender = $customer['id_gender'] == 1 ? '<img src="../img/admin/male.gif" alt="' . $this->l('Male') . '" />' : ($customer['id_gender'] == 2 ? '<img src="../img/admin/female.gif" alt="' . $this->l('Female') . '" />' : ''); echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . $customer['id_customer'] . '</td> <td class="center">' . $imgGender . '</td> <td>' . stripslashes($customer['lastname']) . ' ' . stripslashes($customer['firstname']) . '</td> <td>' . stripslashes($customer['email']) . '<a href="mailto:' . stripslashes($customer['email']) . '"> <img src="../img/admin/email_edit.gif" alt="' . $this->l('Write to this customer') . '" /></a></td> <td>' . Tools::displayDate($customer['birthday'], intval($cookie->id_lang)) . '</td> <td>' . Tools::displayDate($customer['date_add'], intval($cookie->id_lang)) . '</td> <td>' . Order::getCustomerNbOrders($customer['id_customer']) . '</td> <td class="center"><img src="../img/admin/' . ($customer['active'] ? 'enabled.gif' : 'forbbiden.gif') . '" alt="" /></td> <td class="center" width="60px"> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/details.gif" alt="' . $this->l('View orders') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&addcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this customer') . '" /></a> <a href="' . $currentIndex . '?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&deletecustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this customer') . '" /></a> </td> </tr>'; } echo '</table>'; } else { $nbCustomers = 0; } if (isset($this->_list['cart'])) { $cart = $this->_list['cart']; $products = $cart->getProducts(); $discounts = $cart->getDiscounts(); $total_discounts = $cart->getOrderTotal(false, 2); $total_shipping = $cart->getOrderShippingCost($cart->id_carrier); $total_wrapping = $cart->getOrderTotal(true, 6); $total_products = $cart->getOrderTotal(true, 1); $total_price = $cart->getOrderTotal(); echo '<h2>' . $this->l('Cart found:') . ' (#' . sprintf('%08d', $cart->id) . ')</h2> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th width="75" align="center">' . $this->l('Reference') . '</th> <th>Product</th> <th width="55" align="center">' . $this->l('Quantity') . '</th> <th width="88" align="right">' . $this->l('Unit price') . '</th> <th width="80" align="right">' . $this->l('Total price') . '</th> </tr>'; if ($products) { foreach ($products as $product) { echo ' <tr> <td>' . $product['reference'] . '</td> <td>' . $product['name'] . '</a></td> <td align="right">' . $product['quantity'] . '</td> <td align="right">' . Tools::displayPrice($product['price'], $currency) . '</td> <td align="right">' . Tools::displayPrice($product['total_wt'], $currency) . '</td> </tr>'; } } if ($discounts) { foreach ($discounts as $discount) { echo ' <tr> <td>' . $discount['name'] . '</td> <td>' . $discount['description'] . '</td> <td align="right">1</td> <td align="right">-' . Tools::displayPrice($discount['value'], $currency) . '</td> <td align="right">-' . Tools::displayPrice($discount['value'], $currency) . '</td> </tr>'; } } echo ' <tr style="text-align: right; font-weight: bold;"> <td colspan="4">' . $this->l('Products:') . ' </td> <td>' . Tools::displayPrice($total_products, $currency) . '</td> </tr> <tr style="text-align: right; font-weight: bold;"> <td colspan="4">' . $this->l('Vouchers') . ' </td> <td>' . Tools::displayPrice($total_discounts, $currency) . '</td> </tr> <tr style="text-align: right; font-weight: bold;"> <td colspan="4">' . $this->l('Gift-wrapping:') . ' </td> <td>' . Tools::displayPrice($total_wrapping, $currency) . '</td> </tr> <tr style="text-align: right; font-weight: bold;"> <td colspan="4">' . $this->l('Shipping:') . ' </td> <td>' . Tools::displayPrice($total_shipping, $currency) . '</td> </tr> <tr style="text-align: right; font-weight: bold;"> <td colspan="4">' . $this->l('Total:') . ' </td> <td>' . Tools::displayPrice($total_price, $currency) . '</td> </tr> </table>'; } /* Display error if nothing has been matching */ if (!$nbCategories and !$nbProducts and !$nbCustomers and !isset($this->_list['cart'])) { echo '<h3>' . $this->l('Nothing found') . '.</h3>'; } }