Conflicts:
	core/lib/Thelia/Controller/Admin/ProductController.php
	core/lib/Thelia/Model/Product.php
This commit is contained in:
franck
2013-09-18 00:35:48 +02:00
45 changed files with 887 additions and 274 deletions

View File

@@ -61,9 +61,8 @@ class Order extends BaseAction implements EventSubscriberInterface
{
$order = $event->getOrder();
$deliveryAddress = $event->getDeliveryAddress();
$order->setDeliveryModuleId($event->getDeliveryModule());
$order->setPostage($event->getPostage());
$event->setOrder($order);
}

View File

@@ -41,6 +41,9 @@ use Thelia\Core\Event\ProductDeleteContentEvent;
use Thelia\Model\ProductAssociatedContent;
use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\ProductCategory;
use Thelia\Model\TaxRule;
use Thelia\Model\TaxRuleQuery;
use Thelia\Model\TaxQuery;
class Product extends BaseAction implements EventSubscriberInterface
{
@@ -61,6 +64,9 @@ class Product extends BaseAction implements EventSubscriberInterface
->setLocale($event->getLocale())
->setVisible($event->getVisible())
// Set the default tax rule to this product
->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true))
->create($event->getDefaultCategory())
;

View File

@@ -24,6 +24,7 @@
<loop class="Thelia\Core\Template\Loop\Order" name="order"/>
<loop class="Thelia\Core\Template\Loop\OrderStatus" name="order-status"/>
<loop class="Thelia\Core\Template\Loop\CategoryPath" name="category-path"/>
<loop class="Thelia\Core\Template\Loop\Payment" name="payment"/>
<loop class="Thelia\Core\Template\Loop\Product" name="product"/>
<loop class="Thelia\Core\Template\Loop\ProductSaleElements" name="product_sale_elements"/>
<loop class="Thelia\Core\Template\Loop\Feed" name="feed"/>
@@ -37,6 +38,7 @@
<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\TaxRule" name="tax-rule"/>
</loops>
<forms>
@@ -64,6 +66,7 @@
<form name="thelia.cart.add" class="Thelia\Form\CartAdd"/>
<form name="thelia.order.delivery" class="Thelia\Form\OrderDelivery"/>
<form name="thelia.order.payment" class="Thelia\Form\OrderPayment"/>
<form name="thelia.admin.config.creation" class="Thelia\Form\ConfigCreationForm"/>
<form name="thelia.admin.config.modification" class="Thelia\Form\ConfigModificationForm"/>

View File

@@ -112,16 +112,21 @@
<default key="_view">cart</default>
</route>
<route id="order.delivery" path="/order/delivery" methods="post">
<route id="order.delivery.process" path="/order/delivery" methods="post">
<default key="_controller">Thelia\Controller\Front\OrderController::deliver</default>
<default key="_view">order_delivery</default>
</route>
<route id="order.delivery.process" path="/order/delivery">
<route id="order.delivery" path="/order/delivery">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">order_delivery</default>
</route>
<route id="order.invoice.process" path="/order/invoice" methods="post">
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
<default key="_view">order_invoice</default>
</route>
<route id="order.invoice" path="/order/invoice">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">order_invoice</default>

View File

@@ -250,7 +250,7 @@ class ProductController extends AbstractCrudController
// Redirect to parent product list
$this->redirectToRoute(
'admin.products.default',
array('category_id' => $deleteEvent->getProduct()->getDefaultCategoryId())
array('category_id' => $this->getCategoryId())
);
}
@@ -261,7 +261,7 @@ class ProductController extends AbstractCrudController
// Redirect to parent product list
$this->redirectToRoute(
'admin.categories.default',
array('category_id' => $updateEvent->getProduct()->getDefaultCategoryId())
array('category_id' => $this->getCategoryId())
);
}
}
@@ -271,7 +271,7 @@ class ProductController extends AbstractCrudController
// Redirect to parent product list
$this->redirectToRoute(
'admin.categories.default',
array('category_id' => $positionEvent->getProduct()->getDefaultCategoryId())
array('category_id' => $this->getCategoryId())
);
}

View File

@@ -65,4 +65,14 @@ class BaseFrontController extends BaseController
$this->redirectToRoute("cart.view");
}
}
protected function checkValidDelivery()
{
$order = $this->getSession()->getOrder();
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) {
$this->redirectToRoute("order.delivery");
}
}
}

View File

@@ -28,9 +28,12 @@ use Thelia\Core\Event\OrderEvent;
use Thelia\Core\Event\TheliaEvents;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Form\OrderDelivery;
use Thelia\Form\OrderPayment;
use Thelia\Log\Tlog;
use Thelia\Model\AddressQuery;
use Thelia\Model\AreaDeliveryModuleQuery;
use Thelia\Model\CountryQuery;
use Thelia\Model\ModuleQuery;
use Thelia\Model\Order;
/**
@@ -41,7 +44,6 @@ use Thelia\Model\Order;
class OrderController extends BaseFrontController
{
/**
* set billing address
* set delivery address
* set delivery module
*/
@@ -59,25 +61,35 @@ class OrderController extends BaseFrontController
$deliveryAddressId = $form->get("delivery-address")->getData();
$deliveryModuleId = $form->get("delivery-module")->getData();
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
$deliveryModule = ModuleQuery::create()->findPk($deliveryModuleId);
/* check that the delivery address belong to the current customer */
/* check that the delivery address belongs to the current customer */
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Address does not belong to the current customer");
throw new \Exception("Delivery address does not belong to the current customer");
}
/* check that the delivery module fetch the delivery address area */
/* check that the delivery module fetches the delivery address area */
if(AreaDeliveryModuleQuery::create()
->filterByAreaId($deliveryAddress->getCountry()->getAreaId())
->filterByDeliveryModuleId()
->filterByDeliveryModuleId($deliveryModuleId)
->count() == 0) {
throw new \Exception("PUKE");
throw new \Exception("Delivery module cannot be use with selected delivery address");
}
/* try to get postage amount */
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
}
$moduleInstance = $moduleReflection->newInstance();
$postage = $moduleInstance->getPostage($deliveryAddress->getCountry());
$orderEvent = $this->getOrderEvent();
$orderEvent->setDeliveryAddress($deliveryAddressId);
$orderEvent->setDeliveryModule($deliveryModuleId);
$orderEvent->setPostage($postage);
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
@@ -105,6 +117,62 @@ class OrderController extends BaseFrontController
}
/**
* set invoice address
* set payment module
*/
public function pay()
{
$this->checkAuth();
$this->checkCartNotEmpty();
$this->checkValidDelivery();
$message = false;
$orderPayment = new OrderPayment($this->getRequest());
try {
$form = $this->validateForm($orderPayment, "post");
$deliveryAddressId = $form->get("delivery-address")->getData();
$deliveryModuleId = $form->get("delivery-module")->getData();
/* check that the invoice address belongs to the current customer */
$deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId);
if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) {
throw new \Exception("Invoice address does not belong to the current customer");
}
$orderEvent = $this->getOrderEvent();
$orderEvent->setInvoiceAddress($deliveryAddressId);
$orderEvent->setPaymentModule($deliveryModuleId);
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent);
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent);
$this->redirectToRoute("order.invoice");
} catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage());
} catch (PropelException $e) {
$this->getParserContext()->setGeneralError($e->getMessage());
} catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
}
if ($message !== false) {
Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage()));
$orderPayment->setErrorMessage($message);
$this->getParserContext()
->addForm($orderPayment)
->setGeneralError($message)
;
}
}
protected function getOrderEvent()
{
$order = $this->getOrder($this->getRequest());

View File

@@ -23,17 +23,16 @@
namespace Thelia\Core\Event;
use Thelia\Model\Address;
use Thelia\Model\AddressQuery;
use Thelia\Model\Module;
use Thelia\Model\Order;
class OrderEvent extends ActionEvent
{
protected $order = null;
protected $billingAddress = null;
protected $invoiceAddress = null;
protected $deliveryAddress = null;
protected $deliveryModule = null;
protected $paymentModule = null;
protected $postage = null;
/**
* @param Order $order
@@ -54,7 +53,7 @@ class OrderEvent extends ActionEvent
/**
* @param $address
*/
public function setBillingAddress($address)
public function setInvoiceAddress($address)
{
$this->deliveryAddress = $address;
}
@@ -75,6 +74,22 @@ class OrderEvent extends ActionEvent
$this->deliveryModule = $module;
}
/**
* @param $module
*/
public function setPaymentModule($module)
{
$this->paymentModule = $module;
}
/**
* @param $postage
*/
public function setPostage($postage)
{
$this->postage = $postage;
}
/**
* @return null|Order
*/
@@ -84,15 +99,15 @@ class OrderEvent extends ActionEvent
}
/**
* @return array|mixed|Address
* @return null|int
*/
public function getBillingAddress()
public function getInvoiceAddress()
{
return $this->billingAddress;
return $this->invoiceAddress;
}
/**
* @return array|mixed|Address
* @return null|int
*/
public function getDeliveryAddress()
{
@@ -100,10 +115,26 @@ class OrderEvent extends ActionEvent
}
/**
* @return array|mixed|Address
* @return null|int
*/
public function getDeliveryModule()
{
return $this->deliveryModule;
}
/**
* @return null|int
*/
public function getPaymentModule()
{
return $this->paymentModule;
}
/**
* @return null|int
*/
public function getPostage()
{
return $this->postage;
}
}

