Module FreeShipping mis à jour.

This commit is contained in:
2020-02-26 19:59:19 +01:00
parent 311f2555b7
commit b0421200d3
8 changed files with 244 additions and 58 deletions

View File

@@ -1,9 +1,120 @@
{assign var="tab" value="export"}
{if isset($smarty.get.current_tab)}
{assign var="tab" value=$smarty.get.current_tab}
{/if}
<div class="row">
<div class="col-md-12">
<div class="general-block-decorator">
<div class="row">
<div class="col-md-12">
<ul id="tabbed-menu" class="nav nav-tabs">
<li class="{if $tab eq "export"}active{/if}"><a data-toggle="tab" href="#export">{intl l="Export" d='freeshipping.ai'}</a> </li>
<li class="{if $tab eq "rule"}active{/if}"><a data-toggle="tab" href="#rule">{intl l="Configure FreeShipping rule" d='freeshipping.ai'}</a></li>
</ul>
<div class="tab-content">
<div id="export" class="tab-pane {if $tab eq "export"}active{/if} form-container">
<div class="panel panel-default">
<div class="panel-heading clearfix">
{intl l="operations" d='freeshipping.ai'}
</div>
<div class="panel-body">
<button id="check-all-but" title="{intl l="Check all" d='freeshipping.ai'}" class="form-submit-button btn btn-sm btn-default">{intl l="Check all" d='freeshipping.ai'}</button>
<button id="uncheck-all-but" title="{intl l="Uncheck all" d='freeshipping.ai'}" class="form-submit-button btn btn-sm btn-default">{intl l="Uncheck all" d='freeshipping.ai'}</button>
<button id="reverse-all-but" title="{intl l="Reverse selection" d='freeshipping.ai'}" class="form-submit-button btn btn-sm btn-default">{intl l="Reverse selection" d='freeshipping.ai'}</button>
</div>
</div>
{form name="freeShipping.export.inet"}
<form action="{url path='/admin/module/freeshipping/export'}" method="post">
{form_hidden_fields form=$form}
<div class="panel panel-default">
<div class="panel-heading clearfix">
{intl l="Change orders status after export" d='freeshipping.ai'}
</div>
<div class="panel-body">
{form_field form=$form field="new_status_id"}
<table>
<tr>
<td>
<label for="nochange">{intl l="Do not change" d='freeshipping.ai'}</label>&nbsp;
</td>
<td>
<input type="radio" id="nochange" name="{$name}" value="nochange" {if $data eq "nochange"}checked{/if} />
</td>
</tr>
<tr>
<td>
<label for="processing">{intl l="Processing" d='freeshipping.ai'}</label>&nbsp;
</td>
<td>
<input type="radio" id="processing" name="{$name}" value="processing" {if $data eq "processing"}checked{/if} />
</td>
</tr>
<tr>
<td>
<label for="sent">{intl l="Sent" d='freeshipping.ai'}*</label>&nbsp;
</td>
<td>
<input type="radio" id="sent" name="{$name}" value="sent" {if $data eq "sent"}checked{/if} />
</td>
</tr>
</table>
{/form_field}
<span class="p">{intl l="*If you choose this option, the exported orders would not be available on this page anymore" d='freeshipping.ai'}</span>
</div>
</div>
<table class="table table-striped table-condensed">
<thead>
<th class="object-title">
{intl l="REF" d='freeshipping.ai'}
</th>
<th class="object-title">
{intl l="Date" d='freeshipping.ai'}
</th>
<th class="object-title">
{intl l="Total taxed amount" d='freeshipping.ai'}
</th>
<th class="object-title">
{intl l="Export" d='freeshipping.ai'}
</th>
</thead>
<tbody>
{loop name="order.notsent.freeshipping" type="order.notsent.freeshipping"}
{form_field form=$form field="order_"|cat:$ID}
<tr>
<td>
<label for="{$label_attr.for}">
{$label}
</label>
</td>
<td>
{$CREATE_DATE|date_format}
</td>
<td>
{$TOTAL_TAXED_AMOUNT} {loop name="list.freeshipping.getcurrency" type="currency" id=$CURRENCY}{$SYMBOL}{/loop}
</td>
<td>
<input type="checkbox" name="{$name}" id="{$label_attr.for}" value="true" class="form-control"/>
</td>
</tr>
{/form_field}
{/loop}
</tbody>
</table>
<button type="submit" name="export_freeshipping_form" value="stay" class="form-submit-button btn btn-sm btn-default" title="{intl l='Export' d='freeshipping.ai'}">{intl l='Export' d='freeshipping.ai'}</button>
</form>
{/form}
</div>
<div id="rule" class="tab-pane {if $tab eq "rule"}active{/if} form-container">
<div class="panel panel-default">
<div class="panel-heading">
{intl l="Configure FreeShipping rule" d='freeshipping.ai'}
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-condensed table-left-aligned">
<caption class="clearfix">
@@ -39,10 +150,13 @@
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -6,11 +6,13 @@
<loops>
<loop name="free_shipping" class="FreeShipping\Loop\FreeShipping" />
<loop name="order.notsent.freeshipping" class="FreeShipping\Loop\NotSendOrders" />
</loops>
<forms>
<form name="freeShipping.admin.rule.creation" class="FreeShipping\Form\FreeShippingRuleCreationForm"/>
<form name="freeShipping.admin.rule.modification" class="FreeShipping\Form\FreeShippingRuleModificationForm"/>
<form name="freeShipping.export.inet" class="FreeShipping\Form\ExportOrder" />
</forms>
<commands>
@@ -30,6 +32,11 @@
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
<service id="freeShipping.mail" class="FreeShipping\EventListener\SendConfirmationEmail" scope="request">
<argument type="service" id="thelia.parser" />
<argument type="service" id="mailer"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

@@ -7,12 +7,12 @@
<descriptive locale="fr_FR">
<title>Franco de port</title>
</descriptive>
<version>1.0.1</version>
<version>1.1.3</version>
<author>
<name>Michaël Espeche</name>
<email>mespeche@openstudio.fr</email>
</author>
<type>delivery</type>
<thelia>2.1.0</thelia>
<stability>alpha</stability>
<stability>prod</stability>
</module>

View File

@@ -21,4 +21,8 @@
<default key="_controller">FreeShipping\Controller\Admin\FreeShippingController::processUpdateAction</default>
</route>
<route id="admin.freeshipping.export" path="/admin/module/freeshipping/export" methods="post">
<default key="_controller">FreeShipping\Controller\Admin\Export::export</default>
</route>
</routes>

View File

@@ -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;

View File

@@ -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);
if (isset($area)) {
$maxAmount = $area->getAmount();
if ($amount >= $maxAmount) {
return true;
} else {
}
}
return false;
}
}
}

View File

@@ -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 ```<thelia_root>/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.

View File

@@ -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}