Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -1,38 +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

@@ -13,10 +13,9 @@
namespace Colissimo;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Colissimo\Model\Config\ColissimoConfigValue;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Exception\OrderException;
use Thelia\Install\Database;
use Thelia\Model\Country;
use Thelia\Module\AbstractDeliveryModule;
@@ -31,37 +30,52 @@ class Colissimo extends AbstractDeliveryModule
const JSON_PRICE_RESOURCE = "/Config/prices.json";
const MESSAGE_DOMAIN = 'colissimo';
const DOMAIN_NAME = 'colissimo';
public static function getPrices()
{
if (null === self::$prices) {
self::$prices = json_decode(file_get_contents(sprintf('%s%s', __DIR__, self::JSON_PRICE_RESOURCE)), true);
self::$prices = json_decode(Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null), true);
}
return self::$prices;
}
public function isValidDelivery(Country $country) {
public function postActivation(ConnectionInterface $con = null)
{
self::setConfigValue(ColissimoConfigValue::ENABLED, 1);
$areaId = $country->getAreaId();
$database = new Database($con);
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
}
$prices = self::getPrices();
public function isValidDelivery(Country $country)
{
if (0 == self::getConfigValue(ColissimoConfigValue::ENABLED, 1)) {
return false;
}
/* Check if Colissimo delivers the area */
if (isset($prices[$areaId]) && isset($prices[$areaId]["slices"])) {
if (null !== $area = $this->getAreaForCountry($country)) {
$areaId = $area->getId();
// Yes ! Check if the cart weight is below slice limit
$areaPrices = $prices[$areaId]["slices"];
ksort($areaPrices);
$prices = self::getPrices();
/* Check cart weight is below the maximum weight */
end($areaPrices);
$maxWeight = key($areaPrices);
/* 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);
$cartWeight = $this->getRequest()->getSession()->getCart()->getWeight();
/* Check cart weight is below the maximum weight */
end($areaPrices);
$maxWeight = key($areaPrices);
if ($cartWeight <= $maxWeight) return true;
$cartWeight = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getWeight();
if ($cartWeight <= $maxWeight) {
return true;
}
}
}
return false;
@@ -76,7 +90,7 @@ class Colissimo extends AbstractDeliveryModule
*/
public static function getPostageAmount($areaId, $weight)
{
$freeshipping = ColissimoFreeshippingQuery::create()->getLast();
$freeshipping = Colissimo::getConfigValue(ColissimoConfigValue::FREE_SHIPPING);
$postage = 0;
if (!$freeshipping) {
$prices = self::getPrices();
@@ -84,7 +98,11 @@ class Colissimo extends AbstractDeliveryModule
/* 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::MESSAGE_DOMAIN)
Translator::getInstance()->trans(
"Colissimo delivery unavailable for the delivery country",
[],
self::DOMAIN_NAME
)
);
}
@@ -99,7 +117,7 @@ class Colissimo extends AbstractDeliveryModule
Translator::getInstance()->trans(
"Colissimo delivery unavailable for this cart weight (%weight kg)",
array("%weight" => $weight),
self::MESSAGE_DOMAIN
self::DOMAIN_NAME
)
);
}
@@ -118,13 +136,6 @@ class Colissimo extends AbstractDeliveryModule
}
public function postActivation(ConnectionInterface $con = null)
{
$database = new Database($con);
$database->insertSql(null, array(__DIR__ . '/Config/thelia.sql'));
}
/**
*
* calculate and return delivery price
@@ -135,13 +146,32 @@ class Colissimo extends AbstractDeliveryModule
*/
public function getPostage(Country $country)
{
$cartWeight = $this->getRequest()->getSession()->getCart()->getWeight();
$cartWeight = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getWeight();
$postage = self::getPostageAmount(
$country->getAreaId(),
$this->getAreaForCountry($country)->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

@@ -13,25 +13,28 @@
<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>
<commands>
<!--
<command class="MyModule\Command\MySuperCommand" />
-->
</commands>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
-->
</templateDirectives>
<services>
<service id="send.colissimo.mail" class="Colissimo\Listener\SendMail" scope="request">
<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

@@ -7,12 +7,12 @@
<descriptive locale="fr_FR">
<title>Livraison par Colissimo</title>
</descriptive>
<version>1.0</version>
<version>2.3.5</version>
<author>
<name>Manuel Raynaud</name>
<email>mraynaud@openstudio.fr</email>
<email>manu@raynaud.io</email>
</author>
<type>delivery</type>
<thelia>2.0.0</thelia>
<thelia>2.2.0</thelia>
<stability>alpha</stability>
</module>

View File

@@ -1,120 +1,30 @@
{"1": {
"_info": "area 1 : France",
"slices": {
"0.25": 5.23,
"0.5": 5.99,
"0.75": 6.75,
"1": 7.36,
"2": 8.36,
"3": 9.55,
"5": 11.73,
"7": 13.92,
"10": 17.15,
"15": 19.81,
"30": 27.79
}
}, "2": {
"_info": "area 2 : A Zone - Union Europ\u00e9enne 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 l\u2019Europe de l\u2019Est (hors Union Europ\u00e9enne), Norv\u00e8ge, Maghreb",
"slices": {
"1": 19.38,
"2": 22.23,
"3": 26.46,
"4": 30.69,
"5": 34.96,
"6": 39.24,
"7": 43.51,
"8": 47.79,
"9": 52.06,
"10": 56.34,
"15": 66.79,
"20": 77.24
}
}, "4": {
"_info": "area 4 : C Zone - Pays d\u2019Afrique hors Maghreb, Canada, Etats-Unis, Proche et Moyen Orient",
"slices": {
"1": 23.66,
"2": 31.26,
"3": 40.47,
"4": 49.69,
"5": 58.90,
"6": 68.12,
"7": 77.33,
"8": 86.55,
"9": 95.76,
"10": 104.98,
"15": 129.87,
"20": 154.76
}
}, "5": {
"_info": "area 5 : D Zone - Autres destinations",
"slices": {
"1": 26.27,
"2": 38.81,
"3": 51.35,
"4": 63.89,
"5": 76.43,
"6": 88.97,
"7": 101.51,
"8": 114.05,
"9": 126.59,
"10": 139.13,
"15": 163.83,
"20": 188.53
}
}, "6": {
"_info": "area 6 : France OM1",
"slices": {
"0.5": 8.5,
"1": 12.87,
"2": 17.58,
"3": 22.28,
"4": 26.98,
"5": 31.68,
"6": 36.39,
"7": 41.09,
"8": 45.79,
"9": 50.49,
"10": 55.2,
"15": 78.95,
"20": 102.7,
"25": 126.45,
"30": 150.2
}
}, "7": {
"_info": "area 7 : France OM2",
"slices": {
"0.5": 10.17,
"1": 15.39,
"2": 27.12,
"3": 38.86,
"4": 50.59,
"5": 62.32,
"6": 74.05,
"7": 85.79,
"8": 97.52,
"9": 109.25,
"10": 120.98,
"15": 179.69,
"20": 238.4,
"25": 297.11,
"30": 355.82
}
}}
{"1": {
"_info": "area 1 : France",
"slices": {
"0.325": "15",
"0.650": "17.5",
"1.3": "20",
"1.95": "25",
"2.4": "30",
"3.25": "37.50",
"3.9": "45",
"4.5": "52.5",
"5.2": "60",
"5.8": "67.5",
"6.5": "75"
}
}, "8": {
"slices": {
"0.325": "31",
"0.650": "31",
"1.3": "36",
"1.95": "40",
"2.4": "72",
"3.25": "80",
"3.9": "108",
"4.5": "120",
"5.2": "144",
"5.8": "160",
"6.5": "180"
}
}}

View File

@@ -14,4 +14,8 @@
<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,50 +1,32 @@
# 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;
-- ---------------------------------------------------------------------
-- colissimo_freeshipping
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `colissimo_freeshipping`;
CREATE TABLE `colissimo_freeshipping`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`active` TINYINT(1) NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
INSERT INTO `colissimo_freeshipping`(`active`, `created_at`, `updated_at`) VALUES (0, NOW(), NOW());
-- ---------------------------------------------------------------------
-- 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;
# 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

@@ -0,0 +1,77 @@
<?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

@@ -11,9 +11,13 @@
/*************************************************************************************/
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
@@ -22,7 +26,6 @@ use Thelia\Controller\Admin\BaseAdminController;
*/
class EditPrices extends BaseAdminController
{
public function editprices()
{
// Get data & treat
@@ -31,49 +34,51 @@ class EditPrices extends BaseAdminController
$area = $post->get('area');
$weight = $post->get('weight');
$price = $post->get('price');
if( preg_match("#^add|delete$#", $operation) &&
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) {
$json_path= __DIR__."/../".Colissimo::JSON_PRICE_RESOURCE;
if (is_readable($json_path)) {
$json_data = json_decode(file_get_contents($json_path),true);
} elseif(!file_exists($json_path)) {
$json_data = array();
} else {
throw new \Exception("Can't read Colissimo".Colissimo::JSON_PRICE_RESOURCE.". Please change the rights on the file.");
if (null !== $data = Colissimo::getConfigValue(ColissimoConfigValue::PRICES, null)) {
$json_data = json_decode(
$data,
true
);
}
if((float) $weight > 0 && $operation == "add"
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]))
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']);
if ((file_exists($json_path) ?is_writable($json_path):is_writable(__DIR__."/../"))) {
$file = fopen($json_path, 'w');
fwrite($file, json_encode($json_data));;
fclose($file);
} else {
throw new \Exception("Can't write Colissimo".Colissimo::JSON_PRICE_RESOURCE.". Please change the rights on the file.");
}
Colissimo::setConfigValue(ColissimoConfigValue::PRICES, json_encode($json_data));
} else {
throw new \Exception("Area not found");
}
} else {
} else {
throw new \ErrorException("Arguments are missing or invalid");
}
}
return $this->redirectToRoute("admin.module.configure",array(),
array ( 'module_code'=>"Colissimo",
'_controller' => 'Thelia\\Controller\\Admin\\ModuleController::configureAction'));
return $this->redirectToConfigurationPage();
}
/**
* Redirect to the configuration page
*/
protected function redirectToConfigurationPage()
{
return RedirectResponse::create(URL::getInstance()->absoluteUrl('/admin/module/Colissimo'));
}
}

View File

@@ -14,7 +14,6 @@ namespace Colissimo\Controller;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Event\Order\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
@@ -27,15 +26,12 @@ use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\CustomerTitleQuery;
use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusQuery;
/**
* Class Export
* @package Colissimo\Controller
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Manuel Raynaud <manu@raynaud.io>
*/
class Export extends BaseAdminController
{
@@ -53,17 +49,18 @@ class Export extends BaseAdminController
try {
$exportForm = $this->validateForm($form);
// Get new status
$status_id = $exportForm->get('status_id')->getData();
$status = OrderStatusQuery::create()
->filterByCode($status_id)
->findOne();
$orders = ColissimoQuery::getOrders()
->find();
// Get Colissimo orders
$orders = ColissimoQuery::getOrders()->find();
$export = "";
$store_name = ConfigQuery::read("store_name");
$store_name = ConfigQuery::getStoreName();
/** @var $order \Thelia\Model\Order */
foreach ($orders as $order) {
@@ -71,6 +68,7 @@ class Export extends BaseAdminController
if ($value) {
// Get order information
$customer = $order->getCustomer();
$locale = $order->getLang()->getLocale();
$address = $order->getOrderAddressRelatedByDeliveryOrderAddressId();
@@ -78,6 +76,14 @@ class Export extends BaseAdminController
$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
@@ -94,9 +100,7 @@ class Export extends BaseAdminController
}
}
/**
* Cellp
*/
// Cellphone
$cellphone = $customer->getDefaultAddress()->getCellphone();
if (empty($cellphone)) {
@@ -107,32 +111,37 @@ class Export extends BaseAdminController
}
}
/**
* Compute package weight
*/
$weight = 0;
/** @var \Thelia\Model\OrderProduct $product */
foreach ($order->getOrderProducts() as $product) {
$weight+=(double) $product->getWeight();
}
$export .= "\"".$order->getRef()."\";\"".$address->getLastname()."\";\"".$address->getFirstname()."\";\"".$address->getAddress1()."\";\"".$address->getAddress2()."\";\"".$address->getAddress3()."\";\"".$address->getZipcode()."\";\"".$address->getCity()."\";\"".$country->getTitle()."\";\"".$phone."\";\"".$cellphone."\";\"".$weight."\";\"\";\"\";\"".$store_name."\";\"DOM\";\r\n";
$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(
$export,
utf8_decode($export),
200,
array(
"Content-Encoding"=>"ISO-8889-1",
"Content-Type"=>"application/csv-tab-delimited-table",
"Content-disposition"=>"filename=export.csv"
)
@@ -140,7 +149,7 @@ class Export extends BaseAdminController
} catch (FormValidationException $e) {
$this->setupFormErrorContext(
Translator::getInstance()->trans("colissimo expeditor export", [], Colissimo::MESSAGE_DOMAIN),
Translator::getInstance()->trans("colissimo expeditor export", [], Colissimo::DOMAIN_NAME),
$e->getMessage(),
$form,
$e
@@ -154,5 +163,4 @@ class Export extends BaseAdminController
);
}
}
}
}

View File

@@ -12,26 +12,51 @@
namespace Colissimo\Controller;
use Colissimo\Model\ColissimoFreeshipping;
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\HttpFoundation\Response;
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');
class FreeShipping extends BaseAdminController {
public function set() {
$form = new \Colissimo\Form\FreeShipping($this->getRequest());
$response=null;
try {
$vform = $this->validateForm($form);
$data = $vform->get('freeshipping')->getData();
$validateForm = $this->validateForm($form);
$data = $validateForm->getData();
Colissimo::setConfigValue(ColissimoConfigValue::FREE_SHIPPING, (int) ($data["freeshipping"]));
return $this->redirectToConfigurationPage();
$save = new ColissimoFreeshipping();
$save->setActive(!empty($data))->save();
$response = Response::create('');
} 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

@@ -0,0 +1,53 @@
<?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

@@ -0,0 +1,59 @@
<?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

@@ -14,21 +14,16 @@ namespace Colissimo\Form;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\Validator\Constraints\Callback;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusQuery;
/**
* Class Export
* @package Colissimo\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Manuel Raynaud <manu@raynaud.io>
*/
class Export extends BaseForm
{
@@ -59,35 +54,61 @@ class Export extends BaseForm
->find();
$this->formBuilder
->add('status_id', 'text',[
'constraints' => [
new NotBlank(),
new Callback(array(
"methods" => array(
array($this,
"verifyValue")
->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::MESSAGE_DOMAIN),
'label_attr' => [
'for' => 'status_id'
],
'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())
));
$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::MESSAGE_DOMAIN));
if (!preg_match("#^nochange|processing|sent$#", $value)) {
$context->addViolation(
Translator::getInstance()->trans(
'select a valid status',
[],
Colissimo::DOMAIN_NAME
)
);
}
}
@@ -98,4 +119,4 @@ class Export extends BaseForm
{
return "colissimo_export";
}
}
}

View File

@@ -12,13 +12,13 @@
namespace Colissimo\Form;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoFreeshippingQuery;
use Colissimo\Model\Config\Base\ColissimoConfigValue;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;
class FreeShipping extends BaseForm {
class FreeShipping extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
@@ -41,13 +41,15 @@ class FreeShipping extends BaseForm {
*/
protected function buildForm()
{
$freeshipping = ColissimoFreeshippingQuery::create()->getLast();
$this->formBuilder
->add("freeshipping", "checkbox", array(
'data'=>$freeshipping,
'label'=>Translator::getInstance()->trans("Activate free shipping: ", [], Colissimo::MESSAGE_DOMAIN)
))
;
->add(
"freeshipping",
"checkbox",
array(
"label" => Translator::getInstance()->trans("Activate free shipping: ", [], Colissimo::DOMAIN_NAME),
"value" => Colissimo::getConfigValue(ColissimoConfigValue::FREE_SHIPPING, false),
)
);
}
/**
@@ -57,6 +59,4 @@ class FreeShipping extends BaseForm {
{
return "colissimofreeshipping";
}
}
}

View File

@@ -0,0 +1,31 @@
<?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

@@ -0,0 +1,25 @@
<?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

@@ -0,0 +1,36 @@
<?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

@@ -0,0 +1,37 @@
<?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

@@ -0,0 +1,13 @@
<?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

@@ -0,0 +1,34 @@
<?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

@@ -0,0 +1,14 @@
<?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

@@ -6,6 +6,8 @@ return array(
'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,6 +1,6 @@
<?php
return array(
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',
@@ -11,4 +11,4 @@ return array(
'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

@@ -0,0 +1,14 @@
<?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

@@ -0,0 +1,165 @@
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

@@ -28,72 +28,53 @@ use Thelia\Module\PaymentModuleInterface;
/**
* Class SendMail
* @package Colissimo\Listener
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @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::read('store_email');
$contact_email = ConfigQuery::getStoreEmail();
if ($contact_email) {
$message = MessageQuery::create()
->filterByName('mail_colissimo')
->findOne();
if (false === $message) {
throw new \Exception("Failed to load message 'order_confirmation'.");
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$this->parser->assign('customer_id', $customer->getId());
$this->parser->assign('order_ref', $order->getRef());
$this->parser->assign('order_date', $order->getCreatedAt());
$this->parser->assign('update_date', $order->getUpdatedAt());
$this->parser->assign('package', $order->getDeliveryRef());
$message
->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()
->addTo($customer->getEmail(), $customer->getFirstname()." ".$customer->getLastname())
->addFrom($contact_email, ConfigQuery::read('store_name'))
;
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->mailer->send($instance);
$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());
} 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.
*

View File

@@ -24,7 +24,6 @@ use Thelia\Core\Translation\Translator;
* @package Colissimo\Looop
* @author Thelia <info@thelia.net>
*/
class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
{
protected function getArgDefinitions()
@@ -37,24 +36,55 @@ class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
$ret = array();
$dir = __DIR__."/../Config/";
if (!is_readable($dir)) {
$ret[] = array("ERRMES"=>Translator::getInstance()->trans("Can't read Config directory", [], Colissimo::MESSAGE_DOMAIN), "ERRFILE"=>"");
$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::MESSAGE_DOMAIN), "ERRFILE"=>"");
$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::MESSAGE_DOMAIN), "ERRFILE"=>"Colissimo/Config/".$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::MESSAGE_DOMAIN), "ERRFILE"=>"Colissimo/Config/".$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)
@@ -65,7 +95,6 @@ class CheckRightsLoop extends BaseLoop implements ArraySearchLoopInterface
->set("ERRFILE", $arr["ERRFILE"]);
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -12,20 +12,16 @@
namespace Colissimo\Loop;
use Colissimo\Colissimo;
use Colissimo\Model\ColissimoQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Order;
use Thelia\Core\Template\Loop\Order;
/**
* Class NotSendLoop
* @package Colissimo\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Manuel Raynaud <manu@raynaud.io>
*/
class NotSendLoop extends Order
{
@@ -63,7 +59,7 @@ class NotSendLoop extends Order
*/
public function getArgDefinitions()
{
return new ArgumentCollection();
return new ArgumentCollection(Argument::createBooleanTypeArgument('with_prev_next_info', false));
}
/**
@@ -73,8 +69,6 @@ class NotSendLoop extends Order
*/
public function buildModelCriteria()
{
return ColissimoQuery::getOrders();
}
}
}

