* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7540 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class FianetSceau extends Module { private $id_order; function __construct() { $this->name = 'fianetsceau'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->limited_countries = array('fr'); parent::__construct(); $this->displayName = $this->l('FIA-NET Seal of Confidence'); $this->description = $this->l('Turn your visitors into buyers by creating confidence in your site.'); if (!Configuration::get('FIANET_SCEAU_PRIVATEKEY')) $this->warning = $this->l('Please enter your Private Key field.'); if (!Configuration::get('FIANET_SCEAU_SITEID')) $this->warning = $this->l('Please enter your site ID.'); } public function install() { return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('updateOrderStatus') AND Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'fianet_seal`( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_order` int(10) unsigned NOT NULL, `upload_success` int(10) unsigned NOT NULL, `valid` int(10) unsigned NOT NULL, `status` int(10) unsigned NOT NULL, `date_upd` datetime NOT NULL, `date_add` datetime NOT NULL, PRIMARY KEY (`id`) )')); } private function getProcess() { if ((int)Tools::getValue('fia_net_mode') == 1) Configuration::updateValue('FIA_NET_SEAL_MODE', 1); else Configuration::updateValue('FIA_NET_SEAL_MODE', 0); if (!preg_match('#^[0-9]+$#', Tools::getValue('FIANET_SCEAU_SITEID'))) return parent::displayError('Bad site id (numbers only)'); else Configuration::updateValue('FIANET_SCEAU_SITEID', Tools::getValue('FIANET_SCEAU_SITEID')); Configuration::updateValue('FIANET_SCEAU_PRIVATEKEY', Tools::getValue('FIANET_SCEAU_PRIVATEKEY')); if ((int)Tools::getValue('fia_net_mode')) $dataSync = (($site_id = Configuration::get('FIANET_SCEAU_SITEID')) ? '' : 'toto'); else $dataSync = ''; return $this->_html .= $this->displayConfirmation($this->l('Configuration updated').$dataSync); } public function getContent() { $output = '

'.$this->displayName.'

'; if (!is_callable('curl_init')) $output .= parent::displayError('You need to enable Curl library to use this module'); elseif (Tools::isSubmit('submitFianet')) $output .= self::getProcess(); $output .= '
'.$this->displayName.'
« Le Sceau de Confiance FIA-NET, leader de la confiance sur le web, influence la décision d’achat de 83 % des internautes (*)


Le Sceau de Confiance FIA-NET, le plus connu en France, fait la preuve de vos performances. Il restitue les avis de vos clients grâce à l’envoi de deux questionnaires de satisfaction après l’achat et après la livraison.

L’extranet, un outil d’analyse de performance unique, exploite les réponses de vos clients à ces questionnaires. Une aide inestimable qui vous permet de mieux connaitre vos clients et de piloter votre politique marketing et communication.

(*Etude FIA-NET – Novembre 2009 – 836 répondants) »

'.$this->l('To sign in, check out: ').' '.$this->l('Fia-net Website').'

 

'; $output .= '
'.$this->l('Settings').'

'.$this->l('Sample:').' site_id = \'XXXXX\' '.$this->l('(numbers only)').'

'.$this->l('Private key communicated by Fia-Net').'

 

 

'; return $output; } private function sendXML() { $SiteID = Configuration::get('FIANET_SCEAU_SITEID'); $order = new Order((int)$this->id_order); $customer = new Customer((int)$order->id_customer); $currency = new Currency((int)$order->id_currency); $control = new SimpleXMLElement(''); $user = $control->addChild('utilisateur'); $name = $user->addChild('nom', $customer->lastname); if ($customer->id_gender == 1 OR $customer->id_gender == 2) $name->addAttribute('titre', 1); $user->addChild('prenom', $customer->firstname); $user->addChild('email', $customer->email); $info = $control->addChild('infocommande'); $info->addChild('siteid', $SiteID); $info->addChild('refid', (int)$order->id); $total = round($order->total_paid / $currency->conversion_rate, 2); $amount = $info->addChild('montant', $total); $amount->addAttribute('devise', 'EUR'); $ip = long2ip(Db::getInstance()->getValue(' SELECT ip_address FROM '._DB_PREFIX_.'connections a WHERE a.id_guest = ( SELECT id_guest FROM '._DB_PREFIX_.'guest WHERE id_customer = '.(int)$customer->id.' LIMIT 1)')); $order_date = Db::getInstance()->getValue(' SELECT date_add FROM '._DB_PREFIX_.'orders WHERE id_order = '.(int)$order->id); $customer_ip = $info->addChild('ip', $ip); $customer_ip->addAttribute('timestamp', $order_date); $cryptKey = md5(Configuration::get('FIANET_SCEAU_PRIVATEKEY').'_'.(int)$order->id.'+'.$order_date.'='.$customer->email); $control->addChild('crypt', $cryptKey); $XMLInfo = $control->asXML(); $CheckSum = md5($XMLInfo); $curl = curl_init('https://www.fia-net.com/engine/'.(!Configuration::get('FIA_NET_SEAL_MODE') ? 'preprod/' : '').'sendrating.cgi'); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, 'SiteID='.$SiteID.'&XMLInfo='.$XMLInfo.'&CheckSum='.$CheckSum); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $result = new simpleXMLelement(curl_exec($curl)); curl_close ($curl); if ($result['type'] == 'OK') return true; return false; } public function hookUpdateOrderStatus($params) { $this->id_order = (int)$params['id_order']; $res = Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'fianet_seal` a WHERE a.id_order = '.(int)$params['id_order']); $upload_success = false; if (!$res) { if (!($order = new Order((int)$params['id_order']))) return; if ($params['newOrderStatus']->logable == 1) $upload_success = self::sendXML(); Db::getInstance()->Execute(' INSERT INTO '._DB_PREFIX_.'fianet_seal (id_order, upload_success, valid, status, date_upd, date_add) VALUES ('.(int)$order->id.', 0,'.(int)$params['newOrderStatus']->logable.', '.(int)$params['newOrderStatus']->id.', NOW(), NOW())'); } else { if ($res['valid'] == 1 AND $res['upload_success'] == 1) return; if ($params['newOrderStatus']->logable == 1) $upload_success = self::sendXML(); Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'fianet_seal` a SET valid = '.(int)$params['newOrderStatus']->logable.', upload_success = '.(int)$upload_success.', status = '.(int)$params['newOrderStatus']->id.', date_upd = NOW() WHERE a.id = '.(int)$res['id']); } } public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookRightColumn($params) { global $cookie; return 'Voir la fiche marchand sur Fia-net.com'; } }