Correction d'un bogue sur CadeauBienvenue

This commit is contained in:
2021-04-19 11:26:03 +02:00
parent d3744ef887
commit 928b426195
47 changed files with 13 additions and 2368 deletions

View File

@@ -991,7 +991,7 @@ function generateCouponFixtures(\Thelia\Core\Thelia $thelia)
/** @var $container ContainerInterface Service Container */ /** @var $container ContainerInterface Service Container */
$container = $thelia->getContainer(); $container = $thelia->getContainer();
/** @var FacadeInterface $adapter */ /** @var FacadeInterface $adapter */
$adapter = $container->get('thelia.facade');w $adapter = $container->get('thelia.facade');
// Coupons // Coupons
$coupon1 = new Thelia\Model\Coupon(); $coupon1 = new Thelia\Model\Coupon();

View File

@@ -1,14 +1,4 @@
<?php <?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CadeauBienvenue; namespace CadeauBienvenue;

View File

@@ -9,9 +9,9 @@ use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Mailer\MailerFactory; use Thelia\Mailer\MailerFactory;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Log\Tlog;
class NewCustomerListener implements EventSubscriberInterface class NewCustomerListener implements EventSubscriberInterface
@@ -35,7 +35,7 @@ class NewCustomerListener implements EventSubscriberInterface
{ {
return array( return array(
TheliaEvents::CUSTOMER_CREATEACCOUNT => array( TheliaEvents::CUSTOMER_CREATEACCOUNT => array(
'createAccount', 100 'createCadeauBienvenue', 100
), ),
); );
} }
@@ -45,7 +45,7 @@ class NewCustomerListener implements EventSubscriberInterface
* @param $eventName * @param $eventName
* @param EventDispatcherInterface $dispatcher * @param EventDispatcherInterface $dispatcher
*/ */
public function createAccount(CustomerCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher) public function createCadeauBienvenue(CustomerCreateOrUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{ {
$customer = $event->getCustomer(); $customer = $event->getCustomer();
@@ -82,9 +82,10 @@ class NewCustomerListener implements EventSubscriberInterface
[ [
'customer_id' => $customer->getId(), 'customer_id' => $customer->getId(),
'montant' => $discountAmount, 'montant' => $discountAmount,
'date_validite' => $dateExpiration,
'code_promo' => $couponCode 'code_promo' => $couponCode
] ]
); );
Tlog::getInstance()->debug("Coupon de bienvenue envoyé à cette adresse email : " . $customer->getEmail());
} }
} }

View File

@@ -15,9 +15,8 @@
{block name="email-content"} {block name="email-content"}
{loop type="customer" name="client" current="false" id=$customer_id limit=1}<p>Bonjour {$FIRSTNAME} {$LASTNAME},</p>{/loop} {loop type="customer" name="client" current="false" id=$customer_id limit=1}<p>Bonjour {$FIRSTNAME} {$LASTNAME},</p>{/loop}
<p>Pour fêter votre arrivée sur notre site {config key="store_name"} et vous remercier de votre inscription, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès maintenant !</p> <p>Pour fêter votre arrivée sur notre site {config key="store_name"} et vous remercier de votre inscription, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès maintenant et <b>sans limite de temps</b> !</p><br>
<p>Ce bon est valable jusqu'au {format_date date={$date_validite} output="date"}.<br> <p>Pour utiliser ce bon, il vous suffira de saisir le code <b>{$code_promo}</b> lors de l'étape 3 de votre prochaine commande.</p>
Pour l'utiliser, il vous suffira de saisir le code <b>{$code_promo}</b> lors de l'étape 3 de votre prochaine commande.</p>
<p>Rendez-vous très bientôt sur <a href="{url path='/'}">{url path="/"}</a></p> <p>Rendez-vous très bientôt sur <a href="{url path='/'}">{url path="/"}</a></p>
<p>Très cordialement,</p> <p>Très cordialement,</p>
<p>{config key="store_name"}</p> <p>{config key="store_name"}</p>

View File

@@ -1,9 +1,8 @@
{loop type="customer" name="client" current="false" id=$customer_id limit=1}Bonjour {$FIRSTNAME} {$LASTNAME},{/loop} {loop type="customer" name="client" current="false" id=$customer_id limit=1}Bonjour {$FIRSTNAME} {$LASTNAME},{/loop}
Pour fêter votre arrivée sur notre site {config key="store_name"} et vous remercier de votre inscription, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès à présent ! Pour fêter votre arrivée sur notre site {config key="store_name"} et vous remercier de votre inscription, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès à présent et sans limite de temps !
Ce bon est valable jusqu'au {format_date date={$date_validite} output="date"}. Pour utiliser ce bon, il vous suffira de saisir le code {$code_promo} lors de l'étape 3 de votre prochaine commande.
Pour l'utiliser, il vous suffira de saisir le code {$code_promo} lors de l'étape 3 de votre prochaine commande.
Rendez-vous très bientôt sur {url path="/"} Rendez-vous très bientôt sur {url path="/"}

View File

@@ -1,179 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
/*************************************************************************************/
namespace Colissimo;
use Colissimo\Model\Config\ColissimoConfigValue;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Install\Database;
use Thelia\Model\Country;
use Thelia\Model\State;
use Thelia\Module\AbstractDeliveryModule;
use Thelia\Module\AbstractDeliveryModuleWithState;
use Thelia\Module\Exception\DeliveryException;
class Colissimo extends AbstractDeliveryModuleWithState
{
protected $request;
protected $dispatcher;
private static $prices = null;
const JSON_PRICE_RESOURCE = "/Config/prices.json";
const DOMAIN_NAME = 'colissimo';
public static function getPrices()
{
if (null === self::$prices) {
self::$prices = json_decode(Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null), true);
}
return self::$prices;
}
public function postActivation(ConnectionInterface $con = null)
{
self::setConfigValue(ColissimoConfigValue::ENABLED, 1);
$database = new Database($con);
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
}
public function isValidDelivery(Country $country, State $state = null)
{
if (0 == self::getConfigValue(ColissimoConfigValue::ENABLED, 1)) {
return false;
}
if (null !== $area = $this->getAreaForCountry($country, $state)) {
$areaId = $area->getId();
$prices = self::getPrices();
/* Check if Colissimo delivers the area */
if (isset($prices[$areaId]) && isset($prices[$areaId]["slices"])) {
// Yes ! Check if the cart weight is below slice limit
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* Check cart weight is below the maximum weight */
end($areaPrices);
$maxWeight = key($areaPrices);
$cartWeight = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getWeight();
if ($cartWeight <= $maxWeight) {
return true;
}
}
}
return false;
}
/**
* @param $areaId
* @param $weight
*
* @return mixed
* @throws \Thelia\Exception\OrderException
*/
public static function getPostageAmount($areaId, $weight)
{
$freeshipping = Colissimo::getConfigValue(ColissimoConfigValue::FREE_SHIPPING);
$postage = 0;
if (!$freeshipping) {
$prices = self::getPrices();
/* check if Colissimo delivers the asked area */
if (!isset($prices[$areaId]) || !isset($prices[$areaId]["slices"])) {
throw new DeliveryException(
Translator::getInstance()->trans(
"Colissimo delivery unavailable for the delivery country",
[],
self::DOMAIN_NAME
)
);
}
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
/* Check cart weight is below the maximum weight */
end($areaPrices);
$maxWeight = key($areaPrices);
if ($weight > $maxWeight) {
throw new DeliveryException(
Translator::getInstance()->trans(
"Colissimo delivery unavailable for this cart weight (%weight kg)",
array("%weight" => $weight),
self::DOMAIN_NAME
)
);
}
$postage = current($areaPrices);
while (prev($areaPrices)) {
if ($weight > key($areaPrices)) {
break;
}
$postage = current($areaPrices);
}
}
return $postage;
}
/**
*
* calculate and return delivery price
*
* @param Country $country
* @param State $state
* @return mixed
*/
public function getPostage(Country $country, State $state = null)
{
$cartWeight = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getWeight();
$postage = self::getPostageAmount(
$this->getAreaForCountry($country, $state)->getId(),
$cartWeight
);
return $postage;
}
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
$uploadDir = __DIR__ . '/Config/prices.json';
$database = new Database($con);
$tableExists = $database->execute("SHOW TABLES LIKE 'colissimo_freeshipping'")->rowCount();
if (Colissimo::getConfigValue(ColissimoConfigValue::FREE_SHIPPING, null) == null && $tableExists) {
$result = $database->execute('SELECT active FROM colissimo_freeshipping WHERE id=1')->fetch()["active"];
Colissimo::setConfigValue(ColissimoConfigValue::FREE_SHIPPING, $result);
$database->execute("DROP TABLE `colissimo_freeshipping`");
}
if (is_readable($uploadDir) && Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null) == null) {
Colissimo::setConfigValue(ColissimoConfigValue::PRICES, file_get_contents($uploadDir));
}
}
}

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<loops>
<loop class="Colissimo\Loop\Price" name="colissimo"/>
<loop class="Colissimo\Loop\CheckRightsLoop" name="colissimo.check.rights" />
<loop class="Colissimo\Loop\NotSendLoop" name="colissimo.notsend.loop" />
</loops>
<forms>
<form name="colissimo.freeshipping.form" class="Colissimo\Form\FreeShipping" />
<form name="colissimo.export.form" class="Colissimo\Form\Export" />
<form name="colissimo.configuration" class="Colissimo\Form\Configuration" />
</forms>
<services>
<service id="send.colissimo.mail" class="Colissimo\Listener\SendMail">
<argument type="service" id="thelia.parser" />
<argument type="service" id="mailer"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
<services>
<service id="area.deleted.listener" class="Colissimo\EventListener\AreaDeletedListener" scope="request">
<tag name="kernel.event_subscriber"/>
<argument type="service" id="request" />
</service>
</services>
<hooks>
<hook id="colissimo.hook" class="Colissimo\Hook\HookManager">
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfiguration" />
<tag name="hook.event_listener" event="module.config-js" type="back" templates="render:assets/js/module-configuration-js.html" />
</hook>
</hooks>
</config>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module>
<fullnamespace>Colissimo\Colissimo</fullnamespace>
<descriptive locale="en_US">
<title>Colissimo delivery</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Livraison par Colissimo</title>
</descriptive>
<version>2.4.3</version>
<author>
<name>Manuel Raynaud</name>
<email>manu@raynaud.io</email>
</author>
<type>delivery</type>
<thelia>2.4.3</thelia>
<stability>alpha</stability>
</module>

