Création d'un module LivraisonForfaitaire pour pouvoir choisir les frais de livraisons sur les commandes passées depuis le backOffice

This commit is contained in:
2021-07-04 13:09:18 +02:00
parent 8992cbee62
commit ebb1376015
12 changed files with 245 additions and 23 deletions

79
.idea/workspace.xml generated
View File

@@ -6,19 +6,23 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e9efda16-0e17-4a4a-8328-e9581517920e" name="Default Changelist" comment="Rajout du module AdminComment + modifs pour que le commentaire (= le n° de bon de commande) figure dans la facture et dans le relevé de facture">
<change afterPath="$PROJECT_DIR$/local/modules/LivraisonForfaitaire/Config/config.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/LivraisonForfaitaire/Config/module.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/LivraisonForfaitaire/LivraisonForfaitaire.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/LivraisonForfaitaire/Readme.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/LivraisonForfaitaire/composer.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/ReCaptcha/I18n/frontOffice/default/en_US.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local/modules/ReCaptcha/I18n/frontOffice/default/fr_FR.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/Tinymce/assets/css/012cd78.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/Tinymce/assets/css/1509399.css" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/4558eb0.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/bootstrap-datetimepicker/1fbd3d7.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/bootstrap-switch/d261124.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/4c2cb1d.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/9017dfd.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/bootstrap-select/5ae733e.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/de8ae08.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/libs/8a5eb16.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/core/lib/Thelia/Controller/Admin/AbstractCrudController.php" beforeDir="false" afterPath="$PROJECT_DIR$/core/lib/Thelia/Controller/Admin/AbstractCrudController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/local/config/database.yml" beforeDir="false" afterPath="$PROJECT_DIR$/local/config/database.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/local/modules/PurgeFakeCustomer/EventListener/EventManager.php" beforeDir="false" afterPath="$PROJECT_DIR$/local/modules/PurgeFakeCustomer/EventListener/EventManager.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/local/session/sess_952a6789a55c2f1c55a4113a77cb181d" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/local/session/sess_cfc3346747297807d59f812413d1935f" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/log/.htaccess" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/templates/frontOffice/sterivein/ajax/order-delivery-module-list.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/frontOffice/sterivein/ajax/order-delivery-module-list.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/0/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/0/assets/img/flags/c0aed68.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/0/assets/img/flags/c7a1d07.png" beforeDir="false" />
@@ -594,16 +598,12 @@
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/HookAnalytics/assets/js/a872012.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/Tinymce/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/Tinymce/css/e3d487b.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/backOffice/default/template-assets/assets/js/f54a91d.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/0/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/0/img/header.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/0/img/logo.gif" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/1/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/1/img/header.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/default/1/img/logo.gif" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/sterivein/template-assets/assets/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/sterivein/template-assets/assets/img/header.jpg" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/email/sterivein/template-assets/assets/img/logo.gif" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/frontOffice/default/0/.source-stamp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/frontOffice/default/0/css/styles.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/frontOffice/default/0/font/bambina/bambina-webfont.eot" beforeDir="false" />
@@ -1249,6 +1249,7 @@
<change beforePath="$PROJECT_DIR$/web/assets/pdf/default/0/assets/img/6f0479e.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/assets/pdf/sterivein/template-assets/assets/img/df6e9a8.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/web/index_dev.php" beforeDir="false" afterPath="$PROJECT_DIR$/web/index_dev.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/web/tinymce" beforeDir="false" afterPath="$PROJECT_DIR$/web/tinymce" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -1262,6 +1263,14 @@
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="PhpDebugGeneral" notify_if_session_was_finished_without_being_paused="false" />
<component name="PhpServers">
<servers>
@@ -1373,12 +1382,17 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/local/modules/ReCaptcha/I18n/frontOffice" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="reference.webide.settings.project.settings.php" />
<property name="settings.editor.selected.configurable" value="preferences.keymap" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/local/modules/ReCaptcha/I18n/frontOffice" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/local/modules/ReCaptcha/I18n/frontOffice/default" />
<recent name="$PROJECT_DIR$/local/modules/PurgeFakeCustomer/Controller/Admin" />
</key>
</component>
@@ -1417,7 +1431,14 @@
<workItem from="1610525869698" duration="9790000" />
<workItem from="1610555465714" duration="517000" />
<workItem from="1610782909170" duration="3321000" />
<workItem from="1610974517491" duration="4981000" />
<workItem from="1610974517491" duration="5307000" />
<workItem from="1612171235608" duration="1000" />
<workItem from="1616495986712" duration="769000" />
<workItem from="1616503317429" duration="3000" />
<workItem from="1625126253592" duration="904000" />
<workItem from="1625128185816" duration="319000" />
<workItem from="1625129823908" duration="17164000" />
<workItem from="1625396731242" duration="54000" />
</task>
<task id="LOCAL-00001" summary="Inital commit">
<created>1605796595986</created>
@@ -1454,7 +1475,21 @@
<option name="project" value="LOCAL" />
<updated>1610554291167</updated>
</task>
<option name="localTasksCounter" value="6" />
<task id="LOCAL-00006" summary="Petite amélioration sur le module PurgeFakeCustomer -&gt; on loggue les suppressions de faux clients à présent.">
<created>1610990827481</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1610990827481</updated>
</task>
<task id="LOCAL-00007" summary="Commit juste pour le .idea">
<created>1610991008627</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1610991008627</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -1488,7 +1523,9 @@
<MESSAGE value="Inversion des valeurs dans la liste déroulante &quot;Type de promotion&quot; sur la création de nouvelle commande depuis le BO, afin que le pourcentage soit le choix par défaut." />
<MESSAGE value="Création du module PurgeFakeCustomer" />
<MESSAGE value="Finalisation du module PurgeFakeCustomer" />
<option name="LAST_COMMIT_MESSAGE" value="Finalisation du module PurgeFakeCustomer" />
<MESSAGE value="Petite amélioration sur le module PurgeFakeCustomer -&gt; on loggue les suppressions de faux clients à présent." />
<MESSAGE value="Commit juste pour le .idea" />
<option name="LAST_COMMIT_MESSAGE" value="Commit juste pour le .idea" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
@@ -1498,6 +1535,16 @@
<line>14</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/local/modules/OrderCreation/Controller/Admin/OrderCreationAdminController.php</url>
<line>172</line>
<option name="timeStamp" value="15" />
</line-breakpoint>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/local/modules/LivraisonForfaitaire/LivraisonForfaitaire.php</url>
<line>25</line>
<option name="timeStamp" value="20" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
</config>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
<fullnamespace>LivraisonForfaitaire\LivraisonForfaitaire</fullnamespace>
<descriptive locale="en_US">
<title>Permet de gérer des montants de frais de livraison forfaitaires, pour les commandes passées dans le backOffice</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Permet de gérer des montants de frais de livraison forfaitaires, pour les commandes passées dans le backOffice</title>
</descriptive>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.0</version>
<authors>
<author>
<name>Laurent LE CORRE</name>
<email>laurent@thecoredev.fr</email>
</author>
</authors>
<type>delivery</type>
<thelia>2.2.0</thelia>
<stability>other</stability>
<mandatory>0</mandatory>
<hidden>0</hidden>
</module>

