diff --git a/local/modules/FreeShipping/AdminIncludes/module_configuration.html b/local/modules/FreeShipping/AdminIncludes/module_configuration.html index 2ac05909..8ca3178c 100644 --- a/local/modules/FreeShipping/AdminIncludes/module_configuration.html +++ b/local/modules/FreeShipping/AdminIncludes/module_configuration.html @@ -1,48 +1,162 @@ +{assign var="tab" value="export"} +{if isset($smarty.get.current_tab)} + {assign var="tab" value=$smarty.get.current_tab} +{/if}
+
+
+ - -
- - - - - - - - - - - {loop name="rules" type="free_shipping"} - - - - - - {/loop} - -
- {intl l="Free carriage rules"} - {loop type="auth" name="can_create" role="ADMIN" module="freeShipping" access="CREATE"} - - - - {/loop} -
{intl l="Area"}{intl l="Amount up to ... (€)"}{intl l="Actions"}
{$AREA_NAME}{$AMOUNT} -
- {loop type="auth" name="can_change" role="ADMIN" module="freeShipping" access="UPDATE"} - - - {/loop} +
+
+
+
+ {intl l="operations" d='freeshipping.ai'}
-
+
+ + + +
+
+ {form name="freeShipping.export.inet"} +
+ {form_hidden_fields form=$form} +
+
+ {intl l="Change orders status after export" d='freeshipping.ai'} +
+
+ {form_field form=$form field="new_status_id"} + + + + + + + + + + + + + + +
+   + + +
+   + + +
+   + + +
+ {/form_field} + {intl l="*If you choose this option, the exported orders would not be available on this page anymore" d='freeshipping.ai'} +
+
+ + + + + + + + + + {loop name="order.notsent.freeshipping" type="order.notsent.freeshipping"} + {form_field form=$form field="order_"|cat:$ID} + + + + + + + {/form_field} + {/loop} + +
+ {intl l="REF" d='freeshipping.ai'} + + {intl l="Date" d='freeshipping.ai'} + + {intl l="Total taxed amount" d='freeshipping.ai'} + + {intl l="Export" d='freeshipping.ai'} +
+ + + {$CREATE_DATE|date_format} + + {$TOTAL_TAXED_AMOUNT} {loop name="list.freeshipping.getcurrency" type="currency" id=$CURRENCY}{$SYMBOL}{/loop} + + +
+ +
+ {/form} +
+
+
+
+ {intl l="Configure FreeShipping rule" d='freeshipping.ai'} +
+ +
+
+ + + + + + + + + + + {loop name="rules" type="free_shipping"} + + + + + + {/loop} + +
+ {intl l="Free carriage rules"} + {loop type="auth" name="can_create" role="ADMIN" module="freeShipping" access="CREATE"} + + + + {/loop} +
{intl l="Area"}{intl l="Amount up to ... (€)"}{intl l="Actions"}
{$AREA_NAME}{$AMOUNT} +
+ {loop type="auth" name="can_change" role="ADMIN" module="freeShipping" access="UPDATE"} + + + {/loop} +
+
+
+
+
+
+
+
- -
- diff --git a/local/modules/FreeShipping/Config/config.xml b/local/modules/FreeShipping/Config/config.xml index 7105e842..45696bf3 100644 --- a/local/modules/FreeShipping/Config/config.xml +++ b/local/modules/FreeShipping/Config/config.xml @@ -6,11 +6,13 @@ +
+ @@ -30,6 +32,11 @@ + + + + + diff --git a/local/modules/FreeShipping/Config/module.xml b/local/modules/FreeShipping/Config/module.xml index 9a7fb261..e684d806 100644 --- a/local/modules/FreeShipping/Config/module.xml +++ b/local/modules/FreeShipping/Config/module.xml @@ -7,12 +7,12 @@ Franco de port - 1.0.1 + 1.1.3 Michaël Espeche mespeche@openstudio.fr delivery 2.1.0 - alpha + prod diff --git a/local/modules/FreeShipping/Config/routing.xml b/local/modules/FreeShipping/Config/routing.xml index 971d9b1d..516ba36b 100644 --- a/local/modules/FreeShipping/Config/routing.xml +++ b/local/modules/FreeShipping/Config/routing.xml @@ -21,4 +21,8 @@ FreeShipping\Controller\Admin\FreeShippingController::processUpdateAction + + FreeShipping\Controller\Admin\Export::export + + \ No newline at end of file diff --git a/local/modules/FreeShipping/Controller/Admin/FreeShippingController.php b/local/modules/FreeShipping/Controller/Admin/FreeShippingController.php index 0dbc73e8..f1219943 100644 --- a/local/modules/FreeShipping/Controller/Admin/FreeShippingController.php +++ b/local/modules/FreeShipping/Controller/Admin/FreeShippingController.php @@ -33,6 +33,7 @@ use Propel\Runtime\Exception\PropelException; use Thelia\Controller\Admin\AbstractCrudController; use Thelia\Controller\Admin\unknown; use Thelia\Core\Security\AccessManager; +use Thelia\Core\Security\Resource\AdminResources; use Thelia\Form\Exception\FormValidationException; /** @@ -51,18 +52,18 @@ class FreeShippingController extends AbstractCrudController 'freeShipping', 'manual', 'freeShipping_order', - - 'admin.freeShipping', - + AdminResources::MODULE, FreeShippingEvents::FREE_SHIPPING_RULE_CREATE, FreeShippingUpdateEvent::FREE_SHIPPING_RULE_UPDATE, FreeShippingDeleteEvent::FREE_SHIPPING_RULE_DELETE, null, - null + null, + 'FreeShipping' ); } - public function createRuleAction(){ + public function createRuleAction() + { if (null !== $response = $this->checkAuth(array(), array('FreeShipping'), AccessManager::CREATE)) { return $response; @@ -301,4 +302,4 @@ class FreeShippingController extends AbstractCrudController } -} \ No newline at end of file +} diff --git a/local/modules/FreeShipping/FreeShipping.php b/local/modules/FreeShipping/FreeShipping.php index 20d469f5..bf2bc2de 100644 --- a/local/modules/FreeShipping/FreeShipping.php +++ b/local/modules/FreeShipping/FreeShipping.php @@ -25,9 +25,15 @@ namespace FreeShipping; use FreeShipping\Model\Base\FreeShippingQuery; use Propel\Runtime\Connection\ConnectionInterface; +use Thelia\Core\Translation\Translator; use Thelia\Install\Database; use Thelia\Model\AreaQuery; use Thelia\Model\Country; +use Thelia\Model\Lang; +use Thelia\Model\LangQuery; +use Thelia\Model\Message; +use Thelia\Model\MessageQuery; +use Thelia\Model\ModuleQuery; use Thelia\Module\AbstractDeliveryModule; /** @@ -36,13 +42,64 @@ use Thelia\Module\AbstractDeliveryModule; */ class FreeShipping extends AbstractDeliveryModule { + /** The module domain for internationalisation */ + const MODULE_DOMAIN = "freeshipping"; + + /** + * The confirmation message identifier + */ + const MESSAGE_SEND_CONFIRMATION = "send_comfirmation_freeshipping"; + + /** @var Translator $translator */ + protected $translator; + + protected function trans($id, $locale, $parameters = []) + { + if ($this->translator === null) { + $this->translator = Translator::getInstance(); + } + + return $this->translator->trans($id, $parameters, self::MODULE_DOMAIN, $locale); + } + /** * @param ConnectionInterface $con */ public function postActivation(ConnectionInterface $con = null) { $database = new Database($con->getWrappedConnection()); - $database->insertSql(null, [ __DIR__.DS.'Config'.DS.'thelia.sql' ]); + $database->insertSql(null, [__DIR__ . DS . 'Config' . DS . 'thelia.sql']); + + + $languages = LangQuery::create()->find(); + + if (null === MessageQuery::create()->findOneByName(self::MESSAGE_SEND_CONFIRMATION)) { + $message = new Message(); + $message + ->setName(self::MESSAGE_SEND_CONFIRMATION) + ->setHtmlLayoutFileName('') + ->setHtmlTemplateFileName(self::MESSAGE_SEND_CONFIRMATION.'.html') + ->setTextLayoutFileName('') + ->setTextTemplateFileName(self::MESSAGE_SEND_CONFIRMATION.'.txt') + ; + + foreach ($languages as $language) { + /** @var Lang $language */ + $locale = $language->getLocale(); + + $message->setLocale($locale); + + $message->setTitle( + $this->trans('Order send confirmation', $locale) + ); + + $message->setSubject( + $this->trans('Order send confirmation', $locale) + ); + } + + $message->save(); + } } @@ -85,12 +142,14 @@ class FreeShipping extends AbstractDeliveryModule $areaId = $country->getAreaId(); $area = FreeShippingQuery::create()->findOneByAreaId($areaId); - $maxAmount = $area->getAmount(); + if (isset($area)) { + $maxAmount = $area->getAmount(); - if ($amount >= $maxAmount) { - return true; - } else { - return false; + if ($amount >= $maxAmount) { + return true; + } } + + return false; } } diff --git a/local/modules/FreeShipping/README.md b/local/modules/FreeShipping/README.md index 054e74b7..b363856a 100644 --- a/local/modules/FreeShipping/README.md +++ b/local/modules/FreeShipping/README.md @@ -2,15 +2,17 @@ This module is used to offer shipping from a minimum amount on a specific shipping zone. -## How to install +### Manually -This module must be into your ```modules/``` directory (thelia/local/modules/). +* Copy the module into ```/local/modules/``` directory and be sure that the name of the module is ```FreeShipping```. +* Activate it in your thelia administration panel -You can download the .zip file of this module or create a git submodule into your project like this : +### Composer + +Add it in your main thelia composer.json file ``` -cd /path-to-thelia -git submodule add https://github.com/thelia-modules/FreeShipping.git local/modules/FreeShipping +composer require thelia/free-shipping-module:~1.1.0 ``` Next, go to your Thelia admin panel for module activation. diff --git a/local/modules/FreeShipping/templates/backOffice/default/rule-edit.html b/local/modules/FreeShipping/templates/backOffice/default/rule-edit.html index cda80fc6..fadf4192 100644 --- a/local/modules/FreeShipping/templates/backOffice/default/rule-edit.html +++ b/local/modules/FreeShipping/templates/backOffice/default/rule-edit.html @@ -1,6 +1,5 @@ {extends file="admin-layout.tpl"} -{block name="check-resource"}admin.freeShipping{/block} {block name="check-access"}update{/block} {block name="page-title"}{intl l='Edit free shipping rule'}{/block} @@ -67,4 +66,4 @@ -{/block} \ No newline at end of file +{/block}