// Context part 27
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7812 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+63
-72
@@ -33,7 +33,6 @@ class Dejala extends CarrierModule
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
//TODO Iso code of countries where the module can be used, if none module available for all countries
|
||||
$this->limited_countries = array('fr');
|
||||
@@ -41,10 +40,10 @@ class Dejala extends CarrierModule
|
||||
$this->tab = 'shipping_logistics';
|
||||
$this->version = 1.4;
|
||||
$this->internal_version = '1.3';
|
||||
$this->id_lang = $context->language->id;
|
||||
$this->wday_labels = array($this->l('Sunday'), $this->l('Monday'), $this->l('Tuesday'), $this->l('Wednesday'), $this->l('Thursday'), $this->l('Friday'), $this->l('Saturday'));
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->id_lang = $this->context->language->id;
|
||||
$this->wday_labels = array($this->l('Sunday'), $this->l('Monday'), $this->l('Tuesday'), $this->l('Wednesday'), $this->l('Thursday'), $this->l('Friday'), $this->l('Saturday'));
|
||||
|
||||
// The parent construct is required for translations
|
||||
$this->page = basename(__FILE__, '.php');
|
||||
@@ -122,12 +121,11 @@ class Dejala extends CarrierModule
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
// If Dejala is default carrier, try to set another one as default
|
||||
$djlCarrier = DejalaCarrierUtils::getCarrierByName($this->name) ;
|
||||
if (Configuration::get('PS_CARRIER_DEFAULT') == (int)($djlCarrier->id))
|
||||
{
|
||||
$carriers = Carrier::getCarriers($context->language->id, true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
|
||||
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
|
||||
foreach($carriers as $carrier)
|
||||
{
|
||||
if ($carrier['active'] AND !$carrier['deleted'] AND ($carrier['external_module_name'] != $this->name))
|
||||
@@ -231,7 +229,6 @@ class Dejala extends CarrierModule
|
||||
**/
|
||||
public function _postProcess()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$errors = array();
|
||||
$method = Tools::getValue('method');
|
||||
@@ -392,9 +389,8 @@ class Dejala extends CarrierModule
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
//$context->smarty->assign('country', $this->dejalaConfig->country);
|
||||
//$this->context->smarty->assign('country', $this->dejalaConfig->country);
|
||||
$output = $this->display(__FILE__, 'dejala_header.tpl');
|
||||
if (!empty($_POST))
|
||||
{
|
||||
@@ -420,18 +416,17 @@ class Dejala extends CarrierModule
|
||||
|
||||
public function displayForm()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$errors = array();
|
||||
$outputMain = '';
|
||||
$context->smarty->assign("djl_mode", $this->dejalaConfig->mode);
|
||||
$context->smarty->assign("disabled", '');
|
||||
$this->context->smarty->assign("djl_mode", $this->dejalaConfig->mode);
|
||||
$this->context->smarty->assign("disabled", '');
|
||||
if ($this->dejalaConfig->mode == 'PROD')
|
||||
$context->smarty->assign("disabled", 'disabled="disabled"');
|
||||
$this->context->smarty->assign("disabled", 'disabled="disabled"');
|
||||
if (true !== extension_loaded('curl'))
|
||||
{
|
||||
$errors[] = $this->l('This module requires php extension cURL to function properly. Please install the php extension "cURL" first.');
|
||||
$context->smarty->assign("disabled", 'disabled="disabled"');
|
||||
$this->context->smarty->assign("disabled", 'disabled="disabled"');
|
||||
}
|
||||
|
||||
$registered = TRUE;
|
||||
@@ -453,7 +448,7 @@ class Dejala extends CarrierModule
|
||||
}
|
||||
}
|
||||
|
||||
$context->smarty->assign("registered", $registered?"1":"0");
|
||||
$this->context->smarty->assign("registered", $registered?"1":"0");
|
||||
|
||||
|
||||
if (!isset($_GET['cat']) || ($_GET['cat']==='home') || ($_GET['cat']===''))
|
||||
@@ -461,19 +456,19 @@ class Dejala extends CarrierModule
|
||||
else
|
||||
$currentTab=$_GET['cat'];
|
||||
|
||||
$context->smarty->assign("currentTab", $currentTab);
|
||||
$context->smarty->assign("moduleConfigURL", 'index.php?tab=AdminModules&configure=dejala&token='.$_GET['token']);
|
||||
$context->smarty->assign("formAction", $_SERVER['REQUEST_URI']);
|
||||
$this->context->smarty->assign("currentTab", $currentTab);
|
||||
$this->context->smarty->assign("moduleConfigURL", 'index.php?tab=AdminModules&configure=dejala&token='.$_GET['token']);
|
||||
$this->context->smarty->assign("formAction", $_SERVER['REQUEST_URI']);
|
||||
$outputMenu = $this->display(__FILE__, 'dejala_menu.tpl');
|
||||
|
||||
if ($currentTab==='home')
|
||||
{
|
||||
$context->smarty->assign("login", html_entity_decode(Configuration::get('PS_SHOP_EMAIL'), ENT_COMPAT, 'UTF-8'));
|
||||
$this->context->smarty->assign("login", html_entity_decode(Configuration::get('PS_SHOP_EMAIL'), ENT_COMPAT, 'UTF-8'));
|
||||
if ($registered)
|
||||
{
|
||||
$context->smarty->assign("visibility_status", $this->dejalaConfig->visibility_status);
|
||||
$context->smarty->assign("visible_users_list", $this->dejalaConfig->visible_users_list);
|
||||
$context->smarty->assign("store_login", html_entity_decode($this->dejalaConfig->login, ENT_COMPAT, 'UTF-8'));
|
||||
$this->context->smarty->assign("visibility_status", $this->dejalaConfig->visibility_status);
|
||||
$this->context->smarty->assign("visible_users_list", $this->dejalaConfig->visible_users_list);
|
||||
$this->context->smarty->assign("store_login", html_entity_decode($this->dejalaConfig->login, ENT_COMPAT, 'UTF-8'));
|
||||
$smartifyErrors = $this->smartyfyStoreAttributes();
|
||||
if (isset($smartifyErrors) && count($smartifyErrors))
|
||||
$errors = $smartifyErrors;
|
||||
@@ -483,7 +478,7 @@ class Dejala extends CarrierModule
|
||||
$shopName = Configuration::get('PS_SHOP_NAME');
|
||||
if (strlen($shopName) >= 15)
|
||||
$shopName = substr($shopName, 0, 15);
|
||||
$context->smarty->assign("store_name", html_entity_decode($shopName, ENT_COMPAT, 'UTF-8'));
|
||||
$this->context->smarty->assign("store_name", html_entity_decode($shopName, ENT_COMPAT, 'UTF-8'));
|
||||
}
|
||||
$outputMain = $this->display(__FILE__, 'dejala_home.tpl');
|
||||
}
|
||||
@@ -496,7 +491,7 @@ class Dejala extends CarrierModule
|
||||
{
|
||||
foreach ($contacts as $contactName=>$contactData) {
|
||||
foreach ($contactData as $key=>$value) {
|
||||
$context->smarty->assign($contactName.'_'.$key, $value);
|
||||
$this->context->smarty->assign($contactName.'_'.$key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,7 +505,7 @@ class Dejala extends CarrierModule
|
||||
if ('200' == $responseArray['status'])
|
||||
{
|
||||
foreach ($location as $key=>$value)
|
||||
$context->smarty->assign($key, $value);
|
||||
$this->context->smarty->assign($key, $value);
|
||||
|
||||
$outputMain = $this->display(__FILE__, 'dejala_location.tpl');
|
||||
}
|
||||
@@ -523,7 +518,7 @@ class Dejala extends CarrierModule
|
||||
if ('200' == $responseArray['status'])
|
||||
{
|
||||
foreach ($processes as $key=>$value)
|
||||
$context->smarty->assign($key, $value);
|
||||
$this->context->smarty->assign($key, $value);
|
||||
|
||||
$outputMain = $this->display(__FILE__, 'dejala_processes.tpl');
|
||||
}
|
||||
@@ -544,7 +539,7 @@ class Dejala extends CarrierModule
|
||||
$product['public_price'] = number_format(round($product['price'] + $product['margin'], 2), 2, '.', '');
|
||||
$product['public_price_notax'] = number_format(round($product['public_price']/$vat_factor, 2), 2, '.', '');
|
||||
}
|
||||
$context->smarty->assign('products', $products);
|
||||
$this->context->smarty->assign('products', $products);
|
||||
$outputMain = $this->display(__FILE__, 'dejala_products.tpl');
|
||||
}
|
||||
}
|
||||
@@ -582,10 +577,10 @@ class Dejala extends CarrierModule
|
||||
$delivery['delivery_time'] = date('H\hi', $delivery['delivery_utc']);
|
||||
}
|
||||
}
|
||||
$context->smarty->assign('formAction', __PS_BASE_URI__ . 'modules/' . $this->name . '/deliveries_csv.php');
|
||||
$context->smarty->assign('defaultDateFrom', date('01/m/Y'));
|
||||
$context->smarty->assign('defaultDateTo', date('d/m/Y'));
|
||||
$context->smarty->assign('deliveries', $deliveries);
|
||||
$this->context->smarty->assign('formAction', __PS_BASE_URI__ . 'modules/' . $this->name . '/deliveries_csv.php');
|
||||
$this->context->smarty->assign('defaultDateFrom', date('01/m/Y'));
|
||||
$this->context->smarty->assign('defaultDateTo', date('d/m/Y'));
|
||||
$this->context->smarty->assign('deliveries', $deliveries);
|
||||
$outputMain = $this->display(__FILE__, 'dejala_deliveries.tpl');
|
||||
}
|
||||
}
|
||||
@@ -608,9 +603,9 @@ class Dejala extends CarrierModule
|
||||
$m_status['checked'] = '0';
|
||||
$orderStatuses[] = $m_status;
|
||||
}
|
||||
$context->smarty->assign('statuses', $orderStatuses);
|
||||
$this->context->smarty->assign('statuses', $orderStatuses);
|
||||
|
||||
$context->smarty->assign('trigerringStatuses', $this->dejalaConfig->trigerringStatuses);
|
||||
$this->context->smarty->assign('trigerringStatuses', $this->dejalaConfig->trigerringStatuses);
|
||||
$outputMain = $this->display(__FILE__, 'dejala_technical_options.tpl');
|
||||
}
|
||||
|
||||
@@ -630,7 +625,6 @@ class Dejala extends CarrierModule
|
||||
// put in smarty context store attributes
|
||||
function smartyfyStoreAttributes()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$errors = array();
|
||||
$djlUtil = new DejalaUtils();
|
||||
$storeAttrs = array();
|
||||
@@ -639,20 +633,20 @@ class Dejala extends CarrierModule
|
||||
$errors[] = $this->l('An error occurred while getting store, please try again later or contact Dejala.com');
|
||||
else
|
||||
{
|
||||
$context->smarty->assign("account_balance", $storeAttrs['account_balance']);
|
||||
$context->smarty->assign("store_name", $storeAttrs['name']);
|
||||
$this->context->smarty->assign("account_balance", $storeAttrs['account_balance']);
|
||||
$this->context->smarty->assign("store_name", $storeAttrs['name']);
|
||||
|
||||
// Check if account exists in production
|
||||
$responsePing = $djlUtil->ping($this->dejalaConfig, 'PROD');
|
||||
if ('200' == $responsePing['status'])
|
||||
$context->smarty->assign('isLiveReady', '1');
|
||||
$this->context->smarty->assign('isLiveReady', '1');
|
||||
else
|
||||
{
|
||||
$context->smarty->assign('isLiveReady', '0');
|
||||
$this->context->smarty->assign('isLiveReady', '0');
|
||||
if (isset($storeAttrs['attributes']) && isset($storeAttrs['attributes']['request_live']) && ($storeAttrs['attributes']['request_live']=='true'))
|
||||
$context->smarty->assign('isLiveRequested', '1');
|
||||
$this->context->smarty->assign('isLiveRequested', '1');
|
||||
else
|
||||
$context->smarty->assign('isLiveRequested', '0');
|
||||
$this->context->smarty->assign('isLiveRequested', '0');
|
||||
}
|
||||
}
|
||||
return ($errors);
|
||||
@@ -665,7 +659,6 @@ class Dejala extends CarrierModule
|
||||
}
|
||||
|
||||
function displayDeliveryOptions(){
|
||||
$context = Context::getContext();
|
||||
/*
|
||||
Au moment du choix du créneau
|
||||
Pour déterminer le créneau de départ proposé :
|
||||
@@ -682,26 +675,26 @@ class Dejala extends CarrierModule
|
||||
$response = $djlUtil->getStoreAttributes($this->dejalaConfig, $store);
|
||||
if ($response['status'] == 200)
|
||||
{
|
||||
$context->smarty->assign('nb_days', $store['attributes']['nb_days_displayed']);
|
||||
$context->smarty->assign('delivery_delay', $store['attributes']['delivery_delay']);
|
||||
$this->context->smarty->assign('nb_days', $store['attributes']['nb_days_displayed']);
|
||||
$this->context->smarty->assign('delivery_delay', $store['attributes']['delivery_delay']);
|
||||
if (isset($store['attributes']['delivery_partial']))
|
||||
$context->smarty->assign('delivery_partial', $store['attributes']['delivery_partial']);
|
||||
$this->context->smarty->assign('delivery_partial', $store['attributes']['delivery_partial']);
|
||||
}
|
||||
|
||||
$wday_selected = array(1, 1, 1, 1, 1, 1, 1);
|
||||
|
||||
$context->smarty->assign('timetable_css', _MODULE_DIR_.$this->name.'/timetable.css');
|
||||
$context->smarty->assign("timetable_js", _MODULE_DIR_.$this->name.'/timetable.js');
|
||||
$context->smarty->assign("weekdayLabels", $this->wday_labels);
|
||||
$context->smarty->assign("weekdaySelected", $wday_selected);
|
||||
$this->context->smarty->assign('timetable_css', _MODULE_DIR_.$this->name.'/timetable.css');
|
||||
$this->context->smarty->assign("timetable_js", _MODULE_DIR_.$this->name.'/timetable.js');
|
||||
$this->context->smarty->assign("weekdayLabels", $this->wday_labels);
|
||||
$this->context->smarty->assign("weekdaySelected", $wday_selected);
|
||||
|
||||
|
||||
$calendar = array();
|
||||
$response = $djlUtil->getStoreCalendar($this->dejalaConfig, $calendar);
|
||||
if ($response['status'] == 200)
|
||||
{
|
||||
$context->smarty->assign("calendar", $calendar);
|
||||
$context->smarty->assign("timetableTpl", dirname(__FILE__)."/dejala_picking_timetable.tpl");
|
||||
$this->context->smarty->assign("calendar", $calendar);
|
||||
$this->context->smarty->assign("timetableTpl", dirname(__FILE__)."/dejala_picking_timetable.tpl");
|
||||
}
|
||||
$output = $output . $this->display(__FILE__, 'dejala_delivery_options.tpl');
|
||||
|
||||
@@ -733,7 +726,6 @@ class Dejala extends CarrierModule
|
||||
*/
|
||||
public function hookExtraCarrier($params)
|
||||
{
|
||||
$context = Context::getContext();
|
||||
|
||||
$cart = $params['cart'];
|
||||
|
||||
@@ -743,9 +735,9 @@ class Dejala extends CarrierModule
|
||||
if ($this->dejalaConfig->visibility_status == "invisible")
|
||||
return ;
|
||||
|
||||
if (($this->dejalaConfig->visibility_status == "visible_limited") && ((int)$context->customer->id > 0))
|
||||
if (($this->dejalaConfig->visibility_status == "visible_limited") && ((int)$this->context->customer->id > 0))
|
||||
{
|
||||
$customer = $context->customer;
|
||||
$customer = $this->context->customer;
|
||||
if (!in_array($customer->email, preg_split("/[\s,]+/", $this->dejalaConfig->visible_users_list)))
|
||||
return ;
|
||||
}
|
||||
@@ -771,7 +763,7 @@ class Dejala extends CarrierModule
|
||||
if (isset($cart->id_address_delivery) AND $cart->id_address_delivery)
|
||||
$id_zone = (int)Address::getZoneById((int)($cart->id_address_delivery));
|
||||
else
|
||||
$id_zone = (int)$context->country->id_zone;
|
||||
$id_zone = (int)$this->context->country->id_zone;
|
||||
|
||||
$djlCarrier = DejalaCarrierUtils::getCarrierByName($this->name) ;
|
||||
|
||||
@@ -871,8 +863,8 @@ class Dejala extends CarrierModule
|
||||
|
||||
|
||||
$this->mylog("date$=" . $this->logValue($dates,1));
|
||||
$context->smarty->assign('nb_days', $nbDeliveryDates);
|
||||
$context->smarty->assign('dates', $dates);
|
||||
$this->context->smarty->assign('nb_days', $nbDeliveryDates);
|
||||
$this->context->smarty->assign('dates', $dates);
|
||||
for ($i=0; $i < 24; $i++)
|
||||
{
|
||||
$endHour = (($i+$electedProduct['timelimit'])%24);
|
||||
@@ -880,10 +872,10 @@ class Dejala extends CarrierModule
|
||||
$endHour = 24;
|
||||
$hourLabels[] = $i . 'h-' . $endHour . 'h';
|
||||
}
|
||||
$context->smarty->assign('hourLabels', $hourLabels);
|
||||
$this->context->smarty->assign('hourLabels', $hourLabels);
|
||||
|
||||
$context->smarty->assign('timetable_css', _MODULE_DIR_.$this->name.'/timetable.css');
|
||||
$context->smarty->assign("timetable_js", _MODULE_DIR_.$this->name.'/timetable.js');
|
||||
$this->context->smarty->assign('timetable_css', _MODULE_DIR_.$this->name.'/timetable.css');
|
||||
$this->context->smarty->assign("timetable_js", _MODULE_DIR_.$this->name.'/timetable.js');
|
||||
|
||||
$this->mylog("electedCarrier->id=" . $this->logValue($djlCarrier->id));
|
||||
$mCarrier = $djlCarrier;
|
||||
@@ -896,9 +888,9 @@ class Dejala extends CarrierModule
|
||||
|
||||
$resultsArray[] = $row;
|
||||
|
||||
$context->smarty->assign('carriers', $resultsArray);
|
||||
$context->smarty->assign('my_carrier_selected', (isset($cart->id_carrier) && $cart->id_carrier == $djlCarrier->id)) ;
|
||||
$context->smarty->assign('product', $electedProduct);
|
||||
$this->context->smarty->assign('carriers', $resultsArray);
|
||||
$this->context->smarty->assign('my_carrier_selected', (isset($cart->id_carrier) && $cart->id_carrier == $djlCarrier->id)) ;
|
||||
$this->context->smarty->assign('product', $electedProduct);
|
||||
|
||||
|
||||
$djlCart = new DejalaCart($cart->id);
|
||||
@@ -915,21 +907,21 @@ class Dejala extends CarrierModule
|
||||
{
|
||||
if ($l_date['value'] == $deliveryDateSelected)
|
||||
{
|
||||
$context->smarty->assign("deliveryDateIndexSelected", $l_key);
|
||||
$context->smarty->assign("deliveryDateSelected", $deliveryDateSelected);
|
||||
$context->smarty->assign("deliveryHourSelected", $m_hour);
|
||||
$this->context->smarty->assign("deliveryDateIndexSelected", $l_key);
|
||||
$this->context->smarty->assign("deliveryDateSelected", $deliveryDateSelected);
|
||||
$this->context->smarty->assign("deliveryHourSelected", $m_hour);
|
||||
$setDefaultDate = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($setDefaultDate)
|
||||
{
|
||||
$context->smarty->assign("deliveryDateIndexSelected", 0);
|
||||
$context->smarty->assign("deliveryDateSelected", date("Y/m/d", $dateUtc));
|
||||
$context->smarty->assign("deliveryHourSelected", (int)(date("H", $dateUtc)));
|
||||
$this->context->smarty->assign("deliveryDateIndexSelected", 0);
|
||||
$this->context->smarty->assign("deliveryDateSelected", date("Y/m/d", $dateUtc));
|
||||
$this->context->smarty->assign("deliveryHourSelected", (int)(date("H", $dateUtc)));
|
||||
}
|
||||
|
||||
$context->smarty->assign("isCartOutOfStock", $isCartOutOfStock);
|
||||
$this->context->smarty->assign("isCartOutOfStock", $isCartOutOfStock);
|
||||
if (!$isCartOutOfStock)
|
||||
{
|
||||
$buffer = $this->display(__FILE__, 'dejala_carrier.tpl');
|
||||
@@ -937,7 +929,7 @@ class Dejala extends CarrierModule
|
||||
}
|
||||
else
|
||||
{
|
||||
$context->smarty->assign('nostock_info', $this->l('I will select my shipping date when my product is available.'));
|
||||
$this->context->smarty->assign('nostock_info', $this->l('I will select my shipping date when my product is available.'));
|
||||
$buffer = $this->display(__FILE__, 'dejala_carrier_nostock.tpl');
|
||||
}
|
||||
return $buffer;
|
||||
@@ -1025,7 +1017,6 @@ class Dejala extends CarrierModule
|
||||
public function hookProcessCarrier($params)
|
||||
{
|
||||
// FO: Temporary. Necessary to go around the product's cart re-instanciation bug.
|
||||
$context = Context::getContext();
|
||||
|
||||
$cartParams = $params['cart'];
|
||||
$this->hooklog("processCarrier", $params) ;
|
||||
@@ -1073,7 +1064,7 @@ class Dejala extends CarrierModule
|
||||
}
|
||||
|
||||
// FO: VERY DIRTY HACK.... Re-assign the global cart to what it was before.
|
||||
$context->cart = $cartParams ;
|
||||
$this->context->cart = $cartParams ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user