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

'.$this->l('Général').'


'.$this->l('du classement').'
'.$this->l('caractères').'

'; // Configuration des statuts de commande $orderStates = OrderState::getOrderStates($this->context->cookie->id_lang); // Commandes avec le statut payé $this->_html.= '
'.$this->l('Cochez les statuts équivalents à "payés"').'
'. $this->l('Les status suivants sont recommandés d\'être cochés').' : '.'
- '.$this->l('Paiement accepté').'
- '.$this->l('Préparation en cours').'
- '.$this->l('Payé avec...').'
- '.$this->l('Livré').'
- '.$this->l('En cours de livraison').'
- '.$this->l('Paiement à distance accepté').'
'; $orderStatesChecked = Db::getInstance()->ExecuteS('SELECT value FROM '._DB_PREFIX_ .'statseasy WHERE type="orderStatesPaid" AND `id_shop`="'.pSQL($this->context->shop->id).'"'); $oSChecked = array(); foreach($orderStatesChecked as $orderStateChecked){$oSChecked[] = $orderStateChecked['value'];} foreach($orderStates as $os){ if(in_array($os['id_order_state'],$oSChecked)){$checked='checked';}else{$checked='';} $this->_html .= ' '.$os['name'].'
'; } $this->_html .= '
'; // Commandes avec le statut en attente $this->_html.= '
'.$this->l('Cochez les statuts équivalents à "en attente du paiement"').'
'. $this->l('Les status suivants sont recommandés d\'être cochés').' :
- '.$this->l('En attente du paiement par...').'
- '.$this->l('En attente de réapprovisionnement').'
'; $orderStatesChecked = Db::getInstance()->ExecuteS('SELECT value FROM '._DB_PREFIX_ .'statseasy WHERE type="orderStatesWait" AND `id_shop`="'.pSQL($this->context->shop->id).'"'); $oSChecked = array(); foreach($orderStatesChecked as $orderStateChecked){$oSChecked[] = $orderStateChecked['value'];} foreach($orderStates as $os){ if(in_array($os['id_order_state'],$oSChecked)){$checked='checked';}else{$checked='';} $this->_html .= ' '.$os['name'].'
'; } $this->_html .= '
'; // Commandes avec le statut supprimé $this->_html.= '
'.$this->l('Cochez les statuts équivalents à "supprimé / remboursé"').'
'. $this->l('Les status suivants sont recommandés d\'être cochés').' :
- '.$this->l('Annulé').'
- '.$this->l('Remboursé').'
- '.$this->l('Erreur de paiement').'
'; $orderStatesChecked = Db::getInstance()->ExecuteS('SELECT value FROM '._DB_PREFIX_ .'statseasy WHERE type="orderStatesDel" AND `id_shop`="'.pSQL($this->context->shop->id).'"'); $oSChecked = array(); foreach($orderStatesChecked as $orderStateChecked){$oSChecked[] = $orderStateChecked['value'];} foreach($orderStates as $os){ if(in_array($os['id_order_state'],$oSChecked)){$checked='checked';}else{$checked='';} $this->_html .= ' '.$os['name'].'
'; } $this->_html .= '
'; return $this->_html; } /* * Installe un onglet * @param string (nom de l'onglet class) * @param string (nom de l'onglet fr) * @param int (id_parent) * @return - */ function installModuleTab($tabClass,$tabName,$idTabParent){ @copy(_PS_MODULE_DIR_.$this->name.'/logo.gif', _PS_IMG_DIR_.'t/'.$tabClass.'.gif'); $tab = new Tab(); $langs = Language::getLanguages(); foreach($langs as $lang){ $tab->name[$lang['id_lang']] = $tabName; } $tab->class_name = $tabClass; $tab->module = $this->name; $tab->id_parent = $idTabParent; if(!$tab->save()) return false; return true; } /* * Désinstalle un onglet * @param string (nom de l'onglet class) * @return - */ function uninstallModuleTab($tabClass){ $idTab = Tab::getIdFromClassName($tabClass); if($idTab != 0){ $tab = new Tab($idTab); $tab->delete(); return true; } return false; } function msgConfirm($msg){ return $this->displayConfirmation($msg); } function msgError($msg){ return $this->displayError($msg); } static function dateUsToFr($date,$delimiter='-'){ $arr = explode('-',$date); $y = $arr[0]; $m = $arr[1]; $d = $arr[2]; return $d.'-'.$m.'-'.$y; } /* * Retourne une chaine avec trait d'union * @param string * @return string */ static function hyphen($string){ $string = mb_strtolower($string,'UTF-8'); $string = str_replace(' ', '-', $string); $string = str_replace( array( 'à', 'â', 'ä', 'á', 'ã', 'å', 'î', 'ï', 'ì', 'í', 'ô', 'ö', 'ò', 'ó', 'õ', 'ø', 'ù', 'û', 'ü', 'ú', 'é', 'è', 'ê', 'ë', 'ç', 'ÿ', 'ñ', ), array( 'a', 'a', 'a', 'a', 'a', 'a', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'e', 'e', 'e', 'e', 'c', 'y', 'n', ), $string ); $string = str_replace("'",'-',$string); $string = str_replace('(','-',$string); $string = str_replace(')','-',$string); $string = str_replace('--','-',$string); return $string; } } ?>