Merge branch 'master' of github.com:thelia/thelia
This commit is contained in:
@@ -23,18 +23,23 @@
|
||||
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\AddressQuery;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\OrderProductAttributeCombination;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\OrderProduct;
|
||||
use Thelia\Model\OrderStatus;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
use Thelia\Model\OrderAddress;
|
||||
use Thelia\Model\OrderStatusQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -108,14 +113,18 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
/* use a copy to avoid errored reccord in session */
|
||||
$placedOrder = $sessionOrder->copy();
|
||||
$placedOrder->setDispatcher($this->getDispatcher());
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
$currency = $this->getSession()->getCurrency();
|
||||
$lang = $this->getSession()->getLang();
|
||||
$deliveryAddress = AddressQuery::create()->findPk($sessionOrder->chosenDeliveryAddress);
|
||||
$taxCountry = $deliveryAddress->getCountry();
|
||||
$invoiceAddress = AddressQuery::create()->findPk($sessionOrder->chosenInvoiceAddress);
|
||||
$cart = $this->getSession()->getCart();
|
||||
$cartItems = $cart->getCartItems();
|
||||
|
||||
$paymentModule = ModuleQuery::findPk($placedOrder->getPaymentModuleId());
|
||||
$paymentModule = ModuleQuery::create()->findPk($placedOrder->getPaymentModuleId());
|
||||
|
||||
/* fulfill order */
|
||||
$placedOrder->setCustomerId($customer->getId());
|
||||
@@ -163,24 +172,116 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$placedOrder->save($con);
|
||||
|
||||
/* fulfill order_products and decrease stock // @todo dispatch event */
|
||||
/* fulfill order_products and decrease stock */
|
||||
|
||||
foreach($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
|
||||
/* get translation */
|
||||
$productI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Product', $product->getId());
|
||||
|
||||
$pse = $cartItem->getProductSaleElements();
|
||||
|
||||
/* check still in stock */
|
||||
if($cartItem->getQuantity() > $pse->getQuantity()) {
|
||||
throw new TheliaProcessException("Not enough stock", TheliaProcessException::CART_ITEM_NOT_ENOUGH_STOCK, $cartItem);
|
||||
}
|
||||
|
||||
/* decrease stock */
|
||||
$pse->setQuantity(
|
||||
$pse->getQuantity() - $cartItem->getQuantity()
|
||||
);
|
||||
$pse->save($con);
|
||||
|
||||
/* get tax */
|
||||
$taxRuleI18n = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'TaxRule', $product->getTaxRuleId());
|
||||
|
||||
$taxDetail = $product->getTaxRule()->getTaxDetail(
|
||||
$taxCountry,
|
||||
$cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(),
|
||||
$this->getSession()->getLang()->getLocale()
|
||||
);
|
||||
|
||||
$orderProduct = new OrderProduct();
|
||||
$orderProduct
|
||||
->setOrderId($placedOrder->getId())
|
||||
->setProductRef($product->getRef())
|
||||
->setProductSaleElementsRef($pse->getRef())
|
||||
->setTitle($productI18n->getTitle())
|
||||
->setChapo($productI18n->getChapo())
|
||||
->setDescription($productI18n->getDescription())
|
||||
->setPostscriptum($productI18n->getPostscriptum())
|
||||
->setQuantity($cartItem->getQuantity())
|
||||
->setPrice($cartItem->getPrice())
|
||||
->setPromoPrice($cartItem->getPromoPrice())
|
||||
->setWasNew($pse->getNewness())
|
||||
->setWasInPromo($cartItem->getPromo())
|
||||
->setWeight($pse->getWeight())
|
||||
->setTaxRuleTitle($taxRuleI18n->getTitle())
|
||||
->setTaxRuleDescription($taxRuleI18n->getDescription())
|
||||
;
|
||||
$orderProduct->setDispatcher($this->getDispatcher());
|
||||
$orderProduct->save($con);
|
||||
|
||||
/* fulfill order_product_tax */
|
||||
foreach($taxDetail as $tax) {
|
||||
$tax->setOrderProductId($orderProduct->getId());
|
||||
$tax->save($con);
|
||||
}
|
||||
|
||||
/* fulfill order_attribute_combination and decrease stock */
|
||||
foreach($pse->getAttributeCombinations() as $attributeCombination) {
|
||||
$attribute = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'Attribute', $attributeCombination->getAttributeId());
|
||||
$attributeAv = I18n::forceI18nRetrieving($this->getSession()->getLang()->getLocale(), 'AttributeAv', $attributeCombination->getAttributeAvId());
|
||||
|
||||
$orderAttributeCombination = new OrderProductAttributeCombination();
|
||||
$orderAttributeCombination
|
||||
->setOrderProductId($orderProduct->getId())
|
||||
->setAttributeTitle($attribute->getTitle())
|
||||
->setAttributeChapo($attribute->getChapo())
|
||||
->setAttributeDescription($attribute->getDescription())
|
||||
->setAttributePostscriptumn($attribute->getPostscriptum())
|
||||
->setAttributeAvTitle($attributeAv->getTitle())
|
||||
->setAttributeAvChapo($attributeAv->getChapo())
|
||||
->setAttributeAvDescription($attributeAv->getDescription())
|
||||
->setAttributeAvPostscriptum($attributeAv->getPostscriptum())
|
||||
;
|
||||
|
||||
$orderAttributeCombination->save($con);
|
||||
}
|
||||
}
|
||||
|
||||
/* discount @todo */
|
||||
|
||||
$con->commit();
|
||||
|
||||
/* T1style : dispatch mail event ? */
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder));
|
||||
|
||||
/* clear session ? */
|
||||
/* clear session */
|
||||
/* but memorize placed order */
|
||||
$sessionOrder = new \Thelia\Model\Order();
|
||||
$event->setOrder($sessionOrder);
|
||||
$event->setPlacedOrder($placedOrder);
|
||||
$this->getSession()->setOrder($sessionOrder);
|
||||
|
||||
/* empty cart @todo */
|
||||
|
||||
/* call pay method */
|
||||
$paymentModuleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
$paymentModuleInstance = $paymentModuleReflection->newInstance();
|
||||
|
||||
$paymentModuleInstance->setRequest($this->request);
|
||||
$paymentModuleInstance->setDispatcher($this->dispatcher);
|
||||
$paymentModuleInstance->setRequest($this->getRequest());
|
||||
$paymentModuleInstance->setDispatcher($this->getDispatcher());
|
||||
|
||||
$paymentModuleInstance->pay();
|
||||
$paymentModuleInstance->pay($placedOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Core\Event\OrderEvent $event
|
||||
*/
|
||||
public function sendOrderEmail(OrderEvent $event)
|
||||
{
|
||||
/* @todo */
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,14 +289,13 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function setReference(OrderEvent $event)
|
||||
{
|
||||
$x = true;
|
||||
|
||||
$this->setRef($this->generateRef());
|
||||
$event->getOrder()->setRef($this->generateRef());
|
||||
}
|
||||
|
||||
public function generateRef()
|
||||
{
|
||||
return sprintf('O', uniqid('', true), $this->getId());
|
||||
/* order addresses are unique */
|
||||
return uniqid('ORD', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +326,8 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128),
|
||||
TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128),
|
||||
TheliaEvents::ORDER_PAY => array("create", 128),
|
||||
TheliaEvents::ORDER_SET_REFERENCE => array("setReference", 128),
|
||||
TheliaEvents::ORDER_BEFORE_CREATE => array("setReference", 128),
|
||||
TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureAvailability" name="feature-availability"/>
|
||||
<loop class="Thelia\Core\Template\Loop\FeatureValue" name="feature_value"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Folder" name="folder"/>
|
||||
<loop class="Thelia\Core\Template\Loop\Module" name="module"/>
|
||||
<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"/>
|
||||
|
||||
@@ -137,7 +137,11 @@
|
||||
|
||||
<route id="order.payment.process" path="/order/pay">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::pay</default>
|
||||
<default key="_view">order_payment</default>
|
||||
</route>
|
||||
|
||||
<route id="order.placed" path="/order/placed/{order_id}">
|
||||
<default key="_controller">Thelia\Controller\Front\OrderController::orderPlaced</default>
|
||||
<default key="_view">order_placed</default>
|
||||
</route>
|
||||
<!-- end order management process -->
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace Thelia\Controller\Front;
|
||||
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Controller\BaseController;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
class BaseFrontController extends BaseController
|
||||
@@ -69,7 +71,7 @@ class BaseFrontController extends BaseController
|
||||
protected function checkValidDelivery()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) {
|
||||
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId() || null === AddressQuery::create()->findPk($order->chosenDeliveryAddress) || null === ModuleQuery::create()->findPk($order->getDeliveryModuleId())) {
|
||||
$this->redirectToRoute("order.delivery");
|
||||
}
|
||||
}
|
||||
@@ -77,7 +79,7 @@ class BaseFrontController extends BaseController
|
||||
protected function checkValidInvoice()
|
||||
{
|
||||
$order = $this->getSession()->getOrder();
|
||||
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId()) {
|
||||
if(null === $order || null === $order->chosenInvoiceAddress || null === $order->getPaymentModuleId() || null === AddressQuery::create()->findPk($order->chosenInvoiceAddress) || null === ModuleQuery::create()->findPk($order->getPaymentModuleId())) {
|
||||
$this->redirectToRoute("order.invoice");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
namespace Thelia\Controller\Front;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Exception\TheliaProcessException;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -32,9 +33,11 @@ use Thelia\Form\OrderPayment;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\AreaDeliveryModuleQuery;
|
||||
use Thelia\Model\Base\OrderQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Model\Order;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class OrderController
|
||||
@@ -78,11 +81,8 @@ class OrderController extends BaseFrontController
|
||||
throw new \Exception("Delivery module cannot be use with selected delivery address");
|
||||
}
|
||||
|
||||
/* try to get postage amount */
|
||||
/* 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());
|
||||
|
||||
@@ -190,6 +190,36 @@ class OrderController extends BaseFrontController
|
||||
$orderEvent = $this->getOrderEvent();
|
||||
|
||||
$this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
|
||||
|
||||
$placedOrder = $orderEvent->getPlacedOrder();
|
||||
|
||||
if(null !== $placedOrder && null !== $placedOrder->getId()) {
|
||||
/* order has been placed */
|
||||
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId()))));
|
||||
} else {
|
||||
/* order has not been placed */
|
||||
$this->redirectToRoute("cart.view");
|
||||
}
|
||||
}
|
||||
|
||||
public function orderPlaced($order_id)
|
||||
{
|
||||
/* check if the placed order matched the customer */
|
||||
$placedOrder = OrderQuery::create()->findPk(
|
||||
$this->getRequest()->attributes->get('order_id')
|
||||
);
|
||||
|
||||
if(null === $placedOrder) {
|
||||
throw new TheliaProcessException("No placed order", TheliaProcessException::NO_PLACED_ORDER, $placedOrder);
|
||||
}
|
||||
|
||||
$customer = $this->getSecurityContext()->getCustomerUser();
|
||||
|
||||
if(null === $customer || $placedOrder->getCustomerId() !== $customer->getId()) {
|
||||
throw new TheliaProcessException("Received placed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder);
|
||||
}
|
||||
|
||||
$this->getParserContext()->set("placed_order_id", $placedOrder->getId());
|
||||
}
|
||||
|
||||
protected function getOrderEvent()
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Model\Order;
|
||||
class OrderEvent extends ActionEvent
|
||||
{
|
||||
protected $order = null;
|
||||
protected $placedOrder = null;
|
||||
protected $invoiceAddress = null;
|
||||
protected $deliveryAddress = null;
|
||||
protected $deliveryModule = null;
|
||||
@@ -51,6 +52,14 @@ class OrderEvent extends ActionEvent
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setPlacedOrder(Order $order)
|
||||
{
|
||||
$this->placedOrder = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
*/
|
||||
@@ -107,6 +116,14 @@ class OrderEvent extends ActionEvent
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getPlacedOrder()
|
||||
{
|
||||
return $this->placedOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
|
||||
@@ -257,7 +257,12 @@ final class TheliaEvents
|
||||
const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress";
|
||||
const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule";
|
||||
const ORDER_PAY = "action.order.pay";
|
||||
const ORDER_SET_REFERENCE = "action.order.setReference";
|
||||
const ORDER_BEFORE_CREATE = "action.order.beforeCreate";
|
||||
const ORDER_AFTER_CREATE = "action.order.afterCreate";
|
||||
const ORDER_BEFORE_PAYMENT = "action.order.beforePayment";
|
||||
|
||||
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
|
||||
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
|
||||
@@ -81,6 +81,8 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
|
||||
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
@@ -97,12 +99,8 @@ class Cart extends BaseLoop
|
||||
->set("STOCK", $productSaleElement->getQuantity())
|
||||
->set("PRICE", $cartItem->getPrice())
|
||||
->set("PROMO_PRICE", $cartItem->getPromoPrice())
|
||||
->set("TAXED_PRICE", $cartItem->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
))
|
||||
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
))
|
||||
->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))
|
||||
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))
|
||||
->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
|
||||
$result->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?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\ModuleQuery;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Module loop
|
||||
*
|
||||
*
|
||||
* Class Module
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Module extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
new Type\EnumListType(array(
|
||||
BaseModule::CLASSIC_MODULE_TYPE,
|
||||
BaseModule::DELIVERY_MODULE_TYPE,
|
||||
BaseModule::PAYMENT_MODULE_TYPE,
|
||||
))
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
$search->filterByType($moduleType, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$active = $this->getActive();
|
||||
|
||||
if($active !== Type\BooleanOrBothType::ANY) {
|
||||
$search->filterByActivate($active ? 1 : 0, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$modules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($modules);
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $module->getId())
|
||||
->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$module->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("CODE", $module->getCode())
|
||||
->set("TYPE", $module->getType())
|
||||
->set("ACTIVE", $module->getActivate())
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,16 @@
|
||||
|
||||
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\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\OrderQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
/**
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
*/
|
||||
class Order extends BaseLoop
|
||||
{
|
||||
public $countable = true;
|
||||
public $timestampable = true;
|
||||
public $versionable = false;
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
new Type\IntType(),
|
||||
new Type\EnumType(array('current'))
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createIntListTypeArgument('status')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// TODO : a coder !
|
||||
return new LoopResult();
|
||||
$search = OrderQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$customer = $this->getCustomer();
|
||||
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
} else {
|
||||
$search->filterByCustomerId($customer, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$status = $this->getStatus();
|
||||
|
||||
if (null !== $status) {
|
||||
$search->filterByStatusId($status, Criteria::IN);
|
||||
}
|
||||
|
||||
$orders = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($orders);
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$tax = 0;
|
||||
$amount = $order->getTotalAmount($tax);
|
||||
$loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow
|
||||
->set("ID", $order->getId())
|
||||
->set("REF", $order->getRef())
|
||||
->set("CUSTOMER", $order->getCustomerId())
|
||||
->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId())
|
||||
->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId())
|
||||
->set("INVOICE_DATE", $order->getInvoiceDate())
|
||||
->set("CURRENCY", $order->getCurrencyId())
|
||||
->set("CURRENCY_RATE", $order->getCurrencyRate())
|
||||
->set("TRANSACTION_REF", $order->getTransactionRef())
|
||||
->set("DELIVERY_REF", $order->getDeliveryRef())
|
||||
->set("INVOICE_REF", $order->getInvoiceRef())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("PAYMENT_MODULE", $order->getPaymentModuleId())
|
||||
->set("DELIVERY_MODULE", $order->getDeliveryModuleId())
|
||||
->set("STATUS", $order->getStatusId())
|
||||
->set("LANG", $order->getLangId())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("TOTAL_TAX", $tax)
|
||||
->set("TOTAL_AMOUNT", $amount - $tax)
|
||||
->set("TOTAL_TAXED_AMOUNT", $amount)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class TaxEngineException extends \RuntimeException
|
||||
const UNDEFINED_TAX_RULES_COLLECTION = 503;
|
||||
const UNDEFINED_REQUIREMENTS = 504;
|
||||
const UNDEFINED_REQUIREMENT_VALUE = 505;
|
||||
const UNDEFINED_TAX_RULE = 506;
|
||||
|
||||
const BAD_AMOUNT_FORMAT = 601;
|
||||
|
||||
|
||||
54
core/lib/Thelia/Exception/TheliaProcessException.php
Executable file
54
core/lib/Thelia/Exception/TheliaProcessException.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?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\Exception;
|
||||
|
||||
/**
|
||||
* these exception are non fatal exception, due to thelia process exception
|
||||
* or customer random navigation
|
||||
*
|
||||
* they redirect the customer who trig them to a specific error page // @todo
|
||||
*
|
||||
* Class TheliaProcessException
|
||||
* @package Thelia\Exception
|
||||
*/
|
||||
class TheliaProcessException extends \RuntimeException
|
||||
{
|
||||
public $data = null;
|
||||
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const CART_ITEM_NOT_ENOUGH_STOCK = 100;
|
||||
const NO_PLACED_ORDER = 101;
|
||||
const PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER = 102;
|
||||
|
||||
public function __construct($message, $code = null, $data = null, $previous = null)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
if ($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class OrderDelivery extends BaseForm
|
||||
->filterByType(BaseModule::DELIVERY_MODULE_TYPE)
|
||||
->filterByActivate(1)
|
||||
->filterById($value)
|
||||
->find();
|
||||
->findOne();
|
||||
|
||||
if(null === $module) {
|
||||
$context->addViolation("Delivery module ID not found");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,12 +24,19 @@ use Thelia\Model\Map\OrderProductTableMap;
|
||||
* @method ChildOrderProductQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildOrderProductQuery orderByOrderId($order = Criteria::ASC) Order by the order_id column
|
||||
* @method ChildOrderProductQuery orderByProductRef($order = Criteria::ASC) Order by the product_ref column
|
||||
* @method ChildOrderProductQuery orderByProductSaleElementsRef($order = Criteria::ASC) Order by the product_sale_elements_ref column
|
||||
* @method ChildOrderProductQuery orderByTitle($order = Criteria::ASC) Order by the title column
|
||||
* @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column
|
||||
* @method ChildOrderProductQuery orderByChapo($order = Criteria::ASC) Order by the chapo column
|
||||
* @method ChildOrderProductQuery orderByDescription($order = Criteria::ASC) Order by the description column
|
||||
* @method ChildOrderProductQuery orderByPostscriptum($order = Criteria::ASC) Order by the postscriptum column
|
||||
* @method ChildOrderProductQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
|
||||
* @method ChildOrderProductQuery orderByPrice($order = Criteria::ASC) Order by the price column
|
||||
* @method ChildOrderProductQuery orderByTax($order = Criteria::ASC) Order by the tax column
|
||||
* @method ChildOrderProductQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column
|
||||
* @method ChildOrderProductQuery orderByWasNew($order = Criteria::ASC) Order by the was_new column
|
||||
* @method ChildOrderProductQuery orderByWasInPromo($order = Criteria::ASC) Order by the was_in_promo column
|
||||
* @method ChildOrderProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column
|
||||
* @method ChildOrderProductQuery orderByTaxRuleTitle($order = Criteria::ASC) Order by the tax_rule_title column
|
||||
* @method ChildOrderProductQuery orderByTaxRuleDescription($order = Criteria::ASC) Order by the tax_rule_description column
|
||||
* @method ChildOrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column
|
||||
* @method ChildOrderProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildOrderProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
@@ -37,12 +44,19 @@ use Thelia\Model\Map\OrderProductTableMap;
|
||||
* @method ChildOrderProductQuery groupById() Group by the id column
|
||||
* @method ChildOrderProductQuery groupByOrderId() Group by the order_id column
|
||||
* @method ChildOrderProductQuery groupByProductRef() Group by the product_ref column
|
||||
* @method ChildOrderProductQuery groupByProductSaleElementsRef() Group by the product_sale_elements_ref column
|
||||
* @method ChildOrderProductQuery groupByTitle() Group by the title column
|
||||
* @method ChildOrderProductQuery groupByDescription() Group by the description column
|
||||
* @method ChildOrderProductQuery groupByChapo() Group by the chapo column
|
||||
* @method ChildOrderProductQuery groupByDescription() Group by the description column
|
||||
* @method ChildOrderProductQuery groupByPostscriptum() Group by the postscriptum column
|
||||
* @method ChildOrderProductQuery groupByQuantity() Group by the quantity column
|
||||
* @method ChildOrderProductQuery groupByPrice() Group by the price column
|
||||
* @method ChildOrderProductQuery groupByTax() Group by the tax column
|
||||
* @method ChildOrderProductQuery groupByPromoPrice() Group by the promo_price column
|
||||
* @method ChildOrderProductQuery groupByWasNew() Group by the was_new column
|
||||
* @method ChildOrderProductQuery groupByWasInPromo() Group by the was_in_promo column
|
||||
* @method ChildOrderProductQuery groupByWeight() Group by the weight column
|
||||
* @method ChildOrderProductQuery groupByTaxRuleTitle() Group by the tax_rule_title column
|
||||
* @method ChildOrderProductQuery groupByTaxRuleDescription() Group by the tax_rule_description column
|
||||
* @method ChildOrderProductQuery groupByParent() Group by the parent column
|
||||
* @method ChildOrderProductQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildOrderProductQuery groupByUpdatedAt() Group by the updated_at column
|
||||
@@ -55,9 +69,13 @@ use Thelia\Model\Map\OrderProductTableMap;
|
||||
* @method ChildOrderProductQuery rightJoinOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Order relation
|
||||
* @method ChildOrderProductQuery innerJoinOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the Order relation
|
||||
*
|
||||
* @method ChildOrderProductQuery leftJoinOrderFeature($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderFeature relation
|
||||
* @method ChildOrderProductQuery rightJoinOrderFeature($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderFeature relation
|
||||
* @method ChildOrderProductQuery innerJoinOrderFeature($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderFeature relation
|
||||
* @method ChildOrderProductQuery leftJoinOrderProductAttributeCombination($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductAttributeCombination relation
|
||||
* @method ChildOrderProductQuery rightJoinOrderProductAttributeCombination($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductAttributeCombination relation
|
||||
* @method ChildOrderProductQuery innerJoinOrderProductAttributeCombination($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductAttributeCombination relation
|
||||
*
|
||||
* @method ChildOrderProductQuery leftJoinOrderProductTax($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderProductTax relation
|
||||
* @method ChildOrderProductQuery rightJoinOrderProductTax($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProductTax relation
|
||||
* @method ChildOrderProductQuery innerJoinOrderProductTax($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProductTax relation
|
||||
*
|
||||
* @method ChildOrderProduct findOne(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query
|
||||
* @method ChildOrderProduct findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrderProduct matching the query, or a new ChildOrderProduct object populated from the query conditions when no match is found
|
||||
@@ -65,12 +83,19 @@ use Thelia\Model\Map\OrderProductTableMap;
|
||||
* @method ChildOrderProduct findOneById(int $id) Return the first ChildOrderProduct filtered by the id column
|
||||
* @method ChildOrderProduct findOneByOrderId(int $order_id) Return the first ChildOrderProduct filtered by the order_id column
|
||||
* @method ChildOrderProduct findOneByProductRef(string $product_ref) Return the first ChildOrderProduct filtered by the product_ref column
|
||||
* @method ChildOrderProduct findOneByProductSaleElementsRef(string $product_sale_elements_ref) Return the first ChildOrderProduct filtered by the product_sale_elements_ref column
|
||||
* @method ChildOrderProduct findOneByTitle(string $title) Return the first ChildOrderProduct filtered by the title column
|
||||
* @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column
|
||||
* @method ChildOrderProduct findOneByChapo(string $chapo) Return the first ChildOrderProduct filtered by the chapo column
|
||||
* @method ChildOrderProduct findOneByDescription(string $description) Return the first ChildOrderProduct filtered by the description column
|
||||
* @method ChildOrderProduct findOneByPostscriptum(string $postscriptum) Return the first ChildOrderProduct filtered by the postscriptum column
|
||||
* @method ChildOrderProduct findOneByQuantity(double $quantity) Return the first ChildOrderProduct filtered by the quantity column
|
||||
* @method ChildOrderProduct findOneByPrice(double $price) Return the first ChildOrderProduct filtered by the price column
|
||||
* @method ChildOrderProduct findOneByTax(double $tax) Return the first ChildOrderProduct filtered by the tax column
|
||||
* @method ChildOrderProduct findOneByPromoPrice(string $promo_price) Return the first ChildOrderProduct filtered by the promo_price column
|
||||
* @method ChildOrderProduct findOneByWasNew(int $was_new) Return the first ChildOrderProduct filtered by the was_new column
|
||||
* @method ChildOrderProduct findOneByWasInPromo(int $was_in_promo) Return the first ChildOrderProduct filtered by the was_in_promo column
|
||||
* @method ChildOrderProduct findOneByWeight(string $weight) Return the first ChildOrderProduct filtered by the weight column
|
||||
* @method ChildOrderProduct findOneByTaxRuleTitle(string $tax_rule_title) Return the first ChildOrderProduct filtered by the tax_rule_title column
|
||||
* @method ChildOrderProduct findOneByTaxRuleDescription(string $tax_rule_description) Return the first ChildOrderProduct filtered by the tax_rule_description column
|
||||
* @method ChildOrderProduct findOneByParent(int $parent) Return the first ChildOrderProduct filtered by the parent column
|
||||
* @method ChildOrderProduct findOneByCreatedAt(string $created_at) Return the first ChildOrderProduct filtered by the created_at column
|
||||
* @method ChildOrderProduct findOneByUpdatedAt(string $updated_at) Return the first ChildOrderProduct filtered by the updated_at column
|
||||
@@ -78,12 +103,19 @@ use Thelia\Model\Map\OrderProductTableMap;
|
||||
* @method array findById(int $id) Return ChildOrderProduct objects filtered by the id column
|
||||
* @method array findByOrderId(int $order_id) Return ChildOrderProduct objects filtered by the order_id column
|
||||
* @method array findByProductRef(string $product_ref) Return ChildOrderProduct objects filtered by the product_ref column
|
||||
* @method array findByProductSaleElementsRef(string $product_sale_elements_ref) Return ChildOrderProduct objects filtered by the product_sale_elements_ref column
|
||||
* @method array findByTitle(string $title) Return ChildOrderProduct objects filtered by the title column
|
||||
* @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column
|
||||
* @method array findByChapo(string $chapo) Return ChildOrderProduct objects filtered by the chapo column
|
||||
* @method array findByDescription(string $description) Return ChildOrderProduct objects filtered by the description column
|
||||
* @method array findByPostscriptum(string $postscriptum) Return ChildOrderProduct objects filtered by the postscriptum column
|
||||
* @method array findByQuantity(double $quantity) Return ChildOrderProduct objects filtered by the quantity column
|
||||
* @method array findByPrice(double $price) Return ChildOrderProduct objects filtered by the price column
|
||||
* @method array findByTax(double $tax) Return ChildOrderProduct objects filtered by the tax column
|
||||
* @method array findByPromoPrice(string $promo_price) Return ChildOrderProduct objects filtered by the promo_price column
|
||||
* @method array findByWasNew(int $was_new) Return ChildOrderProduct objects filtered by the was_new column
|
||||
* @method array findByWasInPromo(int $was_in_promo) Return ChildOrderProduct objects filtered by the was_in_promo column
|
||||
* @method array findByWeight(string $weight) Return ChildOrderProduct objects filtered by the weight column
|
||||
* @method array findByTaxRuleTitle(string $tax_rule_title) Return ChildOrderProduct objects filtered by the tax_rule_title column
|
||||
* @method array findByTaxRuleDescription(string $tax_rule_description) Return ChildOrderProduct objects filtered by the tax_rule_description column
|
||||
* @method array findByParent(int $parent) Return ChildOrderProduct objects filtered by the parent column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildOrderProduct objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildOrderProduct objects filtered by the updated_at column
|
||||
@@ -175,7 +207,7 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, TITLE, DESCRIPTION, CHAPO, QUANTITY, PRICE, TAX, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -377,6 +409,35 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(OrderProductTableMap::PRODUCT_REF, $productRef, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the product_sale_elements_ref column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByProductSaleElementsRef('fooValue'); // WHERE product_sale_elements_ref = 'fooValue'
|
||||
* $query->filterByProductSaleElementsRef('%fooValue%'); // WHERE product_sale_elements_ref LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $productSaleElementsRef The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByProductSaleElementsRef($productSaleElementsRef = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($productSaleElementsRef)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $productSaleElementsRef)) {
|
||||
$productSaleElementsRef = str_replace('*', '%', $productSaleElementsRef);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, $productSaleElementsRef, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the title column
|
||||
*
|
||||
@@ -406,6 +467,35 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(OrderProductTableMap::TITLE, $title, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the chapo column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
|
||||
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $chapo The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByChapo($chapo = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($chapo)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $chapo)) {
|
||||
$chapo = str_replace('*', '%', $chapo);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the description column
|
||||
*
|
||||
@@ -436,32 +526,32 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the chapo column
|
||||
* Filter the query on the postscriptum column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue'
|
||||
* $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%'
|
||||
* $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue'
|
||||
* $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $chapo The value to use as filter.
|
||||
* @param string $postscriptum The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByChapo($chapo = null, $comparison = null)
|
||||
public function filterByPostscriptum($postscriptum = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($chapo)) {
|
||||
if (is_array($postscriptum)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $chapo)) {
|
||||
$chapo = str_replace('*', '%', $chapo);
|
||||
} elseif (preg_match('/[\%\*]/', $postscriptum)) {
|
||||
$postscriptum = str_replace('*', '%', $postscriptum);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::CHAPO, $chapo, $comparison);
|
||||
return $this->addUsingAlias(OrderProductTableMap::POSTSCRIPTUM, $postscriptum, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,16 +637,45 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the tax column
|
||||
* Filter the query on the promo_price column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByTax(1234); // WHERE tax = 1234
|
||||
* $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34)
|
||||
* $query->filterByTax(array('min' => 12)); // WHERE tax > 12
|
||||
* $query->filterByPromoPrice('fooValue'); // WHERE promo_price = 'fooValue'
|
||||
* $query->filterByPromoPrice('%fooValue%'); // WHERE promo_price LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $tax The value to use as filter.
|
||||
* @param string $promoPrice The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByPromoPrice($promoPrice = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($promoPrice)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $promoPrice)) {
|
||||
$promoPrice = str_replace('*', '%', $promoPrice);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::PROMO_PRICE, $promoPrice, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the was_new column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByWasNew(1234); // WHERE was_new = 1234
|
||||
* $query->filterByWasNew(array(12, 34)); // WHERE was_new IN (12, 34)
|
||||
* $query->filterByWasNew(array('min' => 12)); // WHERE was_new > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $wasNew The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
@@ -564,16 +683,16 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByTax($tax = null, $comparison = null)
|
||||
public function filterByWasNew($wasNew = null, $comparison = null)
|
||||
{
|
||||
if (is_array($tax)) {
|
||||
if (is_array($wasNew)) {
|
||||
$useMinMax = false;
|
||||
if (isset($tax['min'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::TAX, $tax['min'], Criteria::GREATER_EQUAL);
|
||||
if (isset($wasNew['min'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($tax['max'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::TAX, $tax['max'], Criteria::LESS_EQUAL);
|
||||
if (isset($wasNew['max'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
@@ -584,7 +703,135 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::TAX, $tax, $comparison);
|
||||
return $this->addUsingAlias(OrderProductTableMap::WAS_NEW, $wasNew, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the was_in_promo column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByWasInPromo(1234); // WHERE was_in_promo = 1234
|
||||
* $query->filterByWasInPromo(array(12, 34)); // WHERE was_in_promo IN (12, 34)
|
||||
* $query->filterByWasInPromo(array('min' => 12)); // WHERE was_in_promo > 12
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $wasInPromo The value to use as filter.
|
||||
* Use scalar values for equality.
|
||||
* Use array values for in_array() equivalent.
|
||||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByWasInPromo($wasInPromo = null, $comparison = null)
|
||||
{
|
||||
if (is_array($wasInPromo)) {
|
||||
$useMinMax = false;
|
||||
if (isset($wasInPromo['min'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($wasInPromo['max'])) {
|
||||
$this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::WAS_IN_PROMO, $wasInPromo, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the weight column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByWeight('fooValue'); // WHERE weight = 'fooValue'
|
||||
* $query->filterByWeight('%fooValue%'); // WHERE weight LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $weight The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByWeight($weight = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($weight)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $weight)) {
|
||||
$weight = str_replace('*', '%', $weight);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the tax_rule_title column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByTaxRuleTitle('fooValue'); // WHERE tax_rule_title = 'fooValue'
|
||||
* $query->filterByTaxRuleTitle('%fooValue%'); // WHERE tax_rule_title LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $taxRuleTitle The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByTaxRuleTitle($taxRuleTitle = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($taxRuleTitle)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $taxRuleTitle)) {
|
||||
$taxRuleTitle = str_replace('*', '%', $taxRuleTitle);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_TITLE, $taxRuleTitle, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the tax_rule_description column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByTaxRuleDescription('fooValue'); // WHERE tax_rule_description = 'fooValue'
|
||||
* $query->filterByTaxRuleDescription('%fooValue%'); // WHERE tax_rule_description LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $taxRuleDescription The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByTaxRuleDescription($taxRuleDescription = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($taxRuleDescription)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $taxRuleDescription)) {
|
||||
$taxRuleDescription = str_replace('*', '%', $taxRuleDescription);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(OrderProductTableMap::TAX_RULE_DESCRIPTION, $taxRuleDescription, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -790,40 +1037,40 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderFeature object
|
||||
* Filter the query by a related \Thelia\Model\OrderProductAttributeCombination object
|
||||
*
|
||||
* @param \Thelia\Model\OrderFeature|ObjectCollection $orderFeature the related object to use as filter
|
||||
* @param \Thelia\Model\OrderProductAttributeCombination|ObjectCollection $orderProductAttributeCombination the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderFeature($orderFeature, $comparison = null)
|
||||
public function filterByOrderProductAttributeCombination($orderProductAttributeCombination, $comparison = null)
|
||||
{
|
||||
if ($orderFeature instanceof \Thelia\Model\OrderFeature) {
|
||||
if ($orderProductAttributeCombination instanceof \Thelia\Model\OrderProductAttributeCombination) {
|
||||
return $this
|
||||
->addUsingAlias(OrderProductTableMap::ID, $orderFeature->getOrderProductId(), $comparison);
|
||||
} elseif ($orderFeature instanceof ObjectCollection) {
|
||||
->addUsingAlias(OrderProductTableMap::ID, $orderProductAttributeCombination->getOrderProductId(), $comparison);
|
||||
} elseif ($orderProductAttributeCombination instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderFeatureQuery()
|
||||
->filterByPrimaryKeys($orderFeature->getPrimaryKeys())
|
||||
->useOrderProductAttributeCombinationQuery()
|
||||
->filterByPrimaryKeys($orderProductAttributeCombination->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderFeature() only accepts arguments of type \Thelia\Model\OrderFeature or Collection');
|
||||
throw new PropelException('filterByOrderProductAttributeCombination() only accepts arguments of type \Thelia\Model\OrderProductAttributeCombination or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderFeature relation
|
||||
* Adds a JOIN clause to the query using the OrderProductAttributeCombination relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function joinOrderProductAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderFeature');
|
||||
$relationMap = $tableMap->getRelation('OrderProductAttributeCombination');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
@@ -838,14 +1085,14 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderFeature');
|
||||
$this->addJoinObject($join, 'OrderProductAttributeCombination');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderFeature relation OrderFeature object
|
||||
* Use the OrderProductAttributeCombination relation OrderProductAttributeCombination object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
@@ -853,13 +1100,86 @@ abstract class OrderProductQuery extends ModelCriteria
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query
|
||||
* @return \Thelia\Model\OrderProductAttributeCombinationQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
public function useOrderProductAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderFeature($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery');
|
||||
->joinOrderProductAttributeCombination($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderProductAttributeCombination', '\Thelia\Model\OrderProductAttributeCombinationQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query by a related \Thelia\Model\OrderProductTax object
|
||||
*
|
||||
* @param \Thelia\Model\OrderProductTax|ObjectCollection $orderProductTax the related object to use as filter
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByOrderProductTax($orderProductTax, $comparison = null)
|
||||
{
|
||||
if ($orderProductTax instanceof \Thelia\Model\OrderProductTax) {
|
||||
return $this
|
||||
->addUsingAlias(OrderProductTableMap::ID, $orderProductTax->getOrderProductId(), $comparison);
|
||||
} elseif ($orderProductTax instanceof ObjectCollection) {
|
||||
return $this
|
||||
->useOrderProductTaxQuery()
|
||||
->filterByPrimaryKeys($orderProductTax->getPrimaryKeys())
|
||||
->endUse();
|
||||
} else {
|
||||
throw new PropelException('filterByOrderProductTax() only accepts arguments of type \Thelia\Model\OrderProductTax or Collection');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a JOIN clause to the query using the OrderProductTax relation
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return ChildOrderProductQuery The current query, for fluid interface
|
||||
*/
|
||||
public function joinOrderProductTax($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
$tableMap = $this->getTableMap();
|
||||
$relationMap = $tableMap->getRelation('OrderProductTax');
|
||||
|
||||
// create a ModelJoin object for this join
|
||||
$join = new ModelJoin();
|
||||
$join->setJoinType($joinType);
|
||||
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||
if ($previousJoin = $this->getPreviousJoin()) {
|
||||
$join->setPreviousJoin($previousJoin);
|
||||
}
|
||||
|
||||
// add the ModelJoin to the current object
|
||||
if ($relationAlias) {
|
||||
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||
$this->addJoinObject($join, $relationAlias);
|
||||
} else {
|
||||
$this->addJoinObject($join, 'OrderProductTax');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the OrderProductTax relation OrderProductTax object
|
||||
*
|
||||
* @see useQuery()
|
||||
*
|
||||
* @param string $relationAlias optional alias for the relation,
|
||||
* to be used as main alias in the secondary query
|
||||
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||
*
|
||||
* @return \Thelia\Model\OrderProductTaxQuery A secondary query class using the current class as primary query
|
||||
*/
|
||||
public function useOrderProductTaxQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
|
||||
{
|
||||
return $this
|
||||
->joinOrderProductTax($relationAlias, $joinType)
|
||||
->useQuery($relationAlias ? $relationAlias : 'OrderProductTax', '\Thelia\Model\OrderProductTaxQuery');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 12;
|
||||
const NUM_COLUMNS = 19;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 12;
|
||||
const NUM_HYDRATE_COLUMNS = 19;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -84,20 +84,30 @@ class OrderProductTableMap extends TableMap
|
||||
*/
|
||||
const PRODUCT_REF = 'order_product.PRODUCT_REF';
|
||||
|
||||
/**
|
||||
* the column name for the PRODUCT_SALE_ELEMENTS_REF field
|
||||
*/
|
||||
const PRODUCT_SALE_ELEMENTS_REF = 'order_product.PRODUCT_SALE_ELEMENTS_REF';
|
||||
|
||||
/**
|
||||
* the column name for the TITLE field
|
||||
*/
|
||||
const TITLE = 'order_product.TITLE';
|
||||
|
||||
/**
|
||||
* the column name for the CHAPO field
|
||||
*/
|
||||
const CHAPO = 'order_product.CHAPO';
|
||||
|
||||
/**
|
||||
* the column name for the DESCRIPTION field
|
||||
*/
|
||||
const DESCRIPTION = 'order_product.DESCRIPTION';
|
||||
|
||||
/**
|
||||
* the column name for the CHAPO field
|
||||
* the column name for the POSTSCRIPTUM field
|
||||
*/
|
||||
const CHAPO = 'order_product.CHAPO';
|
||||
const POSTSCRIPTUM = 'order_product.POSTSCRIPTUM';
|
||||
|
||||
/**
|
||||
* the column name for the QUANTITY field
|
||||
@@ -110,9 +120,34 @@ class OrderProductTableMap extends TableMap
|
||||
const PRICE = 'order_product.PRICE';
|
||||
|
||||
/**
|
||||
* the column name for the TAX field
|
||||
* the column name for the PROMO_PRICE field
|
||||
*/
|
||||
const TAX = 'order_product.TAX';
|
||||
const PROMO_PRICE = 'order_product.PROMO_PRICE';
|
||||
|
||||
/**
|
||||
* the column name for the WAS_NEW field
|
||||
*/
|
||||
const WAS_NEW = 'order_product.WAS_NEW';
|
||||
|
||||
/**
|
||||
* the column name for the WAS_IN_PROMO field
|
||||
*/
|
||||
const WAS_IN_PROMO = 'order_product.WAS_IN_PROMO';
|
||||
|
||||
/**
|
||||
* the column name for the WEIGHT field
|
||||
*/
|
||||
const WEIGHT = 'order_product.WEIGHT';
|
||||
|
||||
/**
|
||||
* the column name for the TAX_RULE_TITLE field
|
||||
*/
|
||||
const TAX_RULE_TITLE = 'order_product.TAX_RULE_TITLE';
|
||||
|
||||
/**
|
||||
* the column name for the TAX_RULE_DESCRIPTION field
|
||||
*/
|
||||
const TAX_RULE_DESCRIPTION = 'order_product.TAX_RULE_DESCRIPTION';
|
||||
|
||||
/**
|
||||
* the column name for the PARENT field
|
||||
@@ -141,12 +176,12 @@ class OrderProductTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::TITLE, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::CHAPO, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::TAX, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
|
||||
self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -156,12 +191,12 @@ class OrderProductTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ),
|
||||
self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::TITLE => 3, OrderProductTableMap::DESCRIPTION => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::QUANTITY => 6, OrderProductTableMap::PRICE => 7, OrderProductTableMap::TAX => 8, OrderProductTableMap::PARENT => 9, OrderProductTableMap::CREATED_AT => 10, OrderProductTableMap::UPDATED_AT => 11, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ),
|
||||
self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -182,13 +217,20 @@ class OrderProductTableMap extends TableMap
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null);
|
||||
$this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('PRODUCT_REF', 'ProductRef', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('PRODUCT_SALE_ELEMENTS_REF', 'ProductSaleElementsRef', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
|
||||
$this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
|
||||
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
|
||||
$this->addColumn('TAX', 'Tax', 'FLOAT', false, null, null);
|
||||
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'VARCHAR', false, 45, null);
|
||||
$this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null);
|
||||
$this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null);
|
||||
$this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null);
|
||||
$this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null);
|
||||
$this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
@@ -200,7 +242,8 @@ class OrderProductTableMap extends TableMap
|
||||
public function buildRelations()
|
||||
{
|
||||
$this->addRelation('Order', '\\Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT');
|
||||
$this->addRelation('OrderFeature', '\\Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures');
|
||||
$this->addRelation('OrderProductAttributeCombination', '\\Thelia\\Model\\OrderProductAttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductAttributeCombinations');
|
||||
$this->addRelation('OrderProductTax', '\\Thelia\\Model\\OrderProductTax', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderProductTaxes');
|
||||
} // buildRelations()
|
||||
|
||||
/**
|
||||
@@ -222,7 +265,8 @@ class OrderProductTableMap extends TableMap
|
||||
{
|
||||
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
|
||||
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||
OrderFeatureTableMap::clearInstancePool();
|
||||
OrderProductAttributeCombinationTableMap::clearInstancePool();
|
||||
OrderProductTaxTableMap::clearInstancePool();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,12 +410,19 @@ class OrderProductTableMap extends TableMap
|
||||
$criteria->addSelectColumn(OrderProductTableMap::ID);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::ORDER_ID);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::PRODUCT_REF);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::TITLE);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::CHAPO);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::DESCRIPTION);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::POSTSCRIPTUM);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::QUANTITY);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::PRICE);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::TAX);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::PROMO_PRICE);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::WAS_NEW);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::WEIGHT);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::PARENT);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(OrderProductTableMap::UPDATED_AT);
|
||||
@@ -379,12 +430,19 @@ class OrderProductTableMap extends TableMap
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.ORDER_ID');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_REF');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_SALE_ELEMENTS_REF');
|
||||
$criteria->addSelectColumn($alias . '.TITLE');
|
||||
$criteria->addSelectColumn($alias . '.DESCRIPTION');
|
||||
$criteria->addSelectColumn($alias . '.CHAPO');
|
||||
$criteria->addSelectColumn($alias . '.DESCRIPTION');
|
||||
$criteria->addSelectColumn($alias . '.POSTSCRIPTUM');
|
||||
$criteria->addSelectColumn($alias . '.QUANTITY');
|
||||
$criteria->addSelectColumn($alias . '.PRICE');
|
||||
$criteria->addSelectColumn($alias . '.TAX');
|
||||
$criteria->addSelectColumn($alias . '.PROMO_PRICE');
|
||||
$criteria->addSelectColumn($alias . '.WAS_NEW');
|
||||
$criteria->addSelectColumn($alias . '.WAS_IN_PROMO');
|
||||
$criteria->addSelectColumn($alias . '.WEIGHT');
|
||||
$criteria->addSelectColumn($alias . '.TAX_RULE_TITLE');
|
||||
$criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION');
|
||||
$criteria->addSelectColumn($alias . '.PARENT');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
|
||||
@@ -143,7 +143,7 @@ class TaxI18nTableMap extends TableMap
|
||||
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null);
|
||||
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
|
||||
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,7 +143,7 @@ class TaxRuleI18nTableMap extends TableMap
|
||||
$this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null);
|
||||
$this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US');
|
||||
$this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null);
|
||||
$this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null);
|
||||
} // initialize()
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\Order as BaseOrder;
|
||||
use Thelia\Model\Base\OrderProductTaxQuery;
|
||||
use Thelia\Model\Map\OrderProductTaxTableMap;
|
||||
use Thelia\Model\OrderProductQuery;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
use \PDO;
|
||||
|
||||
class Order extends BaseOrder
|
||||
{
|
||||
@@ -19,20 +26,209 @@ class Order extends BaseOrder
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_SET_REFERENCE, new OrderEvent($this));
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_BEFORE_CREATE, new OrderEvent($this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* calculate the total amount
|
||||
*
|
||||
* @TODO create body method
|
||||
* @param int $tax
|
||||
*
|
||||
* @return int
|
||||
* @return int|string|Base\double
|
||||
*/
|
||||
public function getTotalAmount()
|
||||
public function getTotalAmount(&$tax = 0)
|
||||
{
|
||||
return 2;
|
||||
$amount = 0;
|
||||
$tax = 0;
|
||||
|
||||
/* browse all products */
|
||||
$orderProductIds = array();
|
||||
foreach($this->getOrderProducts() as $orderProduct) {
|
||||
$taxAmount = OrderProductTaxQuery::create()
|
||||
->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax')
|
||||
->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL)
|
||||
->findOne();
|
||||
$amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity();
|
||||
$tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity();
|
||||
}
|
||||
|
||||
return $amount + $tax + $this->getPostage(); // @todo : manage discount
|
||||
}
|
||||
|
||||
/**
|
||||
* PROPEL SHOULD FIX IT
|
||||
*
|
||||
* Insert the row in the database.
|
||||
*
|
||||
* @param ConnectionInterface $con
|
||||
*
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
protected function doInsert(ConnectionInterface $con)
|
||||
{
|
||||
$modifiedColumns = array();
|
||||
$index = 0;
|
||||
|
||||
$this->modifiedColumns[] = OrderTableMap::ID;
|
||||
if (null !== $this->id) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')');
|
||||
}
|
||||
|
||||
// check the columns in natural order for more readable SQL queries
|
||||
if ($this->isColumnModified(OrderTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::REF)) {
|
||||
$modifiedColumns[':p' . $index++] = 'REF';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'INVOICE_DATE';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CURRENCY_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CURRENCY_RATE';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) {
|
||||
$modifiedColumns[':p' . $index++] = 'TRANSACTION_REF';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) {
|
||||
$modifiedColumns[':p' . $index++] = 'DELIVERY_REF';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) {
|
||||
$modifiedColumns[':p' . $index++] = 'INVOICE_REF';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::POSTAGE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'POSTAGE';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::STATUS_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'STATUS_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::LANG_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'LANG_ID';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
}
|
||||
if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||
}
|
||||
|
||||
$db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME);
|
||||
|
||||
if ($db->useQuoteIdentifier()) {
|
||||
$tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME);
|
||||
} else {
|
||||
$tableName = OrderTableMap::TABLE_NAME;
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'INSERT INTO %s (%s) VALUES (%s)',
|
||||
$tableName,
|
||||
implode(', ', $modifiedColumns),
|
||||
implode(', ', array_keys($modifiedColumns))
|
||||
);
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
foreach ($modifiedColumns as $identifier => $columnName) {
|
||||
switch ($columnName) {
|
||||
case 'ID':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'REF':
|
||||
$stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CUSTOMER_ID':
|
||||
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'INVOICE_ORDER_ADDRESS_ID':
|
||||
$stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'DELIVERY_ORDER_ADDRESS_ID':
|
||||
$stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'INVOICE_DATE':
|
||||
$stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'CURRENCY_ID':
|
||||
$stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'CURRENCY_RATE':
|
||||
$stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'TRANSACTION_REF':
|
||||
$stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'DELIVERY_REF':
|
||||
$stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'INVOICE_REF':
|
||||
$stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'POSTAGE':
|
||||
$stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'PAYMENT_MODULE_ID':
|
||||
$stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'DELIVERY_MODULE_ID':
|
||||
$stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'STATUS_ID':
|
||||
$stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'LANG_ID':
|
||||
$stmt->bindValue($identifier, $this->lang_id, 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;
|
||||
case 'UPDATED_AT':
|
||||
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$stmt->execute();
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
|
||||
try {
|
||||
$pk = $con->lastInsertId();
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException('Unable to get autoincrement id.', 0, $e);
|
||||
}
|
||||
$this->setId($pk);
|
||||
|
||||
$this->setNew(false);
|
||||
}
|
||||
}
|
||||
|
||||
24
core/lib/Thelia/Model/OrderProduct.php
Executable file → Normal file
24
core/lib/Thelia/Model/OrderProduct.php
Executable file → Normal file
@@ -2,8 +2,30 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\OrderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Base\OrderProduct as BaseOrderProduct;
|
||||
|
||||
class OrderProduct extends BaseOrderProduct {
|
||||
class OrderProduct extends BaseOrderProduct
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_BEFORE_CREATE, new OrderEvent($this->getOrder()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function postInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->dispatchEvent(TheliaEvents::ORDER_PRODUCT_AFTER_CREATE, new OrderEvent($this->getOrder()));
|
||||
}
|
||||
}
|
||||
|
||||
3
core/lib/Thelia/Model/OrderProductQuery.php
Executable file → Normal file
3
core/lib/Thelia/Model/OrderProductQuery.php
Executable file → Normal file
@@ -15,6 +15,7 @@ use Thelia\Model\Base\OrderProductQuery as BaseOrderProductQuery;
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class OrderProductQuery extends BaseOrderProductQuery {
|
||||
class OrderProductQuery extends BaseOrderProductQuery
|
||||
{
|
||||
|
||||
} // OrderProductQuery
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Base\OrderQuery as BaseOrderQuery;
|
||||
|
||||
use \PDO;
|
||||
use Thelia\Model\Map\OrderTableMap;
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'order' table.
|
||||
@@ -15,6 +18,38 @@ use Thelia\Model\Base\OrderQuery as BaseOrderQuery;
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
*/
|
||||
class OrderQuery extends BaseOrderQuery {
|
||||
class OrderQuery extends BaseOrderQuery
|
||||
{
|
||||
/**
|
||||
* PROPEL SHOULD FIX IT
|
||||
*
|
||||
* Find object by primary key using raw SQL to go fast.
|
||||
* Bypass doSelect() and the object formatter by using generated code.
|
||||
*
|
||||
* @param mixed $key Primary key to use for the query
|
||||
* @param ConnectionInterface $con A connection object
|
||||
*
|
||||
* @return Order A model object, or null if the key is not found
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM `order` WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
} catch (\Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
$obj = null;
|
||||
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
|
||||
$obj = new Order();
|
||||
$obj->hydrate($row);
|
||||
OrderTableMap::addInstanceToPool($obj, (string) $key);
|
||||
}
|
||||
$stmt->closeCursor();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
} // OrderQuery
|
||||
|
||||
@@ -3,7 +3,25 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\TaxRule as BaseTaxRule;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
use Thelia\TaxEngine\OrderProductTaxCollection;
|
||||
|
||||
class TaxRule extends BaseTaxRule {
|
||||
class TaxRule extends BaseTaxRule
|
||||
{
|
||||
/**
|
||||
* @param Country $country
|
||||
* @param $untaxedAmount
|
||||
* @param null $askedLocale
|
||||
*
|
||||
* @return OrderProductTaxCollection
|
||||
*/
|
||||
public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null)
|
||||
{
|
||||
$taxCalculator = new Calculator();
|
||||
|
||||
$taxCollection = new OrderProductTaxCollection();
|
||||
$taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale);
|
||||
|
||||
return $taxCollection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,19 @@ class TaxRuleQuery extends BaseTaxRuleQuery
|
||||
{
|
||||
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
|
||||
|
||||
public function getTaxCalculatorCollection(Product $product, Country $country)
|
||||
/**
|
||||
* @param TaxRule $taxRule
|
||||
* @param Country $country
|
||||
*
|
||||
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
|
||||
*/
|
||||
public function getTaxCalculatorCollection(TaxRule $taxRule, Country $country)
|
||||
{
|
||||
$search = TaxQuery::create()
|
||||
->filterByTaxRuleCountry(
|
||||
TaxRuleCountryQuery::create()
|
||||
->filterByCountry($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($product->getTaxRuleId())
|
||||
->filterByTaxRuleId($taxRule->getId())
|
||||
->orderByPosition()
|
||||
->find()
|
||||
)
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
namespace Thelia\Module;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Thelia\Model\ModuleI18nQuery;
|
||||
use Thelia\Model\Map\ModuleImageTableMap;
|
||||
use Thelia\Model\ModuleI18n;
|
||||
use Thelia\Tools\Image;
|
||||
use Thelia\Exception\ModuleException;
|
||||
use Thelia\Model\Module;
|
||||
@@ -76,6 +78,27 @@ abstract class BaseModule extends ContainerAware
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
public function setTitle(Module $module, $titles)
|
||||
{
|
||||
if(is_array($titles)) {
|
||||
foreach($titles as $locale => $title) {
|
||||
$moduleI18n = ModuleI18nQuery::create()->filterById($module->getId())->filterByLocale($locale)->findOne();
|
||||
if(null === $moduleI18n) {
|
||||
$moduleI18n = new ModuleI18n();
|
||||
$moduleI18n
|
||||
->setId($module->getId())
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
;
|
||||
$moduleI18n->save();
|
||||
} else {
|
||||
$moduleI18n->setTitle($title);
|
||||
$moduleI18n->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deployImageFolder(Module $module, $folderPath)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -24,8 +24,11 @@ namespace Thelia\TaxEngine;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Country;
|
||||
use Thelia\Model\OrderProductTax;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Model\TaxRule;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
|
||||
/**
|
||||
* Class Calculator
|
||||
@@ -68,14 +71,34 @@ class Calculator
|
||||
$this->product = $product;
|
||||
$this->country = $country;
|
||||
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country);
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product->getTaxRule(), $country);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxAmountFromUntaxedPrice($untaxedPrice)
|
||||
public function loadTaxRule(TaxRule $taxRule, Country $country)
|
||||
{
|
||||
return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice;
|
||||
$this->product = null;
|
||||
$this->country = null;
|
||||
$this->taxRulesCollection = null;
|
||||
|
||||
if($taxRule->getId() === null) {
|
||||
throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
|
||||
}
|
||||
if($country->getId() === null) {
|
||||
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
|
||||
}
|
||||
|
||||
$this->country = $country;
|
||||
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null)
|
||||
{
|
||||
return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice;
|
||||
}
|
||||
|
||||
public function getTaxAmountFromTaxedPrice($taxedPrice)
|
||||
@@ -83,7 +106,15 @@ class Calculator
|
||||
return $taxedPrice - $this->getUntaxedPrice($taxedPrice);
|
||||
}
|
||||
|
||||
public function getTaxedPrice($untaxedPrice)
|
||||
/**
|
||||
* @param $untaxedPrice
|
||||
* @param null $taxCollection returns OrderProductTaxCollection
|
||||
* @param null $askedLocale
|
||||
*
|
||||
* @return int
|
||||
* @throws \Thelia\Exception\TaxEngineException
|
||||
*/
|
||||
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);
|
||||
@@ -97,6 +128,9 @@ class Calculator
|
||||
$currentPosition = 1;
|
||||
$currentTax = 0;
|
||||
|
||||
if(null !== $taxCollection) {
|
||||
$taxCollection = new OrderProductTaxCollection();
|
||||
}
|
||||
foreach($this->taxRulesCollection as $taxRule) {
|
||||
$position = (int)$taxRule->getTaxRuleCountryPosition();
|
||||
|
||||
@@ -109,7 +143,17 @@ class Calculator
|
||||
$currentPosition = $position;
|
||||
}
|
||||
|
||||
$currentTax += $taxType->calculate($taxedPrice);
|
||||
$taxAmount = round($taxType->calculate($taxedPrice), 2);
|
||||
$currentTax += $taxAmount;
|
||||
|
||||
if(null !== $taxCollection) {
|
||||
$taxI18n = I18n::forceI18nRetrieving($askedLocale, 'Tax', $taxRule->getId());
|
||||
$orderProductTax = new OrderProductTax();
|
||||
$orderProductTax->setTitle($taxI18n->getTitle());
|
||||
$orderProductTax->setDescription($taxI18n->getDescription());
|
||||
$orderProductTax->setAmount($taxAmount);
|
||||
$taxCollection->addTax($orderProductTax);
|
||||
}
|
||||
}
|
||||
|
||||
$taxedPrice += $currentTax;
|
||||
|
||||
126
core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php
Executable file
126
core/lib/Thelia/TaxEngine/OrderProductTaxCollection.php
Executable file
@@ -0,0 +1,126 @@
|
||||
<?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;
|
||||
|
||||
use Thelia\Model\OrderProductTax;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class OrderProductTaxCollection implements \Iterator
|
||||
{
|
||||
private $position;
|
||||
protected $taxes = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
foreach (func_get_args() as $tax) {
|
||||
$this->addTax($tax);
|
||||
}
|
||||
}
|
||||
|
||||
public function isEmpty()
|
||||
{
|
||||
return count($this->taxes) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OrderProductTax $tax
|
||||
*
|
||||
* @return OrderProductTaxCollection
|
||||
*/
|
||||
public function addTax(OrderProductTax $tax)
|
||||
{
|
||||
$this->taxes[] = $tax;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCount()
|
||||
{
|
||||
return count($this->taxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Return the current element
|
||||
* @link http://php.net/manual/en/iterator.current.php
|
||||
* @return OrderProductTax
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->taxes[$this->position];
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Move forward to next element
|
||||
* @link http://php.net/manual/en/iterator.next.php
|
||||
* @return void Any returned value is ignored.
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->position++;
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Return the key of the current element
|
||||
* @link http://php.net/manual/en/iterator.key.php
|
||||
* @return mixed scalar on success, or null on failure.
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Checks if current position is valid
|
||||
* @link http://php.net/manual/en/iterator.valid.php
|
||||
* @return boolean The return value will be casted to boolean and then evaluated.
|
||||
* Returns true on success or false on failure.
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return isset($this->taxes[$this->position]);
|
||||
}
|
||||
|
||||
/**
|
||||
* (PHP 5 >= 5.0.0)<br/>
|
||||
* Rewind the Iterator to the first element
|
||||
* @link http://php.net/manual/en/iterator.rewind.php
|
||||
* @return void Any returned value is ignored.
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
|
||||
public function getKey($key)
|
||||
{
|
||||
return isset($this->taxes[$key]) ? $this->taxes[$key] : null;
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
$taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection'));
|
||||
$taxRuleQuery->expects($this->once())
|
||||
->method('getTaxCalculatorCollection')
|
||||
->with($productQuery, $countryQuery)
|
||||
->with($productQuery->getTaxRule(), $countryQuery)
|
||||
->will($this->returnValue('foo'));
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRuleQuery');
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
namespace Thelia\Tools;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
|
||||
use Thelia\Model\Lang;
|
||||
|
||||
/**
|
||||
@@ -54,4 +56,39 @@ class I18n
|
||||
|
||||
return \DateTime::createFromFormat($currentDateFormat, $date);
|
||||
}
|
||||
|
||||
public static function forceI18nRetrieving($askedLocale, $modelName, $id, $needed = array('Title'))
|
||||
{
|
||||
$i18nQueryClass = sprintf("\\Thelia\\Model\\%sI18nQuery", $modelName);
|
||||
$i18nClass = sprintf("\\Thelia\\Model\\%sI18n", $modelName);
|
||||
|
||||
/* get customer language translation */
|
||||
$i18n = $i18nQueryClass::create()
|
||||
->filterById($id)
|
||||
->filterByLocale(
|
||||
$askedLocale
|
||||
)->findOne();
|
||||
/* or default translation */
|
||||
if(null === $i18n) {
|
||||
$i18n = $i18nQueryClass::create()
|
||||
->filterById($id)
|
||||
->filterByLocale(
|
||||
Lang::getDefaultLanguage()->getLocale()
|
||||
)->findOne();
|
||||
}
|
||||
if(null === $i18n) { // @todo something else ?
|
||||
$i18n = new $i18nClass();;
|
||||
$i18n->setId($id);
|
||||
foreach($needed as $need) {
|
||||
$method = sprintf('set%s', $need);
|
||||
if(method_exists($i18n, $method)) {
|
||||
$i18n->$method('DEFAULT ' . strtoupper($need));
|
||||
} else {
|
||||
// @todo throw sg ?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $i18n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1153,7 +1153,7 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda
|
||||
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
(1, 'fr_FR', 'TVA française à 19.6%'),
|
||||
(1, 'en_UK', 'french 19.6% tax');
|
||||
(1, 'en_US', 'french 19.6% tax');
|
||||
|
||||
INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
@@ -1162,7 +1162,7 @@ INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`)
|
||||
INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
(1, 'fr_FR', 'TVA française à 19.6%'),
|
||||
(1, 'en_UK', 'french 19.6% tax');
|
||||
(1, 'en_US', 'french 19.6% tax');
|
||||
|
||||
INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
|
||||
@@ -760,14 +760,21 @@ CREATE TABLE `order_product`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`order_id` INTEGER NOT NULL,
|
||||
`product_ref` VARCHAR(255),
|
||||
`product_ref` VARCHAR(255) NOT NULL,
|
||||
`product_sale_elements_ref` VARCHAR(255) NOT NULL,
|
||||
`title` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`chapo` TEXT,
|
||||
`description` LONGTEXT,
|
||||
`postscriptum` TEXT,
|
||||
`quantity` FLOAT NOT NULL,
|
||||
`price` FLOAT NOT NULL,
|
||||
`tax` FLOAT,
|
||||
`parent` INTEGER,
|
||||
`promo_price` VARCHAR(45),
|
||||
`was_new` TINYINT NOT NULL,
|
||||
`was_in_promo` TINYINT NOT NULL,
|
||||
`weight` VARCHAR(45),
|
||||
`tax_rule_title` VARCHAR(255),
|
||||
`tax_rule_description` LONGTEXT,
|
||||
`parent` INTEGER COMMENT 'not managed yet',
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
@@ -796,22 +803,28 @@ CREATE TABLE `order_status`
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- order_feature
|
||||
-- order_product_attribute_combination
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `order_feature`;
|
||||
DROP TABLE IF EXISTS `order_product_attribute_combination`;
|
||||
|
||||
CREATE TABLE `order_feature`
|
||||
CREATE TABLE `order_product_attribute_combination`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`order_product_id` INTEGER NOT NULL,
|
||||
`feature_desc` VARCHAR(255),
|
||||
`feature_av_desc` VARCHAR(255),
|
||||
`attribute_title` VARCHAR(255) NOT NULL,
|
||||
`attribute_chapo` TEXT,
|
||||
`attribute_description` LONGTEXT,
|
||||
`attribute_postscriptumn` TEXT,
|
||||
`attribute_av_title` VARCHAR(255) NOT NULL,
|
||||
`attribute_av_chapo` TEXT,
|
||||
`attribute_av_description` LONGTEXT,
|
||||
`attribute_av_postscriptum` TEXT,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_order_feature_order_product_id` (`order_product_id`),
|
||||
CONSTRAINT `fk_order_feature_order_product_id`
|
||||
INDEX `idx_order_product_attribute_combination_order_product_id` (`order_product_id`),
|
||||
CONSTRAINT `fk_order_product_attribute_combination_order_product_id`
|
||||
FOREIGN KEY (`order_product_id`)
|
||||
REFERENCES `order_product` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
@@ -1560,6 +1573,30 @@ CREATE TABLE `module_image`
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- order_product_tax
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `order_product_tax`;
|
||||
|
||||
CREATE TABLE `order_product_tax`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`order_product_id` INTEGER NOT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`description` LONGTEXT,
|
||||
`amount` FLOAT NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_ order_product_tax_order_product_id` (`order_product_id`),
|
||||
CONSTRAINT `fk_ order_product_tax_order_product_id0`
|
||||
FOREIGN KEY (`order_product_id`)
|
||||
REFERENCES `order_product` (`id`)
|
||||
ON UPDATE RESTRICT
|
||||
ON DELETE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- category_i18n
|
||||
-- ---------------------------------------------------------------------
|
||||
@@ -1634,7 +1671,7 @@ CREATE TABLE `tax_i18n`
|
||||
`id` INTEGER NOT NULL,
|
||||
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
|
||||
`title` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`description` LONGTEXT,
|
||||
PRIMARY KEY (`id`,`locale`),
|
||||
CONSTRAINT `tax_i18n_FK_1`
|
||||
FOREIGN KEY (`id`)
|
||||
@@ -1653,7 +1690,7 @@ CREATE TABLE `tax_rule_i18n`
|
||||
`id` INTEGER NOT NULL,
|
||||
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
|
||||
`title` VARCHAR(255),
|
||||
`description` TEXT,
|
||||
`description` LONGTEXT,
|
||||
PRIMARY KEY (`id`,`locale`),
|
||||
CONSTRAINT `tax_rule_i18n_FK_1`
|
||||
FOREIGN KEY (`id`)
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<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="CLOB" />
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title, description" />
|
||||
@@ -110,7 +110,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 name="description" type="CLOB" />
|
||||
<column defaultValue="0" name="is_default" required="true" type="BOOLEAN" />
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n">
|
||||
@@ -595,14 +595,21 @@
|
||||
<table name="order_product" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="order_id" required="true" type="INTEGER" />
|
||||
<column name="product_ref" size="255" type="VARCHAR" />
|
||||
<column name="product_ref" required="true" size="255" type="VARCHAR" />
|
||||
<column name="product_sale_elements_ref" required="true" size="255" type="VARCHAR" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="LONGVARCHAR" />
|
||||
<column name="chapo" type="LONGVARCHAR" />
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="postscriptum" type="LONGVARCHAR" />
|
||||
<column name="quantity" required="true" type="FLOAT" />
|
||||
<column name="price" required="true" type="FLOAT" />
|
||||
<column name="tax" type="FLOAT" />
|
||||
<column name="parent" type="INTEGER" />
|
||||
<column name="promo_price" size="45" type="VARCHAR" />
|
||||
<column name="was_new" required="true" type="TINYINT" />
|
||||
<column name="was_in_promo" required="true" type="TINYINT" />
|
||||
<column name="weight" size="45" type="VARCHAR" />
|
||||
<column name="tax_rule_title" size="255" type="VARCHAR" />
|
||||
<column name="tax_rule_description" type="CLOB" />
|
||||
<column description="not managed yet" name="parent" type="INTEGER" />
|
||||
<foreign-key foreignTable="order" name="fk_order_product_order_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="order_id" />
|
||||
</foreign-key>
|
||||
@@ -626,15 +633,21 @@
|
||||
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
|
||||
</behavior>
|
||||
</table>
|
||||
<table name="order_feature" namespace="Thelia\Model">
|
||||
<table name="order_product_attribute_combination" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="order_product_id" required="true" type="INTEGER" />
|
||||
<column name="feature_desc" size="255" type="VARCHAR" />
|
||||
<column name="feature_av_desc" size="255" type="VARCHAR" />
|
||||
<foreign-key foreignTable="order_product" name="fk_order_feature_order_product_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<column name="attribute_title" required="true" size="255" type="VARCHAR" />
|
||||
<column name="attribute_chapo" type="LONGVARCHAR" />
|
||||
<column name="attribute_description" type="CLOB" />
|
||||
<column name="attribute_postscriptumn" type="LONGVARCHAR" />
|
||||
<column name="attribute_av_title" required="true" size="255" type="VARCHAR" />
|
||||
<column name="attribute_av_chapo" type="LONGVARCHAR" />
|
||||
<column name="attribute_av_description" type="CLOB" />
|
||||
<column name="attribute_av_postscriptum" type="LONGVARCHAR" />
|
||||
<foreign-key foreignTable="order_product" name="fk_order_product_attribute_combination_order_product_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="order_product_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_order_feature_order_product_id">
|
||||
<index name="idx_order_product_attribute_combination_order_product_id">
|
||||
<index-column name="order_product_id" />
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
@@ -1224,4 +1237,18 @@
|
||||
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
|
||||
</behavior>
|
||||
</table>
|
||||
<table name="order_product_tax" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="order_product_id" required="true" type="INTEGER" />
|
||||
<column name="title" required="true" size="255" type="VARCHAR" />
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="amount" required="true" type="FLOAT" />
|
||||
<foreign-key foreignTable="order_product" name="fk_ order_product_tax_order_product_id0" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="order_product_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_ order_product_tax_order_product_id">
|
||||
<index-column name="order_product_id" />
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
</database>
|
||||
|
||||
@@ -71,6 +71,15 @@ class Cheque extends BaseModule implements PaymentModuleInterface
|
||||
if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
|
||||
$this->deployImageFolder($module, sprintf('%s/images', __DIR__));
|
||||
}
|
||||
|
||||
/* set module title */
|
||||
$this->setTitle(
|
||||
$module,
|
||||
array(
|
||||
"en_US" => "Cheque",
|
||||
"fr_FR" => "Cheque",
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
|
||||
@@ -71,6 +71,15 @@ class FakeCB extends BaseModule implements PaymentModuleInterface
|
||||
if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) {
|
||||
$this->deployImageFolder($module, sprintf('%s/images', __DIR__));
|
||||
}
|
||||
|
||||
/* set module title */
|
||||
$this->setTitle(
|
||||
$module,
|
||||
array(
|
||||
"en_US" => "Credit Card",
|
||||
"fr_FR" => "Carte de crédit",
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
|
||||
@@ -24,26 +24,30 @@
|
||||
<a href="cart-step4.php" role="button" class="btn btn-step active"><span class="step-nb">4</span> <span class="step-label">Secure payment</span></a>
|
||||
</div>
|
||||
|
||||
{loop type="order" name="placed-order" id=$placed_order_id}
|
||||
|
||||
<div id="payment-success" class="panel">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">You chose to pay by : <span class="payment-method">Cheque</span></h3>
|
||||
<h3 class="panel-title">You chose to pay by : <span class="payment-method">{loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}</span></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h3>Thank you for the trust you place in us.</h3>
|
||||
<p>A summary of your order email has been sent to the following address: email@toto.com</p>
|
||||
<p>A summary of your order email has been sent to the following address: {customer attr="email"}</p>
|
||||
<p>Your order will be confirmed by us upon receipt of your payment.</p>
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Order number : </dt>
|
||||
<dd>PRO123456788978979</dd>
|
||||
<dd>{$REF}</dd>
|
||||
<dt>Date : </dt>
|
||||
<dd>02/12/2013</dd>
|
||||
<dd>{format_date date=$CREATE_DATE output="date"}</dd>
|
||||
<dt>Total : </dt>
|
||||
<dd>$216.25</dd>
|
||||
<dd>{loop type="currency" name="order-currency" id=$CURRENCY}{$SYMBOL}{/loop} {$TOTAL_TAXED_AMOUNT}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/loop}
|
||||
|
||||
<a href="{navigate to="index"}" role="button" class="btn btn-checkout-home"><span>Go home</span></a>
|
||||
|
||||
</article>
|
||||
Reference in New Issue
Block a user