diff --git a/Readme.md b/Readme.md index abb8ccd30..fe90c50cc 100755 --- a/Readme.md +++ b/Readme.md @@ -22,7 +22,7 @@ Requirements * gd * curl * safe_mode off - * memory_limit at least 128M, preferably 256. + * memory_limit at least 150M, preferably 256. * post_max_size 20M * upload_max_filesize 2M * apache 2 @@ -44,8 +44,10 @@ Installation ------------ ``` bash +$ git clone https://github.com/thelia/thelia.git +$ cd thelia $ curl -sS https://getcomposer.org/installer | php -$ php composer.phar create-project thelia/thelia path/ dev-master +$ php composer.phar install --prefer-dist --optimize-autoloader ``` Finish the installation using cli tools : @@ -56,14 +58,6 @@ $ php Thelia thelia:install You just have to follow all instructions. -Documentation -------------- - -Thelia documentation is available at http://doc.thelia.net - -The documentation is also in beta version and some part can be obsolete cause to some refactor. - - Contribute ---------- diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index c376a78b7..1f04e12f6 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -30,6 +30,7 @@ use Thelia\Core\Event\UpdateSeoEvent; use Thelia\Exception\UrlRewritingException; use Thelia\Form\Exception\FormValidationException; +use \Thelia\Model\Tools\UrlRewritingTrait; class BaseAction { @@ -81,8 +82,8 @@ class BaseAction /** * Changes SEO Fields for an object. * - * @param ModelCriteria $query - * @param UpdateSeoEvent $event + * @param ModelCriteria $query + * @param UpdateSeoEvent $event * * @return mixed */ @@ -104,7 +105,7 @@ class BaseAction // Update the rewritten URL, if required try { $object->setRewrittenUrl($event->getLocale(), $event->getUrl()); - } catch (UrlRewritingException $e) { + } catch(UrlRewritingException $e) { throw new FormValidationException($e->getMessage(), $e->getCode()); } diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 4c76002ac..1b77eb488 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -28,7 +28,6 @@ use Thelia\Condition\ConditionFactory; use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Core\Event\Coupon\CouponConsumeEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; -use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Request; use Thelia\Coupon\CouponFactory; @@ -37,7 +36,6 @@ use Thelia\Condition\ConditionCollection; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon as CouponModel; use Thelia\Model\CouponQuery; -use Thelia\Model\OrderCoupon; /** * Created by JetBrains PhpStorm. @@ -124,20 +122,23 @@ class Coupon extends BaseAction implements EventSubscriberInterface $request->getSession()->setConsumedCoupons($consumedCoupons); $totalDiscount = $couponManager->getDiscount(); + // @todo insert false product in cart with the name of the coupon and the discount as negative price + + // Decrement coupon quantity + // @todo move this part in after order event + $couponQuery = CouponQuery::create(); + $couponModel = $couponQuery->findOneByCode($coupon->getCode()); + $couponManager->decrementQuantity($couponModel); $request ->getSession() ->getCart() ->setDiscount($totalDiscount) ->save(); - $request - ->getSession() - ->getOrder() - ->setDiscount($totalDiscount) - ->save(); } } + $event->setIsValid($isValid); $event->setDiscount($totalDiscount); } @@ -206,68 +207,6 @@ class Coupon extends BaseAction implements EventSubscriberInterface $event->setCouponModel($coupon); } - /** - * @param \Thelia\Core\Event\Order\OrderEvent $event - */ - public function testFreePostage(OrderEvent $event) - { - /** @var CouponManager $couponManager */ - $couponManager = $this->container->get('thelia.coupon.manager'); - - if($couponManager->isCouponRemovingPostage()) { - $order = $event->getOrder(); - - $order->setPostage(0); - - $event->setOrder($order); - - $event->stopPropagation(); - } - } - - /** - * @param \Thelia\Core\Event\Order\OrderEvent $event - */ - public function afterOrder(OrderEvent $event) - { - $request = $this->container->get('request'); - - /** @var CouponManager $couponManager */ - $couponManager = $this->container->get('thelia.coupon.manager'); - - $consumedCoupons = $request->getSession()->getConsumedCoupons(); - - if (is_array($consumedCoupons)) { - foreach($consumedCoupons as $couponCode) { - $couponQuery = CouponQuery::create(); - $couponModel = $couponQuery->findOneByCode($couponCode); - $couponModel->setLocale($request->getSession()->getLang()->getLocale()); - - /* decrease coupon quantity */ - $couponManager->decrementQuantity($couponModel); - - /* memorize coupon */ - $orderCoupon = new OrderCoupon(); - $orderCoupon->setOrder($event->getOrder()) - ->setCode($couponModel->getCode()) - ->setType($couponModel->getType()) - ->setAmount($couponModel->getAmount()) - - ->setTitle($couponModel->getTitle()) - ->setShortDescription($couponModel->getShortDescription()) - ->setDescription($couponModel->getDescription()) - - ->setExpirationDate($couponModel->getExpirationDate()) - ->setIsCumulative($couponModel->getIsCumulative()) - ->setIsRemovingPostage($couponModel->getIsRemovingPostage()) - ->setIsAvailableOnSpecialOffers($couponModel->getIsAvailableOnSpecialOffers()) - ->setSerializedConditions($couponModel->getSerializedConditions()) - ; - $orderCoupon->save(); - } - } - } - /** * Returns an array of event names this subscriber listens to. * @@ -294,9 +233,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface TheliaEvents::COUPON_CREATE => array("create", 128), TheliaEvents::COUPON_UPDATE => array("update", 128), TheliaEvents::COUPON_CONSUME => array("consume", 128), - TheliaEvents::COUPON_CONDITION_UPDATE => array("updateCondition", 128), - TheliaEvents::ORDER_SET_POSTAGE => array("testFreePostage", 256), - TheliaEvents::ORDER_BEFORE_PAYMENT => array("afterOrder", 128), + TheliaEvents::COUPON_CONDITION_UPDATE => array("updateCondition", 128) ); } } diff --git a/core/lib/Thelia/Action/MailingSystem.php b/core/lib/Thelia/Action/MailingSystem.php index 2f62d749b..f46352d53 100644 --- a/core/lib/Thelia/Action/MailingSystem.php +++ b/core/lib/Thelia/Action/MailingSystem.php @@ -35,7 +35,7 @@ class MailingSystem extends BaseAction implements EventSubscriberInterface */ public function update(MailingSystemEvent $event) { - if ($event->getEnabled()) { + if($event->getEnabled()) { ConfigQuery::enableSmtp(); } else { ConfigQuery::disableSmtp(); diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 9d7daaba7..0699c14d1 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -30,7 +30,6 @@ use Thelia\Core\Event\Cart\CartEvent; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Coupon\CouponManager; use Thelia\Exception\TheliaProcessException; use Thelia\Model\AddressQuery; use Thelia\Model\ConfigQuery; @@ -74,17 +73,6 @@ class Order extends BaseAction implements EventSubscriberInterface $order = $event->getOrder(); $order->setDeliveryModuleId($event->getDeliveryModule()); - - $event->setOrder($order); - } - - /** - * @param \Thelia\Core\Event\Order\OrderEvent $event - */ - public function setPostage(OrderEvent $event) - { - $order = $event->getOrder(); - $order->setPostage($event->getPostage()); $event->setOrder($order); @@ -190,11 +178,6 @@ class Order extends BaseAction implements EventSubscriberInterface OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId() ); - /* memorize discount */ - $placedOrder->setDiscount( - $cart->getDiscount() - ); - $placedOrder->save($con); /* fulfill order_products and decrease stock */ @@ -279,6 +262,8 @@ class Order extends BaseAction implements EventSubscriberInterface } } + /* discount @todo */ + $con->commit(); $this->getDispatcher()->dispatch(TheliaEvents::ORDER_BEFORE_PAYMENT, new OrderEvent($placedOrder)); @@ -288,7 +273,7 @@ class Order extends BaseAction implements EventSubscriberInterface $sessionOrder = new \Thelia\Model\Order(); $event->setOrder($sessionOrder); $event->setPlacedOrder($placedOrder); - $this->getSession()->setOrder($placedOrder); + $this->getSession()->setOrder($sessionOrder); /* empty cart */ $this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest()))); @@ -305,7 +290,7 @@ class Order extends BaseAction implements EventSubscriberInterface { $contact_email = ConfigQuery::read('contact_email'); - if ($contact_email) { + if($contact_email) { $message = MessageQuery::create() ->filterByName('order_confirmation') @@ -427,7 +412,6 @@ class Order extends BaseAction implements EventSubscriberInterface return array( TheliaEvents::ORDER_SET_DELIVERY_ADDRESS => array("setDeliveryAddress", 128), TheliaEvents::ORDER_SET_DELIVERY_MODULE => array("setDeliveryModule", 128), - TheliaEvents::ORDER_SET_POSTAGE => array("setPostage", 128), TheliaEvents::ORDER_SET_INVOICE_ADDRESS => array("setInvoiceAddress", 128), TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), TheliaEvents::ORDER_PAY => array("create", 128), diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index a5defe5cb..6d477855b 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -131,6 +131,7 @@ class Product extends BaseAction implements EventSubscriberInterface return $this->genericUpdateSeo(ProductQuery::create(), $event); } + /** * Delete a product entry * diff --git a/core/lib/Thelia/Action/ProductSaleElement.php b/core/lib/Thelia/Action/ProductSaleElement.php index 875dbcc1d..cad3be374 100644 --- a/core/lib/Thelia/Action/ProductSaleElement.php +++ b/core/lib/Thelia/Action/ProductSaleElement.php @@ -209,7 +209,8 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface if ($product->countSaleElements() <= 0) { // If we just deleted the last PSE, create a default one $product->createProductSaleElement($con, 0, 0, 0, $event->getCurrencyId(), true); - } elseif ($pse->getIsDefault()) { + } + elseif ($pse->getIsDefault()) { // If we deleted the default PSE, make the last created one the default $pse = ProductSaleElementsQuery::create() @@ -237,8 +238,8 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface * * @param ProductCombinationGenerationEvent $event */ - public function generateCombinations(ProductCombinationGenerationEvent $event) - { + public function generateCombinations(ProductCombinationGenerationEvent $event) { + $con = Propel::getWriteConnection(ProductSaleElementsTableMap::DATABASE_NAME); $con->beginTransaction(); @@ -251,7 +252,7 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface $isDefault = true; // Create all combinations - foreach ($event->getCombinations() as $combinationAttributesAvIds) { + foreach($event->getCombinations() as $combinationAttributesAvIds) { // Create the PSE $saleElement = $event->getProduct()->createProductSaleElement( @@ -275,7 +276,8 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface // Store all the stuff ! $con->commit(); - } catch (\Exception $ex) { + } + catch (\Exception $ex) { $con->rollback(); @@ -286,9 +288,9 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface /** * Create a combination for a given product sale element * - * @param ConnectionInterface $con the Propel connection - * @param ProductSaleElement $salesElement the product sale element - * @param unknown $combinationAttributes an array oif attributes av IDs + * @param ConnectionInterface $con the Propel connection + * @param ProductSaleElement $salesElement the product sale element + * @param unknown $combinationAttributes an array oif attributes av IDs */ protected function createCombination(ConnectionInterface $con, ProductSaleElements $salesElement, $combinationAttributes) { diff --git a/core/lib/Thelia/Command/AdminUpdatePasswordCommand.php b/core/lib/Thelia/Command/AdminUpdatePasswordCommand.php index 690f4362b..cab25d13f 100644 --- a/core/lib/Thelia/Command/AdminUpdatePasswordCommand.php +++ b/core/lib/Thelia/Command/AdminUpdatePasswordCommand.php @@ -32,6 +32,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\AdminQuery; use Thelia\Tools\Password; + /** * command line for updating admin password * @@ -71,15 +72,18 @@ class AdminUpdatePasswordCommand extends ContainerAwareCommand { $login = $input->getArgument('login'); + if (null === $admin = AdminQuery::create()->filterByLogin($login)->findOne()) { throw new \RuntimeException(sprintf('Admin with login %s does not exists', $login)); } + $password = $input->getOption('password') ?: Password::generateRandom(); $event = new AdministratorUpdatePasswordEvent($admin); $event->setPassword($password); + $this-> getContainer() ->get('event_dispatcher') @@ -95,3 +99,4 @@ class AdminUpdatePasswordCommand extends ContainerAwareCommand } } + diff --git a/core/lib/Thelia/Config/I18n/en_US.php b/core/lib/Thelia/Config/I18n/en_US.php index 2b8b661c2..ce333ddb4 100644 --- a/core/lib/Thelia/Config/I18n/en_US.php +++ b/core/lib/Thelia/Config/I18n/en_US.php @@ -1,14 +1,14 @@ 'Delivery module', - 'Quantity' => 'Quantity', - 'Product' => 'Product', - 'Unit. price' => 'Unit. price', - 'Tax' => 'Tax', - 'Unit taxed price' => 'Unit taxed price', - 'Taxed total' => 'Taxed total', - 'Payment module' => 'Payment module', - 'Postage' => 'Postage', - 'Total' => 'Total', + 'Delivery module' => 'Delivery module', + 'Quantity' => 'Quantity', + 'Product' => 'Product', + 'Unit. price' => 'Unit. price', + 'Tax' => 'Tax', + 'Unit taxed price' => 'Unit taxed price', + 'Taxed total' => 'Taxed total', + 'Payment module' => 'Payment module', + 'Postage' => 'Postage', + 'Total' => 'Total', ); diff --git a/core/lib/Thelia/Config/I18n/es_ES.php b/core/lib/Thelia/Config/I18n/es_ES.php index 0a749d4c1..f1a85bd6a 100644 --- a/core/lib/Thelia/Config/I18n/es_ES.php +++ b/core/lib/Thelia/Config/I18n/es_ES.php @@ -1,36 +1,36 @@ 'Combination builder', - 'Title' => 'Title', - 'City' => 'City', - 'Zip code' => 'Zip code', - 'Country' => 'Country', - 'Phone' => 'Phone', - 'Login' => 'Login', - 'Password' => 'Password', - 'Profile' => 'Profile', - 'Postage' => 'Postage', - 'Add to all product templates' => 'Add to all product templates', - 'Quantity' => 'Quantity', - 'Name' => 'Name', - 'Value' => 'Value', - 'Subject' => 'Subject', - 'Company' => 'Company', - 'Description' => 'Description', - 'Language name' => 'Language name', - 'ISO 639 Code' => 'ISO 639 Code', - 'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :', - 'Host' => 'Host', - 'Port' => 'Port', - 'Encryption' => 'Encryption', - 'Username' => 'Username', - 'Timeout' => 'Timeout', - 'Source IP' => 'Source IP', - 'Email address' => 'Email address', - 'Firstname' => 'Firstname', - 'Lastname' => 'Lastname', - 'Additional address' => 'Additional address', - 'Reference' => 'Reference', - 'EAN Code' => 'EAN Code', + 'Combination builder' => 'Combination builder', + 'Title' => 'Title', + 'City' => 'City', + 'Zip code' => 'Zip code', + 'Country' => 'Country', + 'Phone' => 'Phone', + 'Login' => 'Login', + 'Password' => 'Password', + 'Profile' => 'Profile', + 'Postage' => 'Postage', + 'Add to all product templates' => 'Add to all product templates', + 'Quantity' => 'Quantity', + 'Name' => 'Name', + 'Value' => 'Value', + 'Subject' => 'Subject', + 'Company' => 'Company', + 'Description' => 'Description', + 'Language name' => 'Language name', + 'ISO 639 Code' => 'ISO 639 Code', + 'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :', + 'Host' => 'Host', + 'Port' => 'Port', + 'Encryption' => 'Encryption', + 'Username' => 'Username', + 'Timeout' => 'Timeout', + 'Source IP' => 'Source IP', + 'Email address' => 'Email address', + 'Firstname' => 'Firstname', + 'Lastname' => 'Lastname', + 'Additional address' => 'Additional address', + 'Reference' => 'Reference', + 'EAN Code' => 'EAN Code', ); diff --git a/core/lib/Thelia/Config/I18n/fr_FR.php b/core/lib/Thelia/Config/I18n/fr_FR.php index 188d6f90a..7eb24949a 100644 --- a/core/lib/Thelia/Config/I18n/fr_FR.php +++ b/core/lib/Thelia/Config/I18n/fr_FR.php @@ -23,4 +23,4 @@ return array( -); +); \ No newline at end of file diff --git a/core/lib/Thelia/Config/I18n/it_IT.php b/core/lib/Thelia/Config/I18n/it_IT.php index 188d6f90a..7eb24949a 100644 --- a/core/lib/Thelia/Config/I18n/it_IT.php +++ b/core/lib/Thelia/Config/I18n/it_IT.php @@ -23,4 +23,4 @@ return array( -); +); \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/loop.xml b/core/lib/Thelia/Config/Resources/loop.xml index 0e5414ad8..c253b5fb4 100644 --- a/core/lib/Thelia/Config/Resources/loop.xml +++ b/core/lib/Thelia/Config/Resources/loop.xml @@ -28,7 +28,6 @@ - diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 7e3f936fc..028d5ab15 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -443,6 +443,7 @@ abstract class AbstractCrudController extends BaseAdminController $ex ); + //return $this->renderEditionTemplate(); } diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php index 52c4bbda4..9918f8a2f 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -53,7 +53,7 @@ abstract class AbstractSeoCrudController extends AbstractCrudController * * @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY * @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION - * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO + * @param string $updateSeoEventIdentifier the dispatched update SEO change TheliaEvent identifier, or null if the object has no SEO. Example: TheliaEvents::MESSAGE_UPDATE_SEO */ public function __construct( $objectName, @@ -134,8 +134,7 @@ abstract class AbstractSeoCrudController extends AbstractCrudController * * @param unknown $object */ - protected function hydrateSeoForm($object) - { + protected function hydrateSeoForm($object){ // The "SEO" tab form $locale = $object->getLocale(); $data = array( @@ -228,6 +227,8 @@ abstract class AbstractSeoCrudController extends AbstractCrudController $ex ); + + // At this point, the form has errors, and should be redisplayed. return $this->renderEditionTemplate(); } diff --git a/core/lib/Thelia/Controller/Admin/AddressController.php b/core/lib/Thelia/Controller/Admin/AddressController.php index c818ba492..3e2812bd0 100644 --- a/core/lib/Thelia/Controller/Admin/AddressController.php +++ b/core/lib/Thelia/Controller/Admin/AddressController.php @@ -98,7 +98,7 @@ class AddressController extends AbstractCrudController /** * Fills in the form data array * - * @param unknown $object + * @param unknown $object * @return multitype:NULL */ protected function createFormDataArray($object) @@ -309,8 +309,7 @@ class AddressController extends AbstractCrudController $this->redirectToEditionTemplate(); } - protected function getCustomerId() - { + protected function getCustomerId() { if (null !== $address = $this->getExistingObject()) return $address->getCustomerId(); else diff --git a/core/lib/Thelia/Controller/Admin/AttributeController.php b/core/lib/Thelia/Controller/Admin/AttributeController.php index b058f060d..ce1ca3072 100644 --- a/core/lib/Thelia/Controller/Admin/AttributeController.php +++ b/core/lib/Thelia/Controller/Admin/AttributeController.php @@ -34,6 +34,7 @@ use Thelia\Form\AttributeModificationForm; use Thelia\Form\AttributeCreationForm; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Model\AttributeAv; +use Thelia\Model\AttributeAvQuery; use Thelia\Core\Event\Attribute\AttributeAvUpdateEvent; use Thelia\Core\Event\Attribute\AttributeEvent; diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 1ef329dd1..abb9665f9 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -309,7 +309,6 @@ class BaseAdminController extends BaseController { // Check if the functionality is activated if(!ConfigQuery::read("one_domain_foreach_lang", false)) - return; // If we don't have a locale value, use the locale value in the session @@ -391,8 +390,8 @@ class BaseAdminController extends BaseController * Render the given template, and returns the result as an Http Response. * * @param $templateName the complete template name, with extension - * @param array $args the template arguments - * @param int $status http code status + * @param array $args the template arguments + * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response */ protected function render($templateName, $args = array(), $status = 200) diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php index d2e0a0e9c..4f789244b 100755 --- a/core/lib/Thelia/Controller/Admin/CategoryController.php +++ b/core/lib/Thelia/Controller/Admin/CategoryController.php @@ -201,12 +201,15 @@ class CategoryController extends AbstractSeoCrudController protected function redirectToListTemplateWithId($category_id) { - if ($category_id > 0) { + if($category_id > 0) + { $this->redirectToRoute( 'admin.categories.default', array('category_id' => $category_id) ); - } else { + } + else + { $this->redirectToRoute( 'admin.catalog' ); diff --git a/core/lib/Thelia/Controller/Admin/ConfigStoreController.php b/core/lib/Thelia/Controller/Admin/ConfigStoreController.php index 95d425edb..1a9172ec1 100644 --- a/core/lib/Thelia/Controller/Admin/ConfigStoreController.php +++ b/core/lib/Thelia/Controller/Admin/ConfigStoreController.php @@ -23,9 +23,11 @@ namespace Thelia\Controller\Admin; + use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\AccessManager; use Thelia\Form\ConfigStoreForm; +use Thelia\Log\Tlog; use Thelia\Model\ConfigQuery; /** * Class ConfigStoreController @@ -78,7 +80,7 @@ class ConfigStoreController extends BaseAdminController $data = $form->getData(); // Update store - foreach ($data as $name => $value) { + foreach($data as $name => $value) { if(! in_array($name , array('success_url', 'error_message'))) ConfigQuery::write($name, $value, false); } diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 95f6451c9..a3239542c 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -23,14 +23,19 @@ namespace Thelia\Controller\Admin; +use Propel\Runtime\Exception\PropelException; use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; use Thelia\Form\CustomerCreateForm; use Thelia\Form\CustomerUpdateForm; +use Thelia\Form\Exception\FormValidationException; use Thelia\Model\CustomerQuery; +use Thelia\Core\Translation\Translator; use Thelia\Tools\Password; +use Thelia\Model\AddressQuery; use Thelia\Model\Address; /** @@ -203,4 +208,4 @@ class CustomerController extends AbstractCrudController { $this->redirectToRoute("admin.customer.update.view", $this->getEditionArguments()); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/FeatureController.php b/core/lib/Thelia/Controller/Admin/FeatureController.php index 5ae0aae7d..8ff3a972e 100644 --- a/core/lib/Thelia/Controller/Admin/FeatureController.php +++ b/core/lib/Thelia/Controller/Admin/FeatureController.php @@ -34,6 +34,7 @@ use Thelia\Form\FeatureModificationForm; use Thelia\Form\FeatureCreationForm; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Model\FeatureAv; +use Thelia\Model\FeatureAvQuery; use Thelia\Core\Event\Feature\FeatureAvUpdateEvent; use Thelia\Core\Event\Feature\FeatureEvent; diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php index f123bfb94..aff1c2d63 100755 --- a/core/lib/Thelia/Controller/Admin/FileController.php +++ b/core/lib/Thelia/Controller/Admin/FileController.php @@ -584,7 +584,7 @@ class FileController extends BaseAdminController ); } - if (null === $message) { + if(null === $message) { $message = $this->getTranslator() ->trans( 'Images deleted successfully', @@ -638,7 +638,7 @@ class FileController extends BaseAdminController ) . $e->getMessage(); } - if (null === $message) { + if(null === $message) { $message = $this->getTranslator() ->trans( 'Image position updated', @@ -692,7 +692,7 @@ class FileController extends BaseAdminController ) . $e->getMessage(); } - if (null === $message) { + if(null === $message) { $message = $this->getTranslator() ->trans( 'Document position updated', diff --git a/core/lib/Thelia/Controller/Admin/HomeController.php b/core/lib/Thelia/Controller/Admin/HomeController.php index d4458843d..0fcee29ca 100644 --- a/core/lib/Thelia/Controller/Admin/HomeController.php +++ b/core/lib/Thelia/Controller/Admin/HomeController.php @@ -42,7 +42,7 @@ class HomeController extends BaseAdminController public function loadStatsAjaxAction() { if (null !== $response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW)) return $response; - + $data = new \stdClass(); $data->title = "Stats on " . $this->getRequest()->query->get('month', date('m')) . "/" . $this->getRequest()->query->get('year', date('Y')); @@ -88,6 +88,7 @@ class HomeController extends BaseAdminController array(5) ); + $data->series = array( $saleSeries, $newCustomerSeries, diff --git a/core/lib/Thelia/Controller/Admin/MessageController.php b/core/lib/Thelia/Controller/Admin/MessageController.php index aebf29d04..fe8b655c7 100644 --- a/core/lib/Thelia/Controller/Admin/MessageController.php +++ b/core/lib/Thelia/Controller/Admin/MessageController.php @@ -31,6 +31,7 @@ use Thelia\Model\MessageQuery; use Thelia\Form\MessageModificationForm; use Thelia\Form\MessageCreationForm; use Symfony\Component\Finder\Finder; +use Thelia\Model\ConfigQuery; use Thelia\Core\Template\TemplateHelper; /** @@ -163,8 +164,8 @@ class MessageController extends AbstractCrudController return $this->render('messages'); } - protected function listDirectoryContent($requiredExtension) - { + protected function listDirectoryContent($requiredExtension) { + $list = array(); $dir = TemplateHelper::getInstance()->getActiveMailTemplate()->getAbsolutePath(); diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index edd591ba4..031ae1f26 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -149,6 +149,7 @@ class ModuleController extends AbstractCrudController ->findOneById($this->getRequest()->get('module_id')); } + protected function getObjectLabel($object) { return $object->getTitle(); @@ -217,11 +218,12 @@ class ModuleController extends AbstractCrudController { $module = ModuleQuery::create()->findOneByCode($module_code); - if (null === $module) { + if(null === $module) { throw new \InvalidArgumentException(sprintf("Module `%s` does not exists", $module_code)); } if (null !== $response = $this->checkAuth(array(), $module_code, AccessManager::VIEW)) return $response; + return $this->render( "module-configure", array( diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index c04e2c93e..56d130f5d 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -27,6 +27,7 @@ use Thelia\Core\HttpFoundation\Response; use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; +use Thelia\Core\Event\PdfEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Security\AccessManager; use Thelia\Form\OrderUpdateAddress; @@ -35,6 +36,7 @@ use Thelia\Model\Base\OrderAddressQuery; use Thelia\Model\OrderQuery; use Thelia\Model\OrderStatusQuery; use Thelia\Tools\URL; +use Thelia\Core\Template\TemplateHelper; /** * Class OrderController @@ -201,18 +203,20 @@ class OrderController extends BaseAdminController public function generateInvoicePdf($order_id) { if (null !== $response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::UPDATE)) return $response; + return $this->generateBackOfficeOrderPdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice')); } public function generateDeliveryPdf($order_id) { if (null !== $response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::UPDATE)) return $response; + return $this->generateBackOfficeOrderPdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery')); } private function generateBackOfficeOrderPdf($order_id, $fileName) { - if (null === $response = $this->generateOrderPdf($order_id, $fileName)) { + if(null === $response = $this->generateOrderPdf($order_id, $fileName)){ $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute("admin.order.update.view", array( 'order_id' => $order_id )))); @@ -221,4 +225,5 @@ class OrderController extends BaseAdminController return $response; } + } diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 7b727f206..57ceb8fb4 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -72,6 +72,7 @@ use Thelia\Form\ProductCombinationGenerationForm; use Thelia\TaxEngine\Calculator; use Thelia\Tools\NumberFormat; + /** * Manages products * @@ -1036,18 +1037,17 @@ class ProductController extends AbstractSeoCrudController } // Create combinations - protected function combine($input, &$output, &$tmp) - { + protected function combine($input, &$output, &$tmp) { $current = array_shift($input); if (count($input) > 0) { - foreach ($current as $element) { + foreach($current as $element) { $tmp[] = $element; $this->combine($input, $output, $tmp); array_pop($tmp); } } else { - foreach ($current as $element) { + foreach($current as $element) { $tmp[] = $element; $output[] = $tmp; array_pop($tmp); @@ -1058,8 +1058,8 @@ class ProductController extends AbstractSeoCrudController /** * Build combinations from the combination output builder */ - public function buildCombinationsAction() - { + public function buildCombinationsAction() { + // Check current user authorization if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) return $response; @@ -1082,7 +1082,7 @@ class ProductController extends AbstractSeoCrudController // from the list of attribute_id:attributes_av ID from the form. $combinations = $attributes_av_list = array(); - foreach ($data['attribute_av'] as $item) { + foreach($data['attribute_av'] as $item) { list($attribute_id, $attribute_av_id) = explode(':', $item); if (! isset($attributes_av_list[$attribute_id])) diff --git a/core/lib/Thelia/Controller/Admin/SystemLogController.php b/core/lib/Thelia/Controller/Admin/SystemLogController.php index 9dafd78f6..e61d619f0 100644 --- a/core/lib/Thelia/Controller/Admin/SystemLogController.php +++ b/core/lib/Thelia/Controller/Admin/SystemLogController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Admin; + use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\AccessManager; use Thelia\Form\SystemLogConfigurationForm; @@ -42,7 +43,7 @@ class SystemLogController extends BaseAdminController $destination_directories = Tlog::getInstance()->getDestinationsDirectories(); - foreach ($destination_directories as $dir) { + foreach($destination_directories as $dir) { $this->loadDefinedDestinations($dir, $destinations); } @@ -57,8 +58,8 @@ class SystemLogController extends BaseAdminController ); } - protected function loadDefinedDestinations($directory, &$destinations) - { + protected function loadDefinedDestinations($directory, &$destinations) { + try { foreach (new \DirectoryIterator($directory) as $fileInfo) { @@ -143,7 +144,7 @@ class SystemLogController extends BaseAdminController $active_destinations = array(); - foreach ($destinations as $classname => $destination) { + foreach($destinations as $classname => $destination) { if (isset($destination['active'])) { $active_destinations[] = $destination['classname']; @@ -152,7 +153,7 @@ class SystemLogController extends BaseAdminController if (isset($configs[$classname])) { // Update destinations configuration - foreach ($configs[$classname] as $var => $value) { + foreach($configs[$classname] as $var => $value) { ConfigQuery::write($var, $value, true, true); } } diff --git a/core/lib/Thelia/Controller/Admin/TranslationsController.php b/core/lib/Thelia/Controller/Admin/TranslationsController.php index e4fcfed23..cb7c3f072 100644 --- a/core/lib/Thelia/Controller/Admin/TranslationsController.php +++ b/core/lib/Thelia/Controller/Admin/TranslationsController.php @@ -23,8 +23,12 @@ namespace Thelia\Controller\Admin; + use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\AccessManager; +use Thelia\Form\SystemLogConfigurationForm; +use Thelia\Log\Tlog; +use Thelia\Model\ConfigQuery; use Thelia\Model\ModuleQuery; use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Template\TemplateDefinition; @@ -63,7 +67,7 @@ class TranslationsController extends BaseAdminController if (! empty($item_id) || $item_to_translate == 'co') { - switch ($item_to_translate) { + switch($item_to_translate) { case 'mo' : if (null !== $module = ModuleQuery::create()->findPk($item_id)) { @@ -145,7 +149,8 @@ class TranslationsController extends BaseAdminController $templateArguments['max_input_vars_warning'] = true; $templateArguments['required_max_input_vars'] = $stringsCount; $templateArguments['current_max_input_vars'] = ini_get('max_input_vars'); - } else { + } + else { $templateArguments['all_strings'] = $all_strings; } } @@ -157,12 +162,14 @@ class TranslationsController extends BaseAdminController public function defaultAction() { if (null !== $response = $this->checkAuth(AdminResources::TRANSLATIONS, array(), AccessManager::VIEW)) return $response; + return $this->renderTemplate(); } public function updateAction() { if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE)) return $response; + return $this->renderTemplate(); } } diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index b90d98462..775861c32 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -61,7 +61,7 @@ abstract class BaseController extends ContainerAware /** * Return an empty response (after an ajax request, for example) - * @param int $status + * @param int $status * @return \Thelia\Core\HttpFoundation\Response */ protected function nullResponse($status = 200) @@ -252,6 +252,7 @@ abstract class BaseController extends ContainerAware } + } /** @@ -366,8 +367,8 @@ abstract class BaseController extends ContainerAware * Render the given template, and returns the result as an Http Response. * * @param $templateName the complete template name, with extension - * @param array $args the template arguments - * @param int $status http code status + * @param array $args the template arguments + * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response */ abstract protected function render($templateName, $args = array(), $status = 200); diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 3e70364d4..07f434099 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -25,8 +25,10 @@ namespace Thelia\Controller\Front; use Symfony\Component\Routing\Router; use Thelia\Controller\BaseController; use Thelia\Core\HttpFoundation\Response; +use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Template\TemplateHelper; use Thelia\Model\AddressQuery; +use Thelia\Model\ConfigQuery; use Thelia\Model\ModuleQuery; use Thelia\Tools\Redirect; use Thelia\Tools\URL; @@ -104,8 +106,8 @@ class BaseFrontController extends BaseController * Render the given template, and returns the result as an Http Response. * * @param $templateName the complete template name, with extension - * @param array $args the template arguments - * @param int $status http code status + * @param array $args the template arguments + * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response */ protected function render($templateName, $args = array(), $status = 200) diff --git a/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php b/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php index 43f84ebd5..e007f9961 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php +++ b/core/lib/Thelia/Core/DependencyInjection/Compiler/TranslatorPass.php @@ -26,6 +26,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; + /** * Class TranslatorPass * @package Thelia\Core\DependencyInjection\Compiler @@ -49,11 +50,11 @@ class TranslatorPass implements CompilerPassInterface $translator = $container->getDefinition('thelia.translator'); - foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) { + foreach($container->findTaggedServiceIds('translation.loader') as $id => $attributes) { $translator->addMethodCall('addLoader', array($attributes[0]['alias'], new Reference($id))); if (isset($attributes[0]['legacy-alias'])) { $translator->addMethodCall('addLoader', array($attributes[0]['legacy-alias'], new Reference($id))); } } } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Administrator/AdministratorUpdatePasswordEvent.php b/core/lib/Thelia/Core/Event/Administrator/AdministratorUpdatePasswordEvent.php index 8cfe1ee02..f155a9dce 100644 --- a/core/lib/Thelia/Core/Event/Administrator/AdministratorUpdatePasswordEvent.php +++ b/core/lib/Thelia/Core/Event/Administrator/AdministratorUpdatePasswordEvent.php @@ -25,6 +25,7 @@ namespace Thelia\Core\Event\Administrator; use Thelia\Core\Event\ActionEvent; use Thelia\Model\Admin; + /** * Class AdministratorUpdatePasswordEvent * @package Thelia\Core\Event\Administrator @@ -81,3 +82,4 @@ class AdministratorUpdatePasswordEvent extends ActionEvent } } + diff --git a/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php index f35430c36..2c45942f3 100755 --- a/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Customer/CustomerCreateOrUpdateEvent.php @@ -23,6 +23,7 @@ namespace Thelia\Core\Event\Customer; use Symfony\Component\EventDispatcher\Event; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Customer; /** diff --git a/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php b/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php index 943eb5b64..0a046177e 100755 --- a/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php +++ b/core/lib/Thelia/Core/Event/Customer/CustomerLoginEvent.php @@ -23,6 +23,7 @@ namespace Thelia\Core\Event\Customer; +use Thelia\Core\Event\ActionEvent; use Thelia\Model\Customer; class CustomerLoginEvent extends CustomerEvent diff --git a/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php b/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php index b1446bfce..6630b7c13 100644 --- a/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Message/MessageUpdateEvent.php @@ -138,4 +138,4 @@ class MessageUpdateEvent extends MessageCreateEvent return $this; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Product/ProductCombinationGenerationEvent.php b/core/lib/Thelia/Core/Event/Product/ProductCombinationGenerationEvent.php index ba0fccb68..05b55d733 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductCombinationGenerationEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductCombinationGenerationEvent.php @@ -65,7 +65,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setReference($reference) { $this->reference = $reference; - return $this; } @@ -77,7 +76,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setPrice($price) { $this->price = $price; - return $this; } @@ -89,7 +87,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setWeight($weight) { $this->weight = $weight; - return $this; } @@ -101,7 +98,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setQuantity($quantity) { $this->quantity = $quantity; - return $this; } @@ -113,7 +109,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setSalePrice($sale_price) { $this->sale_price = $sale_price; - return $this; } @@ -125,7 +120,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setOnsale($onsale) { $this->onsale = $onsale; - return $this; } @@ -137,7 +131,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setIsnew($isnew) { $this->isnew = $isnew; - return $this; } @@ -149,7 +142,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setEanCode($ean_code) { $this->ean_code = $ean_code; - return $this; return $this; } @@ -162,7 +154,6 @@ class ProductCombinationGenerationEvent extends ProductEvent public function setCombinations($combinations) { $this->combinations = $combinations; - return $this; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php index 0e95abfba..af28ca73f 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductSetTemplateEvent.php @@ -60,4 +60,4 @@ class ProductSetTemplateEvent extends ProductEvent return $this; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/ProductSaleElement/ProductSaleElementDeleteEvent.php b/core/lib/Thelia/Core/Event/ProductSaleElement/ProductSaleElementDeleteEvent.php index 8f94b254b..811b02fca 100644 --- a/core/lib/Thelia/Core/Event/ProductSaleElement/ProductSaleElementDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/ProductSaleElement/ProductSaleElementDeleteEvent.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Core\Event\ProductSaleElement; +use Thelia\Model\Product; class ProductSaleElementDeleteEvent extends ProductSaleElementEvent { diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 69c05cf6d..b761cf775 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -370,7 +370,6 @@ final class TheliaEvents */ const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress"; const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule"; - const ORDER_SET_POSTAGE = "action.order.setPostage"; const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress"; const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule"; const ORDER_PAY = "action.order.pay"; diff --git a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php index cb287b869..caf46c1aa 100644 --- a/core/lib/Thelia/Core/Event/UpdateSeoEvent.php +++ b/core/lib/Thelia/Core/Event/UpdateSeoEvent.php @@ -184,4 +184,5 @@ class UpdateSeoEvent extends ActionEvent return $this->object; } + } diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php index 1975eba45..e3eaa9577 100755 --- a/core/lib/Thelia/Core/EventListener/ViewListener.php +++ b/core/lib/Thelia/Core/EventListener/ViewListener.php @@ -30,10 +30,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Response; use Symfony\Component\Routing\Router; +use Thelia\Core\HttpKernel\Exception\NotFountHttpException; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserInterface; use Thelia\Core\Template\TemplateHelper; use Thelia\Exception\OrderException; +use Thelia\Model\ConfigQuery; use Thelia\Tools\Redirect; use Thelia\Tools\URL; use Thelia\Core\Security\Exception\AuthenticationException; diff --git a/core/lib/Thelia/Core/HttpFoundation/Response.php b/core/lib/Thelia/Core/HttpFoundation/Response.php index e279215b8..277c16cc2 100644 --- a/core/lib/Thelia/Core/HttpFoundation/Response.php +++ b/core/lib/Thelia/Core/HttpFoundation/Response.php @@ -39,8 +39,8 @@ class Response extends BaseResponse * * @see \Thelia\Core\HttpFoundation\Response::sendContent() */ - public function sendContent() - { + public function sendContent() { + Tlog::getInstance()->write($this->content); parent::sendContent(); diff --git a/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php b/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php index aceb6235f..b45f0f812 100644 --- a/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php +++ b/core/lib/Thelia/Core/HttpKernel/HttpCache/HttpCache.php @@ -65,8 +65,7 @@ class HttpCache extends BaseHttpCache implements HttpKernelInterface $request->getContent() ); } - return parent::handle($request, $type, $catch); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/SecurityContext.php b/core/lib/Thelia/Core/Security/SecurityContext.php index 8512fac0e..e97a19877 100755 --- a/core/lib/Thelia/Core/Security/SecurityContext.php +++ b/core/lib/Thelia/Core/Security/SecurityContext.php @@ -177,7 +177,7 @@ class SecurityContext continue; } - if (!array_key_exists('module', $userPermissions)) { + if(!array_key_exists('module', $userPermissions)) { return false; } diff --git a/core/lib/Thelia/Core/Template/Assets/AssetManagerInterface.php b/core/lib/Thelia/Core/Template/Assets/AssetManagerInterface.php index f2ed7c7ab..86a61d0f6 100644 --- a/core/lib/Thelia/Core/Template/Assets/AssetManagerInterface.php +++ b/core/lib/Thelia/Core/Template/Assets/AssetManagerInterface.php @@ -23,8 +23,7 @@ namespace Thelia\Core\Template\Assets; -interface AssetManagerInterface -{ +interface AssetManagerInterface { /** * Prepare an asset directory by checking that no changes occured in * the source directory. If any change is detected, the whole asset directory @@ -36,6 +35,10 @@ interface AssetManagerInterface * @param string $webAssetsKey the assets key : module name or 0 for base template * * @throws \RuntimeException if something goes wrong. + * + * @internal param string $source_assets_directory the full path to the source asstes directory + * @internal param string $web_assets_directory_base the base directory of the web based asset directory + * @internal param string $key the assets key : module name or 0 for base template */ public function prepareAssets($sourceAssetsDirectory, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey); @@ -55,6 +58,9 @@ interface AssetManagerInterface * * @param boolean $debug true / false * + * @internal param string $web_assets_directory_base the full disk path to the base assets output directory in the web space + * @internal param string $output_url the URL to the base assets output directory in the web space + * * @return string The URL to the generated asset file. */ public function processAsset($assetSource, $assetDirectoryBase, $webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey, $outputUrl, $assetType, $filters, $debug); diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php b/core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php index 46e015798..ac338c514 100755 --- a/core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php +++ b/core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php @@ -51,7 +51,7 @@ class AsseticAssetManager implements AssetManagerInterface /** * Create a stamp form the modification time of the content of the given directory and all of its subdirectories * - * @param string $directory ther directory name + * @param string $directory ther directory name * @return string the stamp of this directory */ protected function getStamp($directory) @@ -76,8 +76,7 @@ class AsseticAssetManager implements AssetManagerInterface * * @return bool */ - protected function isSourceFile(\SplFileInfo $fileInfo) - { + protected function isSourceFile(\SplFileInfo $fileInfo) { return in_array($fileInfo->getExtension(), $this->source_file_extensions); } @@ -135,27 +134,6 @@ class AsseticAssetManager implements AssetManagerInterface * @internal param string $source_assets_directory the source directory * @return the full path of the destination directory */ - protected function getRelativeDirectoryPath($source_assets_directory, $web_assets_directory_base) - { - $source_assets_directory = realpath($source_assets_directory); - - // Remove base path from asset source path to get a path relative to the template base - // and use it to create the destination path. - return str_replace( - realpath(THELIA_ROOT), - '', - $source_assets_directory - ); - } - - /** - * Compute the destination directory path, from the source directory and the - * base directory of the web assets - * - * @param string $source_assets_directory the source directory - * @param string $web_assets_directory_base base directory of the web assets - * @return the full path of the destination directory - */ protected function getDestinationDirectory($webAssetsDirectoryBase, $webAssetsTemplate, $webAssetsKey) { // Compute the absolute path of the output directory @@ -227,7 +205,8 @@ class AsseticAssetManager implements AssetManagerInterface throw new \RuntimeException( "Failed to create asset stamp file $stamp_file_path. Please check that your web server has the proper access rights to do that."); } -/* } else { +/* } + else { @fclose($fp); } */ @@ -237,13 +216,13 @@ class AsseticAssetManager implements AssetManagerInterface /** * Decode the filters names, and initialize the Assetic FilterManager * - * @param FilterManager $filterManager the Assetic filter manager - * @param string $filters a comma separated list of filter names + * @param FilterManager $filterManager the Assetic filter manager + * @param string $filters a comma separated list of filter names * @throws \InvalidArgumentException if a wrong filter is passed - * @return an array of filter names + * @return an array of filter names */ - protected function decodeAsseticFilters(FilterManager $filterManager, $filters) - { + protected function decodeAsseticFilters(FilterManager $filterManager, $filters) { + if (!empty($filters)) { $filter_list = explode(',', $filters); @@ -282,7 +261,8 @@ class AsseticAssetManager implements AssetManagerInterface break; } } - } else { + } + else { $filter_list = array(); } diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index db61c20c1..6d4e6ed92 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -277,6 +277,7 @@ abstract class BaseLoop } } + protected function searchArray(array $search, &$pagination = null) { if (false === $this->countable) { @@ -285,7 +286,7 @@ abstract class BaseLoop if ($this->getArgValue('page') !== null) { $nbPage = ceil(count($search)/$this->getArgValue('limit')); - if ($this->getArgValue('page') > $nbPage || $this->getArgValue('page') <= 0) { + if($this->getArgValue('page') > $nbPage || $this->getArgValue('page') <= 0) { return array(); } @@ -337,9 +338,9 @@ abstract class BaseLoop */ public function exec(&$pagination) { - if ($this instanceof PropelSearchLoopInterface) { + if($this instanceof PropelSearchLoopInterface) { $searchModelCriteria = $this->buildModelCriteria(); - if (null === $searchModelCriteria) { + if(null === $searchModelCriteria) { $results = array(); } else { $results = $this->search( @@ -349,7 +350,7 @@ abstract class BaseLoop } } elseif ($this instanceof ArraySearchLoopInterface) { $searchArray = $this->buildArray(); - if (null === $searchArray) { + if(null === $searchArray) { $results = array(); } else { $results = $this->searchArray( @@ -361,13 +362,13 @@ abstract class BaseLoop $loopResult = new LoopResult($results); - if (true === $this->countable) { + if(true === $this->countable) { $loopResult->setCountable(); } - if (true === $this->timestampable) { + if(true === $this->timestampable) { $loopResult->setTimestamped(); } - if (true === $this->versionable) { + if(true === $this->versionable) { $loopResult->setVersioned(); } @@ -381,29 +382,29 @@ abstract class BaseLoop * - ArraySearchLoopInterface */ $searchInterface = false; - if ($this instanceof PropelSearchLoopInterface) { - if (true === $searchInterface) { + if($this instanceof PropelSearchLoopInterface) { + if(true === $searchInterface) { throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE); } $searchInterface = true; } - if ($this instanceof ArraySearchLoopInterface) { - if (true === $searchInterface) { + if($this instanceof ArraySearchLoopInterface) { + if(true === $searchInterface) { throw new LoopException('Loop cannot implements multiple Search Interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::MULTIPLE_SEARCH_INTERFACE); } $searchInterface = true; } - if (false === $searchInterface) { + if(false === $searchInterface) { throw new LoopException('Loop must implements one of the following interfaces : `PropelSearchLoopInterface`, `ArraySearchLoopInterface`', LoopException::SEARCH_INTERFACE_NOT_FOUND); } /* Only PropelSearch allows timestamp and version */ - if (!$this instanceof PropelSearchLoopInterface) { - if (true === $this->timestampable) { + if(!$this instanceof PropelSearchLoopInterface) { + if(true === $this->timestampable) { throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be timestampable", LoopException::NOT_TIMESTAMPED); } - if (true === $this->versionable) { + if(true === $this->versionable) { throw new LoopException("Loop must implements 'PropelSearchLoopInterface' to be versionable", LoopException::NOT_VERSIONED); } } diff --git a/core/lib/Thelia/Core/Template/Loop/Admin.php b/core/lib/Thelia/Core/Template/Loop/Admin.php index d9c49ef80..ef5ce7e1f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Admin.php +++ b/core/lib/Thelia/Core/Template/Loop/Admin.php @@ -33,6 +33,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\AdminQuery; +use Thelia\Type; /** * diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 4ae41c3b6..9411b1dbd 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -48,7 +48,7 @@ class AssociatedContent extends Content { protected $contentId; protected $contentPosition; - + /** * @return ArgumentCollection */ diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index 0cb7a5e88..072193f34 100755 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -88,7 +88,7 @@ class Auth extends BaseLoop implements ArraySearchLoopInterface $module = $this->getModule(); $access = $this->getAccess(); - if (null !== $module) { + if(null !== $module) { $in = true; } diff --git a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php index ae7226152..c1bc483f9 100644 --- a/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php +++ b/core/lib/Thelia/Core/Template/Loop/BaseSpecificModule.php @@ -24,6 +24,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; diff --git a/core/lib/Thelia/Core/Template/Loop/Cart.php b/core/lib/Thelia/Core/Template/Loop/Cart.php index 6370b30be..88b5a53d4 100755 --- a/core/lib/Thelia/Core/Template/Loop/Cart.php +++ b/core/lib/Thelia/Core/Template/Loop/Cart.php @@ -58,7 +58,7 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface { $cart = $this->getCart($this->request); - if (null === $cart) { + if(null === $cart) { return array(); } @@ -79,9 +79,9 @@ class Cart extends BaseLoop implements ArraySearchLoopInterface public function parseResults(LoopResult $loopResult) { - $taxCountry = TaxEngine::getInstance($this->request->getSession())->getTaxCountry(); + $taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); - foreach ($loopResult->getResultDataCollection() as $cartItem) { + foreach($loopResult->getResultDataCollection() as $cartItem) { $product = $cartItem->getProduct(); $productSaleElement = $cartItem->getProductSaleElements(); diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php index d70654d0b..1b7f68f22 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryPath.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryPath.php @@ -125,9 +125,9 @@ class CategoryPath extends BaseI18nLoop implements ArraySearchLoopInterface public function parseResults(LoopResult $loopResult) { - foreach ($loopResult->getResultDataCollection() as $result) { + foreach($loopResult->getResultDataCollection() as $result) { $loopResultRow = new LoopResultRow($result); - foreach ($result as $output => $outputValue) { + foreach($result as $output => $outputValue) { $loopResultRow->set($output, $outputValue); } $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index 35a9569f9..3c3c3ffe0 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -99,9 +99,9 @@ class CategoryTree extends BaseI18nLoop implements ArraySearchLoopInterface public function parseResults(LoopResult $loopResult) { - foreach ($loopResult->getResultDataCollection() as $result) { + foreach($loopResult->getResultDataCollection() as $result) { $loopResultRow = new LoopResultRow($result); - foreach ($result as $output => $outputValue) { + foreach($result as $output => $outputValue) { $loopResultRow->set($output, $outputValue); } $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 622a3a18c..e211103da 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -24,6 +24,7 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; +use Propel\Runtime\Util\PropelModelPager; use Thelia\Condition\ConditionFactory; use Thelia\Condition\Implementation\ConditionInterface; use Thelia\Core\HttpFoundation\Request; diff --git a/core/lib/Thelia/Core/Template/Loop/Currency.php b/core/lib/Thelia/Core/Template/Loop/Currency.php index 3d7a5631e..82aebeb32 100755 --- a/core/lib/Thelia/Core/Template/Loop/Currency.php +++ b/core/lib/Thelia/Core/Template/Loop/Currency.php @@ -158,7 +158,6 @@ class Currency extends BaseI18nLoop implements PropelSearchLoopInterface } /* perform search */ - return $search; } diff --git a/core/lib/Thelia/Core/Template/Loop/Customer.php b/core/lib/Thelia/Core/Template/Loop/Customer.php index d4b8effb0..f955cd217 100755 --- a/core/lib/Thelia/Core/Template/Loop/Customer.php +++ b/core/lib/Thelia/Core/Template/Loop/Customer.php @@ -36,6 +36,9 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\CustomerQuery; use Thelia\Type\TypeCollection; use Thelia\Type; +use Thelia\Model\OrderQuery; +use Thelia\Model\Map\OrderAddressTableMap; +use Thelia\Model\Map\OrderTableMap; /** * @@ -205,6 +208,7 @@ class Customer extends BaseLoop implements SearchLoopInterface, PropelSearchLoop $search->orderByCreatedAt(Criteria::DESC); break; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Delivery.php b/core/lib/Thelia/Core/Template/Loop/Delivery.php index 5e916f654..f671f1ca9 100644 --- a/core/lib/Thelia/Core/Template/Loop/Delivery.php +++ b/core/lib/Thelia/Core/Template/Loop/Delivery.php @@ -29,6 +29,7 @@ use Thelia\Exception\OrderException; use Thelia\Model\CountryQuery; use Thelia\Module\BaseModule; use Thelia\Module\DeliveryModuleInterface; +use Thelia\TaxEngine\TaxEngine; /** * Class Delivery @@ -59,7 +60,7 @@ class Delivery extends BaseSpecificModule throw new \InvalidArgumentException('Cannot found country id: `' . $countryId . '` in delivery loop'); } } else { - $country = CountryQuery::create()->findOneByByDefault(1); + $country = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); } foreach ($loopResult->getResultDataCollection() as $deliveryModule) { @@ -73,8 +74,8 @@ class Delivery extends BaseSpecificModule try { $postage = $moduleInstance->getPostage($country); - } catch (OrderException $e) { - switch ($e->getCode()) { + } catch(OrderException $e) { + switch($e->getCode()) { case OrderException::DELIVERY_MODULE_UNAVAILABLE: /* do not show this delivery module */ continue(2); diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index fa561b3fb..84dee9f82 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -126,6 +126,7 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); + $orders = $this->getOrder(); foreach ($orders as $order) { diff --git a/core/lib/Thelia/Core/Template/Loop/FolderPath.php b/core/lib/Thelia/Core/Template/Loop/FolderPath.php index b50d7c55d..92c42f890 100644 --- a/core/lib/Thelia/Core/Template/Loop/FolderPath.php +++ b/core/lib/Thelia/Core/Template/Loop/FolderPath.php @@ -135,9 +135,9 @@ class FolderPath extends BaseI18nLoop implements ArraySearchLoopInterface public function parseResults(LoopResult $loopResult) { - foreach ($loopResult->getResultDataCollection() as $result) { + foreach($loopResult->getResultDataCollection() as $result) { $loopResultRow = new LoopResultRow($result); - foreach ($result as $output => $outputValue) { + foreach($result as $output => $outputValue) { $loopResultRow->set($output, $outputValue); } $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/FolderTree.php b/core/lib/Thelia/Core/Template/Loop/FolderTree.php index 851b6d8ff..9598f7a5c 100644 --- a/core/lib/Thelia/Core/Template/Loop/FolderTree.php +++ b/core/lib/Thelia/Core/Template/Loop/FolderTree.php @@ -100,9 +100,9 @@ class FolderTree extends BaseI18nLoop implements ArraySearchLoopInterface public function parseResults(LoopResult $loopResult) { - foreach ($loopResult->getResultDataCollection() as $result) { + foreach($loopResult->getResultDataCollection() as $result) { $loopResultRow = new LoopResultRow($result); - foreach ($result as $output => $outputValue) { + foreach($result as $output => $outputValue) { $loopResultRow->set($output, $outputValue); } $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index def24ae2a..b207deb29 100755 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -236,6 +236,7 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface $search->filterById($exclude, Criteria::NOT_IN); // echo "sql=".$search->toString(); + return $search; } diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php index c3f544382..db947f730 100755 --- a/core/lib/Thelia/Core/Template/Loop/Module.php +++ b/core/lib/Thelia/Core/Template/Loop/Module.php @@ -196,19 +196,19 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface /* first test if module defines it's own config route */ $routerId = "router." . $module->getBaseDir(); - if ($this->container->has($routerId)) { + if($this->container->has($routerId)) { try { - if ($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) { + if($this->container->get($routerId)->match('/admin/module/' . $module->getCode())) { $hasConfigurationInterface = true; } - } catch (ResourceNotFoundException $e) { + } catch(ResourceNotFoundException $e) { /* $hasConfigurationInterface stays false */ } } /* if not ; test if it uses admin inclusion : module_configuration.html */ - if (false === $hasConfigurationInterface) { - if (file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) { + if(false === $hasConfigurationInterface) { + if(file_exists( sprintf("%s/AdminIncludes/%s.html", $module->getAbsoluteBaseDir(), "module_configuration"))) { $hasConfigurationInterface = true; } } diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index 3fb04d60c..5f12fa1eb 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -46,7 +46,7 @@ use Thelia\Type; */ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInterface { - protected $countable = true; + protected $countable = true; protected $timestampable = true; protected $versionable = false; @@ -175,6 +175,7 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt } return $search; + } public function parseResults(LoopResult $loopResult) @@ -201,7 +202,6 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt ->set("STATUS", $order->getStatusId()) ->set("LANG", $order->getLangId()) ->set("POSTAGE", $order->getPostage()) - ->set("DISCOUNT", $order->getDiscount()) ->set("TOTAL_TAX", $tax) ->set("TOTAL_AMOUNT", $amount - $tax) ->set("TOTAL_TAXED_AMOUNT", $amount) diff --git a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php b/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php deleted file mode 100755 index 80e24c487..000000000 --- a/core/lib/Thelia/Core/Template/Loop/OrderCoupon.php +++ /dev/null @@ -1,116 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Core\Template\Loop; - -use Propel\Runtime\ActiveQuery\Criteria; -use Thelia\Condition\ConditionFactory; -use Thelia\Condition\Implementation\ConditionInterface; -use Thelia\Core\HttpFoundation\Request; -use Thelia\Core\Template\Element\BaseLoop; -use Thelia\Core\Template\Element\LoopResult; -use Thelia\Core\Template\Element\LoopResultRow; -use Thelia\Core\Template\Element\PropelSearchLoopInterface; -use Thelia\Core\Template\Loop\Argument\Argument; -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; -use Thelia\Model\OrderCouponQuery; -use Thelia\Model\OrderQuery; -use Thelia\Type; - -/** - * - * OrderCoupon loop - * - * - * Class OrderCoupon - * @package Thelia\Core\Template\Loop - * @author Etienne Roudeix - */ -class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface -{ - /** - * Define all args used in your loop - * - * @return ArgumentCollection - */ - protected function getArgDefinitions() - { - return new ArgumentCollection( - Argument::createIntTypeArgument('order', null, true) - ); - } - - public function buildModelCriteria() - { - $search = OrderCouponQuery::create(); - - $order = $this->getOrder(); - - $search->filterByOrderId($order, Criteria::EQUAL); - - $search->orderById(Criteria::ASC); - - return $search; - - } - - public function parseResults(LoopResult $loopResult) - { - $conditionFactory = $this->container->get('thelia.condition.factory'); - - /** @var OrderCoupon $orderCoupon */ - foreach ($loopResult->getResultDataCollection() as $orderCoupon) { - $loopResultRow = new LoopResultRow($orderCoupon); - $conditions = $conditionFactory->unserializeConditionCollection( - $orderCoupon->getSerializedConditions() - ); - - $now = time(); - $datediff = $orderCoupon->getExpirationDate()->getTimestamp() - $now; - $daysLeftBeforeExpiration = floor($datediff/(60*60*24)); - - $cleanedConditions = array(); - - foreach ($conditions->getConditions() as $condition) { - $cleanedConditions[] = $condition->getToolTip(); - } - $loopResultRow->set("ID", $orderCoupon->getId()) - ->set("CODE", $orderCoupon->getCode()) - ->set("TITLE", $orderCoupon->getTitle()) - ->set("SHORT_DESCRIPTION", $orderCoupon->getShortDescription()) - ->set("DESCRIPTION", $orderCoupon->getDescription()) - ->set("EXPIRATION_DATE", $orderCoupon->getExpirationDate( OrderQuery::create()->findPk($this->getOrder())->getLangId() )) - ->set("USAGE_LEFT", $orderCoupon->getMaxUsage()) - ->set("IS_CUMULATIVE", $orderCoupon->getIsCumulative()) - ->set("IS_REMOVING_POSTAGE", $orderCoupon->getIsRemovingPostage()) - ->set("IS_AVAILABLE_ON_SPECIAL_OFFERS", $orderCoupon->getIsAvailableOnSpecialOffers()) - ->set("AMOUNT", $orderCoupon->getAmount()) - ->set("APPLICATION_CONDITIONS", $cleanedConditions) - ->set("DAY_LEFT_BEFORE_EXPIRATION", $daysLeftBeforeExpiration) - ; - $loopResult->addRow($loopResultRow); - } - - return $loopResult; - } -} diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProduct.php b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php index 8e201f31c..f36162099 100755 --- a/core/lib/Thelia/Core/Template/Loop/OrderProduct.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php @@ -72,7 +72,7 @@ class OrderProduct extends BaseLoop implements PropelSearchLoopInterface $search->orderById(Criteria::ASC); return $search; - + } public function parseResults(LoopResult $loopResult) diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php index bb018ec98..f248159c5 100755 --- a/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php +++ b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php @@ -87,7 +87,7 @@ class OrderProductAttributeCombination extends BaseI18nLoop implements PropelSea } return $search; - + } public function parseResults(LoopResult $loopResult) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 0668df260..49bab69ec 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -465,7 +465,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL return $this->parseComplex($loopResult); } - $taxCountry = TaxEngine::getInstance($this->request->getSession())->getTaxCountry(); + $taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); foreach ($loopResult->getResultDataCollection() as $product) { @@ -983,7 +983,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL { $loopResult = new LoopResult($results); - $taxCountry = TaxEngine::getInstance($this->request->getSession())->getTaxCountry(); + $taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); foreach ($loopResult->getResultDataCollection() as $product) { diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index e1d54ff90..319bb7fee 100755 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -37,6 +37,7 @@ use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\CountryQuery; use Thelia\Model\CurrencyQuery; use Thelia\Model\Map\ProductSaleElementsTableMap; +use Thelia\TaxEngine\TaxEngine; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -145,7 +146,7 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface public function parseResults(LoopResult $loopResult) { - $taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic + $taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); foreach ($loopResult->getResultDataCollection() as $PSEValue) { $loopResultRow = new LoopResultRow($PSEValue); diff --git a/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php b/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php index 4d6491509..ea1d94262 100644 --- a/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductTemplate.php @@ -103,4 +103,4 @@ class ProductTemplate extends BaseI18nLoop implements PropelSearchLoopInterface return $loopResult; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Loop/Profile.php b/core/lib/Thelia/Core/Template/Loop/Profile.php index 8b21d2fe0..bddcf856c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Profile.php +++ b/core/lib/Thelia/Core/Template/Loop/Profile.php @@ -33,6 +33,7 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\ProfileQuery; +use Thelia\Type; /** * diff --git a/core/lib/Thelia/Core/Template/Loop/Template.php b/core/lib/Thelia/Core/Template/Loop/Template.php index 9d30c3410..c7f7ea191 100644 --- a/core/lib/Thelia/Core/Template/Loop/Template.php +++ b/core/lib/Thelia/Core/Template/Loop/Template.php @@ -23,12 +23,19 @@ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Security\AccessManager; +use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; +use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\ModuleQuery; + +use Thelia\Module\BaseModule; use Thelia\Type; use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Template\TemplateDefinition; @@ -65,14 +72,8 @@ class Template extends BaseLoop implements ArraySearchLoopInterface ); } -<<<<<<< HEAD public function buildArray() { $type = $this->getArg('template-type')->getValue(); -======= - public function buildArray() - { - $type = $this->getArg(template_type); ->>>>>>> master if ($type == 'front-office') $templateType = TemplateDefinition::FRONT_OFFICE; diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php index 9f2e95736..b34232009 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php +++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php @@ -42,9 +42,9 @@ class SmartyAssetsManager /** * Creates a new SmartyAssetsManager instance * - * @param AssetManagerInterface $assetsManager an asset manager instance - * @param string $web_root the disk path to the web root (with final /) - * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated + * @param AssetManagerInterface $assetsManager an asset manager instance + * @param string $web_root the disk path to the web root (with final /) + * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated */ public function __construct(AssetManagerInterface $assetsManager, $web_root, $path_relative_to_web_root) { diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php index 8b8ee8ef1..78e1c8f5b 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/AdminUtilities.php @@ -27,6 +27,8 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Tools\URL; use Thelia\Core\Security\SecurityContext; +use Thelia\Model\Config; +use Thelia\Model\ConfigQuery; use Thelia\Core\Template\TemplateHelper; /** @@ -43,8 +45,8 @@ class AdminUtilities extends AbstractSmartyPlugin $this->securityContext = $securityContext; } - protected function fetch_snippet($smarty, $templateName, $variablesArray) - { + protected function fetch_snippet($smarty, $templateName, $variablesArray) { + $data = ''; $snippet_path = sprintf('%s/%s/%s.html', @@ -97,6 +99,7 @@ class AdminUtilities extends AbstractSmartyPlugin $module === null ? array() : array($module), array($access)) ) { + return $this->fetch_snippet($smarty, 'includes/admin-utilities-position-block', array( 'admin_utilities_go_up_url' => URL::getInstance()->absoluteUrl($path, array('mode' => 'up', $url_parameter => $id)), 'admin_utilities_in_place_edit_class' => $in_place_edit_class, diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assets.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assets.php index e4a5c866f..e4c220ed5 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assets.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assets.php @@ -56,11 +56,10 @@ class Assets extends AbstractSmartyPlugin { try { return $this->assetManager->processSmartyPluginCall('js', $params, $content, $template, $repeat); - } catch (\Exception $e) { + } catch(\Exception $e) { $catchException = $this->getNormalizedParam($params, array('catchException')); - if ($catchException == "true") { + if($catchException == "true") { $repeat = false; - return null; } else { throw $e; diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 8905519fb..eab83e140 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -184,7 +184,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin if (array_key_exists('currentCountry', self::$dataAccessCache)) { $taxCountry = self::$dataAccessCache['currentCountry']; } else { - $taxCountry = TaxEngine::getInstance($this->request->getSession())->getTaxCountry(); + $taxCountry = TaxEngine::getInstance($this->request->getSession())->getDeliveryCountry(); self::$dataAccessCache['currentCountry'] = $taxCountry; } @@ -212,8 +212,6 @@ class DataAccessFunctions extends AbstractSmartyPlugin switch ($attribute) { case 'postage': return $order->getPostage(); - case 'discount': - return $order->getDiscount(); case 'delivery_address': return $order->chosenDeliveryAddress; case 'invoice_address': @@ -269,69 +267,69 @@ class DataAccessFunctions extends AbstractSmartyPlugin $includeShipping = true; } - if ($params['startDate'] == 'today') { + if($params['startDate'] == 'today') { $startDate = new \DateTime(); $startDate->setTime(0, 0, 0); - } elseif ($params['startDate'] == 'yesterday') { + } elseif($params['startDate'] == 'yesterday') { $startDate = new \DateTime(); $startDate->setTime(0, 0, 0); $startDate->modify('-1 day'); - } elseif ($params['startDate'] == 'this_month') { + } elseif($params['startDate'] == 'this_month') { $startDate = new \DateTime(); $startDate->modify('first day of this month'); $startDate->setTime(0, 0, 0); - } elseif ($params['startDate'] == 'last_month') { + } elseif($params['startDate'] == 'last_month') { $startDate = new \DateTime(); $startDate->modify('first day of last month'); $startDate->setTime(0, 0, 0); - } elseif ($params['startDate'] == 'this_year') { + } elseif($params['startDate'] == 'this_year') { $startDate = new \DateTime(); $startDate->modify('first day of January this year'); $startDate->setTime(0, 0, 0); - } elseif ($params['startDate'] == 'last_year') { + } elseif($params['startDate'] == 'last_year') { $startDate = new \DateTime(); $startDate->modify('first day of December last year'); $startDate->setTime(0, 0, 0); } else { try { $startDate = new \DateTime($params['startDate']); - } catch (\Exception $e) { + } catch(\Exception $e) { throw new \InvalidArgumentException(sprintf("invalid startDate attribute '%s' in stats access function", $params['startDate'])); } } - if ($params['endDate'] == 'today') { + if($params['endDate'] == 'today') { $endDate = new \DateTime(); $endDate->setTime(0, 0, 0); - } elseif ($params['endDate'] == 'yesterday') { + } elseif($params['endDate'] == 'yesterday') { $endDate = new \DateTime(); $endDate->setTime(0, 0, 0); $endDate->modify('-1 day'); - } elseif ($params['endDate'] == 'this_month') { + } elseif($params['endDate'] == 'this_month') { $endDate = new \DateTime(); $endDate->modify('last day of this month'); $endDate->setTime(0, 0, 0); - } elseif ($params['endDate'] == 'last_month') { + } elseif($params['endDate'] == 'last_month') { $endDate = new \DateTime(); $endDate->modify('last day of last month'); $endDate->setTime(0, 0, 0); - } elseif ($params['endDate'] == 'this_year') { + } elseif($params['endDate'] == 'this_year') { $endDate = new \DateTime(); $endDate->modify('last day of December this year'); $endDate->setTime(0, 0, 0); - } elseif ($params['endDate'] == 'last_year') { + } elseif($params['endDate'] == 'last_year') { $endDate = new \DateTime(); $endDate->modify('last day of January last year'); $endDate->setTime(0, 0, 0); } else { try { $endDate = new \DateTime($params['endDate']); - } catch (\Exception $e) { + } catch(\Exception $e) { throw new \InvalidArgumentException(sprintf("invalid endDate attribute '%s' in stats access function", $params['endDate'])); } } - switch ($params['key']) { + switch( $params['key'] ) { case 'sales' : return OrderQuery::getSaleStats($startDate, $endDate, $includeShipping); case 'orders' : diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Esi.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Esi.php index cfa3788bd..453335740 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Esi.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Esi.php @@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\an; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; + /** * Class Esi * @package Thelia\Core\Template\Smarty\Plugins @@ -52,7 +53,7 @@ class Esi extends AbstractSmartyPlugin $ignore_errors = $this->getParam($params, 'ignore_errors'); $comment = $this->getParam($params, 'comment'); - if (null === $path) { + if(null === $path) { return; } @@ -78,4 +79,4 @@ class Esi extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'render_esi', $this, 'renderEsi') ); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php index 4c92ee85c..9b86410de 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php @@ -48,7 +48,7 @@ class Module extends AbstractSmartyPlugin /** * Process theliaModule template inclusion function * - * @param unknown $params + * @param unknown $params * @param \Smarty_Internal_Template $template * @internal param \Thelia\Core\Template\Smarty\Plugins\unknown $smarty * @@ -60,7 +60,7 @@ class Module extends AbstractSmartyPlugin if (false !== $location = $this->getParam($params, 'location', false)) { - if ($this->debug === true && $this->request->get('SHOW_INCLUDE')) { + if($this->debug === true && $this->request->get('SHOW_INCLUDE')) { echo sprintf('
%s
', $location); } @@ -70,7 +70,7 @@ class Module extends AbstractSmartyPlugin foreach ($modules as $module) { - if (null !== $moduleLimit && $moduleLimit != $module->getCode()) { + if(null !== $moduleLimit && $moduleLimit != $module->getCode()) { continue; } diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 3c8b3ddb3..5900b3295 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -14,7 +14,6 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Exception\ResourceNotFoundException; use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\TemplateDefinition; - use Thelia\Model\ConfigQuery; use Thelia\Core\Template\TemplateHelper; use Imagine\Exception\InvalidArgumentException; @@ -73,6 +72,7 @@ class SmartyParser extends Smarty implements ParserInterface $this->setCompileDir($compile_dir); $this->setCacheDir($cache_dir); + $this->debugging = $debug; // Prevent smarty ErrorException: Notice: Undefined index bla bla bla... @@ -80,7 +80,7 @@ class SmartyParser extends Smarty implements ParserInterface // Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés. - if ($debug) { + if($debug) { $this->setCaching(Smarty::CACHING_OFF); $this->setForceCompile(true); } else { @@ -89,6 +89,7 @@ class SmartyParser extends Smarty implements ParserInterface //$this->enableSecurity(); + // The default HTTP status $this->status = 200; @@ -190,7 +191,6 @@ class SmartyParser extends Smarty implements ParserInterface { return $this->templateDefinition->getPath(); } - /** * Return a rendered template, either from file or ftom a string * diff --git a/core/lib/Thelia/Core/Template/TemplateDefinition.php b/core/lib/Thelia/Core/Template/TemplateDefinition.php index 9cf4038f6..7a4d1685c 100644 --- a/core/lib/Thelia/Core/Template/TemplateDefinition.php +++ b/core/lib/Thelia/Core/Template/TemplateDefinition.php @@ -57,12 +57,13 @@ class TemplateDefinition */ protected $type; + public function __construct($name, $type) { $this->name = $name; $this->type = $type; - switch ($type) { + switch($type) { case TemplateDefinition::FRONT_OFFICE: $this->path = self::FRONT_OFFICE_SUBDIR . $name; break; @@ -89,17 +90,14 @@ class TemplateDefinition public function setName($name) { $this->name = $name; - return $this; } - public function getI18nPath() - { + public function getI18nPath() { return $this->getPath() . DS . 'I18n'; } - public function getAbsoluteI18nPath() - { + public function getAbsoluteI18nPath() { return THELIA_TEMPLATE_DIR . $this->getI18nPath(); } @@ -108,8 +106,7 @@ class TemplateDefinition return $this->path; } - public function getAbsolutePath() - { + public function getAbsolutePath() { return THELIA_TEMPLATE_DIR . $this->getPath(); } @@ -118,15 +115,13 @@ class TemplateDefinition return $this->getPath() . DS . 'configs'; } - public function getAbsoluteConfigPath() - { + public function getAbsoluteConfigPath() { return THELIA_TEMPLATE_DIR . $this->getConfigPath(); } public function setPath($path) { $this->path = $path; - return $this; } @@ -138,7 +133,6 @@ class TemplateDefinition public function setType($type) { $this->type = $type; - return $this; } @@ -149,4 +143,3 @@ class TemplateDefinition return new \ArrayIterator(self::$standardTemplatesSubdirs); } } - diff --git a/core/lib/Thelia/Core/Template/TemplateHelper.php b/core/lib/Thelia/Core/Template/TemplateHelper.php index 000a5bfd5..175f83b42 100644 --- a/core/lib/Thelia/Core/Template/TemplateHelper.php +++ b/core/lib/Thelia/Core/Template/TemplateHelper.php @@ -40,17 +40,16 @@ class TemplateHelper private function __construct() {} - public static function getInstance() - { + public static function getInstance() { if (self::$instance == null) self::$instance = new TemplateHelper(); + return self::$instance; } /** * @return TemplateDefinition */ - public function getActiveMailTemplate() - { + public function getActiveMailTemplate() { return new TemplateDefinition( ConfigQuery::read('active-mail-template', 'default'), TemplateDefinition::EMAIL @@ -60,8 +59,7 @@ class TemplateHelper /** * @return TemplateDefinition */ - public function getActivePdfTemplate() - { + public function getActivePdfTemplate() { return new TemplateDefinition( ConfigQuery::read('active-pdf-template', 'default'), TemplateDefinition::PDF @@ -71,8 +69,7 @@ class TemplateHelper /** * @return TemplateDefinition */ - public function getActiveAdminTemplate() - { + public function getActiveAdminTemplate() { return new TemplateDefinition( ConfigQuery::read('active-admin-template', 'default'), TemplateDefinition::BACK_OFFICE @@ -82,8 +79,7 @@ class TemplateHelper /** * @return TemplateDefinition */ - public function getActiveFrontTemplate() - { + public function getActiveFrontTemplate() { return new TemplateDefinition( ConfigQuery::read('active-front-template', 'default'), TemplateDefinition::FRONT_OFFICE @@ -138,6 +134,7 @@ class TemplateHelper } } + protected function normalize_path($path) { $path = str_replace( @@ -158,27 +155,28 @@ class TemplateHelper * 'translation' => the text translation, or an empty string if none available. * 'dollar' => true if the translatable text contains a $ * - * @param string $directory the path to the directory to examine - * @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE - * @param \Thelia\Core\Translation\Translator $translator the current translator - * @param string $currentLocale the current locale - * @param array $strings the list of strings - * @throws \InvalidArgumentException if $walkMode contains an invalid value - * @return number the total number of translatable texts + * @param string $directory the path to the directory to examine + * @param string $walkMode type of file scanning: WALK_MODE_PHP or WALK_MODE_TEMPLATE + * @param \Thelia\Core\Translation\Translator $translator the current translator + * @param string $currentLocale the current locale + * @param array $strings the list of strings + * @throws \InvalidArgumentException if $walkMode contains an invalid value + * @return number the total number of translatable texts */ - public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings) - { + public function walkDir($directory, $walkMode, Translator $translator, $currentLocale, &$strings) { + $num_texts = 0; if ($walkMode == self::WALK_MODE_PHP) { $prefix = '\-\>[\s]*trans[\s]*\('; $allowed_exts = array('php'); - } elseif ($walkMode == self::WALK_MODE_TEMPLATE) { + } else if ($walkMode == self::WALK_MODE_TEMPLATE) { $prefix = '\{intl[\s]l='; $allowed_exts = array('html', 'tpl', 'xml'); - } else { + } + else { throw new \InvalidArgumentException( Translator::getInstance()->trans('Invalid value for walkMode parameter: %value', array('%value' => $walkMode)) ); @@ -212,15 +210,18 @@ class TemplateHelper Tlog::getInstance()->debug("Strings found: ", $matches[2]); - foreach ($matches[2] as $match) { + foreach($matches[2] as $match) { $hash = md5($match); - if (isset($strings[$hash])) { - if (! in_array($short_path, $strings[$hash]['files'])) { + if (isset($strings[$hash])) + { + if (! in_array($short_path, $strings[$hash]['files'])) + { $strings[$hash]['files'][] = $short_path; } - } else { + } + else { $num_texts++; // remove \' @@ -272,7 +273,9 @@ class TemplateHelper fwrite($fp, ");\n"); @fclose($fp); - } else { + } + else + { throw new \RuntimeException( Translator::getInstance()->trans( 'Failed to open translation file %file. Please be sure that this file is writable by your Web server', diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index ddcbf8a2e..6198c7e1c 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -49,6 +49,7 @@ use Thelia\Config\DefinePropel; use Thelia\Core\Template\TemplateDefinition; use Thelia\Core\TheliaContainerBuilder; use Thelia\Core\DependencyInjection\Loader\XmlFileLoader; +use Thelia\Model\ConfigQuery; use Symfony\Component\Config\FileLocator; use Propel\Runtime\Propel; @@ -175,7 +176,7 @@ class Thelia extends Kernel ->depth(0) ->in(THELIA_ROOT . "/core/lib/Thelia/Config/Resources"); - foreach ($finder as $file) { + foreach($finder as $file) { $loader->load($file->getBaseName()); } @@ -369,4 +370,4 @@ class Thelia extends Kernel //Nothing is load here but it's possible to load container configuration here. //exemple in sf2 : $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 6449d0648..ed4dd672b 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -215,7 +215,7 @@ class TheliaHttpKernel extends HttpKernel protected function initSession(Request $request) { - if (null === self::$session) { + if(null === self::$session) { $storage = new Session\Storage\NativeSessionStorage(); if (Model\ConfigQuery::read("session_config.default")) { diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php index fc1c75de2..775ef7ad8 100755 --- a/core/lib/Thelia/Core/Translation/Translator.php +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -40,7 +40,7 @@ class Translator extends BaseTranslator public function getLocale() { - if ($this->container->isScopeActive('request') && $this->container->has('request')) { + if($this->container->isScopeActive('request') && $this->container->has('request')) { return $this->container->get('request')->getSession()->getLang()->getLocale(); } diff --git a/core/lib/Thelia/Coupon/CouponManager.php b/core/lib/Thelia/Coupon/CouponManager.php index 17d85b8cb..c4eff7888 100644 --- a/core/lib/Thelia/Coupon/CouponManager.php +++ b/core/lib/Thelia/Coupon/CouponManager.php @@ -82,8 +82,15 @@ class CouponManager if (count($this->coupons) > 0) { $couponsKept = $this->sortCoupons($this->coupons); + $isRemovingPostage = $this->isCouponRemovingPostage($couponsKept); + $discount = $this->getEffect($couponsKept); + if ($isRemovingPostage) { + $postage = $this->facade->getCheckoutPostagePrice(); + $discount += $postage; + } + // Just In Case test $checkoutTotalPrice = $this->facade->getCartTotalPrice(); if ($discount >= $checkoutTotalPrice) { @@ -96,24 +103,23 @@ class CouponManager /** * Check if there is a Coupon removing Postage + * + * @param array $couponsKept Array of CouponInterface sorted + * * @return bool */ - public function isCouponRemovingPostage() + protected function isCouponRemovingPostage(array $couponsKept) { - if (count($this->coupons) == 0) { - return false; - } - - $couponsKept = $this->sortCoupons($this->coupons); + $isRemovingPostage = false; /** @var CouponInterface $coupon */ foreach ($couponsKept as $coupon) { if ($coupon->isRemovingPostage()) { - return true; + $isRemovingPostage = true; } } - return false; + return $isRemovingPostage; } /** diff --git a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php index 6f44ecc92..3bf0c372a 100755 --- a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php @@ -23,6 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Core\Translation\Translator; use Thelia\Model\CustomerQuery; /** diff --git a/core/lib/Thelia/Form/MailingSystemModificationForm.php b/core/lib/Thelia/Form/MailingSystemModificationForm.php index 709c19144..8334777ab 100644 --- a/core/lib/Thelia/Form/MailingSystemModificationForm.php +++ b/core/lib/Thelia/Form/MailingSystemModificationForm.php @@ -23,6 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; use Thelia\Model\ProfileQuery; diff --git a/core/lib/Thelia/Form/ProductCombinationGenerationForm.php b/core/lib/Thelia/Form/ProductCombinationGenerationForm.php index 1ca633ccd..8e4b155b9 100644 --- a/core/lib/Thelia/Form/ProductCombinationGenerationForm.php +++ b/core/lib/Thelia/Form/ProductCombinationGenerationForm.php @@ -23,6 +23,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; +use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Model\Currency; use Thelia\Core\Translation\Translator; @@ -87,4 +88,4 @@ class ProductCombinationGenerationForm extends BaseForm { return 'thelia_product_combination_generation_form'; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/ProductModificationForm.php b/core/lib/Thelia/Form/ProductModificationForm.php index d2819737c..9dce2e4e5 100644 --- a/core/lib/Thelia/Form/ProductModificationForm.php +++ b/core/lib/Thelia/Form/ProductModificationForm.php @@ -25,6 +25,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Core\Translation\Translator; + class ProductModificationForm extends ProductCreationForm { use StandardDescriptionFieldsTrait; diff --git a/core/lib/Thelia/Form/SeoFieldsTrait.php b/core/lib/Thelia/Form/SeoFieldsTrait.php index 95ce487fc..5b3270793 100644 --- a/core/lib/Thelia/Form/SeoFieldsTrait.php +++ b/core/lib/Thelia/Form/SeoFieldsTrait.php @@ -35,7 +35,7 @@ trait SeoFieldsTrait /** * Add seo meta title, meta description and meta keywords fields * - * @param array $exclude name of the fields that should not be added to the form + * @param array $exclude name of the fields that should not be added to the form */ protected function addSeoFields($exclude = array()) { diff --git a/core/lib/Thelia/Form/SystemLogConfigurationForm.php b/core/lib/Thelia/Form/SystemLogConfigurationForm.php index f4eb62285..9ba9e6cf2 100644 --- a/core/lib/Thelia/Form/SystemLogConfigurationForm.php +++ b/core/lib/Thelia/Form/SystemLogConfigurationForm.php @@ -23,6 +23,8 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; +use Thelia\Model\ConfigQuery; +use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Log\Tlog; use Thelia\Core\Translation\Translator; diff --git a/core/lib/Thelia/Install/CheckPermission.php b/core/lib/Thelia/Install/CheckPermission.php index efdaf6f04..6a9a5245e 100644 --- a/core/lib/Thelia/Install/CheckPermission.php +++ b/core/lib/Thelia/Install/CheckPermission.php @@ -58,7 +58,7 @@ class CheckPermission extends BaseInstall /** @var array Minimum server configuration necessary */ protected $minServerConfigurationNecessary = array( - 'memory_limit' => 134217728, + 'memory_limit' => 157286400, 'post_max_size' => 20971520, 'upload_max_filesize' => 2097152 ); diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php index 08b7aab66..80aa3ec25 100755 --- a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php @@ -138,4 +138,4 @@ class TlogDestinationFile extends AbstractTlogDestination $this->fh = false; } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php b/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php index e1f3444a5..546ab488c 100644 --- a/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php @@ -25,29 +25,27 @@ namespace Thelia\Log\Destination; use Thelia\Log\AbstractTlogDestination; -class TlogDestinationJavascriptConsole extends AbstractTlogDestination -{ - public function getTitle() - { - return "Browser's Javascript console"; - } +class TlogDestinationJavascriptConsole extends AbstractTlogDestination { - public function getDescription() - { - return "The Thelia logs are displayed in your browser's Javascript console."; - } + public function getTitle() { + return "Browser's Javascript console"; + } - public function write(&$res) - { - $content = ''."\n"; + $content = ''."\n"; + + if (preg_match("||i", $res)) + $res = preg_replace("||i", "$content", $res); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationPopup.php b/core/lib/Thelia/Log/Destination/TlogDestinationPopup.php index 547a24c85..1734e2f43 100644 --- a/core/lib/Thelia/Log/Destination/TlogDestinationPopup.php +++ b/core/lib/Thelia/Log/Destination/TlogDestinationPopup.php @@ -26,88 +26,86 @@ namespace Thelia\Log\Destination; use Thelia\Log\AbstractTlogDestination; use Thelia\Log\TlogDestinationConfig; -class TlogDestinationPopup extends AbstractTlogDestination -{ - // Nom des variables de configuration - // ---------------------------------- - const VAR_POPUP_WIDTH = "tlog_destinationpopup_width"; - const VALEUR_POPUP_WIDTH_DEFAUT = "600"; +class TlogDestinationPopup extends AbstractTlogDestination { - const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height"; - const VALEUR_POPUP_HEIGHT_DEFAUT = "600"; + // Nom des variables de configuration + // ---------------------------------- + const VAR_POPUP_WIDTH = "tlog_destinationpopup_width"; + const VALEUR_POPUP_WIDTH_DEFAUT = "600"; - const VAR_POPUP_TPL = "tlog_destinationpopup_template"; - // Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php - const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl"; + const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height"; + const VALEUR_POPUP_HEIGHT_DEFAUT = "600"; - public function getTitle() - { - return "Javascript popup window"; - } + const VAR_POPUP_TPL = "tlog_destinationpopup_template"; + // Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php + const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl"; - public function getDescription() - { - return "Display logs in a popup window, separate from the main window ."; - } + public function getTitle() { + return "Javascript popup window"; + } - public function getConfigs() - { - return array( - new TlogDestinationConfig( - self::VAR_POPUP_TPL, - "Popup windows template", - "Put #LOGTEXT in the template text where you want to display logs..", - file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT), - TlogDestinationConfig::TYPE_TEXTAREA - ), - new TlogDestinationConfig( - self::VAR_POPUP_HEIGHT, - "Height of the popup window", - "In pixels", - self::VALEUR_POPUP_HEIGHT_DEFAUT, - TlogDestinationConfig::TYPE_TEXTFIELD - ), - new TlogDestinationConfig( - self::VAR_POPUP_WIDTH, - "Width of the popup window", - "In pixels", - self::VALEUR_POPUP_WIDTH_DEFAUT, - TlogDestinationConfig::TYPE_TEXTFIELD - ) - ); - } + public function getDescription() { + return "Display logs in a popup window, separate from the main window ."; + } - public function write(&$res) - { - $content = ""; $count = 1; + public function getConfigs() { + return array( + new TlogDestinationConfig( + self::VAR_POPUP_TPL, + "Popup windows template", + "Put #LOGTEXT in the template text where you want to display logs..", + file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT), + TlogDestinationConfig::TYPE_TEXTAREA + ), + new TlogDestinationConfig( + self::VAR_POPUP_HEIGHT, + "Height of the popup window", + "In pixels", + self::VALEUR_POPUP_HEIGHT_DEFAUT, + TlogDestinationConfig::TYPE_TEXTFIELD + ), + new TlogDestinationConfig( + self::VAR_POPUP_WIDTH, + "Width of the popup window", + "In pixels", + self::VALEUR_POPUP_WIDTH_DEFAUT, + TlogDestinationConfig::TYPE_TEXTFIELD + ) + ); + } - foreach ($this->_logs as $line) { - $content .= "
".htmlspecialchars($line)."
"; - } + public function write(&$res) { - $tpl = $this->getConfig(self::VAR_POPUP_TPL); + $content = ""; $count = 1; - $tpl = str_replace('#LOGTEXT', $content, $tpl); - $tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl); + foreach($this->_logs as $line) { + $content .= "
".htmlspecialchars($line)."
"; + } - $wop = sprintf(' - ', - $this->getConfig(self::VAR_POPUP_WIDTH), - $this->getConfig(self::VAR_POPUP_HEIGHT), - str_replace('"', '\\"', $tpl) - ); + $tpl = $this->getConfig(self::VAR_POPUP_TPL); - if (preg_match("||i", $res)) - $res = preg_replace("||i", "$wop\n", $res); - else - $res .= $wop; + $tpl = str_replace('#LOGTEXT', $content, $tpl); + $tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl); + + $wop = sprintf(' + ', + $this->getConfig(self::VAR_POPUP_WIDTH), + $this->getConfig(self::VAR_POPUP_HEIGHT), + str_replace('"', '\\"', $tpl) + ); + + if (preg_match("||i", $res)) + $res = preg_replace("||i", "$wop\n", $res); + else + $res .= $wop; } } diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index 139de9f26..86bd8bb29 100755 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -171,8 +171,7 @@ class Tlog Implements LoggerInterface * * @return array of directories */ - public function getDestinationsDirectories() - { + public function getDestinationsDirectories() { return $this->dir_destinations; } diff --git a/core/lib/Thelia/Log/TlogDestinationConfig.php b/core/lib/Thelia/Log/TlogDestinationConfig.php index cbc56fd33..01c8fbe4f 100755 --- a/core/lib/Thelia/Log/TlogDestinationConfig.php +++ b/core/lib/Thelia/Log/TlogDestinationConfig.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Log; +use Thelia\Model\Config; use Thelia\Model\ConfigQuery; class TlogDestinationConfig diff --git a/core/lib/Thelia/Model/Base/CartItem.php b/core/lib/Thelia/Model/Base/CartItem.php index 0591d07e6..53b3ef411 100644 --- a/core/lib/Thelia/Model/Base/CartItem.php +++ b/core/lib/Thelia/Model/Base/CartItem.php @@ -109,6 +109,13 @@ abstract class CartItem implements ActiveRecordInterface */ protected $price_end_of_life; + /** + * The value for the discount field. + * Note: this column has a database default value of: 0 + * @var double + */ + protected $discount; + /** * The value for the promo field. * @var int @@ -159,6 +166,7 @@ abstract class CartItem implements ActiveRecordInterface public function applyDefaultValues() { $this->quantity = 1; + $this->discount = 0; } /** @@ -518,6 +526,17 @@ abstract class CartItem implements ActiveRecordInterface } } + /** + * Get the [discount] column value. + * + * @return double + */ + public function getDiscount() + { + + return $this->discount; + } + /** * Get the [promo] column value. * @@ -749,6 +768,27 @@ abstract class CartItem implements ActiveRecordInterface return $this; } // setPriceEndOfLife() + /** + * Set the value of [discount] column. + * + * @param double $v new value + * @return \Thelia\Model\CartItem The current object (for fluent API support) + */ + public function setDiscount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->discount !== $v) { + $this->discount = $v; + $this->modifiedColumns[] = CartItemTableMap::DISCOUNT; + } + + + return $this; + } // setDiscount() + /** * Set the value of [promo] column. * @@ -826,6 +866,10 @@ abstract class CartItem implements ActiveRecordInterface return false; } + if ($this->discount !== 0) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -880,16 +924,19 @@ abstract class CartItem implements ActiveRecordInterface } $this->price_end_of_life = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : CartItemTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->discount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)]; $this->promo = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : CartItemTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : CartItemTableMap::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 ? 10 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : CartItemTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -902,7 +949,7 @@ abstract class CartItem implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 11; // 11 = CartItemTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 12; // 12 = CartItemTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\CartItem object", 0, $e); @@ -1184,6 +1231,9 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) { $modifiedColumns[':p' . $index++] = 'PRICE_END_OF_LIFE'; } + if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) { + $modifiedColumns[':p' . $index++] = 'DISCOUNT'; + } if ($this->isColumnModified(CartItemTableMap::PROMO)) { $modifiedColumns[':p' . $index++] = 'PROMO'; } @@ -1228,6 +1278,9 @@ abstract class CartItem implements ActiveRecordInterface case 'PRICE_END_OF_LIFE': $stmt->bindValue($identifier, $this->price_end_of_life ? $this->price_end_of_life->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; + case 'DISCOUNT': + $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); + break; case 'PROMO': $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); break; @@ -1324,12 +1377,15 @@ abstract class CartItem implements ActiveRecordInterface return $this->getPriceEndOfLife(); break; case 8: - return $this->getPromo(); + return $this->getDiscount(); break; case 9: - return $this->getCreatedAt(); + return $this->getPromo(); break; case 10: + return $this->getCreatedAt(); + break; + case 11: return $this->getUpdatedAt(); break; default: @@ -1369,9 +1425,10 @@ abstract class CartItem implements ActiveRecordInterface $keys[5] => $this->getPrice(), $keys[6] => $this->getPromoPrice(), $keys[7] => $this->getPriceEndOfLife(), - $keys[8] => $this->getPromo(), - $keys[9] => $this->getCreatedAt(), - $keys[10] => $this->getUpdatedAt(), + $keys[8] => $this->getDiscount(), + $keys[9] => $this->getPromo(), + $keys[10] => $this->getCreatedAt(), + $keys[11] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1447,12 +1504,15 @@ abstract class CartItem implements ActiveRecordInterface $this->setPriceEndOfLife($value); break; case 8: - $this->setPromo($value); + $this->setDiscount($value); break; case 9: - $this->setCreatedAt($value); + $this->setPromo($value); break; case 10: + $this->setCreatedAt($value); + break; + case 11: $this->setUpdatedAt($value); break; } // switch() @@ -1487,9 +1547,10 @@ abstract class CartItem implements ActiveRecordInterface if (array_key_exists($keys[5], $arr)) $this->setPrice($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setPromoPrice($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setPriceEndOfLife($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setPromo($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); + if (array_key_exists($keys[8], $arr)) $this->setDiscount($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setPromo($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); + if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); } /** @@ -1509,6 +1570,7 @@ abstract class CartItem implements ActiveRecordInterface if ($this->isColumnModified(CartItemTableMap::PRICE)) $criteria->add(CartItemTableMap::PRICE, $this->price); if ($this->isColumnModified(CartItemTableMap::PROMO_PRICE)) $criteria->add(CartItemTableMap::PROMO_PRICE, $this->promo_price); if ($this->isColumnModified(CartItemTableMap::PRICE_END_OF_LIFE)) $criteria->add(CartItemTableMap::PRICE_END_OF_LIFE, $this->price_end_of_life); + if ($this->isColumnModified(CartItemTableMap::DISCOUNT)) $criteria->add(CartItemTableMap::DISCOUNT, $this->discount); if ($this->isColumnModified(CartItemTableMap::PROMO)) $criteria->add(CartItemTableMap::PROMO, $this->promo); if ($this->isColumnModified(CartItemTableMap::CREATED_AT)) $criteria->add(CartItemTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(CartItemTableMap::UPDATED_AT)) $criteria->add(CartItemTableMap::UPDATED_AT, $this->updated_at); @@ -1582,6 +1644,7 @@ abstract class CartItem implements ActiveRecordInterface $copyObj->setPrice($this->getPrice()); $copyObj->setPromoPrice($this->getPromoPrice()); $copyObj->setPriceEndOfLife($this->getPriceEndOfLife()); + $copyObj->setDiscount($this->getDiscount()); $copyObj->setPromo($this->getPromo()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1779,6 +1842,7 @@ abstract class CartItem implements ActiveRecordInterface $this->price = null; $this->promo_price = null; $this->price_end_of_life = null; + $this->discount = null; $this->promo = null; $this->created_at = null; $this->updated_at = null; diff --git a/core/lib/Thelia/Model/Base/CartItemQuery.php b/core/lib/Thelia/Model/Base/CartItemQuery.php index 524707a26..79d5d3cfe 100644 --- a/core/lib/Thelia/Model/Base/CartItemQuery.php +++ b/core/lib/Thelia/Model/Base/CartItemQuery.php @@ -29,6 +29,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery orderByPrice($order = Criteria::ASC) Order by the price column * @method ChildCartItemQuery orderByPromoPrice($order = Criteria::ASC) Order by the promo_price column * @method ChildCartItemQuery orderByPriceEndOfLife($order = Criteria::ASC) Order by the price_end_of_life column + * @method ChildCartItemQuery orderByDiscount($order = Criteria::ASC) Order by the discount column * @method ChildCartItemQuery orderByPromo($order = Criteria::ASC) Order by the promo column * @method ChildCartItemQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildCartItemQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -41,6 +42,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItemQuery groupByPrice() Group by the price column * @method ChildCartItemQuery groupByPromoPrice() Group by the promo_price column * @method ChildCartItemQuery groupByPriceEndOfLife() Group by the price_end_of_life column + * @method ChildCartItemQuery groupByDiscount() Group by the discount column * @method ChildCartItemQuery groupByPromo() Group by the promo column * @method ChildCartItemQuery groupByCreatedAt() Group by the created_at column * @method ChildCartItemQuery groupByUpdatedAt() Group by the updated_at column @@ -72,6 +74,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method ChildCartItem findOneByPrice(double $price) Return the first ChildCartItem filtered by the price column * @method ChildCartItem findOneByPromoPrice(double $promo_price) Return the first ChildCartItem filtered by the promo_price column * @method ChildCartItem findOneByPriceEndOfLife(string $price_end_of_life) Return the first ChildCartItem filtered by the price_end_of_life column + * @method ChildCartItem findOneByDiscount(double $discount) Return the first ChildCartItem filtered by the discount column * @method ChildCartItem findOneByPromo(int $promo) Return the first ChildCartItem filtered by the promo column * @method ChildCartItem findOneByCreatedAt(string $created_at) Return the first ChildCartItem filtered by the created_at column * @method ChildCartItem findOneByUpdatedAt(string $updated_at) Return the first ChildCartItem filtered by the updated_at column @@ -84,6 +87,7 @@ use Thelia\Model\Map\CartItemTableMap; * @method array findByPrice(double $price) Return ChildCartItem objects filtered by the price column * @method array findByPromoPrice(double $promo_price) Return ChildCartItem objects filtered by the promo_price column * @method array findByPriceEndOfLife(string $price_end_of_life) Return ChildCartItem objects filtered by the price_end_of_life column + * @method array findByDiscount(double $discount) Return ChildCartItem objects filtered by the discount column * @method array findByPromo(int $promo) Return ChildCartItem objects filtered by the promo column * @method array findByCreatedAt(string $created_at) Return ChildCartItem objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildCartItem objects filtered by the updated_at column @@ -175,7 +179,7 @@ abstract class CartItemQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, PROMO, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; + $sql = 'SELECT ID, CART_ID, PRODUCT_ID, QUANTITY, PRODUCT_SALE_ELEMENTS_ID, PRICE, PROMO_PRICE, PRICE_END_OF_LIFE, DISCOUNT, PROMO, CREATED_AT, UPDATED_AT FROM cart_item WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -600,6 +604,47 @@ abstract class CartItemQuery extends ModelCriteria return $this->addUsingAlias(CartItemTableMap::PRICE_END_OF_LIFE, $priceEndOfLife, $comparison); } + /** + * Filter the query on the discount column + * + * Example usage: + * + * $query->filterByDiscount(1234); // WHERE discount = 1234 + * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34) + * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12 + * + * + * @param mixed $discount 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 ChildCartItemQuery The current query, for fluid interface + */ + public function filterByDiscount($discount = null, $comparison = null) + { + if (is_array($discount)) { + $useMinMax = false; + if (isset($discount['min'])) { + $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($discount['max'])) { + $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CartItemTableMap::DISCOUNT, $discount, $comparison); + } + /** * Filter the query on the promo column * diff --git a/core/lib/Thelia/Model/Base/OrderCoupon.php b/core/lib/Thelia/Model/Base/CouponOrder.php similarity index 59% rename from core/lib/Thelia/Model/Base/OrderCoupon.php rename to core/lib/Thelia/Model/Base/CouponOrder.php index f46404d64..4488e8ec6 100644 --- a/core/lib/Thelia/Model/Base/OrderCoupon.php +++ b/core/lib/Thelia/Model/Base/CouponOrder.php @@ -16,18 +16,18 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; +use Thelia\Model\CouponOrder as ChildCouponOrder; +use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; use Thelia\Model\Order as ChildOrder; -use Thelia\Model\OrderCoupon as ChildOrderCoupon; -use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery; use Thelia\Model\OrderQuery as ChildOrderQuery; -use Thelia\Model\Map\OrderCouponTableMap; +use Thelia\Model\Map\CouponOrderTableMap; -abstract class OrderCoupon implements ActiveRecordInterface +abstract class CouponOrder implements ActiveRecordInterface { /** * TableMap class name */ - const TABLE_MAP = '\\Thelia\\Model\\Map\\OrderCouponTableMap'; + const TABLE_MAP = '\\Thelia\\Model\\Map\\CouponOrderTableMap'; /** @@ -69,70 +69,10 @@ abstract class OrderCoupon implements ActiveRecordInterface protected $order_id; /** - * The value for the code field. - * @var string - */ - protected $code; - - /** - * The value for the type field. - * @var string - */ - protected $type; - - /** - * The value for the amount field. + * The value for the value field. * @var double */ - protected $amount; - - /** - * The value for the title field. - * @var string - */ - protected $title; - - /** - * The value for the short_description field. - * @var string - */ - protected $short_description; - - /** - * The value for the description field. - * @var string - */ - protected $description; - - /** - * The value for the expiration_date field. - * @var string - */ - protected $expiration_date; - - /** - * The value for the is_cumulative field. - * @var boolean - */ - protected $is_cumulative; - - /** - * The value for the is_removing_postage field. - * @var boolean - */ - protected $is_removing_postage; - - /** - * The value for the is_available_on_special_offers field. - * @var boolean - */ - protected $is_available_on_special_offers; - - /** - * The value for the serialized_conditions field. - * @var string - */ - protected $serialized_conditions; + protected $value; /** * The value for the created_at field. @@ -160,7 +100,7 @@ abstract class OrderCoupon implements ActiveRecordInterface protected $alreadyInSave = false; /** - * Initializes internal state of Thelia\Model\Base\OrderCoupon object. + * Initializes internal state of Thelia\Model\Base\CouponOrder object. */ public function __construct() { @@ -255,9 +195,9 @@ abstract class OrderCoupon implements ActiveRecordInterface } /** - * Compares this with another OrderCoupon instance. If - * obj is an instance of OrderCoupon, delegates to - * equals(OrderCoupon). Otherwise, returns false. + * Compares this with another CouponOrder instance. If + * obj is an instance of CouponOrder, delegates to + * equals(CouponOrder). Otherwise, returns false. * * @param mixed $obj The object to compare to. * @return boolean Whether equal to the object specified. @@ -340,7 +280,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * @param string $name The virtual column name * @param mixed $value The value to give to the virtual column * - * @return OrderCoupon The current object, for fluid interface + * @return CouponOrder The current object, for fluid interface */ public function setVirtualColumn($name, $value) { @@ -372,7 +312,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * or a format name ('XML', 'YAML', 'JSON', 'CSV') * @param string $data The source data to import from * - * @return OrderCoupon The current object, for fluid interface + * @return CouponOrder The current object, for fluid interface */ public function importFrom($parser, $data) { @@ -440,133 +380,14 @@ abstract class OrderCoupon implements ActiveRecordInterface } /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - - return $this->code; - } - - /** - * Get the [type] column value. - * - * @return string - */ - public function getType() - { - - return $this->type; - } - - /** - * Get the [amount] column value. + * Get the [value] column value. * * @return double */ - public function getAmount() + public function getValue() { - return $this->amount; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - - return $this->title; - } - - /** - * Get the [short_description] column value. - * - * @return string - */ - public function getShortDescription() - { - - return $this->short_description; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - - return $this->description; - } - - /** - * Get the [optionally formatted] temporal [expiration_date] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getExpirationDate($format = NULL) - { - if ($format === null) { - return $this->expiration_date; - } else { - return $this->expiration_date instanceof \DateTime ? $this->expiration_date->format($format) : null; - } - } - - /** - * Get the [is_cumulative] column value. - * - * @return boolean - */ - public function getIsCumulative() - { - - return $this->is_cumulative; - } - - /** - * Get the [is_removing_postage] column value. - * - * @return boolean - */ - public function getIsRemovingPostage() - { - - return $this->is_removing_postage; - } - - /** - * Get the [is_available_on_special_offers] column value. - * - * @return boolean - */ - public function getIsAvailableOnSpecialOffers() - { - - return $this->is_available_on_special_offers; - } - - /** - * Get the [serialized_conditions] column value. - * - * @return string - */ - public function getSerializedConditions() - { - - return $this->serialized_conditions; + return $this->value; } /** @@ -613,7 +434,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * Set the value of [id] column. * * @param int $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) */ public function setId($v) { @@ -623,7 +444,7 @@ abstract class OrderCoupon implements ActiveRecordInterface if ($this->id !== $v) { $this->id = $v; - $this->modifiedColumns[] = OrderCouponTableMap::ID; + $this->modifiedColumns[] = CouponOrderTableMap::ID; } @@ -634,7 +455,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * Set the value of [order_id] column. * * @param int $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) */ public function setOrderId($v) { @@ -644,7 +465,7 @@ abstract class OrderCoupon implements ActiveRecordInterface if ($this->order_id !== $v) { $this->order_id = $v; - $this->modifiedColumns[] = OrderCouponTableMap::ORDER_ID; + $this->modifiedColumns[] = CouponOrderTableMap::ORDER_ID; } if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { @@ -656,266 +477,32 @@ abstract class OrderCoupon implements ActiveRecordInterface } // setOrderId() /** - * Set the value of [code] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = OrderCouponTableMap::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [type] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setType($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = OrderCouponTableMap::TYPE; - } - - - return $this; - } // setType() - - /** - * Set the value of [amount] column. + * Set the value of [value] column. * * @param double $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) */ - public function setAmount($v) + public function setValue($v) { if ($v !== null) { $v = (double) $v; } - if ($this->amount !== $v) { - $this->amount = $v; - $this->modifiedColumns[] = OrderCouponTableMap::AMOUNT; + if ($this->value !== $v) { + $this->value = $v; + $this->modifiedColumns[] = CouponOrderTableMap::VALUE; } return $this; - } // setAmount() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = OrderCouponTableMap::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [short_description] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setShortDescription($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->short_description !== $v) { - $this->short_description = $v; - $this->modifiedColumns[] = OrderCouponTableMap::SHORT_DESCRIPTION; - } - - - return $this; - } // setShortDescription() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = OrderCouponTableMap::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Sets the value of [expiration_date] 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\OrderCoupon The current object (for fluent API support) - */ - public function setExpirationDate($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->expiration_date !== null || $dt !== null) { - if ($dt !== $this->expiration_date) { - $this->expiration_date = $dt; - $this->modifiedColumns[] = OrderCouponTableMap::EXPIRATION_DATE; - } - } // if either are not null - - - return $this; - } // setExpirationDate() - - /** - * Sets the value of the [is_cumulative] column. - * Non-boolean arguments are converted using the following rules: - * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true - * * 0, '0', 'false', 'off', and 'no' are converted to boolean false - * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). - * - * @param boolean|integer|string $v The new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setIsCumulative($v) - { - if ($v !== null) { - if (is_string($v)) { - $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; - } else { - $v = (boolean) $v; - } - } - - if ($this->is_cumulative !== $v) { - $this->is_cumulative = $v; - $this->modifiedColumns[] = OrderCouponTableMap::IS_CUMULATIVE; - } - - - return $this; - } // setIsCumulative() - - /** - * Sets the value of the [is_removing_postage] column. - * Non-boolean arguments are converted using the following rules: - * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true - * * 0, '0', 'false', 'off', and 'no' are converted to boolean false - * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). - * - * @param boolean|integer|string $v The new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setIsRemovingPostage($v) - { - if ($v !== null) { - if (is_string($v)) { - $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; - } else { - $v = (boolean) $v; - } - } - - if ($this->is_removing_postage !== $v) { - $this->is_removing_postage = $v; - $this->modifiedColumns[] = OrderCouponTableMap::IS_REMOVING_POSTAGE; - } - - - return $this; - } // setIsRemovingPostage() - - /** - * Sets the value of the [is_available_on_special_offers] column. - * Non-boolean arguments are converted using the following rules: - * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true - * * 0, '0', 'false', 'off', and 'no' are converted to boolean false - * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). - * - * @param boolean|integer|string $v The new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setIsAvailableOnSpecialOffers($v) - { - if ($v !== null) { - if (is_string($v)) { - $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; - } else { - $v = (boolean) $v; - } - } - - if ($this->is_available_on_special_offers !== $v) { - $this->is_available_on_special_offers = $v; - $this->modifiedColumns[] = OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS; - } - - - return $this; - } // setIsAvailableOnSpecialOffers() - - /** - * Set the value of [serialized_conditions] column. - * - * @param string $v new value - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) - */ - public function setSerializedConditions($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->serialized_conditions !== $v) { - $this->serialized_conditions = $v; - $this->modifiedColumns[] = OrderCouponTableMap::SERIALIZED_CONDITIONS; - } - - - return $this; - } // setSerializedConditions() + } // setValue() /** * 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\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) */ public function setCreatedAt($v) { @@ -923,7 +510,7 @@ abstract class OrderCoupon implements ActiveRecordInterface if ($this->created_at !== null || $dt !== null) { if ($dt !== $this->created_at) { $this->created_at = $dt; - $this->modifiedColumns[] = OrderCouponTableMap::CREATED_AT; + $this->modifiedColumns[] = CouponOrderTableMap::CREATED_AT; } } // if either are not null @@ -936,7 +523,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * * @param mixed $v string, integer (timestamp), or \DateTime value. * Empty strings are treated as NULL. - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) */ public function setUpdatedAt($v) { @@ -944,7 +531,7 @@ abstract class OrderCoupon implements ActiveRecordInterface if ($this->updated_at !== null || $dt !== null) { if ($dt !== $this->updated_at) { $this->updated_at = $dt; - $this->modifiedColumns[] = OrderCouponTableMap::UPDATED_AT; + $this->modifiedColumns[] = CouponOrderTableMap::UPDATED_AT; } } // if either are not null @@ -989,55 +576,22 @@ abstract class OrderCoupon implements ActiveRecordInterface try { - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : OrderCouponTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CouponOrderTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : OrderCouponTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CouponOrderTableMap::translateFieldName('OrderId', TableMap::TYPE_PHPNAME, $indexType)]; $this->order_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : OrderCouponTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; - $this->code = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : CouponOrderTableMap::translateFieldName('Value', TableMap::TYPE_PHPNAME, $indexType)]; + $this->value = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : OrderCouponTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; - $this->type = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderCouponTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; - $this->amount = (null !== $col) ? (double) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderCouponTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderCouponTableMap::translateFieldName('ShortDescription', TableMap::TYPE_PHPNAME, $indexType)]; - $this->short_description = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderCouponTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; - $this->description = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : OrderCouponTableMap::translateFieldName('ExpirationDate', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->expiration_date = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : OrderCouponTableMap::translateFieldName('IsCumulative', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_cumulative = (null !== $col) ? (boolean) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderCouponTableMap::translateFieldName('IsRemovingPostage', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_removing_postage = (null !== $col) ? (boolean) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderCouponTableMap::translateFieldName('IsAvailableOnSpecialOffers', TableMap::TYPE_PHPNAME, $indexType)]; - $this->is_available_on_special_offers = (null !== $col) ? (boolean) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderCouponTableMap::translateFieldName('SerializedConditions', TableMap::TYPE_PHPNAME, $indexType)]; - $this->serialized_conditions = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderCouponTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : CouponOrderTableMap::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 ? 14 + $startcol : OrderCouponTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : CouponOrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1050,10 +604,10 @@ abstract class OrderCoupon implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 15; // 15 = OrderCouponTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 5; // 5 = CouponOrderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\OrderCoupon object", 0, $e); + throw new PropelException("Error populating \Thelia\Model\CouponOrder object", 0, $e); } } @@ -1098,13 +652,13 @@ abstract class OrderCoupon implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(OrderCouponTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME); } // We don't need to alter the object instance pool; we're just modifying this instance // already in the pool. - $dataFetcher = ChildOrderCouponQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $dataFetcher = ChildCouponOrderQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); $row = $dataFetcher->fetch(); $dataFetcher->close(); if (!$row) { @@ -1124,8 +678,8 @@ abstract class OrderCoupon implements ActiveRecordInterface * @param ConnectionInterface $con * @return void * @throws PropelException - * @see OrderCoupon::setDeleted() - * @see OrderCoupon::isDeleted() + * @see CouponOrder::setDeleted() + * @see CouponOrder::isDeleted() */ public function delete(ConnectionInterface $con = null) { @@ -1134,12 +688,12 @@ abstract class OrderCoupon implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); } $con->beginTransaction(); try { - $deleteQuery = ChildOrderCouponQuery::create() + $deleteQuery = ChildCouponOrderQuery::create() ->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { @@ -1176,7 +730,7 @@ abstract class OrderCoupon implements ActiveRecordInterface } if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); } $con->beginTransaction(); @@ -1186,16 +740,16 @@ abstract class OrderCoupon implements ActiveRecordInterface if ($isInsert) { $ret = $ret && $this->preInsert($con); // timestampable behavior - if (!$this->isColumnModified(OrderCouponTableMap::CREATED_AT)) { + if (!$this->isColumnModified(CouponOrderTableMap::CREATED_AT)) { $this->setCreatedAt(time()); } - if (!$this->isColumnModified(OrderCouponTableMap::UPDATED_AT)) { + if (!$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } else { $ret = $ret && $this->preUpdate($con); // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderCouponTableMap::UPDATED_AT)) { + if ($this->isModified() && !$this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) { $this->setUpdatedAt(time()); } } @@ -1207,7 +761,7 @@ abstract class OrderCoupon implements ActiveRecordInterface $this->postUpdate($con); } $this->postSave($con); - OrderCouponTableMap::addInstanceToPool($this); + CouponOrderTableMap::addInstanceToPool($this); } else { $affectedRows = 0; } @@ -1280,60 +834,30 @@ abstract class OrderCoupon implements ActiveRecordInterface $modifiedColumns = array(); $index = 0; - $this->modifiedColumns[] = OrderCouponTableMap::ID; + $this->modifiedColumns[] = CouponOrderTableMap::ID; if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderCouponTableMap::ID . ')'); + throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponOrderTableMap::ID . ')'); } // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderCouponTableMap::ID)) { + if ($this->isColumnModified(CouponOrderTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(OrderCouponTableMap::ORDER_ID)) { + if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) { $modifiedColumns[':p' . $index++] = 'ORDER_ID'; } - if ($this->isColumnModified(OrderCouponTableMap::CODE)) { - $modifiedColumns[':p' . $index++] = 'CODE'; + if ($this->isColumnModified(CouponOrderTableMap::VALUE)) { + $modifiedColumns[':p' . $index++] = 'VALUE'; } - if ($this->isColumnModified(OrderCouponTableMap::TYPE)) { - $modifiedColumns[':p' . $index++] = 'TYPE'; - } - if ($this->isColumnModified(OrderCouponTableMap::AMOUNT)) { - $modifiedColumns[':p' . $index++] = 'AMOUNT'; - } - if ($this->isColumnModified(OrderCouponTableMap::TITLE)) { - $modifiedColumns[':p' . $index++] = 'TITLE'; - } - if ($this->isColumnModified(OrderCouponTableMap::SHORT_DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'SHORT_DESCRIPTION'; - } - if ($this->isColumnModified(OrderCouponTableMap::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; - } - if ($this->isColumnModified(OrderCouponTableMap::EXPIRATION_DATE)) { - $modifiedColumns[':p' . $index++] = 'EXPIRATION_DATE'; - } - if ($this->isColumnModified(OrderCouponTableMap::IS_CUMULATIVE)) { - $modifiedColumns[':p' . $index++] = 'IS_CUMULATIVE'; - } - if ($this->isColumnModified(OrderCouponTableMap::IS_REMOVING_POSTAGE)) { - $modifiedColumns[':p' . $index++] = 'IS_REMOVING_POSTAGE'; - } - if ($this->isColumnModified(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) { - $modifiedColumns[':p' . $index++] = 'IS_AVAILABLE_ON_SPECIAL_OFFERS'; - } - if ($this->isColumnModified(OrderCouponTableMap::SERIALIZED_CONDITIONS)) { - $modifiedColumns[':p' . $index++] = 'SERIALIZED_CONDITIONS'; - } - if ($this->isColumnModified(OrderCouponTableMap::CREATED_AT)) { + if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } - if ($this->isColumnModified(OrderCouponTableMap::UPDATED_AT)) { + if ($this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) { $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; } $sql = sprintf( - 'INSERT INTO order_coupon (%s) VALUES (%s)', + 'INSERT INTO coupon_order (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); @@ -1348,38 +872,8 @@ abstract class OrderCoupon implements ActiveRecordInterface case 'ORDER_ID': $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); break; - case 'CODE': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case 'TYPE': - $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); - break; - case 'AMOUNT': - $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); - break; - case 'TITLE': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case 'SHORT_DESCRIPTION': - $stmt->bindValue($identifier, $this->short_description, PDO::PARAM_STR); - break; - case 'DESCRIPTION': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case 'EXPIRATION_DATE': - $stmt->bindValue($identifier, $this->expiration_date ? $this->expiration_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'IS_CUMULATIVE': - $stmt->bindValue($identifier, (int) $this->is_cumulative, PDO::PARAM_INT); - break; - case 'IS_REMOVING_POSTAGE': - $stmt->bindValue($identifier, (int) $this->is_removing_postage, PDO::PARAM_INT); - break; - case 'IS_AVAILABLE_ON_SPECIAL_OFFERS': - $stmt->bindValue($identifier, (int) $this->is_available_on_special_offers, PDO::PARAM_INT); - break; - case 'SERIALIZED_CONDITIONS': - $stmt->bindValue($identifier, $this->serialized_conditions, PDO::PARAM_STR); + case 'VALUE': + $stmt->bindValue($identifier, $this->value, 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); @@ -1433,7 +927,7 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function getByName($name, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderCouponTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); $field = $this->getByPosition($pos); return $field; @@ -1456,42 +950,12 @@ abstract class OrderCoupon implements ActiveRecordInterface return $this->getOrderId(); break; case 2: - return $this->getCode(); + return $this->getValue(); break; case 3: - return $this->getType(); - break; - case 4: - return $this->getAmount(); - break; - case 5: - return $this->getTitle(); - break; - case 6: - return $this->getShortDescription(); - break; - case 7: - return $this->getDescription(); - break; - case 8: - return $this->getExpirationDate(); - break; - case 9: - return $this->getIsCumulative(); - break; - case 10: - return $this->getIsRemovingPostage(); - break; - case 11: - return $this->getIsAvailableOnSpecialOffers(); - break; - case 12: - return $this->getSerializedConditions(); - break; - case 13: return $this->getCreatedAt(); break; - case 14: + case 4: return $this->getUpdatedAt(); break; default: @@ -1517,27 +981,17 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { - if (isset($alreadyDumpedObjects['OrderCoupon'][$this->getPrimaryKey()])) { + if (isset($alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()])) { return '*RECURSION*'; } - $alreadyDumpedObjects['OrderCoupon'][$this->getPrimaryKey()] = true; - $keys = OrderCouponTableMap::getFieldNames($keyType); + $alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()] = true; + $keys = CouponOrderTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getOrderId(), - $keys[2] => $this->getCode(), - $keys[3] => $this->getType(), - $keys[4] => $this->getAmount(), - $keys[5] => $this->getTitle(), - $keys[6] => $this->getShortDescription(), - $keys[7] => $this->getDescription(), - $keys[8] => $this->getExpirationDate(), - $keys[9] => $this->getIsCumulative(), - $keys[10] => $this->getIsRemovingPostage(), - $keys[11] => $this->getIsAvailableOnSpecialOffers(), - $keys[12] => $this->getSerializedConditions(), - $keys[13] => $this->getCreatedAt(), - $keys[14] => $this->getUpdatedAt(), + $keys[2] => $this->getValue(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1566,7 +1020,7 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) { - $pos = OrderCouponTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $pos = CouponOrderTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); return $this->setByPosition($pos, $value); } @@ -1589,42 +1043,12 @@ abstract class OrderCoupon implements ActiveRecordInterface $this->setOrderId($value); break; case 2: - $this->setCode($value); + $this->setValue($value); break; case 3: - $this->setType($value); - break; - case 4: - $this->setAmount($value); - break; - case 5: - $this->setTitle($value); - break; - case 6: - $this->setShortDescription($value); - break; - case 7: - $this->setDescription($value); - break; - case 8: - $this->setExpirationDate($value); - break; - case 9: - $this->setIsCumulative($value); - break; - case 10: - $this->setIsRemovingPostage($value); - break; - case 11: - $this->setIsAvailableOnSpecialOffers($value); - break; - case 12: - $this->setSerializedConditions($value); - break; - case 13: $this->setCreatedAt($value); break; - case 14: + case 4: $this->setUpdatedAt($value); break; } // switch() @@ -1649,23 +1073,13 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) { - $keys = OrderCouponTableMap::getFieldNames($keyType); + $keys = CouponOrderTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setType($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAmount($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setTitle($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setShortDescription($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setDescription($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setExpirationDate($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setIsCumulative($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setIsRemovingPostage($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setIsAvailableOnSpecialOffers($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setSerializedConditions($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]); + if (array_key_exists($keys[2], $arr)) $this->setValue($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]]); } /** @@ -1675,23 +1089,13 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function buildCriteria() { - $criteria = new Criteria(OrderCouponTableMap::DATABASE_NAME); + $criteria = new Criteria(CouponOrderTableMap::DATABASE_NAME); - if ($this->isColumnModified(OrderCouponTableMap::ID)) $criteria->add(OrderCouponTableMap::ID, $this->id); - if ($this->isColumnModified(OrderCouponTableMap::ORDER_ID)) $criteria->add(OrderCouponTableMap::ORDER_ID, $this->order_id); - if ($this->isColumnModified(OrderCouponTableMap::CODE)) $criteria->add(OrderCouponTableMap::CODE, $this->code); - if ($this->isColumnModified(OrderCouponTableMap::TYPE)) $criteria->add(OrderCouponTableMap::TYPE, $this->type); - if ($this->isColumnModified(OrderCouponTableMap::AMOUNT)) $criteria->add(OrderCouponTableMap::AMOUNT, $this->amount); - if ($this->isColumnModified(OrderCouponTableMap::TITLE)) $criteria->add(OrderCouponTableMap::TITLE, $this->title); - if ($this->isColumnModified(OrderCouponTableMap::SHORT_DESCRIPTION)) $criteria->add(OrderCouponTableMap::SHORT_DESCRIPTION, $this->short_description); - if ($this->isColumnModified(OrderCouponTableMap::DESCRIPTION)) $criteria->add(OrderCouponTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(OrderCouponTableMap::EXPIRATION_DATE)) $criteria->add(OrderCouponTableMap::EXPIRATION_DATE, $this->expiration_date); - if ($this->isColumnModified(OrderCouponTableMap::IS_CUMULATIVE)) $criteria->add(OrderCouponTableMap::IS_CUMULATIVE, $this->is_cumulative); - if ($this->isColumnModified(OrderCouponTableMap::IS_REMOVING_POSTAGE)) $criteria->add(OrderCouponTableMap::IS_REMOVING_POSTAGE, $this->is_removing_postage); - if ($this->isColumnModified(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS)) $criteria->add(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, $this->is_available_on_special_offers); - if ($this->isColumnModified(OrderCouponTableMap::SERIALIZED_CONDITIONS)) $criteria->add(OrderCouponTableMap::SERIALIZED_CONDITIONS, $this->serialized_conditions); - if ($this->isColumnModified(OrderCouponTableMap::CREATED_AT)) $criteria->add(OrderCouponTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderCouponTableMap::UPDATED_AT)) $criteria->add(OrderCouponTableMap::UPDATED_AT, $this->updated_at); + if ($this->isColumnModified(CouponOrderTableMap::ID)) $criteria->add(CouponOrderTableMap::ID, $this->id); + if ($this->isColumnModified(CouponOrderTableMap::ORDER_ID)) $criteria->add(CouponOrderTableMap::ORDER_ID, $this->order_id); + if ($this->isColumnModified(CouponOrderTableMap::VALUE)) $criteria->add(CouponOrderTableMap::VALUE, $this->value); + if ($this->isColumnModified(CouponOrderTableMap::CREATED_AT)) $criteria->add(CouponOrderTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(CouponOrderTableMap::UPDATED_AT)) $criteria->add(CouponOrderTableMap::UPDATED_AT, $this->updated_at); return $criteria; } @@ -1706,8 +1110,8 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function buildPkeyCriteria() { - $criteria = new Criteria(OrderCouponTableMap::DATABASE_NAME); - $criteria->add(OrderCouponTableMap::ID, $this->id); + $criteria = new Criteria(CouponOrderTableMap::DATABASE_NAME); + $criteria->add(CouponOrderTableMap::ID, $this->id); return $criteria; } @@ -1748,7 +1152,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * If desired, this method can also make copies of all associated (fkey referrers) * objects. * - * @param object $copyObj An object of \Thelia\Model\OrderCoupon (or compatible) type. + * @param object $copyObj An object of \Thelia\Model\CouponOrder (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 @@ -1756,17 +1160,7 @@ abstract class OrderCoupon implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setOrderId($this->getOrderId()); - $copyObj->setCode($this->getCode()); - $copyObj->setType($this->getType()); - $copyObj->setAmount($this->getAmount()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setShortDescription($this->getShortDescription()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setExpirationDate($this->getExpirationDate()); - $copyObj->setIsCumulative($this->getIsCumulative()); - $copyObj->setIsRemovingPostage($this->getIsRemovingPostage()); - $copyObj->setIsAvailableOnSpecialOffers($this->getIsAvailableOnSpecialOffers()); - $copyObj->setSerializedConditions($this->getSerializedConditions()); + $copyObj->setValue($this->getValue()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1784,7 +1178,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * objects. * * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\OrderCoupon Clone of current object. + * @return \Thelia\Model\CouponOrder Clone of current object. * @throws PropelException */ public function copy($deepCopy = false) @@ -1801,7 +1195,7 @@ abstract class OrderCoupon implements ActiveRecordInterface * Declares an association between this object and a ChildOrder object. * * @param ChildOrder $v - * @return \Thelia\Model\OrderCoupon The current object (for fluent API support) + * @return \Thelia\Model\CouponOrder The current object (for fluent API support) * @throws PropelException */ public function setOrder(ChildOrder $v = null) @@ -1817,7 +1211,7 @@ abstract class OrderCoupon implements ActiveRecordInterface // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildOrder object, it will not be re-added. if ($v !== null) { - $v->addOrderCoupon($this); + $v->addCouponOrder($this); } @@ -1841,7 +1235,7 @@ abstract class OrderCoupon 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->aOrder->addOrderCoupons($this); + $this->aOrder->addCouponOrders($this); */ } @@ -1855,17 +1249,7 @@ abstract class OrderCoupon implements ActiveRecordInterface { $this->id = null; $this->order_id = null; - $this->code = null; - $this->type = null; - $this->amount = null; - $this->title = null; - $this->short_description = null; - $this->description = null; - $this->expiration_date = null; - $this->is_cumulative = null; - $this->is_removing_postage = null; - $this->is_available_on_special_offers = null; - $this->serialized_conditions = null; + $this->value = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; @@ -1899,7 +1283,7 @@ abstract class OrderCoupon implements ActiveRecordInterface */ public function __toString() { - return (string) $this->exportTo(OrderCouponTableMap::DEFAULT_STRING_FORMAT); + return (string) $this->exportTo(CouponOrderTableMap::DEFAULT_STRING_FORMAT); } // timestampable behavior @@ -1907,11 +1291,11 @@ abstract class OrderCoupon implements ActiveRecordInterface /** * Mark the current object so that the update date doesn't get updated during next save * - * @return ChildOrderCoupon The current object (for fluent API support) + * @return ChildCouponOrder The current object (for fluent API support) */ public function keepUpdateDateUnchanged() { - $this->modifiedColumns[] = OrderCouponTableMap::UPDATED_AT; + $this->modifiedColumns[] = CouponOrderTableMap::UPDATED_AT; return $this; } diff --git a/core/lib/Thelia/Model/Base/CouponOrderQuery.php b/core/lib/Thelia/Model/Base/CouponOrderQuery.php new file mode 100644 index 000000000..255d69504 --- /dev/null +++ b/core/lib/Thelia/Model/Base/CouponOrderQuery.php @@ -0,0 +1,678 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildCouponOrder|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = CouponOrderTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(CouponOrderTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponOrder A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, ORDER_ID, VALUE, CREATED_AT, UPDATED_AT FROM coupon_order WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildCouponOrder(); + $obj->hydrate($row); + CouponOrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildCouponOrder|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(CouponOrderTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(CouponOrderTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id 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 ChildCouponOrderQuery 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(CouponOrderTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(CouponOrderTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponOrderTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the order_id column + * + * Example usage: + * + * $query->filterByOrderId(1234); // WHERE order_id = 1234 + * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) + * $query->filterByOrderId(array('min' => 12)); // WHERE order_id > 12 + * + * + * @see filterByOrder() + * + * @param mixed $orderId 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 ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByOrderId($orderId = null, $comparison = null) + { + if (is_array($orderId)) { + $useMinMax = false; + if (isset($orderId['min'])) { + $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderId['max'])) { + $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponOrderTableMap::ORDER_ID, $orderId, $comparison); + } + + /** + * Filter the query on the value column + * + * Example usage: + * + * $query->filterByValue(1234); // WHERE value = 1234 + * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) + * $query->filterByValue(array('min' => 12)); // WHERE value > 12 + * + * + * @param mixed $value 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 ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByValue($value = null, $comparison = null) + { + if (is_array($value)) { + $useMinMax = false; + if (isset($value['min'])) { + $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($value['max'])) { + $this->addUsingAlias(CouponOrderTableMap::VALUE, $value['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponOrderTableMap::VALUE, $value, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildCouponOrderQuery 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(CouponOrderTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * 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 ChildCouponOrderQuery 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(CouponOrderTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Order object + * + * @param \Thelia\Model\Order|ObjectCollection $order The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function filterByOrder($order, $comparison = null) + { + if ($order instanceof \Thelia\Model\Order) { + return $this + ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->getId(), $comparison); + } elseif ($order instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(CouponOrderTableMap::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByOrder() only accepts arguments of type \Thelia\Model\Order or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Order relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Order'); + + // 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, 'Order'); + } + + return $this; + } + + /** + * Use the Order relation Order 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\OrderQuery A secondary query class using the current class as primary query + */ + public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); + } + + /** + * Exclude object from result + * + * @param ChildCouponOrder $couponOrder Object to remove from the list of results + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function prune($couponOrder = null) + { + if ($couponOrder) { + $this->addUsingAlias(CouponOrderTableMap::ID, $couponOrder->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the coupon_order table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // 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). + CouponOrderTableMap::clearInstancePool(); + CouponOrderTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildCouponOrder or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildCouponOrder 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 + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(CouponOrderTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + CouponOrderTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + CouponOrderTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(CouponOrderTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(CouponOrderTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(CouponOrderTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(CouponOrderTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(CouponOrderTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildCouponOrderQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(CouponOrderTableMap::CREATED_AT); + } + +} // CouponOrderQuery diff --git a/core/lib/Thelia/Model/Base/Order.php b/core/lib/Thelia/Model/Base/Order.php index ebd3c0de2..befa2abfe 100644 --- a/core/lib/Thelia/Model/Base/Order.php +++ b/core/lib/Thelia/Model/Base/Order.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\CouponOrder as ChildCouponOrder; +use Thelia\Model\CouponOrderQuery as ChildCouponOrderQuery; use Thelia\Model\Currency as ChildCurrency; use Thelia\Model\CurrencyQuery as ChildCurrencyQuery; use Thelia\Model\Customer as ChildCustomer; @@ -28,8 +30,6 @@ use Thelia\Model\ModuleQuery as ChildModuleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderAddress as ChildOrderAddress; use Thelia\Model\OrderAddressQuery as ChildOrderAddressQuery; -use Thelia\Model\OrderCoupon as ChildOrderCoupon; -use Thelia\Model\OrderCouponQuery as ChildOrderCouponQuery; use Thelia\Model\OrderProduct as ChildOrderProduct; use Thelia\Model\OrderProductQuery as ChildOrderProductQuery; use Thelia\Model\OrderQuery as ChildOrderQuery; @@ -137,12 +137,6 @@ abstract class Order implements ActiveRecordInterface */ protected $invoice_ref; - /** - * The value for the discount field. - * @var double - */ - protected $discount; - /** * The value for the postage field. * @var double @@ -232,10 +226,10 @@ abstract class Order implements ActiveRecordInterface protected $collOrderProductsPartial; /** - * @var ObjectCollection|ChildOrderCoupon[] Collection to store aggregation of ChildOrderCoupon objects. + * @var ObjectCollection|ChildCouponOrder[] Collection to store aggregation of ChildCouponOrder objects. */ - protected $collOrderCoupons; - protected $collOrderCouponsPartial; + protected $collCouponOrders; + protected $collCouponOrdersPartial; /** * Flag to prevent endless save loop, if this object is referenced @@ -255,7 +249,7 @@ abstract class Order implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $orderCouponsScheduledForDeletion = null; + protected $couponOrdersScheduledForDeletion = null; /** * Initializes internal state of Thelia\Model\Base\Order object. @@ -645,17 +639,6 @@ abstract class Order implements ActiveRecordInterface return $this->invoice_ref; } - /** - * Get the [discount] column value. - * - * @return double - */ - public function getDiscount() - { - - return $this->discount; - } - /** * Get the [postage] column value. * @@ -998,27 +981,6 @@ abstract class Order implements ActiveRecordInterface return $this; } // setInvoiceRef() - /** - * Set the value of [discount] column. - * - * @param double $v new value - * @return \Thelia\Model\Order The current object (for fluent API support) - */ - public function setDiscount($v) - { - if ($v !== null) { - $v = (double) $v; - } - - if ($this->discount !== $v) { - $this->discount = $v; - $this->modifiedColumns[] = OrderTableMap::DISCOUNT; - } - - - return $this; - } // setDiscount() - /** * Set the value of [postage] column. * @@ -1255,31 +1217,28 @@ abstract class Order implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : OrderTableMap::translateFieldName('InvoiceRef', TableMap::TYPE_PHPNAME, $indexType)]; $this->invoice_ref = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Discount', TableMap::TYPE_PHPNAME, $indexType)]; - $this->discount = (null !== $col) ? (double) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 11 + $startcol : OrderTableMap::translateFieldName('Postage', TableMap::TYPE_PHPNAME, $indexType)]; $this->postage = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 12 + $startcol : OrderTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; $this->payment_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; $this->delivery_module_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderTableMap::translateFieldName('StatusId', TableMap::TYPE_PHPNAME, $indexType)]; $this->status_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::translateFieldName('LangId', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderTableMap::translateFieldName('LangId', TableMap::TYPE_PHPNAME, $indexType)]; $this->lang_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderTableMap::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 ? 18 + $startcol : OrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1292,7 +1251,7 @@ abstract class Order implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 19; // 19 = OrderTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 18; // 18 = OrderTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Order object", 0, $e); @@ -1387,7 +1346,7 @@ abstract class Order implements ActiveRecordInterface $this->aLang = null; $this->collOrderProducts = null; - $this->collOrderCoupons = null; + $this->collCouponOrders = null; } // if (deep) } @@ -1600,17 +1559,17 @@ abstract class Order implements ActiveRecordInterface } } - if ($this->orderCouponsScheduledForDeletion !== null) { - if (!$this->orderCouponsScheduledForDeletion->isEmpty()) { - \Thelia\Model\OrderCouponQuery::create() - ->filterByPrimaryKeys($this->orderCouponsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->couponOrdersScheduledForDeletion !== null) { + if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { + \Thelia\Model\CouponOrderQuery::create() + ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->orderCouponsScheduledForDeletion = null; + $this->couponOrdersScheduledForDeletion = null; } } - if ($this->collOrderCoupons !== null) { - foreach ($this->collOrderCoupons as $referrerFK) { + if ($this->collCouponOrders !== null) { + foreach ($this->collCouponOrders as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1676,9 +1635,6 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; } - if ($this->isColumnModified(OrderTableMap::DISCOUNT)) { - $modifiedColumns[':p' . $index++] = 'DISCOUNT'; - } if ($this->isColumnModified(OrderTableMap::POSTAGE)) { $modifiedColumns[':p' . $index++] = 'POSTAGE'; } @@ -1744,9 +1700,6 @@ abstract class Order implements ActiveRecordInterface case 'INVOICE_REF': $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); break; - case 'DISCOUNT': - $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); - break; case 'POSTAGE': $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); break; @@ -1864,27 +1817,24 @@ abstract class Order implements ActiveRecordInterface return $this->getInvoiceRef(); break; case 11: - return $this->getDiscount(); - break; - case 12: return $this->getPostage(); break; - case 13: + case 12: return $this->getPaymentModuleId(); break; - case 14: + case 13: return $this->getDeliveryModuleId(); break; - case 15: + case 14: return $this->getStatusId(); break; - case 16: + case 15: return $this->getLangId(); break; - case 17: + case 16: return $this->getCreatedAt(); break; - case 18: + case 17: return $this->getUpdatedAt(); break; default: @@ -1927,14 +1877,13 @@ abstract class Order implements ActiveRecordInterface $keys[8] => $this->getTransactionRef(), $keys[9] => $this->getDeliveryRef(), $keys[10] => $this->getInvoiceRef(), - $keys[11] => $this->getDiscount(), - $keys[12] => $this->getPostage(), - $keys[13] => $this->getPaymentModuleId(), - $keys[14] => $this->getDeliveryModuleId(), - $keys[15] => $this->getStatusId(), - $keys[16] => $this->getLangId(), - $keys[17] => $this->getCreatedAt(), - $keys[18] => $this->getUpdatedAt(), + $keys[11] => $this->getPostage(), + $keys[12] => $this->getPaymentModuleId(), + $keys[13] => $this->getDeliveryModuleId(), + $keys[14] => $this->getStatusId(), + $keys[15] => $this->getLangId(), + $keys[16] => $this->getCreatedAt(), + $keys[17] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1969,8 +1918,8 @@ abstract class Order implements ActiveRecordInterface if (null !== $this->collOrderProducts) { $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collOrderCoupons) { - $result['OrderCoupons'] = $this->collOrderCoupons->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collCouponOrders) { + $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -2040,27 +1989,24 @@ abstract class Order implements ActiveRecordInterface $this->setInvoiceRef($value); break; case 11: - $this->setDiscount($value); - break; - case 12: $this->setPostage($value); break; - case 13: + case 12: $this->setPaymentModuleId($value); break; - case 14: + case 13: $this->setDeliveryModuleId($value); break; - case 15: + case 14: $this->setStatusId($value); break; - case 16: + case 15: $this->setLangId($value); break; - case 17: + case 16: $this->setCreatedAt($value); break; - case 18: + case 17: $this->setUpdatedAt($value); break; } // switch() @@ -2098,14 +2044,13 @@ abstract class Order implements ActiveRecordInterface if (array_key_exists($keys[8], $arr)) $this->setTransactionRef($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setDeliveryRef($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setInvoiceRef($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setDiscount($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPostage($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setPaymentModuleId($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setDeliveryModuleId($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setStatusId($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setLangId($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]); - if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]); + if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]); + if (array_key_exists($keys[12], $arr)) $this->setPaymentModuleId($arr[$keys[12]]); + if (array_key_exists($keys[13], $arr)) $this->setDeliveryModuleId($arr[$keys[13]]); + if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setLangId($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); } /** @@ -2128,7 +2073,6 @@ abstract class Order implements ActiveRecordInterface if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) $criteria->add(OrderTableMap::TRANSACTION_REF, $this->transaction_ref); if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) $criteria->add(OrderTableMap::DELIVERY_REF, $this->delivery_ref); if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) $criteria->add(OrderTableMap::INVOICE_REF, $this->invoice_ref); - if ($this->isColumnModified(OrderTableMap::DISCOUNT)) $criteria->add(OrderTableMap::DISCOUNT, $this->discount); if ($this->isColumnModified(OrderTableMap::POSTAGE)) $criteria->add(OrderTableMap::POSTAGE, $this->postage); if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) $criteria->add(OrderTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) $criteria->add(OrderTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); @@ -2209,7 +2153,6 @@ abstract class Order implements ActiveRecordInterface $copyObj->setTransactionRef($this->getTransactionRef()); $copyObj->setDeliveryRef($this->getDeliveryRef()); $copyObj->setInvoiceRef($this->getInvoiceRef()); - $copyObj->setDiscount($this->getDiscount()); $copyObj->setPostage($this->getPostage()); $copyObj->setPaymentModuleId($this->getPaymentModuleId()); $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); @@ -2229,9 +2172,9 @@ abstract class Order implements ActiveRecordInterface } } - foreach ($this->getOrderCoupons() as $relObj) { + foreach ($this->getCouponOrders() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderCoupon($relObj->copy($deepCopy)); + $copyObj->addCouponOrder($relObj->copy($deepCopy)); } } @@ -2687,8 +2630,8 @@ abstract class Order implements ActiveRecordInterface if ('OrderProduct' == $relationName) { return $this->initOrderProducts(); } - if ('OrderCoupon' == $relationName) { - return $this->initOrderCoupons(); + if ('CouponOrder' == $relationName) { + return $this->initCouponOrders(); } } @@ -2911,31 +2854,31 @@ abstract class Order implements ActiveRecordInterface } /** - * Clears out the collOrderCoupons collection + * Clears out the collCouponOrders 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 addOrderCoupons() + * @see addCouponOrders() */ - public function clearOrderCoupons() + public function clearCouponOrders() { - $this->collOrderCoupons = null; // important to set this to NULL since that means it is uninitialized + $this->collCouponOrders = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collOrderCoupons collection loaded partially. + * Reset is the collCouponOrders collection loaded partially. */ - public function resetPartialOrderCoupons($v = true) + public function resetPartialCouponOrders($v = true) { - $this->collOrderCouponsPartial = $v; + $this->collCouponOrdersPartial = $v; } /** - * Initializes the collOrderCoupons collection. + * Initializes the collCouponOrders collection. * - * By default this just sets the collOrderCoupons collection to an empty array (like clearcollOrderCoupons()); + * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); * 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. * @@ -2944,17 +2887,17 @@ abstract class Order implements ActiveRecordInterface * * @return void */ - public function initOrderCoupons($overrideExisting = true) + public function initCouponOrders($overrideExisting = true) { - if (null !== $this->collOrderCoupons && !$overrideExisting) { + if (null !== $this->collCouponOrders && !$overrideExisting) { return; } - $this->collOrderCoupons = new ObjectCollection(); - $this->collOrderCoupons->setModel('\Thelia\Model\OrderCoupon'); + $this->collCouponOrders = new ObjectCollection(); + $this->collCouponOrders->setModel('\Thelia\Model\CouponOrder'); } /** - * Gets an array of ChildOrderCoupon objects which contain a foreign key that references this object. + * Gets an array of ChildCouponOrder 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. @@ -2964,109 +2907,109 @@ abstract class Order implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildOrderCoupon[] List of ChildOrderCoupon objects + * @return Collection|ChildCouponOrder[] List of ChildCouponOrder objects * @throws PropelException */ - public function getOrderCoupons($criteria = null, ConnectionInterface $con = null) + public function getCouponOrders($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collOrderCouponsPartial && !$this->isNew(); - if (null === $this->collOrderCoupons || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderCoupons) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { // return empty collection - $this->initOrderCoupons(); + $this->initCouponOrders(); } else { - $collOrderCoupons = ChildOrderCouponQuery::create(null, $criteria) + $collCouponOrders = ChildCouponOrderQuery::create(null, $criteria) ->filterByOrder($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collOrderCouponsPartial && count($collOrderCoupons)) { - $this->initOrderCoupons(false); + if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { + $this->initCouponOrders(false); - foreach ($collOrderCoupons as $obj) { - if (false == $this->collOrderCoupons->contains($obj)) { - $this->collOrderCoupons->append($obj); + foreach ($collCouponOrders as $obj) { + if (false == $this->collCouponOrders->contains($obj)) { + $this->collCouponOrders->append($obj); } } - $this->collOrderCouponsPartial = true; + $this->collCouponOrdersPartial = true; } - $collOrderCoupons->getInternalIterator()->rewind(); + $collCouponOrders->getInternalIterator()->rewind(); - return $collOrderCoupons; + return $collCouponOrders; } - if ($partial && $this->collOrderCoupons) { - foreach ($this->collOrderCoupons as $obj) { + if ($partial && $this->collCouponOrders) { + foreach ($this->collCouponOrders as $obj) { if ($obj->isNew()) { - $collOrderCoupons[] = $obj; + $collCouponOrders[] = $obj; } } } - $this->collOrderCoupons = $collOrderCoupons; - $this->collOrderCouponsPartial = false; + $this->collCouponOrders = $collCouponOrders; + $this->collCouponOrdersPartial = false; } } - return $this->collOrderCoupons; + return $this->collCouponOrders; } /** - * Sets a collection of OrderCoupon objects related by a one-to-many relationship + * Sets a collection of CouponOrder 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 $orderCoupons A Propel collection. + * @param Collection $couponOrders A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildOrder The current object (for fluent API support) */ - public function setOrderCoupons(Collection $orderCoupons, ConnectionInterface $con = null) + public function setCouponOrders(Collection $couponOrders, ConnectionInterface $con = null) { - $orderCouponsToDelete = $this->getOrderCoupons(new Criteria(), $con)->diff($orderCoupons); + $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - $this->orderCouponsScheduledForDeletion = $orderCouponsToDelete; + $this->couponOrdersScheduledForDeletion = $couponOrdersToDelete; - foreach ($orderCouponsToDelete as $orderCouponRemoved) { - $orderCouponRemoved->setOrder(null); + foreach ($couponOrdersToDelete as $couponOrderRemoved) { + $couponOrderRemoved->setOrder(null); } - $this->collOrderCoupons = null; - foreach ($orderCoupons as $orderCoupon) { - $this->addOrderCoupon($orderCoupon); + $this->collCouponOrders = null; + foreach ($couponOrders as $couponOrder) { + $this->addCouponOrder($couponOrder); } - $this->collOrderCoupons = $orderCoupons; - $this->collOrderCouponsPartial = false; + $this->collCouponOrders = $couponOrders; + $this->collCouponOrdersPartial = false; return $this; } /** - * Returns the number of related OrderCoupon objects. + * Returns the number of related CouponOrder objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related OrderCoupon objects. + * @return int Count of related CouponOrder objects. * @throws PropelException */ - public function countOrderCoupons(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countCouponOrders(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collOrderCouponsPartial && !$this->isNew(); - if (null === $this->collOrderCoupons || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderCoupons) { + $partial = $this->collCouponOrdersPartial && !$this->isNew(); + if (null === $this->collCouponOrders || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collCouponOrders) { return 0; } if ($partial && !$criteria) { - return count($this->getOrderCoupons()); + return count($this->getCouponOrders()); } - $query = ChildOrderCouponQuery::create(null, $criteria); + $query = ChildCouponOrderQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -3076,53 +3019,53 @@ abstract class Order implements ActiveRecordInterface ->count($con); } - return count($this->collOrderCoupons); + return count($this->collCouponOrders); } /** - * Method called to associate a ChildOrderCoupon object to this object - * through the ChildOrderCoupon foreign key attribute. + * Method called to associate a ChildCouponOrder object to this object + * through the ChildCouponOrder foreign key attribute. * - * @param ChildOrderCoupon $l ChildOrderCoupon + * @param ChildCouponOrder $l ChildCouponOrder * @return \Thelia\Model\Order The current object (for fluent API support) */ - public function addOrderCoupon(ChildOrderCoupon $l) + public function addCouponOrder(ChildCouponOrder $l) { - if ($this->collOrderCoupons === null) { - $this->initOrderCoupons(); - $this->collOrderCouponsPartial = true; + if ($this->collCouponOrders === null) { + $this->initCouponOrders(); + $this->collCouponOrdersPartial = true; } - if (!in_array($l, $this->collOrderCoupons->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderCoupon($l); + if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddCouponOrder($l); } return $this; } /** - * @param OrderCoupon $orderCoupon The orderCoupon object to add. + * @param CouponOrder $couponOrder The couponOrder object to add. */ - protected function doAddOrderCoupon($orderCoupon) + protected function doAddCouponOrder($couponOrder) { - $this->collOrderCoupons[]= $orderCoupon; - $orderCoupon->setOrder($this); + $this->collCouponOrders[]= $couponOrder; + $couponOrder->setOrder($this); } /** - * @param OrderCoupon $orderCoupon The orderCoupon object to remove. + * @param CouponOrder $couponOrder The couponOrder object to remove. * @return ChildOrder The current object (for fluent API support) */ - public function removeOrderCoupon($orderCoupon) + public function removeCouponOrder($couponOrder) { - if ($this->getOrderCoupons()->contains($orderCoupon)) { - $this->collOrderCoupons->remove($this->collOrderCoupons->search($orderCoupon)); - if (null === $this->orderCouponsScheduledForDeletion) { - $this->orderCouponsScheduledForDeletion = clone $this->collOrderCoupons; - $this->orderCouponsScheduledForDeletion->clear(); + if ($this->getCouponOrders()->contains($couponOrder)) { + $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); + if (null === $this->couponOrdersScheduledForDeletion) { + $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; + $this->couponOrdersScheduledForDeletion->clear(); } - $this->orderCouponsScheduledForDeletion[]= clone $orderCoupon; - $orderCoupon->setOrder(null); + $this->couponOrdersScheduledForDeletion[]= clone $couponOrder; + $couponOrder->setOrder(null); } return $this; @@ -3144,7 +3087,6 @@ abstract class Order implements ActiveRecordInterface $this->transaction_ref = null; $this->delivery_ref = null; $this->invoice_ref = null; - $this->discount = null; $this->postage = null; $this->payment_module_id = null; $this->delivery_module_id = null; @@ -3176,8 +3118,8 @@ abstract class Order implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collOrderCoupons) { - foreach ($this->collOrderCoupons as $o) { + if ($this->collCouponOrders) { + foreach ($this->collCouponOrders as $o) { $o->clearAllReferences($deep); } } @@ -3187,10 +3129,10 @@ abstract class Order implements ActiveRecordInterface $this->collOrderProducts->clearIterator(); } $this->collOrderProducts = null; - if ($this->collOrderCoupons instanceof Collection) { - $this->collOrderCoupons->clearIterator(); + if ($this->collCouponOrders instanceof Collection) { + $this->collCouponOrders->clearIterator(); } - $this->collOrderCoupons = null; + $this->collCouponOrders = null; $this->aCurrency = null; $this->aCustomer = null; $this->aOrderAddressRelatedByInvoiceOrderAddressId = null; diff --git a/core/lib/Thelia/Model/Base/OrderQuery.php b/core/lib/Thelia/Model/Base/OrderQuery.php index ba669c065..592864f1f 100644 --- a/core/lib/Thelia/Model/Base/OrderQuery.php +++ b/core/lib/Thelia/Model/Base/OrderQuery.php @@ -32,7 +32,6 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery orderByTransactionRef($order = Criteria::ASC) Order by the transaction_ref column * @method ChildOrderQuery orderByDeliveryRef($order = Criteria::ASC) Order by the delivery_ref column * @method ChildOrderQuery orderByInvoiceRef($order = Criteria::ASC) Order by the invoice_ref column - * @method ChildOrderQuery orderByDiscount($order = Criteria::ASC) Order by the discount column * @method ChildOrderQuery orderByPostage($order = Criteria::ASC) Order by the postage column * @method ChildOrderQuery orderByPaymentModuleId($order = Criteria::ASC) Order by the payment_module_id column * @method ChildOrderQuery orderByDeliveryModuleId($order = Criteria::ASC) Order by the delivery_module_id column @@ -52,7 +51,6 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery groupByTransactionRef() Group by the transaction_ref column * @method ChildOrderQuery groupByDeliveryRef() Group by the delivery_ref column * @method ChildOrderQuery groupByInvoiceRef() Group by the invoice_ref column - * @method ChildOrderQuery groupByDiscount() Group by the discount column * @method ChildOrderQuery groupByPostage() Group by the postage column * @method ChildOrderQuery groupByPaymentModuleId() Group by the payment_module_id column * @method ChildOrderQuery groupByDeliveryModuleId() Group by the delivery_module_id column @@ -101,9 +99,9 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrderQuery rightJoinOrderProduct($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderProduct relation * @method ChildOrderQuery innerJoinOrderProduct($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderProduct relation * - * @method ChildOrderQuery leftJoinOrderCoupon($relationAlias = null) Adds a LEFT JOIN clause to the query using the OrderCoupon relation - * @method ChildOrderQuery rightJoinOrderCoupon($relationAlias = null) Adds a RIGHT JOIN clause to the query using the OrderCoupon relation - * @method ChildOrderQuery innerJoinOrderCoupon($relationAlias = null) Adds a INNER JOIN clause to the query using the OrderCoupon relation + * @method ChildOrderQuery leftJoinCouponOrder($relationAlias = null) Adds a LEFT JOIN clause to the query using the CouponOrder relation + * @method ChildOrderQuery rightJoinCouponOrder($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CouponOrder relation + * @method ChildOrderQuery innerJoinCouponOrder($relationAlias = null) Adds a INNER JOIN clause to the query using the CouponOrder relation * * @method ChildOrder findOne(ConnectionInterface $con = null) Return the first ChildOrder matching the query * @method ChildOrder findOneOrCreate(ConnectionInterface $con = null) Return the first ChildOrder matching the query, or a new ChildOrder object populated from the query conditions when no match is found @@ -119,7 +117,6 @@ use Thelia\Model\Map\OrderTableMap; * @method ChildOrder findOneByTransactionRef(string $transaction_ref) Return the first ChildOrder filtered by the transaction_ref column * @method ChildOrder findOneByDeliveryRef(string $delivery_ref) Return the first ChildOrder filtered by the delivery_ref column * @method ChildOrder findOneByInvoiceRef(string $invoice_ref) Return the first ChildOrder filtered by the invoice_ref column - * @method ChildOrder findOneByDiscount(double $discount) Return the first ChildOrder filtered by the discount column * @method ChildOrder findOneByPostage(double $postage) Return the first ChildOrder filtered by the postage column * @method ChildOrder findOneByPaymentModuleId(int $payment_module_id) Return the first ChildOrder filtered by the payment_module_id column * @method ChildOrder findOneByDeliveryModuleId(int $delivery_module_id) Return the first ChildOrder filtered by the delivery_module_id column @@ -139,7 +136,6 @@ use Thelia\Model\Map\OrderTableMap; * @method array findByTransactionRef(string $transaction_ref) Return ChildOrder objects filtered by the transaction_ref column * @method array findByDeliveryRef(string $delivery_ref) Return ChildOrder objects filtered by the delivery_ref column * @method array findByInvoiceRef(string $invoice_ref) Return ChildOrder objects filtered by the invoice_ref column - * @method array findByDiscount(double $discount) Return ChildOrder objects filtered by the discount column * @method array findByPostage(double $postage) Return ChildOrder objects filtered by the postage column * @method array findByPaymentModuleId(int $payment_module_id) Return ChildOrder objects filtered by the payment_module_id column * @method array findByDeliveryModuleId(int $delivery_module_id) Return ChildOrder objects filtered by the delivery_module_id column @@ -235,7 +231,7 @@ abstract class OrderQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, DISCOUNT, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; + $sql = 'SELECT ID, REF, CUSTOMER_ID, INVOICE_ORDER_ADDRESS_ID, DELIVERY_ORDER_ADDRESS_ID, INVOICE_DATE, CURRENCY_ID, CURRENCY_RATE, TRANSACTION_REF, DELIVERY_REF, INVOICE_REF, POSTAGE, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, STATUS_ID, LANG_ID, CREATED_AT, UPDATED_AT FROM order WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -737,47 +733,6 @@ abstract class OrderQuery extends ModelCriteria return $this->addUsingAlias(OrderTableMap::INVOICE_REF, $invoiceRef, $comparison); } - /** - * Filter the query on the discount column - * - * Example usage: - * - * $query->filterByDiscount(1234); // WHERE discount = 1234 - * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34) - * $query->filterByDiscount(array('min' => 12)); // WHERE discount > 12 - * - * - * @param mixed $discount 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 ChildOrderQuery The current query, for fluid interface - */ - public function filterByDiscount($discount = null, $comparison = null) - { - if (is_array($discount)) { - $useMinMax = false; - if (isset($discount['min'])) { - $this->addUsingAlias(OrderTableMap::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($discount['max'])) { - $this->addUsingAlias(OrderTableMap::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderTableMap::DISCOUNT, $discount, $comparison); - } - /** * Filter the query on the postage column * @@ -1751,40 +1706,40 @@ abstract class OrderQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\OrderCoupon object + * Filter the query by a related \Thelia\Model\CouponOrder object * - * @param \Thelia\Model\OrderCoupon|ObjectCollection $orderCoupon the related object to use as filter + * @param \Thelia\Model\CouponOrder|ObjectCollection $couponOrder the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderQuery The current query, for fluid interface */ - public function filterByOrderCoupon($orderCoupon, $comparison = null) + public function filterByCouponOrder($couponOrder, $comparison = null) { - if ($orderCoupon instanceof \Thelia\Model\OrderCoupon) { + if ($couponOrder instanceof \Thelia\Model\CouponOrder) { return $this - ->addUsingAlias(OrderTableMap::ID, $orderCoupon->getOrderId(), $comparison); - } elseif ($orderCoupon instanceof ObjectCollection) { + ->addUsingAlias(OrderTableMap::ID, $couponOrder->getOrderId(), $comparison); + } elseif ($couponOrder instanceof ObjectCollection) { return $this - ->useOrderCouponQuery() - ->filterByPrimaryKeys($orderCoupon->getPrimaryKeys()) + ->useCouponOrderQuery() + ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByOrderCoupon() only accepts arguments of type \Thelia\Model\OrderCoupon or Collection'); + throw new PropelException('filterByCouponOrder() only accepts arguments of type \Thelia\Model\CouponOrder or Collection'); } } /** - * Adds a JOIN clause to the query using the OrderCoupon relation + * Adds a JOIN clause to the query using the CouponOrder relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildOrderQuery The current query, for fluid interface */ - public function joinOrderCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderCoupon'); + $relationMap = $tableMap->getRelation('CouponOrder'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -1799,14 +1754,14 @@ abstract class OrderQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'OrderCoupon'); + $this->addJoinObject($join, 'CouponOrder'); } return $this; } /** - * Use the OrderCoupon relation OrderCoupon object + * Use the CouponOrder relation CouponOrder object * * @see useQuery() * @@ -1814,13 +1769,13 @@ abstract class OrderQuery 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\OrderCouponQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query */ - public function useOrderCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinOrderCoupon($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderCoupon', '\Thelia\Model\OrderCouponQuery'); + ->joinCouponOrder($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); } /** diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php index 88d2caa2e..c1f28bc3d 100755 --- a/core/lib/Thelia/Model/Cart.php +++ b/core/lib/Thelia/Model/Cart.php @@ -83,6 +83,7 @@ class Cart extends BaseCart 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(); @@ -101,6 +102,7 @@ class Cart extends BaseCart foreach($this->getCartItems() as $cartItem) { $subtotal = $cartItem->getRealPrice(); + $subtotal -= $cartItem->getDiscount(); $subtotal *= $cartItem->getQuantity(); $total += $subtotal; diff --git a/core/lib/Thelia/Model/CouponOrder.php b/core/lib/Thelia/Model/CouponOrder.php new file mode 100755 index 000000000..65c326e60 --- /dev/null +++ b/core/lib/Thelia/Model/CouponOrder.php @@ -0,0 +1,9 @@ + array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Promo', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'promo', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::PROMO, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'PROMO', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'promo', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id', 'CartId', 'ProductId', 'Quantity', 'ProductSaleElementsId', 'Price', 'PromoPrice', 'PriceEndOfLife', 'Discount', 'Promo', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'cartId', 'productId', 'quantity', 'productSaleElementsId', 'price', 'promoPrice', 'priceEndOfLife', 'discount', 'promo', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CartItemTableMap::ID, CartItemTableMap::CART_ID, CartItemTableMap::PRODUCT_ID, CartItemTableMap::QUANTITY, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID, CartItemTableMap::PRICE, CartItemTableMap::PROMO_PRICE, CartItemTableMap::PRICE_END_OF_LIFE, CartItemTableMap::DISCOUNT, CartItemTableMap::PROMO, CartItemTableMap::CREATED_AT, CartItemTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CART_ID', 'PRODUCT_ID', 'QUANTITY', 'PRODUCT_SALE_ELEMENTS_ID', 'PRICE', 'PROMO_PRICE', 'PRICE_END_OF_LIFE', 'DISCOUNT', 'PROMO', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'cart_id', 'product_id', 'quantity', 'product_sale_elements_id', 'price', 'promo_price', 'price_end_of_life', 'discount', 'promo', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -151,12 +156,12 @@ class CartItemTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Promo' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'promo' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), - self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::PROMO => 8, CartItemTableMap::CREATED_AT => 9, CartItemTableMap::UPDATED_AT => 10, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'PROMO' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), - self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'promo' => 8, 'created_at' => 9, 'updated_at' => 10, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) + self::TYPE_PHPNAME => array('Id' => 0, 'CartId' => 1, 'ProductId' => 2, 'Quantity' => 3, 'ProductSaleElementsId' => 4, 'Price' => 5, 'PromoPrice' => 6, 'PriceEndOfLife' => 7, 'Discount' => 8, 'Promo' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'cartId' => 1, 'productId' => 2, 'quantity' => 3, 'productSaleElementsId' => 4, 'price' => 5, 'promoPrice' => 6, 'priceEndOfLife' => 7, 'discount' => 8, 'promo' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(CartItemTableMap::ID => 0, CartItemTableMap::CART_ID => 1, CartItemTableMap::PRODUCT_ID => 2, CartItemTableMap::QUANTITY => 3, CartItemTableMap::PRODUCT_SALE_ELEMENTS_ID => 4, CartItemTableMap::PRICE => 5, CartItemTableMap::PROMO_PRICE => 6, CartItemTableMap::PRICE_END_OF_LIFE => 7, CartItemTableMap::DISCOUNT => 8, CartItemTableMap::PROMO => 9, CartItemTableMap::CREATED_AT => 10, CartItemTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CART_ID' => 1, 'PRODUCT_ID' => 2, 'QUANTITY' => 3, 'PRODUCT_SALE_ELEMENTS_ID' => 4, 'PRICE' => 5, 'PROMO_PRICE' => 6, 'PRICE_END_OF_LIFE' => 7, 'DISCOUNT' => 8, 'PROMO' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'cart_id' => 1, 'product_id' => 2, 'quantity' => 3, 'product_sale_elements_id' => 4, 'price' => 5, 'promo_price' => 6, 'price_end_of_life' => 7, 'discount' => 8, 'promo' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); /** @@ -183,6 +188,7 @@ class CartItemTableMap extends TableMap $this->addColumn('PRICE', 'Price', 'FLOAT', false, null, null); $this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null); $this->addColumn('PRICE_END_OF_LIFE', 'PriceEndOfLife', 'TIMESTAMP', false, null, null); + $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, 0); $this->addColumn('PROMO', 'Promo', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -357,6 +363,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn(CartItemTableMap::PRICE); $criteria->addSelectColumn(CartItemTableMap::PROMO_PRICE); $criteria->addSelectColumn(CartItemTableMap::PRICE_END_OF_LIFE); + $criteria->addSelectColumn(CartItemTableMap::DISCOUNT); $criteria->addSelectColumn(CartItemTableMap::PROMO); $criteria->addSelectColumn(CartItemTableMap::CREATED_AT); $criteria->addSelectColumn(CartItemTableMap::UPDATED_AT); @@ -369,6 +376,7 @@ class CartItemTableMap extends TableMap $criteria->addSelectColumn($alias . '.PRICE'); $criteria->addSelectColumn($alias . '.PROMO_PRICE'); $criteria->addSelectColumn($alias . '.PRICE_END_OF_LIFE'); + $criteria->addSelectColumn($alias . '.DISCOUNT'); $criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/OrderCouponTableMap.php b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php similarity index 54% rename from core/lib/Thelia/Model/Map/OrderCouponTableMap.php rename to core/lib/Thelia/Model/Map/CouponOrderTableMap.php index c77a046f0..d96183505 100644 --- a/core/lib/Thelia/Model/Map/OrderCouponTableMap.php +++ b/core/lib/Thelia/Model/Map/CouponOrderTableMap.php @@ -10,12 +10,12 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\RelationMap; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Map\TableMapTrait; -use Thelia\Model\OrderCoupon; -use Thelia\Model\OrderCouponQuery; +use Thelia\Model\CouponOrder; +use Thelia\Model\CouponOrderQuery; /** - * This class defines the structure of the 'order_coupon' table. + * This class defines the structure of the 'coupon_order' table. * * * @@ -25,14 +25,14 @@ use Thelia\Model\OrderCouponQuery; * (i.e. if it's a text column type). * */ -class OrderCouponTableMap extends TableMap +class CouponOrderTableMap extends TableMap { use InstancePoolTrait; use TableMapTrait; /** * The (dot-path) name of this class */ - const CLASS_NAME = 'Thelia.Model.Map.OrderCouponTableMap'; + const CLASS_NAME = 'Thelia.Model.Map.CouponOrderTableMap'; /** * The default database name for this class @@ -42,22 +42,22 @@ class OrderCouponTableMap extends TableMap /** * The table name for this class */ - const TABLE_NAME = 'order_coupon'; + const TABLE_NAME = 'coupon_order'; /** * The related Propel class for this table */ - const OM_CLASS = '\\Thelia\\Model\\OrderCoupon'; + const OM_CLASS = '\\Thelia\\Model\\CouponOrder'; /** * A class that can be returned by this tableMap */ - const CLASS_DEFAULT = 'Thelia.Model.OrderCoupon'; + const CLASS_DEFAULT = 'Thelia.Model.CouponOrder'; /** * The total number of columns */ - const NUM_COLUMNS = 15; + const NUM_COLUMNS = 5; /** * The number of lazy-loaded columns @@ -67,82 +67,32 @@ class OrderCouponTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 15; + const NUM_HYDRATE_COLUMNS = 5; /** * the column name for the ID field */ - const ID = 'order_coupon.ID'; + const ID = 'coupon_order.ID'; /** * the column name for the ORDER_ID field */ - const ORDER_ID = 'order_coupon.ORDER_ID'; + const ORDER_ID = 'coupon_order.ORDER_ID'; /** - * the column name for the CODE field + * the column name for the VALUE field */ - const CODE = 'order_coupon.CODE'; - - /** - * the column name for the TYPE field - */ - const TYPE = 'order_coupon.TYPE'; - - /** - * the column name for the AMOUNT field - */ - const AMOUNT = 'order_coupon.AMOUNT'; - - /** - * the column name for the TITLE field - */ - const TITLE = 'order_coupon.TITLE'; - - /** - * the column name for the SHORT_DESCRIPTION field - */ - const SHORT_DESCRIPTION = 'order_coupon.SHORT_DESCRIPTION'; - - /** - * the column name for the DESCRIPTION field - */ - const DESCRIPTION = 'order_coupon.DESCRIPTION'; - - /** - * the column name for the EXPIRATION_DATE field - */ - const EXPIRATION_DATE = 'order_coupon.EXPIRATION_DATE'; - - /** - * the column name for the IS_CUMULATIVE field - */ - const IS_CUMULATIVE = 'order_coupon.IS_CUMULATIVE'; - - /** - * the column name for the IS_REMOVING_POSTAGE field - */ - const IS_REMOVING_POSTAGE = 'order_coupon.IS_REMOVING_POSTAGE'; - - /** - * the column name for the IS_AVAILABLE_ON_SPECIAL_OFFERS field - */ - const IS_AVAILABLE_ON_SPECIAL_OFFERS = 'order_coupon.IS_AVAILABLE_ON_SPECIAL_OFFERS'; - - /** - * the column name for the SERIALIZED_CONDITIONS field - */ - const SERIALIZED_CONDITIONS = 'order_coupon.SERIALIZED_CONDITIONS'; + const VALUE = 'coupon_order.VALUE'; /** * the column name for the CREATED_AT field */ - const CREATED_AT = 'order_coupon.CREATED_AT'; + const CREATED_AT = 'coupon_order.CREATED_AT'; /** * the column name for the UPDATED_AT field */ - const UPDATED_AT = 'order_coupon.UPDATED_AT'; + const UPDATED_AT = 'coupon_order.UPDATED_AT'; /** * The default string format for model objects of the related table @@ -156,12 +106,12 @@ class OrderCouponTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'Code', 'Type', 'Amount', 'Title', 'ShortDescription', 'Description', 'ExpirationDate', 'IsCumulative', 'IsRemovingPostage', 'IsAvailableOnSpecialOffers', 'SerializedConditions', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'code', 'type', 'amount', 'title', 'shortDescription', 'description', 'expirationDate', 'isCumulative', 'isRemovingPostage', 'isAvailableOnSpecialOffers', 'serializedConditions', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderCouponTableMap::ID, OrderCouponTableMap::ORDER_ID, OrderCouponTableMap::CODE, OrderCouponTableMap::TYPE, OrderCouponTableMap::AMOUNT, OrderCouponTableMap::TITLE, OrderCouponTableMap::SHORT_DESCRIPTION, OrderCouponTableMap::DESCRIPTION, OrderCouponTableMap::EXPIRATION_DATE, OrderCouponTableMap::IS_CUMULATIVE, OrderCouponTableMap::IS_REMOVING_POSTAGE, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS, OrderCouponTableMap::SERIALIZED_CONDITIONS, OrderCouponTableMap::CREATED_AT, OrderCouponTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'CODE', 'TYPE', 'AMOUNT', 'TITLE', 'SHORT_DESCRIPTION', 'DESCRIPTION', 'EXPIRATION_DATE', 'IS_CUMULATIVE', 'IS_REMOVING_POSTAGE', 'IS_AVAILABLE_ON_SPECIAL_OFFERS', 'SERIALIZED_CONDITIONS', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'code', 'type', 'amount', 'title', 'short_description', 'description', 'expiration_date', 'is_cumulative', 'is_removing_postage', 'is_available_on_special_offers', 'serialized_conditions', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) + self::TYPE_PHPNAME => array('Id', 'OrderId', 'Value', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'value', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(CouponOrderTableMap::ID, CouponOrderTableMap::ORDER_ID, CouponOrderTableMap::VALUE, CouponOrderTableMap::CREATED_AT, CouponOrderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'value', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -171,12 +121,12 @@ class OrderCouponTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Type' => 3, 'Amount' => 4, 'Title' => 5, 'ShortDescription' => 6, 'Description' => 7, 'ExpirationDate' => 8, 'IsCumulative' => 9, 'IsRemovingPostage' => 10, 'IsAvailableOnSpecialOffers' => 11, 'SerializedConditions' => 12, 'CreatedAt' => 13, 'UpdatedAt' => 14, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'shortDescription' => 6, 'description' => 7, 'expirationDate' => 8, 'isCumulative' => 9, 'isRemovingPostage' => 10, 'isAvailableOnSpecialOffers' => 11, 'serializedConditions' => 12, 'createdAt' => 13, 'updatedAt' => 14, ), - self::TYPE_COLNAME => array(OrderCouponTableMap::ID => 0, OrderCouponTableMap::ORDER_ID => 1, OrderCouponTableMap::CODE => 2, OrderCouponTableMap::TYPE => 3, OrderCouponTableMap::AMOUNT => 4, OrderCouponTableMap::TITLE => 5, OrderCouponTableMap::SHORT_DESCRIPTION => 6, OrderCouponTableMap::DESCRIPTION => 7, OrderCouponTableMap::EXPIRATION_DATE => 8, OrderCouponTableMap::IS_CUMULATIVE => 9, OrderCouponTableMap::IS_REMOVING_POSTAGE => 10, OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS => 11, OrderCouponTableMap::SERIALIZED_CONDITIONS => 12, OrderCouponTableMap::CREATED_AT => 13, OrderCouponTableMap::UPDATED_AT => 14, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'TYPE' => 3, 'AMOUNT' => 4, 'TITLE' => 5, 'SHORT_DESCRIPTION' => 6, 'DESCRIPTION' => 7, 'EXPIRATION_DATE' => 8, 'IS_CUMULATIVE' => 9, 'IS_REMOVING_POSTAGE' => 10, 'IS_AVAILABLE_ON_SPECIAL_OFFERS' => 11, 'SERIALIZED_CONDITIONS' => 12, 'CREATED_AT' => 13, 'UPDATED_AT' => 14, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'code' => 2, 'type' => 3, 'amount' => 4, 'title' => 5, 'short_description' => 6, 'description' => 7, 'expiration_date' => 8, 'is_cumulative' => 9, 'is_removing_postage' => 10, 'is_available_on_special_offers' => 11, 'serialized_conditions' => 12, 'created_at' => 13, 'updated_at' => 14, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'Value' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'value' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(CouponOrderTableMap::ID => 0, CouponOrderTableMap::ORDER_ID => 1, CouponOrderTableMap::VALUE => 2, CouponOrderTableMap::CREATED_AT => 3, CouponOrderTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'VALUE' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'value' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) ); /** @@ -189,25 +139,15 @@ class OrderCouponTableMap extends TableMap public function initialize() { // attributes - $this->setName('order_coupon'); - $this->setPhpName('OrderCoupon'); - $this->setClassName('\\Thelia\\Model\\OrderCoupon'); + $this->setName('coupon_order'); + $this->setPhpName('CouponOrder'); + $this->setClassName('\\Thelia\\Model\\CouponOrder'); $this->setPackage('Thelia.Model'); $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ORDER_ID', 'OrderId', 'INTEGER', 'order', 'ID', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null); - $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); - $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); - $this->addColumn('SHORT_DESCRIPTION', 'ShortDescription', 'LONGVARCHAR', true, null, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', true, null, null); - $this->addColumn('EXPIRATION_DATE', 'ExpirationDate', 'TIMESTAMP', true, null, null); - $this->addColumn('IS_CUMULATIVE', 'IsCumulative', 'BOOLEAN', true, 1, null); - $this->addColumn('IS_REMOVING_POSTAGE', 'IsRemovingPostage', 'BOOLEAN', true, 1, null); - $this->addColumn('IS_AVAILABLE_ON_SPECIAL_OFFERS', 'IsAvailableOnSpecialOffers', 'BOOLEAN', true, 1, null); - $this->addColumn('SERIALIZED_CONDITIONS', 'SerializedConditions', 'LONGVARCHAR', true, null, null); + $this->addColumn('VALUE', 'Value', 'FLOAT', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -289,7 +229,7 @@ class OrderCouponTableMap extends TableMap */ public static function getOMClass($withPrefix = true) { - return $withPrefix ? OrderCouponTableMap::CLASS_DEFAULT : OrderCouponTableMap::OM_CLASS; + return $withPrefix ? CouponOrderTableMap::CLASS_DEFAULT : CouponOrderTableMap::OM_CLASS; } /** @@ -303,21 +243,21 @@ class OrderCouponTableMap extends TableMap * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. - * @return array (OrderCoupon object, last column rank) + * @return array (CouponOrder object, last column rank) */ public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) { - $key = OrderCouponTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = OrderCouponTableMap::getInstanceFromPool($key))) { + $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = CouponOrderTableMap::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 + OrderCouponTableMap::NUM_HYDRATE_COLUMNS; + $col = $offset + CouponOrderTableMap::NUM_HYDRATE_COLUMNS; } else { - $cls = OrderCouponTableMap::OM_CLASS; + $cls = CouponOrderTableMap::OM_CLASS; $obj = new $cls(); $col = $obj->hydrate($row, $offset, false, $indexType); - OrderCouponTableMap::addInstanceToPool($obj, $key); + CouponOrderTableMap::addInstanceToPool($obj, $key); } return array($obj, $col); @@ -340,8 +280,8 @@ class OrderCouponTableMap extends TableMap $cls = static::getOMClass(false); // populate the object(s) while ($row = $dataFetcher->fetch()) { - $key = OrderCouponTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = OrderCouponTableMap::getInstanceFromPool($key))) { + $key = CouponOrderTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = CouponOrderTableMap::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 @@ -350,7 +290,7 @@ class OrderCouponTableMap extends TableMap $obj = new $cls(); $obj->hydrate($row); $results[] = $obj; - OrderCouponTableMap::addInstanceToPool($obj, $key); + CouponOrderTableMap::addInstanceToPool($obj, $key); } // if key exists } @@ -371,35 +311,15 @@ class OrderCouponTableMap extends TableMap public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { - $criteria->addSelectColumn(OrderCouponTableMap::ID); - $criteria->addSelectColumn(OrderCouponTableMap::ORDER_ID); - $criteria->addSelectColumn(OrderCouponTableMap::CODE); - $criteria->addSelectColumn(OrderCouponTableMap::TYPE); - $criteria->addSelectColumn(OrderCouponTableMap::AMOUNT); - $criteria->addSelectColumn(OrderCouponTableMap::TITLE); - $criteria->addSelectColumn(OrderCouponTableMap::SHORT_DESCRIPTION); - $criteria->addSelectColumn(OrderCouponTableMap::DESCRIPTION); - $criteria->addSelectColumn(OrderCouponTableMap::EXPIRATION_DATE); - $criteria->addSelectColumn(OrderCouponTableMap::IS_CUMULATIVE); - $criteria->addSelectColumn(OrderCouponTableMap::IS_REMOVING_POSTAGE); - $criteria->addSelectColumn(OrderCouponTableMap::IS_AVAILABLE_ON_SPECIAL_OFFERS); - $criteria->addSelectColumn(OrderCouponTableMap::SERIALIZED_CONDITIONS); - $criteria->addSelectColumn(OrderCouponTableMap::CREATED_AT); - $criteria->addSelectColumn(OrderCouponTableMap::UPDATED_AT); + $criteria->addSelectColumn(CouponOrderTableMap::ID); + $criteria->addSelectColumn(CouponOrderTableMap::ORDER_ID); + $criteria->addSelectColumn(CouponOrderTableMap::VALUE); + $criteria->addSelectColumn(CouponOrderTableMap::CREATED_AT); + $criteria->addSelectColumn(CouponOrderTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ORDER_ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.TYPE'); - $criteria->addSelectColumn($alias . '.AMOUNT'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.SHORT_DESCRIPTION'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.EXPIRATION_DATE'); - $criteria->addSelectColumn($alias . '.IS_CUMULATIVE'); - $criteria->addSelectColumn($alias . '.IS_REMOVING_POSTAGE'); - $criteria->addSelectColumn($alias . '.IS_AVAILABLE_ON_SPECIAL_OFFERS'); - $criteria->addSelectColumn($alias . '.SERIALIZED_CONDITIONS'); + $criteria->addSelectColumn($alias . '.VALUE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } @@ -414,7 +334,7 @@ class OrderCouponTableMap extends TableMap */ public static function getTableMap() { - return Propel::getServiceContainer()->getDatabaseMap(OrderCouponTableMap::DATABASE_NAME)->getTable(OrderCouponTableMap::TABLE_NAME); + return Propel::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME)->getTable(CouponOrderTableMap::TABLE_NAME); } /** @@ -422,16 +342,16 @@ class OrderCouponTableMap extends TableMap */ public static function buildTableMap() { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(OrderCouponTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(OrderCouponTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new OrderCouponTableMap()); + $dbMap = Propel::getServiceContainer()->getDatabaseMap(CouponOrderTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(CouponOrderTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new CouponOrderTableMap()); } } /** - * Performs a DELETE on the database, given a OrderCoupon or Criteria object OR a primary key value. + * Performs a DELETE on the database, given a CouponOrder or Criteria object OR a primary key value. * - * @param mixed $values Criteria or OrderCoupon object or primary key or array of primary keys + * @param mixed $values Criteria or CouponOrder 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 @@ -442,25 +362,25 @@ class OrderCouponTableMap extends TableMap public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; - } elseif ($values instanceof \Thelia\Model\OrderCoupon) { // it's a model object + } elseif ($values instanceof \Thelia\Model\CouponOrder) { // 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(OrderCouponTableMap::DATABASE_NAME); - $criteria->add(OrderCouponTableMap::ID, (array) $values, Criteria::IN); + $criteria = new Criteria(CouponOrderTableMap::DATABASE_NAME); + $criteria->add(CouponOrderTableMap::ID, (array) $values, Criteria::IN); } - $query = OrderCouponQuery::create()->mergeWith($criteria); + $query = CouponOrderQuery::create()->mergeWith($criteria); - if ($values instanceof Criteria) { OrderCouponTableMap::clearInstancePool(); + if ($values instanceof Criteria) { CouponOrderTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { OrderCouponTableMap::removeInstanceFromPool($singleval); + foreach ((array) $values as $singleval) { CouponOrderTableMap::removeInstanceFromPool($singleval); } } @@ -468,20 +388,20 @@ class OrderCouponTableMap extends TableMap } /** - * Deletes all rows from the order_coupon table. + * Deletes all rows from the coupon_order 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 OrderCouponQuery::create()->doDeleteAll($con); + return CouponOrderQuery::create()->doDeleteAll($con); } /** - * Performs an INSERT on the database, given a OrderCoupon or Criteria object. + * Performs an INSERT on the database, given a CouponOrder or Criteria object. * - * @param mixed $criteria Criteria or OrderCoupon object containing data that is used to create the INSERT statement. + * @param mixed $criteria Criteria or CouponOrder 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 @@ -490,22 +410,22 @@ class OrderCouponTableMap extends TableMap public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(OrderCouponTableMap::DATABASE_NAME); + $con = Propel::getServiceContainer()->getWriteConnection(CouponOrderTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { - $criteria = $criteria->buildCriteria(); // build Criteria from OrderCoupon object + $criteria = $criteria->buildCriteria(); // build Criteria from CouponOrder object } - if ($criteria->containsKey(OrderCouponTableMap::ID) && $criteria->keyContainsValue(OrderCouponTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderCouponTableMap::ID.')'); + if ($criteria->containsKey(CouponOrderTableMap::ID) && $criteria->keyContainsValue(CouponOrderTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponOrderTableMap::ID.')'); } // Set the correct dbName - $query = OrderCouponQuery::create()->mergeWith($criteria); + $query = CouponOrderQuery::create()->mergeWith($criteria); try { // use transaction because $criteria could contain info @@ -521,7 +441,7 @@ class OrderCouponTableMap extends TableMap return $pk; } -} // OrderCouponTableMap +} // CouponOrderTableMap // This is the static code needed to register the TableMap for this table with the main Propel class. // -OrderCouponTableMap::buildTableMap(); +CouponOrderTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/OrderTableMap.php b/core/lib/Thelia/Model/Map/OrderTableMap.php index fcf0ba70d..7daabb665 100644 --- a/core/lib/Thelia/Model/Map/OrderTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderTableMap.php @@ -57,7 +57,7 @@ class OrderTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 19; + const NUM_COLUMNS = 18; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 19; + const NUM_HYDRATE_COLUMNS = 18; /** * the column name for the ID field @@ -124,11 +124,6 @@ class OrderTableMap extends TableMap */ const INVOICE_REF = 'order.INVOICE_REF'; - /** - * the column name for the DISCOUNT field - */ - const DISCOUNT = 'order.DISCOUNT'; - /** * the column name for the POSTAGE field */ @@ -176,12 +171,12 @@ class OrderTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Discount', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'discount', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::DISCOUNT, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'DISCOUNT', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'discount', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) + self::TYPE_PHPNAME => array('Id', 'Ref', 'CustomerId', 'InvoiceOrderAddressId', 'DeliveryOrderAddressId', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'TransactionRef', 'DeliveryRef', 'InvoiceRef', 'Postage', 'PaymentModuleId', 'DeliveryModuleId', 'StatusId', 'LangId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'ref', 'customerId', 'invoiceOrderAddressId', 'deliveryOrderAddressId', 'invoiceDate', 'currencyId', 'currencyRate', 'transactionRef', 'deliveryRef', 'invoiceRef', 'postage', 'paymentModuleId', 'deliveryModuleId', 'statusId', 'langId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderTableMap::ID, OrderTableMap::REF, OrderTableMap::CUSTOMER_ID, OrderTableMap::INVOICE_ORDER_ADDRESS_ID, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID, OrderTableMap::INVOICE_DATE, OrderTableMap::CURRENCY_ID, OrderTableMap::CURRENCY_RATE, OrderTableMap::TRANSACTION_REF, OrderTableMap::DELIVERY_REF, OrderTableMap::INVOICE_REF, OrderTableMap::POSTAGE, OrderTableMap::PAYMENT_MODULE_ID, OrderTableMap::DELIVERY_MODULE_ID, OrderTableMap::STATUS_ID, OrderTableMap::LANG_ID, OrderTableMap::CREATED_AT, OrderTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'REF', 'CUSTOMER_ID', 'INVOICE_ORDER_ADDRESS_ID', 'DELIVERY_ORDER_ADDRESS_ID', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION_REF', 'DELIVERY_REF', 'INVOICE_REF', 'POSTAGE', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'STATUS_ID', 'LANG_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'ref', 'customer_id', 'invoice_order_address_id', 'delivery_order_address_id', 'invoice_date', 'currency_id', 'currency_rate', 'transaction_ref', 'delivery_ref', 'invoice_ref', 'postage', 'payment_module_id', 'delivery_module_id', 'status_id', 'lang_id', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -191,12 +186,12 @@ class OrderTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Discount' => 11, 'Postage' => 12, 'PaymentModuleId' => 13, 'DeliveryModuleId' => 14, 'StatusId' => 15, 'LangId' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'discount' => 11, 'postage' => 12, 'paymentModuleId' => 13, 'deliveryModuleId' => 14, 'statusId' => 15, 'langId' => 16, 'createdAt' => 17, 'updatedAt' => 18, ), - self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::DISCOUNT => 11, OrderTableMap::POSTAGE => 12, OrderTableMap::PAYMENT_MODULE_ID => 13, OrderTableMap::DELIVERY_MODULE_ID => 14, OrderTableMap::STATUS_ID => 15, OrderTableMap::LANG_ID => 16, OrderTableMap::CREATED_AT => 17, OrderTableMap::UPDATED_AT => 18, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'DISCOUNT' => 11, 'POSTAGE' => 12, 'PAYMENT_MODULE_ID' => 13, 'DELIVERY_MODULE_ID' => 14, 'STATUS_ID' => 15, 'LANG_ID' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ), - self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'discount' => 11, 'postage' => 12, 'payment_module_id' => 13, 'delivery_module_id' => 14, 'status_id' => 15, 'lang_id' => 16, 'created_at' => 17, 'updated_at' => 18, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'InvoiceOrderAddressId' => 3, 'DeliveryOrderAddressId' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'TransactionRef' => 8, 'DeliveryRef' => 9, 'InvoiceRef' => 10, 'Postage' => 11, 'PaymentModuleId' => 12, 'DeliveryModuleId' => 13, 'StatusId' => 14, 'LangId' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'ref' => 1, 'customerId' => 2, 'invoiceOrderAddressId' => 3, 'deliveryOrderAddressId' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transactionRef' => 8, 'deliveryRef' => 9, 'invoiceRef' => 10, 'postage' => 11, 'paymentModuleId' => 12, 'deliveryModuleId' => 13, 'statusId' => 14, 'langId' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), + self::TYPE_COLNAME => array(OrderTableMap::ID => 0, OrderTableMap::REF => 1, OrderTableMap::CUSTOMER_ID => 2, OrderTableMap::INVOICE_ORDER_ADDRESS_ID => 3, OrderTableMap::DELIVERY_ORDER_ADDRESS_ID => 4, OrderTableMap::INVOICE_DATE => 5, OrderTableMap::CURRENCY_ID => 6, OrderTableMap::CURRENCY_RATE => 7, OrderTableMap::TRANSACTION_REF => 8, OrderTableMap::DELIVERY_REF => 9, OrderTableMap::INVOICE_REF => 10, OrderTableMap::POSTAGE => 11, OrderTableMap::PAYMENT_MODULE_ID => 12, OrderTableMap::DELIVERY_MODULE_ID => 13, OrderTableMap::STATUS_ID => 14, OrderTableMap::LANG_ID => 15, OrderTableMap::CREATED_AT => 16, OrderTableMap::UPDATED_AT => 17, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'INVOICE_ORDER_ADDRESS_ID' => 3, 'DELIVERY_ORDER_ADDRESS_ID' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION_REF' => 8, 'DELIVERY_REF' => 9, 'INVOICE_REF' => 10, 'POSTAGE' => 11, 'PAYMENT_MODULE_ID' => 12, 'DELIVERY_MODULE_ID' => 13, 'STATUS_ID' => 14, 'LANG_ID' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), + self::TYPE_FIELDNAME => array('id' => 0, 'ref' => 1, 'customer_id' => 2, 'invoice_order_address_id' => 3, 'delivery_order_address_id' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction_ref' => 8, 'delivery_ref' => 9, 'invoice_ref' => 10, 'postage' => 11, 'payment_module_id' => 12, 'delivery_module_id' => 13, 'status_id' => 14, 'lang_id' => 15, 'created_at' => 16, 'updated_at' => 17, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) ); /** @@ -226,7 +221,6 @@ class OrderTableMap extends TableMap $this->addColumn('TRANSACTION_REF', 'TransactionRef', 'VARCHAR', false, 100, null); $this->addColumn('DELIVERY_REF', 'DeliveryRef', 'VARCHAR', false, 100, null); $this->addColumn('INVOICE_REF', 'InvoiceRef', 'VARCHAR', false, 100, null); - $this->addColumn('DISCOUNT', 'Discount', 'FLOAT', false, null, null); $this->addColumn('POSTAGE', 'Postage', 'FLOAT', true, null, null); $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); @@ -250,7 +244,7 @@ class OrderTableMap extends TableMap $this->addRelation('ModuleRelatedByDeliveryModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('Lang', '\\Thelia\\Model\\Lang', RelationMap::MANY_TO_ONE, array('lang_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $this->addRelation('OrderProduct', '\\Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts'); - $this->addRelation('OrderCoupon', '\\Thelia\\Model\\OrderCoupon', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderCoupons'); + $this->addRelation('CouponOrder', '\\Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders'); } // buildRelations() /** @@ -273,7 +267,7 @@ class OrderTableMap 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. OrderProductTableMap::clearInstancePool(); - OrderCouponTableMap::clearInstancePool(); + CouponOrderTableMap::clearInstancePool(); } /** @@ -425,7 +419,6 @@ class OrderTableMap extends TableMap $criteria->addSelectColumn(OrderTableMap::TRANSACTION_REF); $criteria->addSelectColumn(OrderTableMap::DELIVERY_REF); $criteria->addSelectColumn(OrderTableMap::INVOICE_REF); - $criteria->addSelectColumn(OrderTableMap::DISCOUNT); $criteria->addSelectColumn(OrderTableMap::POSTAGE); $criteria->addSelectColumn(OrderTableMap::PAYMENT_MODULE_ID); $criteria->addSelectColumn(OrderTableMap::DELIVERY_MODULE_ID); @@ -445,7 +438,6 @@ class OrderTableMap extends TableMap $criteria->addSelectColumn($alias . '.TRANSACTION_REF'); $criteria->addSelectColumn($alias . '.DELIVERY_REF'); $criteria->addSelectColumn($alias . '.INVOICE_REF'); - $criteria->addSelectColumn($alias . '.DISCOUNT'); $criteria->addSelectColumn($alias . '.POSTAGE'); $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index 56abca4cc..d761c3959 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -55,7 +55,7 @@ class Order extends BaseOrder * * @return float|int|string */ - public function getTotalAmount(&$tax = 0, $includePostage = true, $includeDiscount = true) + public function getTotalAmount(&$tax = 0, $includePostage = true) { $amount = 0; $tax = 0; @@ -79,21 +79,177 @@ class Order extends BaseOrder $total = $amount + $tax; - // @todo : manage discount : free postage ? - if(true === $includeDiscount) { - $total -= $this->getDiscount(); - - if($total<0) { - $total = 0; - } else { - $total = round($total, 2); - } - } - if(false !== $includePostage) { $total += $this->getPostage(); } - return $total; + return $total; // @todo : manage discount + } + + /** + * PROPEL SHOULD FIX IT + * + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = OrderTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(OrderTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(OrderTableMap::REF)) { + $modifiedColumns[':p' . $index++] = 'REF'; + } + if ($this->isColumnModified(OrderTableMap::CUSTOMER_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_ORDER_ADDRESS_ID'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_DATE)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_DATE'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_ID)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_ID'; + } + if ($this->isColumnModified(OrderTableMap::CURRENCY_RATE)) { + $modifiedColumns[':p' . $index++] = 'CURRENCY_RATE'; + } + if ($this->isColumnModified(OrderTableMap::TRANSACTION_REF)) { + $modifiedColumns[':p' . $index++] = 'TRANSACTION_REF'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_REF)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_REF'; + } + if ($this->isColumnModified(OrderTableMap::INVOICE_REF)) { + $modifiedColumns[':p' . $index++] = 'INVOICE_REF'; + } + if ($this->isColumnModified(OrderTableMap::POSTAGE)) { + $modifiedColumns[':p' . $index++] = 'POSTAGE'; + } + if ($this->isColumnModified(OrderTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; + } + if ($this->isColumnModified(OrderTableMap::STATUS_ID)) { + $modifiedColumns[':p' . $index++] = 'STATUS_ID'; + } + if ($this->isColumnModified(OrderTableMap::LANG_ID)) { + $modifiedColumns[':p' . $index++] = 'LANG_ID'; + } + if ($this->isColumnModified(OrderTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(OrderTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $db = Propel::getServiceContainer()->getAdapter(OrderTableMap::DATABASE_NAME); + + if ($db->useQuoteIdentifier()) { + $tableName = $db->quoteIdentifierTable(OrderTableMap::TABLE_NAME); + } else { + $tableName = OrderTableMap::TABLE_NAME; + } + + $sql = sprintf( + 'INSERT INTO %s (%s) VALUES (%s)', + $tableName, + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'REF': + $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); + break; + case 'CUSTOMER_ID': + $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); + break; + case 'INVOICE_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->invoice_order_address_id, PDO::PARAM_INT); + break; + case 'DELIVERY_ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->delivery_order_address_id, PDO::PARAM_INT); + break; + case 'INVOICE_DATE': + $stmt->bindValue($identifier, $this->invoice_date ? $this->invoice_date->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'CURRENCY_ID': + $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); + break; + case 'CURRENCY_RATE': + $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); + break; + case 'TRANSACTION_REF': + $stmt->bindValue($identifier, $this->transaction_ref, PDO::PARAM_STR); + break; + case 'DELIVERY_REF': + $stmt->bindValue($identifier, $this->delivery_ref, PDO::PARAM_STR); + break; + case 'INVOICE_REF': + $stmt->bindValue($identifier, $this->invoice_ref, PDO::PARAM_STR); + break; + case 'POSTAGE': + $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); + break; + case 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); + break; + case 'STATUS_ID': + $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); + break; + case 'LANG_ID': + $stmt->bindValue($identifier, $this->lang_id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); } } diff --git a/core/lib/Thelia/Model/OrderCoupon.php b/core/lib/Thelia/Model/OrderCoupon.php deleted file mode 100644 index 558496813..000000000 --- a/core/lib/Thelia/Model/OrderCoupon.php +++ /dev/null @@ -1,10 +0,0 @@ -prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (\Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new Order(); + $obj->hydrate($row); + OrderTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + public static function getMonthlySaleStats($month, $year) { $numberOfDay = cal_days_in_month(CAL_GREGORIAN, $month, $year); diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 7a29c7e6a..4575f5aac 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -39,6 +39,7 @@ use Thelia\Model\Module; use Thelia\Model\ModuleImage; use Thelia\Model\ModuleQuery; + class BaseModule extends ContainerAware implements BaseModuleInterface { const CLASSIC_MODULE_TYPE = 1; @@ -114,18 +115,16 @@ class BaseModule extends ContainerAware implements BaseModuleInterface return $this->container; } - public function hasRequest() - { + + public function hasRequest() { return null !== $this->request; } - public function setRequest(Request $request) - { + public function setRequest(Request $request) { $this->request = $request; } - public function getRequest() - { + public function getRequest() { if ($this->hasRequest() === false) { throw new \RuntimeException("Sorry, the request is not available in this context"); } @@ -133,18 +132,16 @@ class BaseModule extends ContainerAware implements BaseModuleInterface return $this->request; } - public function hasDispatcher() - { + + public function hasDispatcher() { return null !== $this->dispatcher; } - public function setDispatcher(EventDispatcherInterface $dispatcher) - { + public function setDispatcher(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; } - public function getDispatcher() - { + public function getDispatcher() { if ($this->hasDispatcher() === false) { throw new \RuntimeException("Sorry, the dispatcher is not available in this context"); } @@ -152,6 +149,7 @@ class BaseModule extends ContainerAware implements BaseModuleInterface return $this->dispatcher; } + public function setTitle(Module $module, $titles) { if (is_array($titles)) { @@ -291,4 +289,4 @@ class BaseModule extends ContainerAware implements BaseModuleInterface { // Implement this method to do something useful. } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Module/BaseModuleInterface.php b/core/lib/Thelia/Module/BaseModuleInterface.php index be7b30a12..694a4082c 100644 --- a/core/lib/Thelia/Module/BaseModuleInterface.php +++ b/core/lib/Thelia/Module/BaseModuleInterface.php @@ -24,6 +24,8 @@ namespace Thelia\Module; use Propel\Runtime\Connection\ConnectionInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\HttpFoundation\Request; interface BaseModuleInterface { diff --git a/core/lib/Thelia/TaxEngine/TaxEngine.php b/core/lib/Thelia/TaxEngine/TaxEngine.php index 9e2f1909d..36406dc59 100755 --- a/core/lib/Thelia/TaxEngine/TaxEngine.php +++ b/core/lib/Thelia/TaxEngine/TaxEngine.php @@ -104,7 +104,7 @@ class TaxEngine * @param bool $force result is static cached ; even if a below parameter change between 2 calls, we need to keep coherent results. but you can force it. * @return null|TaxEngine */ - public function getTaxCountry($force = false) + public function getDeliveryCountry($force = false) { if(false === $force || null === self::$taxCountry) { /* is there a logged in customer ? */ diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php index 1eca7d2ea..8db9c08dc 100644 --- a/core/lib/Thelia/Tests/Action/ContentTest.php +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -47,7 +47,7 @@ class ContentTest extends TestCaseWithURLToolSetup public function getUpdateEvent(&$content) { - if (!$content instanceof \Thelia\Model\Content) { + if(!$content instanceof \Thelia\Model\Content) { $content = $this->getRandomContent(); } diff --git a/core/lib/Thelia/Tests/Action/FolderTest.php b/core/lib/Thelia/Tests/Action/FolderTest.php index cbf9a7c1e..83eebc93c 100644 --- a/core/lib/Thelia/Tests/Action/FolderTest.php +++ b/core/lib/Thelia/Tests/Action/FolderTest.php @@ -45,7 +45,7 @@ class FolderTest extends TestCaseWithURLToolSetup public function getUpdateEvent(&$folder) { - if (!$folder instanceof \Thelia\Model\Folder) { + if(!$folder instanceof \Thelia\Model\Folder) { $folder = $this->getRandomFolder(); } @@ -65,7 +65,7 @@ class FolderTest extends TestCaseWithURLToolSetup public function getUpdateSeoEvent(&$folder) { - if (!$folder instanceof \Thelia\Model\Folder) { + if(!$folder instanceof \Thelia\Model\Folder) { $folder = $this->getRandomFolder(); } @@ -83,7 +83,6 @@ class FolderTest extends TestCaseWithURLToolSetup public function processUpdateSeoAction($event) { $contentAction = new Folder($this->getContainer()); - return $contentAction->updateSeo($event); } @@ -224,7 +223,7 @@ class FolderTest extends TestCaseWithURLToolSetup ->findOne(); if (null === $nextFolder) { - $this->fail('use fixtures before launching test, there is not enough folder in database'); + $this->fail('use fixtures before launching test, there is no folder in database'); } $folder = FolderQuery::create() diff --git a/core/lib/Thelia/Tests/Action/OrderTest.php b/core/lib/Thelia/Tests/Action/OrderTest.php index f2fd00a32..64a92fd40 100644 --- a/core/lib/Thelia/Tests/Action/OrderTest.php +++ b/core/lib/Thelia/Tests/Action/OrderTest.php @@ -24,6 +24,7 @@ namespace Thelia\Tests\Action; use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Thelia\Core\Event\Order\OrderAddressEvent; use Thelia\Core\Event\Order\OrderEvent; diff --git a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php index 3d5e757d1..8b5c30398 100644 --- a/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php +++ b/core/lib/Thelia/Tests/Action/RewrittenUrlTestTrait.php @@ -37,7 +37,7 @@ trait RewrittenUrlTestTrait ->filterByView(ConfigQuery::getObsoleteRewrittenUrlView(), Criteria::NOT_EQUAL) ->findOne(); - if (null === $existingUrl) { + if(null === $existingUrl) { $this->fail('use fixtures before launching test, there is not enough rewritten url'); } @@ -55,12 +55,12 @@ trait RewrittenUrlTestTrait /* get a brand new URL */ $exist = true; - while (true === $exist) { + while(true === $exist) { $newUrl = md5(rand(1, 999999)) . ".html"; try { new RewritingResolver($newUrl); - } catch (UrlRewritingException $e) { - if ($e->getCode() === UrlRewritingException::URL_NOT_FOUND) { + } catch(UrlRewritingException $e) { + if($e->getCode() === UrlRewritingException::URL_NOT_FOUND) { /* It's all good if URL is not found */ $exist = false; } else { @@ -91,9 +91,9 @@ trait RewrittenUrlTestTrait try { $aRandomProduct->setRewrittenUrl($aRandomProduct->getLocale(), $currentUrl); $failReassign = false; - } catch (\Exception $e) { + } catch(\Exception $e) { } $this->assertFalse($failReassign); } -} +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php index de715e499..46f639521 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionCollectionTest.php @@ -52,6 +52,7 @@ class ConditionCollectionTest extends \PHPUnit_Framework_TestCase { } + /** * Generate adapter stub * diff --git a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php index 824592f77..37fde4cea 100644 --- a/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php +++ b/core/lib/Thelia/Tests/Condition/ConditionFactoryTest.php @@ -431,10 +431,12 @@ class ConditionFactoryTest extends \PHPUnit_Framework_TestCase ->method('getContainer') ->will($this->returnValue($stubContainer)); + $conditions = new ConditionCollection(); $conditionFactory = new ConditionFactory($stubContainer); + $conditionNone = new MatchForEveryone($stubFacade); $expectedCollection = new ConditionCollection(); $expectedCollection->add($conditionNone); diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php index c7e15af87..f59fe04ef 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForEveryoneTest.php @@ -197,5 +197,6 @@ class MatchForEveryoneTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected1, $actual1); $this->assertEquals($expected2, $actual2); + } } diff --git a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php index 1c61ed1f2..d28bf198d 100644 --- a/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Condition/Implementation/MatchForTotalAmountTest.php @@ -633,6 +633,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase ->method('getAvailableCurrencies') ->will($this->returnValue($currencies)); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::EQUAL, @@ -643,6 +644,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase MatchForTotalAmount::INPUT2 => 'UNK'); $condition1->setValidatorsFromForm($operators, $values); + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') ->disableOriginalConstructor() ->getMock(); @@ -698,6 +700,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase ->method('getAvailableCurrencies') ->will($this->returnValue($currencies)); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::EQUAL, @@ -708,6 +711,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') ->disableOriginalConstructor() ->getMock(); @@ -763,6 +767,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase ->method('getAvailableCurrencies') ->will($this->returnValue($currencies)); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::EQUAL, @@ -773,6 +778,7 @@ class MatchForTotalAmountTest extends \PHPUnit_Framework_TestCase MatchForTotalAmount::INPUT2 => 'EUR'); $condition1->setValidatorsFromForm($operators, $values); + $stubContainer = $this->getMockBuilder('\Symfony\Component\DependencyInjection\Container') ->disableOriginalConstructor() ->getMock(); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php index ac371e71f..c4bf8f3a6 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/CategoryTest.php @@ -53,7 +53,7 @@ class CategoryTest extends BaseLoopTestor public function testSearchById() { $category = CategoryQuery::create()->findOne(); - if (null === $category) { + if(null === $category) { $category = new \Thelia\Model\Category(); $category->setParent(0); $category->setVisible(1); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php index 0009b90d8..3d5329a66 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ContentTest.php @@ -53,7 +53,7 @@ class ContentTest extends BaseLoopTestor public function testSearchById() { $content = ContentQuery::create()->findOne(); - if (null === $content) { + if(null === $content) { $content = new \Thelia\Model\Content(); $content->setDefaultFolder(0); $content->setVisible(1); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php index 0dd3b6b0d..87c078e16 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/FolderTest.php @@ -53,7 +53,7 @@ class FolderTest extends BaseLoopTestor public function testSearchById() { $folder = FolderQuery::create()->findOne(); - if (null === $folder) { + if(null === $folder) { $folder = new \Thelia\Model\Folder(); $folder->setParent(0); $folder->setVisible(1); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php index b071bde9c..66081caa5 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/ProductTest.php @@ -54,7 +54,7 @@ class ProductTest extends BaseLoopTestor public function testSearchById() { $product = ProductQuery::create()->orderById(Criteria::ASC)->findOne(); - if (null === $product) { + if(null === $product) { $product = new \Thelia\Model\Product(); $product->setDefaultCategory(0); $product->setVisible(1); diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php index dd42a343e..7e2da4b26 100644 --- a/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/TaxRuleTest.php @@ -53,7 +53,7 @@ class TaxRuleTest extends BaseLoopTestor public function testSearchById() { $tr = TaxRuleQuery::create()->findOne(); - if (null === $tr) { + if(null === $tr) { $tr = new \Thelia\Model\TaxRule(); $tr->setTitle('foo'); $tr->save(); diff --git a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php index b5d073c87..b70bdf247 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponFactoryTest.php @@ -156,6 +156,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); $coupon1->setSerializedConditions($serializedConditions); + $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(true); $coupon1->setIsRemovingPostage(false); @@ -189,6 +190,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponManager = new RemoveXAmount($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, @@ -221,6 +223,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('unserializeConditionCollection') ->will($this->returnValue($conditions)); + $stubContainer->expects($this->any()) ->method('get') ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); @@ -252,6 +255,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponManager = new RemoveXAmount($stubFacade); + + $stubContainer->expects($this->any()) ->method('get') ->will($this->onConsecutiveCalls($stubFacade, $couponManager)); @@ -288,6 +293,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponManager = new RemoveXAmount($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, @@ -320,6 +326,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('unserializeConditionCollection') ->will($this->returnValue($conditions)); + $stubContainer->expects($this->any()) ->method('get') ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); @@ -351,6 +358,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponManager = new RemoveXAmount($stubFacade); + $condition1 = new MatchForTotalAmount($stubFacade); $operators = array( MatchForTotalAmount::INPUT1 => Operators::SUPERIOR, @@ -381,6 +389,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('unserializeConditionCollection') ->will($this->returnValue($conditions)); + $stubContainer->expects($this->any()) ->method('get') ->will($this->onConsecutiveCalls($stubFacade, $couponManager, $stubConditionFactory)); diff --git a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php index bda8275e6..bf4b9f1e9 100644 --- a/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php +++ b/core/lib/Thelia/Tests/Coupon/CouponManagerTest.php @@ -62,6 +62,7 @@ class CouponManagerTest extends \PHPUnit_Framework_TestCase { } + /** * Generate a valid Coupon model */ @@ -117,6 +118,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedConditions = $conditionFactory->serializeConditionCollection($conditions); $coupon1->setSerializedConditions($serializedConditions); + $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(true); $coupon1->setIsRemovingPostage(true); @@ -156,7 +158,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $couponFactory = new CouponFactory($stubContainer); $model1 = $this->generateCouponModel($stubFacade, $conditionFactory); - $model1->setCode('XMAS')->setIsRemovingPostage(false)->setAmount(21.00); + $model1->setAmount(21.00); $coupon1 = $couponFactory->buildCouponFromModel($model1); $model2 = $this->generateCouponModel($stubFacade, $conditionFactory); @@ -174,16 +176,12 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->will($this->returnValue(122.53)); $couponManager = new CouponManager($stubContainer); - $couponManager->addAvailableCoupon($coupon1); - $couponManager->addAvailableCoupon($coupon2); - $actual = $couponManager->getDiscount(); - $expected = 21 + 21.50; + $expected = 50.80; $this->assertEquals($expected, $actual); - $this->assertTrue($couponManager->isCouponRemovingPostage()); } /** @@ -309,6 +307,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $conditionFactory = new ConditionFactory($stubContainer); + + $stubFacade->expects($this->any()) ->method('getCurrentCoupons') ->will($this->returnValue(array())); @@ -334,6 +334,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $coupon1 = $couponFactory->buildCouponFromModel($model1); $coupon2 = clone $coupon1; + $couponManager = new CouponManager($stubContainer); $couponManager->addAvailableCoupon($coupon1); $couponManager->addAvailableCoupon($coupon2); @@ -386,6 +387,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('get') ->will($this->onConsecutiveCalls($stubFacade)); + $couponManager = new CouponManager($stubContainer); $couponManager->addAvailableCondition($condition1); $couponManager->addAvailableCondition($condition2); @@ -442,8 +444,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('get') ->will($this->onConsecutiveCalls($stubFacade)); + $couponManager = new CouponManager($stubContainer); + $stubModel = $this->getMockBuilder('\Thelia\Model\Coupon') ->disableOriginalConstructor() ->getMock(); @@ -507,8 +511,10 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua ->method('get') ->will($this->onConsecutiveCalls($stubFacade)); + $couponManager = new CouponManager($stubContainer); + $stubModel = $this->getMockBuilder('\Thelia\Model\Coupon') ->disableOriginalConstructor() ->getMock(); diff --git a/core/lib/Thelia/Tests/Model/Message.php b/core/lib/Thelia/Tests/Model/Message.php index 661ec68e0..1b7cd5716 100644 --- a/core/lib/Thelia/Tests/Model/Message.php +++ b/core/lib/Thelia/Tests/Model/Message.php @@ -23,6 +23,7 @@ namespace Thelia\Tests\Model; + use Thelia\Model\ConfigQuery; use Symfony\Component\Filesystem\Filesystem; use Thelia\Model\Message; @@ -323,8 +324,8 @@ class MessageTest extends \PHPUnit_Framework_TestCase $this->assertEquals("TEXT Layout 6: TEXT