Merge with Master
This commit is contained in:
@@ -5,7 +5,7 @@ Thelia
|
||||
------
|
||||
[](https://travis-ci.org/thelia/thelia)
|
||||
|
||||
[Thelia](http://thelia.net) is an open source tool for creating e-business websites and managing online content. This software is published under GPL.
|
||||
[Thelia](http://thelia.net/v2) is an open source tool for creating e-business websites and managing online content. This software is published under GPL.
|
||||
|
||||
Here is the current developping next major version. You can download this version for testing or see the code.
|
||||
Here is the most recent developed code for the next major version (v2). You can download this version for testing or having a look on the code (or anything you wish, respecting GPL). See http://thelia.net/v2 web site for more information.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"symfony/form": "2.2.*",
|
||||
"symfony/validator": "2.3.*",
|
||||
|
||||
"smarty/smarty": "v3.1.15",
|
||||
"smarty/smarty": "v3.1.14",
|
||||
"kriswallsmith/assetic": "1.2.*@dev",
|
||||
"leafo/lessphp": "0.3.*@dev",
|
||||
"ptachoire/cssembed": "dev-master",
|
||||
|
||||
8
composer.lock
generated
8
composer.lock
generated
@@ -3,7 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "9c5ea1a9fd0f8ba533c41ff3676e0970",
|
||||
"hash": "852879ecc2e39e5cf283a3b1c5051a8e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ensepar/html2pdf",
|
||||
@@ -507,11 +507,11 @@
|
||||
},
|
||||
{
|
||||
"name": "smarty/smarty",
|
||||
"version": "v3.1.15",
|
||||
"version": "v3.1.14",
|
||||
"source": {
|
||||
"type": "svn",
|
||||
"url": "http://smarty-php.googlecode.com/svn",
|
||||
"reference": "/tags/v3.1.15/@4782"
|
||||
"reference": "/tags/v3.1.14/@4752"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2"
|
||||
@@ -547,7 +547,7 @@
|
||||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"time": "2013-10-01 21:08:54"
|
||||
"time": "2013-07-02 16:38:47"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
|
||||
131
core/lib/Thelia/Action/Area.php
Normal file
131
core/lib/Thelia/Action/Area.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaUpdatePostageEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\AreaQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Action\BaseAction;
|
||||
use Thelia\Model\Area as AreaModel;
|
||||
|
||||
|
||||
/**
|
||||
* Class Area
|
||||
* @package Thelia\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Area extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public function addCountry(AreaAddCountryEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country->setDispatcher($this->getDispatcher());
|
||||
$country->setAreaId($event->getAreaId())
|
||||
->save();
|
||||
|
||||
$event->setArea($country->getArea());
|
||||
}
|
||||
}
|
||||
|
||||
public function removeCountry(AreaRemoveCountryEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country->setDispatcher($this->getDispatcher());
|
||||
$country->setAreaId(null)
|
||||
->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePostage(AreaUpdatePostageEvent $event)
|
||||
{
|
||||
if (null !== $area = AreaQuery::create()->findPk($event->getAreaId())) {
|
||||
$area->setDispatcher($this->getDispatcher());
|
||||
$area
|
||||
->setPostage($event->getPostage())
|
||||
->save();
|
||||
|
||||
$event->setArea($area);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(AreaDeleteEvent $event)
|
||||
{
|
||||
if (null !== $area = AreaQuery::create()->findPk($event->getAreaId())) {
|
||||
$area->setDispatcher($this->getDispatcher());
|
||||
$area->delete();
|
||||
|
||||
$event->setArea($area);
|
||||
}
|
||||
}
|
||||
|
||||
public function create(AreaCreateEvent $event)
|
||||
{
|
||||
$area = new AreaModel();
|
||||
|
||||
$area
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setName($event->getAreaName())
|
||||
->save();
|
||||
|
||||
$event->setArea($area);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::AREA_ADD_COUNTRY => array('addCountry', 128),
|
||||
TheliaEvents::AREA_REMOVE_COUNTRY => array('removeCountry', 128),
|
||||
TheliaEvents::AREA_POSTAGE_UPDATE => array('updatePostage', 128),
|
||||
TheliaEvents::AREA_DELETE => array('delete', 128),
|
||||
TheliaEvents::AREA_CREATE => array('create', 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,19 @@ class Country extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
public function update(CountryUpdateEvent $event)
|
||||
{
|
||||
if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) {
|
||||
$country
|
||||
->setIsocode($event->getIsocode())
|
||||
->setIsoalpha2($event->getIsoAlpha2())
|
||||
->setIsoalpha3($event->getIsoAlpha3())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setChapo($event->getChapo())
|
||||
->setDescription($event->getDescription())
|
||||
->save();
|
||||
|
||||
$event->setCountry($country);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete(CountryDeleteEvent $event)
|
||||
|
||||
@@ -197,6 +197,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
$taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId());
|
||||
|
||||
$taxDetail = $product->getTaxRule()->getTaxDetail(
|
||||
$product,
|
||||
$taxCountry,
|
||||
$cartItem->getPrice(),
|
||||
$cartItem->getPromoPrice(),
|
||||
|
||||
92
core/lib/Thelia/Action/ShippingZone.php
Normal file
92
core/lib/Thelia/Action/ShippingZone.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\ShippingZone\ShippingZoneAddAreaEvent;
|
||||
use Thelia\Core\Event\ShippingZone\ShippingZoneRemoveAreaEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\AreaDeliveryModule;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZone
|
||||
* @package Thelia\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZone extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
|
||||
public function addArea(ShippingZoneAddAreaEvent $event)
|
||||
{
|
||||
$areaDelivery = new AreaDeliveryModule();
|
||||
|
||||
$areaDelivery
|
||||
->setAreaId($event->getAreaId())
|
||||
->setDeliveryModuleId($event->getShoppingZoneId())
|
||||
->save();
|
||||
}
|
||||
|
||||
public function removeArea(ShippingZoneRemoveAreaEvent $event)
|
||||
{
|
||||
$areaDelivery = AreaDeliveryModuleQuery::create()
|
||||
->filterByAreaId($event->getAreaId())
|
||||
->filterByDeliveryModuleId($event->getShoppingZoneId())
|
||||
->findOne();
|
||||
|
||||
if($areaDelivery) {
|
||||
$areaDelivery->delete();
|
||||
} else {
|
||||
throw new \RuntimeException(sprintf('areaDeliveryModule not found with area_id = %d and delivery_module_id = %d', $event->getAreaId(), $event->getShoppingZoneId()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of event names this subscriber wants to listen to.
|
||||
*
|
||||
* The array keys are event names and the value can be:
|
||||
*
|
||||
* * The method name to call (priority defaults to 0)
|
||||
* * An array composed of the method name to call and the priority
|
||||
* * An array of arrays composed of the method names to call and respective
|
||||
* priorities, or 0 if unset
|
||||
*
|
||||
* For instance:
|
||||
*
|
||||
* * array('eventName' => 'methodName')
|
||||
* * array('eventName' => array('methodName', $priority))
|
||||
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
|
||||
*
|
||||
* @return array The event names to listen to
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::SHIPPING_ZONE_ADD_AREA => array('addArea', 128),
|
||||
TheliaEvents::SHIPPING_ZONE_REMOVE_AREA => array('removeArea', 128),
|
||||
);
|
||||
}
|
||||
}
|
||||
150
core/lib/Thelia/Action/TaxRule.php
Normal file
150
core/lib/Thelia/Action/TaxRule.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Tax\TaxRuleEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\TaxRuleCountry;
|
||||
use Thelia\Model\TaxRuleCountryQuery;
|
||||
use Thelia\Model\TaxRule as TaxRuleModel;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
class TaxRule extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @param TaxRuleEvent $event
|
||||
*/
|
||||
public function create(TaxRuleEvent $event)
|
||||
{
|
||||
$taxRule = new TaxRuleModel();
|
||||
|
||||
$taxRule
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
;
|
||||
|
||||
$taxRule->save();
|
||||
|
||||
$event->setTaxRule($taxRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TaxRuleEvent $event
|
||||
*/
|
||||
public function update(TaxRuleEvent $event)
|
||||
{
|
||||
if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$taxRule
|
||||
->setDispatcher($this->getDispatcher())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
->save()
|
||||
;
|
||||
|
||||
|
||||
|
||||
$event->setTaxRule($taxRule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TaxRuleEvent $event
|
||||
*/
|
||||
public function updateTaxes(TaxRuleEvent $event)
|
||||
{
|
||||
if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$taxList = json_decode($event->getTaxList(), true);
|
||||
|
||||
/* clean the current tax rule for the countries */
|
||||
TaxRuleCountryQuery::create()
|
||||
->filterByTaxRule($taxRule)
|
||||
->filterByCountryId($event->getCountryList(), Criteria::IN)
|
||||
->delete();
|
||||
|
||||
/* for each country */
|
||||
foreach($event->getCountryList() as $country) {
|
||||
$position = 1;
|
||||
/* on applique les nouvelles regles */
|
||||
foreach($taxList as $tax) {
|
||||
if(is_array($tax)) {
|
||||
foreach($tax as $samePositionTax) {
|
||||
$taxModel = new TaxRuleCountry();
|
||||
$taxModel->setTaxRule($taxRule)
|
||||
->setCountryId($country)
|
||||
->setTaxId($samePositionTax)
|
||||
->setPosition($position);
|
||||
$taxModel->save();
|
||||
}
|
||||
} else {
|
||||
$taxModel = new TaxRuleCountry();
|
||||
$taxModel->setTaxRule($taxRule)
|
||||
->setCountryId($country)
|
||||
->setTaxId($tax)
|
||||
->setPosition($position);
|
||||
$taxModel->save();
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
}
|
||||
|
||||
$event->setTaxRule($taxRule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TaxRuleEvent $event
|
||||
*/
|
||||
public function delete(TaxRuleEvent $event)
|
||||
{
|
||||
if (null !== $taxRule = TaxRuleQuery::create()->findPk($event->getId())) {
|
||||
|
||||
$taxRule
|
||||
->delete()
|
||||
;
|
||||
|
||||
$event->setTaxRule($taxRule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(
|
||||
TheliaEvents::TAX_RULE_CREATE => array("create", 128),
|
||||
TheliaEvents::TAX_RULE_UPDATE => array("update", 128),
|
||||
TheliaEvents::TAX_RULE_TAXES_UPDATE => array("updateTaxes", 128),
|
||||
TheliaEvents::TAX_RULE_DELETE => array("delete", 128),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,11 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.taxrule" class="Thelia\Action\TaxRule">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.content" class="Thelia\Action\Content">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
@@ -121,6 +126,16 @@
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.area" class="Thelia\Action\Area">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.action.shippingZone" class="Thelia\Action\ShippingZone">
|
||||
<argument type="service" id="service_container"/>
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<loops>
|
||||
<loop class="Thelia\Core\Template\Loop\Accessory" name="accessory"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Address" name="address"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Area" name="area"/>
|
||||
<loop class="Thelia\Core\Template\Loop\AssociatedContent" name="associated_content"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Attribute" name="attribute"/>
|
||||
<loop class="Thelia\Core\Template\Loop\AttributeAvailability" name="attribute_availability"/>
|
||||
@@ -45,7 +46,9 @@
|
||||
<loop class="Thelia\Core\Template\Loop\Message" name="message"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Delivery" name="delivery"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Template" name="template"/> <!-- This is product templates ;-) -->
|
||||
<loop class="Thelia\Core\Template\Loop\Tax" name="tax"/>
|
||||
<loop class="Thelia\Core\Template\Loop\TaxRule" name="tax-rule"/>
|
||||
<loop class="Thelia\Core\Template\Loop\TaxRuleCountry" name="tax-rule-country"/>
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
@@ -111,6 +114,10 @@
|
||||
|
||||
<form name="thelia.admin.featureav.creation" class="Thelia\Form\FeatureAvCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.taxrule.modification" class="Thelia\Form\TaxRuleModificationForm"/>
|
||||
<form name="thelia.admin.taxrule.taxlistupdate" class="Thelia\Form\TaxRuleTaxListUpdateForm"/>
|
||||
<form name="thelia.admin.taxrule.add" class="Thelia\Form\TaxRuleCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.template.creation" class="Thelia\Form\TemplateCreationForm"/>
|
||||
<form name="thelia.admin.template.modification" class="Thelia\Form\TemplateModificationForm"/>
|
||||
|
||||
@@ -123,6 +130,13 @@
|
||||
|
||||
<form name="thelia.admin.admin-profile.creation" class="Thelia\Form\AdminProfileCreationForm"/>
|
||||
|
||||
<form name="thelia.admin.area.create" class="Thelia\Form\Area\AreaCreateForm"/>
|
||||
<form name="thelia.admin.area.modification" class="Thelia\Form\Area\AreaModificationForm"/>
|
||||
<form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/>
|
||||
|
||||
<form name="thelia.shopping_zone_area" class="Thelia\Form\ShippingZone\ShippingZoneAddArea"/>
|
||||
<form name="thelia.shopping_zone_remove_area" class="Thelia\Form\ShippingZone\ShippingZoneRemoveArea"/>
|
||||
</forms>
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<!-- Route to administration base -->
|
||||
<!-- Route to administration base -->
|
||||
<route id="admin" path="/admin">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminController::indexAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to the administration login page -->
|
||||
<!-- Route to the administration login page -->
|
||||
<route id="admin.login" path="/admin/login">
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::showLoginAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to the administration logout page -->
|
||||
<!-- Route to the administration logout page -->
|
||||
<route id="admin.logout" path="/admin/logout">
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLogoutAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Route to the login check controller -->
|
||||
<!-- Route to the login check controller -->
|
||||
<route id="admin.checklogin" path="/admin/checklogin">
|
||||
<default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
|
||||
</route>
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
|
||||
|
||||
<!-- Route to the catalog controller -->
|
||||
<!-- Route to the catalog controller -->
|
||||
|
||||
<route id="admin.catalog" path="/admin/catalog">
|
||||
<default key="_controller">Thelia\Controller\Admin\CategoryController::defaultAction</default>
|
||||
@@ -405,29 +405,6 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\FolderController::updatePositionAction</default>
|
||||
</route>
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.update" path="/admin/configuration/country/update/{country_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.delete" path="/admin/configuration/countries/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.toggle-default" path="/admin/configuration/country/toggleDefault">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::toggleDefaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- content routes management -->
|
||||
<route id="admin.content.create" path="/admin/content/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
|
||||
@@ -706,21 +683,79 @@
|
||||
<requirement key="shipping_zones_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-zones.area.add" path="/admin/configuration/shipping_zones/area/add" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::addArea</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-zones.area.remove" path="/admin/configuration/shipping_zones/area/remove">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingZoneController::removeArea</default>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Shipping zones routes management -->
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.default" path="/admin/configuration/shipping_configuration">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::indexAction</default>
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{shipping_configuration_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\ShippingConfigurationController::updateAction</default>
|
||||
<requirement key="shipping_configuration_id">\d+</requirement>
|
||||
<route id="admin.configuration.shipping-configuration.update.view" path="/admin/configuration/shipping_configuration/update/{area_id}" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::updateAction</default>
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.delete" path="/admin/configuration/shipping_configuration/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.create" path="/admin/configuration/shipping_configuration/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.update.postage" path="/admin/configuration/shipping_configuration/update_postage/{area_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::updatePostageAction</default>
|
||||
<requirement key="area_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.add" path="/admin/configuration/shipping_configuration/country/add" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::addCountry</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.shipping-configuration.country.remove" path="/admin/configuration/shipping_configuration/country/remove" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Admin\AreaController::removeCountry</default>
|
||||
</route>
|
||||
|
||||
<!-- end shipping routes management -->
|
||||
|
||||
<!-- Countries routes management -->
|
||||
|
||||
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.update" path="/admin/configuration/country/update/{country_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.save" path="/admin/configuration/country/save/{country_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::processUpdateAction</default>
|
||||
<requirement key="country_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.delete" path="/admin/configuration/countries/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.countries.toggle-default" path="/admin/configuration/country/toggleDefault">
|
||||
<default key="_controller">Thelia\Controller\Admin\CountryController::toggleDefaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end countries routes management -->
|
||||
|
||||
<!-- feature and features value management -->
|
||||
|
||||
@@ -787,49 +822,41 @@
|
||||
|
||||
<!-- end Modules rule management -->
|
||||
|
||||
<!-- mailing system management -->
|
||||
|
||||
<route id="admin.configuration.mailing-system.default" path="/admin/configuration/mailing_system">
|
||||
<default key="_controller">Thelia\Controller\Admin\MailingSystemController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end mailing system management -->
|
||||
|
||||
<!-- languages system management -->
|
||||
|
||||
<route id="admin.configuration.languages.default" path="/admin/configuration/languages">
|
||||
<default key="_controller">Thelia\Controller\Admin\LanguageController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end mailing system management -->
|
||||
|
||||
<!-- admin profiles management -->
|
||||
|
||||
<route id="admin.configuration.admin-profiles.default" path="/admin/configuration/admin_profiles">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminProfileController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end admin profiles management -->
|
||||
|
||||
<!-- taxe rules management -->
|
||||
|
||||
<route id="admin.configuration.taxes-rules.default" path="/admin/configuration/taxes_rules">
|
||||
<route id="admin.configuration.taxes-rules.list" path="/admin/configuration/taxes_rules">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::defaultAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.taxes-rules.update" path="/admin/configuration/taxes_rules/update/{tax_rule_id}" methods="get">
|
||||
<route id="admin.configuration.taxes-rules.update" path="/admin/configuration/taxes_rules/update/{tax_rule_id}">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::updateAction</default>
|
||||
<requirement key="tax_rule_id">\d+</requirement>
|
||||
</route>
|
||||
|
||||
<!-- end admin profiles management -->
|
||||
<route id="admin.configuration.taxes-rules.add" path="/admin/configuration/taxes_rules/add">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::createAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.taxes-rules.save" path="/admin/configuration/taxes_rules/save">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::processUpdateAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.taxes-rules.saveTaxes" path="/admin/configuration/taxes_rules/saveTaxes">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::processUpdateTaxesAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.taxes-rules.delete" path="/admin/configuration/taxes_rules/delete">
|
||||
<default key="_controller">Thelia\Controller\Admin\TaxRuleController::deleteAction</default>
|
||||
</route>
|
||||
|
||||
<!-- end tax rules management -->
|
||||
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
<route id="admin.processTemplate" path="/admin/{template}">
|
||||
<default key="_controller">Thelia\Controller\Admin\AdminController::processTemplateAction</default>
|
||||
<requirement key="template">.*</requirement>
|
||||
</route>
|
||||
|
||||
</routes>
|
||||
</routes>
|
||||
326
core/lib/Thelia/Controller/Admin/AreaController.php
Normal file
326
core/lib/Thelia/Controller/Admin/AreaController.php
Normal file
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\Area\AreaAddCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||
use Thelia\Core\Event\Area\AreaDeleteEvent;
|
||||
use Thelia\Core\Event\Area\AreaRemoveCountryEvent;
|
||||
use Thelia\Core\Event\Area\AreaUpdateEvent;
|
||||
use Thelia\Core\Event\Area\AreaUpdatePostageEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Area\AreaCountryForm;
|
||||
use Thelia\Form\Area\AreaCreateForm;
|
||||
use Thelia\Form\Area\AreaModificationForm;
|
||||
use Thelia\Form\Area\AreaPostageForm;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\AreaQuery;
|
||||
|
||||
/**
|
||||
* Class AreaController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'area',
|
||||
null,
|
||||
null,
|
||||
|
||||
'admin.area.default',
|
||||
'admin.area.create',
|
||||
'admin.area.update',
|
||||
'admin.area.delete',
|
||||
|
||||
TheliaEvents::AREA_CREATE,
|
||||
TheliaEvents::AREA_UPDATE,
|
||||
TheliaEvents::AREA_DELETE
|
||||
);
|
||||
}
|
||||
|
||||
protected function getAreaId()
|
||||
{
|
||||
return $this->getRequest()->get('area_id', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new AreaCreateForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the update form for this object
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new AreaModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param unknown $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'name' => $object->getName()
|
||||
);
|
||||
|
||||
return new AreaModificationForm($this->getRequest(), 'form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the creation event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*
|
||||
* @return \Thelia\Core\Event\Area\AreaCreateEvent
|
||||
*/
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$event = new AreaCreateEvent();
|
||||
|
||||
return $this->hydrateEvent($event, $formData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the update event with the provided form data
|
||||
*
|
||||
* @param unknown $formData
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new AreaUpdateEvent();
|
||||
|
||||
return $this->hydrateEvent($event, $formData);
|
||||
}
|
||||
|
||||
private function hydrateEvent($event, $formData)
|
||||
{
|
||||
$event->setAreaName($formData['name']);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the delete event with the provided form data
|
||||
*/
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
return new AreaDeleteEvent($this->getAreaId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the event contains the object, e.g. the action has updated the object in the event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\Area\AreaEvent $event
|
||||
*/
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasArea();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created object from an event.
|
||||
*
|
||||
* @param \Thelia\Core\Event\Area\AreaEvent $event
|
||||
*/
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->getArea();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an existing object from the database
|
||||
*/
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return AreaQuery::create()->findPk($this->getAreaId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object label form the object event (name, title, etc.)
|
||||
*
|
||||
* @param \Thelia\Model\Area $object
|
||||
*/
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object ID from the object
|
||||
*
|
||||
* @param \Thelia\Model\Area $object
|
||||
*/
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the main list template
|
||||
*
|
||||
* @param unknown $currentOrder, if any, null otherwise.
|
||||
*/
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
return $this->render("shipping-configuration");
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('shipping-configuration-edit',array(
|
||||
'area_id' => $this->getAreaId()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the edition template
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.shipping-configuration.update.view', array(), array(
|
||||
"area_id" => $this->getAreaId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the list template
|
||||
*/
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.shipping-configuration.default');
|
||||
}
|
||||
|
||||
/**
|
||||
* add a country to a define area
|
||||
*/
|
||||
public function addCountry()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
|
||||
$areaCountryForm = new AreaCountryForm($this->getRequest());
|
||||
$error_msg = null;
|
||||
try {
|
||||
|
||||
$form = $this->validateForm($areaCountryForm);
|
||||
|
||||
$event = new AreaAddCountryEvent($form->get('area_id')->getData(), $form->get('country_id')->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::AREA_ADD_COUNTRY, $event);
|
||||
|
||||
if (! $this->eventContainsObject($event))
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName)));
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $this->getObjectFromEvent($event)) {
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified, new country added", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($areaCountryForm->getSuccessUrl());
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)), $error_msg, $areaCountryForm);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
public function removeCountry()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
$request = $this->getRequest();
|
||||
$removeCountryEvent = new AreaRemoveCountryEvent($request->request->get('areai_id', 0), $request->request->get('country_id', 0));
|
||||
|
||||
$this->dispatch(TheliaEvents::AREA_REMOVE_COUNTRY, $removeCountryEvent);
|
||||
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
|
||||
public function updatePostageAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
|
||||
$areaUpdateForm = new AreaPostageForm($this->getRequest());
|
||||
$error_msg = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($areaUpdateForm);
|
||||
|
||||
$event = new AreaUpdatePostageEvent($form->get('area_id')->getData());
|
||||
$event->setPostage($form->get('postage')->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::AREA_POSTAGE_UPDATE, $event);
|
||||
|
||||
if (! $this->eventContainsObject($event))
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName)));
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $this->getObjectFromEvent($event)) {
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified, country remove", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($areaUpdateForm->getSuccessUrl());
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)), $error_msg, $areaUpdateForm);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ class BaseAdminController extends BaseController
|
||||
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
|
||||
* @param unknown $urlParameters the URL parametrs, as a var/value pair array
|
||||
*/
|
||||
public function redirectToRoute($routeId, $urlParameters = array(), $routeParameters = array())
|
||||
public function redirectToRoute($routeId, array $urlParameters = array(), array $routeParameters = array())
|
||||
{
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, $routeParameters), $urlParameters));
|
||||
}
|
||||
|
||||
@@ -39,24 +39,6 @@ use Thelia\Model\CountryQuery;
|
||||
class CountryController extends AbstractCrudController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $objectName the lower case object name. Example. "message"
|
||||
*
|
||||
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
|
||||
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
|
||||
*
|
||||
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
|
||||
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
|
||||
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
|
||||
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
|
||||
*
|
||||
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
|
||||
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
|
||||
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
|
||||
*
|
||||
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
|
||||
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
@@ -129,7 +111,7 @@ class CountryController extends AbstractCrudController
|
||||
*/
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new CountryUpdateEvent();
|
||||
$event = new CountryUpdateEvent($formData['id']);
|
||||
|
||||
return $this->hydrateEvent($event, $formData);
|
||||
}
|
||||
@@ -139,6 +121,8 @@ class CountryController extends AbstractCrudController
|
||||
$event
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setIsocode($formData['isocode'])
|
||||
->setIsoAlpha2($formData['isoalpha2'])
|
||||
->setIsoAlpha3($formData['isoalpha3'])
|
||||
@@ -236,7 +220,10 @@ class CountryController extends AbstractCrudController
|
||||
*/
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute('admin.configuration.countries.update', array(), $this->getRequest()->get('country_id', 0));
|
||||
$this->redirectToRoute('admin.configuration.countries.update', array(), array(
|
||||
"country_id" => $this->getRequest()->get('country_id', 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\ShippingZone\ShippingZoneAddAreaEvent;
|
||||
use Thelia\Core\Event\ShippingZone\ShippingZoneRemoveAreaEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\ShippingZone\ShippingZoneAddArea;
|
||||
use Thelia\Form\ShippingZone\ShippingZoneRemoveArea;
|
||||
|
||||
/**
|
||||
* Class ShippingZoneController
|
||||
@@ -30,6 +36,8 @@ namespace Thelia\Controller\Admin;
|
||||
*/
|
||||
class ShippingZoneController extends BaseAdminController
|
||||
{
|
||||
public $objectName = 'areaDeliveryModule';
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
|
||||
@@ -38,8 +46,99 @@ class ShippingZoneController extends BaseAdminController
|
||||
|
||||
public function updateAction($shipping_zones_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.view")) return $response;
|
||||
return $this->render("shipping-zones-edit", array(
|
||||
"shipping_zones_id" => $shipping_zones_id
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function addArea()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.update")) return $response;
|
||||
|
||||
$shippingAreaForm = new ShippingZoneAddArea($this->getRequest());
|
||||
$error_msg = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($shippingAreaForm);
|
||||
|
||||
$event = new ShippingZoneAddAreaEvent(
|
||||
$form->get('area_id')->getData(),
|
||||
$form->get('shipping_zone_id')->getData()
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::SHIPPING_ZONE_ADD_AREA, $event);
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($shippingAreaForm->getSuccessUrl());
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)), $error_msg, $shippingAreaForm);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
public function removeArea()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-zones.update")) return $response;
|
||||
|
||||
$shippingAreaForm = new ShippingZoneRemoveArea($this->getRequest());
|
||||
$error_msg = null;
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($shippingAreaForm);
|
||||
|
||||
$event = new ShippingZoneRemoveAreaEvent(
|
||||
$form->get('area_id')->getData(),
|
||||
$form->get('shipping_zone_id')->getData()
|
||||
);
|
||||
|
||||
$this->dispatch(TheliaEvents::SHIPPING_ZONE_REMOVE_AREA, $event);
|
||||
|
||||
// Redirect to the success URL
|
||||
$this->redirect($shippingAreaForm->getSuccessUrl());
|
||||
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("%obj modification", array('%obj' => $this->objectName)), $error_msg, $shippingAreaForm);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the edition template
|
||||
*/
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render("shipping-zones-edit", array(
|
||||
"shipping_zones_id" => $this->getShippingZoneId()
|
||||
));
|
||||
}
|
||||
|
||||
protected function getShippingZoneId()
|
||||
{
|
||||
return $this->getRequest()->get('shipping_zone_id', 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,23 +23,265 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
/**
|
||||
* Class TaxRuleController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class TaxRuleController extends BaseAdminController
|
||||
use Thelia\Core\Event\Tax\TaxRuleEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\TaxRuleCreationForm;
|
||||
use Thelia\Form\TaxRuleModificationForm;
|
||||
use Thelia\Form\TaxRuleTaxListUpdateForm;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
class TaxRuleController extends AbstractCrudController
|
||||
{
|
||||
public function defaultAction()
|
||||
public function __construct()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.taxes-rules.view")) return $response;
|
||||
return $this->render("taxes-rules", array("display_taxes_rules" => 20));
|
||||
parent::__construct(
|
||||
'taxrule',
|
||||
'manual',
|
||||
'order',
|
||||
|
||||
'admin.configuration.taxrule.view',
|
||||
'admin.configuration.taxrule.create',
|
||||
'admin.configuration.taxrule.update',
|
||||
'admin.configuration.taxrule.delete',
|
||||
|
||||
TheliaEvents::TAX_RULE_CREATE,
|
||||
TheliaEvents::TAX_RULE_UPDATE,
|
||||
TheliaEvents::TAX_RULE_DELETE
|
||||
);
|
||||
}
|
||||
|
||||
public function updateAction($tax_rule_id){
|
||||
return $this->render("tax-rule-edit", array(
|
||||
"tax_rule_id" => $tax_rule_id
|
||||
));
|
||||
protected function getCreationForm()
|
||||
{
|
||||
return new TaxRuleCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
return new TaxRuleModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
protected function getCreationEvent($formData)
|
||||
{
|
||||
$event = new TaxRuleEvent();
|
||||
|
||||
$event->setLocale($formData['locale']);
|
||||
$event->setTitle($formData['title']);
|
||||
$event->setDescription($formData['description']);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getUpdateEvent($formData)
|
||||
{
|
||||
$event = new TaxRuleEvent();
|
||||
|
||||
$event->setLocale($formData['locale']);
|
||||
$event->setId($formData['id']);
|
||||
$event->setTitle($formData['title']);
|
||||
$event->setDescription($formData['description']);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getUpdateTaxListEvent($formData)
|
||||
{
|
||||
$event = new TaxRuleEvent();
|
||||
|
||||
$event->setId($formData['id']);
|
||||
$event->setTaxList($formData['tax_list']);
|
||||
$event->setCountryList($formData['country_list']);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function getDeleteEvent()
|
||||
{
|
||||
$event = new TaxRuleEvent();
|
||||
|
||||
$event->setId(
|
||||
$this->getRequest()->get('tax_rule_id', 0)
|
||||
);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
protected function eventContainsObject($event)
|
||||
{
|
||||
return $event->hasTaxRule();
|
||||
}
|
||||
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'description' => $object->getDescription(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new TaxRuleModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function hydrateTaxUpdateForm($object)
|
||||
{
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new TaxRuleTaxListUpdateForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
protected function getObjectFromEvent($event)
|
||||
{
|
||||
return $event->hasTaxRule() ? $event->getTaxRule() : null;
|
||||
}
|
||||
|
||||
protected function getExistingObject()
|
||||
{
|
||||
return TaxRuleQuery::create()
|
||||
->joinWithI18n($this->getCurrentEditionLocale())
|
||||
->findOneById($this->getRequest()->get('tax_rule_id'));
|
||||
}
|
||||
|
||||
protected function getObjectLabel($object)
|
||||
{
|
||||
return $object->getTitle();
|
||||
}
|
||||
|
||||
protected function getObjectId($object)
|
||||
{
|
||||
return $object->getId();
|
||||
}
|
||||
|
||||
protected function getViewArguments($country = null, $tab = null)
|
||||
{
|
||||
return array(
|
||||
'tab' => $tab === null ? $this->getRequest()->get('tab', 'data') : $tab,
|
||||
'country' => $country === null ? $this->getRequest()->get('country', CountryQuery::create()->findOneByByDefault(1)->getId()) : $country,
|
||||
);
|
||||
}
|
||||
|
||||
protected function getRouteArguments($tax_rule_id = null)
|
||||
{
|
||||
return array(
|
||||
'tax_rule_id' => $tax_rule_id === null ? $this->getRequest()->get('tax_rule_id') : $tax_rule_id,
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderListTemplate($currentOrder)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render(
|
||||
'taxes-rules',
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
return $this->render('tax-rule-edit', array_merge($this->getViewArguments(), $this->getRouteArguments()));
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate($request = null, $country = null)
|
||||
{
|
||||
// We always return to the feature edition form
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.taxes-rules.update",
|
||||
$this->getViewArguments($country),
|
||||
$this->getRouteArguments()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put in this method post object creation processing if required.
|
||||
*
|
||||
* @param TaxRuleEvent $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalCreateAction($createEvent)
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.taxes-rules.update",
|
||||
$this->getViewArguments(),
|
||||
$this->getRouteArguments($createEvent->getTaxRule()->getId())
|
||||
);
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.taxes-rules.list"
|
||||
);
|
||||
}
|
||||
|
||||
public function updateAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response;
|
||||
|
||||
$object = $this->getExistingObject();
|
||||
|
||||
if ($object != null) {
|
||||
|
||||
// Hydrate the form abd pass it to the parser
|
||||
$changeTaxesForm = $this->hydrateTaxUpdateForm($object);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeTaxesForm);
|
||||
}
|
||||
|
||||
return parent::updateAction();
|
||||
}
|
||||
|
||||
public function processUpdateTaxesAction()
|
||||
{
|
||||
// Check current user authorization
|
||||
if (null !== $response = $this->checkAuth('admin.configuration.taxrule.update')) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
// Create the form from the request
|
||||
$changeForm = new TaxRuleTaxListUpdateForm($this->getRequest());
|
||||
|
||||
try {
|
||||
// Check the form against constraints violations
|
||||
$form = $this->validateForm($changeForm, "POST");
|
||||
|
||||
// Get the form field values
|
||||
$data = $form->getData();
|
||||
|
||||
$changeEvent = $this->getUpdateTaxListEvent($data);
|
||||
|
||||
$this->dispatch(TheliaEvents::TAX_RULE_TAXES_UPDATE, $changeEvent);
|
||||
|
||||
if (! $this->eventContainsObject($changeEvent))
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj', $this->objectName)));
|
||||
|
||||
// Log object modification
|
||||
if (null !== $changedObject = $this->getObjectFromEvent($changeEvent)) {
|
||||
$this->adminLogAppend(sprintf("%s %s (ID %s) modified", ucfirst($this->objectName), $this->getObjectLabel($changedObject), $this->getObjectId($changedObject)));
|
||||
}
|
||||
|
||||
if ($response == null) {
|
||||
$this->redirectToEditionTemplate($this->getRequest(), isset($data['country_list'][0]) ? $data['country_list'][0] : null);
|
||||
} else {
|
||||
return $response;
|
||||
}
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext($this->getTranslator()->trans("%obj modification", array('%obj' => 'taxrule')), $error_msg, $changeForm, $ex);
|
||||
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ class RegisterRouterPass implements CompilerPassInterface
|
||||
$priority = isset($attributes[0]["priority"]) ? $attributes[0]["priority"] : 0;
|
||||
$router = $container->getDefinition($id);
|
||||
$router->addMethodCall("setOption", array("matcher_cache_class", $container::camelize("ProjectUrlMatcher".$id)));
|
||||
$router->addMethodCall("setOption", array("generator_cache_class", $container::camelize("ProjectUrlGenerator".$id)));
|
||||
|
||||
$chainRouter->addMethodCall("add", array(new Reference($id), $priority));
|
||||
|
||||
@@ -76,7 +77,8 @@ class RegisterRouterPass implements CompilerPassInterface
|
||||
array(
|
||||
"cache_dir" => $container->getParameter("kernel.cache_dir"),
|
||||
"debug" => $container->getParameter("kernel.debug"),
|
||||
"matcher_cache_class" => $container::camelize("ProjectUrlMatcher".$moduleCode)
|
||||
"matcher_cache_class" => $container::camelize("ProjectUrlMatcher".$moduleCode),
|
||||
"generator_cache_class" => $container::camelize("ProjectUrlGenerator".$moduleCode),
|
||||
),
|
||||
new Reference("request.context")
|
||||
)
|
||||
|
||||
86
core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php
Normal file
86
core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaAddCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaAddCountryEvent extends AreaEvent
|
||||
{
|
||||
protected $area_id;
|
||||
protected $country_id;
|
||||
|
||||
function __construct($area_id, $country_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
@@ -17,29 +17,37 @@
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingConfigurationController
|
||||
* @package Thelia\Controller\Admin
|
||||
* Class AreaCreateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingConfigurationController extends BaseAdminController
|
||||
class AreaCreateEvent extends AreaEvent
|
||||
{
|
||||
public function indexAction()
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @param mixed $name
|
||||
*/
|
||||
public function setAreaName($name)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.shipping-configuration.view")) return $response;
|
||||
return $this->render("shipping-configuration", array("display_shipping_configuration" => 20));
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function updateAction($shipping_configuration_id)
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaName()
|
||||
{
|
||||
return $this->render("shipping-configuration-edit", array(
|
||||
"shipping_configuration_id" => $shipping_configuration_id
|
||||
));
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
65
core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php
Normal file
65
core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaDeleteEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaDeleteEvent extends AreaEvent
|
||||
{
|
||||
/**
|
||||
* @var int area id
|
||||
*/
|
||||
protected $area_id;
|
||||
|
||||
public function __construct($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
66
core/lib/Thelia/Core/Event/Area/AreaEvent.php
Normal file
66
core/lib/Thelia/Core/Event/Area/AreaEvent.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaEvent
|
||||
* @package Thelia\Core\Event\Shipping
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaEvent extends ActionEvent
|
||||
{
|
||||
protected $area;
|
||||
|
||||
public function __construct($area = null)
|
||||
{
|
||||
$this->area = $area;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setArea($area)
|
||||
{
|
||||
$this->area = $area;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getArea()
|
||||
{
|
||||
return $this->area;
|
||||
}
|
||||
|
||||
public function hasArea()
|
||||
{
|
||||
return null !== $this->area;
|
||||
}
|
||||
}
|
||||
35
core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php
Normal file
35
core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaRemoveCountryEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaRemoveCountryEvent extends AreaAddCountryEvent
|
||||
{
|
||||
|
||||
}
|
||||
35
core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php
Normal file
35
core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaUpdateEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaUpdateEvent extends AreaCreateEvent
|
||||
{
|
||||
|
||||
}
|
||||
85
core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php
Normal file
85
core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Area;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaUpdatePostageEvent
|
||||
* @package Thelia\Core\Event\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaUpdatePostageEvent extends AreaEvent
|
||||
{
|
||||
protected $area_id;
|
||||
protected $postage;
|
||||
|
||||
function __construct($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postage
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostage($postage)
|
||||
{
|
||||
$this->postage = $postage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostage()
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -31,5 +31,90 @@ namespace Thelia\Core\Event\Country;
|
||||
*/
|
||||
class CountryUpdateEvent extends CountryCreateEvent
|
||||
{
|
||||
protected $country_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
function __construct($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $country_id
|
||||
*/
|
||||
public function setCountryId($country_id)
|
||||
{
|
||||
$this->country_id = $country_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountryId()
|
||||
{
|
||||
return $this->country_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\ShippingZone;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZoneAddAreaEvent
|
||||
* @package Thelia\Core\Event\ShippingZone
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneAddAreaEvent extends ActionEvent
|
||||
{
|
||||
protected $area_id;
|
||||
protected $shopping_zone_id;
|
||||
|
||||
function __construct($area_id, $shopping_zone_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
$this->shopping_zone_id = $shopping_zone_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $area_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAreaId($area_id)
|
||||
{
|
||||
$this->area_id = $area_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAreaId()
|
||||
{
|
||||
return $this->area_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $shopping_zone_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setShoppingZoneId($shopping_zone_id)
|
||||
{
|
||||
$this->shopping_zone_id = $shopping_zone_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getShoppingZoneId()
|
||||
{
|
||||
return $this->shopping_zone_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\ShippingZone;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZoneRemoveAreaEvent
|
||||
* @package Thelia\Core\Event\ShippingZone
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneRemoveAreaEvent extends ShippingZoneAddAreaEvent
|
||||
{
|
||||
|
||||
}
|
||||
122
core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php
Normal file
122
core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Tax;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\TaxRule;
|
||||
|
||||
class TaxRuleEvent extends ActionEvent
|
||||
{
|
||||
protected $taxRule = null;
|
||||
|
||||
protected $locale;
|
||||
protected $id;
|
||||
protected $title;
|
||||
protected $description;
|
||||
protected $countryList;
|
||||
protected $taxList;
|
||||
|
||||
public function __construct(TaxRule $taxRule = null)
|
||||
{
|
||||
$this->taxRule = $taxRule;
|
||||
}
|
||||
|
||||
public function hasTaxRule()
|
||||
{
|
||||
return ! is_null($this->taxRule);
|
||||
}
|
||||
|
||||
public function getTaxRule()
|
||||
{
|
||||
return $this->taxRule;
|
||||
}
|
||||
|
||||
public function setTaxRule(TaxRule $taxRule)
|
||||
{
|
||||
$this->taxRule = $taxRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setCountryList($countryList)
|
||||
{
|
||||
$this->countryList = $countryList;
|
||||
}
|
||||
|
||||
public function getCountryList()
|
||||
{
|
||||
return $this->countryList;
|
||||
}
|
||||
|
||||
public function setTaxList($taxList)
|
||||
{
|
||||
$this->taxList = $taxList;
|
||||
}
|
||||
|
||||
public function getTaxList()
|
||||
{
|
||||
return $this->taxList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -232,6 +232,30 @@ final class TheliaEvents
|
||||
const BEFORE_UPDATECOUNTRY = "action.before_updateCountry";
|
||||
const AFTER_UPDATECOUNTRY = "action.after_updateCountry";
|
||||
|
||||
// -- AREA CONFIGURATION MANAGEMENT
|
||||
|
||||
const AREA_CREATE = 'action.createArea';
|
||||
const AREA_UPDATE = 'action.updateArea';
|
||||
const AREA_DELETE = 'action.deleteArea';
|
||||
|
||||
const AREA_ADD_COUNTRY = 'action.area.addCountry';
|
||||
const AREA_REMOVE_COUNTRY = 'action.area.removeCountry';
|
||||
const AREA_POSTAGE_UPDATE = 'action.area.postageUpdate';
|
||||
|
||||
const BEFORE_CREATEAREA = 'action.before_createArea';
|
||||
const AFTER_CREATEAREA = 'action.after_createArea';
|
||||
|
||||
const BEFORE_UPDATEAREA = 'action.before_updateArea';
|
||||
const AFTER_UPDATEAREA = 'action.after_updateArea';
|
||||
|
||||
const BEFORE_DELETEAREA = 'action.before_deleteArea';
|
||||
const AFTER_DELETEAREA = 'action.after_deleteArea';
|
||||
|
||||
// -- SHIPPING ZONE MANAGEMENT
|
||||
|
||||
const SHIPPING_ZONE_ADD_AREA = 'action.shippingZone.addArea';
|
||||
const SHIPPING_ZONE_REMOVE_AREA = 'action.shippingZone.removeArea';
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
@@ -519,6 +543,14 @@ final class TheliaEvents
|
||||
|
||||
const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency';
|
||||
|
||||
// -- Tax Rules management ---------------------------------------------
|
||||
|
||||
const TAX_RULE_CREATE = "action.createTaxRule";
|
||||
const TAX_RULE_UPDATE = "action.updateTaxRule";
|
||||
const TAX_RULE_DELETE = "action.deleteTaxRule";
|
||||
const TAX_RULE_SET_DEFAULT = "action.setDefaultTaxRule";
|
||||
const TAX_RULE_TAXES_UPDATE = "action.updateTaxesTaxRule";
|
||||
|
||||
// -- Product templates management -----------------------------------------
|
||||
|
||||
const TEMPLATE_CREATE = "action.createTemplate";
|
||||
|
||||
144
core/lib/Thelia/Core/Template/Loop/Area.php
Normal file
144
core/lib/Thelia/Core/Template/Loop/Area.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\AreaQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class Area
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class Area extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* define all args used in your loop
|
||||
*
|
||||
*
|
||||
* example :
|
||||
*
|
||||
* public function getArgDefinitions()
|
||||
* {
|
||||
* return new ArgumentCollection(
|
||||
* Argument::createIntListTypeArgument('id'),
|
||||
* new Argument(
|
||||
* 'ref',
|
||||
* new TypeCollection(
|
||||
* new Type\AlphaNumStringListType()
|
||||
* )
|
||||
* ),
|
||||
* Argument::createIntListTypeArgument('category'),
|
||||
* Argument::createBooleanTypeArgument('new'),
|
||||
* Argument::createBooleanTypeArgument('promo'),
|
||||
* Argument::createFloatTypeArgument('min_price'),
|
||||
* Argument::createFloatTypeArgument('max_price'),
|
||||
* Argument::createIntTypeArgument('min_stock'),
|
||||
* Argument::createFloatTypeArgument('min_weight'),
|
||||
* Argument::createFloatTypeArgument('max_weight'),
|
||||
* Argument::createBooleanTypeArgument('current'),
|
||||
*
|
||||
* );
|
||||
* }
|
||||
*
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntTypeArgument('with_zone'),
|
||||
Argument::createIntTypeArgument('without_zone')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* this function have to be implement in your own loop class.
|
||||
*
|
||||
* All loops parameters can be accessible via getter.
|
||||
*
|
||||
* for example, ref parameter is accessible through getRef method
|
||||
*
|
||||
* @param $pagination
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$id = $this->getId();
|
||||
|
||||
$search = AreaQuery::create();
|
||||
|
||||
if ($id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$withZone = $this->getWith_zone();
|
||||
|
||||
if ($withZone) {
|
||||
$search->joinAreaDeliveryModule('with_zone')
|
||||
->where('`with_zone`.delivery_module_id '.Criteria::EQUAL.' ?', $withZone, \PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
$withoutZone = $this->getWithout_zone();
|
||||
|
||||
if($withoutZone)
|
||||
{
|
||||
$search->joinAreaDeliveryModule('without_zone', Criteria::LEFT_JOIN)
|
||||
->addJoinCondition('without_zone', 'delivery_module_id '.Criteria::EQUAL.' ?', $withoutZone, null, \PDO::PARAM_INT)
|
||||
->where('`without_zone`.delivery_module_id '.Criteria::ISNULL);
|
||||
}
|
||||
|
||||
//echo $search->toString(); exit;
|
||||
|
||||
$areas = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($areas);
|
||||
|
||||
foreach ($areas as $area) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $area, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $area->getId())
|
||||
->set('NAME', $area->getName())
|
||||
->set('POSTAGE', $area->getPostage())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -113,6 +113,7 @@ class Country extends BaseI18nLoop
|
||||
->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("IS_DEFAULT", $country->getByDefault() === 1 ? "1" : "0")
|
||||
->set("ISOCODE", $country->getIsocode())
|
||||
->set("ISOALPHA2", $country->getIsoalpha2())
|
||||
->set("ISOALPHA3", $country->getIsoalpha3())
|
||||
|
||||
167
core/lib/Thelia/Core/Template/Loop/Tax.php
Normal file
167
core/lib/Thelia/Core/Template/Loop/Tax.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\TaxRuleCountryQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* Tax loop
|
||||
*
|
||||
*
|
||||
* Class Tax
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Tax extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createIntListTypeArgument('tax_rule'),
|
||||
Argument::createIntListTypeArgument('exclude_tax_rule'),
|
||||
Argument::createIntTypeArgument('country'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$country = $this->getCountry();
|
||||
|
||||
$taxRule = $this->getTax_rule();
|
||||
if(null !== $taxRule && null !== $country) {
|
||||
$search->filterByTaxRuleCountry(
|
||||
TaxRuleCountryQuery::create()
|
||||
->filterByCountryId($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($taxRule, Criteria::IN)
|
||||
->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
|
||||
$excludeTaxRule = $this->getExclude_tax_rule();
|
||||
if(null !== $excludeTaxRule && null !== $country) {
|
||||
$excludedTaxes = TaxRuleCountryQuery::create()
|
||||
->filterByCountryId($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($excludeTaxRule, Criteria::IN)
|
||||
->find();
|
||||
/*DOES NOT WORK
|
||||
* $search->filterByTaxRuleCountry(
|
||||
$excludedTaxes,
|
||||
Criteria::NOT_IN
|
||||
);*/
|
||||
foreach($excludedTaxes as $excludedTax) {
|
||||
$search->filterByTaxRuleCountry($excludedTax, Criteria::NOT_EQUAL);
|
||||
}
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$taxes = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($taxes);
|
||||
|
||||
foreach ($taxes as $tax) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax->getId())
|
||||
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
162
core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php
Normal file
162
core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Map\CountryTableMap;
|
||||
use Thelia\Model\Map\TaxRuleCountryTableMap;
|
||||
use Thelia\Model\Map\TaxTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxRuleCountryQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* TaxRuleCountry loop
|
||||
*
|
||||
*
|
||||
* Class TaxRuleCountry
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRuleCountry extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('country'),
|
||||
Argument::createIntListTypeArgument('taxes'),
|
||||
Argument::createIntTypeArgument('tax_rule', null, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxRuleCountryQuery::create();
|
||||
|
||||
$country = $this->getCountry();
|
||||
$taxes = $this->getTaxes();
|
||||
|
||||
if((null === $country && null === $taxes)) {
|
||||
throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop');
|
||||
}
|
||||
|
||||
if((null === $country && null !== $taxes)) {
|
||||
throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop');
|
||||
}
|
||||
|
||||
if(null !== $taxes) {
|
||||
$search->groupByCountryId();
|
||||
|
||||
$originalCountryJoin = new Join();
|
||||
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', 'origin');
|
||||
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', 'origin');
|
||||
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', null, TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', 'origin');
|
||||
$originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', 'origin', Criteria::NOT_EQUAL);
|
||||
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->addJoinObject($originalCountryJoin, 's_to_o');
|
||||
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT);
|
||||
|
||||
$search->having('COUNT(*)=?', count($taxes), \PDO::PARAM_INT);
|
||||
|
||||
/* manage tax translation */
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'),
|
||||
CountryTableMap::TABLE_NAME,
|
||||
'COUNTRY_ID'
|
||||
);
|
||||
} elseif(null !== $country) {
|
||||
$search->filterByCountryId($country);
|
||||
|
||||
/* manage tax translation */
|
||||
$this->configureI18nProcessing(
|
||||
$search,
|
||||
array('TITLE', 'DESCRIPTION'),
|
||||
TaxTableMap::TABLE_NAME,
|
||||
'TAX_ID'
|
||||
);
|
||||
}
|
||||
|
||||
$taxRule = $this->getTax_rule();
|
||||
$search->filterByTaxRuleId($taxRule);
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$taxRuleCountries = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($taxRuleCountries);
|
||||
|
||||
foreach ($taxRuleCountries as $taxRuleCountry) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
if(null !== $taxes) {
|
||||
$loopResultRow
|
||||
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
|
||||
->set("COUNTRY" , $taxRuleCountry->getCountryId())
|
||||
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO'))
|
||||
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
}elseif(null !== $country) {
|
||||
$loopResultRow
|
||||
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
|
||||
->set("COUNTRY" , $taxRuleCountry->getCountryId())
|
||||
->set("TAX" , $taxRuleCountry->getTaxId())
|
||||
->set("POSITION" , $taxRuleCountry->getPosition())
|
||||
->set("TAX_TITLE" , $taxRuleCountry->getVirtualColumn(TaxTableMap::TABLE_NAME . '_i18n_TITLE'))
|
||||
->set("TAX_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(TaxTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -163,16 +163,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
|
||||
public function countryDataAccess($params, $smarty)
|
||||
{
|
||||
if (array_key_exists('defaultCountry', self::$dataAccessCache)) {
|
||||
$defaultCountry = self::$dataAccessCache['defaultCountry'];
|
||||
} else {
|
||||
$defaultCountry = CountryQuery::create()->findOneByByDefault(1);
|
||||
self::$dataAccessCache['defaultCountry'] = $defaultCountry;
|
||||
}
|
||||
|
||||
switch ($params["attr"]) {
|
||||
switch ($params["ask"]) {
|
||||
case "default":
|
||||
return $defaultCountry->getId();
|
||||
/*if (array_key_exists('defaultCountry', self::$dataAccessCache)) {
|
||||
$defaultCountry = self::$dataAccessCache['defaultCountry'];
|
||||
} else {
|
||||
$defaultCountry = CountryQuery::create()->findOneByByDefault(1);
|
||||
self::$dataAccessCache['defaultCountry'] = $defaultCountry;
|
||||
}*/
|
||||
$defaultCountry = CountryQuery::create()->filterByByDefault(1)->limit(1);
|
||||
return $this->dataAccessWithI18n("defaultCountry", $params, $defaultCountry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,8 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
public function renderHiddenFormField($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$field = '<input type="hidden" name="%s" value="%s">';
|
||||
$attrFormat = '%s="%s"';
|
||||
$field = '<input type="hidden" name="%s" value="%s" %s>';
|
||||
|
||||
$instance = $this->getInstanceFromParams($params);
|
||||
|
||||
@@ -197,7 +198,13 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
foreach ($formView->getIterator() as $row) {
|
||||
if ($this->isHidden($row) && $row->isRendered() === false) {
|
||||
$return .= sprintf($field, $row->vars["full_name"], $row->vars["value"]);
|
||||
$attributeList = array();
|
||||
if(isset($row->vars["attr"])) {
|
||||
foreach($row->vars["attr"] as $attrKey => $attrValue) {
|
||||
$attributeList[] = sprintf($attrFormat, $attrKey, $attrValue);
|
||||
}
|
||||
}
|
||||
$return .= sprintf($field, $row->vars["full_name"], $row->vars["value"], implode(' ', $attributeList));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,12 @@ class TaxEngineException extends \RuntimeException
|
||||
const UNDEFINED_REQUIREMENTS = 504;
|
||||
const UNDEFINED_REQUIREMENT_VALUE = 505;
|
||||
const UNDEFINED_TAX_RULE = 506;
|
||||
const NO_TAX_IN_TAX_RULES_COLLECTION = 507;
|
||||
|
||||
const BAD_AMOUNT_FORMAT = 601;
|
||||
|
||||
const FEATURE_BAD_EXPECTED_VALUE = 701;
|
||||
|
||||
public function __construct($message, $code = null, $previous = null)
|
||||
{
|
||||
if ($code === null) {
|
||||
|
||||
89
core/lib/Thelia/Form/Area/AreaCountryForm.php
Normal file
89
core/lib/Thelia/Form/Area/AreaCountryForm.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Area;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaCountryForm
|
||||
* @package Thelia\Form\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaCountryForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('area_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new GreaterThan(array('value' => 0)),
|
||||
new NotBlank()
|
||||
)
|
||||
|
||||
))
|
||||
->add('country_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new GreaterThan(array('value' => 0)),
|
||||
new NotBlank()
|
||||
),
|
||||
'label_attr' => array(
|
||||
'for' => 'area_country'
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Country')
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_area_country';
|
||||
}
|
||||
}
|
||||
79
core/lib/Thelia/Form/Area/AreaCreateForm.php
Normal file
79
core/lib/Thelia/Form/Area/AreaCreateForm.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Area;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaCreateForm
|
||||
* @package Thelia\Form\Shipping
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaCreateForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('name', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label_attr' => array('for' => 'shipping_name'),
|
||||
'label' => Translator::getInstance()->trans('shipping area name')
|
||||
))
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_area_creation';
|
||||
}
|
||||
}
|
||||
49
core/lib/Thelia/Form/Area/AreaModificationForm.php
Normal file
49
core/lib/Thelia/Form/Area/AreaModificationForm.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Area;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Form\Area\AreaCreateForm;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaModificationForm
|
||||
* @package Thelia\Form\Shipping
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaModificationForm extends AreaCreateForm
|
||||
{
|
||||
public function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_area_modification';
|
||||
}
|
||||
}
|
||||
88
core/lib/Thelia/Form/Area/AreaPostageForm.php
Normal file
88
core/lib/Thelia/Form/Area/AreaPostageForm.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\Area;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
|
||||
/**
|
||||
* Class AreaPostageForm
|
||||
* @package Thelia\Form\Area
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AreaPostageForm extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('area_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new GreaterThan(array('value' => 0)),
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add('postage', 'number', array(
|
||||
'constraints' => array(
|
||||
new GreaterThanOrEqual(array('value' => 0)),
|
||||
new NotBlank()
|
||||
),
|
||||
'label_attr' => array('for' => 'area_postage'),
|
||||
'label' => Translator::getInstance()->trans('Postage')
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_area_postage';
|
||||
}
|
||||
}
|
||||
@@ -122,16 +122,6 @@ abstract class DocumentModification extends BaseForm
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,16 +130,6 @@ abstract class ImageModification extends BaseForm
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
87
core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php
Normal file
87
core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\ShippingZone;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZoneAddArea
|
||||
* @package Thelia\Form\ShippingZone
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneAddArea extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('area_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new GreaterThan(array('value' => 0))
|
||||
),
|
||||
'label_attr' => array('for' => 'shipping_area'),
|
||||
'label' => Translator::getInstance()->trans('Area')
|
||||
))
|
||||
->add('shipping_zone_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new GreaterThan(array('value' => 0))
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_shippingzone_area';
|
||||
}
|
||||
}
|
||||
42
core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php
Normal file
42
core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\ShippingZone;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZoneRemoveArea
|
||||
* @package Thelia\Form\ShippingZone
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneRemoveArea extends ShippingZoneAddArea
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_shippingzone_remove_area';
|
||||
}
|
||||
}
|
||||
49
core/lib/Thelia/Form/TaxRuleCreationForm.php
Normal file
49
core/lib/Thelia/Form/TaxRuleCreationForm.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CountryQuery;
|
||||
|
||||
class TaxRuleCreationForm extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(new NotBlank())
|
||||
))
|
||||
;
|
||||
|
||||
$this->addStandardDescFields(array('postscriptum', 'chapo', 'locale'));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_tax_rule_creation";
|
||||
}
|
||||
}
|
||||
66
core/lib/Thelia/Form/TaxRuleModificationForm.php
Normal file
66
core/lib/Thelia/Form/TaxRuleModificationForm.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
class TaxRuleModificationForm extends TaxRuleCreationForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyTaxRuleId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_tax_rule_modification";
|
||||
}
|
||||
|
||||
public function verifyTaxRuleId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$taxRule = TaxRuleQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $taxRule) {
|
||||
$context->addViolation("Tax rule ID not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
127
core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php
Normal file
127
core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\TaxQuery;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Type\JsonType;
|
||||
|
||||
class TaxRuleTaxListUpdateForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$countryList = array();
|
||||
foreach(CountryQuery::create()->find() as $country) {
|
||||
$countryList[$country->getId()] = $country->getId();
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyTaxRuleId"),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
))
|
||||
->add("tax_list", "hidden", array(
|
||||
"required" => true,
|
||||
"attr" => array(
|
||||
"id" => 'tax_list',
|
||||
),
|
||||
"constraints" => array(
|
||||
new Constraints\Callback(
|
||||
array(
|
||||
"methods" => array(
|
||||
array($this, "verifyTaxList"),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
))
|
||||
->add("country_list", "choice", array(
|
||||
"choices" => $countryList,
|
||||
"required" => true,
|
||||
"multiple" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_tax_rule_taxlistupdate";
|
||||
}
|
||||
|
||||
public function verifyTaxRuleId($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$taxRule = TaxRuleQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if (null === $taxRule) {
|
||||
$context->addViolation("Tax rule ID not found");
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyTaxList($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$jsonType = new JsonType();
|
||||
if(!$jsonType->isValid($value)) {
|
||||
$context->addViolation("Tax list is not valid JSON");
|
||||
}
|
||||
|
||||
$taxList = json_decode($value, true);
|
||||
|
||||
/* check we have 2 level max */
|
||||
|
||||
foreach($taxList as $taxLevel1) {
|
||||
if(is_array($taxLevel1)) {
|
||||
foreach($taxLevel1 as $taxLevel2) {
|
||||
if(is_array($taxLevel2)) {
|
||||
$context->addViolation("Bad tax list JSON");
|
||||
} else {
|
||||
$taxModel = TaxQuery::create()->findPk($taxLevel2);
|
||||
if (null === $taxModel) {
|
||||
$context->addViolation("Tax ID not found in tax list JSON");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$taxModel = TaxQuery::create()->findPk($taxLevel1);
|
||||
if (null === $taxModel) {
|
||||
$context->addViolation("Tax ID not found in tax list JSON");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,49 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\Area\AreaEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Area as BaseArea;
|
||||
|
||||
class Area extends BaseArea {
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_CREATEAREA, new AreaEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_CREATEAREA, new AreaEvent($this));
|
||||
}
|
||||
|
||||
public function preUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEAREA, new AreaEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postUpdate(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_UPDATEAREA, new AreaEvent($this));
|
||||
}
|
||||
|
||||
public function preDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEAREA, new AreaEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postDelete(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::AFTER_DELETEAREA, new AreaEvent($this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\TaxRule as BaseTaxRule;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
use Thelia\TaxEngine\OrderProductTaxCollection;
|
||||
|
||||
class TaxRule extends BaseTaxRule
|
||||
{
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* @param Country $country
|
||||
* @param $untaxedAmount
|
||||
@@ -16,14 +19,14 @@ class TaxRule extends BaseTaxRule
|
||||
*
|
||||
* @return OrderProductTaxCollection
|
||||
*/
|
||||
public function getTaxDetail(Country $country, $untaxedAmount, $untaxedPromoAmount, $askedLocale = null)
|
||||
public function getTaxDetail(Product $product, Country $country, $untaxedAmount, $untaxedPromoAmount, $askedLocale = null)
|
||||
{
|
||||
$taxCalculator = new Calculator();
|
||||
|
||||
$taxCollection = new OrderProductTaxCollection();
|
||||
$taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale);
|
||||
$taxCalculator->loadTaxRule($this, $country, $product)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale);
|
||||
$promoTaxCollection = new OrderProductTaxCollection();
|
||||
$taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedPromoAmount, $promoTaxCollection, $askedLocale);
|
||||
$taxCalculator->loadTaxRule($this, $country, $product)->getTaxedPrice($untaxedPromoAmount, $promoTaxCollection, $askedLocale);
|
||||
|
||||
foreach($taxCollection as $index => $tax) {
|
||||
$tax->setPromoAmount($promoTaxCollection->getKey($index)->getAmount());
|
||||
|
||||
@@ -120,10 +120,10 @@ trait PositionManagementTrait {
|
||||
try {
|
||||
$this
|
||||
->setPosition($result->getPosition())
|
||||
->save()
|
||||
->save($cnx)
|
||||
;
|
||||
|
||||
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save();
|
||||
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save($cnx);
|
||||
|
||||
$cnx->commit();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class Calculator
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadTaxRule(TaxRule $taxRule, Country $country)
|
||||
public function loadTaxRule(TaxRule $taxRule, Country $country, Product $product)
|
||||
{
|
||||
$this->product = null;
|
||||
$this->country = null;
|
||||
@@ -88,8 +88,12 @@ class Calculator
|
||||
if($country->getId() === null) {
|
||||
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
|
||||
}
|
||||
if($product->getId() === null) {
|
||||
throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT);
|
||||
}
|
||||
|
||||
$this->country = $country;
|
||||
$this->product = $product;
|
||||
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
|
||||
|
||||
@@ -117,7 +121,11 @@ class Calculator
|
||||
public function getTaxedPrice($untaxedPrice, &$taxCollection = null, $askedLocale = null)
|
||||
{
|
||||
if(null === $this->taxRulesCollection) {
|
||||
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
|
||||
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
|
||||
}
|
||||
|
||||
if(null === $this->product) {
|
||||
throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT);
|
||||
}
|
||||
|
||||
if(false === filter_var($untaxedPrice, FILTER_VALIDATE_FLOAT)) {
|
||||
@@ -143,7 +151,7 @@ class Calculator
|
||||
$currentPosition = $position;
|
||||
}
|
||||
|
||||
$taxAmount = round($taxType->calculate($taxedPrice), 2);
|
||||
$taxAmount = round($taxType->calculate($this->product, $taxedPrice), 2);
|
||||
$currentTax += $taxAmount;
|
||||
|
||||
if(null !== $taxCollection) {
|
||||
@@ -167,12 +175,20 @@ class Calculator
|
||||
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
|
||||
}
|
||||
|
||||
if(null === $this->product) {
|
||||
throw new TaxEngineException('Product is empty in Calculator::getTaxedPrice', TaxEngineException::UNDEFINED_PRODUCT);
|
||||
}
|
||||
|
||||
if(false === filter_var($taxedPrice, FILTER_VALIDATE_FLOAT)) {
|
||||
throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT);
|
||||
}
|
||||
|
||||
$taxRule = $this->taxRulesCollection->getLast();
|
||||
|
||||
if(null === $taxRule) {
|
||||
throw new TaxEngineException('Tax rules collection got no tax ', TaxEngineException::NO_TAX_IN_TAX_RULES_COLLECTION);
|
||||
}
|
||||
|
||||
$untaxedPrice = $taxedPrice;
|
||||
$currentPosition = (int)$taxRule->getTaxRuleCountryPosition();
|
||||
$currentFixTax = 0;
|
||||
@@ -192,7 +208,7 @@ class Calculator
|
||||
$currentPosition = $position;
|
||||
}
|
||||
|
||||
$currentFixTax += $taxType->fixAmountRetriever();
|
||||
$currentFixTax += $taxType->fixAmountRetriever($this->product);
|
||||
$currentTaxFactor += $taxType->pricePercentRetriever();
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Type\TypeInterface;
|
||||
|
||||
/**
|
||||
@@ -34,14 +35,17 @@ abstract class BaseTaxType
|
||||
{
|
||||
protected $requirements = null;
|
||||
|
||||
public abstract function calculate($untaxedPrice);
|
||||
|
||||
public abstract function pricePercentRetriever();
|
||||
|
||||
public abstract function fixAmountRetriever();
|
||||
public abstract function fixAmountRetriever(Product $product);
|
||||
|
||||
public abstract function getRequirementsList();
|
||||
|
||||
public function calculate(Product $product, $untaxedPrice)
|
||||
{
|
||||
return $untaxedPrice * $this->pricePercentRetriever() + $this->fixAmountRetriever($product);
|
||||
}
|
||||
|
||||
public function loadRequirements($requirementsValues)
|
||||
{
|
||||
$this->requirements = $this->getRequirementsList();
|
||||
|
||||
68
core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php
Executable file
68
core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\FeatureProductQuery;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Type\FloatType;
|
||||
use Thelia\Type\ModelValidIdType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class FeatureFixAmountTaxType extends BaseTaxType
|
||||
{
|
||||
public function pricePercentRetriever()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function fixAmountRetriever(Product $product)
|
||||
{
|
||||
$featureId = $this->getRequirement("feature");
|
||||
|
||||
$query = FeatureProductQuery::create()
|
||||
->filterByProduct($product)
|
||||
->filterByFeatureId($featureId)
|
||||
->findOne();
|
||||
|
||||
$taxAmount = $query->getFreeTextValue();
|
||||
|
||||
$testInt = new FloatType();
|
||||
if(!$testInt->isValid($taxAmount)) {
|
||||
throw new TaxEngineException('Feature value does not match FLOAT format', TaxEngineException::FEATURE_BAD_EXPECTED_VALUE);
|
||||
}
|
||||
|
||||
return $taxAmount;
|
||||
}
|
||||
|
||||
public function getRequirementsList()
|
||||
{
|
||||
return array(
|
||||
'feature' => new ModelValidIdType('Feature'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Type\FloatToFloatArrayType;
|
||||
use Thelia\Type\ModelType;
|
||||
use Thelia\Type\ModelValidIdType;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,17 +32,12 @@ use Thelia\Type\ModelType;
|
||||
*/
|
||||
class featureSlicePercentTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function pricePercentRetriever()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function fixAmountRetriever()
|
||||
public function fixAmountRetriever(\Thelia\Model\Product $product)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -50,7 +45,7 @@ class featureSlicePercentTaxType extends BaseTaxType
|
||||
public function getRequirementsList()
|
||||
{
|
||||
return array(
|
||||
'featureId' => new ModelType('Currency'),
|
||||
'featureId' => new ModelValidIdType('Currency'),
|
||||
'slices' => new FloatToFloatArrayType(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,17 +31,12 @@ use Thelia\Type\FloatType;
|
||||
*/
|
||||
class FixAmountTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
return $this->getRequirement("amount");
|
||||
}
|
||||
|
||||
public function pricePercentRetriever()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function fixAmountRetriever()
|
||||
public function fixAmountRetriever(\Thelia\Model\Product $product)
|
||||
{
|
||||
return $this->getRequirement("amount");
|
||||
}
|
||||
|
||||
@@ -31,17 +31,12 @@ use Thelia\Type\FloatType;
|
||||
*/
|
||||
class PricePercentTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
return $untaxedPrice * $this->getRequirement("percent") * 0.01;
|
||||
}
|
||||
|
||||
public function pricePercentRetriever()
|
||||
{
|
||||
return ($this->getRequirement("percent") * 0.01);
|
||||
}
|
||||
|
||||
public function fixAmountRetriever()
|
||||
public function fixAmountRetriever(\Thelia\Model\Product $product)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/* check tax */
|
||||
$orderProductTaxList = $orderProduct->getOrderProductTaxes();
|
||||
foreach ($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) {
|
||||
foreach ($cartItem->getProduct()->getTaxRule()->getTaxDetail($cartItem->getProduct(), $validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) {
|
||||
$orderProductTax = $orderProductTaxList[$index];
|
||||
$this->assertEquals($tax->getAmount(), $orderProductTax->getAmount());
|
||||
$this->assertEquals($tax->getPromoAmount(), $orderProductTax->getPromoAmount());
|
||||
|
||||
@@ -126,14 +126,64 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$calculator->getTaxedPrice('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\TaxEngineException
|
||||
* @expectedExceptionCode 501
|
||||
*/
|
||||
public function testGetUntaxedPriceAndGetTaxAmountFromTaxedPriceWithNoProductLoaded()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\TaxEngineException
|
||||
* @expectedExceptionCode 507
|
||||
*/
|
||||
public function testGetUntaxedPriceAndGetTaxAmountFromTaxedPriceWithEmptyTaxRuleCollection()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
}
|
||||
|
||||
public function testGetTaxedPriceAndGetTaxAmountFromUntaxedPrice()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
@@ -163,11 +213,19 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
->setVirtualColumn('taxRuleCountryPosition', 3);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmountFromUntaxedPrice(500);
|
||||
$taxedPrice = $calculator->getTaxedPrice(500);
|
||||
|
||||
@@ -211,11 +269,19 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
->setVirtualColumn('taxRuleCountryPosition', 3);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
$untaxedPrice = $calculator->getUntaxedPrice(600.95);
|
||||
|
||||
|
||||
70
core/lib/Thelia/Type/ModelValidIdType.php
Executable file
70
core/lib/Thelia/Type/ModelValidIdType.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Type;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Exception\TypeException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ModelValidIdType implements TypeInterface
|
||||
{
|
||||
protected $expectedModelActiveRecordQuery = null;
|
||||
|
||||
/**
|
||||
* @param $expectedModelActiveRecord
|
||||
* @throws TypeException
|
||||
*/
|
||||
public function __construct($expectedModelActiveRecord)
|
||||
{
|
||||
$class = '\\Thelia\\Model\\' . $expectedModelActiveRecord . 'Query';
|
||||
|
||||
if (!(class_exists($class) || !new $class instanceof ModelCriteria)) {
|
||||
throw new TypeException('MODEL NOT FOUND', TypeException::MODEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
$this->expectedModelActiveRecordQuery = $class;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'Model valid Id type';
|
||||
}
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
$queryClass = $this->expectedModelActiveRecordQuery;
|
||||
|
||||
return null !== $queryClass::create()->findPk($value);
|
||||
}
|
||||
|
||||
public function getFormattedValue($value)
|
||||
{
|
||||
$queryClass = $this->expectedModelActiveRecordQuery;
|
||||
|
||||
return $this->isValid($value) ? $queryClass::create()->findPk($value) : null;
|
||||
}
|
||||
}
|
||||
128
install/faker_add_ecotax.php
Executable file
128
install/faker_add_ecotax.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Thelia\Condition\ConditionFactory;
|
||||
use Thelia\Condition\Implementation\MatchForEveryoneManager;
|
||||
use Thelia\Condition\Implementation\MatchForTotalAmountManager;
|
||||
use Thelia\Condition\Implementation\MatchForXArticlesManager;
|
||||
use Thelia\Condition\Operators;
|
||||
use Thelia\Coupon\AdapterInterface;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
|
||||
|
||||
require __DIR__ . '/../core/bootstrap.php';
|
||||
|
||||
$thelia = new Thelia\Core\Thelia("dev", true);
|
||||
$thelia->boot();
|
||||
|
||||
$faker = Faker\Factory::create();
|
||||
|
||||
$con = \Propel\Runtime\Propel::getConnection(
|
||||
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
|
||||
);
|
||||
$con->beginTransaction();
|
||||
|
||||
// Intialize URL management
|
||||
|
||||
try {
|
||||
$options = getopt('f::e::');
|
||||
|
||||
$forceEcotaxFeatureId = $options['f'];
|
||||
if(null !== $forceEcotaxFeatureId && !filter_var($forceEcotaxFeatureId, FILTER_VALIDATE_INT)) {
|
||||
exit('[ERROR] bad value for f option\n');
|
||||
}
|
||||
|
||||
$forceEcotaxId = $options['e'];
|
||||
if(null !== $forceEcotaxId && !filter_var($forceEcotaxId, FILTER_VALIDATE_INT)) {
|
||||
exit('[ERROR] bad value for e option\n');
|
||||
}
|
||||
|
||||
echo "Adding Ecotax feature\n";
|
||||
$feature = null;
|
||||
if(null !== $forceEcotaxFeatureId) {
|
||||
$feature = \Thelia\Model\FeatureQuery::create()->findPk($forceEcotaxFeatureId);
|
||||
if(null === $feature) {
|
||||
echo "Feature `$forceEcotaxFeatureId` not found\n";
|
||||
}
|
||||
}
|
||||
if(null === $feature) {
|
||||
$feature = new \Thelia\Model\Feature();
|
||||
$feature->setVisible(1);
|
||||
$feature->save();
|
||||
echo sprintf("Ecotax feature added with ID \n", $feature->getId());
|
||||
}
|
||||
|
||||
$fr = \Thelia\Model\Base\FeatureI18nQuery::create()
|
||||
->filterByLocale('fr_FR')
|
||||
->filterByFeature($feature)
|
||||
->findOne();
|
||||
if(null === $fr) {
|
||||
$fr = new \Thelia\Model\FeatureI18n();
|
||||
$fr->setLocale('fr_FR')
|
||||
->setFeature($feature);
|
||||
}
|
||||
$fr->setTitle('Ecotaxe');
|
||||
$fr->save($con);
|
||||
|
||||
$us = \Thelia\Model\Base\FeatureI18nQuery::create()
|
||||
->filterByLocale('en_US')
|
||||
->filterByFeature($feature)
|
||||
->findOne();
|
||||
if(null === $us) {
|
||||
$us = new \Thelia\Model\FeatureI18n();
|
||||
$us->setLocale('en_US')
|
||||
->setFeature($feature);
|
||||
}
|
||||
$us->setTitle('Ecotax');
|
||||
$us->save($con);
|
||||
|
||||
echo "Adding ecotax\n";
|
||||
|
||||
$tax = null;
|
||||
if(null !== $forceEcotaxId) {
|
||||
$tax = \Thelia\Model\TaxQuery::create()->findPk($forceEcotaxId);
|
||||
if(null === $tax) {
|
||||
echo "Tax `$forceEcotaxId` not found\n";
|
||||
}
|
||||
}
|
||||
if(null === $tax) {
|
||||
$tax = new \Thelia\Model\Tax();
|
||||
$tax->setType('FeatureFixAmountTaxType')
|
||||
->setSerializedRequirements(
|
||||
base64_encode(sprintf('{"feature":%s}', $feature->getId()))
|
||||
);
|
||||
$tax->save();
|
||||
echo sprintf("Ecotax added with ID \n", $tax->getId());
|
||||
}
|
||||
|
||||
$fr = \Thelia\Model\Base\TaxI18nQuery::create()
|
||||
->filterByLocale('fr_FR')
|
||||
->filterByTax($tax)
|
||||
->findOne();
|
||||
if(null === $fr) {
|
||||
$fr = new \Thelia\Model\TaxI18n();
|
||||
$fr->setLocale('fr_FR')
|
||||
->setTax($tax);
|
||||
}
|
||||
$fr->setTitle('Ecotaxe');
|
||||
$fr->save($con);
|
||||
|
||||
$us = \Thelia\Model\Base\TaxI18nQuery::create()
|
||||
->filterByLocale('en_US')
|
||||
->filterByTax($tax)
|
||||
->findOne();
|
||||
if(null === $us) {
|
||||
$us = new \Thelia\Model\TaxI18n();
|
||||
$us->setLocale('en_US')
|
||||
->setTax($tax);
|
||||
}
|
||||
$us->setTitle('Ecotax');
|
||||
$us->save($con);
|
||||
|
||||
$con->commit();
|
||||
|
||||
echo "Successfully terminated.\n";
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "error : ".$e->getMessage()."\n";
|
||||
$con->rollBack();
|
||||
}
|
||||
@@ -1149,25 +1149,31 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
|
||||
|
||||
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW());
|
||||
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW()),
|
||||
(2, 'PricePercentTaxType', 'eyJwZXJjZW50Ijo1LjV9', NOW(), NOW());
|
||||
|
||||
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
(1, 'fr_FR', 'TVA française à 19.6%'),
|
||||
(1, 'en_US', 'French 19.6% VAT');
|
||||
|
||||
(1, 'en_US', 'French 19.6% VAT'),
|
||||
(2, 'fr_FR', 'TVA française à 5.5%'),
|
||||
(2, 'en_US', 'French 5.5% VAT');
|
||||
INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, 1, NOW(), NOW());
|
||||
(1, 1, NOW(), NOW()),
|
||||
(2, 0, NOW(), NOW());
|
||||
|
||||
INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
(1, 'fr_FR', 'TVA française à 19.6%'),
|
||||
(1, 'en_US', 'French 19.6% VAT');
|
||||
(1, 'en_US', 'French 19.6% VAT'),
|
||||
(2, 'fr_FR', 'TVA française à 5.5%'),
|
||||
(2, 'en_US', 'French 5.5% VAT');
|
||||
|
||||
INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, 64, 1, 1, NOW(), NOW());
|
||||
(1, 64, 1, 1, NOW(), NOW()),
|
||||
(2, 64, 2, 1, NOW(), NOW());
|
||||
|
||||
INSERT INTO `order_status`(`id`, `code`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'not_paid', NOW(), NOW()),
|
||||
|
||||
@@ -326,3 +326,79 @@
|
||||
height: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
// -- Drag & drop --
|
||||
.take{
|
||||
|
||||
.draggable{
|
||||
border: 2px dashed @gray-light;
|
||||
margin-bottom: 10px;
|
||||
padding: 10px;
|
||||
|
||||
&:last-child{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.over{
|
||||
.drop-message{
|
||||
border-color: @brand-primary;
|
||||
color: @brand-primary;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.place{
|
||||
|
||||
.over{
|
||||
.drop-message{
|
||||
border-color: @brand-primary;
|
||||
color: @brand-primary;
|
||||
}
|
||||
}
|
||||
|
||||
.panel-body{
|
||||
|
||||
.draggable, .drag{
|
||||
margin: 5px 0;
|
||||
padding: 10px;
|
||||
border: 1px dashed @gray-light;
|
||||
}
|
||||
|
||||
.drop-group{
|
||||
padding: 10px;
|
||||
border: 2px dashed @gray-light;
|
||||
margin-bottom: 10px;
|
||||
|
||||
&:last-child{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.take, .place{
|
||||
|
||||
.drop-message{
|
||||
width: 50%;
|
||||
margin: 10px auto;
|
||||
padding: 10px;
|
||||
color: @gray;
|
||||
border: 2px dashed @gray;
|
||||
text-align: center;
|
||||
.opacity(0.5);
|
||||
|
||||
.glyphicon{
|
||||
display: block;
|
||||
font-size: @font-size-large;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.ui-draggable-dragging{
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/category' category_id={$category_d}}" />
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/category' category_id={$category_id}}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
|
||||
@@ -5,180 +5,180 @@
|
||||
{block name="check-permissions"}admin.configuration.view{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="configuration">
|
||||
<div class="configuration">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{module_include location='configuration_top'}
|
||||
{module_include location='configuration_top'}
|
||||
|
||||
<h2>{intl l="Thelia configuration"}</h2>
|
||||
<h2>{intl l="Thelia configuration"}</h2>
|
||||
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='Product catalog configuration'}</caption>
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='Product catalog configuration'}</caption>
|
||||
|
||||
{module_include location='catalog_configuration_top'}
|
||||
{module_include location='catalog_configuration_top'}
|
||||
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.templates"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/templates'}">{intl l='Product templates'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/templates'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.templates"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/templates'}">{intl l='Product templates'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/templates'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.attributes"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/attributes'}">{intl l='Product attributes'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/attributes'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.attributes"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/attributes'}">{intl l='Product attributes'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/attributes'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.features"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/features'}">{intl l='Product features'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/features'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.features"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/features'}">{intl l='Product features'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/features'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc4" roles="ADMIN" permissions="admin.configuration.messages"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/messages'}">{intl l='Mailing templates'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/messages'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc4" roles="ADMIN" permissions="admin.configuration.messages"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/messages'}">{intl l='Mailing templates'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/messages'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc5" roles="ADMIN" permissions="admin.configuration.currencies"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/currencies'}">{intl l='Currencies'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/currencies'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc5" roles="ADMIN" permissions="admin.configuration.currencies"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/currencies'}">{intl l='Currencies'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/currencies'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc6" roles="ADMIN" permissions="admin.configuration.taxe-rules"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/taxes_rules'}">{intl l='Taxes rules'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/taxes_rules'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc6" roles="ADMIN" permissions="admin.configuration.taxe-rules"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/taxes_rules'}">{intl l='Taxes rules'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/taxes_rules'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{module_include location='catalog_configuration_bottom'}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{module_include location='catalog_configuration_bottom'}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='Shipping configuration'}</caption>
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='Shipping configuration'}</caption>
|
||||
|
||||
{module_include location='shipping_configuration_top'}
|
||||
{module_include location='shipping_configuration_top'}
|
||||
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.contries"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/countries'}">{intl l='Countries'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/countries'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.contries"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/countries'}">{intl l='Countries'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/countries'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.shipping_zones"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/shipping_zones'}">{intl l='Shipping zones'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/shipping_zones'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.shipping_zones"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/shipping_zones'}">{intl l='Shipping zones'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/shipping_zones'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.shipping_configuration"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/shipping_configuration'}">{intl l='Shipping configuration'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/shipping_configuration'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.shipping_configuration"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/shipping_configuration'}">{intl l='Shipping configuration'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/shipping_configuration'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{module_include location='shipping_configuration_bottom'}
|
||||
{module_include location='shipping_configuration_bottom'}
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='System parameters'}</caption>
|
||||
<div class="col-md-4">
|
||||
<div class="menu-list-table general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed">
|
||||
<caption>{intl l='System parameters'}</caption>
|
||||
|
||||
{module_include location='system_configuration_top'}
|
||||
{module_include location='system_configuration_top'}
|
||||
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.modules"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/modules'}">{intl l='Modules activation'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/modules'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc1" roles="ADMIN" permissions="admin.configuration.modules"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/modules'}">{intl l='Modules activation'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/modules'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.variables"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/variables'}">{intl l='System variables'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/variables'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc2" roles="ADMIN" permissions="admin.configuration.variables"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/variables'}">{intl l='System variables'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/variables'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.admin_profiles"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_profiles'}">{intl l='Back-office profiles'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_profiles'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.admin_profiles"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_profiles'}">{intl l='Back-office profiles'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_profiles'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc4" roles="ADMIN" permissions="admin.configuration.admin_users"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_users'}">{intl l='Back-office users'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_users'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc4" roles="ADMIN" permissions="admin.configuration.admin_users"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_users'}">{intl l='Back-office users'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_users'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc5" roles="ADMIN" permissions="admin.configuration.languages"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/languages'}">{intl l='Languages & URLs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/languages'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc5" roles="ADMIN" permissions="admin.configuration.languages"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/languages'}">{intl l='Languages & URLs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/languages'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc6" roles="ADMIN" permissions="admin.configuration.mailing_system"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/mailing_system'}">{intl l='Mailing system'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/mailing_system'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc6" roles="ADMIN" permissions="admin.configuration.mailing_system"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/mailing_system'}">{intl l='Mailing system'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/mailing_system'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc7" roles="ADMIN" permissions="admin.configuration.admin_logs"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_logs'}">{intl l='Administration logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc7" roles="ADMIN" permissions="admin.configuration.admin_logs"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/admin_logs'}">{intl l='Administration logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/admin_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="pcc8" roles="ADMIN" permissions="admin.configuration.system_logs"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/system_logs'}">{intl l='System logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/system_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
{loop type="auth" name="pcc8" roles="ADMIN" permissions="admin.configuration.system_logs"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/system_logs'}">{intl l='System logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/system_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
{module_include location='system_configuration_bottom'}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{module_include location='system_configuration_bottom'}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{module_include location='configuration_bottom'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{module_include location='configuration_bottom'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
@@ -52,17 +52,17 @@
|
||||
{loop name="countries" type="country" backend_context="1" lang=$lang_id order=$order}
|
||||
<tr>
|
||||
<td>{$ID}</td>
|
||||
<td>{$TITLE}</td>
|
||||
<td><a href="{url path="/admin/configuration/country/update/{$ID}"}">{$TITLE}</a></td>
|
||||
<td>
|
||||
<div class="make-switch switch-small switch-radio change-default-toggle" data-id="{$ID}" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input class="change-default-toggle" type="radio" name="by_default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{* <td>
|
||||
<div class="make-switch switch-small switch-radio" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
|
||||
<input class="change-default" type="radio" name="" value="{$ID}" {if $IS_DEFAULT}selected="selected"{/if}/>
|
||||
</div>
|
||||
</td>
|
||||
</td> *}
|
||||
<td>{$ISOCODE}</td>
|
||||
<td>{$ISOALPHA3}</td>
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
<div class="col-md-12">
|
||||
|
||||
{form name="thelia.admin.country.modification"}
|
||||
<form method="POST" action="{url path='/admin/configuration/countries/save'}" {form_enctype form=$form} class="clearfix">
|
||||
|
||||
<form method="POST" action="{url path="/admin/configuration/country/save/{$ID}"}" {form_enctype form=$form} class="clearfix">
|
||||
{include file = "includes/inner-form-toolbar.html"}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{* Be sure to get the country ID, even if the form could not be validated *}
|
||||
@@ -40,8 +40,12 @@
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/countries'}" />
|
||||
{/form_field}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/country/update/{$ID}"}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -74,51 +78,26 @@
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Alpha code 3'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l="Translations"}
|
||||
</div>
|
||||
|
||||
{loop type="lang" name="lang"}
|
||||
<div class="col-md-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
<img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}"> {$TITLE}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l=""}" placeholder="{intl l='Country short description'}"></textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country description'}"></textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Country title'}">
|
||||
</div>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-default btn-primary" title="{intl l='Add a new country'}">
|
||||
{intl l="Save"}
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
</button>
|
||||
{/form_field}
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l=""}" placeholder="{intl l='Country short description'}">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="{$label}"}" placeholder="{intl l='Country description'}">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<div class="shipping-configuration edit-shipping-configuration">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{loop name="area-edit" type="area" id=$area_id}
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration/shipping_configuration'}">{intl l="Shipping configuration"}</a></li>
|
||||
<li>{intl l='Editing shipping configuration "%name"' name="{$TITLE}"}</li>
|
||||
<li>{intl l='Editing shipping configuration "%name"' name="{$NAME}"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
@@ -21,30 +21,40 @@
|
||||
<div class="general-block-decorator">
|
||||
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l='Edit shipping configuration %title' title=$TITLE}
|
||||
{intl l='Edit shipping configuration %title' title=$NAME}
|
||||
</div>
|
||||
|
||||
<div class="form-container clearfix">
|
||||
<div class="col-md-4">
|
||||
|
||||
|
||||
{form name="thelia.admin.area.country"}
|
||||
<form method="POST" action="{url path="/admin/configuration/shipping_configuration/country/add"}">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
<form method="POST" action="">
|
||||
<label class="control-label" for="">{intl l="Country"}</label>
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/shipping_configuration/update/{$area_id}"}" >
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<input type="hidden" name="{$name}" value="{$area_id}">
|
||||
{/form_field}
|
||||
{form_field form=$form field='country_id'}
|
||||
<label class="control-label" for="{$label_attr.for}">{intl l="Country"}</label>
|
||||
|
||||
<div class="input-group">
|
||||
<select name="" id="" data-toggle="selectpicker">
|
||||
<option value="1">France</option>
|
||||
<option value="2">Monaco</option>
|
||||
<option value="3">Nouvelle-Calédonie</option>
|
||||
<select name="{$name}" id="{$label_attr.for}" data-toggle="selectpicker">
|
||||
{loop name="country-without-area" type="country" with_area="0" backend_context="1" lang=$lang_id}
|
||||
<option value="{$ID}">{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-plus-sign"></span> {intl l="Add this country"}</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
@@ -57,44 +67,46 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loop name="country-area" type="country" area=$area_id backend_context="1"}
|
||||
<tr>
|
||||
<td>Wallis-et-Futuna</td>
|
||||
<td>{$TITLE}</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this country'}" href="#delete_country_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Polynésie française</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this country'}" href="#delete_country_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>USA - Alabama</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this country'}" href="#delete_zone_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<a class="btn btn-default btn-xs btn-delete-country" title="{intl l='Delete this country'}" href="#delete_country_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="active">
|
||||
<td colspan="2">
|
||||
<form method="POST" action="">
|
||||
<label for="" class="control-label">{intl l="Freight"}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="" id="" placeholder="Freight value">
|
||||
{form name="thelia.admin.area.postage"}
|
||||
<form method="POST" action="{url path="/admin/configuration/shipping_configuration/update_postage/{$area_id}"}">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/shipping_configuration/update/{$area_id}"}" >
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<input type="hidden" name="{$name}" value="{$area_id}">
|
||||
{/form_field}
|
||||
{form_field form=$form field='postage'}
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}</label>
|
||||
<div class="input-group {if $error}has-error{/if}">
|
||||
<input type="text" class="form-control" name="{$name}" value="{$POSTAGE}" id="{$label_attr.for}" placeholder="Postage">
|
||||
<span class="input-group-addon">€</span>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span></button>
|
||||
</span>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
</form>
|
||||
{/form}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
@@ -106,14 +118,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="area-edit"}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{intl l="No area defined with this id"}
|
||||
</div>
|
||||
</div>
|
||||
{/elseloop}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* Delete related content confirmation dialog *}
|
||||
|
||||
{capture "delete_country_dialog"}
|
||||
|
||||
<input type="hidden" name="area_id" value="{$area_id}">
|
||||
<input type="hidden" name="country_id" id="delete-country-id" value="">
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
@@ -123,7 +144,7 @@
|
||||
dialog_title = {intl l="Remove country"}
|
||||
dialog_message = {intl l="Do you really want to remove this country ?"}
|
||||
|
||||
form_action = {url path=''}
|
||||
form_action = {url path='/admin/configuration/shipping_configuration/country/remove'}
|
||||
form_content = {$smarty.capture.delete_country_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
@@ -135,4 +156,12 @@
|
||||
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".btn-delete-country").click(function(e){
|
||||
$("#delete-country-id").val($(this).data("id"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
@@ -41,66 +41,24 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop name="area-list" type="area" backend_context="1"}
|
||||
<tr>
|
||||
<td>France</td>
|
||||
<td><a href="{url path="/admin/configuration/shipping_configuration/update/$ID"}">{$NAME}</a></td>
|
||||
|
||||
{module_include location='shipping_configuration_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-change" title="{intl l='Change this shipping configuration'}" href="{url path="/admin/configuration/shipping_configuration/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-delete" title="{intl l='Delete this shipping configuration'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping configuration could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Outre-Mer DOM</td>
|
||||
|
||||
{module_include location='shipping_configuration_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-change" title="{intl l='Change this shipping configuration'}" href="{url path="/admin/configuration/shipping_configuration/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-delete" title="{intl l='Delete this shipping configuration'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping configuration could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Outre-Mer TOM</td>
|
||||
|
||||
{module_include location='shipping_configuration_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-change" title="{intl l='Change this shipping configuration'}" href="{url path="/admin/configuration/shipping_configuration/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"}
|
||||
<a class="btn btn-default btn-xs shipping-configuration-delete" title="{intl l='Delete this shipping configuration'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping configuration could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-configuration.change"}
|
||||
<a class="btn btn-default btn-xs area-configuration-change" title="{intl l='Change this shipping configuration'}" href="{url path="/admin/configuration/shipping_configuration/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.shipping-configuration.delete"}
|
||||
<a class="btn btn-default btn-xs area-configuration-delete" title="{intl l='Delete this shipping configuration'}" href="#delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -117,16 +75,23 @@
|
||||
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "creation_dialog"}
|
||||
{form name="thelia.admin.area.create"}
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
{* on success, redirect to the edition page, _ID_ is replaced with the created object ID, see controller *}
|
||||
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/shipping_configuration/update/_ID_'}" />
|
||||
{/form_field}
|
||||
{form_field form=$form field="name"}
|
||||
<div class="form-group">
|
||||
<label for="" class="control-label">{intl l="Name"} : </label>
|
||||
<input type="text" id="" name="" class="form-control" title="{intl l="Name"}" placeholder="{intl l='Shipping configuration name'}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" title="{intl l="Name"}" placeholder="{intl l='Shipping configuration name'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
|
||||
{module_include location='shipping_configuration_create_form'}
|
||||
|
||||
{/form}
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
@@ -139,7 +104,7 @@
|
||||
dialog_ok_label = {intl l="Create this shipping configuration"}
|
||||
dialog_cancel_label = {intl l="Cancel"}
|
||||
|
||||
form_action = {url path='/admin/configuration/configuration/shipping_configuration/create'}
|
||||
form_action = {url path='/admin/configuration/shipping_configuration/create'}
|
||||
form_enctype = ''
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
@@ -147,7 +112,7 @@
|
||||
{* Delete confirmation dialog *}
|
||||
|
||||
{capture "delete_dialog"}
|
||||
<input type="hidden" name="shipping_zones_id" id="shipping_configuration_delete_id" value="" />
|
||||
<input type="hidden" name="area_id" id="shipping_configuration_delete_id" value="" />
|
||||
|
||||
{module_include location='shipping_configuration_delete_form'}
|
||||
|
||||
@@ -163,4 +128,14 @@
|
||||
form_action = {url path='/admin/configuration/shipping_configuration/delete'}
|
||||
form_content = {$smarty.capture.delete_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".area-configuration-delete").click(function(e){
|
||||
$("#shipping_configuration_delete_id").val($(this).data("id"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
@@ -26,25 +26,33 @@
|
||||
|
||||
<div class="form-container clearfix">
|
||||
<div class="col-md-4">
|
||||
|
||||
<form method="POST" action="">
|
||||
<label class="control-label" for="">{intl l="Zones"}</label>
|
||||
{form name="thelia.shopping_zone_area"}
|
||||
<form method="POST" action="{url path="/admin/configuration/shipping_zones/area/add"}">
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/shipping_zones/update/{$shipping_zones_id}"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='shipping_zone_id'}
|
||||
<input type="hidden" name="{$name}" value="{$shipping_zones_id}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="input-group">
|
||||
<select name="" id="" data-toggle="selectpicker">
|
||||
<option value="">1</option>
|
||||
<option value="">2</option>
|
||||
<option value="">3</option>
|
||||
<option value="">4</option>
|
||||
<option value="">5</option>
|
||||
<select name="{$name}" id="{$label_attr.for}" data-toggle="selectpicker">
|
||||
{loop name="area.module.not_associated" type="area" without_zone=$shipping_zones_id}
|
||||
<option value="{$ID}">{$NAME}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-plus-sign"></span> {intl l="Add"}</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
@@ -57,30 +65,16 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loop type="area" name="area.module.associated" with_zone=$shipping_zones_id}
|
||||
<tr>
|
||||
<td>France</td>
|
||||
<td>{$NAME}</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this zone'}" href="#delete_zone_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Zone 1</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this zone'}" href="#delete_zone_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Zone 2</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this zone'}" href="#delete_zone_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<a class="btn btn-default btn-xs delete-zone-area" title="{intl l='Delete this zone'}" href="#delete_zone_dialog" data-id="{$ID}" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -97,7 +91,22 @@
|
||||
{* Delete related content confirmation dialog *}
|
||||
|
||||
{capture "delete_zone_dialog"}
|
||||
|
||||
{form name="thelia.shopping_zone_remove_area"}
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/shipping_zones/update/{$shipping_zones_id}"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='shipping_zone_id'}
|
||||
<input type="hidden" name="{$name}" value="{$shipping_zones_id}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<input type="hidden" name="{$name}" value="" id="shipping-zone-id-delete" />
|
||||
{/form_field}
|
||||
|
||||
{/form}
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
@@ -107,7 +116,7 @@
|
||||
dialog_title = {intl l="Remove zone"}
|
||||
dialog_message = {intl l="Do you really want to remove this zone ?"}
|
||||
|
||||
form_action = {url path=''}
|
||||
form_action = {url path='/admin/configuration/shipping_zones/area/remove'}
|
||||
form_content = {$smarty.capture.delete_zone_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
@@ -119,4 +128,12 @@
|
||||
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".delete-zone-area").click(function(e){
|
||||
$("#shipping-zone-id-delete").val($(this).data('id'));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
@@ -36,57 +36,21 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{loop type="delivery" name="delivery.list" backend_context="1"}
|
||||
<tr>
|
||||
<td>So Colissimo</td>
|
||||
<td><a href="{url path="/admin/configuration/shipping_zones/update/$ID"}">{$TITLE}</a></td>
|
||||
|
||||
{module_include location='shipping_zones_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"}
|
||||
<a class="btn btn-default btn-xs shipping-zones-change" title="{intl l='Change this shipping zone'}" href="{url path="/admin/configuration/shipping_zones/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping zone could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"}
|
||||
<a class="btn btn-default btn-xs shipping-zones-change" title="{intl l='Change this shipping zone'}" href="{url path="/admin/configuration/shipping_zones/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Chronopost</td>
|
||||
|
||||
{module_include location='shipping_zones_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"}
|
||||
<a class="btn btn-default btn-xs shipping-zones-change" title="{intl l='Change this shipping zone'}" href="{url path="/admin/configuration/shipping_zones/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping zone could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Kiala</td>
|
||||
|
||||
{module_include location='shipping_zones_table_row'}
|
||||
|
||||
<td>
|
||||
{if ! $SECURED}
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.shipping-zones.change"}
|
||||
<a class="btn btn-default btn-xs shipping-zones-change" title="{intl l='Change this shipping zone'}" href="{url path="/admin/configuration/shipping_zones/update/$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
|
||||
{/loop}
|
||||
</div>
|
||||
{else}
|
||||
<i title="{intl l='This shipping zone could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -98,24 +62,4 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* Delete confirmation dialog *}
|
||||
|
||||
{capture "delete_dialog"}
|
||||
<input type="hidden" name="shipping_zones_id" id="shipping_zones_delete_id" value="" />
|
||||
|
||||
{module_include location='shipping_zones_delete_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "delete_dialog"
|
||||
dialog_title = {intl l="Delete shipping zone"}
|
||||
dialog_message = {intl l="Do you really want to delete this shipping zone ?"}
|
||||
|
||||
form_action = {url path='/admin/configuration/shipping_zones/delete'}
|
||||
form_content = {$smarty.capture.delete_dialog nofilter}
|
||||
}
|
||||
{/block}
|
||||
@@ -5,7 +5,11 @@
|
||||
{block name="check-permissions"}admin.configuration.taxes-rules.edit{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="taxes-rules edit-taxes-rules">
|
||||
|
||||
{assign oder_tab {$smarty.get.tab|default:$smarty.post.tab|default:'data'}}
|
||||
{assign asked_country {$smarty.get.country|default:{country ask="default" attr="id"}}}
|
||||
|
||||
<div class="taxes-rules edit-taxes-rules">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
@@ -13,144 +17,277 @@
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration/taxes_rules'}">{intl l="Taxes rules"}</a></li>
|
||||
<li>{intl l='Editing tax rule "%name"' name="{$TITLE}"}</li>
|
||||
<li>{intl l='Editing tax rule'}</li>
|
||||
</ul>
|
||||
|
||||
{loop type="tax-rule" name="tax-rule" id=$tax_rule_id backend_context="1" lang=$edit_language_id}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator clearfix">
|
||||
|
||||
<div class="title title-without-tabs">
|
||||
{intl l="Edit tax rule $TITLE"}
|
||||
</div>
|
||||
<ul class="nav nav-tabs clearfix">
|
||||
<li {if $oder_tab == 'data'}class="active"{/if}><a href="#data" data-tab-name="cart" data-toggle="tab"><span class="glyphicon glyphicon-shopping-cart"></span> {intl l="Description"}</a></li>
|
||||
<li {if $oder_tab == 'taxes'}class="active"{/if}><a href="#taxes" data-tab-name="bill" data-toggle="tab"><span class="glyphicon glyphicon-list-alt"></span> {intl l="Taxes"}</a></li>
|
||||
</ul>
|
||||
|
||||
<form action="" method="post">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane fade {if $oder_tab == 'data'}active in{/if}" id="data">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Choose a country"} :</label>
|
||||
<div class="input-group">
|
||||
<select name="" id="" data-toggle="selectpicker">
|
||||
<option value="">France</option>
|
||||
<option value="">Spanish</option>
|
||||
</select>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span></button>
|
||||
</span>
|
||||
<div class="form-container">
|
||||
|
||||
{form name="thelia.admin.taxrule.modification"}
|
||||
|
||||
<form method="POST" action="{url path="/admin/configuration/taxes_rules/save"}" {form_enctype form=$form} >
|
||||
|
||||
{include
|
||||
file = "includes/inner-form-toolbar.html"
|
||||
hide_submit_buttons = false
|
||||
|
||||
page_url = {url path="/admin/configuration/taxes_rules/update/$tax_rule_id" tab=data}
|
||||
close_url = {url path="/admin/configuration/taxes_rules"}
|
||||
}
|
||||
|
||||
{* Be sure to get the product ID, even if the form could not be validated *}
|
||||
<input type="hidden" name="tax_rule_id" value="{$ID}" />
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/taxes_rules"}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l=$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$TITLE}{/if}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{intl l=$label} :
|
||||
<span class="label-help-block">{intl l="The detailed description."}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$DESCRIPTION}{/if}{/if}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="control-group">
|
||||
<label> </label>
|
||||
<div class="controls">
|
||||
<p>{intl l='Tax rule created on %date_create. Last modification: %date_change' date_create={format_date date=$CREATE_DATE} date_change={format_date date=$UPDATE_DATE}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div class="tab-pane fade {if $oder_tab == 'taxes'}active in{/if}" id="taxes">
|
||||
|
||||
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
|
||||
<p class="lead">
|
||||
<span class="label label-info">Italy</span>
|
||||
<span class="label label-info">England</span>
|
||||
<span class="label label-info">Japan</span>
|
||||
</p>
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l="Manage taxes"}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="" class="label-control">{intl l="Choose a country"} :</label>
|
||||
<form id="country-selector-form" action="{url path="/admin/configuration/taxes_rules/update/$tax_rule_id"}" method="GET">
|
||||
<input type="hidden" name="tab" value="taxes">
|
||||
<select id="country-selector" name="country" data-toggle="selectpicker">
|
||||
{loop type="country" name="country-list"}
|
||||
<option value="{$ID}" {if $ID == $asked_country}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="panel" class="panel panel-default place">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Create a tax rule</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
|
||||
<p class="lead">
|
||||
|
||||
<div class="drop-group droppable add-to-group">
|
||||
{$matchedCountries.first=$asked_country}
|
||||
|
||||
{loop type="tax-rule-country" name="same-country-list" tax_rule=$ID taxes="1,2,3" country=$asked_country}
|
||||
{$matchedCountries[]=$COUNTRY}
|
||||
<span class="label label-info">{$COUNTRY_TITLE}</span>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="same-country-list"}
|
||||
<span class="label label-danger">{intl l="NONE"}</span>
|
||||
{/elseloop}
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
<div id="panel" class="panel panel-default place">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{intl l="Manage the tax rule taxes appliance order"}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{assign lastPosition 0}
|
||||
{loop type="tax-rule-country" name="existing-tax-list" tax_rule=$ID country=$asked_country}
|
||||
{if $POSITION != $lastPosition}
|
||||
{assign lastPosition $POSITION}
|
||||
{if $LOOP_COUNT > 1}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="drop-group droppable add-to-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
<span class="message">{intl l="Add tax to this group"}</span>
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div class="drag" data-id="{$TAX}">{$TAX_TITLE}</div>
|
||||
|
||||
{if $LOOP_COUNT == $LOOP_TOTAL}
|
||||
</div>
|
||||
{/if}
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="existing-tax-list"}
|
||||
<div class="drop-group droppable add-to-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
<span class="message">{intl l="Add tax to this group"}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/elseloop}
|
||||
|
||||
</div>
|
||||
<div class="panel-footer droppable create-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
<span class="message">{intl l="Add tax to this group"}</span>
|
||||
<span class="message">{intl l="Drop tax here to create a tax group"}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="#tax_list_update_dialog" data-toggle="modal" id="apply-taxes-rules" class="btn btn-default btn-primary btn-block"><span class="glyphicon glyphicon-check"></span> {intl l="Apply"}</a>
|
||||
|
||||
</div>
|
||||
<div class="panel-footer droppable create-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
<span class="message">{intl l="Drop tax here to create a tax group"}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<a href="#confirmation_dialog" data-toggle="modal" id="apply-taxes-rules" class="btn btn-default btn-primary btn-block"><span class="glyphicon glyphicon-check"></span> {intl l="Apply"}</a>
|
||||
<div id="panel-list" class="panel panel-default take">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Available taxes</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{loop type="tax" name="tax-list" exclude_tax_rule=$ID country=$asked_country}
|
||||
<div class="draggable" data-id="{$ID}">{$TITLE}</div>
|
||||
{/loop}
|
||||
</div>
|
||||
<div class="panel-footer droppable remove-from-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-minus"></span>
|
||||
<span class="message">{intl l="Drop tax here to delete from group"}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div id="panel-list" class="panel panel-default take">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">List of taxes</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="draggable">Cras justo odio</div>
|
||||
<div class="draggable">Dapibus ac facilisis in</div>
|
||||
<div class="draggable">Morbi leo risus</div>
|
||||
<div class="draggable">Porta ac consectetur ac</div>
|
||||
<div class="draggable">Vestibulum at eros</div>
|
||||
</div>
|
||||
<div class="panel-footer droppable remove-from-group">
|
||||
<p class="drop-message">
|
||||
<span class="glyphicon glyphicon-minus"></span>
|
||||
<span class="message">{intl l="Drop tax here to delete from group"}</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/loop}
|
||||
|
||||
</div>
|
||||
|
||||
{* Confirmation dialog *}
|
||||
|
||||
{capture "confirmation_dialog"}
|
||||
|
||||
<form action="" method="post">
|
||||
{* Confirmation dialog *}
|
||||
{form name="thelia.admin.taxrule.taxlistupdate"}
|
||||
|
||||
{if $form_error_message}
|
||||
{$taxUpdateError = true}
|
||||
{else}
|
||||
{$taxUpdateError = false}
|
||||
{/if}
|
||||
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "tax_list_update_dialog"}
|
||||
|
||||
<input type="hidden" name="tax_rule_id" value="{$tax_rule_id}">
|
||||
<input type="hidden" name="tab" value="taxes">
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='country_list'}
|
||||
|
||||
<p>{intl l="Tax rule taxes will be update for the following countries :"}</p>
|
||||
<div class="form-group">
|
||||
<select name="" id="" data-toggle="selectpicker" multiple>
|
||||
<option value="1">France</option>
|
||||
<option value="2">England</option>
|
||||
<option value="3">Spain</option>
|
||||
<select name="{$name}" data-toggle="selectpicker" multiple>
|
||||
{loop type="country" name="country-list"}
|
||||
<option value='{$ID}' {if (!$value AND in_array($ID, $matchedCountries)) OR ($value AND in_array($ID, $value))}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{/form_field}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
{include
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "confirmation_dialog"
|
||||
dialog_title = {intl l="Create a new tax rule"}
|
||||
dialog_body = {$smarty.capture.confirmation_dialog nofilter}
|
||||
dialog_id = "tax_list_update_dialog"
|
||||
dialog_title = {intl l="Update tax rule taxes"}
|
||||
dialog_body = {$smarty.capture.tax_list_update_dialog nofilter}
|
||||
|
||||
dialog_ok_label = {intl l="Create this tax rule"}
|
||||
dialog_ok_label = {intl l="Edit tax rule taxes"}
|
||||
dialog_cancel_label = {intl l="Cancel"}
|
||||
|
||||
form_action = {url path='/admin/categories/create'}
|
||||
|
||||
form_error_message = $form_error_message
|
||||
form_action = {url path="/admin/configuration/taxes_rules/saveTaxes"}
|
||||
form_enctype = {form_enctype form=$form}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
|
||||
{/form}
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
|
||||
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
<script src='{$asset_url}'></script>
|
||||
{/javascripts}
|
||||
|
||||
{javascripts file='assets/js/main.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
<script src='{$asset_url}'></script>
|
||||
{/javascripts}
|
||||
|
||||
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||
{literal}
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
|
||||
{if $taxUpdateError == true}
|
||||
$('#tax_list_update_dialog').modal();
|
||||
{/if}
|
||||
|
||||
{literal}
|
||||
$('#country-selector').change(function(e) {
|
||||
$('#country-selector-form').submit();
|
||||
});
|
||||
|
||||
// Cache jQuery Objects
|
||||
var $group = $('#panel');
|
||||
var $list = $('#panel-list');
|
||||
@@ -158,7 +295,7 @@
|
||||
// Build array of taxes rules
|
||||
$('#apply-taxes-rules').click(function(){
|
||||
var taxesRules = [],
|
||||
index;
|
||||
index;
|
||||
|
||||
$('.drop-group', $group).each(function(i){
|
||||
var $this = $(this);
|
||||
@@ -167,11 +304,12 @@
|
||||
|
||||
$('.drag', $this).each(function(j){
|
||||
taxesRules[index][j] = [];
|
||||
taxesRules[index][j] = $(this).text();
|
||||
taxesRules[index][j] = $(this).data('id'); // retrieve with data
|
||||
});
|
||||
});
|
||||
|
||||
console.log(taxesRules);
|
||||
$('#tax_list').val(JSON.stringify(taxesRules));
|
||||
});
|
||||
|
||||
// Default options for draggable
|
||||
@@ -186,7 +324,7 @@
|
||||
// Default options for sortabble
|
||||
var sortOptions = {
|
||||
cursor: 'move',
|
||||
items: 'div',
|
||||
cancel: '.drop-message',
|
||||
update: function( event, ui ){
|
||||
// Check if we have an empty group
|
||||
var $zone = $('.add-to-group', $group);
|
||||
@@ -216,12 +354,13 @@
|
||||
|
||||
// Make the new group droppable
|
||||
$drop
|
||||
.droppable(dropOptions)
|
||||
.sortable(sortOptions);
|
||||
.droppable(dropOptions)
|
||||
.sortable(sortOptions);
|
||||
}
|
||||
}
|
||||
$("<div></div>").addClass('drag').text( ui.draggable.text() ).appendTo( $drop );
|
||||
ui.draggable.remove();
|
||||
|
||||
$("<div></div>").addClass('drag').attr('data-id', ui.draggable.data('id')).text( ui.draggable.text()).appendTo( $drop );
|
||||
ui.draggable.remove();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,25 +371,27 @@
|
||||
|
||||
// let the drop-group be droppable & sortable, accepting the tax items
|
||||
$('.droppable', $group)
|
||||
.droppable(dropOptions)
|
||||
.sortable(sortOptions);
|
||||
.droppable(dropOptions)
|
||||
.sortable(sortOptions);
|
||||
|
||||
$('.place .panel-body').sortable(sortOptions);
|
||||
|
||||
// let the gallery be droppable as well, accepting items from the trash
|
||||
$('.remove-from-group', $list)
|
||||
.droppable({
|
||||
accept: "#panel .drag",
|
||||
hoverClass: 'over',
|
||||
drop: function( event, ui ) {
|
||||
.droppable({
|
||||
accept: "#panel .drag",
|
||||
hoverClass: 'over',
|
||||
drop: function( event, ui ) {
|
||||
$("<div></div>").addClass('draggable').text( ui.draggable.text() ).attr('data-id', ui.draggable.data('id')).draggable(dragOptions).appendTo( $list.find('.panel-body') );
|
||||
ui.draggable.remove();
|
||||
|
||||
$("<div></div>").addClass('draggable').text( ui.draggable.text() ).draggable(dragOptions).appendTo( $list.find('.panel-body') );
|
||||
ui.draggable.remove();
|
||||
}
|
||||
});
|
||||
|
||||
{/literal}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{/block}
|
||||
@@ -5,86 +5,164 @@
|
||||
{block name="check-permissions"}admin.taxes-rules.view{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="taxes-rules">
|
||||
<div class="taxes-rules">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<div class="clearfix">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration/taxes_rules'}">{intl l="Taxes rules"}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
{module_include location='taxes_rules_top'}
|
||||
<div class="clearfix">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration/taxes_rules'}">{intl l="Taxes rules"}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption class="clearfix">
|
||||
{intl l="Taxes rules"}
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.taxes-rules.create"}
|
||||
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new tax rule'}" href="#creation_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</a>
|
||||
{/loop}
|
||||
</caption>
|
||||
<thead>
|
||||
{module_include location='taxes_rules_top'}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="general-block-decorator">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-condensed table-left-aligned">
|
||||
<caption class="clearfix">
|
||||
{intl l="Taxes rules"}
|
||||
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.taxes-rules.create"}
|
||||
<a class="btn btn-default btn-primary pull-right" title="{intl l='Create a new tax rule'}" href="#tax_rule_create_dialog" data-toggle="modal">
|
||||
<span class="glyphicon glyphicon-plus"></span>
|
||||
</a>
|
||||
{/loop}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l="Name"}</th>
|
||||
<th>{intl l="Description"}</th>
|
||||
<th>{intl l="Actions"}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Eco taxe</td>
|
||||
<td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur, aperiam, voluptatibus odio numquam adipisci!</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.change"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Change this tax rule'}" href="{url path="/admin/configuration/taxes_rules/update/{$ID}"}"><span class="glyphicon glyphicon-edit"></span></a>
|
||||
{/loop}
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.delete"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Delete this tax rule'}" href="#tax_rule_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{loop type="tax-rule" name="taxes-rules"}
|
||||
|
||||
<tr>
|
||||
<td>{$TITLE}</td>
|
||||
<td>{$DESCRIPTION}</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.change"}
|
||||
<a class="btn btn-default btn-xs" title="{intl l='Change this tax rule'}" href="{url path="/admin/configuration/taxes_rules/update/$ID"}"><span class="glyphicon glyphicon-edit"></span></a>
|
||||
{/loop}
|
||||
|
||||
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.change"}
|
||||
<a class="btn btn-default btn-xs js-delete-tax-rule" title="{intl l='Delete this tax rule'}" href="#tax_rule_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
{/loop}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{/loop}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{module_include location='taxes_rules_bottom'}
|
||||
|
||||
</div>
|
||||
|
||||
{module_include location='taxes_rules_bottom'}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{* -- Delete category confirmation dialog ----------------------------------- *}
|
||||
{* -- Add tax rule confirmation dialog ----------------------------------- *}
|
||||
{form name="thelia.admin.taxrule.add"}
|
||||
|
||||
{capture "tax_rule_delete_dialog"}
|
||||
<input type="hidden" name="tax_rule_id" id="tax_rule_delete_id" value="" />
|
||||
{if $form_error_message}
|
||||
{$taxCreateError = true}
|
||||
{else}
|
||||
{$taxCreateError = false}
|
||||
{/if}
|
||||
|
||||
{module_include location='tax_rule_delete_form'}
|
||||
{* Capture the dialog body, to pass it to the generic dialog *}
|
||||
{capture "tax_rule_create_dialog"}
|
||||
|
||||
{/capture}
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{include
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{intl l=$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$TITLE}{/if}{/if}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{intl l=$label} :
|
||||
<span class="label-help-block">{intl l="The detailed description."}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$DESCRIPTION}{/if}{/if}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-create-dialog.html"
|
||||
|
||||
dialog_id = "tax_rule_create_dialog"
|
||||
dialog_title = {intl l="Create a new tax rule"}
|
||||
dialog_body = {$smarty.capture.tax_rule_create_dialog nofilter}
|
||||
|
||||
dialog_ok_label = {intl l="Create"}
|
||||
dialog_cancel_label = {intl l="Cancel"}
|
||||
|
||||
form_action = {url path="/admin/configuration/taxes_rules/add"}
|
||||
form_enctype = {form_enctype form=$form}
|
||||
form_error_message = $form_error_message
|
||||
}
|
||||
|
||||
{/form}
|
||||
|
||||
{* -- Delete tax rule confirmation dialog ----------------------------------- *}
|
||||
|
||||
{capture "tax_rule_delete_dialog"}
|
||||
<input type="hidden" name="tax_rule_id" id="tax_rule_delete_id" value="" />
|
||||
|
||||
{module_include location='tax_rule_delete_form'}
|
||||
|
||||
{/capture}
|
||||
|
||||
{include
|
||||
file = "includes/generic-confirm-dialog.html"
|
||||
|
||||
dialog_id = "tax_rule_delete_dialog"
|
||||
dialog_title = {intl l="Delete tax rule"}
|
||||
dialog_message = {intl l="Do you really want to delete this tax rule ?"}
|
||||
|
||||
form_action = {url path='/admin/configuration/taxes_rules/delete'}
|
||||
form_content = {$smarty.capture.tax_rule_delete_dialog nofilter}
|
||||
form_action = {url path='/admin/configuration/taxes_rules/delete'}
|
||||
form_content = {$smarty.capture.tax_rule_delete_dialog nofilter}
|
||||
}
|
||||
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
{if $taxCreateError == true}
|
||||
$('#tax_rule_create_dialog').modal();
|
||||
{/if}
|
||||
|
||||
$(".js-delete-tax-rule").click(function(e){
|
||||
$('#tax_rule_delete_id').val($(this).data('id'))
|
||||
});
|
||||
</script>
|
||||
|
||||
{/block}
|
||||
Reference in New Issue
Block a user