View File

@@ -0,0 +1,55 @@
<?php
namespace LivraisonForfaitaire;
use Thelia\Model\Country;
use Thelia\Module\AbstractDeliveryModule;
class LivraisonForfaitaire extends AbstractDeliveryModule
{
/** @var string */
const DOMAIN_NAME = 'livraisonforfaitaire';
/**
* calculate and return delivery price
*
* @param Country $country
* @throws \Exception
*
* @return mixed
*/
public function getPostage(Country $country)
{
if (null !== $area = $this->getAreaForCountry($country)) {
$select = $this->getRequest()->get('select-forfait');
if ($select !== null && $select !== "")
$postage = $select;
else
$postage = $area->getPostage();
} else {
throw new \InvalidArgumentException("Country or Area should not be null");
}
return $postage === null ? 0 : $postage;
}
/**
* This method is called by the Delivery loop, to check if the current module has to be displayed to the customer.
* Override it to implements your delivery rules/
*
* If you return true, the delivery method will de displayed to the customer
* If you return false, the delivery method will not be displayed
*
* @param Country $country the country to deliver to.
*
* @return boolean
*/
public function isValidDelivery(Country $country)
{
// We should find an area for the country.
return null !== $this->getAreaForCountry($country);
}
}

View File

@@ -0,0 +1,55 @@
# Livraison Forfaitaire
Add a short description here. You can also add a screenshot if needed.
## Installation
### Manually
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is LivraisonForfaitaire.
* Activate it in your thelia administration panel
### Composer
Add it in your main thelia composer.json file
```
composer require your-vendor/livraison-forfaitaire-module:~1.0
```
## Usage
Explain here how to use your module, how to configure it, etc.
## Hook
If your module use one or more hook, fill this part. Explain which hooks are used.
## Loop
If your module declare one or more loop, describe them here like this :
[loop name]
### Input arguments
|Argument |Description |
|--- |--- |
|**arg1** | describe arg1 with an exemple. |
|**arg2** | describe arg2 with an exemple. |
### Output arguments
|Variable |Description |
|--- |--- |
|$VAR1 | describe $VAR1 variable |
|$VAR2 | describe $VAR2 variable |
### Exemple
Add a complete exemple of your loop
## Other ?
If you have other think to put, feel free to complete your readme as you want.