View File

@@ -1,64 +0,0 @@
{"1": {
"_info": "area 1 : France",
"slices": {
"0.25": 5.23,
"0.5": 6.13,
"0.75": 6.89,
"1": 7.51,
"2": 8.50,
"5": 10.93,
"10": 15.68,
"30": 23.28
}
}, "2": {
"_info": "area 2 : A Zone - Union Europ\u00e9enne et Suisse",
"slices": {
"0.5": 11.54,
"1": 14.11,
"2": 15.68,
"5": 20.14,
"10": 33.25,
"20": 55.10,
"30": 55.10
}
}, "3": {
"_info": "area 3 : B Zone - Pays de l\u2019Europe de l\u2019Est (hors Union Europ\u00e9enne et Russie), Norv\u00e8ge, Maghreb",
"slices": {
"0.5": 15.39,
"1": 18.38,
"2": 20.00,
"5": 25.65,
"10": 42.75,
"20": 66.50
}
}, "4": {
"_info": "area 4 : C Zone - Autres destinations",
"slices": {
"0.5": 22.52,
"1": 24.99,
"2": 34.30,
"5": 50.35,
"10": 95.00,
"20": 152.00
}
}, "5": {
"_info": "area 5 : France OM1",
"slices": {
"0.5": 8.69,
"1": 13.16,
"2": 17.96,
"5": 26.60,
"10": 42.75,
"30": 95.95
}
}, "6": {
"_info": "area 6 : France OM2",
"slices": {
"0.5": 10.40,
"1": 15.72,
"2": 27.74,
"5": 46.08,
"10": 90.25,
"30": 237.50
}
}}

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="colissimo.edit.prices" path="/admin/module/colissimo/prices" methods="post">
<default key="_controller">Colissimo\Controller\EditPrices::editprices</default>
</route>
<route id="colissimo.edit.freeshipping" path="/admin/module/colissimo/freeshipping" methods="post">
<default key="_controller">Colissimo\Controller\FreeShipping::set</default>
</route>
<route id="colissimo.export" path="/admin/module/colissimo/export" methods="post">
<default key="_controller">Colissimo\Controller\Export::exportAction</default>
</route>
<route id="colissimo.configuration" path="/admin/module/colissimo/configuration/update" methods="post">
<default key="_controller">Colissimo\Controller\Configuration::editConfiguration</default>
</route>
</routes>

View File