View File

@@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserInterface;
use Thelia\Exception\OrderException;
use Thelia\Tools\Redirect;
use Thelia\Tools\URL;
use Thelia\Core\Security\Exception\AuthenticationException;
@@ -87,6 +89,19 @@ class ViewListener implements EventSubscriberInterface
// Redirect to the login template
Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate()));
} catch (OrderException $e) {
switch($e->getCode()) {
case OrderException::CART_EMPTY:
// Redirect to the cart template
Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));
break;
case OrderException::UNDEFINED_DELIVERY:
// Redirect to the delivery choice template
Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL));
break;
}
throw $e;
}
}

View File

@@ -218,6 +218,9 @@ class Session extends BaseSession
return $this;
}
/**
* @return Order
*/
public function getOrder()
{
return $this->get("thelia.order");

View File

@@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
{
// TODO: Implement generate() method.
throw new RouteNotFoundException();
}
/**

View File

@@ -54,7 +54,13 @@ class Address extends BaseLoop
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
new Argument(
'id',
new TypeCollection(
new Type\IntListType(),
new Type\EnumType(array('*', 'any'))
)
),
new Argument(
'customer',
new TypeCollection(
@@ -63,8 +69,14 @@ class Address extends BaseLoop
),
'current'
),
Argument::createBooleanTypeArgument('default'),
Argument::createIntListTypeArgument('exclude')
Argument::createBooleanOrBothTypeArgument('default'),
new Argument(
'exclude',
new TypeCollection(
new Type\IntListType(),
new Type\EnumType(array('none'))
)
)
);
}
@@ -79,7 +91,7 @@ class Address extends BaseLoop
$id = $this->getId();
if (null !== $id) {
if (null !== $id && !in_array($id, array('*', 'any'))) {
$search->filterById($id, Criteria::IN);
}
@@ -106,7 +118,7 @@ class Address extends BaseLoop
$exclude = $this->getExclude();
if (!is_null($exclude)) {
if (null !== $exclude && 'none' !== $exclude) {
$search->filterById($exclude, Criteria::NOT_IN);
}

View File

@@ -29,7 +29,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\ModuleQuery;
/**
* Class Delivery
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
@@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop
{
$search = ModuleQuery::create();
$search->filterByActivate(1);
if (null !== $id = $this->getId()) {
$search->filterById($id);
}

View File

@@ -87,7 +87,7 @@ class Country extends BaseI18nLoop
if (true === $withArea) {
$search->filterByAreaId(null, Criteria::ISNOTNULL);
} elseif (false == $withArea) {
} elseif (false === $withArea) {
$search->filterByAreaId(null, Criteria::ISNULL);
}

View File

@@ -89,7 +89,7 @@ class Delivery extends BaseSpecificModule
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set('PRICE', $moduleInstance->calculate($country))
->set('POSTAGE', $moduleInstance->getPostage($country))
;
$loopResult->addRow($loopResultRow);

View File

@@ -0,0 +1,84 @@
<?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\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Module\BaseModule;
/**
* Class Payment
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@gmail.com>
*/
class Payment extends BaseSpecificModule
{
public function getArgDefinitions()
{
$collection = parent::getArgDefinitions();
return $collection;
}
public function exec(&$pagination)
{
$search = parent::exec($pagination);
/* manage translations */
$locale = $this->configureI18nProcessing($search);
$search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL);
/* perform search */
$paymentModules = $this->search($search, $pagination);
$loopResult = new LoopResult($paymentModules);
foreach ($paymentModules as $paymentModule) {
$loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable);
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
}
$moduleInstance = $moduleReflection->newInstance();
$moduleInstance->setRequest($this->request);
$moduleInstance->setDispatcher($this->dispatcher);
$loopResultRow
->set('ID', $paymentModule->getId())
->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE'))
->set('CHAPO', $paymentModule->getVirtualColumn('i18n_CHAPO'))
->set('DESCRIPTION', $paymentModule->getVirtualColumn('i18n_DESCRIPTION'))
->set('POSTSCRIPTUM', $paymentModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -0,0 +1,136 @@
<?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\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\TaxRuleQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/**
*
* TaxRule loop
*
*
* Class TaxRule
* @package Thelia\Core\Template\Loop
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class TaxRule extends BaseI18nLoop
{
public $timestampable = true;
/**
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id'),
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 = TaxRuleQuery::create();
/* manage translations */
$locale = $this->configureI18nProcessing($search, '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);
}
$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 */
$tax_rules = $this->search($search, $pagination);
$loopResult = new LoopResult($tax_rules);
foreach ($tax_rules as $tax_rule) {
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow
->set("ID" , $tax_rule->getId())
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE" , $locale)
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
}

View File

@@ -188,7 +188,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin
public function orderDataAccess($params, &$smarty)
{
return $this->dataAccess("Order", $params, $this->request->getSession()->getOrder());
$order = $this->request->getSession()->getOrder();
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
switch($attribute) {
case 'postage':
return $order->getPostage();
case 'delivery_address':
return $order->chosenDeliveryAddress;
}
throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute));
}
/**
@@ -196,6 +205,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin
*
* @param $params
* @param $smarty
*
* @return string
*/
public function langDataAccess($params, $smarty)
{
@@ -294,6 +305,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'),
new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'),

View File

@@ -78,7 +78,17 @@ class Security extends AbstractSmartyPlugin
{
$cart = $this->request->getSession()->getCart();
if($cart===null || $cart->countCartItems() == 0) {
throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY);
throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1));
}
return "";
}
public function checkValidDeliveryFunction($params, &$smarty)
{
$order = $this->request->getSession()->getOrder();
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) {
throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1));
}
return "";
@@ -94,6 +104,7 @@ class Security extends AbstractSmartyPlugin
return array(
new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'),
new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'),
new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'),
);
}
}

