Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<forms>
<form name="socolissimo.freeshipping.form" class="SoColissimo\Form\FreeShipping" />
<form name="socolissimo.configure" class="SoColissimo\Form\ConfigureSoColissimo" />
<form name="socolissimo.check.ids" class="SoColissimo\Form\CheckSoColissimoIds" />
<form name="socolissimo.export" class="SoColissimo\Form\ExportOrder" />
<form name="socolissimo.import" class="SoColissimo\Form\ImportForm"/>
<form name="socolissimo.add.price.form" class="SoColissimo\Form\AddPriceForm" />
Expand Down
4 changes: 4 additions & 0 deletions Config/routing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<default key="_controller">SoColissimo\Controller\SaveConfig::save</default>
</route>

<route id="socolissimo.check" path="/admin/module/socolissimo/check" methods="post">
<default key="_controller">SoColissimo\Controller\CheckAccountController::check</default>
</route>

<route id="socolissimo.get.specific.location" path="/module/socolissimo/{countryid}/{zipcode}/{city}/{address}" methods="get">
<default key="_controller">SoColissimo\Controller\GetSpecificLocation::get</default>
<default key="address"></default>
Expand Down
49 changes: 49 additions & 0 deletions Controller/CheckAccountController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace SoColissimo\Controller;

use SoColissimo\Form\CheckSoColissimoIds;
use SoColissimo\SoColissimo;
use SoColissimo\WebService\FindByAddress;
use Symfony\Component\HttpFoundation\JsonResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ConfigQuery;

class CheckAccountController extends BaseAdminController
{
/**
* @return JsonResponse
* @throws \Exception
*/
public function check()
{
$translator = Translator::getInstance();
$statusCode = 500;
$message = '';
$status = $translator->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);
}
}
78 changes: 78 additions & 0 deletions Form/CheckSoColissimoIds.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Created by PhpStorm.
* User: audreymartel
* Date: 30/05/2018
* Time: 10:13
*/

namespace SoColissimo\Form;

use SoColissimo\SoColissimo;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Thelia\Form\BaseForm;


/**
* Class CheckColissimoIds
* @package SoColissimo\Form
* @author amartel <amartel@openstudio.fr>
*/
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";
}
}
5 changes: 4 additions & 1 deletion I18n/backOffice/default/fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)',
Expand Down
6 changes: 6 additions & 0 deletions I18n/fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
23 changes: 21 additions & 2 deletions templates/backOffice/default/SoColissimo/module-config-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 + '<br>' + 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 + '<br>' + data.message);
$("#socolissimo-check-ids-result").addClass('alert alert-warning');
});
return false;
});
});


Expand Down
38 changes: 38 additions & 0 deletions templates/backOffice/default/SoColissimo/module_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ <h3>{intl l="An error occured"}</h3>
<li class="{if $tab eq "prices_slices_tab_{$ID}"}active{/if}"><a data-toggle="tab" href="#prices_slices_tab_{$ID}">{intl l="Price slices for \"%mode\"" d='socolissimo.bo.default' mode={$TITLE}}</a></li>
{/loop}
<li class="{if $tab eq "configure"}active{/if}"><a data-toggle="tab" href="#configure">{intl l="Advanced configuration" d='socolissimo.bo.default'}</a></li>
<li class="{if $tab eq "check"}active{/if}"><a data-toggle="tab" href="#check">{intl l="Check account" d='socolissimo.bo.default'}</a></li>
</ul>

<div class="tab-content">
Expand Down Expand Up @@ -267,6 +268,43 @@ <h3>{intl l="An error occured"}</h3>
</div>
</div>

<div id="check" class="tab-pane {if $tab eq "check"}active{/if} form-container">
{form name="socolissimo.check.ids"}
{if $form_error && $form_error_message}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
<form id="socolissimo-check-ids" method="post">
{form_hidden_fields form=$form}
{form_field form=$form field='address'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}">
</div>
{/form_field}
{form_field form=$form field='postcode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}">
</div>
{/form_field}
{form_field form=$form field='city'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}">
</div>
{/form_field}
{form_field form=$form field='lang'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}">
</div>
{/form_field}
<button type="submit" class="form-submit-button btn btn-sm btn-default btn-info btn-test-account-config" title="{intl l='Test account' d='socolissimo.bo.default'}">{intl l='Test' d='socolissimo.bo.default'}</button>
<div id="socolissimo-check-ids-result"></div>
</form>
{/form}
</div>

{loop type="socolissimo.delivery.mode" name="devlivery_mode"}
{$deliveryModeId=$ID}
<div id="prices_slices_tab_{$deliveryModeId}" class="tab-pane {if $tab eq "prices_slices_tab_$deliveryModeId" }active{/if} form-container">
Expand Down