Jump to content

tab in BO per mostrare tutti i dati dei clienti in una unica tabella


Mikie

Recommended Posts

Ciao
sto cercando di realizzare un nuovo tab che mi consenta di visualizzare in una unica tabella tutti (o i principali) dati dei clienti in una sola tabella, il passo suggessivo è aggiungere un link per salvare la tabella in excell.

Sono riuscito a creare un nuovo tab con gli strumenti in BO di presta e ho creato il relativo file php nella cartella tabs basandomi su AdminAddresses e AdminCustomers.

Il codice non è molto pulito, in particolare per la generazione della query, inoltre i record della tabella sono linkati e questo non mi serve.


include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php');

class AdminExcel extends AdminTab
{


   //** @var array countries list /
   private $countriesArray = array();

   //** @var array State list /
   private $stateList = array();

   public function __construct()
   {
        global $cookie;

        $this->table = 'address';
        $this->className = 'Address';
        $this->lang = false;
        $this->edit = false;
        $this->delete = false;
       $this->colorOnBackground = true;

       if (!Tools::getValue('realedit'))
           $this->deleted = false;

       $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON 
       (cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.intval($cookie->id_lang).')';

       $countries = Country::getCountries(intval($cookie->id_lang));
       foreach ($countries AS $country)
           $this->countriesArray[$country['id_country']] = $country['name'];
       $this->stateList = State::getStates(intval($cookie->id_lang))*/

       $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` ad ON 
       (ad.`id_customer` = a.`id_customer`)';*/

       $this->_select = 'email as ademail, piva as adpiva, cf as adcf, phone as adphone, cl.`name` as country';
       $this->_join = 'LEFT JOIN  ( `'._DB_PREFIX_.'country_lang` cl LEFT JOIN `'._DB_PREFIX_.'customer` ad ON 
       (ad.`id_customer` = `id_customer`)) ON 
       (cl.`id_country` = a.`id_country` AND cl.`id_lang` = '.intval($cookie->id_lang).')';
       $this->_group ='GROUP BY id_customer';

       $countries = Country::getCountries(intval($cookie->id_lang));
       foreach ($countries AS $country)
           $this->countriesArray[$country['id_country']] = $country['name'];
       $this->stateList = State::getStates(intval($cookie->id_lang));

       $this->fieldsDisplay = array(
       'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
       'firstname' => array('title' => $this->l('First name'), 'width' => 80),
       'lastname' => array('title' => $this->l('Last name'), 'width' => 100, 'filter_key' => 'a!name'),
       'ademail' => array('title' => $this->l('Email'), 'width' => 100),
       'adpiva' => array('title' => $this->l('Piva'), 'width' => 50),
       'adphone' => array('title' => $this->l('Phone'), 'width' => 50),
       'adcf' => array('title' => $this->l('CF'), 'width' => 50),
       'address1' => array('title' => $this->l('Address'), 'width' => 100),
       'address2' => array('title' => $this->l('Address'), 'width' => 100),
       'postcode' => array('title' => $this->l('Post/Zip code'), 'align' => 'right', 'width' => 50),
       'city' => array('title' => $this->l('City'), 'width' => 150),
       'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country')

       );

       parent::__construct();
   }

}
?>



Avete suggerimenti per ottimizzare il codice e poi per generare il file excel?

precedentemente usavo questo script che però vorrei integrare in questo tab:


<?php
$filename="clienti.xls";
header ("Content-Type: application/vnd.ms-excel");
header ("Content-Disposition: inline; filename=$filename");
$nomehost="localhost";
$nomeutente="xxxx";
$password="yyyy";
$db="zzzz";
?>

<html lang=it><head>

<title>Clienti</title></head>

<body>
' . mysql_field_name($export, $i) . "

</body></html>


Grazie anticipatamente :lol:
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...