View File

@@ -25,12 +25,25 @@ namespace Thelia\Exception;
class OrderException extends \RuntimeException
{
/**
* @var string The cart template name
*/
public $cartRoute = "cart.view";
public $orderDeliveryRoute = "order.delivery";
public $arguments = array();
const UNKNOWN_EXCEPTION = 0;
const CART_EMPTY = 100;
public function __construct($message, $code = null, $previous = null)
const UNDEFINED_DELIVERY = 200;
public function __construct($message, $code = null, $arguments = array(), $previous = null)
{
if(is_array($arguments)) {
$this->arguments = $arguments;
}
if ($code === null) {
$code = self::UNKNOWN_EXCEPTION;
}

View File

@@ -0,0 +1,94 @@
<?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\AddressQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ModuleQuery;
use Thelia\Module\BaseModule;
/**
* Class OrderPayment
* @package Thelia\Form
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class OrderPayment extends BaseForm
{
protected function buildForm()
{
$this->formBuilder
->add("invoice-address", "integer", array(
"required" => true,
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback(array(
"methods" => array(
array($this, "verifyInvoiceAddress")
)
))
)
))
->add("payment-module", "integer", array(
"required" => true,
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback(array(
"methods" => array(
array($this, "verifyPaymentModule")
)
))
)
));
}
public function verifyInvoiceAddress($value, ExecutionContextInterface $context)
{
$address = AddressQuery::create()
->findPk($value);
if(null === $address) {
$context->addViolation("Address ID not found");
}
}
public function verifyPaymentModule($value, ExecutionContextInterface $context)
{
$module = ModuleQuery::create()
->filterByType(BaseModule::PAYMENT_MODULE_TYPE)
->filterByActivate(1)
->filterById($value)
->find();
if(null === $module) {
$context->addViolation("Payment module ID not found");
}
}
public function getName()
{
return "thelia_order_payment";
}
}

View File

@@ -77,13 +77,6 @@ abstract class Tax implements ActiveRecordInterface
*/
protected $serialized_requirements;
/**
* The value for the is_default field.
* Note: this column has a database default value of: false
* @var boolean
*/
protected $is_default;
/**
* The value for the created_at field.
* @var string
@@ -142,24 +135,11 @@ abstract class Tax implements ActiveRecordInterface
*/
protected $taxI18nsScheduledForDeletion = null;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->is_default = false;
}
/**
* Initializes internal state of Thelia\Model\Base\Tax object.
* @see applyDefaults()
*/
public function __construct()
{
$this->applyDefaultValues();
}
/**
@@ -442,17 +422,6 @@ abstract class Tax implements ActiveRecordInterface
return $this->serialized_requirements;
}
/**
* Get the [is_default] column value.
*
* @return boolean
*/
public function getIsDefault()
{
return $this->is_default;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -556,35 +525,6 @@ abstract class Tax implements ActiveRecordInterface
return $this;
} // setSerializedRequirements()
/**
* Sets the value of the [is_default] column.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
*
* @param boolean|integer|string $v The new value
* @return \Thelia\Model\Tax The current object (for fluent API support)
*/
public function setIsDefault($v)
{
if ($v !== null) {
if (is_string($v)) {
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
} else {
$v = (boolean) $v;
}
}
if ($this->is_default !== $v) {
$this->is_default = $v;
$this->modifiedColumns[] = TaxTableMap::IS_DEFAULT;
}
return $this;
} // setIsDefault()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -637,10 +577,6 @@ abstract class Tax implements ActiveRecordInterface
*/
public function hasOnlyDefaultValues()
{
if ($this->is_default !== false) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -677,16 +613,13 @@ abstract class Tax implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('SerializedRequirements', TableMap::TYPE_PHPNAME, $indexType)];
$this->serialized_requirements = (null !== $col) ? (string) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_default = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -699,7 +632,7 @@ abstract class Tax implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 6; // 6 = TaxTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 5; // 5 = TaxTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $e);
@@ -966,9 +899,6 @@ abstract class Tax implements ActiveRecordInterface
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) {
$modifiedColumns[':p' . $index++] = 'SERIALIZED_REQUIREMENTS';
}
if ($this->isColumnModified(TaxTableMap::IS_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
}
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -995,9 +925,6 @@ abstract class Tax implements ActiveRecordInterface
case 'SERIALIZED_REQUIREMENTS':
$stmt->bindValue($identifier, $this->serialized_requirements, PDO::PARAM_STR);
break;
case 'IS_DEFAULT':
$stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -1076,12 +1003,9 @@ abstract class Tax implements ActiveRecordInterface
return $this->getSerializedRequirements();
break;
case 3:
return $this->getIsDefault();
break;
case 4:
return $this->getCreatedAt();
break;
case 5:
case 4:
return $this->getUpdatedAt();
break;
default:
@@ -1116,9 +1040,8 @@ abstract class Tax implements ActiveRecordInterface
$keys[0] => $this->getId(),
$keys[1] => $this->getType(),
$keys[2] => $this->getSerializedRequirements(),
$keys[3] => $this->getIsDefault(),
$keys[4] => $this->getCreatedAt(),
$keys[5] => $this->getUpdatedAt(),
$keys[3] => $this->getCreatedAt(),
$keys[4] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1177,12 +1100,9 @@ abstract class Tax implements ActiveRecordInterface
$this->setSerializedRequirements($value);
break;
case 3:
$this->setIsDefault($value);
break;
case 4:
$this->setCreatedAt($value);
break;
case 5:
case 4:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1212,9 +1132,8 @@ abstract class Tax implements ActiveRecordInterface
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setType($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setSerializedRequirements($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setIsDefault($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
}
/**
@@ -1229,7 +1148,6 @@ abstract class Tax implements ActiveRecordInterface
if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id);
if ($this->isColumnModified(TaxTableMap::TYPE)) $criteria->add(TaxTableMap::TYPE, $this->type);
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) $criteria->add(TaxTableMap::SERIALIZED_REQUIREMENTS, $this->serialized_requirements);
if ($this->isColumnModified(TaxTableMap::IS_DEFAULT)) $criteria->add(TaxTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::UPDATED_AT, $this->updated_at);
@@ -1297,7 +1215,6 @@ abstract class Tax implements ActiveRecordInterface
{
$copyObj->setType($this->getType());
$copyObj->setSerializedRequirements($this->getSerializedRequirements());
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1871,12 +1788,10 @@ abstract class Tax implements ActiveRecordInterface
$this->id = null;
$this->type = null;
$this->serialized_requirements = null;
$this->is_default = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);

View File

@@ -25,14 +25,12 @@ use Thelia\Model\Map\TaxTableMap;
* @method ChildTaxQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildTaxQuery orderByType($order = Criteria::ASC) Order by the type column
* @method ChildTaxQuery orderBySerializedRequirements($order = Criteria::ASC) Order by the serialized_requirements column
* @method ChildTaxQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
* @method ChildTaxQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildTaxQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildTaxQuery groupById() Group by the id column
* @method ChildTaxQuery groupByType() Group by the type column
* @method ChildTaxQuery groupBySerializedRequirements() Group by the serialized_requirements column
* @method ChildTaxQuery groupByIsDefault() Group by the is_default column
* @method ChildTaxQuery groupByCreatedAt() Group by the created_at column
* @method ChildTaxQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -54,14 +52,12 @@ use Thelia\Model\Map\TaxTableMap;
* @method ChildTax findOneById(int $id) Return the first ChildTax filtered by the id column
* @method ChildTax findOneByType(string $type) Return the first ChildTax filtered by the type column
* @method ChildTax findOneBySerializedRequirements(string $serialized_requirements) Return the first ChildTax filtered by the serialized_requirements column
* @method ChildTax findOneByIsDefault(boolean $is_default) Return the first ChildTax filtered by the is_default column
* @method ChildTax findOneByCreatedAt(string $created_at) Return the first ChildTax filtered by the created_at column
* @method ChildTax findOneByUpdatedAt(string $updated_at) Return the first ChildTax filtered by the updated_at column
*
* @method array findById(int $id) Return ChildTax objects filtered by the id column
* @method array findByType(string $type) Return ChildTax objects filtered by the type column
* @method array findBySerializedRequirements(string $serialized_requirements) Return ChildTax objects filtered by the serialized_requirements column
* @method array findByIsDefault(boolean $is_default) Return ChildTax objects filtered by the is_default column
* @method array findByCreatedAt(string $created_at) Return ChildTax objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildTax objects filtered by the updated_at column
*
@@ -152,7 +148,7 @@ abstract class TaxQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, TYPE, SERIALIZED_REQUIREMENTS, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
$sql = 'SELECT ID, TYPE, SERIALIZED_REQUIREMENTS, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -340,33 +336,6 @@ abstract class TaxQuery extends ModelCriteria
return $this->addUsingAlias(TaxTableMap::SERIALIZED_REQUIREMENTS, $serializedRequirements, $comparison);
}
/**
* Filter the query on the is_default column
*
* Example usage:
* <code>
* $query->filterByIsDefault(true); // WHERE is_default = true
* $query->filterByIsDefault('yes'); // WHERE is_default = true
* </code>
*
* @param boolean|string $isDefault The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildTaxQuery The current query, for fluid interface
*/
public function filterByIsDefault($isDefault = null, $comparison = null)
{
if (is_string($isDefault)) {
$is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(TaxTableMap::IS_DEFAULT, $isDefault, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -67,6 +67,13 @@ abstract class TaxRule implements ActiveRecordInterface
*/
protected $id;
/**
* The value for the is_default field.
* Note: this column has a database default value of: false
* @var boolean
*/
protected $is_default;
/**
* The value for the created_at field.
* @var string
@@ -137,11 +144,24 @@ abstract class TaxRule implements ActiveRecordInterface
*/
protected $taxRuleI18nsScheduledForDeletion = null;
/**
* Applies default values to this object.
* This method should be called from the object's constructor (or
* equivalent initialization method).
* @see __construct()
*/
public function applyDefaultValues()
{
$this->is_default = false;
}
/**
* Initializes internal state of Thelia\Model\Base\TaxRule object.
* @see applyDefaults()
*/
public function __construct()
{
$this->applyDefaultValues();
}
/**
@@ -402,6 +422,17 @@ abstract class TaxRule implements ActiveRecordInterface
return $this->id;
}
/**
* Get the [is_default] column value.
*
* @return boolean
*/
public function getIsDefault()
{
return $this->is_default;
}
/**
* Get the [optionally formatted] temporal [created_at] column value.
*
@@ -463,6 +494,35 @@ abstract class TaxRule implements ActiveRecordInterface
return $this;
} // setId()
/**
* Sets the value of the [is_default] column.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
*
* @param boolean|integer|string $v The new value
* @return \Thelia\Model\TaxRule The current object (for fluent API support)
*/
public function setIsDefault($v)
{
if ($v !== null) {
if (is_string($v)) {
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
} else {
$v = (boolean) $v;
}
}
if ($this->is_default !== $v) {
$this->is_default = $v;
$this->modifiedColumns[] = TaxRuleTableMap::IS_DEFAULT;
}
return $this;
} // setIsDefault()
/**
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
*
@@ -515,6 +575,10 @@ abstract class TaxRule implements ActiveRecordInterface
*/
public function hasOnlyDefaultValues()
{
if ($this->is_default !== false) {
return false;
}
// otherwise, everything was equal, so return TRUE
return true;
} // hasOnlyDefaultValues()
@@ -545,13 +609,16 @@ abstract class TaxRule implements ActiveRecordInterface
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxRuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
$this->id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxRuleTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)];
$this->is_default = (null !== $col) ? (boolean) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxRuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
if ($col === '0000-00-00 00:00:00') {
$col = null;
}
@@ -564,7 +631,7 @@ abstract class TaxRule implements ActiveRecordInterface
$this->ensureConsistency();
}
return $startcol + 3; // 3 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS.
return $startcol + 4; // 4 = TaxRuleTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \Thelia\Model\TaxRule object", 0, $e);
@@ -845,6 +912,9 @@ abstract class TaxRule implements ActiveRecordInterface
if ($this->isColumnModified(TaxRuleTableMap::ID)) {
$modifiedColumns[':p' . $index++] = 'ID';
}
if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) {
$modifiedColumns[':p' . $index++] = 'IS_DEFAULT';
}
if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) {
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
}
@@ -865,6 +935,9 @@ abstract class TaxRule implements ActiveRecordInterface
case 'ID':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case 'IS_DEFAULT':
$stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT);
break;
case 'CREATED_AT':
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
break;
@@ -937,9 +1010,12 @@ abstract class TaxRule implements ActiveRecordInterface
return $this->getId();
break;
case 1:
return $this->getCreatedAt();
return $this->getIsDefault();
break;
case 2:
return $this->getCreatedAt();
break;
case 3:
return $this->getUpdatedAt();
break;
default:
@@ -972,8 +1048,9 @@ abstract class TaxRule implements ActiveRecordInterface
$keys = TaxRuleTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCreatedAt(),
$keys[2] => $this->getUpdatedAt(),
$keys[1] => $this->getIsDefault(),
$keys[2] => $this->getCreatedAt(),
$keys[3] => $this->getUpdatedAt(),
);
$virtualColumns = $this->virtualColumns;
foreach($virtualColumns as $key => $virtualColumn)
@@ -1029,9 +1106,12 @@ abstract class TaxRule implements ActiveRecordInterface
$this->setId($value);
break;
case 1:
$this->setCreatedAt($value);
$this->setIsDefault($value);
break;
case 2:
$this->setCreatedAt($value);
break;
case 3:
$this->setUpdatedAt($value);
break;
} // switch()
@@ -1059,8 +1139,9 @@ abstract class TaxRule implements ActiveRecordInterface
$keys = TaxRuleTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]);
if (array_key_exists($keys[1], $arr)) $this->setIsDefault($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
}
/**
@@ -1073,6 +1154,7 @@ abstract class TaxRule implements ActiveRecordInterface
$criteria = new Criteria(TaxRuleTableMap::DATABASE_NAME);
if ($this->isColumnModified(TaxRuleTableMap::ID)) $criteria->add(TaxRuleTableMap::ID, $this->id);
if ($this->isColumnModified(TaxRuleTableMap::IS_DEFAULT)) $criteria->add(TaxRuleTableMap::IS_DEFAULT, $this->is_default);
if ($this->isColumnModified(TaxRuleTableMap::CREATED_AT)) $criteria->add(TaxRuleTableMap::CREATED_AT, $this->created_at);
if ($this->isColumnModified(TaxRuleTableMap::UPDATED_AT)) $criteria->add(TaxRuleTableMap::UPDATED_AT, $this->updated_at);
@@ -1138,6 +1220,7 @@ abstract class TaxRule implements ActiveRecordInterface
*/
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setIsDefault($this->getIsDefault());
$copyObj->setCreatedAt($this->getCreatedAt());
$copyObj->setUpdatedAt($this->getUpdatedAt());
@@ -1961,10 +2044,12 @@ abstract class TaxRule implements ActiveRecordInterface
public function clear()
{
$this->id = null;
$this->is_default = null;
$this->created_at = null;
$this->updated_at = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);

