Merge branch 'modules'

This commit is contained in:
Etienne Roudeix
2013-11-14 12:04:20 +01:00
27 changed files with 866 additions and 321 deletions

View File

@@ -56,7 +56,7 @@ class HttpException extends BaseAction implements EventSubscriberInterface
$parser = $this->container->get("thelia.parser");
// Define the template thant shoud be used
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate());
//$event->getRequest()->attributes->set('_view', ConfigQuery::getPageNotFoundView());

View File

@@ -279,12 +279,7 @@ class Order extends BaseAction implements EventSubscriberInterface
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
/* call pay method */
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
$paymentModuleInstance = $paymentModuleReflection->newInstance();
$paymentModuleInstance->setRequest($this->getRequest());
$paymentModuleInstance->setDispatcher($this->getDispatcher());
$paymentModuleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
$paymentModuleInstance->pay($placedOrder);
}

View File

@@ -943,6 +943,14 @@
<default key="_controller">Thelia\Controller\Admin\ModuleController::deleteAction</default>
</route>
<!--
Generic module route.
Will be use if module route is not define in module own config file.
-->
<route id="admin.module.configure" path="/admin/module/{module_code}">
<default key="_controller">Thelia\Controller\Admin\ModuleController::configureAction</default>
</route>
<!-- end Modules rule management -->
<!-- tax management -->

View File

@@ -201,7 +201,7 @@ class BaseAdminController extends BaseController
$parser = $this->container->get("thelia.parser");
// Define the template that should be used
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveAdminTemplate()->getPath());
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveAdminTemplate());
return $parser;
}

View File

@@ -188,6 +188,24 @@ class ModuleController extends AbstractCrudController
return $this->render("modules");
}
public function configureAction($module_code)
{
$module = ModuleQuery::create()->findOneByCode($module_code);
if(null === $module) {
throw new \InvalidArgumentException(sprintf("Module `%s` does not exists", $module_code));
}
if (null !== $response = $this->checkAuth(array(), $module_code, AccessManager::VIEW)) return $response;
return $this->render(
"module-configure",
array(
"module_code" => $module_code,
)
);
}
public function toggleActivationAction($module_id)
{
if (null !== $response = $this->checkAuth(AdminResources::MODULE, array(), AccessManager::UPDATE)) return $response;

View File

@@ -97,7 +97,7 @@ class BaseFrontController extends BaseController
$parser = $this->container->get("thelia.parser");
// Define the template that should be used
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
$parser->setTemplate($template ?: TemplateHelper::getInstance()->getActiveFrontTemplate());
return $parser;
}

View File

@@ -84,8 +84,7 @@ class OrderController extends BaseFrontController
}
/* get postage amount */
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
$orderEvent = $this->getOrderEvent();

View File

@@ -78,7 +78,7 @@ class ViewListener implements EventSubscriberInterface
{
$parser = $this->container->get('thelia.parser');
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate()->getPath());
$parser->setTemplate(TemplateHelper::getInstance()->getActiveFrontTemplate());
$request = $this->container->get('request');
try {

View File

@@ -25,8 +25,10 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Exception\OrderException;
use Thelia\Model\CountryQuery;
use Thelia\Module\BaseModule;
use Thelia\Module\DeliveryModuleInterface;
/**
* Class Delivery
@@ -63,14 +65,24 @@ class Delivery extends BaseSpecificModule
foreach ($loopResult->getResultDataCollection() as $deliveryModule) {
$loopResultRow = new LoopResultRow($deliveryModule);
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
$moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode()));
if (false === $moduleInstance instanceof DeliveryModuleInterface) {
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
}
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->setRequest($this->request);
$moduleInstance->setDispatcher($this->dispatcher);
try {
$postage = $moduleInstance->getPostage($country);
} catch(OrderException $e) {
switch($e->getCode()) {
case OrderException::DELIVERY_MODULE_UNAVAILABLE:
/* do not show this delivery module */
continue(2);
break;
default:
throw $e;
}
}
$loopResultRow
->set('ID', $deliveryModule->getId())
@@ -78,7 +90,7 @@ class Delivery extends BaseSpecificModule
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set('POSTAGE', $moduleInstance->getPostage($country))
->set('POSTAGE', $postage)
;
$loopResult->addRow($loopResultRow);

View File

@@ -26,6 +26,7 @@ use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Module\BaseModule;
use Thelia\Module\PaymentModuleInterface;
/**
* Class Payment
@@ -47,14 +48,11 @@ class Payment extends BaseSpecificModule implements PropelSearchLoopInterface
foreach ($loopResult->getResultDataCollection() as $paymentModule) {
$loopResultRow = new LoopResultRow($paymentModule);
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
$moduleInstance = $this->container->get(sprintf('module.%s', $paymentModule->getCode()));
if (false === $moduleInstance instanceof PaymentModuleInterface) {
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
}
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->setRequest($this->request);
$moduleInstance->setDispatcher($this->dispatcher);
$loopResultRow
->set('ID', $paymentModule->getId())

View File

@@ -44,10 +44,16 @@ class Module extends AbstractSmartyPlugin
if (false !== $location = $this->getParam($params, 'location', false)) {
$moduleLimit = $this->getParam($params, 'module', null);
$modules = ModuleQuery::getActivated();
foreach ($modules as $module) {
if(null !== $moduleLimit && $moduleLimit != $module->getCode()) {
continue;
}
$file = sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, $module->getBaseDir(), $location);
if (file_exists($file)) {

View File

@@ -13,6 +13,7 @@ use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserContext;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Template\TemplateHelper;
@@ -23,13 +24,15 @@ use Thelia\Core\Template\TemplateHelper;
*/
class SmartyParser extends Smarty implements ParserInterface
{
public $plugins = array();
protected $request;
protected $dispatcher;
protected $parserContext;
protected $backOfficeTemplateDirectories = array();
protected $frontOfficeTemplateDirectories = array();
protected $template = "";
protected $status = 200;
@@ -101,15 +104,59 @@ class SmartyParser extends Smarty implements ParserInterface
}
}
public function setTemplate($template_path_from_template_base)
public function addBackOfficeTemplateDirectory($templateName, $templateDirectory, $key)
{
$this->template = $template_path_from_template_base;
$this->backOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
}
$this->addTemplateDir(THELIA_TEMPLATE_DIR.$this->template, 0);
public function addFrontOfficeTemplateDirectory($templateName, $templateDirectory, $key)
{
$this->frontOfficeTemplateDirectories[$templateName][$key] = $templateDirectory;
}
$config_dir = THELIA_TEMPLATE_DIR.$this->template.'/configs';
/**
* @param TemplateDefinition $templateDefinition
*/
public function setTemplate(TemplateDefinition $templateDefinition)
{
$this->template = $templateDefinition->getPath();
$this->setConfigDir($config_dir);
/* init template directories */
$this->setTemplateDir(array());
/* add main template directory */
$this->addTemplateDir(THELIA_TEMPLATE_DIR . $this->template, 0);
/* define config directory */
$configDirectory = THELIA_TEMPLATE_DIR . $this->template . '/configs';
$this->setConfigDir($configDirectory);
/* add modules template directories */
switch($templateDefinition->getType()) {
case TemplateDefinition::FRONT_OFFICE:
/* do not pass array directly to addTemplateDir since we cant control on keys */
if(isset($this->frontOfficeTemplateDirectories[$templateDefinition->getName()])) {
foreach($this->frontOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
$this->addTemplateDir($directory, $key);
}
}
break;
case TemplateDefinition::BACK_OFFICE:
/* do not pass array directly to addTemplateDir since we cant control on keys */
if(isset($this->backOfficeTemplateDirectories[$templateDefinition->getName()])) {
foreach($this->backOfficeTemplateDirectories[$templateDefinition->getName()] as $key => $directory) {
$this->addTemplateDir($directory, $key);
}
}
break;
case TemplateDefinition::PDF:
break;
default:
break;
}
}
public function getTemplate()

View File