View File

@@ -0,0 +1,11 @@
{
"name": "your-vendor/livraison-forfaitaire-module",
"license": "LGPL-3.0+",
"type": "thelia-module",
"require": {
"thelia/installer": "~1.1"
},
"extra": {
"installer-name": "LivraisonForfaitaire"
}
}

View File

@@ -0,0 +1,4 @@
<?php
return array(
// 'an english string' => 'The displayed english string',
);

View File

@@ -0,0 +1,8 @@
<?php
return array(
'Error' => 'Erreur',
'Secret key' => 'Clé secrète',
'Site key' => 'Clé du site',
'Sorry, it seems that you\'re not human.' => 'Désolé, il semblerait que vous ne soyez pas un être humain.'
);

View File

@@ -1,2 +0,0 @@
order deny,allow
deny from all

View File

@@ -3,7 +3,7 @@
{if $smarty.get.back == '1'}
{$exclude = "0"}
{else}
{$exclude = "40"}
{$exclude = "40,48"}
{/if}
{form name="thelia.order.delivery"}
@@ -49,7 +49,17 @@
<td>
<div class="price">
{if $POSTAGE >= 0}
{format_money number=$POSTAGE symbol={currency attr='symbol'}}
{if $CODE eq "LivraisonForfaitaire"}
{assign var="montantsChaine" value={config key="livraisons_forfaitaires.montants"}|default:"0"}
{assign var="montantsTableau" value=";"|explode:"$montantsChaine"}
<select id="select-forfait" name="select-forfait">
{foreach from=$montantsTableau item=montant}
<option value="{$montant}">{format_money number="{$montant}" symbol={currency attr='symbol'}}</option>
{/foreach}
</select>
{else}
{format_money number=$POSTAGE symbol={currency attr='symbol'}}
{/if}
{else}
&nbsp;
{/if}

View File

@@ -24,8 +24,7 @@ require __DIR__ . '/../core/bootstrap.php';
$trustedIp = array(
'::1',
'127.0.0.1',
'82.229.232.53',
'217.128.222.247'
'90.1.209.212',
);
$request = Request::createFromGlobals();

View File

@@ -1 +1 @@
/var/www/clients/client8/web16/web/thelia/local/modules/Tinymce/Resources/js/tinymce
/Volumes/Dev/Sources/Clients/sterivein/thelia/local/modules/Tinymce/Resources/js/tinymce