in renderlist
$helper_list->actions = array('viewCustomer');
public function displayViewCustomerLink($token = null, $id, $name = null) { $this->smarty->assign(array( 'href' => 'index.php?controller=AdminCustomers&id_customer='.(int)$id.'&updatecustomer&token='.Tools::getAdminTokenLite('AdminCustomers'), 'action' => $this->l('View'), 'disable' => !((int)$id > 0), )); return $this->display(__FILE__, 'views/templates/admin/list_action_viewcustomer.tpl'); }
then make a tpl - list_action_viewcustomer.
-------------------------------------------------------------
example
public function renderList() { $fields_list = array( 'id' => array( 'title' => $this->l('ID'), 'search' => false, ), 'shop_name' => array( 'title' => $this->l('Shop'), 'search' => false, ), 'gender' => array( 'title' => $this->l('Gender'), 'search' => false, ), 'lastname' => array( 'title' => $this->l('Lastname'), 'search' => false, ), 'firstname' => array( 'title' => $this->l('Firstname'), 'search' => false, ), 'email' => array( 'title' => $this->l('Email'), 'search' => false, ), 'subscribed' => array( 'title' => $this->l('Subscribed'), 'type' => 'bool', 'active' => 'subscribed', 'search' => false, ), 'newsletter_date_add' => array( 'title' => $this->l('Subscribed on'), 'type' => 'date', 'search' => false, ) ); if (!Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE')) unset($fields_list['shop_name']); $helper_list = New HelperList(); $helper_list->module = $this; $helper_list->title = $this->l('Newsletter registrations'); $helper_list->shopLinkType = ''; $helper_list->no_link = true; $helper_list->show_toolbar = true; $helper_list->simple_header = false; $helper_list->identifier = 'id'; $helper_list->table = 'merged'; $helper_list->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name; $helper_list->token = Tools::getAdminTokenLite('AdminModules'); $helper_list->actions = array('viewCustomer'); $helper_list->toolbar_btn['export'] = array( 'href' => $helper_list->currentIndex.'&exportSubscribers&token='.$helper_list->token, 'desc' => $this->l('Export') ); /* Before 1.6.0.7 displayEnableLink() could not be overridden in Module class we declare another row action instead */ if (version_compare(_PS_VERSION_, '1.6.0.7', '<')) { unset($fields_list['subscribed']); $helper_list->actions = array_merge($helper_list->actions, array('unsubscribe')); } // This is needed for displayEnableLink to avoid code duplication $this->_helperlist = $helper_list; /* Retrieve list data */ $subscribers = $this->getSubscribers(); $helper_list->listTotal = count($subscribers); /* Paginate the result */ $page = ($page = Tools::getValue('submitFilter'.$helper_list->table)) ? $page : 1; $pagination = ($pagination = Tools::getValue($helper_list->table.'_pagination')) ? $pagination : 50; $subscribers = $this->paginateSubscribers($subscribers, $page, $pagination); return $helper_list->generateList($subscribers, $fields_list); }
public function displayUnsubscribeLink($token = null, $id, $name = null) { $this->smarty->assign(array( 'href' => Tools::safeOutput($this->_helperlist->currentIndex.'&subscribedcustomer&'.$this->_helperlist->identifier.'='.$id.'&token='.$token), 'action' => $this->l('Unsubscribe'), )); return $this->display(__FILE__, 'views/templates/admin/list_action_unsubscribe.tpl'); }
public function getSubscribers() { $dbquery = new DbQuery(); $dbquery->select('c.`id_customer` AS `id`, s.`name` AS `shop_name`, gl.`name` AS `gender`, c.`lastname`, c.`firstname`, c.`email`, c.`newsletter` AS `subscribed`, c.`newsletter_date_add`'); $dbquery->from('customer', 'c'); $dbquery->leftJoin('shop', 's', 's.id_shop = c.id_shop'); $dbquery->leftJoin('gender', 'g', 'g.id_gender = c.id_gender'); $dbquery->leftJoin('gender_lang', 'gl', 'g.id_gender = gl.id_gender AND gl.id_lang = '.$this->context->employee->id_lang); $dbquery->where('c.`newsletter` = 1'); if ($this->_searched_email) $dbquery->where('c.`email` LIKE \'%'.bqSQL($this->_searched_email).'%\' '); $customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($dbquery->build()); $dbquery = new DbQuery(); $dbquery->select('CONCAT(\'N\', n.`id`) AS `id`, s.`name` AS `shop_name`, NULL AS `gender`, NULL AS `lastname`, NULL AS `firstname`, n.`email`, n.`active` AS `subscribed`, n.`newsletter_date_add`'); $dbquery->from('newsletter', 'n'); $dbquery->leftJoin('shop', 's', 's.id_shop = n.id_shop'); $dbquery->where('n.`active` = 1'); if ($this->_searched_email) $dbquery->where('n.`email` LIKE \'%'.bqSQL($this->_searched_email).'%\' '); $non_customers = Db::getInstance()->executeS($dbquery->build()); $subscribers = array_merge($customers, $non_customers); return $subscribers; }
public function paginateSubscribers($subscribers, $page = 1, $pagination = 50) { if(count($subscribers) > $pagination) $subscribers = array_slice($subscribers, $pagination * ($page - 1), $pagination); return $subscribers; }
------------------------------------------------------------------------------------------
another eg public function renderList() { $current_index = AdminController::$currentIndex; $token = Tools::getAdminTokenLite('AdminModules'); $list = DB::getInstance()->executeS("\n SELECT * FROM `" . _DB_PREFIX_ . "mycarrier_rule`\n "); $fields_list = array('id_rule' => array('title' => $this->l('Id'), 'width' => 20, 'type' => 'text'), 'name' => array('title' => $this->l('Name'), 'width' => 'auto', 'type' => 'text'), 'is_msk' => array('title' => $this->l('Moskow region'), 'width' => 80, 'type' => 'bool', 'active' => 'status'), 'price' => array('title' => $this->l('Price'), 'width' => 80, 'type' => 'price')); $helper = new HelperList(); $helper->module = $this; $helper->shopLinkType = ''; $helper->simple_header = true; $helper->actions = array('edit', 'delete'); $helper->identifier = 'id_rule'; $helper->show_toolbar = true; $helper->title = 'helper list'; $helper->table = '_rule'; $helper->token = $token; $helper->currentIndex = $current_index . '&configure=' . $this->name; $helper->toolbar_btn = array('new' => array('href' => $current_index . '&configure=' . $this->name . '&token=' . $token . '&addBlockCMS', 'desc' => $this->l('Add new'))); $this->_html .= $helper->generateList($list, $fields_list); } |
|
|
Comments
Post a Comment