124 lines
4.5 KiB
PHP
124 lines
4.5 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to a commercial license from Common-Services Co., Ltd.
|
|
* Use, copy, modification or distribution of this source file without written
|
|
* license agreement from the SARL SMC is strictly forbidden.
|
|
* In order to obtain a license, please contact us: contact@common-services.com
|
|
* ...........................................................................
|
|
* INFORMATION SUR LA LICENCE D'UTILISATION
|
|
*
|
|
* L'utilisation de ce fichier source est soumise a une licence commerciale
|
|
* concedee par la societe Common-Services Co., Ltd.
|
|
* Toute utilisation, reproduction, modification ou distribution du present
|
|
* fichier source sans contrat de licence ecrit de la part de la Common-Services Co. Ltd. est
|
|
* expressement interdite.
|
|
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
|
|
* ...........................................................................
|
|
*
|
|
* @package So Colissimo Flexibilite
|
|
* @author Alexandre D.
|
|
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
|
|
* @license Commercial license
|
|
* Support by mail : support.soflexibilite@common-services.com
|
|
*/
|
|
|
|
require_once(dirname(__FILE__).'/../../../config/config.inc.php');
|
|
require_once(dirname(__FILE__).'/../../../init.php');
|
|
require_once(dirname(__FILE__).'/../soflexibilite.php');
|
|
|
|
|
|
class InitSoflexibiliteEnv extends Module
|
|
{
|
|
|
|
public function initEnvSoflexibilite()
|
|
{
|
|
ob_start();
|
|
|
|
$this->name = 'soflexibilite';
|
|
$this->protocol = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
|
|
$this->url = $this->protocol.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name;
|
|
$this->parser_url = $this->url.'/functions/parser.php';
|
|
$this->point_list_url = $this->url.'/functions/point_list.php';
|
|
$this->saveDelivery_url = $this->url.'/functions/saveDeliveryPoint.php';
|
|
$this->initSoflexibiliteEnv_url = $this->url.'/functions/initSoflexibiliteEnv.php';
|
|
$this->checkPointSelectedOPC_url = $this->url.'/functions/checkPointSelectedOPC.php';
|
|
|
|
$customerAddresses = $this->context->customer->getAddresses((int)$this->context->cookie->id_lang);
|
|
$mobile = '';
|
|
$inputs = null;
|
|
|
|
$id_delivery_address = (int)$this->context->cart->id_address_delivery;
|
|
|
|
foreach ($customerAddresses as $address)
|
|
{
|
|
if ((int)$address['id_address'] === $id_delivery_address)
|
|
{
|
|
$inputs[] = array(
|
|
'id_address' => $address['id_address'],
|
|
'alias' => $address['alias'],
|
|
'company' => $address['company'],
|
|
'firstname' => $address['firstname'],
|
|
'lastname' => $address['lastname'],
|
|
'address1' => $address['address1'],
|
|
'address2' => $address['address2'],
|
|
'postcode' => $address['postcode'],
|
|
'city' => $address['city'],
|
|
'phone' => $address['phone_mobile'],
|
|
'country' => $address['country'],
|
|
'abdefault' => $address['id_address'] == $this->context->cart->id_address_delivery ? '1' : '0'
|
|
);
|
|
if (isset($address['phone_mobile']))
|
|
{
|
|
$tel = sprintf('%010s', preg_replace('[^\x30-\x39]', '', $address['phone_mobile']));
|
|
if (Tools::substr($tel, 1, 1) == 6 || Tools::substr($tel, 1, 1) == 7)
|
|
$mobile = $tel;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->context->smarty->assign(
|
|
array(
|
|
'soflexibilite_dom_id' => Configuration::get('SOFLEXIBILITE_DOM_ID'),
|
|
'soflexibilite_rdv_id' => Configuration::get('SOFLEXIBILITE_RDV_ID'),
|
|
'soflexibilite_bpr_id' => Configuration::get('SOFLEXIBILITE_BPR_ID'),
|
|
'soflexibilite_a2p_id' => Configuration::get('SOFLEXIBILITE_A2P_ID'),
|
|
'soflexibilite_cit_id' => Configuration::get('SOFLEXIBILITE_CIT_ID'),
|
|
'soflexibilite_cust_id' => $id_delivery_address,
|
|
'inputs' => $inputs,
|
|
'soflexibilite_mobile' => $mobile,
|
|
'soflexibilite_point_list_url' => $this->point_list_url,
|
|
'parser_url' => $this->parser_url,
|
|
'saveDeliveryPoint' => $this->saveDelivery_url,
|
|
'checkPointSelectedOPC' => $this->checkPointSelectedOPC_url,
|
|
'protocol' => $this->protocol,
|
|
'soflexibilite_cart_id' => $this->context->cookie->soflexibilite_cart_id
|
|
)
|
|
);
|
|
|
|
$html = $this->context->smarty->fetch(dirname(__FILE__).'/../views/templates/hook/displayBeforeCarrierMobile.tpl');
|
|
|
|
$result = ob_get_clean();
|
|
|
|
if ($result)
|
|
$output = $result;
|
|
else
|
|
$output = null;
|
|
|
|
|
|
$json = array(
|
|
'output' => $output,
|
|
'status' => true,
|
|
'html' => $html
|
|
);
|
|
die(Tools::jsonEncode($json));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$SoflexibiliteEnv = new InitSoflexibiliteEnv();
|
|
$SoflexibiliteEnv->initEnvSoflexibilite();
|