* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 9219 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once(realpath(dirname(__FILE__).'/../mondialrelay.php')); class MRManagement extends MondialRelay { private $_params = array(); private $_resultList = array( 'error' => array(), 'success' => array()); public function __construct($params) { $this->_params = $params; parent::__construct(); } public function __destruct() { } /* ** This method fill the database with the selected carrier */ public function addSelectedCarrierToDB() { $query = 'SELECT `id_mr_selected` FROM `' . _DB_PREFIX_ . 'mr_selected` WHERE `id_cart` = '.(int)$this->_params['id_cart']; // Not exist and needed for database unset($this->_params['relayPointInfo']['permaLinkDetail']); // Update if Exist else add a new entry if (Db::getInstance()->getRow($query)) { $query = 'UPDATE `'._DB_PREFIX_.'mr_selected` SET `id_method` = '.(int)$this->_params['id_mr_method'].', '; if (is_array($this->_params['relayPointInfo'])) foreach($this->_params['relayPointInfo'] as $nameKey => $value) $query .= '`MR_Selected_'.MRTools::bqSQL($nameKey).'` = "'.pSQL($value).'", '; else // Clean the existing relay point data $query .= ' MR_Selected_Num = NULL, MR_Selected_LgAdr1 = NULL, MR_Selected_LgAdr2 = NULL, MR_Selected_LgAdr3 = NULL, MR_Selected_LgAdr4 = NULL, MR_Selected_CP = NULL, MR_Selected_Pays = NULL, MR_Selected_Ville = NULL, '; $query = rtrim($query, ', ').' WHERE `id_cart` = '.(int)$this->_params['id_cart']; } else { $query = 'INSERT INTO `'._DB_PREFIX_.'mr_selected` (`id_customer`, `id_method`, `id_cart`, '; if (is_array($this->_params['relayPointInfo'])) foreach($this->_params['relayPointInfo'] as $nameKey => $value) $query .= '`MR_Selected_'.MRTools::bqSQL($nameKey).'`, '; $query = rtrim($query, ', ').') VALUES ( '.(int)$this->_params['id_customer'].', '.(int)$this->_params['id_mr_method'].', '.(int)$this->_params['id_cart'].', '; if (is_array($this->_params['relayPointInfo'])) foreach($this->_params['relayPointInfo'] as $nameKey => $value) $query .= '"'.pSQL($value).'", '; $query = rtrim($query, ', ').')'; } Db::getInstance()->Execute($query); } public function uninstallDetail() { $html = ''; switch($this->_params['action']) { case 'showFancy': $html .= '