@@ -1,32 +0,0 @@
# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- Mail templates for colissimo
-- ---------------------------------------------------------------------
-- First, delete existing entries
SET @var := 0;
SELECT @var := `id` FROM `message` WHERE name="mail_colissimo";
DELETE FROM `message` WHERE `id`=@var;
-- Try if ON DELETE constraint isn't set
DELETE FROM `message_i18n` WHERE `id`=@var;
-- Then add new entries
SELECT @max := MAX(`id`) FROM `message`;
SET @max := @max+1;
-- insert message
INSERT INTO `message` (`id`, `name`, `secured`) VALUES
(@max,
'mail_colissimo',
'0'
);
-- and template fr_FR
INSERT INTO `message_i18n` (`id`, `locale`, `title`, `subject`, `text_message`, `html_message`) VALUES
(@max, 'en_US', 'Colissimo shipping message', 'Your order {$order_ref} has been shipped', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\nDear {$FIRSTNAME} {$LASTNAME},\r\n{/loop}\r\nThank you for your order on our online store {config key="store_name"}.\r\nYour order {$order_ref} dated {format_date date=$order_date} has been shipped on {format_date date=$update_date}.\r\nThe tracking number for this delivery is {$package}. Please check the La Poste website for tracking your parcel: www.coliposte.net.\r\nYou can use this tracking number to get your parcel in your local La Poste office. If don''t get an advice in your mailbox after two working days, claim your parcel at your local La Poste office, using this tracking number.\r\nFeel free to contact us for any forther information\r\nBest Regards.', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\n<p>Dear {$FIRSTNAME} {$LASTNAME},</p>\r\n{/loop}\r\n<p>Thank you for your order on our online store {config key="store_name"}.</p>\r\n<p>Your order {$order_ref} dated {format_date date=$order_date} has been shipped on {format_date date=$update_date}.\r\nThe tracking number for this delivery is {$package}. Please check the La Poste website for tracking your parcel: <a href="www.coliposte.net">www.coliposte.net</a>.</p>\r\n<p>You can use this tracking number to get your parcel in your local La Poste office. If don''t get an advice in your mailbox after two working days, claim your parcel at your local La Poste office, using this tracking number.</p>\r\n<p>Feel free to contact us for any forther information</p>\r\n<p>Best Regards.</p>'),
(@max, 'fr_FR', 'Message d''expédition de colissimo', 'Suivi colissimo commande : {$order_ref}', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\n{$LASTNAME} {$FIRSTNAME},\r\n{/loop}\r\nNous vous remercions de votre commande sur notre site {config key="store_name"}\r\nUn colis concernant votre commande {$order_ref} du {format_date date=$order_date} a quitté nos entrepôts pour être pris en charge par La Poste le {format_date date=$update_date}.\r\nSon numéro de suivi est le suivant : {$package}\r\nIl vous permet de suivre votre colis en ligne sur le site de La Poste : www.coliposte.net\r\nIl vous sera, par ailleurs, très utile si vous étiez absent au moment de la livraison de votre colis : en fournissant ce numéro de Colissimo Suivi, vous pourrez retirer votre colis dans le bureau de Poste le plus proche.\r\nATTENTION ! Si vous ne trouvez pas l''avis de passage normalement déposé dans votre boîte aux lettres au bout de 48 Heures jours ouvrables, n''hésitez pas à aller le réclamer à votre bureau de Poste, muni de votre numéro de Colissimo Suivi.\r\nNous restons à votre disposition pour toute information complémentaire.\r\nCordialement', '{loop type="customer" name="customer.order" current="false" id="$customer_id" backend_context="1"}\r\n{$LASTNAME} {$FIRSTNAME},\r\n{/loop}\r\nNous vous remercions de votre commande sur notre site {config key="store_name"}\r\nUn colis concernant votre commande {$order_ref} du {format_date date=$order_date} a quitté nos entrepôts pour être pris en charge par La Poste le {format_date date=$update_date}.\r\nSon numéro de suivi est le suivant : {$package}\r\nIl vous permet de suivre votre colis en ligne sur le site de La Poste : www.coliposte.net\r\nIl vous sera, par ailleurs, très utile si vous étiez absent au moment de la livraison de votre colis : en fournissant ce numéro de Colissimo Suivi, vous pourrez retirer votre colis dans le bureau de Poste le plus proche.\r\nATTENTION ! Si vous ne trouvez pas l''avis de passage normalement déposé dans votre boîte aux lettres au bout de 48 Heures jours ouvrables, n''hésitez pas à aller le réclamer à votre bureau de Poste, muni de votre numéro de Colissimo Suivi.\r\nNous restons à votre disposition pour toute information complémentaire.\r\nCordialement');
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -1,77 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Colissimo;
use Colissimo\Model\Config\ColissimoConfigValue;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Tools\URL;
/**
* Class Configuration
* @package Colissimo\Controller
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class Configuration extends BaseAdminController
{
public function editConfiguration()
{
if (null !== $response = $this->checkAuth(
AdminResources::MODULE,
[Colissimo::DOMAIN_NAME],
AccessManager::UPDATE
)) {
return $response;
}
$form = $this->createForm('colissimo.configuration');
$error_message = null;
try {
$validateForm = $this->validateForm($form);
$data = $validateForm->getData();
Colissimo::setConfigValue(
ColissimoConfigValue::ENABLED,
is_bool($data["enabled"]) ? (int) ($data["enabled"]) : $data["enabled"]
);
return $this->redirectToConfigurationPage();
} catch (FormValidationException $e) {
$error_message = $this->createStandardFormValidationErrorMessage($e);
}
if (null !== $error_message) {
$this->setupFormErrorContext(
'configuration',
$error_message,
$form
);
$response = $this->render("module-configure", ['module_code' => 'Colissimo']);
}
return $response;
}
/**
* Redirect to the configuration page
*/
protected function redirectToConfigurationPage()
{
return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Colissimo'));
}
}

View File

@@ -1,84 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Colissimo;
use Colissimo\Model\Config\ColissimoConfigValue;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Thelia\Model\AreaQuery;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Tools\URL;
/**
* Class EditPrices
* @package Colissimo\Controller
* @author Thelia <info@thelia.net>
*/
class EditPrices extends BaseAdminController
{
public function editprices()
{
// Get data & treat
$post = $this->getRequest();
$operation = $post->get('operation');
$area = $post->get('area');
$weight = $post->get('weight');
$price = $post->get('price');
if (preg_match("#^add|delete$#", $operation) &&
preg_match("#^\d+$#", $area) &&
preg_match("#^\d+\.?\d*$#", $weight)
) {
// check if area exists in db
$exists = AreaQuery::create()
->findPK($area);
if ($exists !== null) {
if (null !== $data = Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null)) {
$json_data = json_decode(
$data,
true
);
}
if ((float) $weight > 0 && $operation == "add"
&& preg_match("#\d+\.?\d*#", $price)) {
$json_data[$area]['slices'][$weight] = $price;
} elseif ($operation == "delete") {
if (isset($json_data[$area]['slices'][$weight])) {
unset($json_data[$area]['slices'][$weight]);
}
} else {
throw new \Exception("Weight must be superior to 0");
}
ksort($json_data[$area]['slices']);
Colissimo::setConfigValue(ColissimoConfigValue::PRICES, json_encode($json_data));
} else {
throw new \Exception("Area not found");
}
} else {
throw new \ErrorException("Arguments are missing or invalid");
}
return $this->redirectToConfigurationPage();
}
/**
* Redirect to the configuration page
*/
protected function redirectToConfigurationPage()
{
return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Colissimo'));
}
}

View File

@@ -1,166 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoQuery;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Colissimo\Form\Export as FormExport;
use Thelia\Core\Translation\Translator;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CustomerTitleQuery;
use Thelia\Model\OrderStatusQuery;
/**
* Class Export
* @package Colissimo\Controller
* @author Manuel Raynaud <manu@raynaud.io>
*/
class Export extends BaseAdminController
{
const DEFAULT_PHONE = "0100000000";
const DEFAULT_CELLPHONE = "0600000000";
public function exportAction()
{
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), array('Colissimo'), AccessManager::UPDATE)) {
return $response;
}
$form = new FormExport($this->getRequest());
try {
$exportForm = $this->validateForm($form);
// Get new status
$status_id = $exportForm->get('status_id')->getData();
$status = OrderStatusQuery::create()
->filterByCode($status_id)
->findOne();
// Get Colissimo orders
$orders = ColissimoQuery::getOrders()->find();
$export = "";
$store_name = ConfigQuery::getStoreName();
/** @var $order \Thelia\Model\Order */
foreach ($orders as $order) {
$value = $exportForm->get('order_'.$order->getId())->getData();
if ($value) {
// Get order information
$customer = $order->getCustomer();
$locale = $order->getLang()->getLocale();
$address = $order->getOrderAddressRelatedByDeliveryOrderAddressId();
$country = CountryQuery::create()->findPk($address->getCountryId());
$country->setLocale($locale);
$customerTitle = CustomerTitleQuery::create()->findPk($address->getCustomerTitleId());
$customerTitle->setLocale($locale);
$weight = $exportForm->get('order_weight_'.$order->getId())->getData();
if ($weight == 0) {
/** @var \Thelia\Model\OrderProduct $product */
foreach ($order->getOrderProducts() as $product) {
$weight += (double)$product->getWeight();
}
}
/**
* Get user's phone & cellphone
* First get invoice address phone,
* If empty, try to get default address' phone.
* If still empty, set default value
*/
$phone = $address->getPhone();
if (empty($phone)) {
$phone = $customer->getDefaultAddress()->getPhone();
if (empty($phone)) {
$phone = self::DEFAULT_PHONE;
}
}
// Cellphone
$cellphone = $customer->getDefaultAddress()->getCellphone();
if (empty($cellphone)) {
$cellphone = $customer->getDefaultAddress()->getCellphone();
if (empty($cellphone)) {
$cellphone = self::DEFAULT_CELLPHONE;
}
}
$export .=
"\"".$order->getRef()
."\";\"".$address->getLastname()
."\";\"".$address->getFirstname()
."\";\"".$address->getAddress1()
."\";\"".$address->getAddress2()
."\";\"".$address->getAddress3()
."\";\"".$address->getZipcode()
."\";\"".$address->getCity()
."\";\"".$country->getIsoalpha2()
."\";\"".$phone
."\";\"".$cellphone
."\";\"".$weight
."\";\"".$customer->getEmail()
."\";\"\";\"".$store_name
."\";\"DOM\";\r\n";
if ($status) {
$event = new OrderEvent($order);
$event->setStatus($status->getId());
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event);
}
}
}
return Response::create(
utf8_decode($export),
200,
array(
"Content-Encoding"=>"ISO-8889-1",
"Content-Type"=>"application/csv-tab-delimited-table",
"Content-disposition"=>"filename=export.csv"
)
);
} catch (FormValidationException $e) {
$this->setupFormErrorContext(
Translator::getInstance()->trans("colissimo expeditor export", [], Colissimo::DOMAIN_NAME),
$e->getMessage(),
$form,
$e
);
return $this->render(
"module-configure",
array(
"module_code" => "Colissimo",
)
);
}
}
}

