diff --git a/local/modules/FedEx/Config/config.xml b/local/modules/FedEx/Config/config.xml index d5ba94b7..82d54dbf 100755 --- a/local/modules/FedEx/Config/config.xml +++ b/local/modules/FedEx/Config/config.xml @@ -22,17 +22,9 @@ - - - - - - - - diff --git a/local/modules/FedEx/Config/prices.json b/local/modules/FedEx/Config/prices.json deleted file mode 100644 index 53eacc3b..00000000 --- a/local/modules/FedEx/Config/prices.json +++ /dev/null @@ -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 - } -}} diff --git a/local/modules/FedEx/Config/routing.xml b/local/modules/FedEx/Config/routing.xml index 30263c8c..230c5435 100755 --- a/local/modules/FedEx/Config/routing.xml +++ b/local/modules/FedEx/Config/routing.xml @@ -10,4 +10,5 @@ FedEx\Controller\Configuration::editConfiguration + diff --git a/local/modules/FedEx/Controller/Configuration.php b/local/modules/FedEx/Controller/Configuration.php index 3a4ea94b..6ee90e1d 100755 --- a/local/modules/FedEx/Controller/Configuration.php +++ b/local/modules/FedEx/Controller/Configuration.php @@ -3,7 +3,6 @@ namespace FedEx\Controller; use FedEx\FedEx; -use FedEx\Model\Config\FedExConfigValue; use Symfony\Component\HttpFoundation\RedirectResponse; use Thelia\Controller\Admin\BaseAdminController; use Thelia\Core\Security\AccessManager; @@ -36,7 +35,7 @@ class Configuration extends BaseAdminController $data = $validateForm->getData(); FedEx::setConfigValue( - FedExConfigValue::TRACKING_URL, + FedEx::TRACKING_URL_PARAMETER, $data["tracking_url"] ); diff --git a/local/modules/FedEx/FedEx.php b/local/modules/FedEx/FedEx.php index 6e192bb8..b510c1a3 100755 --- a/local/modules/FedEx/FedEx.php +++ b/local/modules/FedEx/FedEx.php @@ -13,16 +13,16 @@ use Thelia\Module\Exception\DeliveryException; class FedEx extends AbstractDeliveryModule { + const DOMAIN_NAME = 'fedex'; + protected $request; protected $dispatcher; - const TRACKING_URL = 'tracking_url'; + const TRACKING_URL_PARAMETER = 'tracking_url'; + const DEFAULT_TRACKING_URL = "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber="; private static $prices = null; - const JSON_PRICE_RESOURCE = "/Config/prices.json"; - const DOMAIN_NAME = 'fedex'; - public static function getPrices() { if (null === self::$prices) { @@ -34,7 +34,7 @@ class FedEx extends AbstractDeliveryModule public function postActivation(ConnectionInterface $con = null) { - self::setConfigValue(FedExConfigValue::TRACKING_URL, "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber="); + self::setConfigValue(FedEx::TRACKING_URL_PARAMETER, FedEx::DEFAULT_TRACKING_URL); $database = new Database($con); $database->insertSql(null, array(__DIR__ . '/Config/thelia.sql')); @@ -43,10 +43,6 @@ class FedEx extends AbstractDeliveryModule public function isValidDelivery(Country $country, State $state = null) { - if (0 == self::getConfigValue(FedExConfigValue::ENABLED, 1)) { - return false; - } - if (null !== $area = $this->getAreaForCountry($country, $state)) { $areaId = $area->getId(); @@ -144,20 +140,4 @@ class FedEx extends AbstractDeliveryModule 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 'FedEx_freeshipping'")->rowCount(); -// if (FedEx::getConfigValue(FedExConfigValue::FREE_SHIPPING, null) == null && $tableExists) { -// $result = $database->execute('SELECT active FROM FedEx_freeshipping WHERE id=1')->fetch()["active"]; -// FedEx::setConfigValue(FedExConfigValue::FREE_SHIPPING, $result); -// $database->execute("DROP TABLE `FedEx_freeshipping`"); -// } - - if (is_readable($uploadDir) && FedEx::getConfigValue(FedExConfigValue::PRICES, null) == null) { - FedEx::setConfigValue(FedExConfigValue::PRICES, file_get_contents($uploadDir)); - } - } } diff --git a/local/modules/FedEx/Form/Configuration.php b/local/modules/FedEx/Form/Configuration.php index 5cd3d2cf..320a4787 100644 --- a/local/modules/FedEx/Form/Configuration.php +++ b/local/modules/FedEx/Form/Configuration.php @@ -3,8 +3,7 @@ namespace FedEx\Form; use FedEx\FedEx; -use FedEx\Model\Config\Base\FedExConfigValue; -use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Form\BaseForm; /** @@ -18,9 +17,12 @@ class Configuration extends BaseForm { $this->formBuilder ->add( - FedEx::TRACKING_URL, - 'text', + FedEx::TRACKING_URL_PARAMETER, + 'url', [ + 'constraints' => [ + new NotBlank(), + ], 'label' => $this->translator->trans('FedEx parcel tracking URL', [], FedEx::DOMAIN_NAME), 'label_attr' => [ 'help' => $this->translator->trans('This is the parcel tracking URL for FedEx.', [], FedEx::DOMAIN_NAME) diff --git a/local/modules/FedEx/I18n/backOffice/default/en_US.php b/local/modules/FedEx/I18n/backOffice/default/en_US.php index d5ecf96c..6a326274 100644 --- a/local/modules/FedEx/I18n/backOffice/default/en_US.php +++ b/local/modules/FedEx/I18n/backOffice/default/en_US.php @@ -26,7 +26,7 @@ return array( 'Processing' => 'Processing', 'REF' => 'REF', 'Sent' => 'Sent', - 'This is the parcel tracking URL for FedEx.' => 'This is the parcel tracking URL for FedEx.', + 'This is the parcel tracking URL for FedEx.' => 'Please indicate FedEx parcel tracking`s WebService URL : last character must be symbol = ', 'Total taxed amount' => 'Total taxed amount', 'Weight up to ... (kg)' => 'Weight up to ... (kg)', 'Number of packages' => 'Number of packages', diff --git a/local/modules/FedEx/I18n/backOffice/default/fr_FR.php b/local/modules/FedEx/I18n/backOffice/default/fr_FR.php index 95102b7f..b10e1703 100644 --- a/local/modules/FedEx/I18n/backOffice/default/fr_FR.php +++ b/local/modules/FedEx/I18n/backOffice/default/fr_FR.php @@ -1,35 +1,25 @@ '* Si vous choisissez cette option, les commandes exportées ne seront plus affichée sur cette page.', +return array( 'Actions' => 'Actions', - 'An error occured' => 'Une erreur est survenue', 'Area : ' => 'Zone de livraison : ', 'Cancel' => 'Annuler', - 'FedEx Module allows to send your products all around the world with FedEx.' => 'FedEx vous permet d’expédier vos colis dans le monde entier avec FedEx', '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', - 'FedEx parcel tracking URL' => 'URL de suivi des colis FedEx', - 'Number of packages' => 'Nombre de colis', - 'Packages weight' => 'Poids des colis', + 'FedEx parcel tracking URL' => 'URL du WebService de suivi des colis FedEx', + 'FedEx Module allows to send your products all around the world with FedEx.' => 'FedEx vous permet d’expédier vos colis dans le monde entier avec FedEx', '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', - 'This is the parcel tracking URL for FedEx.' => 'Il s\'agit de l\'URL fournie par FedEx afin de suivre les expéditions de ses colis.', - 'Total taxed amount' => 'Total TTC', + 'Save' => 'Sauvegarder', + 'This is the parcel tracking URL for FedEx.' => 'Veuillez saisir l\'URL de suivi des colis FedEx : le dernier caractère doit être le symbole =', 'Weight up to ... (kg)' => 'Jusqu\'au poids (Kg)', -]; +); diff --git a/local/modules/FedEx/I18n/fr_FR.php b/local/modules/FedEx/I18n/fr_FR.php index f7986712..1c52ef5b 100644 --- a/local/modules/FedEx/I18n/fr_FR.php +++ b/local/modules/FedEx/I18n/fr_FR.php @@ -1,11 +1,12 @@ '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', 'FedEx delivery unavailable for the delivery country' => 'La livraison par FedEx n\'est pas disponible dans ce pays', 'FedEx delivery unavailable for this cart weight (%weight kg)' => 'La livraison par FedEx n\'est pas disponible pour un panier de %weight Kg', - 'select a valid status' => 'Choisissez un statut de commande valide.', -]; + 'FedEx parcel tracking URL' => 'URL du WebService de suivi des colis FedEx', + 'This is the parcel tracking URL for FedEx.' => 'Veuillez saisir l\'URL de suivi des colis FedEx : le dernier caractère doit être le symbole =', +); diff --git a/local/modules/FedEx/Listener/SendMail.php b/local/modules/FedEx/Listener/SendMail.php index a8e4860d..2ebde8aa 100755 --- a/local/modules/FedEx/Listener/SendMail.php +++ b/local/modules/FedEx/Listener/SendMail.php @@ -10,15 +10,12 @@ 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 FedEx\Listener - * @author Manuel Raynaud + * @author Laurent LE CORRE */ class SendMail implements EventSubscriberInterface { @@ -51,6 +48,7 @@ class SendMail implements EventSubscriberInterface 'order_ref' => $order->getRef(), 'order_date' => $order->getCreatedAt(), 'update_date' => $order->getUpdatedAt(), + 'tracking_url' => FedEx::getConfigValue('tracking_url',$FedEx::DEFAULT_TRACKING_URL), 'package' => $order->getDeliveryRef() ] ); diff --git a/local/modules/FedEx/templates/backOffice/default/assets/js/module-configuration-js.html b/local/modules/FedEx/templates/backOffice/default/assets/js/module-configuration-js.html deleted file mode 100644 index bfc91a30..00000000 --- a/local/modules/FedEx/templates/backOffice/default/assets/js/module-configuration-js.html +++ /dev/null @@ -1,38 +0,0 @@ -{javascripts file="assets/js/bootstrap-switch/bootstrap-switch.js"} - -{/javascripts} - - \ No newline at end of file diff --git a/local/modules/FedEx/templates/backOffice/default/module_configuration.html b/local/modules/FedEx/templates/backOffice/default/module_configuration.html index ade518ed..81e15956 100755 --- a/local/modules/FedEx/templates/backOffice/default/module_configuration.html +++ b/local/modules/FedEx/templates/backOffice/default/module_configuration.html @@ -13,21 +13,6 @@ {intl d='fedex.bo.default' l="FedEx Module allows to send your products all around the world with FedEx."} - - - - - - × - {intl d='fedex.bo.default' l="An error occured"} - - - - - - - - @@ -35,23 +20,9 @@ {form_hidden_fields form=$form} - {form_field form=$form field="tracking_url"} - - - - {$label} - - {form_error form=$form field="tracking_url" value={module_config module="FedEx" key='tracking_url' locale="en_US"}} - - {$message} - {/form_error} - - {if ! empty($label_attr.help)} - {$label_attr.help} - {/if} - - {/form_field} - + {loop type="module-config" name="boucle" module="FedEx" variable="tracking_url"} + {render_form_field field="tracking_url" value=$VALUE} + {/loop} {intl d='fedex.bo.default' l='Save'}
{intl d='fedex.bo.default' l="FedEx Module allows to send your products all around the world with FedEx."}