name = 'statseasy';
$this->tab = 'administration';
$this->author = 'Webbax';
$this->version = '1.6.1';
$this->module_key = '27612041d70e451f354bc9c8952a593b';
/* PS 1.6 */
$this->bootstrap = true;
$this->ps_version = Tools::substr(_PS_VERSION_,0,3);
parent::__construct();
$this->displayName = $this->l('Stats Easy');
$this->description = $this->l('Pour avoir une vue d\'ensemble des statistiques de votre boutique');
$this->description .= ' '.$this->l('Module réalisé par').' Webbax';
}
function install(){
Db::getInstance()->Execute("
CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."statseasy` (
`id_statseasy` int(11) NOT NULL AUTO_INCREMENT,
`type` text NOT NULL,
`value` text NOT NULL,
`id_shop` INT NOT NULL,
PRIMARY KEY (`id_statseasy`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;"
);
$shops = Shop::getShops();
foreach($shops as $shop){
if(!Shop::isFeatureActive()){$shop['id_shop']=0;} // 1 shop only
Configuration::updateValue('STATSEASY_NBTOP',5,false,null,$shop['id_shop']);
Configuration::updateValue('STATSEASY_NBCHARS_CUT',22,false,null,$shop['id_shop']);
}
if(!parent::install() || !$this->installModuleTab('AdminStatseasy','Stats Easy',19))
return false;
else
return true;
}
function uninstall(){
Db::getInstance()->Execute('DROP TABLE if exists `'._DB_PREFIX_.'statseasy`');
if(!parent::uninstall() || !$this->uninstallModuleTab('AdminStatseasy'))
return false;
return true;
}
function getContent(){
if($this->ps_version=='1.6'){
$this->_html .= '';
}
// Configuration paramètres principaux du module
if(Tools::isSubmit('formConfiguration')){
$this->_html .= $this->msgConfirm($this->l('La configuration a été modifiée.'));
Configuration::updateValue('STATSEASY_NBTOP',Tools::getValue('nbtop'));
Configuration::updateValue('STATSEASY_NBCHARS_CUT',Tools::getValue('nbchars_cut'));
}
$this->_html.= '
';
// Commandes avec le statut payé
$res = Tools::getValue('orderStatesPaid');
if(Tools::isSubmit('submitOrderStatesPaid') && !empty($res)){
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_ .'statseasy WHERE `type`="orderStatesPaid" AND `id_shop`="'.pSQL($this->context->shop->id).'"');
foreach($res as $key=>$id_orderstate){
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_ .'statseasy (type,value,id_shop) VALUES ("orderStatesPaid","'.pSQL($id_orderstate).'","'.pSQL($this->context->shop->id).'")');
}
$this->_html .= $this->msgConfirm($this->l('Les status "payés" ont été sauvés.'));
}
// Commandes avec le statut en attente
$res = Tools::getValue('orderStatesWait');
if(Tools::isSubmit('submitOrderStatesWait')&& !empty($res)){
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_ .'statseasy WHERE `type`="orderStatesWait" AND `id_shop`="'.pSQL($this->context->shop->id).'"');
foreach($res as $key=>$id_orderstate){
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_ .'statseasy (type,value,id_shop) VALUES ("orderStatesWait","'.pSQL($id_orderstate).'","'.pSQL($this->context->shop->id).'")');
}
$this->_html .= $this->msgConfirm($this->l('Les status "en attentes" ont été sauvés.'));
}
// Commandes avec le statut supprimé
$res = Tools::getValue('orderStatesDel');
if(Tools::isSubmit('submitOrderStatesDel')&& !empty($res)){
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_ .'statseasy WHERE `type`="orderStatesDel" AND `id_shop`="'.pSQL($this->context->shop->id).'"');
foreach($res as $key=>$id_orderstate){
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_ .'statseasy (type,value,id_shop) VALUES ("orderStatesDel","'.pSQL($id_orderstate).'","'.pSQL($this->context->shop->id).'")');
}
$this->_html .= $this->msgConfirm($this->l('Les status "supprimés" ont été sauvés.'));
}
$this->_html.= '
';
// Configuration des statuts de commande
$orderStates = OrderState::getOrderStates($this->context->cookie->id_lang);
// Commandes avec le statut payé
$this->_html.= '
';
// Commandes avec le statut en attente
$this->_html.= '
';
// Commandes avec le statut supprimé
$this->_html.= '