View File

@@ -1,62 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Colissimo;
use Colissimo\Model\Config\ColissimoConfigValue;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Tools\URL;
/**
* Class FreeShipping
* @package Colissimo\Controller
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class FreeShipping extends BaseAdminController
{
public function set()
{
$response = $this->checkAuth(AdminResources::MODULE, [Colissimo::DOMAIN_NAME], AccessManager::UPDATE);
if (null !== $response) {
return $response;
}
$form = $this->createForm('colissimo.freeshipping.form');
try {
$validateForm = $this->validateForm($form);
$data = $validateForm->getData();
Colissimo::setConfigValue(ColissimoConfigValue::FREE_SHIPPING, (int) ($data["freeshipping"]));
return $this->redirectToConfigurationPage();
} catch (\Exception $e) {
$response = JsonResponse::create(array("error"=>$e->getMessage()), 500);
}
return $response;
}
/**
* Redirect to the configuration page
*/
protected function redirectToConfigurationPage()
{
return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Colissimo'));
}
}

View File

@@ -1,53 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\EventListener;
use Colissimo\Colissimo;
use Colissimo\Model\Config\ColissimoConfigValue;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Area\AreaDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
/**
* Class AreaDeletedListener
* @package AreaDeletedListener\EventListener
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class AreaDeletedListener implements EventSubscriberInterface
{
/**
* @param AreaDeleteEvent $event
*/
public function updateConfig(AreaDeleteEvent $event)
{
if (null !== $data = Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null)) {
$areaId = $event->getAreaId();
$json_data = json_decode($data, true);
unset($json_data[$areaId]);
Colissimo::setConfigValue(ColissimoConfigValue::PRICES, json_encode($json_data, true));
}
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
TheliaEvents::AREA_DELETE => [
'updateConfig', 128
]
];
}
}

View File

@@ -1,59 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Form;
use Colissimo\Colissimo;
use Colissimo\Model\Config\Base\ColissimoConfigValue;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
/**
* Class Configuration
* @package Colissimo\Form
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class Configuration extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add(
"enabled",
"checkbox",
array(
"label" => "Enabled",
"label_attr" => [
"for" => "enabled",
"help" => Translator::getInstance()->trans(
'Check if you want to activate Colissimo',
[],
Colissimo::DOMAIN_NAME
)
],
"required" => false,
"constraints" => array(
),
"value" => Colissimo::getConfigValue(ColissimoConfigValue::ENABLED, 1),
)
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "colissimo_enable";
}
}

View File

@@ -1,122 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Form;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoQuery;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
/**
* Class Export
* @package Colissimo\Form
* @author Manuel Raynaud <manu@raynaud.io>
*/
class Export extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$orders = ColissimoQuery::getOrders()
->find();
$this->formBuilder
->add(
'status_id',
'text',
[
'constraints' => [
new NotBlank(),
new Callback(
array("methods" => array(array($this, "verifyValue")))
)
],
'label' => Translator::getInstance()->trans(
'Modify status export after export',
[],
Colissimo::DOMAIN_NAME
),
'label_attr' => [
'for' => 'status_id'
]
]
);
/** @var \Thelia\Model\Order $order */
foreach ($orders as $order) {
$this->formBuilder
->add(
"order_".$order->getId(),
"checkbox",
array(
'label'=>$order->getRef(),
'label_attr'=>array(
'for'=>'export_'.$order->getId()
)
)
)
->add(
"order_nb_pkg_".$order->getId(),
'number'
)
->add(
"order_weight_".$order->getId(),
'number'
);
}
}
public function verifyValue($value, ExecutionContextInterface $context)
{
if (!preg_match("#^nochange|processing|sent$#", $value)) {
$context->addViolation(
Translator::getInstance()->trans(
'select a valid status',
[],
Colissimo::DOMAIN_NAME
)
);
}
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "colissimo_export";
}
}

View File

@@ -1,62 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Form;
use Colissimo\Colissimo;
use Colissimo\Model\Config\Base\ColissimoConfigValue;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
class FreeShipping extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$this->formBuilder
->add(
"freeshipping",
"checkbox",
array(
"label" => Translator::getInstance()->trans("Activate free shipping: ", [], Colissimo::DOMAIN_NAME),
"value" => Colissimo::getConfigValue(ColissimoConfigValue::FREE_SHIPPING, false),
)
);
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return "colissimofreeshipping";
}
}

View File