View File

@@ -23,10 +23,12 @@ use Thelia\Model\Map\TaxRuleTableMap;
*
*
* @method ChildTaxRuleQuery orderById($order = Criteria::ASC) Order by the id column
* @method ChildTaxRuleQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column
* @method ChildTaxRuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
* @method ChildTaxRuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
*
* @method ChildTaxRuleQuery groupById() Group by the id column
* @method ChildTaxRuleQuery groupByIsDefault() Group by the is_default column
* @method ChildTaxRuleQuery groupByCreatedAt() Group by the created_at column
* @method ChildTaxRuleQuery groupByUpdatedAt() Group by the updated_at column
*
@@ -50,10 +52,12 @@ use Thelia\Model\Map\TaxRuleTableMap;
* @method ChildTaxRule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTaxRule matching the query, or a new ChildTaxRule object populated from the query conditions when no match is found
*
* @method ChildTaxRule findOneById(int $id) Return the first ChildTaxRule filtered by the id column
* @method ChildTaxRule findOneByIsDefault(boolean $is_default) Return the first ChildTaxRule filtered by the is_default column
* @method ChildTaxRule findOneByCreatedAt(string $created_at) Return the first ChildTaxRule filtered by the created_at column
* @method ChildTaxRule findOneByUpdatedAt(string $updated_at) Return the first ChildTaxRule filtered by the updated_at column
*
* @method array findById(int $id) Return ChildTaxRule objects filtered by the id column
* @method array findByIsDefault(boolean $is_default) Return ChildTaxRule objects filtered by the is_default column
* @method array findByCreatedAt(string $created_at) Return ChildTaxRule objects filtered by the created_at column
* @method array findByUpdatedAt(string $updated_at) Return ChildTaxRule objects filtered by the updated_at column
*
@@ -144,7 +148,7 @@ abstract class TaxRuleQuery extends ModelCriteria
*/
protected function findPkSimple($key, $con)
{
$sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
$sql = 'SELECT ID, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM tax_rule WHERE ID = :p0';
try {
$stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@@ -274,6 +278,33 @@ abstract class TaxRuleQuery extends ModelCriteria
return $this->addUsingAlias(TaxRuleTableMap::ID, $id, $comparison);
}
/**
* Filter the query on the is_default column
*
* Example usage:
* <code>
* $query->filterByIsDefault(true); // WHERE is_default = true
* $query->filterByIsDefault('yes'); // WHERE is_default = true
* </code>
*
* @param boolean|string $isDefault The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return ChildTaxRuleQuery The current query, for fluid interface
*/
public function filterByIsDefault($isDefault = null, $comparison = null)
{
if (is_string($isDefault)) {
$is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(TaxRuleTableMap::IS_DEFAULT, $isDefault, $comparison);
}
/**
* Filter the query on the created_at column
*

View File

@@ -79,7 +79,6 @@ class Category extends BaseCategory
*/
public function postInsert(ConnectionInterface $con = null)
{
//$this->generateRewrittenUrl($this->getLocale());
$this->dispatchEvent(TheliaEvents::AFTER_CREATECATEGORY, new CategoryEvent($this));
}

View File

@@ -39,9 +39,4 @@ class Content extends BaseContent
return true;
}
public function postInsert(ConnectionInterface $con = null)
{
//$this->generateRewrittenUrl($this->getLocale());
}
}

