Rdev Posted November 13, 2012 Share Posted November 13, 2012 (edited) bonjour, je veux ajouté un filtre par code postal dans la liste des clients dans le BO sur le fichier AdminCustomers.php voir capture qui a une idée comment affiché le code postal Edited November 13, 2012 by R005 (see edit history) Link to comment Share on other sites More sharing options...
Rdev Posted November 13, 2012 Author Share Posted November 13, 2012 j'ai trouvé une solution il faut ajouter ce code à la fin du $this->_select , ( SELECT b.postcode FROM '._DB_PREFIX_.'address b WHERE b.id_customer = a.id_customer LIMIT 1 ) as postcode '; et ajouter ce code entre l'email et l'age 'postcode' => array('title' => $this->l('Postcode'), 'width' => 32), le code final est : $this->_select = '(YEAR(NOW()) - YEAR(birthday)) as age, ( SELECT c.date_add FROM '._DB_PREFIX_.'guest g LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest WHERE g.id_customer = a.id_customer ORDER BY c.date_add DESC LIMIT 1 ) as connect, ( SELECT b.postcodeFROM '._DB_PREFIX_.'address b WHERE b.id_customer = a.id_customer LIMIT 1 ) as postcode'; $genders = array(1 => $this->l('M'), 2 => $this->l('F'), 9 => $this->l('?')); $this->fieldsDisplay = array( 'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'id_gender' => array('title' => $this->l('Gender'), 'width' => 25, 'align' => 'center', 'icon' => array(1 => 'male.gif', 2 => 'female.gif', 'default' => 'unknown.gif'), 'orderby' => false, 'type' => 'select', 'select' => $genders, 'filter_key' => 'a!id_gender'), 'lastname' => array('title' => $this->l('Last Name'), 'width' => 80), 'firstname' => array('title' => $this->l('First name'), 'width' => 60), 'email' => array('title' => $this->l('E-mail address'), 'width' => 120, 'maxlength' => 19), 'postcode' => array('title' => $this->l('Postcode'), 'width' => 32), 'age' => array('title' => $this->l('Age'), 'width' => 30, 'search' => false), 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), 'newsletter' => array('title' => $this->l('News.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false), 'optin' => array('title' => $this->l('Opt.'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif'), 'orderby' => false), 'date_add' => array('title' => $this->l('Registration'), 'width' => 60, 'type' => 'date'), 'connect' => array('title' => $this->l('Connection'), 'width' => 60, 'type' => 'datetime', 'search' => false)); Link to comment Share on other sites More sharing options...
FredCD Posted September 23, 2013 Share Posted September 23, 2013 Bonjour radhia, Merci pour ce code, je m'en suis servi et il fonctionne très bien. J'aimerais l'améliorer pour rendre le champ "code postal" "cherchable". J'ai ajouté un 'search' => true mais quand j'envoie une recherche j'ai une erreur Mauvaise requête SQLUnknown column 'postcode' in 'where clause' Je comprends que le problème vient du fait que je fais un appel à un champ contenu dans une autre table que "customer" mais je ne vois pas trop comment déclarer la jointure ou expliquer à PS de chercher dans le champ postcode défini dans le controller. As tu une idée ? Link to comment Share on other sites More sharing options...
Rdev Posted September 27, 2013 Author Share Posted September 27, 2013 Bonjour FredCD, désolé maintenant je n'ai aucune idée mais je vais voir et puis je te réponds 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