@@ -1,31 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Hook;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
/**
* Class HookManager
* @package Colissimo\Hook
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class HookManager extends BaseHook
{
public function onModuleConfiguration(HookRenderEvent $event)
{
$module_id = self::getModule()->getModuleId();
$event->add($this->render("module_configuration.html", ['module_id' => $module_id]));
}
}

View File

@@ -1,25 +0,0 @@
<?php
return [
'*If you choose this option, the exported orders would not be available on this page anymore' => '*Wenn Sie diese Option auswählen, sind die exportierten Bestellungen auf dieser Seite nicht mehr verfügbar',
'Actions' => 'Aktionen',
'An error occured' => 'Ein Fehler ist aufgetreten',
'Area : ' => 'Bereich : ',
'Cancel' => 'Abbrechen',
'Change orders status after export' => 'Status der Bestellung nach dem Export ändern',
'Colissimo Module allows to send your products all around the world with La Poste.' => 'Colissimo Modul ermöglicht, Ihre Produkte mit La Poste weltweit zu versenden.',
'Create' => 'Erstellen',
'Date' => 'Datum',
'Delete' => 'Löschen',
'Do not change' => 'Nicht ändern',
'Edit' => 'Ändern',
'Export' => 'Export',
'Please change the access rights' => 'Bitte ändern Sie die Zugriffsrechte',
'Price (€)' => 'Preis (€)',
'Processing' => 'Bearbeitung',
'REF' => 'REF',
'Sent' => 'Gesendet',
'There is currently not orders to export' => 'Es gibt derzeit keine Bestellungen, die exportiert werden können',
'Total taxed amount' => 'Gesamter besteuerter Betrag',
'Weight up to ... (kg)' => 'Gewicht bis zu ... (kg)',
];

View File

@@ -1,36 +0,0 @@
<?php
return array(
'*If you choose this option, the exported orders would not be available on this page anymore' => '*If you choose this option, the exported orders would not be available on this page anymore',
'Actions' => 'Actions',
'An error occured' => 'An error occured',
'Area : ' => 'Area : ',
'Cancel' => 'Cancel',
'Change orders status after export' => 'Change orders status after export',
'Colissimo Module allows to send your products all around the world with La Poste.' => 'Colissimo Module allows to send your products all around the world with La Poste.',
'Create' => 'Create',
'Create a new price slice' => 'Create a new price slice',
'Create a price slice' => 'Create a price slice',
'Date' => 'Date',
'Delete' => 'Delete',
'Delete a price slice' => 'Delete a price slice',
'Delete this price slice' => 'Delete this price slice',
'Do not change' => 'Do not change',
'Do you really want to delete this slice ?' => 'Do you really want to delete this slice ?',
'Edit' => 'Edit',
'Edit a price slice' => 'Edit a price slice',
'Edit this price slice' => 'Edit this price slice',
'Export' => 'Export',
'Export expeditor inet file' => 'Export expeditor inet file',
'Please change the access rights' => 'Please change the access rights',
'Price (€)' => 'Price (€)',
'Price slices' => 'Price slices',
'Processing' => 'Processing',
'REF' => 'REF',
'Sent' => 'Sent',
'There is currently not orders to export' => 'There is currently no orders to export',
'Total taxed amount' => 'Total taxed amount',
'Weight up to ... (kg)' => 'Weight up to ... (kg)',
'Number of packages' => 'Number of packages',
'Packages weight' => 'Packages weight'
);

View File

@@ -1,37 +0,0 @@
<?php
return [
'*If you choose this option, the exported orders would not be available on this page anymore' => '* Si vous choisissez cette option, les commandes exportées ne seront plus affichée sur cette page.',
'Actions' => 'Actions',
'An error occured' => 'Une erreur est survenue',
'Area : ' => 'Zone de livraison : ',
'Cancel' => 'Annuler',
'Change orders status after export' => 'Modification du statut des commande après l\'export',
'Colissimo Module allows to send your products all around the world with La Poste.' => 'Colissimo vous permet dexpédier vos colis dans le monde entier avec La Poste',
'Create' => 'Créer',
'Create a new price slice' => 'Créer une nouvelle tranche de prix',
'Create a price slice' => 'Créer une tranche de prix',
'Customer' => 'Client',
'Date' => 'Date',
'Delete' => 'Supprimer',
'Delete a price slice' => 'Supprimer une tranche de prix',
'Delete this price slice' => 'Supprimer cette tranche de prix',
'Do not change' => 'Ne pas modifier',
'Do you really want to delete this slice ?' => 'Confirmez-vous la suppression de cette tranche de prix',
'Edit' => 'Modifier',
'Edit a price slice' => 'Modifier une tranche de prix',
'Edit this price slice' => 'Modifier cette tranche de prix',
'Export' => 'Export',
'Export expeditor inet file' => 'Exporter le fichier Expeditor INET',
'Number of packages' => 'Nombre de colis',
'Packages weight' => 'Poids des colis',
'Please change the access rights' => 'Merci de modifier les droits d\'accès',
'Price (€)' => 'Prix (€)',
'Price slices' => 'Prix et poids',
'Processing' => 'Traitement',
'REF' => 'REF',
'Sent' => 'Envoyée',
'There is currently not orders to export' => 'Il n\'y a pas de commande à exporter pour le moment',
'Total taxed amount' => 'Total TTC',
'Weight up to ... (kg)' => 'Jusqu\'au poids (Kg)',
];

View File

@@ -1,13 +0,0 @@
<?php
return [
'Actions' => 'Azioni',
'Cancel' => 'Annulla',
'Create' => 'Creare',
'Date' => 'Data',
'Delete' => 'Cancellare',
'Edit' => 'Modifica',
'Export' => 'Esporta',
'Number of packages' => 'Numero di pacchetti',
'Packages weight' => 'Peso pacchi',
];

View File

@@ -1,38 +0,0 @@
<?php
return array(
'*If you choose this option, the exported orders would not be available on this page anymore' => '*Если вы выберите эту опцию, экспортированные заказы больше не будут доступны на этой странице',
'Actions' => 'Действия',
'An error occured' => 'Произошла ошибка',
'Area : ' => 'Зона :',
'Cancel' => 'Отменить',
'Change orders status after export' => 'Изменить статус заказа после экспорта',
'Colissimo Module allows to send your products all around the world with La Poste.' => 'Модуль Colissimo позволяет отсылать ваши товары по всему миру, с помощью почтовой компании Франции La Poste.',
'Create' => 'Создать',
'Create a new price slice' => 'Создать новый разрез цены',
'Create a price slice' => 'Создать разрез цены',
'Customer' => 'Клиент',
'Date' => 'Дата',
'Delete' => 'Удалить',
'Delete a price slice' => 'Удалить разрез цены',
'Delete this price slice' => 'Удалить этот разрез цены',
'Do not change' => 'Не изменять',
'Do you really want to delete this slice ?' => 'Вы действительно хотите удалить этот разрез ?',
'Edit' => 'Редактировать',
'Edit a price slice' => 'Редактировать разрез цены',
'Edit this price slice' => 'Редактировать этот разрез цены',
'Export' => 'Экспорт',
'Export expeditor inet file' => 'Экспортировать inet file экспедитора',
'Number of packages' => 'Количество комплектов',
'Packages weight' => 'Вес комплектов',
'Please change the access rights' => 'Пожалуйста, измените права доступа',
'Price (€)' => 'Цена (€)',
'Price slices' => 'Разрезы цен',
'Processing' => 'В обработке',
'REF' => 'REF',
'Save' => 'Сохранить',
'Sent' => 'Отправлен',
'There is currently not orders to export' => 'Сейчас нет заказов для экспорта',
'Total taxed amount' => 'Итого',
'Weight up to ... (kg)' => 'Вес до ... (кг)',
);

View File

@@ -1,34 +0,0 @@
<?php
return [
'*If you choose this option, the exported orders would not be available on this page anymore' => '* Bu seçeneği seçerseniz, ihracat siparişleri artık bu sayfadaki müsait olmaz',
'Actions' => 'Eylemler',
'An error occured' => 'Bir hata meydana geldi',
'Area : ' => 'Alanı: ',
'Cancel' => 'Vazgeç',
'Change orders status after export' => 'İhracat sonra sipariş durumunu değiştir',
'Colissimo Module allows to send your products all around the world with La Poste.' => 'Colissimo modülü sağlar ürünlerinizi göndermek için La Poste ile dünyanın her yerinden.',
'Create' => 'Oluştur',
'Create a new price slice' => 'Yeni fiyat dilimi oluşturmak',
'Create a price slice' => 'Bir fiyat dilim oluşturma',
'Date' => 'Tarih',
'Delete' => 'sil',
'Delete a price slice' => 'Bir fiyat dilim silmek',
'Delete this price slice' => 'Bu fiyat dilim silmek',
'Do not change' => 'Değiştirme',
'Do you really want to delete this slice ?' => 'Gerçekten bu dosyayı silmek istiyor musunuz ?',
'Edit' => 'Düzenle',
'Edit a price slice' => 'Bir fiyat dilim Düzenle',
'Edit this price slice' => 'Bu fiyat dilim Düzenle',
'Export' => 'Dışa aktarma',
'Export expeditor inet file' => 'Expeditor inet dosyası dışa aktarma',
'Please change the access rights' => 'Lütfen erişim haklarını Değiştir',
'Price (€)' => 'Fiyat (TL)',
'Price slices' => 'Fiyat dilimleri',
'Processing' => 'İşlem devam ediyor',
'REF' => 'ÜRÜN KODU',
'Sent' => 'Gönder',
'There is currently not orders to export' => 'Şu anda hiçbir emir vermek için',
'Total taxed amount' => 'Toplam Kdvtutarı',
'Weight up to ... (kg)' => 'Fazla kilo... (kg)',
];

View File

@@ -1,14 +0,0 @@
<?php
return [
'Activate free shipping: ' => 'Kostenlose Lieferung aktivieren: ',
'Can\'t read Config directory' => 'Config-Verzeichnis kann nicht gelesen werden',
'Can\'t read file' => 'Datei kann nicht gelesen werden',
'Can\'t write Config directory' => 'Config-Verzeichnis kann nicht beschrieben werden',
'Can\'t write file' => 'Datei kann nicht geschrieben werden',
'Colissimo delivery unavailable for the delivery country' => 'Eine Lieferung mit Colissimo ist für das Land nicht verfügbar',
'Colissimo delivery unavailable for this cart weight (%weight kg)' => 'Eine Lieferung mit Colissimo ist für Warenkörbe mit diesem Gewicht (%weight kg) nicht verfügbar',
'Modify status export after export' => 'Status der Bestellung nach dem Export ändern',
'colissimo expeditor export' => 'Colissimo expeditor export',
'select a valid status' => 'Wählen Sie einen gültigen Bestellungsstatus aus',
];

View File

@@ -1,14 +0,0 @@
<?php
return array(
'Activate free shipping: ' => 'Activate free shipping: ',
'Can\'t read Config directory' => 'Can\'t read Config directory',
'Can\'t read file' => 'Can\'t read file',
'Can\'t write Config directory' => 'Can\'t write Config directory',
'Can\'t write file' => 'Can\'t write file',
'Colissimo delivery unavailable for the delivery country' => 'Colissimo delivery unavailable for the delivery country',
'Colissimo delivery unavailable for this cart weight (%weight kg)' => 'Colissimo delivery unavailable for this cart weight (%weight kg)',
'Modify status export after export' => 'Change orders status after export',
'colissimo expeditor export' => 'Colissimo Expeditor export',
'select a valid status' => 'Select a valid order status',
);

View File

@@ -1,14 +0,0 @@
<?php
return [
'Activate free shipping: ' => 'Activer la livraison offerte: ',
'Can\'t read Config directory' => 'Le dossier Config ne peut être lu',
'Can\'t read file' => 'Le fichier suivant ne peut être lu',
'Can\'t write Config directory' => 'Le dossier Config ne peut être écrit',
'Can\'t write file' => 'Le fichier suivant ne peut être écrit',
'Colissimo delivery unavailable for the delivery country' => 'La livraison par Colissimo n\'est pas disponible dans ce pays',
'Colissimo delivery unavailable for this cart weight (%weight kg)' => 'La livraison par Colissimo n\'est pas disponible pour un panier de %weight Kg',
'Modify status export after export' => 'Modification du statut des commandes après l\'export',
'colissimo expeditor export' => 'Export pour le logiciel Expeditor',
'select a valid status' => 'Choisissez un statut de commande valide.',
];

View File

@@ -1,15 +0,0 @@
<?php
return array(
'Activate free shipping: ' => 'Активировать бесплатную доставку:',
'Can\'t read Config directory' => 'Невозможно прочитать директорию Config',
'Can\'t read file' => 'Невозможно прочитать файл',
'Can\'t write Config directory' => 'Невозможно записать в директорию Config',
'Can\'t write file' => 'Невозможно записать файл',
'Check if you want to activate Colissimo' => 'Выберите если хотите активировать Colissimo',
'Colissimo delivery unavailable for the delivery country' => 'Доставка Colissimo не доступна для страны доставки',
'Colissimo delivery unavailable for this cart weight (%weight kg)' => 'Доставка Colissimo не доступна для этого веса корзины (%weight кг)',
'Modify status export after export' => 'Изменить статус экспорта после экспорта',
'colissimo expeditor export' => 'Colissimo экспорт экспедитора',
'select a valid status' => 'Выберите правильный статус',
);

View File

@@ -1,14 +0,0 @@
<?php
return [
'Activate free shipping: ' => 'Ücretsiz nakliye etkinleştirmek için: ',
'Can\'t read Config directory' => 'Yapılandırma dizini okunamıyor',
'Can\'t read file' => 'Dosyayı okuyamıyor',
'Can\'t write Config directory' => 'Dosyayı okuyamıyor',
'Can\'t write file' => 'Dosyaya yazılamıyor',
'Colissimo delivery unavailable for the delivery country' => 'Bu Teslimat Bu ülke için kullanılamaz Colissimo teslim',
'Colissimo delivery unavailable for this cart weight (%weight kg)' => 'Colissimo teslimat için bu sepeti ağırlık (%weight kg) kullanılamaz',
'Modify status export after export' => 'İhracat sonra sipariş durumunu değiştir',
'colissimo expeditor export' => 'Colissimo Expeditor verme',
'select a valid status' => 'Geçerli sipariş durumunu seçin',
];

View File

@@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -1,104 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Listener;
use Colissimo\Colissimo;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Template\ParserInterface;
use Thelia\Log\Tlog;
use Thelia\Mailer\MailerFactory;
use Thelia\Model\ConfigQuery;
use Thelia\Model\MessageQuery;
use Thelia\Model\OrderStatus;
use Thelia\Module\PaymentModuleInterface;
/**
* Class SendMail
* @package Colissimo\Listener
* @author Manuel Raynaud <manu@raynaud.io>
*/
class SendMail implements EventSubscriberInterface
{
protected $parser;
protected $mailer;
public function __construct(ParserInterface $parser, MailerFactory $mailer)
{
$this->parser = $parser;
$this->mailer = $mailer;
}
public function updateStatus(OrderEvent $event)
{
$order = $event->getOrder();
$colissimo = new Colissimo();
if ($order->isSent() && $order->getDeliveryModuleId() == $colissimo->getModuleModel()->getId()) {
$contact_email = ConfigQuery::getStoreEmail();
if ($contact_email) {
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->mailer->sendEmailToCustomer(
'mail_colissimo',
$customer,
[
'customer_id' => $customer->getId(),
'order_ref' => $order->getRef(),
'order_date' => $order->getCreatedAt(),
'update_date' => $order->getUpdatedAt(),
'package' => $order->getDeliveryRef()
]
);
Tlog::getInstance()->debug("Colissimo shipping message sent to customer ".$customer->getEmail());
} else {
$customer = $order->getCustomer();
Tlog::getInstance()->debug("Colissimo shipping message no contact email customer_id", $customer->getId());
}
}
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128)
);
}
}