View File

@@ -70,9 +70,4 @@ class Folder extends BaseFolder
return true;
}
public function postInsert(ConnectionInterface $con = null)
{
//$this->generateRewrittenUrl($this->getLocale());
}
}

View File

@@ -2,8 +2,14 @@
namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\FolderI18n as BaseFolderI18n;
class FolderI18n extends BaseFolderI18n {
public function postInsert(ConnectionInterface $con = null)
{
$folder = $this->getFolder();
$folder->generateRewrittenUrl($this->getLocale());
}
}

View File

@@ -57,7 +57,7 @@ class TaxRuleTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 3;
const NUM_COLUMNS = 4;
/**
* The number of lazy-loaded columns
@@ -67,13 +67,18 @@ class TaxRuleTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 3;
const NUM_HYDRATE_COLUMNS = 4;
/**
* the column name for the ID field
*/
const ID = 'tax_rule.ID';
/**
* the column name for the IS_DEFAULT field
*/
const IS_DEFAULT = 'tax_rule.IS_DEFAULT';
/**
* the column name for the CREATED_AT field
*/
@@ -105,12 +110,12 @@ class TaxRuleTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, )
self::TYPE_PHPNAME => array('Id', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'isDefault', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxRuleTableMap::ID, TaxRuleTableMap::IS_DEFAULT, TaxRuleTableMap::CREATED_AT, TaxRuleTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'is_default', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
@@ -120,12 +125,12 @@ class TaxRuleTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ),
self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::CREATED_AT => 1, TaxRuleTableMap::UPDATED_AT => 2, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ),
self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ),
self::TYPE_NUM => array(0, 1, 2, )
self::TYPE_PHPNAME => array('Id' => 0, 'IsDefault' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'isDefault' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
self::TYPE_COLNAME => array(TaxRuleTableMap::ID => 0, TaxRuleTableMap::IS_DEFAULT => 1, TaxRuleTableMap::CREATED_AT => 2, TaxRuleTableMap::UPDATED_AT => 3, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'IS_DEFAULT' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
self::TYPE_FIELDNAME => array('id' => 0, 'is_default' => 1, 'created_at' => 2, 'updated_at' => 3, ),
self::TYPE_NUM => array(0, 1, 2, 3, )
);
/**
@@ -145,6 +150,7 @@ class TaxRuleTableMap extends TableMap
$this->setUseIdGenerator(true);
// columns
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', true, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -323,10 +329,12 @@ class TaxRuleTableMap extends TableMap
{
if (null === $alias) {
$criteria->addSelectColumn(TaxRuleTableMap::ID);
$criteria->addSelectColumn(TaxRuleTableMap::IS_DEFAULT);
$criteria->addSelectColumn(TaxRuleTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxRuleTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}

View File

@@ -57,7 +57,7 @@ class TaxTableMap extends TableMap
/**
* The total number of columns
*/
const NUM_COLUMNS = 6;
const NUM_COLUMNS = 5;
/**
* The number of lazy-loaded columns
@@ -67,7 +67,7 @@ class TaxTableMap extends TableMap
/**
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
*/
const NUM_HYDRATE_COLUMNS = 6;
const NUM_HYDRATE_COLUMNS = 5;
/**
* the column name for the ID field
@@ -84,11 +84,6 @@ class TaxTableMap extends TableMap
*/
const SERIALIZED_REQUIREMENTS = 'tax.SERIALIZED_REQUIREMENTS';
/**
* the column name for the IS_DEFAULT field
*/
const IS_DEFAULT = 'tax.IS_DEFAULT';
/**
* the column name for the CREATED_AT field
*/
@@ -120,12 +115,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
protected static $fieldNames = array (
self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'IsDefault', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'isDefault', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::IS_DEFAULT, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'is_default', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'CreatedAt', 'UpdatedAt', ),
self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'createdAt', 'updatedAt', ),
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'CREATED_AT', 'UPDATED_AT', ),
self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'created_at', 'updated_at', ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
@@ -135,12 +130,12 @@ class TaxTableMap extends TableMap
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
*/
protected static $fieldKeys = array (
self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'IsDefault' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'isDefault' => 3, 'createdAt' => 4, 'updatedAt' => 5, ),
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::IS_DEFAULT => 3, TaxTableMap::CREATED_AT => 4, TaxTableMap::UPDATED_AT => 5, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'IS_DEFAULT' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ),
self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'is_default' => 3, 'created_at' => 4, 'updated_at' => 5, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, )
self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::CREATED_AT => 3, TaxTableMap::UPDATED_AT => 4, ),
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'created_at' => 3, 'updated_at' => 4, ),
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
);
/**
@@ -162,7 +157,6 @@ class TaxTableMap extends TableMap
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
$this->addColumn('SERIALIZED_REQUIREMENTS', 'SerializedRequirements', 'LONGVARCHAR', true, null, null);
$this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false);
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
} // initialize()
@@ -341,14 +335,12 @@ class TaxTableMap extends TableMap
$criteria->addSelectColumn(TaxTableMap::ID);
$criteria->addSelectColumn(TaxTableMap::TYPE);
$criteria->addSelectColumn(TaxTableMap::SERIALIZED_REQUIREMENTS);
$criteria->addSelectColumn(TaxTableMap::IS_DEFAULT);
$criteria->addSelectColumn(TaxTableMap::CREATED_AT);
$criteria->addSelectColumn(TaxTableMap::UPDATED_AT);
} else {
$criteria->addSelectColumn($alias . '.ID');
$criteria->addSelectColumn($alias . '.TYPE');
$criteria->addSelectColumn($alias . '.SERIALIZED_REQUIREMENTS');
$criteria->addSelectColumn($alias . '.IS_DEFAULT');
$criteria->addSelectColumn($alias . '.CREATED_AT');
$criteria->addSelectColumn($alias . '.UPDATED_AT');
}

View File

@@ -7,7 +7,7 @@ use Thelia\Model\Base\Order as BaseOrder;
class Order extends BaseOrder
{
public $chosenDeliveryAddress = null;
public $chosenInvoiceModule = null;
public $chosenInvoiceAddress = null;
/**
* calculate the total amount

View File

@@ -103,7 +103,7 @@ class Product extends BaseProduct
try {
// Create the product
$this->save($con);
echo "1";
// Add the default category
$pc = new ProductCategory();
@@ -116,19 +116,19 @@ echo "1";
// Set the position
$this->setPosition($this->getNextPosition())->save($con);
echo "2";
// Create an empty product sale element
$sale_elements = new ProductSaleElements();
$sale_elements
->setProduct($this)
->setRef('')
->setRef($this->getRef())
->setPromo(0)
->setNewness(0)
->setWeight(0)
->save($con)
;
echo "3";
// Create an empty product price in the default currency
$product_price = new ProductPrice();
@@ -136,22 +136,19 @@ echo "1";
->setProductSaleElements($sale_elements)
->setPromoPrice(0)
->setPrice(0)
->setCurrency(CurrencyQuery::create()->findByByDefault(true))
->setCurrency(CurrencyQuery::create()->findOneByByDefault(true))
->save($con)
;
echo "4";
// Store all the stuff !
$con->commit();
echo "commited !!!: ".$this->getId();
$this->dispatchEvent(TheliaEvents::AFTER_CREATEPRODUCT, new ProductEvent($this));
}
catch(PropelException $ex) {
catch(\Exception $ex) {
$con->rollback();
echo("error !");
exit;
throw $ex;
}
}
@@ -172,9 +169,7 @@ exit;
if ($produits != null) $query->filterById($produits, Criteria::IN);
}
/**
* {@inheritDoc}
*/
public function preUpdate(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_UPDATEPRODUCT, new ProductEvent($this));