View File

@@ -17,7 +17,6 @@ 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;
@@ -48,10 +47,9 @@ class Price extends BaseLoop implements ArraySearchLoopInterface
public function buildArray()
{
$area = $this->getArea();
$prices = Colissimo::getPrices();
if(!isset($prices[$area]) || !isset($prices[$area]["slices"])) {
if (!isset($prices[$area]) || !isset($prices[$area]["slices"])) {
return array();
}
@@ -70,8 +68,6 @@ class Price extends BaseLoop implements ArraySearchLoopInterface
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -29,13 +29,12 @@ use Thelia\Model\OrderQuery;
use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusQuery;
/**
* Class ColissimoQuery
* @package Colissimo\Model
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Manuel Raynaud <manu@raynaud.io>
*/
class ColissimoQuery
class ColissimoQuery
{
/**
* @return OrderQuery
@@ -51,10 +50,7 @@ class ColissimoQuery
Criteria::IN
)
->find()
->toArray("code")
;
->toArray("code");
$query = OrderQuery::create()
->filterByDeliveryModuleId((new Colissimo())->getModuleModel()->getId())
@@ -67,4 +63,4 @@ class ColissimoQuery
return $query;
}
}
}

View File

@@ -0,0 +1,25 @@
<?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

@@ -0,0 +1,24 @@
<?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

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

View File

@@ -0,0 +1,36 @@
{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,258 +1,316 @@
<div class="row">
<!-- Errors -->
{loop name="checkrights.colissimo" type="colissimo.check.rights"}
<div class="alert alert-danger">
<p>{$ERRMES} {$ERRFILE} | {intl d='colissimo.ai' l="Please change the access rights"}.</p>
</div>
{/loop}
</div>
{elseloop rel="checkrights.colissimo"}
<div class="alert alert-info">
<p>{intl d='colissimo.ai' 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.ai' 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">
<ul id="tabbed-menu" class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#export">{intl d='colissimo.ai' 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.ai' l="Price slices"}</a></li>
</ul>
<div class="tab-content">
<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 form=$form}
<div class="panel panel-default">
{form_field form=$form field="status_id"}
<div class="panel-heading clearfix">
{intl d='colissimo.ai' l="Change orders status after export"}
</div>
<div class="panel-body">
<table>
<tr>
<td>
<label for="nochange">{intl d='colissimo.ai' l="Do not change"}</label>&nbsp;
</td>
<td>
<input type="radio" id="nochange" name="{$name}" value="nochange"/>
</td>
</tr>
<tr>
<td>
<label for="processing">{intl d='colissimo.ai' 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.ai' l="Sent"}*</label>&nbsp;
</td>
<td>
<input type="radio" id="sent" name="{$name}" value="sent"/>
</td>
</tr>
</table>
{/form_field}
<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>
<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="Date"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Total taxed amount"}
</th>
<th class="object-title">
{intl d='colissimo.ai' l="Export"}
</th>
</thead>
<tbody>
{loop name="colissimo.notsend.loop" type="colissimo.notsend.loop"}
{form_field form=$form field="order_"|cat:$ID}
<tr>
<td>
<label for="{$label_attr.for}">
{$label}
</label>
</td>
<td>
{$CREATE_DATE|date_format}
</td>
<td>
{$TOTAL_TAXED_AMOUNT} {loop name="list.socolissimo.getcurrency" type="currency" id=$CURRENCY}{$SYMBOL}{/loop}
</td>
<td>
<input type="checkbox" name="{$name}" id="{$label_attr.for}" value="true" class="form-control"/>
</td>
</tr>
{/form_field}
{/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.ai' l='Export'}">{intl d='colissimo.ai' 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=$form}
{form_field form=$form 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}" value="true" {if $data}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}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "price_slice_create_dialog_{$ID}"
dialog_title = {intl d='colissimo.ai' 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.ai' l="Weight up to ... (kg)"}</label></label>
<input type=\"number\" id=\"weight_{$ID}\" name=\"weight\" value=\"1\" class=\"form-control\" pattern=\"\\d+\\.?\\d*\" required/>
<label for=\"price_{$ID}\">{intl d='colissimo.ai' l="Price (€)"}</label></label>
<input type=\"number\" 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.ai' l="Create"}
dialog_cancel_label = {intl d='colissimo.ai' l="Cancel"}
}
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
{intl d='colissimo.ai' 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.ai' 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.ai' l="Weight up to ... (kg)"}</th>
<th class="col-md-5">{intl d='colissimo.ai' l="Price (€)"}</th>
<th class="col-md-1">{intl d='colissimo.ai' 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.ai' 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.ai' l='Price (€)'}</label>
<input type=\"number\" 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.ai' l="Edit"}
dialog_cancel_label = {intl d='colissimo.ai' 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.ai' 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.ai' l="Do you really want to delete this slice ?"}"
form_action="{url path="/admin/module/colissimo/prices"}"
dialog_ok_label = {intl d='colissimo.ai' l="Delete"}
dialog_cancel_label = {intl d='colissimo.ai' 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.ai' 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.ai' 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}
<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.001\" 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}