Superbegood31 Posted July 10, 2014 Share Posted July 10, 2014 (edited) Bonjour, Je souhaiterai inclure l'adresse ip du visiteur dans la liste des paniers. Pour ce faire, j'ai inclus à la requête le champ ip_address avec un left_join de la table "connections". Jusqu'ici pas de problème, par contre je n'arrive pas à afficher l'adresse ip avec la fonction long2ip. Ma question : Comment inclure la fonction long2ip dans un fields_list ? 'ip_address' => array( 'title' => $this->l('IP'), 'align' => 'text-right', 'filter_key' => 'coip!ip_address' ), Merci d'avance Edited July 10, 2014 by SWITCHBOARD (see edit history) Link to comment Share on other sites More sharing options...
Superbegood31 Posted July 10, 2014 Author Share Posted July 10, 2014 Pour ceux que ça intéresse, voici la solution (PS 1.6.0.8) : Dans AdminCartsController.php Rempacer $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, c.`company`, a.id_cart total, ca.name carrier, Par $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, c.`company`, a.id_cart total, ca.name carrier, coip.ip_address ip_address, Après LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(NOW(), co.`date_add`)) < 1800) Ajouter LEFT JOIN `'._DB_PREFIX_.'connections` coip ON (a.id_guest = coip.id_guest)'; Après 'id_guest' => array( 'title' => $this->l('Online'), 'align' => 'text-center', 'type' => 'bool', 'havingFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'tab-customers.gif') ), Ajouter 'ip_address' => array( 'title' => $this->l('IP'), 'align' => 'text-right', 'callback' => 'getip', 'filter_key' => 'coip!ip_address' ), Ajouter avant la dernière accolade public static function getip($echo, $tr) { $id_customer = $tr['ip_address']; $customer = new Customer($id_customer); return long2ip($id_customer); } Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 Pour ceux que ça intéresse, voici la solution (PS 1.6.0.8) : Dans AdminCartsController.php Rempacer $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, c.`company`, a.id_cart total, ca.name carrier, Par $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, c.`company`, a.id_cart total, ca.name carrier, coip.ip_address ip_address, Après LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(NOW(), co.`date_add`)) < 1800) Ajouter LEFT JOIN `'._DB_PREFIX_.'connections` coip ON (a.id_guest = coip.id_guest)'; Après 'id_guest' => array( 'title' => $this->l('Online'), 'align' => 'text-center', 'type' => 'bool', 'havingFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'tab-customers.gif') ), Ajouter 'ip_address' => array( 'title' => $this->l('IP'), 'align' => 'text-right', 'callback' => 'getip', 'filter_key' => 'coip!ip_address' ), Ajouter avant la dernière accolade public static function getip($echo, $tr) { $id_customer = $tr['ip_address']; $customer = new Customer($id_customer); return long2ip($id_customer); } Bonjour avez vous la même solution pour 16.06?.Merci Link to comment Share on other sites More sharing options...
Superbegood31 Posted July 11, 2014 Author Share Posted July 11, 2014 Bonjour, Cela doit être identique Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 Bonjour, Cela doit être identique Non le code et un peut diffèrent sur 16.06 : $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, IFNULL(o.id_order, \''.$this->l('Non ordered').'\') id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest'; est ce la même chose , ou mètre la première modif. Merci Link to comment Share on other sites More sharing options...
Superbegood31 Posted July 11, 2014 Author Share Posted July 11, 2014 En fait il s'agit du retour à la ligne... Après ca.name carrier, Ajouter coip.ip_address ip_address, Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 En fait il s'agit du retour à la ligne... Après ca.name carrier, Ajouter coip.ip_address ip_address, donc le code ressemble à cela: $this->_select = 'CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) `customer`, a.id_cart total, ca.name carrier,coip.ip_address ip_address, IFNULL(o.id_order, \''.$this->l('Non ordered').'\') id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest'; merci Link to comment Share on other sites More sharing options...
Superbegood31 Posted July 11, 2014 Author Share Posted July 11, 2014 Avec plaisir Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 Avec plaisir Encore une petite question , ou installez vous la dernière modif: // For compatibility reasons, we have to check standard actions in class attributes foreach ($this->actions_available as $action) { if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action) $this->actions[] = $action; } $helper->is_cms = $this->is_cms; $skip_list = array(); foreach ($this->_list as $row) if (isset($row['id_order']) && is_numeric($row['id_order'])) $skip_list[] = $row['id_cart']; if (array_key_exists('delete', $helper->list_skip_actions)) $helper->list_skip_actions['delete'] = array_merge($helper->list_skip_actions['delete'], (array)$skip_list); else $helper->list_skip_actions['delete'] = (array)$skip_list; $list = $helper->generateList($this->_list, $this->fields_list); return $list; } } Merci de votre réponse Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 super j'ai trouvé et cela fonctionne. Merci beaucoup. Link to comment Share on other sites More sharing options...
Superbegood31 Posted July 11, 2014 Author Share Posted July 11, 2014 j'étais en train de répondre... Pas assez rapide... Link to comment Share on other sites More sharing options...
houin Posted July 11, 2014 Share Posted July 11, 2014 j'étais en train de répondre... Pas assez rapide... merci beaucoup pour vos réponse Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now