View File

@@ -2,8 +2,14 @@
namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\ProductI18n as BaseProductI18n;
class ProductI18n extends BaseProductI18n {
public function postInsert(ConnectionInterface $con = null)
{
$product = $this->getProduct();
$product->generateRewrittenUrl($this->getLocale());
}
}

View File

@@ -34,5 +34,5 @@ interface DeliveryModuleInterface extends BaseModuleInterface
*
* @return mixed
*/
public function calculate(Country $country);
public function getPostage(Country $country);
}

View File

@@ -76,6 +76,7 @@ class ProductRewriteTest extends \PHPUnit_Framework_TestCase
}
/**
* @covers Thelia\Model\Tools\UrlRewritingTrait::generateRewrittenUrl
* @expectedException \RuntimeException
* @expectedExceptionMessage Object product must be saved before generating url
*/

View File

@@ -281,7 +281,7 @@ try {
$folder = new Thelia\Model\Folder();
$folder->setParent(0);
$folder->setVisible(1);
$folder->setPosition($i);
$folder->setPosition($i+1);
setI18n($faker, $folder);
$folder->save();
@@ -294,11 +294,11 @@ try {
$document->setFolderId($folder->getId());
generate_document($document, 1, 'folder', $folder->getId());
for($j=1; $j<rand(0, 5); $j++) {
for($j=0; $j<3; $j++) {
$subfolder = new Thelia\Model\Folder();
$subfolder->setParent($folder->getId());
$subfolder->setVisible(1);
$subfolder->setPosition($j);
$subfolder->setPosition($j+1);
setI18n($faker, $subfolder);
$subfolder->save();
@@ -311,7 +311,7 @@ try {
$document->setFolderId($folder->getId());
generate_document($document, 1, 'folder', $subfolder->getId());
for($k=0; $k<rand(0, 5); $k++) {
for($k=0; $k<4; $k++) {
$content = new Thelia\Model\Content();
$content->addFolder($subfolder);
@@ -320,8 +320,8 @@ try {
$collection->prepend($contentFolders[0]->setDefaultFolder(1));
$content->setContentFolders($collection);
$content->setVisible(rand(1, 10)>7 ? 0 : 1);
$content->setPosition($k);
$content->setVisible(1);
$content->setPosition($k+1);
setI18n($faker, $content);
$content->save();

View File

@@ -1128,18 +1128,18 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
(268, 'es_ES', 'USA - Alabama', '', '', ''),
(268, 'fr_FR', 'USA - Alabama', '', '', '');
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `is_default`, `created_at`, `updated_at`)
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `updated_at`)
VALUES
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', 1, NOW(), NOW());
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW());
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
VALUES
(1, 'fr_FR', 'TVA française à 19.6%'),
(1, 'en_UK', 'french 19.6% tax');
INSERT INTO `tax_rule` (`id`, `created_at`, `updated_at`)
INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
VALUES
(1, NOW(), NOW());
(1, 1, NOW(), NOW());
INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
VALUES

View File

@@ -121,7 +121,6 @@ CREATE TABLE `tax`
`id` INTEGER NOT NULL AUTO_INCREMENT,
`type` VARCHAR(255) NOT NULL,
`serialized_requirements` TEXT NOT NULL,
`is_default` TINYINT(1) DEFAULT 0,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)
@@ -136,6 +135,7 @@ DROP TABLE IF EXISTS `tax_rule`;
CREATE TABLE `tax_rule`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`is_default` TINYINT(1) DEFAULT 0 NOT NULL,
`created_at` DATETIME,
`updated_at` DATETIME,
PRIMARY KEY (`id`)

View File

@@ -102,7 +102,6 @@
<column name="type" required="true" size="255" type="VARCHAR" />
<column name="serialized_requirements" required="true" type="LONGVARCHAR" />
<column name="title" size="255" type="VARCHAR" />
<column name="description" type="LONGVARCHAR" />
<column name="description" type="LONGVARCHAR" />
<behavior name="timestampable" />
<behavior name="i18n">
@@ -112,6 +111,7 @@
<table name="tax_rule" namespace="Thelia\Model">
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
<column name="title" size="255" type="VARCHAR" />
<column name="description" type="LONGVARCHAR" />
<column defaultValue="0" name="is_default" required="true" type="BOOLEAN" />
<behavior name="timestampable" />
<behavior name="i18n">

View File

@@ -61,7 +61,7 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface
* @param Country $country
* @return mixed
*/
public function calculate(Country $country)
public function getPostage(Country $country)
{
// TODO: Implement calculate() method.
return 2;

View File

@@ -517,6 +517,7 @@
{capture "product_delete_dialog"}
<input type="hidden" name="product_id" id="product_delete_id" value="" />
<input type="hidden" name="category_id" value="{$category_id}" />
{module_include location='product_delete_form'}

View File

@@ -1124,6 +1124,7 @@ td.product,
> tr {
> td {
&.price,
&.unitprice,
&.qty,
&.subprice { padding: 35px 10px; }
}

View File

@@ -128,7 +128,7 @@
{form_field form=$form field='delivery-module'}
<input type="radio" name="{$name}" {if $value == $ID}checked="checked"{/if} value="{$ID}">
{/form_field}
<strong>{$TITLE}</strong> / {currency attr="symbol"} {$PRICE}
<strong>{$TITLE}</strong> / {currency attr="symbol"} {$POSTAGE}
</label>
</div>
{/loop}

View File

@@ -1,5 +1,11 @@
{extends file="layout.tpl"}
{block name="no-return-functions"}
{check_auth context="front" roles="CUSTOMER" login_tpl="login"}
{check_cart_not_empty}
{check_valid_delivery}
{/block}
{block name="breadcrumb"}
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
<strong id="breadcrumb-label">You are here: </strong>
@@ -18,13 +24,20 @@
<h1 id="main-label" class="page-header">Your Cart</h1>
<div class="btn-group checkout-progress">
<a href="cart.php" role="button" class="btn btn-step"><span class="step-nb">1</span> <span class="step-label"> <span>Your Cart</span></a>
<a href="cart-step2.php" role="button" class="btn btn-step"><span class="step-nb">2</span> <span class="step-label">Billing and delivery</span></a>
<a href="cart-step3.php" role="button" class="btn btn-step active"><span class="step-nb">3</span> <span class="step-label">Check my order</span></a>
<a href="cart-step4.php" role="button" class="btn btn-step disabled"><span class="step-nb">4</span> <span class="step-label">Secure payment</span></a>
<a href="{url path="/cart"}" role="button" class="btn btn-step"><span class="step-nb">1</span> <span class="step-label"> <span>Your Cart</span></a>
<a href="{url path="/order/delivery"}" role="button" class="btn btn-step"><span class="step-nb">2</span> <span class="step-label">Billing and delivery</span></a>
<a href="#" role="button" class="btn btn-step active"><span class="step-nb">3</span> <span class="step-label">Check my order</span></a>
<a href="#" role="button" class="btn btn-step disabled"><span class="step-nb">4</span> <span class="step-label">Secure payment</span></a>
</div>
<form id="form-cart" action="cart-step4.php" method="post" role="form">
{form name="thelia.order.payment"}
<form id="form-cart-payment" action="{url path="/order/invoice"}" method="post" role="form" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<table class="table table-cart">
<colgroup>
<col width="150">
@@ -43,6 +56,10 @@
<span class="hidden-xs">Unit Price</span>
<span class="visible-xs">Price</span>
</th>
<th class="qty">
<span class="hidden-xs">Quantity</span>
<span class="visible-xs">Quantity</span>
</th>
<th class="subprice">
<span class="hidden-xs">Total <abbr title="Tax Inclusive">TTC</abbr></span>
<span class="visible-xs">Total</span>
@@ -96,6 +113,9 @@
<div class="special-price"><span class="price">{currency attr="symbol"} {$TAXED_PRICE}</span></div>
{/if}
</td>
<td class="qty">
<span class="price">{$QUANTITY}</span>
</td>
<td class="subprice">
<span class="price">{currency attr="symbol"} {$real_price * $QUANTITY}</span>
</td>
@@ -106,11 +126,11 @@
</tbody>
<tfoot>
<tr >
<td rowspan="3" colspan="2" class="empty">&nbsp;</td>
<td rowspan="3" colspan="3" class="empty">&nbsp;</td>
<th class="shipping">Shipping Tax</th>
<td class="shipping">
<div class="shipping-price">
<span class="price">{order attr="postage"}</span>
<span class="price">{currency attr="symbol"} {order attr="postage"}</span>
</div>
</td>
</tr>
@@ -129,7 +149,7 @@
<th class="total">Total <abbr title="Tax Inclusive">TTC</abbr></th>
<td class="total">
<div class="total-price">
<span class="price">$200.00</span>
<span class="price">{currency attr="symbol"} {{cart attr="total_taxed_price"} + {order attr="postage"}}</span>
</div>
</td>
</tr>
@@ -138,38 +158,115 @@
<div id="cart-address">
<div class="panel">
{loop type="address" name="delivery-address" id="{order attr="delivery_address"}"}
<div class="panel-heading">Delivery address</div>
<div class="panel-body">
<span class="fn">M. DUPONT Jean</span>
<span class="org">Agency XY</span>
<span class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords}</span>
<span class="org">{$COMPANY}</span>
<address class="adr">
<span class="street-address">street name of my business</span><br>
<span class="postal-code">75000</span>
<span class="locality">City, <span class="country-name">Country</span></span>
<span class="street-address">{$ADDRESS1}</span><br>
{if $ADDRESS2 != ""}
<span class="street-address">{$ADDRESS2}</span><br>
{/if}
{if $ADDRESS3 != ""}
<span class="street-address">{$ADDRESS3}</span><br>
{/if}
<span class="postal-code">{$ZIPCODE}</span>
<span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
</address>
</div>
{/loop}
</div>
{form_field form=$form field='invoice-address'}
<div class="panel">
<div class="panel-heading">Billing address</div>
{if $error}
<span class="help-block"><span class="icon-remove"></span> {$message}</span>
{/if}
<div class="panel-body">
<span class="fn">M. DUPONT Jean</span>
<span class="org">Agency XY</span>
<address class="adr">
<span class="street-address">street name of my business</span><br>
<span class="postal-code">75000</span>
<span class="locality">City, <span class="country-name">Country</span></span>
</address>
<a href="address.php" class="btn btn-change-address">Change address</a>
<table class="col-md-12">
{loop type="address" name="invoice-address" default="{if !$error && $value}*{else}true{/if}" id="{if !$error && $value}{$value}{else}*{/if}"}
<tr>
<td>
<span class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords}</span>
<span class="org">{$COMPANY}</span>
<address class="adr">
<span class="street-address">{$ADDRESS1}</span><br>
{if $ADDRESS2 != ""}
<span class="street-address">{$ADDRESS2}</span><br>
{/if}
{if $ADDRESS3 != ""}
<span class="street-address">{$ADDRESS3}</span><br>
{/if}
<span class="postal-code">{$ZIPCODE}</span>
<span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
</address>
</td>
<td>
<input class="js-invoice-address-selector {if !$error}hidden{/if}" type="radio" name="{$name}" value="{$ID}" {if $value == $ID OR !$error}checked="checked"{/if}>
</td>
</tr>
{if !$error}
<tr class="js-change-invoice-address">
<td colspan="2">
<a href="#" class="btn btn-change-address">Change address</a>
</td>
</tr>
{/if}
{/loop}
{loop type="address" name="invoice-address" default="{if !$error && $value}*{else}false{/if}" exclude="{if !$error && $value}{$value}{else}none{/if}"}
<tr class="js-other-invoice-address {if !$error}hidden{/if}">
<td>
<span class="fn">{loop type="title" name="customer.title.info" id=$TITLE}{$SHORT}{/loop} {$LASTNAME|upper} {$FIRSTNAME|ucwords}</span>
<span class="org">{$COMPANY}</span>
<address class="adr">
<span class="street-address">{$ADDRESS1}</span><br>
{if $ADDRESS2 != ""}
<span class="street-address">{$ADDRESS2}</span><br>
{/if}
{if $ADDRESS3 != ""}
<span class="street-address">{$ADDRESS3}</span><br>
{/if}
<span class="postal-code">{$ZIPCODE}</span>
<span class="locality">{$CITY}, <span class="country-name">{loop type="country" name="customer.country.info" id=$COUNTRY}{$TITLE}{/loop}</span></span>
</address>
</td>
<td>
<input class="js-invoice-address-selector {if !$error}hidden{/if}" type="radio" name="{$name}" value="{$ID}" {if $value == $ID}checked="checked"{/if}>
</td>
</tr>
{/loop}
</table>
</div>
</div>
</div>
{/form_field}
{form_field form=$form field='payment-module'}
<div id="payment-method" class="panel">
<div class="panel-heading">Choose your payment method</div>
<div class="panel-body">
<ul class="list-payment">
<?php foreach ($payment as $key => $value) { ?>
{loop type="payment" name="payments" force_return="true"}
<li>
<div class="radio">
<label for="payment_<?php echo $key; ?>">
@@ -178,14 +275,20 @@
</label>
</div>
</li>
<?php } ?>
{/loop}
</div>
</div>
<a href="cart-step2.php" role="button" class="btn btn-back"><span>Back</span></a>
<button type="submit" class="btn btn-checkout-next"><span>Next Step</span></button>
{/form_field}
<a href="{url path="/order/delivery"}" role="button" class="btn btn-back"><span>Back</span></a>
<button type="submit" class="btn btn-checkout-next"><span>TO REMOVE</span></button>
</form>
{/form}
</article>
@@ -196,8 +299,16 @@
{block name="javascript-initialization"}
<script type="text/javascript">
jQuery(function($cart) {
jQuery(function($order) {
$order('.js-change-invoice-address').on('click', 'a', function(e) {
e.preventDefault();
$order('.js-other-invoice-address').removeClass('hidden');
$order('.js-invoice-address-selector').removeClass('hidden');
$order('#js-invoice-address-default-selector').unbind().remove();
$order('.js-change-invoice-address').unbind().remove();
});
});
</script>
{/block}