diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index a34f4a85e..64254d734 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -36,6 +36,10 @@ use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\CategoryAssociatedContentQuery; class Category extends BaseAction implements EventSubscriberInterface { @@ -147,6 +151,33 @@ class Category extends BaseAction implements EventSubscriberInterface } } + public function addContent(CategoryAddContentEvent $event) { + + if (CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->count() <= 0) { + + $content = new CategoryAssociatedContent(); + + $content + ->setCategory($event->getCategory()) + ->setContentId($event->getContentId()) + ->save() + ; + } + } + + public function removeContent(CategoryDeleteContentEvent $event) { + + $content = CategoryAssociatedContentQuery::create() + ->filterByContentId($event->getContentId()) + ->filterByCategory($event->getCategory())->findOne() + ; + + if ($content !== null) $content->delete(); + } + + /** * {@inheritDoc} */ @@ -157,7 +188,12 @@ class Category extends BaseAction implements EventSubscriberInterface TheliaEvents::CATEGORY_UPDATE => array("update", 128), TheliaEvents::CATEGORY_DELETE => array("delete", 128), TheliaEvents::CATEGORY_TOGGLE_VISIBILITY => array("toggleVisibility", 128), - TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128) + + TheliaEvents::CATEGORY_UPDATE_POSITION => array("updatePosition", 128), + + TheliaEvents::CATEGORY_ADD_CONTENT => array("addContent", 128), + TheliaEvents::CATEGORY_REMOVE_CONTENT => array("removeContent", 128), + ); } } diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php new file mode 100755 index 000000000..a0d98265e --- /dev/null +++ b/core/lib/Thelia/Action/Order.php @@ -0,0 +1,98 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\CartEvent; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ProductPrice; +use Thelia\Model\ProductPriceQuery; +use Thelia\Model\CartItem; +use Thelia\Model\CartItemQuery; +use Thelia\Model\ConfigQuery; + +/** + * + * Class Order + * @package Thelia\Action + * @author Etienne Roudeix + */ +class Order extends BaseAction implements EventSubscriberInterface +{ + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryAddress(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->chosenDeliveryAddress = $event->getDeliveryAddress(); + + $event->setOrder($order); + } + + /** + * @param \Thelia\Core\Event\OrderEvent $event + */ + public function setDeliveryModule(OrderEvent $event) + { + $order = $event->getOrder(); + + $deliveryAddress = $event->getDeliveryAddress(); + + $order->setDeliveryModuleId($event->getDeliveryModule()); + + $event->setOrder($order); + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128), + TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128), + ); + } +} diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index a586667d1..b67455f2c 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -17,6 +17,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 2a344bad9..e8ea3a9d5 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -58,6 +58,8 @@
+ + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 53c137988..ca76db188 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -95,12 +95,25 @@ Thelia\Controller\Admin\CategoryController::updatePositionAction + + + Thelia\Controller\Admin\CategoryController::addRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::deleteRelatedContentAction + + + + Thelia\Controller\Admin\CategoryController::getAvailableRelatedContentAction + xml|json + + Thelia\Controller\Admin\CategoryController::getByParentIdAction xml|json - diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index adbb7d529..7705c81cc 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -97,6 +97,7 @@ Thelia\Controller\Front\DefaultController::noAction cart + Thelia\Controller\Front\CartController::addItem @@ -111,6 +112,21 @@ cart + + Thelia\Controller\Front\OrderController::deliver + order_delivery + + + + Thelia\Controller\Front\DefaultController::noAction + order_delivery + + + + Thelia\Controller\Front\DefaultController::noAction + order_invoice + + diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 5b7f8b60a..7b9550610 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -224,7 +224,7 @@ abstract class AbstractCrudController extends BaseAdminController * @param unknown $updateEvent the update event * @return Response a response, or null to continue normal processing */ - protected function performAdditionalUpdateAction($updateeEvent) + protected function performAdditionalUpdateAction($updateEvent) { return null; } diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index 83d90c86e..7f19fd73e 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -32,6 +32,13 @@ use Thelia\Form\CategoryModificationForm; use Thelia\Form\CategoryCreationForm; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Core\Event\CategoryToggleVisibilityEvent; +use Thelia\Core\Event\CategoryDeleteContentEvent; +use Thelia\Core\Event\CategoryAddContentEvent; +use Thelia\Model\CategoryAssociatedContent; +use Thelia\Model\FolderQuery; +use Thelia\Model\ContentQuery; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Model\CategoryAssociatedContentQuery; /** * Manages categories @@ -152,31 +159,37 @@ class CategoryController extends AbstractCrudController return $object->getId(); } + protected function getEditionArguments() + { + return array( + 'category_id' => $this->getRequest()->get('category_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'current_tab' => $this->getRequest()->get('current_tab', 'general') + ); + } + protected function renderListTemplate($currentOrder) { return $this->render('categories', array( 'category_order' => $currentOrder, 'category_id' => $this->getRequest()->get('category_id', 0) - ) - ); - } - - protected function renderEditionTemplate() { - return $this->render('category-edit', array('category_id' => $this->getRequest()->get('category_id', 0))); - } - - protected function redirectToEditionTemplate() { - $this->redirectToRoute( - "admin.categories.update", - array('category_id' => $this->getRequest()->get('category_id', 0)) - ); + )); } protected function redirectToListTemplate() { $this->redirectToRoute( 'admin.categories.default', array('category_id' => $this->getRequest()->get('category_id', 0)) - ); + ); + } + + protected function renderEditionTemplate() { + + return $this->render('category-edit', $this->getEditionArguments()); + } + + protected function redirectToEditionTemplate() { + $this->redirectToRoute("admin.categories.update", $this->getEditionArguments()); } /** @@ -209,6 +222,18 @@ class CategoryController extends AbstractCrudController ); } + protected function performAdditionalUpdateAction($updateEvent) + { + if ($this->getRequest()->get('save_mode') != 'stay') { + + // Redirect to parent category list + $this->redirectToRoute( + 'admin.categories.default', + array('category_id' => $updateEvent->getCategory()->getParent()) + ); + } + } + protected function performAdditionalUpdatePositionAction($event) { @@ -224,4 +249,81 @@ class CategoryController extends AbstractCrudController return null; } + + public function getAvailableRelatedContentAction($categoryId, $folderId) { + + $result = array(); + + $folders = FolderQuery::create()->filterById($folderId)->find(); + + if ($folders !== null) { + + $list = ContentQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->filterByFolder($folders, Criteria::IN) + ->filterById(CategoryAssociatedContentQuery::create()->select('content_id')->findByCategoryId($categoryId), Criteria::NOT_IN) + ->find(); + ; + + if ($list !== null) { + foreach($list as $item) { + $result[] = array('id' => $item->getId(), 'title' => $item->getTitle()); + } + } + } + + return $this->jsonResponse(json_encode($result)); + } + + public function addRelatedContentAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new CategoryAddContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::CATEGORY_ADD_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteRelatedContentAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; + + $content_id = intval($this->getRequest()->get('content_id')); + + if ($content_id > 0) { + + $event = new CategoryDeleteContentEvent( + $this->getExistingObject(), + $content_id + ); + + try { + $this->dispatch(TheliaEvents::CATEGORY_REMOVE_CONTENT, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } } diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 3c4c0a5bc..1c7140211 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -62,6 +62,14 @@ class BaseController extends ContainerAware return new Response(); } + /** + * Return a JSON response + */ + protected function jsonResponse($json_data) + { + return new Response($json_data, 200, array('content-type' => 'application/json')); + } + /** * Dispatch a Thelia event * diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 1c4a13977..6540f28a4 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -57,4 +57,11 @@ class BaseFrontController extends BaseController $this->redirectToRoute("customer.login.view"); } } + + protected function checkCartNotEmpty() + { + if($this->getSession()->getCart()->countCartItems() == 0) { + $this->redirectToRoute("cart.view"); + } + } } diff --git a/core/lib/Thelia/Controller/Front/OrderController.php b/core/lib/Thelia/Controller/Front/OrderController.php new file mode 100755 index 000000000..1bac39b14 --- /dev/null +++ b/core/lib/Thelia/Controller/Front/OrderController.php @@ -0,0 +1,126 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Controller\Front; + +use Propel\Runtime\Exception\PropelException; +use Thelia\Form\Exception\FormValidationException; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Symfony\Component\HttpFoundation\Request; +use Thelia\Form\OrderDelivery; +use Thelia\Log\Tlog; +use Thelia\Model\Base\AddressQuery; +use Thelia\Model\Order; + +/** + * Class OrderController + * @package Thelia\Controller\Front + * @author Etienne Roudeix + */ +class OrderController extends BaseFrontController +{ + /** + * set billing address + * set delivery address + * set delivery module + */ + public function deliver() + { + $this->checkAuth(); + $this->checkCartNotEmpty(); + + $message = false; + + $orderDelivery = new OrderDelivery($this->getRequest()); + + $x = $this->getRequest(); + $y = $_POST; + + try { + $form = $this->validateForm($orderDelivery, "post"); + + $deliveryAddressId = $form->get("delivery-address")->getData(); + $deliveryModuleId = $form->get("delivery-module")->getData(); + + /* check that the delivery address belong to the current customer */ + $deliveryAddress = AddressQuery::create()->findPk($deliveryAddressId); + if($deliveryAddress->getCustomerId() !== $this->getSecurityContext()->getCustomerUser()->getId()) { + throw new \Exception("Address does not belong to the current customer"); + } + + /* check that the delivery module fetch the delivery address area */ + + + + $orderEvent = $this->getOrderEvent(); + $orderEvent->setDeliveryAddress($deliveryAddressId); + $orderEvent->setDeliveryModule($deliveryModuleId); + + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_ADDRESS, $orderEvent); + $this->getDispatcher()->dispatch(TheliaEvents::ORDER_SET_DELIVERY_MODULE, $orderEvent); + + $this->redirectToRoute("order.invoice"); + + } catch (FormValidationException $e) { + $message = sprintf("Please check your input: %s", $e->getMessage()); + } catch (PropelException $e) { + $this->getParserContext()->setGeneralError($e->getMessage()); + } catch (\Exception $e) { + $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); + } + + if ($message !== false) { + Tlog::getInstance()->error(sprintf("Error during order delivery process : %s. Exception was %s", $message, $e->getMessage())); + + $orderDelivery->setErrorMessage($message); + + $this->getParserContext() + ->addForm($orderDelivery) + ->setGeneralError($message) + ; + } + + } + + protected function getOrderEvent() + { + $order = $this->getOrder($this->getRequest()); + + return new OrderEvent($order); + } + + public function getOrder(Request $request) + { + $session = $request->getSession(); + + if (null !== $order = $session->getOrder()) { + return $order; + } + + $order = new Order(); + + $session->setOrder($order); + + return $order; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php new file mode 100644 index 000000000..3ca5b2ae5 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryAddContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryAddContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php new file mode 100644 index 000000000..bb28beb21 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CategoryDeleteContentEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Category; + +class CategoryDeleteContentEvent extends CategoryEvent +{ + protected $content_id; + + public function __construct(Category $category, $content_id) + { + parent::__construct($category); + + $this->content_id = $content_id; + } + + public function getContentId() + { + return $this->content_id; + } + + public function setContentId($content_id) + { + $this->content_id = $content_id; + } +} diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php new file mode 100755 index 000000000..6c2b5ff4b --- /dev/null +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -0,0 +1,109 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Address; +use Thelia\Model\AddressQuery; +use Thelia\Model\Module; +use Thelia\Model\Order; + +class OrderEvent extends ActionEvent +{ + protected $order = null; + protected $billingAddress = null; + protected $deliveryAddress = null; + protected $deliveryModule = null; + + /** + * @param Order $order + */ + public function __construct(Order $order) + { + $this->setOrder($order); + } + + /** + * @param Order $order + */ + public function setOrder(Order $order) + { + $this->order = $order; + } + + /** + * @param $address + */ + public function setBillingAddress($address) + { + $this->deliveryAddress = $address; + } + + /** + * @param $address + */ + public function setDeliveryAddress($address) + { + $this->deliveryAddress = $address; + } + + /** + * @param $module + */ + public function setDeliveryModule($module) + { + $this->deliveryModule = $module; + } + + /** + * @return null|Order + */ + public function getOrder() + { + return $this->order; + } + + /** + * @return array|mixed|Address + */ + public function getBillingAddress() + { + return $this->billingAddress; + } + + /** + * @return array|mixed|Address + */ + public function getDeliveryAddress() + { + return $this->deliveryAddress; + } + + /** + * @return array|mixed|Address + */ + public function getDeliveryModule() + { + return $this->deliveryModule; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 1fc91dacb..bab268613 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -153,6 +153,9 @@ final class TheliaEvents const CATEGORY_TOGGLE_VISIBILITY = "action.toggleCategoryVisibility"; const CATEGORY_UPDATE_POSITION = "action.updateCategoryPosition"; + const CATEGORY_ADD_CONTENT = "action.categoryAddContent"; + const CATEGORY_REMOVE_CONTENT = "action.categoryRemoveContent"; + const BEFORE_CREATECATEGORY = "action.before_createcategory"; const AFTER_CREATECATEGORY = "action.after_createcategory"; @@ -189,6 +192,13 @@ final class TheliaEvents const CART_DELETEITEM = "action.deleteArticle"; + /** + * Order linked event + */ + const ORDER_SET_BILLING_ADDRESS = "action.order.setBillingAddress"; + const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress"; + const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule"; + /** * Sent on image processing */ @@ -200,7 +210,7 @@ final class TheliaEvents const DOCUMENT_PROCESS = "action.processDocument"; /** - * Sent on cimage cache clear request + * Sent on image cache clear request */ const IMAGE_CLEAR_CACHE = "action.clearImageCache"; diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index e9e3d50bf..5edd007b3 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -29,6 +29,7 @@ use Thelia\Exception\InvalidCartException; use Thelia\Model\CartQuery; use Thelia\Model\Cart; use Thelia\Model\Currency; +use Thelia\Model\Order; use Thelia\Tools\URL; use Thelia\Model\Lang; @@ -43,6 +44,8 @@ use Thelia\Model\Lang; class Session extends BaseSession { /** + * @param bool $forceDefault + * * @return \Thelia\Model\Lang|null */ public function getLang($forceDefault = true) @@ -205,22 +208,19 @@ class Session extends BaseSession return $this; } - /** - * assign delivery id in session - * - * @param $delivery_id - * @return $this - */ - public function setDelivery($delivery_id) + // -- Order ------------------------------------------------------------------ + + + public function setOrder(Order $order) { - $this->set("thelia.delivery_id", $delivery_id); + $this->set("thelia.order", $order); return $this; } - public function getDelivery() + public function getOrder() { - return $this->get("thelia.delivery_id"); + return $this->get("thelia.order"); } diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 253c48da7..d85f75fa6 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -53,8 +53,12 @@ class AssociatedContent extends Content { $argumentCollection = parent::getArgDefinitions(); - $argumentCollection->addArgument(Argument::createIntTypeArgument('product')) - ->addArgument(Argument::createIntTypeArgument('category')); + $argumentCollection + ->addArgument(Argument::createIntTypeArgument('product')) + ->addArgument(Argument::createIntTypeArgument('category')) + ->addArgument(Argument::createIntTypeArgument('exclude_product')) + ->addArgument(Argument::createIntTypeArgument('exclude_category')) + ; $argumentCollection->get('order')->default = "associated_content"; @@ -91,6 +95,28 @@ class AssociatedContent extends Content $search->filterByCategoryId($category, Criteria::EQUAL); } + $exclude_product = $this->getExcludeProduct(); + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $exclude_product) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(), + Criteria::NOT_IN + ); + } + + $exclude_category = $this->getExcludeCategory(); + + // If we have to filter by template, find all attributes assigned to this template, and filter by found IDs + if (null !== $exclude_category) { + // Exclure tous les attribut qui sont attachés aux templates indiqués + $search->filterById( + CategoryAssociatedContentQuery::create()->filterByProductId($exclude_category)->select('category_id')->find(), + Criteria::NOT_IN + ); + } + $order = $this->getOrder(); $orderByAssociatedContent = array_search('associated_content', $order); $orderByAssociatedContentReverse = array_search('associated_content_reverse', $order); diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index f65afdf40..3c8724d68 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -13,6 +13,7 @@ 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\Model\CountryQuery; class Cart extends BaseLoop { @@ -82,7 +83,7 @@ class Cart extends BaseLoop foreach ($cartItems as $cartItem) { $product = $cartItem->getProduct(); - //$product->setLocale($this->request->getSession()->getLocale()); + $productSaleElement = $cartItem->getProductSaleElements(); $loopResultRow = new LoopResultRow($result, $cartItem, $this->versionable, $this->timestampable, $this->countable); @@ -92,6 +93,17 @@ class Cart extends BaseLoop $loopResultRow->set("QUANTITY", $cartItem->getQuantity()); $loopResultRow->set("PRICE", $cartItem->getPrice()); $loopResultRow->set("PRODUCT_ID", $product->getId()); + $loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale())) + ->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("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0); $result->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index a0e9ebb7a..dea302797 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -22,9 +22,12 @@ /*************************************************************************************/ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\CountryQuery; +use Thelia\Module\BaseModule; /** * Class Delivery @@ -50,6 +53,19 @@ class Delivery extends BaseSpecificModule $search = parent::exec($pagination); /* manage translations */ $locale = $this->configureI18nProcessing($search); + + $search->filterByType(BaseModule::DELIVERY_MODULE_TYPE, Criteria::EQUAL); + + $countryId = $this->getCountry(); + if(null !== $countryId) { + $country = CountryQuery::create()->findPk($countryId); + if(null === $country) { + throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); + } + } else { + $country = CountryQuery::create()->findOneByByDefault(1); + } + /* perform search */ $deliveryModules = $this->search($search, $pagination); @@ -73,7 +89,7 @@ class Delivery extends BaseSpecificModule ->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO')) ->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION')) ->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set('PRICE', $moduleInstance->calculate($this->getCountry())) + ->set('PRICE', $moduleInstance->calculate($country)) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index 980ade454..e27626129 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -115,7 +115,7 @@ class ProductSaleElements extends BaseLoop $currencyId = $this->getCurrency(); if (null !== $currencyId) { - $currency = CurrencyQuery::create()->findOneById($currencyId); + $currency = CurrencyQuery::create()->findPk($currencyId); if (null === $currency) { throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 802dfcff2..41341f789 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -31,6 +31,7 @@ use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Model\CategoryQuery; use Thelia\Model\ContentQuery; +use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\FolderQuery; use Thelia\Model\Product; @@ -154,20 +155,42 @@ class DataAccessFunctions extends AbstractSmartyPlugin } } + public function countryDataAccess($params, $smarty) + { + $defaultCountry = CountryQuery::create()->findOneByByDefault(1); + + switch($params["attr"]) { + case "default": + return $defaultCountry->getId(); + } + } + public function cartDataAccess($params, $smarty) { $cart = $this->getCart($this->request); $result = ""; switch($params["attr"]) { case "count_item": - $result = $cart->getCartItems()->count(); break; + case "total_price": + $result = $cart->getTotalAmount(); + break; + case "total_taxed_price": + $result = $cart->getTaxedAmount( + CountryQuery::create()->findOneById(64) // @TODO : make it magic + ); + break; } return $result; } + public function orderDataAccess($params, &$smarty) + { + return $this->dataAccess("Order", $params, $this->request->getSession()->getOrder()); + } + /** * Lang global data * @@ -279,8 +302,10 @@ class DataAccessFunctions extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'), new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'), + new SmartyPluginDescriptor('function', 'country', $this, 'countryDataAccess'), new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), new SmartyPluginDescriptor('function', 'cart', $this, 'cartDataAccess'), + new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'), ); } } diff --git a/core/lib/Thelia/Form/CategoryCreationForm.php b/core/lib/Thelia/Form/CategoryCreationForm.php index 172b09ee6..5da76c8ba 100755 --- a/core/lib/Thelia/Form/CategoryCreationForm.php +++ b/core/lib/Thelia/Form/CategoryCreationForm.php @@ -43,15 +43,18 @@ class CategoryCreationForm extends BaseForm "label" => Translator::getInstance()->trans("Parent category *"), "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "parent_create") )) ->add("locale", "text", array( "constraints" => array( new NotBlank() - ) + ), + "label_attr" => array("for" => "locale_create") )) ->add("visible", "integer", array( - "label" => Translator::getInstance()->trans("This category is online on the front office.") + "label" => Translator::getInstance()->trans("This category is online on the front office."), + "label_attr" => array("for" => "visible_create") )) ; } diff --git a/core/lib/Thelia/Form/CategoryModificationForm.php b/core/lib/Thelia/Form/CategoryModificationForm.php index 42b5893c1..943c0d941 100644 --- a/core/lib/Thelia/Form/CategoryModificationForm.php +++ b/core/lib/Thelia/Form/CategoryModificationForm.php @@ -39,7 +39,8 @@ class CategoryModificationForm extends CategoryCreationForm ->add("url", "text", array( "label" => Translator::getInstance()->trans("Rewriten URL *"), - "constraints" => array(new NotBlank()) + "constraints" => array(new NotBlank()), + "label_attr" => array("for" => "rewriten_url") )) ; diff --git a/core/lib/Thelia/Form/OrderDelivery.php b/core/lib/Thelia/Form/OrderDelivery.php new file mode 100755 index 000000000..3ef1444f6 --- /dev/null +++ b/core/lib/Thelia/Form/OrderDelivery.php @@ -0,0 +1,94 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\AddressQuery; +use Thelia\Model\ConfigQuery; +use Thelia\Core\Translation\Translator; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class OrderDelivery + * @package Thelia\Form + * @author Etienne Roudeix + */ +class OrderDelivery extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add("delivery-address", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryAddress") + ) + )) + ) + )) + ->add("delivery-module", "integer", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback(array( + "methods" => array( + array($this, "verifyDeliveryModule") + ) + )) + ) + )); + } + + public function verifyDeliveryAddress($value, ExecutionContextInterface $context) + { + $address = AddressQuery::create() + ->findPk($value); + + if(null === $address) { + $context->addViolation("Address ID not found"); + } + } + + public function verifyDeliveryModule($value, ExecutionContextInterface $context) + { + $module = ModuleQuery::create() + ->filterByType(BaseModule::DELIVERY_MODULE_TYPE) + ->filterByActivate(1) + ->filterById($value) + ->find(); + + if(null === $module) { + $context->addViolation("Delivery module ID not found"); + } + } + + public function getName() + { + return "thelia_order_delivery"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php index 9d1851252..b35aad12f 100644 --- a/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php +++ b/core/lib/Thelia/Form/StandardDescriptionFieldsTrait.php @@ -58,7 +58,8 @@ trait StandardDescriptionFieldsTrait "label" => Translator::getInstance()->trans("Title"), "label_attr" => array( "for" => "title" - ) + ), + "label_attr" => array("for" => "title_field") ) ); @@ -67,7 +68,7 @@ trait StandardDescriptionFieldsTrait ->add("chapo", "text", array( "label" => Translator::getInstance()->trans("Summary"), "label_attr" => array( - "for" => "summary" + "for" => "summary_field" ) )); @@ -76,7 +77,7 @@ trait StandardDescriptionFieldsTrait ->add("description", "text", array( "label" => Translator::getInstance()->trans("Detailed description"), "label_attr" => array( - "for" => "detailed_description" + "for" => "detailed_description_field" ) )); @@ -85,7 +86,7 @@ trait StandardDescriptionFieldsTrait ->add("postscriptum", "text", array( "label" => Translator::getInstance()->trans("Conclusion"), "label_attr" => array( - "for" => "conclusion" + "for" => "conclusion_field" ) )); } diff --git a/core/lib/Thelia/Model/AreaDeliveryModule.php b/core/lib/Thelia/Model/AreaDeliveryModule.php new file mode 100644 index 000000000..206625a12 --- /dev/null +++ b/core/lib/Thelia/Model/AreaDeliveryModule.php @@ -0,0 +1,10 @@ +unit; + return $this->postage; } /** @@ -491,25 +491,25 @@ abstract class Area implements ActiveRecordInterface } // setName() /** - * Set the value of [unit] column. + * Set the value of [postage] column. * * @param double $v new value * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function setUnit($v) + public function setPostage($v) { if ($v !== null) { $v = (double) $v; } - if ($this->unit !== $v) { - $this->unit = $v; - $this->modifiedColumns[] = AreaTableMap::UNIT; + if ($this->postage !== $v) { + $this->postage = $v; + $this->modifiedColumns[] = AreaTableMap::POSTAGE; } return $this; - } // setUnit() + } // setPostage() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. @@ -596,8 +596,8 @@ abstract class Area implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; $this->name = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Unit', TableMap::TYPE_PHPNAME, $indexType)]; - $this->unit = (null !== $col) ? (double) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postage = (null !== $col) ? (double) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { @@ -681,7 +681,7 @@ abstract class Area implements ActiveRecordInterface $this->collCountries = null; - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } // if (deep) } @@ -834,18 +834,17 @@ abstract class Area implements ActiveRecordInterface } } - if ($this->delivzonesScheduledForDeletion !== null) { - if (!$this->delivzonesScheduledForDeletion->isEmpty()) { - foreach ($this->delivzonesScheduledForDeletion as $delivzone) { - // need to save related object because we set the relation to null - $delivzone->save($con); - } - $this->delivzonesScheduledForDeletion = null; + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; } } - if ($this->collDelivzones !== null) { - foreach ($this->collDelivzones as $referrerFK) { + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -884,8 +883,8 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::NAME)) { $modifiedColumns[':p' . $index++] = 'NAME'; } - if ($this->isColumnModified(AreaTableMap::UNIT)) { - $modifiedColumns[':p' . $index++] = 'UNIT'; + if ($this->isColumnModified(AreaTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; } if ($this->isColumnModified(AreaTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; @@ -910,8 +909,8 @@ abstract class Area implements ActiveRecordInterface case 'NAME': $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); break; - case 'UNIT': - $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR); + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); @@ -988,7 +987,7 @@ abstract class Area implements ActiveRecordInterface return $this->getName(); break; case 2: - return $this->getUnit(); + return $this->getPostage(); break; case 3: return $this->getCreatedAt(); @@ -1027,7 +1026,7 @@ abstract class Area implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getName(), - $keys[2] => $this->getUnit(), + $keys[2] => $this->getPostage(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -1041,8 +1040,8 @@ abstract class Area implements ActiveRecordInterface if (null !== $this->collCountries) { $result['Countries'] = $this->collCountries->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collDelivzones) { - $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1085,7 +1084,7 @@ abstract class Area implements ActiveRecordInterface $this->setName($value); break; case 2: - $this->setUnit($value); + $this->setPostage($value); break; case 3: $this->setCreatedAt($value); @@ -1119,7 +1118,7 @@ abstract class Area implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setPostage($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1135,7 +1134,7 @@ abstract class Area implements ActiveRecordInterface if ($this->isColumnModified(AreaTableMap::ID)) $criteria->add(AreaTableMap::ID, $this->id); if ($this->isColumnModified(AreaTableMap::NAME)) $criteria->add(AreaTableMap::NAME, $this->name); - if ($this->isColumnModified(AreaTableMap::UNIT)) $criteria->add(AreaTableMap::UNIT, $this->unit); + if ($this->isColumnModified(AreaTableMap::POSTAGE)) $criteria->add(AreaTableMap::POSTAGE, $this->postage); if ($this->isColumnModified(AreaTableMap::CREATED_AT)) $criteria->add(AreaTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AreaTableMap::UPDATED_AT)) $criteria->add(AreaTableMap::UPDATED_AT, $this->updated_at); @@ -1202,7 +1201,7 @@ abstract class Area implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setName($this->getName()); - $copyObj->setUnit($this->getUnit()); + $copyObj->setPostage($this->getPostage()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1217,9 +1216,9 @@ abstract class Area implements ActiveRecordInterface } } - foreach ($this->getDelivzones() as $relObj) { + foreach ($this->getAreaDeliveryModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDelivzone($relObj->copy($deepCopy)); + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); } } @@ -1267,8 +1266,8 @@ abstract class Area implements ActiveRecordInterface if ('Country' == $relationName) { return $this->initCountries(); } - if ('Delivzone' == $relationName) { - return $this->initDelivzones(); + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); } } @@ -1491,31 +1490,31 @@ abstract class Area implements ActiveRecordInterface } /** - * Clears out the collDelivzones collection + * Clears out the collAreaDeliveryModules collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addDelivzones() + * @see addAreaDeliveryModules() */ - public function clearDelivzones() + public function clearAreaDeliveryModules() { - $this->collDelivzones = null; // important to set this to NULL since that means it is uninitialized + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collDelivzones collection loaded partially. + * Reset is the collAreaDeliveryModules collection loaded partially. */ - public function resetPartialDelivzones($v = true) + public function resetPartialAreaDeliveryModules($v = true) { - $this->collDelivzonesPartial = $v; + $this->collAreaDeliveryModulesPartial = $v; } /** - * Initializes the collDelivzones collection. + * Initializes the collAreaDeliveryModules collection. * - * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones()); + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1524,17 +1523,17 @@ abstract class Area implements ActiveRecordInterface * * @return void */ - public function initDelivzones($overrideExisting = true) + public function initAreaDeliveryModules($overrideExisting = true) { - if (null !== $this->collDelivzones && !$overrideExisting) { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { return; } - $this->collDelivzones = new ObjectCollection(); - $this->collDelivzones->setModel('\Thelia\Model\Delivzone'); + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); } /** - * Gets an array of ChildDelivzone objects which contain a foreign key that references this object. + * Gets an array of ChildAreaDeliveryModule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1544,109 +1543,109 @@ abstract class Area implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildDelivzone[] List of ChildDelivzone objects + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects * @throws PropelException */ - public function getDelivzones($criteria = null, ConnectionInterface $con = null) + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { // return empty collection - $this->initDelivzones(); + $this->initAreaDeliveryModules(); } else { - $collDelivzones = ChildDelivzoneQuery::create(null, $criteria) + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) ->filterByArea($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collDelivzonesPartial && count($collDelivzones)) { - $this->initDelivzones(false); + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); - foreach ($collDelivzones as $obj) { - if (false == $this->collDelivzones->contains($obj)) { - $this->collDelivzones->append($obj); + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); } } - $this->collDelivzonesPartial = true; + $this->collAreaDeliveryModulesPartial = true; } - $collDelivzones->getInternalIterator()->rewind(); + $collAreaDeliveryModules->getInternalIterator()->rewind(); - return $collDelivzones; + return $collAreaDeliveryModules; } - if ($partial && $this->collDelivzones) { - foreach ($this->collDelivzones as $obj) { + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { if ($obj->isNew()) { - $collDelivzones[] = $obj; + $collAreaDeliveryModules[] = $obj; } } } - $this->collDelivzones = $collDelivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; } } - return $this->collDelivzones; + return $this->collAreaDeliveryModules; } /** - * Sets a collection of Delivzone objects related by a one-to-many relationship + * Sets a collection of AreaDeliveryModule objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $delivzones A Propel collection. + * @param Collection $areaDeliveryModules A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildArea The current object (for fluent API support) */ - public function setDelivzones(Collection $delivzones, ConnectionInterface $con = null) + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) { - $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); - $this->delivzonesScheduledForDeletion = $delivzonesToDelete; + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; - foreach ($delivzonesToDelete as $delivzoneRemoved) { - $delivzoneRemoved->setArea(null); + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setArea(null); } - $this->collDelivzones = null; - foreach ($delivzones as $delivzone) { - $this->addDelivzone($delivzone); + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); } - $this->collDelivzones = $delivzones; - $this->collDelivzonesPartial = false; + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; return $this; } /** - * Returns the number of related Delivzone objects. + * Returns the number of related AreaDeliveryModule objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related Delivzone objects. + * @return int Count of related AreaDeliveryModule objects. * @throws PropelException */ - public function countDelivzones(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { return 0; } if ($partial && !$criteria) { - return count($this->getDelivzones()); + return count($this->getAreaDeliveryModules()); } - $query = ChildDelivzoneQuery::create(null, $criteria); + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1656,58 +1655,83 @@ abstract class Area implements ActiveRecordInterface ->count($con); } - return count($this->collDelivzones); + return count($this->collAreaDeliveryModules); } /** - * Method called to associate a ChildDelivzone object to this object - * through the ChildDelivzone foreign key attribute. + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. * - * @param ChildDelivzone $l ChildDelivzone + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule * @return \Thelia\Model\Area The current object (for fluent API support) */ - public function addDelivzone(ChildDelivzone $l) + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) { - if ($this->collDelivzones === null) { - $this->initDelivzones(); - $this->collDelivzonesPartial = true; + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; } - if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDelivzone($l); + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); } return $this; } /** - * @param Delivzone $delivzone The delivzone object to add. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. */ - protected function doAddDelivzone($delivzone) + protected function doAddAreaDeliveryModule($areaDeliveryModule) { - $this->collDelivzones[]= $delivzone; - $delivzone->setArea($this); + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setArea($this); } /** - * @param Delivzone $delivzone The delivzone object to remove. + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. * @return ChildArea The current object (for fluent API support) */ - public function removeDelivzone($delivzone) + public function removeAreaDeliveryModule($areaDeliveryModule) { - if ($this->getDelivzones()->contains($delivzone)) { - $this->collDelivzones->remove($this->collDelivzones->search($delivzone)); - if (null === $this->delivzonesScheduledForDeletion) { - $this->delivzonesScheduledForDeletion = clone $this->collDelivzones; - $this->delivzonesScheduledForDeletion->clear(); + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); } - $this->delivzonesScheduledForDeletion[]= $delivzone; - $delivzone->setArea(null); + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setArea(null); } return $this; } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Area is new, it will return + * an empty collection; or if this Area has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Area. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Module', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1715,7 +1739,7 @@ abstract class Area implements ActiveRecordInterface { $this->id = null; $this->name = null; - $this->unit = null; + $this->postage = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1742,8 +1766,8 @@ abstract class Area implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collDelivzones) { - foreach ($this->collDelivzones as $o) { + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { $o->clearAllReferences($deep); } } @@ -1753,10 +1777,10 @@ abstract class Area implements ActiveRecordInterface $this->collCountries->clearIterator(); } $this->collCountries = null; - if ($this->collDelivzones instanceof Collection) { - $this->collDelivzones->clearIterator(); + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); } - $this->collDelivzones = null; + $this->collAreaDeliveryModules = null; } /** diff --git a/core/lib/Thelia/Model/Base/Delivzone.php b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php similarity index 80% rename from core/lib/Thelia/Model/Base/Delivzone.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModule.php index deb21997e..38a16dd5a 100644 --- a/core/lib/Thelia/Model/Base/Delivzone.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModule.php @@ -17,17 +17,19 @@ use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\Area as ChildArea; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\AreaQuery as ChildAreaQuery; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +use Thelia\Model\Module as ChildModule; +use Thelia\Model\ModuleQuery as ChildModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; -abstract class Delivzone implements ActiveRecordInterface +abstract class AreaDeliveryModule implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\DelivzoneTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\AreaDeliveryModuleTableMap'; /** @@ -69,10 +71,10 @@ abstract class Delivzone implements ActiveRecordInterface protected $area_id; /** - * The value for the delivery field. - * @var string + * The value for the delivery_module_id field. + * @var int */ - protected $delivery; + protected $delivery_module_id; /** * The value for the created_at field. @@ -91,6 +93,11 @@ abstract class Delivzone implements ActiveRecordInterface */ protected $aArea; + /** + * @var Module + */ + protected $aModule; + /** * Flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. @@ -100,7 +107,7 @@ abstract class Delivzone implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\Delivzone object. + * Initializes internal state of Thelia\Model\Base\AreaDeliveryModule object. */ public function __construct() { @@ -195,9 +202,9 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Compares this with another Delivzone instance. If - * obj is an instance of Delivzone, delegates to - * equals(Delivzone). Otherwise, returns false. + * Compares this with another AreaDeliveryModule instance. If + * obj is an instance of AreaDeliveryModule, delegates to + * equals(AreaDeliveryModule). Otherwise, returns false. * * @param obj The object to compare to. * @return Whether equal to the object specified. @@ -278,7 +285,7 @@ abstract class Delivzone implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -310,7 +317,7 @@ abstract class Delivzone implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return Delivzone The current object, for fluid interface + * @return AreaDeliveryModule The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -376,14 +383,14 @@ abstract class Delivzone implements ActiveRecordInterface } /** - * Get the [delivery] column value. + * Get the [delivery_module_id] column value. * - * @return string + * @return int */ - public function getDelivery() + public function getDeliveryModuleId() { - return $this->delivery; + return $this->delivery_module_id; } /** @@ -430,7 +437,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setId($v) { @@ -440,7 +447,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; } @@ -451,7 +458,7 @@ abstract class Delivzone implements ActiveRecordInterface * Set the value of [area_id] column. * * @param int $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setAreaId($v) { @@ -461,7 +468,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->area_id !== $v) { $this->area_id = $v; - $this->modifiedColumns[] = DelivzoneTableMap::AREA_ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::AREA_ID; } if ($this->aArea !== null && $this->aArea->getId() !== $v) { @@ -473,32 +480,36 @@ abstract class Delivzone implements ActiveRecordInterface } // setAreaId() /** - * Set the value of [delivery] column. + * Set the value of [delivery_module_id] column. * - * @param string $v new value - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @param int $v new value + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ - public function setDelivery($v) + public function setDeliveryModuleId($v) { if ($v !== null) { - $v = (string) $v; + $v = (int) $v; } - if ($this->delivery !== $v) { - $this->delivery = $v; - $this->modifiedColumns[] = DelivzoneTableMap::DELIVERY; + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; } return $this; - } // setDelivery() + } // setDeliveryModuleId() /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -506,7 +517,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::CREATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::CREATED_AT; } } // if either are not null @@ -519,7 +530,7 @@ abstract class Delivzone implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -527,7 +538,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; } } // if either are not null @@ -572,22 +583,22 @@ abstract class Delivzone implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : DelivzoneTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : DelivzoneTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; $this->area_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : DelivzoneTableMap::translateFieldName('Delivery', TableMap::TYPE_PHPNAME, $indexType)]; - $this->delivery = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : DelivzoneTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : DelivzoneTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AreaDeliveryModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -600,10 +611,10 @@ abstract class Delivzone implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = DelivzoneTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Delivzone object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\AreaDeliveryModule object", 0, $e); } } @@ -625,6 +636,9 @@ abstract class Delivzone implements ActiveRecordInterface if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { $this->aArea = null; } + if ($this->aModule !== null && $this->delivery_module_id !== $this->aModule->getId()) { + $this->aModule = null; + } } // ensureConsistency /** @@ -648,13 +662,13 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildDelivzoneQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildAreaDeliveryModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -665,6 +679,7 @@ abstract class Delivzone implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? $this->aArea = null; + $this->aModule = null; } // if (deep) } @@ -674,8 +689,8 @@ abstract class Delivzone implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see Delivzone::setDeleted() - * @see Delivzone::isDeleted() + * @see AreaDeliveryModule::setDeleted() + * @see AreaDeliveryModule::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -684,12 +699,12 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildDelivzoneQuery::create() + $deleteQuery = ChildAreaDeliveryModuleQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -726,7 +741,7 @@ abstract class Delivzone implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -736,16 +751,16 @@ abstract class Delivzone implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -757,7 +772,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - DelivzoneTableMap::addInstanceToPool($this); + AreaDeliveryModuleTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -799,6 +814,13 @@ abstract class Delivzone implements ActiveRecordInterface $this->setArea($this->aArea); } + if ($this->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { @@ -830,30 +852,30 @@ abstract class Delivzone implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = DelivzoneTableMap::ID; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzoneTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaDeliveryModuleTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DelivzoneTableMap::ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) { $modifiedColumns[':p' . $index++] = 'AREA_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) { - $modifiedColumns[':p' . $index++] = 'DELIVERY'; + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; } - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) { + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO delivzone (%s) VALUES (%s)', + 'INSERT INTO area_delivery_module (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -868,8 +890,8 @@ abstract class Delivzone implements ActiveRecordInterface case 'AREA_ID': $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); break; - case 'DELIVERY': - $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR); + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_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); @@ -923,7 +945,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -946,7 +968,7 @@ abstract class Delivzone implements ActiveRecordInterface return $this->getAreaId(); break; case 2: - return $this->getDelivery(); + return $this->getDeliveryModuleId(); break; case 3: return $this->getCreatedAt(); @@ -977,15 +999,15 @@ abstract class Delivzone implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true; - $keys = DelivzoneTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['AreaDeliveryModule'][$this->getPrimaryKey()] = true; + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), - $keys[2] => $this->getDelivery(), + $keys[2] => $this->getDeliveryModuleId(), $keys[3] => $this->getCreatedAt(), $keys[4] => $this->getUpdatedAt(), ); @@ -999,6 +1021,9 @@ abstract class Delivzone implements ActiveRecordInterface if (null !== $this->aArea) { $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); } + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } } return $result; @@ -1017,7 +1042,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = DelivzoneTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = AreaDeliveryModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1040,7 +1065,7 @@ abstract class Delivzone implements ActiveRecordInterface $this->setAreaId($value); break; case 2: - $this->setDelivery($value); + $this->setDeliveryModuleId($value); break; case 3: $this->setCreatedAt($value); @@ -1070,11 +1095,11 @@ abstract class Delivzone implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = DelivzoneTableMap::getFieldNames($keyType); + $keys = AreaDeliveryModuleTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]); + if (array_key_exists($keys[2], $arr)) $this->setDeliveryModuleId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); } @@ -1086,13 +1111,13 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); - if ($this->isColumnModified(DelivzoneTableMap::ID)) $criteria->add(DelivzoneTableMap::ID, $this->id); - if ($this->isColumnModified(DelivzoneTableMap::AREA_ID)) $criteria->add(DelivzoneTableMap::AREA_ID, $this->area_id); - if ($this->isColumnModified(DelivzoneTableMap::DELIVERY)) $criteria->add(DelivzoneTableMap::DELIVERY, $this->delivery); - if ($this->isColumnModified(DelivzoneTableMap::CREATED_AT)) $criteria->add(DelivzoneTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DelivzoneTableMap::UPDATED_AT)) $criteria->add(DelivzoneTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::ID)) $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::AREA_ID)) $criteria->add(AreaDeliveryModuleTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID)) $criteria->add(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::CREATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AreaDeliveryModuleTableMap::UPDATED_AT)) $criteria->add(AreaDeliveryModuleTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1107,8 +1132,8 @@ abstract class Delivzone implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, $this->id); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, $this->id); return $criteria; } @@ -1149,7 +1174,7 @@ abstract class Delivzone implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\Delivzone (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\AreaDeliveryModule (or compatible) type. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. * @throws PropelException @@ -1157,7 +1182,7 @@ abstract class Delivzone implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setAreaId($this->getAreaId()); - $copyObj->setDelivery($this->getDelivery()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1175,7 +1200,7 @@ abstract class Delivzone implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Delivzone Clone of current object. + * @return \Thelia\Model\AreaDeliveryModule Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1192,7 +1217,7 @@ abstract class Delivzone implements ActiveRecordInterface * Declares an association between this object and a ChildArea object. * * @param ChildArea $v - * @return \Thelia\Model\Delivzone The current object (for fluent API support) + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) * @throws PropelException */ public function setArea(ChildArea $v = null) @@ -1208,7 +1233,7 @@ abstract class Delivzone implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildArea object, it will not be re-added. if ($v !== null) { - $v->addDelivzone($this); + $v->addAreaDeliveryModule($this); } @@ -1232,13 +1257,64 @@ abstract class Delivzone implements ActiveRecordInterface to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. - $this->aArea->addDelivzones($this); + $this->aArea->addAreaDeliveryModules($this); */ } return $this->aArea; } + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\AreaDeliveryModule The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addAreaDeliveryModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->delivery_module_id !== null)) { + $this->aModule = ChildModuleQuery::create()->findPk($this->delivery_module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModule->addAreaDeliveryModules($this); + */ + } + + return $this->aModule; + } + /** * Clears the current object and sets all attributes to their default values */ @@ -1246,7 +1322,7 @@ abstract class Delivzone implements ActiveRecordInterface { $this->id = null; $this->area_id = null; - $this->delivery = null; + $this->delivery_module_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1271,6 +1347,7 @@ abstract class Delivzone implements ActiveRecordInterface } // if ($deep) $this->aArea = null; + $this->aModule = null; } /** @@ -1280,7 +1357,7 @@ abstract class Delivzone implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(DelivzoneTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(AreaDeliveryModuleTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1288,11 +1365,11 @@ abstract class Delivzone implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildDelivzone The current object (for fluent API support) + * @return ChildAreaDeliveryModule The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = DelivzoneTableMap::UPDATED_AT; + $this->modifiedColumns[] = AreaDeliveryModuleTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/DelivzoneQuery.php b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php similarity index 53% rename from core/lib/Thelia/Model/Base/DelivzoneQuery.php rename to core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php index e4b8a8ab5..394fe651e 100644 --- a/core/lib/Thelia/Model/Base/DelivzoneQuery.php +++ b/core/lib/Thelia/Model/Base/AreaDeliveryModuleQuery.php @@ -12,80 +12,84 @@ use Propel\Runtime\Collection\Collection; use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Exception\PropelException; -use Thelia\Model\Delivzone as ChildDelivzone; -use Thelia\Model\DelivzoneQuery as ChildDelivzoneQuery; -use Thelia\Model\Map\DelivzoneTableMap; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; +use Thelia\Model\Map\AreaDeliveryModuleTableMap; /** - * Base class that represents a query for the 'delivzone' table. + * Base class that represents a query for the 'area_delivery_module' table. * * * - * @method ChildDelivzoneQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildDelivzoneQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column - * @method ChildDelivzoneQuery orderByDelivery($order = Criteria::ASC) Order by the delivery column - * @method ChildDelivzoneQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column - * @method ChildDelivzoneQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column + * @method ChildAreaDeliveryModuleQuery orderById($order = Criteria::ASC) Order by the id column + * @method ChildAreaDeliveryModuleQuery orderByAreaId($order = Criteria::ASC) Order by the area_id column + * @method ChildAreaDeliveryModuleQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column + * @method ChildAreaDeliveryModuleQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * - * @method ChildDelivzoneQuery groupById() Group by the id column - * @method ChildDelivzoneQuery groupByAreaId() Group by the area_id column - * @method ChildDelivzoneQuery groupByDelivery() Group by the delivery column - * @method ChildDelivzoneQuery groupByCreatedAt() Group by the created_at column - * @method ChildDelivzoneQuery groupByUpdatedAt() Group by the updated_at column + * @method ChildAreaDeliveryModuleQuery groupById() Group by the id column + * @method ChildAreaDeliveryModuleQuery groupByAreaId() Group by the area_id column + * @method ChildAreaDeliveryModuleQuery groupByDeliveryModuleId() Group by the delivery_module_id column + * @method ChildAreaDeliveryModuleQuery groupByCreatedAt() Group by the created_at column + * @method ChildAreaDeliveryModuleQuery groupByUpdatedAt() Group by the updated_at column * - * @method ChildDelivzoneQuery leftJoin($relation) Adds a LEFT JOIN clause to the query - * @method ChildDelivzoneQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query - * @method ChildDelivzoneQuery innerJoin($relation) Adds a INNER JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery leftJoin($relation) Adds a LEFT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query + * @method ChildAreaDeliveryModuleQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildDelivzoneQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation - * @method ChildDelivzoneQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery leftJoinArea($relationAlias = null) Adds a LEFT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery rightJoinArea($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Area relation + * @method ChildAreaDeliveryModuleQuery innerJoinArea($relationAlias = null) Adds a INNER JOIN clause to the query using the Area relation * - * @method ChildDelivzone findOne(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query - * @method ChildDelivzone findOneOrCreate(ConnectionInterface $con = null) Return the first ChildDelivzone matching the query, or a new ChildDelivzone object populated from the query conditions when no match is found + * @method ChildAreaDeliveryModuleQuery leftJoinModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery rightJoinModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Module relation + * @method ChildAreaDeliveryModuleQuery innerJoinModule($relationAlias = null) Adds a INNER JOIN clause to the query using the Module relation * - * @method ChildDelivzone findOneById(int $id) Return the first ChildDelivzone filtered by the id column - * @method ChildDelivzone findOneByAreaId(int $area_id) Return the first ChildDelivzone filtered by the area_id column - * @method ChildDelivzone findOneByDelivery(string $delivery) Return the first ChildDelivzone filtered by the delivery column - * @method ChildDelivzone findOneByCreatedAt(string $created_at) Return the first ChildDelivzone filtered by the created_at column - * @method ChildDelivzone findOneByUpdatedAt(string $updated_at) Return the first ChildDelivzone filtered by the updated_at column + * @method ChildAreaDeliveryModule findOne(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query + * @method ChildAreaDeliveryModule findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAreaDeliveryModule matching the query, or a new ChildAreaDeliveryModule object populated from the query conditions when no match is found * - * @method array findById(int $id) Return ChildDelivzone objects filtered by the id column - * @method array findByAreaId(int $area_id) Return ChildDelivzone objects filtered by the area_id column - * @method array findByDelivery(string $delivery) Return ChildDelivzone objects filtered by the delivery column - * @method array findByCreatedAt(string $created_at) Return ChildDelivzone objects filtered by the created_at column - * @method array findByUpdatedAt(string $updated_at) Return ChildDelivzone objects filtered by the updated_at column + * @method ChildAreaDeliveryModule findOneById(int $id) Return the first ChildAreaDeliveryModule filtered by the id column + * @method ChildAreaDeliveryModule findOneByAreaId(int $area_id) Return the first ChildAreaDeliveryModule filtered by the area_id column + * @method ChildAreaDeliveryModule findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildAreaDeliveryModule filtered by the delivery_module_id column + * @method ChildAreaDeliveryModule findOneByCreatedAt(string $created_at) Return the first ChildAreaDeliveryModule filtered by the created_at column + * @method ChildAreaDeliveryModule findOneByUpdatedAt(string $updated_at) Return the first ChildAreaDeliveryModule filtered by the updated_at column + * + * @method array findById(int $id) Return ChildAreaDeliveryModule objects filtered by the id column + * @method array findByAreaId(int $area_id) Return ChildAreaDeliveryModule objects filtered by the area_id column + * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildAreaDeliveryModule objects filtered by the delivery_module_id column + * @method array findByCreatedAt(string $created_at) Return ChildAreaDeliveryModule objects filtered by the created_at column + * @method array findByUpdatedAt(string $updated_at) Return ChildAreaDeliveryModule objects filtered by the updated_at column * */ -abstract class DelivzoneQuery extends ModelCriteria +abstract class AreaDeliveryModuleQuery extends ModelCriteria { /** - * Initializes internal state of \Thelia\Model\Base\DelivzoneQuery object. + * Initializes internal state of \Thelia\Model\Base\AreaDeliveryModuleQuery object. * * @param string $dbName The database name * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\Delivzone', $modelAlias = null) + public function __construct($dbName = 'thelia', $modelName = '\\Thelia\\Model\\AreaDeliveryModule', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } /** - * Returns a new ChildDelivzoneQuery object. + * Returns a new ChildAreaDeliveryModuleQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * - * @return ChildDelivzoneQuery + * @return ChildAreaDeliveryModuleQuery */ public static function create($modelAlias = null, $criteria = null) { - if ($criteria instanceof \Thelia\Model\DelivzoneQuery) { + if ($criteria instanceof \Thelia\Model\AreaDeliveryModuleQuery) { return $criteria; } - $query = new \Thelia\Model\DelivzoneQuery(); + $query = new \Thelia\Model\AreaDeliveryModuleQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } @@ -108,19 +112,19 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con an optional connection object * - * @return ChildDelivzone|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ public function findPk($key, $con = null) { if ($key === null) { return null; } - if ((null !== ($obj = DelivzoneTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + if ((null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { // the object is already in the instance pool return $obj; } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $this->basePreSelect($con); if ($this->formatter || $this->modelAlias || $this->with || $this->select @@ -139,11 +143,11 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDelivzone A model object, or null if the key is not found + * @return ChildAreaDeliveryModule A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, AREA_ID, DELIVERY, CREATED_AT, UPDATED_AT FROM delivzone WHERE ID = :p0'; + $sql = 'SELECT ID, AREA_ID, DELIVERY_MODULE_ID, CREATED_AT, UPDATED_AT FROM area_delivery_module WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -154,9 +158,9 @@ abstract class DelivzoneQuery extends ModelCriteria } $obj = null; if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildDelivzone(); + $obj = new ChildAreaDeliveryModule(); $obj->hydrate($row); - DelivzoneTableMap::addInstanceToPool($obj, (string) $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); @@ -169,7 +173,7 @@ abstract class DelivzoneQuery extends ModelCriteria * @param mixed $key Primary key to use for the query * @param ConnectionInterface $con A connection object * - * @return ChildDelivzone|array|mixed the result, formatted by the current formatter + * @return ChildAreaDeliveryModule|array|mixed the result, formatted by the current formatter */ protected function findPkComplex($key, $con) { @@ -211,12 +215,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param mixed $key Primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKey($key) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $key, Criteria::EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $key, Criteria::EQUAL); } /** @@ -224,12 +228,12 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param array $keys The list of primary key to use for the query * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByPrimaryKeys($keys) { - return $this->addUsingAlias(DelivzoneTableMap::ID, $keys, Criteria::IN); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $keys, Criteria::IN); } /** @@ -248,18 +252,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterById($id = null, $comparison = null) { if (is_array($id)) { $useMinMax = false; if (isset($id['min'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($id['max'])) { - $this->addUsingAlias(DelivzoneTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -270,7 +274,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::ID, $id, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $id, $comparison); } /** @@ -291,18 +295,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByAreaId($areaId = null, $comparison = null) { if (is_array($areaId)) { $useMinMax = false; if (isset($areaId['min'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -313,36 +317,50 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::AREA_ID, $areaId, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $areaId, $comparison); } /** - * Filter the query on the delivery column + * Filter the query on the delivery_module_id column * * Example usage: * - * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue' - * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%' + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 * * - * @param string $delivery The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @see filterByModule() + * + * @param mixed $deliveryModuleId 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 ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function filterByDelivery($delivery = null, $comparison = null) + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) { - if (null === $comparison) { - if (is_array($delivery)) { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $delivery)) { - $delivery = str_replace('*', '%', $delivery); - $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(DelivzoneTableMap::DELIVERY, $delivery, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); } /** @@ -363,18 +381,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByCreatedAt($createdAt = null, $comparison = null) { if (is_array($createdAt)) { $useMinMax = false; if (isset($createdAt['min'])) { - $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($createdAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -385,7 +403,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, $createdAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, $createdAt, $comparison); } /** @@ -406,18 +424,18 @@ abstract class DelivzoneQuery extends ModelCriteria * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByUpdatedAt($updatedAt = null, $comparison = null) { if (is_array($updatedAt)) { $useMinMax = false; if (isset($updatedAt['min'])) { - $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($updatedAt['max'])) { - $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -428,7 +446,7 @@ abstract class DelivzoneQuery extends ModelCriteria } } - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, $updatedAt, $comparison); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, $updatedAt, $comparison); } /** @@ -437,20 +455,20 @@ abstract class DelivzoneQuery extends ModelCriteria * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function filterByArea($area, $comparison = null) { if ($area instanceof \Thelia\Model\Area) { return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->getId(), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->getId(), $comparison); } elseif ($area instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this - ->addUsingAlias(DelivzoneTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + ->addUsingAlias(AreaDeliveryModuleTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); } @@ -462,9 +480,9 @@ abstract class DelivzoneQuery extends ModelCriteria * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); $relationMap = $tableMap->getRelation('Area'); @@ -499,7 +517,7 @@ abstract class DelivzoneQuery extends ModelCriteria * * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinArea($relationAlias, $joinType) @@ -507,23 +525,98 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Exclude object from result + * Filter the query by a related \Thelia\Model\Module object * - * @param ChildDelivzone $delivzone Object to remove from the list of results + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ - public function prune($delivzone = null) + public function filterByModule($module, $comparison = null) { - if ($delivzone) { - $this->addUsingAlias(DelivzoneTableMap::ID, $delivzone->getId(), Criteria::NOT_EQUAL); + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // 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, 'Module'); } return $this; } /** - * Deletes all rows from the delivzone table. + * Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildAreaDeliveryModule $areaDeliveryModule Object to remove from the list of results + * + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface + */ + public function prune($areaDeliveryModule = null) + { + if ($areaDeliveryModule) { + $this->addUsingAlias(AreaDeliveryModuleTableMap::ID, $areaDeliveryModule->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). @@ -531,7 +624,7 @@ abstract class DelivzoneQuery extends ModelCriteria public function doDeleteAll(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $affectedRows = 0; // initialize var to track total num of affected rows try { @@ -542,8 +635,8 @@ abstract class DelivzoneQuery extends ModelCriteria // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). - DelivzoneTableMap::clearInstancePool(); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); } catch (PropelException $e) { @@ -555,9 +648,9 @@ abstract class DelivzoneQuery extends ModelCriteria } /** - * Performs a DELETE on the database, given a ChildDelivzone or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a ChildAreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or ChildDelivzone object or primary key or array of primary keys + * @param mixed $values Criteria or ChildAreaDeliveryModule object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -568,13 +661,13 @@ abstract class DelivzoneQuery extends ModelCriteria public function delete(ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } $criteria = $this; // Set the correct dbName - $criteria->setDbName(DelivzoneTableMap::DATABASE_NAME); + $criteria->setDbName(AreaDeliveryModuleTableMap::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows @@ -584,10 +677,10 @@ abstract class DelivzoneQuery extends ModelCriteria $con->beginTransaction(); - DelivzoneTableMap::removeInstanceFromPool($criteria); + AreaDeliveryModuleTableMap::removeInstanceFromPool($criteria); $affectedRows += ModelCriteria::delete($con); - DelivzoneTableMap::clearRelatedInstancePool(); + AreaDeliveryModuleTableMap::clearRelatedInstancePool(); $con->commit(); return $affectedRows; @@ -604,11 +697,11 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of the latest update in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyUpdated($nbDays = 7) { - return $this->addUsingAlias(DelivzoneTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** @@ -616,51 +709,51 @@ abstract class DelivzoneQuery extends ModelCriteria * * @param int $nbDays Maximum age of in days * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function recentlyCreated($nbDays = 7) { - return $this->addUsingAlias(DelivzoneTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + return $this->addUsingAlias(AreaDeliveryModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); } /** * Order by update date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastUpdatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by update date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstUpdatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::UPDATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } /** * Order by create date desc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function lastCreatedFirst() { - return $this->addDescendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addDescendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } /** * Order by create date asc * - * @return ChildDelivzoneQuery The current query, for fluid interface + * @return ChildAreaDeliveryModuleQuery The current query, for fluid interface */ public function firstCreatedFirst() { - return $this->addAscendingOrderByColumn(DelivzoneTableMap::CREATED_AT); + return $this->addAscendingOrderByColumn(AreaDeliveryModuleTableMap::CREATED_AT); } -} // DelivzoneQuery +} // AreaDeliveryModuleQuery diff --git a/core/lib/Thelia/Model/Base/AreaQuery.php b/core/lib/Thelia/Model/Base/AreaQuery.php index f583a30dd..ea4cd8b90 100644 --- a/core/lib/Thelia/Model/Base/AreaQuery.php +++ b/core/lib/Thelia/Model/Base/AreaQuery.php @@ -23,13 +23,13 @@ use Thelia\Model\Map\AreaTableMap; * * @method ChildAreaQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildAreaQuery orderByName($order = Criteria::ASC) Order by the name column - * @method ChildAreaQuery orderByUnit($order = Criteria::ASC) Order by the unit column + * @method ChildAreaQuery orderByPostage($order = Criteria::ASC) Order by the postage column * @method ChildAreaQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAreaQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAreaQuery groupById() Group by the id column * @method ChildAreaQuery groupByName() Group by the name column - * @method ChildAreaQuery groupByUnit() Group by the unit column + * @method ChildAreaQuery groupByPostage() Group by the postage column * @method ChildAreaQuery groupByCreatedAt() Group by the created_at column * @method ChildAreaQuery groupByUpdatedAt() Group by the updated_at column * @@ -41,22 +41,22 @@ use Thelia\Model\Map\AreaTableMap; * @method ChildAreaQuery rightJoinCountry($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Country relation * @method ChildAreaQuery innerJoinCountry($relationAlias = null) Adds a INNER JOIN clause to the query using the Country relation * - * @method ChildAreaQuery leftJoinDelivzone($relationAlias = null) Adds a LEFT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery rightJoinDelivzone($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Delivzone relation - * @method ChildAreaQuery innerJoinDelivzone($relationAlias = null) Adds a INNER JOIN clause to the query using the Delivzone relation + * @method ChildAreaQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildAreaQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation * * @method ChildArea findOne(ConnectionInterface $con = null) Return the first ChildArea matching the query * @method ChildArea findOneOrCreate(ConnectionInterface $con = null) Return the first ChildArea matching the query, or a new ChildArea object populated from the query conditions when no match is found * * @method ChildArea findOneById(int $id) Return the first ChildArea filtered by the id column * @method ChildArea findOneByName(string $name) Return the first ChildArea filtered by the name column - * @method ChildArea findOneByUnit(double $unit) Return the first ChildArea filtered by the unit column + * @method ChildArea findOneByPostage(double $postage) Return the first ChildArea filtered by the postage column * @method ChildArea findOneByCreatedAt(string $created_at) Return the first ChildArea filtered by the created_at column * @method ChildArea findOneByUpdatedAt(string $updated_at) Return the first ChildArea filtered by the updated_at column * * @method array findById(int $id) Return ChildArea objects filtered by the id column * @method array findByName(string $name) Return ChildArea objects filtered by the name column - * @method array findByUnit(double $unit) Return ChildArea objects filtered by the unit column + * @method array findByPostage(double $postage) Return ChildArea objects filtered by the postage column * @method array findByCreatedAt(string $created_at) Return ChildArea objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildArea objects filtered by the updated_at column * @@ -147,7 +147,7 @@ abstract class AreaQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, NAME, UNIT, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; + $sql = 'SELECT ID, NAME, POSTAGE, CREATED_AT, UPDATED_AT FROM area WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -307,16 +307,16 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query on the unit column + * Filter the query on the postage column * * Example usage: * - * $query->filterByUnit(1234); // WHERE unit = 1234 - * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34) - * $query->filterByUnit(array('min' => 12)); // WHERE unit > 12 + * $query->filterByPostage(1234); // WHERE postage = 1234 + * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34) + * $query->filterByPostage(array('min' => 12)); // WHERE postage > 12 * * - * @param mixed $unit The value to use as filter. + * @param mixed $postage 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. @@ -324,16 +324,16 @@ abstract class AreaQuery extends ModelCriteria * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByUnit($unit = null, $comparison = null) + public function filterByPostage($postage = null, $comparison = null) { - if (is_array($unit)) { + if (is_array($postage)) { $useMinMax = false; - if (isset($unit['min'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['min'], Criteria::GREATER_EQUAL); + if (isset($postage['min'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } - if (isset($unit['max'])) { - $this->addUsingAlias(AreaTableMap::UNIT, $unit['max'], Criteria::LESS_EQUAL); + if (isset($postage['max'])) { + $this->addUsingAlias(AreaTableMap::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { @@ -344,7 +344,7 @@ abstract class AreaQuery extends ModelCriteria } } - return $this->addUsingAlias(AreaTableMap::UNIT, $unit, $comparison); + return $this->addUsingAlias(AreaTableMap::POSTAGE, $postage, $comparison); } /** @@ -507,40 +507,40 @@ abstract class AreaQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\Delivzone object + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object * - * @param \Thelia\Model\Delivzone|ObjectCollection $delivzone the related object to use as filter + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAreaQuery The current query, for fluid interface */ - public function filterByDelivzone($delivzone, $comparison = null) + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) { - if ($delivzone instanceof \Thelia\Model\Delivzone) { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { return $this - ->addUsingAlias(AreaTableMap::ID, $delivzone->getAreaId(), $comparison); - } elseif ($delivzone instanceof ObjectCollection) { + ->addUsingAlias(AreaTableMap::ID, $areaDeliveryModule->getAreaId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { return $this - ->useDelivzoneQuery() - ->filterByPrimaryKeys($delivzone->getPrimaryKeys()) + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByDelivzone() only accepts arguments of type \Thelia\Model\Delivzone or Collection'); + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); } } /** - * Adds a JOIN clause to the query using the Delivzone relation + * Adds a JOIN clause to the query using the AreaDeliveryModule relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAreaQuery The current query, for fluid interface */ - public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Delivzone'); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -555,14 +555,14 @@ abstract class AreaQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'Delivzone'); + $this->addJoinObject($join, 'AreaDeliveryModule'); } return $this; } /** - * Use the Delivzone relation Delivzone object + * Use the AreaDeliveryModule relation AreaDeliveryModule object * * @see useQuery() * @@ -570,13 +570,13 @@ abstract class AreaQuery 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\DelivzoneQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AreaDeliveryModuleQuery A secondary query class using the current class as primary query */ - public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinDelivzone($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery'); + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index a154c382d..7f4df77ce 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -17,6 +17,8 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; +use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; use Thelia\Model\GroupModule as ChildGroupModule; use Thelia\Model\GroupModuleQuery as ChildGroupModuleQuery; use Thelia\Model\Module as ChildModule; @@ -121,6 +123,12 @@ abstract class Module implements ActiveRecordInterface protected $collOrdersRelatedByDeliveryModuleId; protected $collOrdersRelatedByDeliveryModuleIdPartial; + /** + * @var ObjectCollection|ChildAreaDeliveryModule[] Collection to store aggregation of ChildAreaDeliveryModule objects. + */ + protected $collAreaDeliveryModules; + protected $collAreaDeliveryModulesPartial; + /** * @var ObjectCollection|ChildGroupModule[] Collection to store aggregation of ChildGroupModule objects. */ @@ -167,6 +175,12 @@ abstract class Module implements ActiveRecordInterface */ protected $ordersRelatedByDeliveryModuleIdScheduledForDeletion = null; + /** + * An array of objects scheduled for deletion. + * @var ObjectCollection + */ + protected $areaDeliveryModulesScheduledForDeletion = null; + /** * An array of objects scheduled for deletion. * @var ObjectCollection @@ -846,6 +860,8 @@ abstract class Module implements ActiveRecordInterface $this->collOrdersRelatedByDeliveryModuleId = null; + $this->collAreaDeliveryModules = null; + $this->collGroupModules = null; $this->collModuleI18ns = null; @@ -1017,6 +1033,23 @@ abstract class Module implements ActiveRecordInterface } } + if ($this->areaDeliveryModulesScheduledForDeletion !== null) { + if (!$this->areaDeliveryModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AreaDeliveryModuleQuery::create() + ->filterByPrimaryKeys($this->areaDeliveryModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->areaDeliveryModulesScheduledForDeletion = null; + } + } + + if ($this->collAreaDeliveryModules !== null) { + foreach ($this->collAreaDeliveryModules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + if ($this->groupModulesScheduledForDeletion !== null) { if (!$this->groupModulesScheduledForDeletion->isEmpty()) { \Thelia\Model\GroupModuleQuery::create() @@ -1273,6 +1306,9 @@ abstract class Module implements ActiveRecordInterface if (null !== $this->collOrdersRelatedByDeliveryModuleId) { $result['OrdersRelatedByDeliveryModuleId'] = $this->collOrdersRelatedByDeliveryModuleId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } + if (null !== $this->collAreaDeliveryModules) { + $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } if (null !== $this->collGroupModules) { $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } @@ -1476,6 +1512,12 @@ abstract class Module implements ActiveRecordInterface } } + foreach ($this->getAreaDeliveryModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAreaDeliveryModule($relObj->copy($deepCopy)); + } + } + foreach ($this->getGroupModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addGroupModule($relObj->copy($deepCopy)); @@ -1535,6 +1577,9 @@ abstract class Module implements ActiveRecordInterface if ('OrderRelatedByDeliveryModuleId' == $relationName) { return $this->initOrdersRelatedByDeliveryModuleId(); } + if ('AreaDeliveryModule' == $relationName) { + return $this->initAreaDeliveryModules(); + } if ('GroupModule' == $relationName) { return $this->initGroupModules(); } @@ -2279,6 +2324,249 @@ abstract class Module implements ActiveRecordInterface return $this->getOrdersRelatedByDeliveryModuleId($query, $con); } + /** + * Clears out the collAreaDeliveryModules collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAreaDeliveryModules() + */ + public function clearAreaDeliveryModules() + { + $this->collAreaDeliveryModules = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAreaDeliveryModules collection loaded partially. + */ + public function resetPartialAreaDeliveryModules($v = true) + { + $this->collAreaDeliveryModulesPartial = $v; + } + + /** + * Initializes the collAreaDeliveryModules collection. + * + * By default this just sets the collAreaDeliveryModules collection to an empty array (like clearcollAreaDeliveryModules()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAreaDeliveryModules($overrideExisting = true) + { + if (null !== $this->collAreaDeliveryModules && !$overrideExisting) { + return; + } + $this->collAreaDeliveryModules = new ObjectCollection(); + $this->collAreaDeliveryModules->setModel('\Thelia\Model\AreaDeliveryModule'); + } + + /** + * Gets an array of ChildAreaDeliveryModule objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildModule is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + * @throws PropelException + */ + public function getAreaDeliveryModules($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + // return empty collection + $this->initAreaDeliveryModules(); + } else { + $collAreaDeliveryModules = ChildAreaDeliveryModuleQuery::create(null, $criteria) + ->filterByModule($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAreaDeliveryModulesPartial && count($collAreaDeliveryModules)) { + $this->initAreaDeliveryModules(false); + + foreach ($collAreaDeliveryModules as $obj) { + if (false == $this->collAreaDeliveryModules->contains($obj)) { + $this->collAreaDeliveryModules->append($obj); + } + } + + $this->collAreaDeliveryModulesPartial = true; + } + + $collAreaDeliveryModules->getInternalIterator()->rewind(); + + return $collAreaDeliveryModules; + } + + if ($partial && $this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $obj) { + if ($obj->isNew()) { + $collAreaDeliveryModules[] = $obj; + } + } + } + + $this->collAreaDeliveryModules = $collAreaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + } + } + + return $this->collAreaDeliveryModules; + } + + /** + * Sets a collection of AreaDeliveryModule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $areaDeliveryModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildModule The current object (for fluent API support) + */ + public function setAreaDeliveryModules(Collection $areaDeliveryModules, ConnectionInterface $con = null) + { + $areaDeliveryModulesToDelete = $this->getAreaDeliveryModules(new Criteria(), $con)->diff($areaDeliveryModules); + + + $this->areaDeliveryModulesScheduledForDeletion = $areaDeliveryModulesToDelete; + + foreach ($areaDeliveryModulesToDelete as $areaDeliveryModuleRemoved) { + $areaDeliveryModuleRemoved->setModule(null); + } + + $this->collAreaDeliveryModules = null; + foreach ($areaDeliveryModules as $areaDeliveryModule) { + $this->addAreaDeliveryModule($areaDeliveryModule); + } + + $this->collAreaDeliveryModules = $areaDeliveryModules; + $this->collAreaDeliveryModulesPartial = false; + + return $this; + } + + /** + * Returns the number of related AreaDeliveryModule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related AreaDeliveryModule objects. + * @throws PropelException + */ + public function countAreaDeliveryModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAreaDeliveryModulesPartial && !$this->isNew(); + if (null === $this->collAreaDeliveryModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAreaDeliveryModules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAreaDeliveryModules()); + } + + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByModule($this) + ->count($con); + } + + return count($this->collAreaDeliveryModules); + } + + /** + * Method called to associate a ChildAreaDeliveryModule object to this object + * through the ChildAreaDeliveryModule foreign key attribute. + * + * @param ChildAreaDeliveryModule $l ChildAreaDeliveryModule + * @return \Thelia\Model\Module The current object (for fluent API support) + */ + public function addAreaDeliveryModule(ChildAreaDeliveryModule $l) + { + if ($this->collAreaDeliveryModules === null) { + $this->initAreaDeliveryModules(); + $this->collAreaDeliveryModulesPartial = true; + } + + if (!in_array($l, $this->collAreaDeliveryModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAreaDeliveryModule($l); + } + + return $this; + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to add. + */ + protected function doAddAreaDeliveryModule($areaDeliveryModule) + { + $this->collAreaDeliveryModules[]= $areaDeliveryModule; + $areaDeliveryModule->setModule($this); + } + + /** + * @param AreaDeliveryModule $areaDeliveryModule The areaDeliveryModule object to remove. + * @return ChildModule The current object (for fluent API support) + */ + public function removeAreaDeliveryModule($areaDeliveryModule) + { + if ($this->getAreaDeliveryModules()->contains($areaDeliveryModule)) { + $this->collAreaDeliveryModules->remove($this->collAreaDeliveryModules->search($areaDeliveryModule)); + if (null === $this->areaDeliveryModulesScheduledForDeletion) { + $this->areaDeliveryModulesScheduledForDeletion = clone $this->collAreaDeliveryModules; + $this->areaDeliveryModulesScheduledForDeletion->clear(); + } + $this->areaDeliveryModulesScheduledForDeletion[]= clone $areaDeliveryModule; + $areaDeliveryModule->setModule(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Module is new, it will return + * an empty collection; or if this Module has previously + * been saved, it will retrieve related AreaDeliveryModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Module. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAreaDeliveryModule[] List of ChildAreaDeliveryModule objects + */ + public function getAreaDeliveryModulesJoinArea($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAreaDeliveryModuleQuery::create(null, $criteria); + $query->joinWith('Area', $joinBehavior); + + return $this->getAreaDeliveryModules($query, $con); + } + /** * Clears out the collGroupModules collection * @@ -2789,6 +3077,11 @@ abstract class Module implements ActiveRecordInterface $o->clearAllReferences($deep); } } + if ($this->collAreaDeliveryModules) { + foreach ($this->collAreaDeliveryModules as $o) { + $o->clearAllReferences($deep); + } + } if ($this->collGroupModules) { foreach ($this->collGroupModules as $o) { $o->clearAllReferences($deep); @@ -2813,6 +3106,10 @@ abstract class Module implements ActiveRecordInterface $this->collOrdersRelatedByDeliveryModuleId->clearIterator(); } $this->collOrdersRelatedByDeliveryModuleId = null; + if ($this->collAreaDeliveryModules instanceof Collection) { + $this->collAreaDeliveryModules->clearIterator(); + } + $this->collAreaDeliveryModules = null; if ($this->collGroupModules instanceof Collection) { $this->collGroupModules->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index 30bdd9178..0ed6c5293 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -52,6 +52,10 @@ use Thelia\Model\Map\ModuleTableMap; * @method ChildModuleQuery rightJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation * @method ChildModuleQuery innerJoinOrderRelatedByDeliveryModuleId($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderRelatedByDeliveryModuleId relation * + * @method ChildModuleQuery leftJoinAreaDeliveryModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation + * @method ChildModuleQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation + * * @method ChildModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation * @method ChildModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation @@ -711,6 +715,79 @@ abstract class ModuleQuery extends ModelCriteria ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByDeliveryModuleId', '\Thelia\Model\OrderQuery'); } + /** + * Filter the query by a related \Thelia\Model\AreaDeliveryModule object + * + * @param \Thelia\Model\AreaDeliveryModule|ObjectCollection $areaDeliveryModule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function filterByAreaDeliveryModule($areaDeliveryModule, $comparison = null) + { + if ($areaDeliveryModule instanceof \Thelia\Model\AreaDeliveryModule) { + return $this + ->addUsingAlias(ModuleTableMap::ID, $areaDeliveryModule->getDeliveryModuleId(), $comparison); + } elseif ($areaDeliveryModule instanceof ObjectCollection) { + return $this + ->useAreaDeliveryModuleQuery() + ->filterByPrimaryKeys($areaDeliveryModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAreaDeliveryModule() only accepts arguments of type \Thelia\Model\AreaDeliveryModule or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the AreaDeliveryModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildModuleQuery The current query, for fluid interface + */ + public function joinAreaDeliveryModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AreaDeliveryModule'); + + // 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, 'AreaDeliveryModule'); + } + + return $this; + } + + /** + * Use the AreaDeliveryModule relation AreaDeliveryModule 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\AreaDeliveryModuleQuery A secondary query class using the current class as primary query + */ + public function useAreaDeliveryModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAreaDeliveryModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AreaDeliveryModule', '\Thelia\Model\AreaDeliveryModuleQuery'); + } + /** * Filter the query by a related \Thelia\Model\GroupModule object * diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 1cf55089f..89eeff249 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -8,6 +8,7 @@ use Thelia\Model\Base\Cart as BaseCart; use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductPriceQuery; use Thelia\Model\CartItemQuery; +use Thelia\TaxEngine\Calculator; class Cart extends BaseCart { @@ -74,9 +75,25 @@ class Cart extends BaseCart ; } - public function getTaxedAmount() + public function getTaxedAmount(Country $country) { + $taxCalculator = new Calculator(); + $total = 0; + + foreach($this->getCartItems() as $cartItem) { + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + /* we round it for the unit price, before the quantity factor */ + $subtotal = round($taxCalculator->load($cartItem->getProduct(), $country)->getTaxedPrice($subtotal), 2); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; + } + + $total -= $this->getDiscount(); + + return $total; } public function getTotalAmount() @@ -84,7 +101,11 @@ class Cart extends BaseCart $total = 0; foreach($this->getCartItems() as $cartItem) { - $total += $cartItem->getPrice()-$cartItem->getDiscount(); + $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); + $subtotal *= $cartItem->getQuantity(); + + $total += $subtotal; } $total -= $this->getDiscount(); diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index 5ef6048a5..a1fb3601a 100755 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -8,6 +8,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Base\CartItem as BaseCartItem; use Thelia\Model\ConfigQuery; use Thelia\Core\Event\CartEvent; +use Thelia\TaxEngine\Calculator; class CartItem extends BaseCartItem { @@ -64,4 +65,20 @@ class CartItem extends BaseCartItem return $this; } + public function getRealPrice() + { + return $this->getPromo() == 1 ? $this->getPromoPrice() : $this->getPrice(); + } + + public function getTaxedPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); + } + + public function getTaxedPromoPrice(Country $country) + { + $taxCalculator = new Calculator(); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); + } } diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index 73d99f591..5724e2df1 100755 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -25,4 +25,4 @@ class CategoryDocument extends BaseCategoryDocument return true; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Delivzone.php b/core/lib/Thelia/Model/Delivzone.php deleted file mode 100755 index 58d4f0f7b..000000000 --- a/core/lib/Thelia/Model/Delivzone.php +++ /dev/null @@ -1,9 +0,0 @@ - array('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID, DelivzoneTableMap::AREA_ID, DelivzoneTableMap::DELIVERY, DelivzoneTableMap::CREATED_AT, DelivzoneTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'AreaId', 'DeliveryModuleId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'areaId', 'deliveryModuleId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID, AreaDeliveryModuleTableMap::AREA_ID, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID, AreaDeliveryModuleTableMap::CREATED_AT, AreaDeliveryModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'AREA_ID', 'DELIVERY_MODULE_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'area_id', 'delivery_module_id', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class DelivzoneTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(DelivzoneTableMap::ID => 0, DelivzoneTableMap::AREA_ID => 1, DelivzoneTableMap::DELIVERY => 2, DelivzoneTableMap::CREATED_AT => 3, DelivzoneTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'AreaId' => 1, 'DeliveryModuleId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'areaId' => 1, 'deliveryModuleId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaDeliveryModuleTableMap::ID => 0, AreaDeliveryModuleTableMap::AREA_ID => 1, AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID => 2, AreaDeliveryModuleTableMap::CREATED_AT => 3, AreaDeliveryModuleTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'AREA_ID' => 1, 'DELIVERY_MODULE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'area_id' => 1, 'delivery_module_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -139,15 +139,15 @@ class DelivzoneTableMap extends TableMap public function initialize() { // attributes - $this->setName('delivzone'); - $this->setPhpName('Delivzone'); - $this->setClassName('\\Thelia\\Model\\Delivzone'); + $this->setName('area_delivery_module'); + $this->setPhpName('AreaDeliveryModule'); + $this->setClassName('\\Thelia\\Model\\AreaDeliveryModule'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', false, null, null); - $this->addColumn('DELIVERY', 'Delivery', 'VARCHAR', true, 45, null); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -157,7 +157,8 @@ class DelivzoneTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); + $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'CASCADE', 'RESTRICT'); } // buildRelations() /** @@ -229,7 +230,7 @@ class DelivzoneTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? DelivzoneTableMap::CLASS_DEFAULT : DelivzoneTableMap::OM_CLASS; + return $withPrefix ? AreaDeliveryModuleTableMap::CLASS_DEFAULT : AreaDeliveryModuleTableMap::OM_CLASS; } /** @@ -243,21 +244,21 @@ class DelivzoneTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (Delivzone object, last column rank) + * @return array (AreaDeliveryModule object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + DelivzoneTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + AreaDeliveryModuleTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = DelivzoneTableMap::OM_CLASS; + $cls = AreaDeliveryModuleTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -280,8 +281,8 @@ class DelivzoneTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = DelivzoneTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = DelivzoneTableMap::getInstanceFromPool($key))) { + $key = AreaDeliveryModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AreaDeliveryModuleTableMap::getInstanceFromPool($key))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj->hydrate($row, 0, true); // rehydrate @@ -290,7 +291,7 @@ class DelivzoneTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - DelivzoneTableMap::addInstanceToPool($obj, $key); + AreaDeliveryModuleTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -311,15 +312,15 @@ class DelivzoneTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(DelivzoneTableMap::ID); - $criteria->addSelectColumn(DelivzoneTableMap::AREA_ID); - $criteria->addSelectColumn(DelivzoneTableMap::DELIVERY); - $criteria->addSelectColumn(DelivzoneTableMap::CREATED_AT); - $criteria->addSelectColumn(DelivzoneTableMap::UPDATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::AREA_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::DELIVERY_MODULE_ID); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(AreaDeliveryModuleTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.AREA_ID'); - $criteria->addSelectColumn($alias . '.DELIVERY'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -334,7 +335,7 @@ class DelivzoneTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME)->getTable(DelivzoneTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME)->getTable(AreaDeliveryModuleTableMap::TABLE_NAME); } /** @@ -342,16 +343,16 @@ class DelivzoneTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(DelivzoneTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(DelivzoneTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new DelivzoneTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AreaDeliveryModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AreaDeliveryModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AreaDeliveryModuleTableMap()); } } /** - * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a AreaDeliveryModule or Criteria object OR a primary key value. * - * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys + * @param mixed $values Criteria or AreaDeliveryModule object or primary key or array of primary keys * which is used to create the DELETE statement * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows @@ -362,25 +363,25 @@ class DelivzoneTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Delivzone) { // it's a model object + } elseif ($values instanceof \Thelia\Model\AreaDeliveryModule) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DelivzoneTableMap::DATABASE_NAME); - $criteria->add(DelivzoneTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(AreaDeliveryModuleTableMap::DATABASE_NAME); + $criteria->add(AreaDeliveryModuleTableMap::ID, (array) $values, Criteria::IN); } - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { DelivzoneTableMap::clearInstancePool(); + if ($values instanceof Criteria) { AreaDeliveryModuleTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { DelivzoneTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { AreaDeliveryModuleTableMap::removeInstanceFromPool($singleval); } } @@ -388,20 +389,20 @@ class DelivzoneTableMap extends TableMap } /** - * Deletes all rows from the delivzone table. + * Deletes all rows from the area_delivery_module table. * * @param ConnectionInterface $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll(ConnectionInterface $con = null) { - return DelivzoneQuery::create()->doDeleteAll($con); + return AreaDeliveryModuleQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a Delivzone or Criteria object. + * Performs an INSERT on the database, given a AreaDeliveryModule or Criteria object. * - * @param mixed $criteria Criteria or Delivzone object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or AreaDeliveryModule object containing data that is used to create the INSERT statement. * @param ConnectionInterface $con the ConnectionInterface connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be @@ -410,22 +411,22 @@ class DelivzoneTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(DelivzoneTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(AreaDeliveryModuleTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Delivzone object + $criteria = $criteria->buildCriteria(); // build Criteria from AreaDeliveryModule object } - if ($criteria->containsKey(DelivzoneTableMap::ID) && $criteria->keyContainsValue(DelivzoneTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzoneTableMap::ID.')'); + if ($criteria->containsKey(AreaDeliveryModuleTableMap::ID) && $criteria->keyContainsValue(AreaDeliveryModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaDeliveryModuleTableMap::ID.')'); } // Set the correct dbName - $query = DelivzoneQuery::create()->mergeWith($criteria); + $query = AreaDeliveryModuleQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -441,7 +442,7 @@ class DelivzoneTableMap extends TableMap return $pk; } -} // DelivzoneTableMap +} // AreaDeliveryModuleTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -DelivzoneTableMap::buildTableMap(); +AreaDeliveryModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AreaTableMap.php b/core/lib/Thelia/Model/Map/AreaTableMap.php index 9dc308de5..3c1bc5ee4 100644 --- a/core/lib/Thelia/Model/Map/AreaTableMap.php +++ b/core/lib/Thelia/Model/Map/AreaTableMap.php @@ -80,9 +80,9 @@ class AreaTableMap extends TableMap const NAME = 'area.NAME'; /** - * the column name for the UNIT field + * the column name for the POSTAGE field */ - const UNIT = 'area.UNIT'; + const POSTAGE = 'area.POSTAGE'; /** * the column name for the CREATED_AT field @@ -106,11 +106,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'name', 'unit', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::UNIT, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'name', 'unit', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'Name', 'Postage', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'name', 'postage', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AreaTableMap::ID, AreaTableMap::NAME, AreaTableMap::POSTAGE, AreaTableMap::CREATED_AT, AreaTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'NAME', 'POSTAGE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'name', 'postage', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -121,11 +121,11 @@ class AreaTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::UNIT => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_PHPNAME => array('Id' => 0, 'Name' => 1, 'Postage' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AreaTableMap::ID => 0, AreaTableMap::NAME => 1, AreaTableMap::POSTAGE => 2, AreaTableMap::CREATED_AT => 3, AreaTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'NAME' => 1, 'POSTAGE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'name' => 1, 'postage' => 2, 'created_at' => 3, 'updated_at' => 4, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); @@ -147,7 +147,7 @@ class AreaTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('NAME', 'Name', 'VARCHAR', true, 100, null); - $this->addColumn('UNIT', 'Unit', 'FLOAT', false, null, null); + $this->addColumn('POSTAGE', 'Postage', 'FLOAT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -158,7 +158,7 @@ class AreaTableMap extends TableMap public function buildRelations() { $this->addRelation('Country', '\\Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countries'); - $this->addRelation('Delivzone', '\\Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); } // buildRelations() /** @@ -181,7 +181,7 @@ class AreaTableMap 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. CountryTableMap::clearInstancePool(); - DelivzoneTableMap::clearInstancePool(); + AreaDeliveryModuleTableMap::clearInstancePool(); } /** @@ -324,13 +324,13 @@ class AreaTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(AreaTableMap::ID); $criteria->addSelectColumn(AreaTableMap::NAME); - $criteria->addSelectColumn(AreaTableMap::UNIT); + $criteria->addSelectColumn(AreaTableMap::POSTAGE); $criteria->addSelectColumn(AreaTableMap::CREATED_AT); $criteria->addSelectColumn(AreaTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.NAME'); - $criteria->addSelectColumn($alias . '.UNIT'); + $criteria->addSelectColumn($alias . '.POSTAGE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index 252cad5cf..1a2f63692 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -186,6 +186,7 @@ class ModuleTableMap extends TableMap { $this->addRelation('OrderRelatedByPaymentModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'payment_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByPaymentModuleId'); $this->addRelation('OrderRelatedByDeliveryModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryModuleId'); + $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); $this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns'); } // buildRelations() @@ -210,6 +211,7 @@ class ModuleTableMap 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. + AreaDeliveryModuleTableMap::clearInstancePool(); GroupModuleTableMap::clearInstancePool(); ModuleI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index f8e6db193..2bc014d27 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -4,7 +4,10 @@ namespace Thelia\Model; use Thelia\Model\Base\Order as BaseOrder; -class Order extends BaseOrder { +class Order extends BaseOrder +{ + public $chosenDeliveryAddress = null; + public $chosenInvoiceModule = null; /** * calculate the total amount diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index cc082e691..ca36fd5e7 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -38,7 +38,7 @@ class Product extends BaseProduct public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()); + return round($taxCalculator->load($this, $country)->getTaxedPrice($this->getRealLowestPrice()), 2); } /** diff --git a/core/lib/Thelia/Model/ProductSaleElements.php b/core/lib/Thelia/Model/ProductSaleElements.php index 184e37d0a..6a95c37f3 100755 --- a/core/lib/Thelia/Model/ProductSaleElements.php +++ b/core/lib/Thelia/Model/ProductSaleElements.php @@ -32,12 +32,12 @@ class ProductSaleElements extends BaseProductSaleElements public function getTaxedPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPrice()), 2); } public function getTaxedPromoPrice(Country $country) { $taxCalculator = new Calculator(); - return $taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()); + return round($taxCalculator->load($this->getProduct(), $country)->getTaxedPrice($this->getPromoPrice()), 2); } } diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 9d76e08f3..a13403482 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -28,6 +28,9 @@ use Symfony\Component\DependencyInjection\ContainerAware; abstract class BaseModule extends ContainerAware { + const CLASSIC_MODULE_TYPE = 1; + const DELIVERY_MODULE_TYPE = 2; + const PAYMENT_MODULE_TYPE = 3; public function __construct() { diff --git a/core/lib/Thelia/Module/DeliveryModuleInterface.php b/core/lib/Thelia/Module/DeliveryModuleInterface.php index ba218ac4d..72f8769bc 100644 --- a/core/lib/Thelia/Module/DeliveryModuleInterface.php +++ b/core/lib/Thelia/Module/DeliveryModuleInterface.php @@ -23,13 +23,16 @@ namespace Thelia\Module; +use Thelia\Model\Country; + interface DeliveryModuleInterface extends BaseModuleInterface { /** - * * calculate and return delivery price * + * @param Country $country + * * @return mixed */ - public function calculate($country = null); + public function calculate(Country $country); } diff --git a/install/faker.php b/install/faker.php index 0b0ea38e2..0303a9a34 100755 --- a/install/faker.php +++ b/install/faker.php @@ -206,7 +206,7 @@ try { $featureList = array(); for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); - $feature->setVisible(rand(1, 10)>7 ? 0 : 1); + $feature->setVisible(1); $feature->setPosition($i); setI18n($faker, $feature); @@ -280,7 +280,7 @@ try { for($i=0; $i<4; $i++) { $folder = new Thelia\Model\Folder(); $folder->setParent(0); - $folder->setVisible(rand(1, 10)>7 ? 0 : 1); + $folder->setVisible(1); $folder->setPosition($i); setI18n($faker, $folder); @@ -297,7 +297,7 @@ try { for($j=1; $jsetParent($folder->getId()); - $subfolder->setVisible(rand(1, 10)>7 ? 0 : 1); + $subfolder->setVisible(1); $subfolder->setPosition($j); setI18n($faker, $subfolder); @@ -458,12 +458,13 @@ function createProduct($faker, Thelia\Model\Category $category, $position, $temp $product = new Thelia\Model\Product(); $product->setRef($category->getId() . '_' . $position . '_' . $faker->randomNumber(8)); $product->addCategory($category); + $product->setVisible(1); $productCategories = $product->getProductCategories(); $productCategories[0]->setDefaultCategory(true); $collection = new \Propel\Runtime\Collection\Collection(); $collection->append($productCategories[0]->setDefaultCategory(true)); $product->setProductCategories($collection); - $product->setVisible(rand(1, 10)>7 ? 0 : 1); + $product->setVisible(1); $product->setPosition($position); $product->setTaxRuleId(1); $product->setTemplate($template); @@ -489,7 +490,7 @@ function createCategory($faker, $parent, $position, &$categoryIdList, $contentId { $category = new Thelia\Model\Category(); $category->setParent($parent); - $category->setVisible(rand(1, 10)>7 ? 0 : 1); + $category->setVisible(1); $category->setPosition($position); setI18n($faker, $category); diff --git a/install/insert.sql b/install/insert.sql index fbb09889b..e50c0bd81 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -31,7 +31,13 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES -(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()); +(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()), +(2, 'Colissimo', 2, 1, 1, 'Colissimo\\Colissimo', NOW(), NOW()); + +INSERT INTO `thelia_2`.`module_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +('2', 'en_US', '72h delivery', NULL, NULL, NULL), +('2', 'fr_FR', 'Livraison par colissimo en 72h', NULL, NULL, NULL); + INSERT INTO `customer_title`(`id`, `by_default`, `position`, `created_at`, `updated_at`) VALUES (1, 1, 1, NOW(), NOW()), @@ -46,13 +52,13 @@ INSERT INTO `customer_title_i18n` (`id`, `locale`, `short`, `long`) VALUES (3, 'fr_FR', 'Mlle', 'Madamemoiselle'), (3, 'en_US', 'Miss', 'Miss'); -INSERT INTO `currency` (`id` ,`code` ,`symbol` ,`rate`, `position` ,`by_default` ,`created_at` ,`updated_at`) +INSERT INTO `currency` (`id`, `code`, `symbol`, `rate`, `position`, `by_default`, `created_at`, `updated_at`) VALUES -(1, 'EUR', '€', '1', 1, '1', NOW() , NOW()), +(1, 'EUR', '€', '1', 1, '1', NOW(), NOW()), (2, 'USD', '$', '1.26', 2, '0', NOW(), NOW()), (3, 'GBP', '£', '0.89', 3, '0', NOW(), NOW()); -INSERT INTO `currency_i18n` (`id` ,`locale` ,`name`) +INSERT INTO `currency_i18n` (`id`, `locale`, `name`) VALUES (1, 'fr_FR', 'Euro'), (1, 'en_US', 'Euro'), diff --git a/install/thelia.sql b/install/thelia.sql index 435bdf8e5..3d003091f 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -21,7 +21,7 @@ CREATE TABLE `category` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product @@ -54,7 +54,7 @@ CREATE TABLE `product` CONSTRAINT `fk_product_template1` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_category @@ -83,7 +83,7 @@ CREATE TABLE `product_category` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- country @@ -108,7 +108,7 @@ CREATE TABLE `country` REFERENCES `area` (`id`) ON UPDATE RESTRICT ON DELETE SET NULL -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- tax @@ -124,7 +124,7 @@ CREATE TABLE `tax` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- tax_rule @@ -138,7 +138,7 @@ CREATE TABLE `tax_rule` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- tax_rule_country @@ -173,7 +173,7 @@ CREATE TABLE `tax_rule_country` REFERENCES `country` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature @@ -189,7 +189,7 @@ CREATE TABLE `feature` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature_av @@ -211,7 +211,7 @@ CREATE TABLE `feature_av` REFERENCES `feature` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature_product @@ -248,7 +248,7 @@ CREATE TABLE `feature_product` REFERENCES `feature_av` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature_template @@ -274,7 +274,7 @@ CREATE TABLE `feature_template` CONSTRAINT `fk_feature_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute @@ -289,7 +289,7 @@ CREATE TABLE `attribute` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute_av @@ -311,7 +311,7 @@ CREATE TABLE `attribute_av` REFERENCES `attribute` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute_combination @@ -343,7 +343,7 @@ CREATE TABLE `attribute_combination` CONSTRAINT `fk_attribute_combination_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) REFERENCES `product_sale_elements` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_sale_elements @@ -370,7 +370,7 @@ CREATE TABLE `product_sale_elements` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute_template @@ -396,7 +396,7 @@ CREATE TABLE `attribute_template` CONSTRAINT `fk_attribute_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- config @@ -415,7 +415,7 @@ CREATE TABLE `config` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`name`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- customer @@ -449,7 +449,7 @@ CREATE TABLE `customer` REFERENCES `customer_title` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- address @@ -496,7 +496,7 @@ CREATE TABLE `address` REFERENCES `country` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- customer_title @@ -512,7 +512,7 @@ CREATE TABLE `customer_title` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- lang @@ -538,7 +538,7 @@ CREATE TABLE `lang` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder @@ -558,7 +558,7 @@ CREATE TABLE `folder` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content @@ -577,7 +577,7 @@ CREATE TABLE `content` `version_created_at` DATETIME, `version_created_by` VARCHAR(100), PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_image @@ -600,7 +600,7 @@ CREATE TABLE `product_image` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_document @@ -623,7 +623,7 @@ CREATE TABLE `product_document` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order @@ -701,7 +701,7 @@ CREATE TABLE `order` REFERENCES `lang` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- currency @@ -720,7 +720,7 @@ CREATE TABLE `currency` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order_address @@ -745,7 +745,7 @@ CREATE TABLE `order_address` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order_product @@ -774,7 +774,7 @@ CREATE TABLE `order_product` REFERENCES `order` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order_status @@ -789,7 +789,7 @@ CREATE TABLE `order_status` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order_feature @@ -812,7 +812,7 @@ CREATE TABLE `order_feature` REFERENCES `order_product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- module @@ -832,7 +832,7 @@ CREATE TABLE `module` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- accessory @@ -861,7 +861,7 @@ CREATE TABLE `accessory` REFERENCES `product` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- area @@ -873,33 +873,39 @@ CREATE TABLE `area` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, - `unit` FLOAT, + `postage` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- delivzone +-- area_delivery_module -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `delivzone`; +DROP TABLE IF EXISTS `area_delivery_module`; -CREATE TABLE `delivzone` +CREATE TABLE `area_delivery_module` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `area_id` INTEGER, - `delivery` VARCHAR(45) NOT NULL, + `area_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_delivzone_area_id` (`area_id`), - CONSTRAINT `fk_delivzone_area_id` + INDEX `idx_area_delivery_module_area_id` (`area_id`), + INDEX `idx_area_delivery_module_delivery_module_id` (`delivery_module_id`), + CONSTRAINT `fk_area_delivery_module_area_id` FOREIGN KEY (`area_id`) REFERENCES `area` (`id`) ON UPDATE RESTRICT - ON DELETE SET NULL -) ENGINE=InnoDB CHARACTER SET='utf8'; + ON DELETE CASCADE, + CONSTRAINT `idx_area_delivery_module_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- group @@ -915,7 +921,7 @@ CREATE TABLE `group` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- resource @@ -931,7 +937,7 @@ CREATE TABLE `resource` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `code_UNIQUE` (`code`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- admin @@ -953,7 +959,7 @@ CREATE TABLE `admin` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- admin_group @@ -981,7 +987,7 @@ CREATE TABLE `admin_group` REFERENCES `admin` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- group_resource @@ -1011,7 +1017,7 @@ CREATE TABLE `group_resource` REFERENCES `resource` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- group_module @@ -1040,7 +1046,7 @@ CREATE TABLE `group_module` REFERENCES `module` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- message @@ -1060,7 +1066,7 @@ CREATE TABLE `message` `version_created_by` VARCHAR(100), PRIMARY KEY (`id`), UNIQUE INDEX `name_UNIQUE` (`name`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- coupon @@ -1096,7 +1102,7 @@ CREATE TABLE `coupon` INDEX `idx_is_removing_postage` (`is_removing_postage`), INDEX `idx_max_usage` (`max_usage`), INDEX `idx_is_available_on_special_offers` (`is_available_on_special_offers`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- coupon_order @@ -1118,7 +1124,7 @@ CREATE TABLE `coupon_order` REFERENCES `order` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- admin_log @@ -1137,7 +1143,7 @@ CREATE TABLE `admin_log` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_folder @@ -1166,7 +1172,7 @@ CREATE TABLE `content_folder` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- cart @@ -1203,7 +1209,7 @@ CREATE TABLE `cart` CONSTRAINT `fk_cart_currency_id` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- cart_item @@ -1238,7 +1244,7 @@ CREATE TABLE `cart_item` CONSTRAINT `fk_cart_item_product_sale_elements_id` FOREIGN KEY (`product_sale_elements_id`) REFERENCES `product_sale_elements` (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_price @@ -1265,7 +1271,7 @@ CREATE TABLE `product_price` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_image @@ -1288,7 +1294,7 @@ CREATE TABLE `category_image` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_image @@ -1311,7 +1317,7 @@ CREATE TABLE `folder_image` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_image @@ -1334,7 +1340,7 @@ CREATE TABLE `content_image` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_document @@ -1357,7 +1363,7 @@ CREATE TABLE `category_document` REFERENCES `category` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_document @@ -1380,7 +1386,7 @@ CREATE TABLE `content_document` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_document @@ -1403,7 +1409,7 @@ CREATE TABLE `folder_document` REFERENCES `folder` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_associated_content @@ -1432,7 +1438,7 @@ CREATE TABLE `product_associated_content` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_associated_content @@ -1461,7 +1467,7 @@ CREATE TABLE `category_associated_content` REFERENCES `content` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- rewriting_url @@ -1488,7 +1494,7 @@ CREATE TABLE `rewriting_url` REFERENCES `rewriting_url` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- rewriting_argument @@ -1510,7 +1516,7 @@ CREATE TABLE `rewriting_argument` REFERENCES `rewriting_url` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- template @@ -1524,7 +1530,7 @@ CREATE TABLE `template` `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_i18n @@ -1545,7 +1551,7 @@ CREATE TABLE `category_i18n` FOREIGN KEY (`id`) REFERENCES `category` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_i18n @@ -1566,7 +1572,7 @@ CREATE TABLE `product_i18n` FOREIGN KEY (`id`) REFERENCES `product` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- country_i18n @@ -1587,7 +1593,7 @@ CREATE TABLE `country_i18n` FOREIGN KEY (`id`) REFERENCES `country` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- tax_i18n @@ -1606,7 +1612,7 @@ CREATE TABLE `tax_i18n` FOREIGN KEY (`id`) REFERENCES `tax` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- tax_rule_i18n @@ -1625,7 +1631,7 @@ CREATE TABLE `tax_rule_i18n` FOREIGN KEY (`id`) REFERENCES `tax_rule` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature_i18n @@ -1646,7 +1652,7 @@ CREATE TABLE `feature_i18n` FOREIGN KEY (`id`) REFERENCES `feature` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- feature_av_i18n @@ -1667,7 +1673,7 @@ CREATE TABLE `feature_av_i18n` FOREIGN KEY (`id`) REFERENCES `feature_av` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute_i18n @@ -1688,7 +1694,7 @@ CREATE TABLE `attribute_i18n` FOREIGN KEY (`id`) REFERENCES `attribute` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- attribute_av_i18n @@ -1709,7 +1715,7 @@ CREATE TABLE `attribute_av_i18n` FOREIGN KEY (`id`) REFERENCES `attribute_av` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- config_i18n @@ -1730,7 +1736,7 @@ CREATE TABLE `config_i18n` FOREIGN KEY (`id`) REFERENCES `config` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- customer_title_i18n @@ -1749,7 +1755,7 @@ CREATE TABLE `customer_title_i18n` FOREIGN KEY (`id`) REFERENCES `customer_title` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_i18n @@ -1770,7 +1776,7 @@ CREATE TABLE `folder_i18n` FOREIGN KEY (`id`) REFERENCES `folder` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_i18n @@ -1791,7 +1797,7 @@ CREATE TABLE `content_i18n` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_image_i18n @@ -1812,7 +1818,7 @@ CREATE TABLE `product_image_i18n` FOREIGN KEY (`id`) REFERENCES `product_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_document_i18n @@ -1833,7 +1839,7 @@ CREATE TABLE `product_document_i18n` FOREIGN KEY (`id`) REFERENCES `product_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- currency_i18n @@ -1851,7 +1857,7 @@ CREATE TABLE `currency_i18n` FOREIGN KEY (`id`) REFERENCES `currency` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- order_status_i18n @@ -1872,7 +1878,7 @@ CREATE TABLE `order_status_i18n` FOREIGN KEY (`id`) REFERENCES `order_status` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- module_i18n @@ -1893,7 +1899,7 @@ CREATE TABLE `module_i18n` FOREIGN KEY (`id`) REFERENCES `module` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- group_i18n @@ -1914,7 +1920,7 @@ CREATE TABLE `group_i18n` FOREIGN KEY (`id`) REFERENCES `group` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- resource_i18n @@ -1935,7 +1941,7 @@ CREATE TABLE `resource_i18n` FOREIGN KEY (`id`) REFERENCES `resource` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- message_i18n @@ -1956,7 +1962,7 @@ CREATE TABLE `message_i18n` FOREIGN KEY (`id`) REFERENCES `message` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- coupon_i18n @@ -1976,7 +1982,7 @@ CREATE TABLE `coupon_i18n` FOREIGN KEY (`id`) REFERENCES `coupon` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_image_i18n @@ -1997,7 +2003,7 @@ CREATE TABLE `category_image_i18n` FOREIGN KEY (`id`) REFERENCES `category_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_image_i18n @@ -2018,7 +2024,7 @@ CREATE TABLE `folder_image_i18n` FOREIGN KEY (`id`) REFERENCES `folder_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_image_i18n @@ -2039,7 +2045,7 @@ CREATE TABLE `content_image_i18n` FOREIGN KEY (`id`) REFERENCES `content_image` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_document_i18n @@ -2060,7 +2066,7 @@ CREATE TABLE `category_document_i18n` FOREIGN KEY (`id`) REFERENCES `category_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_document_i18n @@ -2081,7 +2087,7 @@ CREATE TABLE `content_document_i18n` FOREIGN KEY (`id`) REFERENCES `content_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_document_i18n @@ -2102,7 +2108,7 @@ CREATE TABLE `folder_document_i18n` FOREIGN KEY (`id`) REFERENCES `folder_document` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- template_i18n @@ -2120,7 +2126,7 @@ CREATE TABLE `template_i18n` FOREIGN KEY (`id`) REFERENCES `template` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- category_version @@ -2144,7 +2150,7 @@ CREATE TABLE `category_version` FOREIGN KEY (`id`) REFERENCES `category` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- product_version @@ -2170,7 +2176,7 @@ CREATE TABLE `product_version` FOREIGN KEY (`id`) REFERENCES `product` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- folder_version @@ -2194,7 +2200,7 @@ CREATE TABLE `folder_version` FOREIGN KEY (`id`) REFERENCES `folder` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- content_version @@ -2217,7 +2223,7 @@ CREATE TABLE `content_version` FOREIGN KEY (`id`) REFERENCES `content` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- message_version @@ -2240,7 +2246,7 @@ CREATE TABLE `message_version` FOREIGN KEY (`id`) REFERENCES `message` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; -- --------------------------------------------------------------------- -- coupon_version @@ -2270,7 +2276,7 @@ CREATE TABLE `coupon_version` FOREIGN KEY (`id`) REFERENCES `coupon` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB CHARACTER SET='utf8'; +) ENGINE=InnoDB; # This restores the fkey checks, after having unset them earlier SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/config/schema.xml b/local/config/schema.xml index eac865408..688fc1fa4 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -1,1197 +1,1199 @@ - + - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - -
-
\ No newline at end of file + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php index 4d24cc059..2fe9cd0b9 100644 --- a/local/modules/Colissimo/Colissimo.php +++ b/local/modules/Colissimo/Colissimo.php @@ -25,6 +25,7 @@ namespace Colissimo; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; +use Thelia\Model\Country; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; @@ -57,10 +58,10 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface * * calculate and return delivery price * - * @param null $country + * @param Country $country * @return mixed */ - public function calculate($country = null) + public function calculate(Country $country) { // TODO: Implement calculate() method. return 2; diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index 626114d2a..723cf8242 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -39,8 +39,8 @@
-
diff --git a/web/index_dev.php b/web/index_dev.php index bb90e6ab0..16c7d5f71 100755 --- a/web/index_dev.php +++ b/web/index_dev.php @@ -51,5 +51,7 @@ $response = $thelia->handle($request)->prepare($request)->send(); $thelia->terminate($request, $response); -echo "\n"; -echo "\n"; +if (strstr($response->headers->get('content-type'), 'text/html') !== false) { + echo "\n"; + echo "\n"; +}