diff --git a/Config/config.xml b/Config/config.xml index 2e8ecaa..9e94f46 100755 --- a/Config/config.xml +++ b/Config/config.xml @@ -20,6 +20,7 @@
+ diff --git a/Config/routing.xml b/Config/routing.xml index 0542975..cb4f7bf 100755 --- a/Config/routing.xml +++ b/Config/routing.xml @@ -26,6 +26,10 @@ SoColissimo\Controller\SaveConfig::save + + SoColissimo\Controller\CheckAccountController::check + + SoColissimo\Controller\GetSpecificLocation::get diff --git a/Controller/CheckAccountController.php b/Controller/CheckAccountController.php new file mode 100644 index 0000000..ab5d3c4 --- /dev/null +++ b/Controller/CheckAccountController.php @@ -0,0 +1,49 @@ +trans('Connection Failed', [], SoColissimo::DOMAIN); + try { + $form = new CheckSoColissimoIds($this->getRequest()); + $validateForm = $this->validateForm($form); + $findAddressRequest = new FindByAddress(); + $findAddressRequest->setAddress($validateForm->get('address')->getData()) + ->setZipCode($validateForm->get('postcode')->getData()) + ->setCity($validateForm->get('city')->getData()) + ->setLang($validateForm->get('lang')->getData()) + ->setFilterRelay(0) + ->setShippingDate(date("d/m/Y")) + ->setAccountNumber(ConfigQuery::read('socolissimo_login')) + ->setPassword(ConfigQuery::read('socolissimo_pwd')) + ; + $findAddressRequest->exec(); + $status = $translator->trans('Connection Success', [], SoColissimo::DOMAIN); + $statusCode = 200; + } catch (\Exception $e) { + $message = $e->getMessage(); + } + return new JsonResponse([ + 'status' => $status, + 'message' => $message, + ], $statusCode); + } +} \ No newline at end of file diff --git a/Form/CheckSoColissimoIds.php b/Form/CheckSoColissimoIds.php new file mode 100644 index 0000000..c9173df --- /dev/null +++ b/Form/CheckSoColissimoIds.php @@ -0,0 +1,78 @@ + + */ +class CheckSoColissimoIds extends BaseForm +{ + protected function buildForm() + { + $translator = Translator::getInstance(); + $this->formBuilder + ->add( + 'address', + 'text', + [ + 'constraints' => [new NotBlank()], + 'data' => 'Clermont-Ferrand', + 'label' => $translator->trans("Address", [], SoColissimo::DOMAIN), + 'label_attr' => ['for' => 'address'] + ] + ) + ->add( + 'postcode', + 'text', + [ + 'constraints' => [new NotBlank()], + 'data' => '63000', + 'label' => $translator->trans("Postcode", [], SoColissimo::DOMAIN), + 'label_attr' => ['for' => 'postcode'] + ] + ) + ->add( + 'city', + 'text', + [ + 'constraints' => [new NotBlank()], + 'data' => 'France', + 'label' => $translator->trans("City", [], SoColissimo::DOMAIN), + 'label_attr' => ['for' => 'city'] + ] + ) + ->add( + 'lang', + 'text', + [ + 'constraints' => [new NotBlank()], + 'data' => 'FR', + 'label' => $translator->trans("Lang", [], SoColissimo::DOMAIN), + 'label_attr' => ['for' => 'lang'] + ] + ) + ; + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "checksocolissimoids"; + } +} diff --git a/I18n/backOffice/default/fr_FR.php b/I18n/backOffice/default/fr_FR.php index 8bca68d..78d6254 100644 --- a/I18n/backOffice/default/fr_FR.php +++ b/I18n/backOffice/default/fr_FR.php @@ -3,13 +3,14 @@ return array( '*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 n\'apparaitront plus dans cette page', 'Actions' => 'Actions', - 'Activate total free shipping ' => 'Activer les frais de port gratuits', 'Activate free shipping from (€) :' => 'Activer les frais de port gratuits à partir de (€)', + 'Activate total free shipping ' => 'Activer les frais de port gratuits', 'Add this price slice' => 'Ajouter cette tranche de prix', 'Advanced configuration' => 'Configuration avancée', 'An error occured' => 'Une erreur est survenue', 'Area : ' => 'Zone :', 'Change orders status after export' => 'Modifier le statut des commandes après l\'export', + 'Check account' => 'Test du compte', 'Check all' => 'Tout cocher', 'Customer' => 'Client', 'Date' => 'Date', @@ -37,6 +38,8 @@ 'Save this price slice' => 'Enregistrer cette tranche de prix', 'Sent' => 'Envoyé', 'TEST' => 'TEST', + 'Test' => 'Test', + 'Test account' => 'Test compte', 'The file has to be a CSV with 2 columns. The first contains the delivery reference, the second the order reference.' => 'Le fichier doit être au format CSV et contenir 2 colonnes. La première indique les références colis, la seconde les références des commandes.', 'The slices are ordered by maximum cart weight then by maximum cart price.' => 'Les tranches sont triés pour poids de panier max puis par prix de panier max.', 'Total taxed amount' => 'Montant total (avec taxes)', diff --git a/I18n/fr_FR.php b/I18n/fr_FR.php index 0462fdd..d6d9f78 100755 --- a/I18n/fr_FR.php +++ b/I18n/fr_FR.php @@ -3,16 +3,22 @@ return array( 'Account number' => 'Numéro de compte', 'Activate free shipping: ' => 'Livraison offerte: ', + 'Address' => 'Adresse : ', 'Bad file format. CSV expected.' => 'Mauvais format de fichier. CSV attendu.', 'Can\'t read Config directory' => 'Le dossier Config ne peut être lu', 'Can\'t read file' => 'Le fichier suivant ne peut être lu', + 'City' => 'Ville : ', 'Colissimo URL prod' => 'URL de Colissimo en production', 'Colissimo URL test' => 'URL de Colissimo en mode test', + 'Connection Failed' => 'La connexion a échoué', + 'Connection Success' => 'Connection ok', 'Do not change' => 'Ne pas changer', 'Google map API key' => 'Clé API Google map', + 'Lang' => 'Langue : ', 'No relay points were selected' => 'Aucun point relais n\'a été sélectionné', 'Operation successful. %i orders affected.' => 'Opération effectuée avec succès. %i commandes affectées.', 'Password' => 'Mot de passe', + 'Postcode' => 'Code postale : ', 'Select file to import' => 'Sélectionner un fichier à importer', 'Set orders status as processing' => 'En traitement', 'Set orders status as sent' => 'Envoyée', diff --git a/templates/backOffice/default/SoColissimo/module-config-js.html b/templates/backOffice/default/SoColissimo/module-config-js.html index 2fa6962..5e84afa 100755 --- a/templates/backOffice/default/SoColissimo/module-config-js.html +++ b/templates/backOffice/default/SoColissimo/module-config-js.html @@ -12,7 +12,8 @@ var config = { 'urlAdd': '{url path="/admin/module/socolissimo/slice/save"}', 'urlDelete': '{url path="/admin/module/socolissimo/slice/delete"}', - 'urlSave': '{url path="/admin/module/socolissimo/slice/save"}' + 'urlSave': '{url path="/admin/module/socolissimo/slice/save"}', + 'urlCheck': '{url path="/admin/module/socolissimo/check"}' }; $(document).ready(function() { @@ -200,8 +201,26 @@ }); + $("#socolissimo-check-ids").on('submit', function (event) { + event.preventDefault(); + $("#socolissimo-check-ids-result").removeClass('alert-warning', 'alert-success', 'alert'); + $("#socolissimo-check-ids-result").html(); + $.ajax({ + type: "POST", + dataType: 'json', + data: $(this).serialize(), + url: config.urlCheck + }).done(function(data, textStatus, jqXHR){ + $("#socolissimo-check-ids-result").html(data.status + '
' + data.message); + $("#socolissimo-check-ids-result").addClass('alert alert-success'); - + }).fail(function(jqXHR, textStatus, errorThrown){ + var data = jqXHR.responseJSON; + $("#socolissimo-check-ids-result").html(data.status + '
' + data.message); + $("#socolissimo-check-ids-result").addClass('alert alert-warning'); + }); + return false; + }); }); diff --git a/templates/backOffice/default/SoColissimo/module_configuration.html b/templates/backOffice/default/SoColissimo/module_configuration.html index 3932e27..0945514 100755 --- a/templates/backOffice/default/SoColissimo/module_configuration.html +++ b/templates/backOffice/default/SoColissimo/module_configuration.html @@ -45,6 +45,7 @@

{intl l="An error occured"}

  • {intl l="Price slices for \"%mode\"" d='socolissimo.bo.default' mode={$TITLE}}
  • {/loop}
  • {intl l="Advanced configuration" d='socolissimo.bo.default'}
  • +
  • {intl l="Check account" d='socolissimo.bo.default'}
  • @@ -267,6 +268,43 @@

    {intl l="An error occured"}

    +
    + {form name="socolissimo.check.ids"} + {if $form_error && $form_error_message} +
    {$form_error_message}
    + {/if} + + {form_hidden_fields form=$form} + {form_field form=$form field='address'} +
    + + +
    + {/form_field} + {form_field form=$form field='postcode'} +
    + + +
    + {/form_field} + {form_field form=$form field='city'} +
    + + +
    + {/form_field} + {form_field form=$form field='lang'} +
    + + +
    + {/form_field} + +
    + + {/form} +
    + {loop type="socolissimo.delivery.mode" name="devlivery_mode"} {$deliveryModeId=$ID}