View File

@@ -1,100 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Loop;
use Colissimo\Colissimo;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Translation\Translator;
/**
* Class CheckRightsLoop
* @package Colissimo\Looop
* @author Thelia <info@thelia.net>
*/
class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
{
protected function getArgDefinitions()
{
return new ArgumentCollection();
}
public function buildArray()
{
$ret = array();
$dir = __DIR__."/../Config/";
if (!is_readable($dir)) {
$ret[] = array(
"ERRMES"=>Translator::getInstance()->trans(
"Can't read Config directory",
[],
Colissimo::DOMAIN_NAME
),
"ERRFILE"=>""
);
}
if (!is_writable($dir)) {
$ret[] = array(
"ERRMES"=>Translator::getInstance()->trans(
"Can't write Config directory",
[],
Colissimo::DOMAIN_NAME
),
"ERRFILE"=>""
);
}
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (strlen($file) > 5 && substr($file, -5) === ".json") {
if (!is_readable($dir.$file)) {
$ret[] = array(
"ERRMES"=>Translator::getInstance()->trans(
"Can't read file",
[],
Colissimo::DOMAIN_NAME
),
"ERRFILE"=>"Colissimo/Config/".$file
);
}
if (!is_writable($dir.$file)) {
$ret[] = array(
"ERRMES"=>Translator::getInstance()->trans(
"Can't write file",
[],
Colissimo::DOMAIN_NAME
),
"ERRFILE"=>"Colissimo/Config/".$file
);
}
}
}
}
return $ret;
}
public function parseResults(LoopResult $loopResult)
{
foreach ($loopResult->getResultDataCollection() as $arr) {
$loopResultRow = new LoopResultRow();
$loopResultRow->set("ERRMES", $arr["ERRMES"])
->set("ERRFILE", $arr["ERRFILE"]);
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -1,74 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Loop;
use Colissimo\Model\ColissimoQuery;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Order;
/**
* Class NotSendLoop
* @package Colissimo\Loop
* @author Manuel Raynaud <manu@raynaud.io>
*/
class NotSendLoop extends Order
{
/**
*
* define all args used in your loop
*
*
* example :
*
* public function getArgDefinitions()
* {
* return new ArgumentCollection(
* Argument::createIntListTypeArgument('id'),
* new Argument(
* 'ref',
* new TypeCollection(
* new Type\AlphaNumStringListType()
* )
* ),
* Argument::createIntListTypeArgument('category'),
* Argument::createBooleanTypeArgument('new'),
* Argument::createBooleanTypeArgument('promo'),
* Argument::createFloatTypeArgument('min_price'),
* Argument::createFloatTypeArgument('max_price'),
* Argument::createIntTypeArgument('min_stock'),
* Argument::createFloatTypeArgument('min_weight'),
* Argument::createFloatTypeArgument('max_weight'),
* Argument::createBooleanTypeArgument('current'),
*
* );
* }
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
public function getArgDefinitions()
{
return new ArgumentCollection(Argument::createBooleanTypeArgument('with_prev_next_info', false));
}
/**
* this method returns a Propel ModelCriteria
*
* @return \Propel\Runtime\ActiveQuery\ModelCriteria
*/
public function buildModelCriteria()
{
return ColissimoQuery::getOrders();
}
}

View File

@@ -1,73 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
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

@@ -1,66 +0,0 @@
<?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\Model;
use Colissimo\Colissimo;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusQuery;
/**
* Class ColissimoQuery
* @package Colissimo\Model
* @author Manuel Raynaud <manu@raynaud.io>
*/
class ColissimoQuery
{
/**
* @return OrderQuery
*/
public static function getOrders()
{
$status = OrderStatusQuery::create()
->filterByCode(
array(
OrderStatus::CODE_PAID,
OrderStatus::CODE_PROCESSING,
),
Criteria::IN
)
->find()
->toArray("code");
$query = OrderQuery::create()
->filterByDeliveryModuleId((new Colissimo())->getModuleModel()->getId())
->filterByStatusId(
array(
$status[OrderStatus::CODE_PAID]['Id'],
$status[OrderStatus::CODE_PROCESSING]['Id']),
Criteria::IN
);
return $query;
}
}

View File

@@ -1,25 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Model\Config\Base;
/**
* Class Colissimo
* @package Colissimo\Model\Config\Base
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class ColissimoConfigValue
{
const FREE_SHIPPING = "free_shipping";
const PRICES = "prices";
const ENABLED = "enabled";
}

View File

@@ -1,24 +0,0 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Model\Config;
use Colissimo\Model\Config\Base\ColissimoConfigValue as BaseColissimoConfigValue;
/**
* Class Colissimo
* @package Colissimo\Model\Config
* @author Thomas Arnaud <tarnaud@openstudio.fr>
*/
class ColissimoConfigValue extends BaseColissimoConfigValue
{
}

View File

@@ -1,23 +0,0 @@
[GENERAL]
DELIMITE=O
SEPARATEUR=59
DELIMITEUR=34
FINDELIGNE=CRLF
Unité poids=KG
[CHAMPS]
ReferenceExpedition=1
NomDestinataire=2
Prenom=3
Adresse1=4
Adresse2=5
Adresse3=6
CodePostal=7
Commune=8
CodePays=9
Telephone=10
Portable=11
Poids=12
Mail=13
CodePointRetrait=14
CodeProduit=15
NomCommercialChargeur=16

View File

@@ -1,11 +0,0 @@
{
"name": "thelia/colissimo-module",
"license": "LGPL-3.0+",
"type": "thelia-module",
"require": {
"thelia/installer": "~1.1"
},
"extra": {
"installer-name": "Colissimo"
}
}

View File

@@ -1,3 +0,0 @@
Colissimo prices based on April 2013 pdf.
TarifsAvril2013.pdf is available in this module documentation folder.
You may update prices in Config/prices.json file.

View File

@@ -1,36 +0,0 @@
{javascripts file="assets/js/bootstrap-switch/bootstrap-switch.js"}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(document).ready(function() {
$(".freeshipping-activation-Colissimo").bootstrapSwitch();
$(".freeshipping-activation-Colissimo").on("switch-change", function(e, data){
var is_checked = data.value;
var form = $("#freeshippingform");
$('body').append('<div class="modal-backdrop fade in" id="loading-event"><div class="loading"></div></div>');
$.ajax({
url: form.attr('action'),
type: form.attr('method'),
data: form.serialize()
}).done(function(){
$("#loading-event").remove();
})
.success(function() {
if (is_checked) {
$('#config-btn-0').removeClass('disabled');
$('#table-prices-colissimo').hide('slow');
} else {
$('#config-btn-0').addClass('disabled');
$('#table-prices-colissimo').show('slow');
}
})
.fail(function(jqXHR, textStatus, errorThrown){
$("#loading-event").remove();
$('#freeshipping-failed-body').html(jqXHR.responseJSON.error);
$("#freeshipping-failed").modal("show");
});
});
});
</script>

View File

@@ -1,316 +0,0 @@
<div class="row">
<!-- Errors -->
{loop name="checkrights.colissimo" type="colissimo.check.rights"}
<div class="alert alert-danger">
<p>{$ERRMES} {$ERRFILE} | {intl d='colissimo.bo.default' l="Please change the access rights"}.</p>
</div>
{/loop}
</div>
{elseloop rel="checkrights.colissimo"}
<div class="alert alert-info">
<p>{intl d='colissimo.bo.default' l="Colissimo Module allows to send your products all around the world with La Poste."}</p>
</div>
<div class="modal fade" id="freeshipping-failed" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl d='colissimo.bo.default' l="An error occured"}</h3>
</div>
<div class="modal-body" id="freeshipping-failed-body">
</div>
</div>
</div>
</div>
<div class="general-block-decorator">
<div class="row">
<div class="col-md-12">
{form name="colissimo.configuration"}
<form method="POST" action="{url path='/admin/module/colissimo/configuration/update'}">
{form_hidden_fields form=$form}
{form_field form=$form field="enabled"}
<div class="form-group">
<label class="control-label" for="{$label_attr.for}">
<input type="checkbox" name="{$name}" id="{$label_attr.for}" {if $value}checked{/if} />
{$label}
{form_error form=$form field="enabled"}
<br />
<span class="error">{$message}</span>
{/form_error}
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
<button type="submit" name="colissimo_save_configuration" value="save" class="form-submit-button btn btn-sm btn-default" title="{intl d='colissimo.bo.default' l='Save'}">
{intl d='colissimo.bo.default' l='Save'}
</button>
</form>
{/form}
</div>
</div>
</div>
<div class="general-block-decorator">
<div class="row">
<div class="col-md-12">
<!-- Tab menu -->
<ul id="tabbed-menu" class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#export">{intl d='colissimo.bo.default' l="Export expeditor inet file"}</a> </li>
<li class="{if $tab eq "1"}active{/if}"><a data-toggle="tab" href="#prices_slices_tab">{intl d='colissimo.bo.default' l="Price slices"}</a></li>
</ul>
<div class="tab-content">
<!-- Export tab -->
<div id="export" class="tab-pane active form-container">
{form name="colissimo.export.form"}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<form action="{url path='/admin/module/colissimo/export'}" method="post">
{form_hidden_fields}
<div class="panel panel-default">
<div class="panel-heading clearfix">
{intl d='colissimo.bo.default' l="Change orders status after export"}
</div>
<div class="panel-body">
<table>
{form_field field="status_id"}
<tr>
<td>
<label for="nochange">{intl d='colissimo.bo.default' l="Do not change"}</label>&nbsp;
</td>
<td>
<input type="radio" id="nochange" name="{$name}" value="nochange" checked/>
</td>
</tr>
<tr>
<td>
<label for="processing">{intl d='colissimo.bo.default' l="Processing"}</label>&nbsp;
</td>
<td>
<input type="radio" id="processing" name="{$name}" value="processing"/>
</td>
</tr>
<tr>
<td>
<label for="sent">{intl d='colissimo.bo.default' l="Sent"}*</label>&nbsp;
</td>
<td>
<input type="radio" id="sent" name="{$name}" value="sent"/>
</td>
</tr>
{/form_field}
</table>
<span class="p">{intl d='colissimo.ai' l="*If you choose this option, the exported orders would not be available on this page anymore"}</span>
</div>
</div>
<!-- Order list -->
<table class="table table-striped table-condensed">
<thead>
<th class="object-title">
{intl d='colissimo.ai' l="REF"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Customer"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Date"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Total taxed amount"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Number of packages"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Packages weight"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Export"}
</th>
</thead>
<tbody>
{loop name="colissimo.notsend.loop" type="colissimo.notsend.loop"}
<tr>
<td>
<a href="{url path="/admin/order/update/%id" id=$ID}">{$REF}</a>
</td>
<td>
{loop type='customer' name='colissimo.customer' id=$CUSTOMER current='false'}
<a href="{url path="/admin/customer/update" customer_id=$ID}">{$LASTNAME} {$FIRSTNAME}</a>
{/loop}
</td>
<td>
{$CREATE_DATE|date_format}
</td>
<td>
{$TOTAL_TAXED_AMOUNT} {loop name="list.socolissimo.getcurrency" type="currency" id=$CURRENCY}{$SYMBOL}{/loop}
</td>
<td>
{form_field form=$form field="order_nb_pkg_"|cat:$ID}
<input class="form-control text-center" type="text" name="{$name}" value="1" />
{/form_field}
</td>
<td>
{form_field form=$form field="order_weight_"|cat:$ID}
<input class="form-control text-center" type="text" name="{$name}" value="0" />
{/form_field}
</td>
<td>
{form_field field="order_"|cat:$ID}
<input type="checkbox" name="{$name}" id="{$label_attr.for}" value="true" class="form-control"/>
{/form_field}
</td>
</tr>
{/loop}
{elseloop rel="colissimo.notsend.loop"}
<tr>
<td colspan="4">
<br />
<div class="alert alert-info">{intl d='colissimo.ai' l="There is currently not orders to export"}</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
{ifloop rel="colissimo.notsend.loop"}
<button type="submit" name="export_socolissimo_form" value="stay" class="form-submit-button btn btn-sm btn-default" title="{intl d='colissimo.bo.default' l='Export'}">{intl d='colissimo.bo.default' l='Export'}</button>
{/ifloop}
</form>
{/form}
</div>
<div id="prices_slices_tab" class="tab-pane {if $tab eq 1}active{/if} form-container">
<!-- checkbox free shipping -->
{assign var="isColissimoFreeShipping" value=0}
{form name="colissimo.freeshipping.form"}
<br />
<form action="{url path="/admin/module/colissimo/freeshipping"}" method="post" id="freeshippingform">
{form_hidden_fields}
{form_field field="freeshipping"}
<label>
{$label}
</label>
<div class="switch-small freeshipping-activation-Colissimo" data-id="0" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok-circle'></i>" data-off-label="<i class='glyphicon glyphicon-remove-circle'></i>">
<input type="checkbox" name="{$name}" {if $value}checked{assign var="isColissimoFreeShipping" value=1}{/if} />
</div>
{/form_field}
</form>
{/form}
<div id="table-prices-colissimo" {if $isColissimoFreeShipping eq 1} style="display:none;" {/if}>
<!-- Prices editing -->
{* -- Add price slice confirmation dialog ----------------------------------- *}
{loop type="area" name="list area" backend_context=true module_id=$module_id}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "price_slice_create_dialog_{$ID}"
dialog_title = {intl d='colissimo.bo.default' l="Create a price slice"}
dialog_body = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\" />
<label for=\"weight_{$ID}\">{intl d='colissimo.bo.default' l="Weight up to ... (kg)"}</label></label>
<input type=\"number\" step=\"0.01\" id=\"weight_{$ID}\" name=\"weight\" value=\"1\" class=\"form-control\" pattern=\"\d+\.?\d*\" required/>
<label for=\"price_{$ID}\">{intl d='colissimo.bo.default' l="Price (€)"}</label></label>
<input type=\"number\" step=\"0.01\" id=\"price_{$ID}\" name=\"price\" value=\"1\" class=\"form-control\" pattern=\"\d+\.?\d*\" required/>"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl d='colissimo.bo.default' l="Create"}
dialog_cancel_label = {intl d='colissimo.bo.default' l="Cancel"}
}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl d='colissimo.bo.default' 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 d='colissimo.bo.default' l='Create a new price slice'}" href="#price_slice_create_dialog_{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-plus"></span>
</a>
{/loop}
</caption>
<thead>
<tr>
<th class="col-md-3">{intl d='colissimo.bo.default' l="Weight up to ... (kg)"}</th>
<th class="col-md-5">{intl d='colissimo.bo.default' l="Price (€)"}</th>
<th class="col-md-1">{intl d='colissimo.bo.default' l="Actions"}</th>
</tr>
</thead>
<tbody>
{loop type="colissimo" name="colissimo" area=$ID}
{* -- EDIT price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl d='colissimo.bo.default' l="Edit a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"add\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
<label for=\"price_edit_{$ID}_{$MAX_WEIGHT}\">{intl d='colissimo.bo.default' l='Price (€)'}</label>
<input type=\"number\" step=\"0.01\" id=\"price_edit_{$ID}_{$MAX_WEIGHT}\" class=\"form-control\" name=\"price\" value=\"{$PRICE}\" pattern=\"\d+\.?\d*\" required/>"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl d='colissimo.bo.default' l="Edit"}
dialog_cancel_label = {intl d='colissimo.bo.default' l="Cancel"}
}
{* -- Delete price slice confirmation dialog ----------------------------------- *}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}"
dialog_title = {intl d='colissimo.bo.default' l="Delete a price slice"}
dialog_message = "<input type=\"hidden\" name=\"operation\" value=\"delete\"/>
<input type=\"hidden\" name=\"area\" value=\"{$ID}\"/>
<input type=\"hidden\" name=\"weight\" value=\"{$MAX_WEIGHT}\"/>
{intl d='colissimo.bo.default' l="Do you really want to delete this slice ?"}"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl d='colissimo.bo.default' l="Delete"}
dialog_cancel_label = {intl d='colissimo.bo.default' l="Cancel"}
}
<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 d='colissimo.bo.default' l='Edit this price slice'}" href="#price_slice_edit_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl d='colissimo.bo.default' l='Delete this price slice'}" href="#price_slice_delete_dialog_{$ID}_{$MAX_WEIGHT|replace:'.':'-'}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
{/loop}
</div>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
{/loop}
</div>
</div>
</div>
</div>
</div>
</div>
{/elseloop}

View File

@@ -140,9 +140,9 @@
{/form_field} {/form_field}
{form_field field="cellphone"} {form_field field="cellphone"}
<div class="form-group group-cellphone{if $error} has-error{/if}"> <div class="form-group group-cellphone{if $error} has-error{/if}">
<label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label> <label class="control-label col-sm-3" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
<div class="control-input col-sm-5"> <div class="control-input col-sm-5">
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="20" placeholder="{intl l="Placeholder cellphone"}" value="{$value}"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}> <input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="20" placeholder="{intl l="Placeholder cellphone"}" value="{$value}" aria-required="true" required{if !isset($error_focus) && $error} autofocus{/if}>
{if $error } {if $error }
<span class="help-block">{$message}</span> <span class="help-block">{$message}</span>
{assign var="error_focus" value="true"} {assign var="error_focus" value="true"}