@@ -54,14 +54,20 @@ class TemplateDefinition
$this->name = $name;
$this->type = $type;
if ($type == self::BACK_OFFICE)
$this->path = self::BACK_OFFICE_SUBDIR . $name;
else if ($type == self::PDF)
$this->path = self::PDF_SUBDIR . $name;
else if ($type == self::FRONT_OFFICE)
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
else
$this->path = $name;
switch($type) {
case TemplateDefinition::FRONT_OFFICE:
$this->path = self::FRONT_OFFICE_SUBDIR . $name;
break;
case TemplateDefinition::BACK_OFFICE:
$this->path = self::BACK_OFFICE_SUBDIR . $name;
break;
case TemplateDefinition::PDF:
$this->path = self::PDF_SUBDIR . $name;
break;
default:
$this->path = $name;
break;
}
}
public function getName()

View File

@@ -46,6 +46,9 @@ class TemplateHelper
return self::$instance;
}
/**
* @return TemplateDefinition
*/
public function getActivePdfTemplate() {
return new TemplateDefinition(
ConfigQuery::read('active-pdf-template', 'default'),
@@ -53,6 +56,9 @@ class TemplateHelper
);
}
/**
* @return TemplateDefinition
*/
public function getActiveAdminTemplate() {
return new TemplateDefinition(
ConfigQuery::read('active-admin-template', 'default'),
@@ -60,6 +66,9 @@ class TemplateHelper
);
}
/**
* @return TemplateDefinition
*/
public function getActiveFrontTemplate() {
return new TemplateDefinition(
ConfigQuery::read('active-front-template', 'default'),

View File

@@ -35,6 +35,7 @@ namespace Thelia\Core;
use Propel\Runtime\Connection\ConnectionWrapper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -45,6 +46,7 @@ use Thelia\Core\Bundle;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Config\DatabaseConfiguration;
use Thelia\Config\DefinePropel;
use Thelia\Core\Template\TemplateDefinition;
use Thelia\Core\TheliaContainerBuilder;
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
use Thelia\Model\ConfigQuery;
@@ -126,7 +128,6 @@ class Thelia extends Kernel
$modules = \Thelia\Model\ModuleQuery::getActivated();
$translationDirs = array();
$templateDirs = array();
$parser = $container->getDefinition('thelia.parser');
foreach ($modules as $module) {
@@ -134,7 +135,7 @@ class Thelia extends Kernel
$defintion = new Definition();
$defintion->setClass($module->getFullNamespace());
$defintion->addMethodCall("setContainer", array('service_container'));
$defintion->addMethodCall("setContainer", array(new Reference('service_container')));
$container->setDefinition(
"module.".$module->getCode(),
@@ -151,9 +152,54 @@ class Thelia extends Kernel
$translationDirs[] = $dir;
}
if (is_dir($dir = THELIA_MODULE_DIR . "/" . $code . "/templates")) {
//$templateDirs[$code] = $dir;
$parser->addMethodCall('addTemplateDir', array($dir, $code));
/* is there a front-office template directory ? */
$frontOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::FRONT_OFFICE_SUBDIR);
if (is_dir($frontOfficeModuleTemplateDirectory)) {
try {
$moduleFrontOfficeTemplateBrowser = new \DirectoryIterator($frontOfficeModuleTemplateDirectory);
} catch (\UnexpectedValueException $e) {
throw $e;
}
/* browse the directory */
foreach ($moduleFrontOfficeTemplateBrowser as $moduleFrontOfficeTemplateContent) {
/* is it a directory which is not . or .. ? */
if ($moduleFrontOfficeTemplateContent->isDir() && !$moduleFrontOfficeTemplateContent->isDot()) {
$parser->addMethodCall(
'addFrontOfficeTemplateDirectory',
array(
$moduleFrontOfficeTemplateContent->getFilename(),
$frontOfficeModuleTemplateDirectory,
$code,
)
);
}
}
}
/* is there a back-office template directory ? */
$backOfficeModuleTemplateDirectory = sprintf("%s%s%stemplates%s%s", THELIA_MODULE_DIR, $code, DS, DS, TemplateDefinition::BACK_OFFICE_SUBDIR);
if (is_dir($backOfficeModuleTemplateDirectory)) {
try {
$moduleBackOfficeTemplateBrowser = new \DirectoryIterator($backOfficeModuleTemplateDirectory);
} catch (\UnexpectedValueException $e) {
throw $e;
}
/* browse the directory */
foreach ($moduleBackOfficeTemplateBrowser as $moduleBackOfficeTemplateContent) {
/* is it a directory which is not . or .. ? */
if ($moduleBackOfficeTemplateContent->isDir() && !$moduleBackOfficeTemplateContent->isDot()) {
$parser->addMethodCall(
'addBackOfficeTemplateDirectory',
array(
$moduleBackOfficeTemplateContent->getFilename(),
$backOfficeModuleTemplateDirectory,
$code,
)
);
}
}
}
} catch (\InvalidArgumentException $e) {
// TODO: process module configuration exception

View File

@@ -38,6 +38,7 @@ class OrderException extends \RuntimeException
const CART_EMPTY = 100;
const UNDEFINED_DELIVERY = 200;
const DELIVERY_MODULE_UNAVAILABLE = 201;
public function __construct($message, $code = null, $arguments = array(), $previous = null)
{

View File

@@ -112,4 +112,18 @@ class Cart extends BaseCart
return $total;
}
public function getWeight()
{
$weight = 0;
foreach($this->getCartItems() as $cartItem) {
$itemWeight = $cartItem->getProductSaleElements()->getWeight();
$itemWeight *= $cartItem->getQuantity();
$weight += $itemWeight;
}
return $weight;
}
}

View File

@@ -424,7 +424,7 @@ try {
$stock->setQuantity($faker->randomNumber(1,50));
$stock->setPromo($faker->randomNumber(0,1));
$stock->setNewness($faker->randomNumber(0,1));
$stock->setWeight($faker->randomFloat(2, 100,10000));
$stock->setWeight($faker->randomFloat(2, 1, 5));
$stock->setIsDefault($i == 0);
$stock->setEanCode(substr(str_shuffle("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 13));
$stock->save();

View File

@@ -86,285 +86,285 @@ VALUES
INSERT INTO `area` (`id`, `name`, `postage`, `created_at`, `updated_at`) VALUES
(1, 'France', NULL, NOW(), NOW()),
(2, 'Area 1', NULL, NOW(), NOW()),
(3, 'Area 2', NULL, NOW(), NOW()),
(4, 'Area 3', NULL, NOW(), NOW()),
(5, 'Area 4', NULL, NOW(), NOW()),
(6, 'Area 5', NULL, NOW(), NOW()),
(7, 'Area 6', NULL, NOW(), NOW()),
(8, 'Area 7', NULL, NOW(), NOW()),
(9, 'Area 8', NULL, NOW(), NOW()),
(10, 'DOM', NULL, NOW(), NOW()),
(11, 'TOM', NULL, NOW(), NOW());
(2, 'A Zone', NULL, NOW(), NOW()),
(3, 'B Zone', NULL, NOW(), NOW()),
(4, 'C Zone', NULL, NOW(), NOW()),
(5, 'D Zone', NULL, NOW(), NOW()),
(6, 'France OM1', NULL, NOW(), NOW()),
(7, 'France OM2', NULL, NOW(), NOW());
INSERT INTO `area_delivery_module` (`id`, `area_id`, `delivery_module_id`, `created_at`, `updated_at`) VALUES
(1, 1, 2, NOW(), NOW());
(1, 1, 2, NOW(), NOW()),
(2, 2, 2, NOW(), NOW()),
(3, 3, 2, NOW(), NOW()),
(4, 4, 2, NOW(), NOW()),
(5, 5, 2, NOW(), NOW()),
(6, 6, 2, NOW(), NOW());
INSERT INTO `country` (`id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `by_default`, `shop_country`, `created_at`, `updated_at`) VALUES
(1, NULL, '4', 'AF', 'AFG', 0, 0, NOW(), NOW()),
(2, NULL, '710', 'ZA', 'ZAF', 0, 0, NOW(), NOW()),
(3, NULL, '8', 'AL', 'ALB', 0, 0, NOW(), NOW()),
(4, NULL, '12', 'DZ', 'DZA', 0, 0, NOW(), NOW()),
(5, NULL, '276', 'DE', 'DEU', 0, 0, NOW(), NOW()),
(6, NULL, '20', 'AD', 'AND', 0, 0, NOW(), NOW()),
(7, NULL, '24', 'AO', 'AGO', 0, 0, NOW(), NOW()),
(8, NULL, '28', 'AG', 'ATG', 0, 0, NOW(), NOW()),
(9, NULL, '682', 'SA', 'SAU', 0, 0, NOW(), NOW()),
(10, NULL, '32', 'AR', 'ARG', 0, 0, NOW(), NOW()),
(11, NULL, '51', 'AM', 'ARM', 0, 0, NOW(), NOW()),
(12, NULL, '36', 'AU', 'AUS', 0, 0, NOW(), NOW()),
(13, NULL, '40', 'AT', 'AUT', 0, 0, NOW(), NOW()),
(14, NULL, '31', 'AZ', 'AZE', 0, 0, NOW(), NOW()),
(15, NULL, '44', 'BS', 'BHS', 0, 0, NOW(), NOW()),
(16, NULL, '48', 'BR', 'BHR', 0, 0, NOW(), NOW()),
(17, NULL, '50', 'BD', 'BGD', 0, 0, NOW(), NOW()),
(18, NULL, '52', 'BB', 'BRB', 0, 0, NOW(), NOW()),
(19, NULL, '585', 'PW', 'PLW', 0, 0, NOW(), NOW()),
(20, NULL, '56', 'BE', 'BEL', 0, 0, NOW(), NOW()),
(21, NULL, '84', 'BL', 'BLZ', 0, 0, NOW(), NOW()),
(22, NULL, '204', 'BJ', 'BEN', 0, 0, NOW(), NOW()),
(1, 5, '4', 'AF', 'AFG', 0, 0, NOW(), NOW()),
(2, 4, '710', 'ZA', 'ZAF', 0, 0, NOW(), NOW()),
(3, 3, '8', 'AL', 'ALB', 0, 0, NOW(), NOW()),
(4, 3, '12', 'DZ', 'DZA', 0, 0, NOW(), NOW()),
(5, 2, '276', 'DE', 'DEU', 0, 0, NOW(), NOW()),
(6, 1, '20', 'AD', 'AND', 0, 0, NOW(), NOW()),
(7, 4, '24', 'AO', 'AGO', 0, 0, NOW(), NOW()),
(8, 5, '28', 'AG', 'ATG', 0, 0, NOW(), NOW()),
(9, 4, '682', 'SA', 'SAU', 0, 0, NOW(), NOW()),
(10, 5, '32', 'AR', 'ARG', 0, 0, NOW(), NOW()),
(11, 3, '51', 'AM', 'ARM', 0, 0, NOW(), NOW()),
(12, 5, '36', 'AU', 'AUS', 0, 0, NOW(), NOW()),
(13, 2, '40', 'AT', 'AUT', 0, 0, NOW(), NOW()),
(14, 3, '31', 'AZ', 'AZE', 0, 0, NOW(), NOW()),
(15, 5, '44', 'BS', 'BHS', 0, 0, NOW(), NOW()),
(16, 4, '48', 'BR', 'BHR', 0, 0, NOW(), NOW()),
(17, 5, '50', 'BD', 'BGD', 0, 0, NOW(), NOW()),
(18, 5, '52', 'BB', 'BRB', 0, 0, NOW(), NOW()),
(19, 3, '585', 'PW', 'PLW', 0, 0, NOW(), NOW()),
(20, 5, '56', 'BE', 'BEL', 0, 0, NOW(), NOW()),
(21, 5, '84', 'BL', 'BLZ', 0, 0, NOW(), NOW()),
(22, 4, '204', 'BJ', 'BEN', 0, 0, NOW(), NOW()),
(23, NULL, '64', 'BT', 'BTN', 0, 0, NOW(), NOW()),
(24, NULL, '112', 'BY', 'BLR', 0, 0, NOW(), NOW()),
(25, NULL, '104', 'MM', 'MMR', 0, 0, NOW(), NOW()),
(26, NULL, '68', 'BO', 'BOL', 0, 0, NOW(), NOW()),
(27, NULL, '70', 'BA', 'BIH', 0, 0, NOW(), NOW()),
(28, NULL, '72', 'BW', 'BWA', 0, 0, NOW(), NOW()),
(29, NULL, '76', 'BR', 'BRA', 0, 0, NOW(), NOW()),
(30, NULL, '96', 'BN', 'BRN', 0, 0, NOW(), NOW()),
(31, NULL, '100', 'BG', 'BGR', 0, 0, NOW(), NOW()),
(32, NULL, '854', 'BF', 'BFA', 0, 0, NOW(), NOW()),
(33, NULL, '108', 'BI', 'BDI', 0, 0, NOW(), NOW()),
(34, NULL, '116', 'KH', 'KHM', 0, 0, NOW(), NOW()),
(35, NULL, '120', 'CM', 'CMR', 0, 0, NOW(), NOW()),
(37, NULL, '132', 'CV', 'CPV', 0, 0, NOW(), NOW()),
(38, NULL, '152', 'CL', 'CHL', 0, 0, NOW(), NOW()),
(39, NULL, '156', 'CN', 'CHN', 0, 0, NOW(), NOW()),
(40, NULL, '196', 'CY', 'CYP', 0, 0, NOW(), NOW()),
(41, NULL, '170', 'CO', 'COL', 0, 0, NOW(), NOW()),
(42, NULL, '174', 'KM', 'COM', 0, 0, NOW(), NOW()),
(43, NULL, '178', 'CG', 'COG', 0, 0, NOW(), NOW()),
(44, NULL, '184', 'CK', 'COK', 0, 0, NOW(), NOW()),
(45, NULL, '408', 'KP', 'PRK', 0, 0, NOW(), NOW()),
(46, NULL, '410', 'KR', 'KOR', 0, 0, NOW(), NOW()),
(47, NULL, '188', 'CR', 'CRI', 0, 0, NOW(), NOW()),
(48, NULL, '384', 'CI', 'CIV', 0, 0, NOW(), NOW()),
(49, NULL, '191', 'HR', 'HRV', 0, 0, NOW(), NOW()),
(50, NULL, '192', 'CU', 'CUB', 0, 0, NOW(), NOW()),
(51, NULL, '208', 'DK', 'DNK', 0, 0, NOW(), NOW()),
(52, NULL, '262', 'DJ', 'DJI', 0, 0, NOW(), NOW()),
(53, NULL, '212', 'DM', 'DMA', 0, 0, NOW(), NOW()),
(54, NULL, '818', 'EG', 'EGY', 0, 0, NOW(), NOW()),
(55, NULL, '784', 'AE', 'ARE', 0, 0, NOW(), NOW()),
(56, NULL, '218', 'EC', 'ECU', 0, 0, NOW(), NOW()),
(57, NULL, '232', 'ER', 'ERI', 0, 0, NOW(), NOW()),
(58, NULL, '724', 'ES', 'ESP', 0, 0, NOW(), NOW()),
(59, NULL, '233', 'EE', 'EST', 0, 0, NOW(), NOW()),
(61, NULL, '231', 'ET', 'ETH', 0, 0, NOW(), NOW()),
(62, NULL, '242', 'FJ', 'FJI', 0, 0, NOW(), NOW()),
(63, NULL, '246', 'FI', 'FIN', 0, 0, NOW(), NOW()),
(24, 3, '112', 'BY', 'BLR', 0, 0, NOW(), NOW()),
(25, 5, '104', 'MM', 'MMR', 0, 0, NOW(), NOW()),
(26, 5, '68', 'BO', 'BOL', 0, 0, NOW(), NOW()),
(27, 3, '70', 'BA', 'BIH', 0, 0, NOW(), NOW()),
(28, 4, '72', 'BW', 'BWA', 0, 0, NOW(), NOW()),
(29, 5, '76', 'BR', 'BRA', 0, 0, NOW(), NOW()),
(30, 5, '96', 'BN', 'BRN', 0, 0, NOW(), NOW()),
(31, 3, '100', 'BG', 'BGR', 0, 0, NOW(), NOW()),
(32, 5, '854', 'BF', 'BFA', 0, 0, NOW(), NOW()),
(33, 4, '108', 'BI', 'BDI', 0, 0, NOW(), NOW()),
(34, 5, '116', 'KH', 'KHM', 0, 0, NOW(), NOW()),
(35, 4, '120', 'CM', 'CMR', 0, 0, NOW(), NOW()),
(37, 4, '132', 'CV', 'CPV', 0, 0, NOW(), NOW()),
(38, 5, '152', 'CL', 'CHL', 0, 0, NOW(), NOW()),
(39, 5, '156', 'CN', 'CHN', 0, 0, NOW(), NOW()),
(40, 2, '196', 'CY', 'CYP', 0, 0, NOW(), NOW()),
(41, 5, '170', 'CO', 'COL', 0, 0, NOW(), NOW()),
(42, 4, '174', 'KM', 'COM', 0, 0, NOW(), NOW()),
(43, 4, '178', 'CG', 'COG', 0, 0, NOW(), NOW()),
(44, 5, '184', 'CK', 'COK', 0, 0, NOW(), NOW()),
(45, 5, '408', 'KP', 'PRK', 0, 0, NOW(), NOW()),
(46, 5, '410', 'KR', 'KOR', 0, 0, NOW(), NOW()),
(47, 5, '188', 'CR', 'CRI', 0, 0, NOW(), NOW()),
(48, 4, '384', 'CI', 'CIV', 0, 0, NOW(), NOW()),
(49, 2, '191', 'HR', 'HRV', 0, 0, NOW(), NOW()),
(50, 5, '192', 'CU', 'CUB', 0, 0, NOW(), NOW()),
(51, 2, '208', 'DK', 'DNK', 0, 0, NOW(), NOW()),
(52, 5, '262', 'DJ', 'DJI', 0, 0, NOW(), NOW()),
(53, 5, '212', 'DM', 'DMA', 0, 0, NOW(), NOW()),
(54, 4, '818', 'EG', 'EGY', 0, 0, NOW(), NOW()),
(55, 4, '784', 'AE', 'ARE', 0, 0, NOW(), NOW()),
(56, 5, '218', 'EC', 'ECU', 0, 0, NOW(), NOW()),
(57, 4, '232', 'ER', 'ERI', 0, 0, NOW(), NOW()),
(58, 2, '724', 'ES', 'ESP', 0, 0, NOW(), NOW()),
(59, 2, '233', 'EE', 'EST', 0, 0, NOW(), NOW()),
(61, 4, '231', 'ET', 'ETH', 0, 0, NOW(), NOW()),
(62, 5, '242', 'FJ', 'FJI', 0, 0, NOW(), NOW()),
(63, 2, '246', 'FI', 'FIN', 0, 0, NOW(), NOW()),
(64, 1, '250', 'FR', 'FRA', 1, 1, NOW(), NOW()),
(65, NULL, '266', 'GA', 'GAB', 0, 0, NOW(), NOW()),
(66, NULL, '270', 'GM', 'GMB', 0, 0, NOW(), NOW()),
(67, NULL, '268', 'GE', 'GEO', 0, 0, NOW(), NOW()),
(68, NULL, '288', 'GH', 'GHA', 0, 0, NOW(), NOW()),
(69, NULL, '300', 'GR', 'GRC', 0, 0, NOW(), NOW()),
(70, NULL, '308', 'GD', 'GRD', 0, 0, NOW(), NOW()),
(71, NULL, '320', 'GT', 'GTM', 0, 0, NOW(), NOW()),
(72, NULL, '324', 'GN', 'GIN', 0, 0, NOW(), NOW()),
(73, NULL, '624', 'GW', 'GNB', 0, 0, NOW(), NOW()),
(74, NULL, '226', 'GQ', 'GNQ', 0, 0, NOW(), NOW()),
(75, NULL, '328', 'GY', 'GUY', 0, 0, NOW(), NOW()),
(76, NULL, '332', 'HT', 'HTI', 0, 0, NOW(), NOW()),
(77, NULL, '340', 'HN', 'HND', 0, 0, NOW(), NOW()),
(78, NULL, '348', 'HU', 'HUN', 0, 0, NOW(), NOW()),
(79, NULL, '356', 'IN', 'IND', 0, 0, NOW(), NOW()),
(80, NULL, '360', 'ID', 'IDN', 0, 0, NOW(), NOW()),
(81, NULL, '364', 'IR', 'IRN', 0, 0, NOW(), NOW()),
(82, NULL, '368', 'IQ', 'IRQ', 0, 0, NOW(), NOW()),
(83, NULL, '372', 'IE', 'IRL', 0, 0, NOW(), NOW()),
(84, NULL, '352', 'IS', 'ISL', 0, 0, NOW(), NOW()),
(85, NULL, '376', 'IL', 'ISR', 0, 0, NOW(), NOW()),
(86, NULL, '380', 'IT', 'ITA', 0, 0, NOW(), NOW()),
(87, NULL, '388', 'JM', 'JAM', 0, 0, NOW(), NOW()),
(88, NULL, '392', 'JP', 'JPN', 0, 0, NOW(), NOW()),
(89, NULL, '400', 'JO', 'JOR', 0, 0, NOW(), NOW()),
(90, NULL, '398', 'KZ', 'KAZ', 0, 0, NOW(), NOW()),
(91, NULL, '404', 'KE', 'KEN', 0, 0, NOW(), NOW()),
(92, NULL, '417', 'KG', 'KGZ', 0, 0, NOW(), NOW()),
(93, NULL, '296', 'KI', 'KIR', 0, 0, NOW(), NOW()),
(94, NULL, '414', 'KW', 'KWT', 0, 0, NOW(), NOW()),
(95, NULL, '418', 'LA', 'LAO', 0, 0, NOW(), NOW()),
(96, NULL, '426', 'LS', 'LSO', 0, 0, NOW(), NOW()),
(97, NULL, '428', 'LV', 'LVA', 0, 0, NOW(), NOW()),
(98, NULL, '422', 'LB', 'LBN', 0, 0, NOW(), NOW()),
(99, NULL, '430', 'LR', 'LBR', 0, 0, NOW(), NOW()),
(100, NULL, '343', 'LY', 'LBY', 0, 0, NOW(), NOW()),
(101, NULL, '438', 'LI', 'LIE', 0, 0, NOW(), NOW()),
(102, NULL, '440', 'LT', 'LTU', 0, 0, NOW(), NOW()),
(103, NULL, '442', 'LU', 'LUX', 0, 0, NOW(), NOW()),
(104, NULL, '807', 'MK', 'MKD', 0, 0, NOW(), NOW()),
(105, NULL, '450', 'MD', 'MDG', 0, 0, NOW(), NOW()),
(106, NULL, '458', 'MY', 'MYS', 0, 0, NOW(), NOW()),
(107, NULL, '454', 'MW', 'MWI', 0, 0, NOW(), NOW()),
(108, NULL, '462', 'MV', 'MDV', 0, 0, NOW(), NOW()),
(109, NULL, '466', 'ML', 'MLI', 0, 0, NOW(), NOW()),
(110, NULL, '470', 'MT', 'MLT', 0, 0, NOW(), NOW()),
(111, NULL, '504', 'MA', 'MAR', 0, 0, NOW(), NOW()),
(112, NULL, '584', 'MH', 'MHL', 0, 0, NOW(), NOW()),
(113, NULL, '480', 'MU', 'MUS', 0, 0, NOW(), NOW()),
(114, NULL, '478', 'MR', 'MRT', 0, 0, NOW(), NOW()),
(115, NULL, '484', 'MX', 'MEX', 0, 0, NOW(), NOW()),
(65, 4, '266', 'GA', 'GAB', 0, 0, NOW(), NOW()),
(66, 4, '270', 'GM', 'GMB', 0, 0, NOW(), NOW()),
(67, 3, '268', 'GE', 'GEO', 0, 0, NOW(), NOW()),
(68, 4, '288', 'GH', 'GHA', 0, 0, NOW(), NOW()),
(69, 2, '300', 'GR', 'GRC', 0, 0, NOW(), NOW()),
(70, 5, '308', 'GD', 'GRD', 0, 0, NOW(), NOW()),
(71, 5, '320', 'GT', 'GTM', 0, 0, NOW(), NOW()),
(72, 4, '324', 'GN', 'GIN', 0, 0, NOW(), NOW()),
(73, 4, '624', 'GW', 'GNB', 0, 0, NOW(), NOW()),
(74, 4, '226', 'GQ', 'GNQ', 0, 0, NOW(), NOW()),
(75, 5, '328', 'GY', 'GUY', 0, 0, NOW(), NOW()),
(76, 5, '332', 'HT', 'HTI', 0, 0, NOW(), NOW()),
(77, 5, '340', 'HN', 'HND', 0, 0, NOW(), NOW()),
(78, 2, '348', 'HU', 'HUN', 0, 0, NOW(), NOW()),
(79, 5, '356', 'IN', 'IND', 0, 0, NOW(), NOW()),
(80, 5, '360', 'ID', 'IDN', 0, 0, NOW(), NOW()),
(81, 4, '364', 'IR', 'IRN', 0, 0, NOW(), NOW()),
(82, 4, '368', 'IQ', 'IRQ', 0, 0, NOW(), NOW()),
(83, 2, '372', 'IE', 'IRL', 0, 0, NOW(), NOW()),
(84, 3, '352', 'IS', 'ISL', 0, 0, NOW(), NOW()),
(85, 4, '376', 'IL', 'ISR', 0, 0, NOW(), NOW()),
(86, 2, '380', 'IT', 'ITA', 0, 0, NOW(), NOW()),
(87, 5, '388', 'JM', 'JAM', 0, 0, NOW(), NOW()),
(88, 5, '392', 'JP', 'JPN', 0, 0, NOW(), NOW()),
(89, 4, '400', 'JO', 'JOR', 0, 0, NOW(), NOW()),
(90, 5, '398', 'KZ', 'KAZ', 0, 0, NOW(), NOW()),
(91, 4, '404', 'KE', 'KEN', 0, 0, NOW(), NOW()),
(92, 5, '417', 'KG', 'KGZ', 0, 0, NOW(), NOW()),
(93, 5, '296', 'KI', 'KIR', 0, 0, NOW(), NOW()),
(94, 4, '414', 'KW', 'KWT', 0, 0, NOW(), NOW()),
(95, 5, '418', 'LA', 'LAO', 0, 0, NOW(), NOW()),
(96, 4, '426', 'LS', 'LSO', 0, 0, NOW(), NOW()),
(97, 2, '428', 'LV', 'LVA', 0, 0, NOW(), NOW()),
(98, 4, '422', 'LB', 'LBN', 0, 0, NOW(), NOW()),
(99, 4, '430', 'LR', 'LBR', 0, 0, NOW(), NOW()),
(100, 4, '343', 'LY', 'LBY', 0, 0, NOW(), NOW()),
(101, 2, '438', 'LI', 'LIE', 0, 0, NOW(), NOW()),
(102, 2, '440', 'LT', 'LTU', 0, 0, NOW(), NOW()),
(103, 2, '442', 'LU', 'LUX', 0, 0, NOW(), NOW()),
(104, 3, '807', 'MK', 'MKD', 0, 0, NOW(), NOW()),
(105, 4, '450', 'MD', 'MDG', 0, 0, NOW(), NOW()),
(106, 5, '458', 'MY', 'MYS', 0, 0, NOW(), NOW()),
(107, 4, '454', 'MW', 'MWI', 0, 0, NOW(), NOW()),
(108, 5, '462', 'MV', 'MDV', 0, 0, NOW(), NOW()),
(109, 4, '466', 'ML', 'MLI', 0, 0, NOW(), NOW()),
(110, 2, '470', 'MT', 'MLT', 0, 0, NOW(), NOW()),
(111, 3, '504', 'MA', 'MAR', 0, 0, NOW(), NOW()),
(112, 5, '584', 'MH', 'MHL', 0, 0, NOW(), NOW()),
(113, 4, '480', 'MU', 'MUS', 0, 0, NOW(), NOW()),
(114, 4, '478', 'MR', 'MRT', 0, 0, NOW(), NOW()),
(115, 5, '484', 'MX', 'MEX', 0, 0, NOW(), NOW()),
(116, NULL, '583', 'FM', 'FSM', 0, 0, NOW(), NOW()),
(117, NULL, '498', 'MD', 'MDA', 0, 0, NOW(), NOW()),
(118, NULL, '492', 'MC', 'MCO', 0, 0, NOW(), NOW()),
(119, NULL, '496', 'MN', 'MNG', 0, 0, NOW(), NOW()),
(120, NULL, '508', 'MZ', 'MOZ', 0, 0, NOW(), NOW()),
(121, NULL, '516', 'NA', 'NAM', 0, 0, NOW(), NOW()),
(122, NULL, '520', 'NR', 'NRU', 0, 0, NOW(), NOW()),
(123, NULL, '524', 'NP', 'NPL', 0, 0, NOW(), NOW()),
(124, NULL, '558', 'NI', 'NIC', 0, 0, NOW(), NOW()),
(125, NULL, '562', 'NE', 'NER', 0, 0, NOW(), NOW()),
(126, NULL, '566', 'NG', 'NGA', 0, 0, NOW(), NOW()),
(117, 3, '498', 'MD', 'MDA', 0, 0, NOW(), NOW()),
(118, 1, '492', 'MC', 'MCO', 0, 0, NOW(), NOW()),
(119, 5, '496', 'MN', 'MNG', 0, 0, NOW(), NOW()),
(120, 4, '508', 'MZ', 'MOZ', 0, 0, NOW(), NOW()),
(121, 4, '516', 'NA', 'NAM', 0, 0, NOW(), NOW()),
(122, 5, '520', 'NR', 'NRU', 0, 0, NOW(), NOW()),
(123, 5, '524', 'NP', 'NPL', 0, 0, NOW(), NOW()),
(124, 5, '558', 'NI', 'NIC', 0, 0, NOW(), NOW()),
(125, 4, '562', 'NE', 'NER', 0, 0, NOW(), NOW()),
(126, 4, '566', 'NG', 'NGA', 0, 0, NOW(), NOW()),
(127, NULL, '570', 'NU', 'NIU', 0, 0, NOW(), NOW()),
(128, NULL, '578', 'NO', 'NOR', 0, 0, NOW(), NOW()),
(129, NULL, '554', 'NZ', 'NZL', 0, 0, NOW(), NOW()),
(130, NULL, '512', 'OM', 'OMN', 0, 0, NOW(), NOW()),
(131, NULL, '800', 'UG', 'UGA', 0, 0, NOW(), NOW()),
(132, NULL, '860', 'UZ', 'UZB', 0, 0, NOW(), NOW()),
(133, NULL, '586', 'PK', 'PAK', 0, 0, NOW(), NOW()),
(134, NULL, '591', 'PA', 'PAN', 0, 0, NOW(), NOW()),
(135, NULL, '598', 'PG', 'PNG', 0, 0, NOW(), NOW()),
(136, NULL, '600', 'PY', 'PRY', 0, 0, NOW(), NOW()),
(137, NULL, '528', 'NL', 'NLD', 0, 0, NOW(), NOW()),
(138, NULL, '604', 'PE', 'PER', 0, 0, NOW(), NOW()),
(139, NULL, '608', 'PH', 'PHL', 0, 0, NOW(), NOW()),
(140, NULL, '616', 'PL', 'POL', 0, 0, NOW(), NOW()),
(141, NULL, '620', 'PT', 'PRT', 0, 0, NOW(), NOW()),
(142, NULL, '634', 'QA', 'QAT', 0, 0, NOW(), NOW()),
(143, NULL, '140', 'CF', 'CAF', 0, 0, NOW(), NOW()),
(144, NULL, '214', 'DO', 'DOM', 0, 0, NOW(), NOW()),
(145, NULL, '203', 'CZ', 'CZE', 0, 0, NOW(), NOW()),
(146, NULL, '642', 'RO', 'ROU', 0, 0, NOW(), NOW()),
(147, NULL, '826', 'GB', 'GBR', 0, 0, NOW(), NOW()),
(148, NULL, '643', 'RU', 'RUS', 0, 0, NOW(), NOW()),
(149, NULL, '646', 'RW', 'RWA', 0, 0, NOW(), NOW()),
(150, NULL, '659', 'KN', 'KNA', 0, 0, NOW(), NOW()),
(151, NULL, '662', 'LC', 'LCA', 0, 0, NOW(), NOW()),
(152, NULL, '674', 'SM', 'SMR', 0, 0, NOW(), NOW()),
(153, NULL, '670', 'VC', 'VCT', 0, 0, NOW(), NOW()),
(154, NULL, '90', 'SB', 'SLB', 0, 0, NOW(), NOW()),
(128, 3, '578', 'NO', 'NOR', 0, 0, NOW(), NOW()),
(129, 5, '554', 'NZ', 'NZL', 0, 0, NOW(), NOW()),
(130, 4, '512', 'OM', 'OMN', 0, 0, NOW(), NOW()),
(131, 4, '800', 'UG', 'UGA', 0, 0, NOW(), NOW()),
(132, 5, '860', 'UZ', 'UZB', 0, 0, NOW(), NOW()),
(133, 5, '586', 'PK', 'PAK', 0, 0, NOW(), NOW()),
(134, 5, '591', 'PA', 'PAN', 0, 0, NOW(), NOW()),
(135, 5, '598', 'PG', 'PNG', 0, 0, NOW(), NOW()),
(136, 5, '600', 'PY', 'PRY', 0, 0, NOW(), NOW()),
(137, 2, '528', 'NL', 'NLD', 0, 0, NOW(), NOW()),
(138, 5, '604', 'PE', 'PER', 0, 0, NOW(), NOW()),
(139, 5, '608', 'PH', 'PHL', 0, 0, NOW(), NOW()),
(140, 2, '616', 'PL', 'POL', 0, 0, NOW(), NOW()),
(141, 2, '620', 'PT', 'PRT', 0, 0, NOW(), NOW()),
(142, 4, '634', 'QA', 'QAT', 0, 0, NOW(), NOW()),
(143, 4, '140', 'CF', 'CAF', 0, 0, NOW(), NOW()),
(144, 5, '214', 'DO', 'DOM', 0, 0, NOW(), NOW()),
(145, 2, '203', 'CZ', 'CZE', 0, 0, NOW(), NOW()),
(146, 2, '642', 'RO', 'ROU', 0, 0, NOW(), NOW()),
(147, 2, '826', 'GB', 'GBR', 0, 0, NOW(), NOW()),
(148, 3, '643', 'RU', 'RUS', 0, 0, NOW(), NOW()),
(149, 4, '646', 'RW', 'RWA', 0, 0, NOW(), NOW()),
(150, 5, '659', 'KN', 'KNA', 0, 0, NOW(), NOW()),
(151, 5, '662', 'LC', 'LCA', 0, 0, NOW(), NOW()),
(152, 2, '674', 'SM', 'SMR', 0, 0, NOW(), NOW()),
(153, 5, '670', 'VC', 'VCT', 0, 0, NOW(), NOW()),
(154, 5, '90', 'SB', 'SLB', 0, 0, NOW(), NOW()),
(155, NULL, '222', 'SV', 'SLV', 0, 0, NOW(), NOW()),
(156, NULL, '882', 'WS', 'WSM', 0, 0, NOW(), NOW()),
(157, NULL, '678', 'ST', 'STP', 0, 0, NOW(), NOW()),
(158, NULL, '686', 'SN', 'SEN', 0, 0, NOW(), NOW()),
(159, NULL, '690', 'SC', 'SYC', 0, 0, NOW(), NOW()),
(160, NULL, '694', 'SL', 'SLE', 0, 0, NOW(), NOW()),
(161, NULL, '702', 'SG', 'SGP', 0, 0, NOW(), NOW()),
(162, NULL, '703', 'SK', 'SVK', 0, 0, NOW(), NOW()),
(163, NULL, '705', 'SI', 'SVN', 0, 0, NOW(), NOW()),
(164, NULL, '706', 'SO', 'SOM', 0, 0, NOW(), NOW()),
(165, NULL, '729', 'SD', 'SDN', 0, 0, NOW(), NOW()),
(166, NULL, '144', 'LK', 'LKA', 0, 0, NOW(), NOW()),
(167, NULL, '752', 'SE', 'SWE', 0, 0, NOW(), NOW()),
(168, NULL, '756', 'CH', 'CHE', 0, 0, NOW(), NOW()),
(169, NULL, '740', 'SR', 'SUR', 0, 0, NOW(), NOW()),
(170, NULL, '748', 'SZ', 'SWZ', 0, 0, NOW(), NOW()),
(171, NULL, '760', 'SY', 'SYR', 0, 0, NOW(), NOW()),
(172, NULL, '762', 'TJ', 'TJK', 0, 0, NOW(), NOW()),
(173, NULL, '834', 'TZ', 'TZA', 0, 0, NOW(), NOW()),
(174, NULL, '148', 'TD', 'TCD', 0, 0, NOW(), NOW()),
(175, NULL, '764', 'TH', 'THA', 0, 0, NOW(), NOW()),
(176, NULL, '768', 'TG', 'TGO', 0, 0, NOW(), NOW()),
(177, NULL, '776', 'TO', 'TON', 0, 0, NOW(), NOW()),
(178, NULL, '780', 'TT', 'TTO', 0, 0, NOW(), NOW()),
(179, NULL, '788', 'TN', 'TUN', 0, 0, NOW(), NOW()),
(180, NULL, '795', 'TM', 'TKM', 0, 0, NOW(), NOW()),
(181, NULL, '792', 'TR', 'TUR', 0, 0, NOW(), NOW()),
(182, NULL, '798', 'TV', 'TUV', 0, 0, NOW(), NOW()),
(183, NULL, '804', 'UA', 'UKR', 0, 0, NOW(), NOW()),
(184, NULL, '858', 'UY', 'URY', 0, 0, NOW(), NOW()),
(185, NULL, '336', 'VA', 'VAT', 0, 0, NOW(), NOW()),
(186, NULL, '548', 'VU', 'VUT', 0, 0, NOW(), NOW()),
(187, NULL, '862', 'VE', 'VEN', 0, 0, NOW(), NOW()),
(188, NULL, '704', 'VN', 'VNM', 0, 0, NOW(), NOW()),
(189, NULL, '887', 'YE', 'YEM', 0, 0, NOW(), NOW()),
(190, NULL, '807', 'MK', 'MKD', 0, 0, NOW(), NOW()),
(191, NULL, '180', 'CD', 'COD', 0, 0, NOW(), NOW()),
(192, NULL, '894', 'ZM', 'ZMB', 0, 0, NOW(), NOW()),
(193, NULL, '716', 'ZW', 'ZWE', 0, 0, NOW(), NOW()),
(196, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(197, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(198, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(199, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(200, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(201, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(202, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(203, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(204, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(205, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(206, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(207, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(208, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(209, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(210, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(211, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(212, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(213, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(214, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(215, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(216, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(217, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(218, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(219, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(220, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(221, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(222, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(223, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(224, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(225, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(226, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(227, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(228, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(229, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(230, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(231, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(232, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(233, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(234, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(235, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(236, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(237, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(238, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(239, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(240, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(241, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(242, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(243, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(244, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(245, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(246, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(247, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(248, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(249, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(250, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(251, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(252, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(253, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(254, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(255, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(256, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(257, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(258, NULL, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(259, NULL, '312', 'GP', 'GLP', 0, 0, NOW(), NOW()),
(260, NULL, '254', 'GF', 'GUF', 0, 0, NOW(), NOW()),
(261, NULL, '474', 'MQ', 'MTQ', 0, 0, NOW(), NOW()),
(262, NULL, '175', 'YT', 'MYT', 0, 0, NOW(), NOW()),
(263, NULL, '638', 'RE', 'REU', 0, 0, NOW(), NOW()),
(264, NULL, '666', 'PM', 'SPM', 0, 0, NOW(), NOW()),
(265, NULL, '540', 'NC', 'NCL', 0, 0, NOW(), NOW()),
(266, NULL, '258', 'PF', 'PYF', 0, 0, NOW(), NOW()),
(267, NULL, '876', 'WF', 'WLF', 0, 0, NOW(), NOW()),
(268, NULL, '840', 'US', 'USA', 0, 0, NOW(), NOW());
(156, 5, '882', 'WS', 'WSM', 0, 0, NOW(), NOW()),
(157, 4, '678', 'ST', 'STP', 0, 0, NOW(), NOW()),
(158, 4, '686', 'SN', 'SEN', 0, 0, NOW(), NOW()),
(159, 4, '690', 'SC', 'SYC', 0, 0, NOW(), NOW()),
(160, 4, '694', 'SL', 'SLE', 0, 0, NOW(), NOW()),
(161, 5, '702', 'SG', 'SGP', 0, 0, NOW(), NOW()),
(162, 2, '703', 'SK', 'SVK', 0, 0, NOW(), NOW()),
(163, 2, '705', 'SI', 'SVN', 0, 0, NOW(), NOW()),
(164, 4, '706', 'SO', 'SOM', 0, 0, NOW(), NOW()),
(165, 4, '729', 'SD', 'SDN', 0, 0, NOW(), NOW()),
(166, 5, '144', 'LK', 'LKA', 0, 0, NOW(), NOW()),
(167, 2, '752', 'SE', 'SWE', 0, 0, NOW(), NOW()),
(168, 2, '756', 'CH', 'CHE', 0, 0, NOW(), NOW()),
(169, 5, '740', 'SR', 'SUR', 0, 0, NOW(), NOW()),
(170, 4, '748', 'SZ', 'SWZ', 0, 0, NOW(), NOW()),
(171, 4, '760', 'SY', 'SYR', 0, 0, NOW(), NOW()),
(172, 5, '762', 'TJ', 'TJK', 0, 0, NOW(), NOW()),
(173, 5, '834', 'TZ', 'TZA', 0, 0, NOW(), NOW()),
(174, 4, '148', 'TD', 'TCD', 0, 0, NOW(), NOW()),
(175, 5, '764', 'TH', 'THA', 0, 0, NOW(), NOW()),
(176, 4, '768', 'TG', 'TGO', 0, 0, NOW(), NOW()),
(177, 5, '776', 'TO', 'TON', 0, 0, NOW(), NOW()),
(178, 5, '780', 'TT', 'TTO', 0, 0, NOW(), NOW()),
(179, 3, '788', 'TN', 'TUN', 0, 0, NOW(), NOW()),
(180, 5, '795', 'TM', 'TKM', 0, 0, NOW(), NOW()),
(181, 3, '792', 'TR', 'TUR', 0, 0, NOW(), NOW()),
(182, 5, '798', 'TV', 'TUV', 0, 0, NOW(), NOW()),
(183, 2, '804', 'UA', 'UKR', 0, 0, NOW(), NOW()),
(184, 5, '858', 'UY', 'URY', 0, 0, NOW(), NOW()),
(185, 2, '336', 'VA', 'VAT', 0, 0, NOW(), NOW()),
(186, 5, '548', 'VU', 'VUT', 0, 0, NOW(), NOW()),
(187, 5, '862', 'VE', 'VEN', 0, 0, NOW(), NOW()),
(188, 5, '704', 'VN', 'VNM', 0, 0, NOW(), NOW()),
(189, 4, '887', 'YE', 'YEM', 0, 0, NOW(), NOW()),
(191, 4, '180', 'CD', 'COD', 0, 0, NOW(), NOW()),
(192, 4, '894', 'ZM', 'ZMB', 0, 0, NOW(), NOW()),
(193, 4, '716', 'ZW', 'ZWE', 0, 0, NOW(), NOW()),
(196, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(197, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(198, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(199, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(200, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(201, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(202, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(203, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(204, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(205, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(206, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(207, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(208, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(209, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(210, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(211, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(212, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(213, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(214, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(215, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(216, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(217, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(218, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(219, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(220, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(221, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(222, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(223, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(224, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(225, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(226, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(227, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(228, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(229, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(230, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(231, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(232, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(233, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(234, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(235, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(236, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(237, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(238, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(239, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(240, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(241, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(242, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(243, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(244, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(245, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW()),
(246, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(247, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(248, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(249, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(250, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(251, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(252, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(253, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(254, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(255, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(256, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(257, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(258, 4, '124', 'CA', 'CAN', 0, 0, NOW(), NOW()),
(259, 6, '312', 'GP', 'GLP', 0, 0, NOW(), NOW()),
(260, 6, '254', 'GF', 'GUF', 0, 0, NOW(), NOW()),
(261, 6, '474', 'MQ', 'MTQ', 0, 0, NOW(), NOW()),
(262, 6, '175', 'YT', 'MYT', 0, 0, NOW(), NOW()),
(263, 6, '638', 'RE', 'REU', 0, 0, NOW(), NOW()),
(264, 6, '666', 'PM', 'SPM', 0, 0, NOW(), NOW()),
(265, 7, '540', 'NC', 'NCL', 0, 0, NOW(), NOW()),
(266, 7, '258', 'PF', 'PYF', 0, 0, NOW(), NOW()),
(267, 7, '876', 'WF', 'WLF', 0, 0, NOW(), NOW()),
(268, 4, '840', 'US', 'USA', 0, 0, NOW(), NOW());
INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES
(1, 'en_US', 'Afghanistan', '', '', ''),
@@ -423,7 +423,7 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
(18, 'fr_FR', 'Barbade', '', '', ''),
(19, 'en_US', 'Belarus', '', '', ''),
(19, 'es_ES', 'Belarús', '', '', ''),
(19, 'fr_FR', 'Belau', '', '', ''),
(19, 'fr_FR', 'Belarus', '', '', ''),
(20, 'en_US', 'Belgium', '', '', ''),
(20, 'es_ES', 'Bélgica', '', '', ''),
(20, 'fr_FR', 'Belgique', '', '', ''),

View File

@@ -0,0 +1,87 @@
<div class="row">
<div class="col-md-12">
<div class="alert alert-info">
<p>{intl l="Colissimo Module allows to send your products all around the world with La Poste."}</p>
</div>
<div class="alert alert-danger">
<p>{intl l="Prices are not dynamically editable yet."}</p>
<p>{intl l="Prices below can be edited in local/modules/Colissimo/Config/prices.json file."}</p>
</div>
<div class="general-block-decorator">
{loop type="area" name="list area" backend_context=true}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl l="Area : "}{$NAME}
{loop type="auth" name="can_create" role="ADMIN" module="colissimo" access="CREATE"}
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new price slice'}" href="#price_slice_create_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus"></span>
</a>
{/loop}
</caption>
<thead>
<tr>
<th class="col-md-3">{intl l="Weight lower than ... (kg)"}</th>
<th class="col-md-5">{intl l="Price (€)"}</th>
<th class="col-md-1">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop type="colissimo" name="colissimo" area=$ID}
<tr>
<td>{$MAX_WEIGHT}</td>
<td>{$PRICE}</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" role="ADMIN" module="colissimo" access="UPDATE"}
<a class="btn btn-default btn-xs" title="{intl l='Delete this price slice'}" href="#price_slice_delete_dialog" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
{/loop}
</div>
</div>
</div>
{* -- Add price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "price_slice_create_dialog"
dialog_title = {intl l="Create a price slice"}
dialog_body = "Not available yet."
dialog_ok_label = {intl l="Create"}
dialog_cancel_label = {intl l="Cancel"}
}
{* -- Delete price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_delete_dialog"
dialog_title = {intl l="Delete a price slice"}
dialog_message = "Not available yet."
dialog_ok_label = {intl l="Delete"}
dialog_cancel_label = {intl l="Cancel"}
}
<script type="text/javascript">
jQuery(function($) {
})
</script>

View File

@@ -25,6 +25,7 @@ namespace Colissimo;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Exception\OrderException;
use Thelia\Model\Country;
use Thelia\Module\BaseModule;
use Thelia\Module\DeliveryModuleInterface;
@@ -34,6 +35,58 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
protected $request;
protected $dispatcher;
private static $prices = null;
const JSON_PRICE_RESOURCE = "prices.json";
public static function getPrices()
{
if(null === self::$prices) {
self::$prices = json_decode(file_get_contents(sprintf('%s/Config/%s', __DIR__, self::JSON_PRICE_RESOURCE)), true);
}
return self::$prices;
}
/**
* @param $areaId
* @param $weight
*
* @return mixed
* @throws \Thelia\Exception\OrderException
*/
public static function getPostageAmount($areaId, $weight)
{
$prices = self::getPrices();
/* check if Colissimo delivers the asked area */
if(!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new OrderException("Colissimo delivery unavailable for the chosen delivery country", OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* check this weight is not too much */
end($areaPrices);
$maxWeight = key($areaPrices);
if($weight > $maxWeight) {
throw new OrderException(sprintf("Colissimo delivery unavailable for this cart weight (%s kg)", $weight), OrderException::DELIVERY_MODULE_UNAVAILABLE);
}
$postage = current($areaPrices);
while(prev($areaPrices)) {
if($weight > key($areaPrices)) {
break;
}
$postage = current($areaPrices);
}
return $postage;
}
public function setRequest(Request $request)
{
$this->request = $request;
@@ -60,11 +113,18 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
*
* @param Country $country
* @return mixed
* @throws \Thelia\Exception\OrderException
*/
public function getPostage(Country $country)
{
// TODO: Implement getPostage() method.
return 2;
$cartWeight = $this->getContainer()->get('request')->getSession()->getCart()->getWeight();
$postage = self::getPostageAmount(
$country->getAreaId(),
$cartWeight
);
return $postage;
}
public function getCode()

View File

@@ -5,9 +5,7 @@
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<!-- sample definition
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
-->
<loop class="Colissimo\Loop\Price" name="colissimo"/>
</loops>
<forms>

View File

@@ -0,0 +1,128 @@
{
"1": {
"_info": "area 1 : France",
"slices": {
"0.25": 5.23,
"0.5": 5.8,
"0.75": 6.56,
"1": 7.13,
"2": 8.08,
"3": 9.22,
"5": 11.31,
"7": 13.4,
"10": 16.53,
"15": 19.14,
"30": 26.93
}
},
"2": {
"_info": "area 2 : A Zone - Union Européenne et Suisse",
"slices": {
"1": 15.34,
"2": 16.96,
"3": 20.47,
"4": 23.99,
"5": 27.5,
"6": 31.02,
"7": 34.53,
"8": 38.05,
"9": 41.56,
"10": 45.08,
"15": 51.92,
"20": 58.76,
"25": 65.6,
"30": 72.44
}
},
"3": {
"_info": "area 3 : B Zone - Pays de lEurope de lEst (hors Union Européenne), Norvège, Maghreb",
"slices": {
"1": 18.81,
"2": 20.62,
"3": 24.94,
"4": 29.26,
"5": 33.58,
"6": 37.91,
"7": 42.23,
"8": 46.55,
"9": 50.87,
"10": 55.2,
"15": 65.08,
"20": 74.96
}
},
"4": {
"_info": "area 4 : C Zone - Pays dAfrique hors Maghreb, Canada, Etats-Unis, Proche et Moyen Orient",
"slices": {
"1": 22.04,
"2": 29.55,
"3": 38.86,
"4": 48.17,
"5": 57.48,
"6": 66.79,
"7": 76.1,
"8": 85.41,
"9": 94.72,
"10": 104.03,
"15": 126.92,
"20": 149.82
}
},
"5": {
"_info": "area 5 : D Zone - Autres destinations",
"slices": {
"1": 25.08,
"2": 37.72,
"3": 50.26,
"4": 62.8,
"5": 75.34,
"6": 87.88,
"7": 100.42,
"8": 112.96,
"9": 125.5,
"10": 138.04,
"15": 162.74,
"20": 187.44
}
},
"6": {
"_info": "area 6 : France OM1",
"slices": {
"0.5": 8.27,
"1": 12.49,
"2": 17.05,
"3": 21.61,
"4": 26.17,
"5": 30.73,
"6": 35.29,
"7": 39.85,
"8": 44.41,
"9": 48.97,
"10": 53.53,
"15": 76.33,
"20": 99.13,
"25": 121.93,
"30": 144.73
}
},
"7": {
"_info": "area 7 : France OM2",
"slices": {
"0.5": 9.88,
"1": 14.92,
"2": 26.32,
"3": 37.72,
"4": 49.12,
"5": 60.52,
"6": 71.92,
"7": 83.32,
"8": 94.72,
"9": 106.12,
"10": 117.52,
"15": 174.52,
"20": 231.52,
"25": 288.52,
"30": 345.52
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Colissimo\Loop;
use Colissimo\Colissimo;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
/**
*
* Price loop
*
*
* Class Price
* @package Colissimo\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class Price extends BaseLoop implements ArraySearchLoopInterface
{
/* set countable to false since we need to preserve keys */
protected $countable = false;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('area', null, true)
);
}
public function buildArray()
{
$area = $this->getArea();
$prices = Colissimo::getPrices();
if(!isset($prices[$area]) || !isset($prices[$area]["slices"])) {
return array();
}
$areaPrices = $prices[$area]["slices"];
ksort($areaPrices);
return $areaPrices;
}
public function parseResults(LoopResult $loopResult)
{
foreach ($loopResult->getResultDataCollection() as $maxWeight => $price) {
$loopResultRow = new LoopResultRow();
$loopResultRow->set("MAX_WEIGHT", $maxWeight)
->set("PRICE", $price);
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -43,7 +43,7 @@
{loop type="auth" name="can_change" role="ADMIN" module=$CODE access="VIEW"}
<a class="btn btn-primary btn-xs" title="{intl l='Configure this module'}" href="{url path="/admin/module/update/$CODE"}">{intl l="Configure"}</a>
<a class="btn btn-primary btn-xs" title="{intl l='Configure this module'}" href="{url path="/admin/module/$CODE"}">{intl l="Configure"}</a>
{/loop}
{*loop type="auth" name="can_change" role="ADMIN" resource="admin.modules" access="VIEW"}

View File

@@ -0,0 +1,25 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Modules'}{/block}
{block name="check-resource"}admin.module{/block}
{block name="check-access"}view{/block}
{block name="main-content"}
<div class="modules-configure">
<div id="wrapper" class="container">
<div class="clearfix">
<ul class="breadcrumb pull-left">
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
<li><a href="{url path='/admin/modules'}">{intl l="Modules"}</a></li>
<li><a href="#">{intl l="Configure"} : {loop type="module" name="module-name" code=$module_code}{$CODE} - {$TITLE}{/loop}</a></li>
</ul>
</div>
{module_include location='module_configuration' module=$module_code}
</div>
</div>
{/block}