Merge branch 'master' of https://github.com/thelia/thelia
This commit is contained in:
@@ -36,13 +36,12 @@
|
||||
"simplepie/simplepie": "dev-master",
|
||||
|
||||
"imagine/imagine": "dev-master",
|
||||
"symfony/serializer": "dev-master",
|
||||
"symfony/icu": "1.0"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"fzaninotto/faker": "dev-master",
|
||||
"maximebf/debugbar": "1.*"
|
||||
"maximebf/debugbar": "dev-master"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"config" : {
|
||||
|
||||
16
composer.lock
generated
16
composer.lock
generated
@@ -3,8 +3,7 @@
|
||||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "ba2f3e0943f00c7c3bf0c086bc611b0f",
|
||||
|
||||
"hash": "28dfdc7a840f9e70df422581f82a871f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "imagine/imagine",
|
||||
@@ -1621,16 +1620,16 @@
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "1.5.1",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maximebf/php-debugbar.git",
|
||||
"reference": "37dccc40da52bf9f85571c30cf302da696db0d05"
|
||||
"reference": "7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/37dccc40da52bf9f85571c30cf302da696db0d05",
|
||||
"reference": "37dccc40da52bf9f85571c30cf302da696db0d05",
|
||||
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d",
|
||||
"reference": "7fbe0a5d4ffc7f4e205c2b15542382308d34bd0d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1666,7 +1665,7 @@
|
||||
"keywords": [
|
||||
"debug"
|
||||
],
|
||||
"time": "2013-08-17 02:02:49"
|
||||
"time": "2013-09-11 13:01:19"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@@ -2048,7 +2047,8 @@
|
||||
"ptachoire/cssembed": 20,
|
||||
"simplepie/simplepie": 20,
|
||||
"imagine/imagine": 20,
|
||||
"fzaninotto/faker": 20
|
||||
"fzaninotto/faker": 20,
|
||||
"maximebf/debugbar": 20
|
||||
},
|
||||
"platform": {
|
||||
"php": ">=5.4"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Action;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Constraint\ConstraintFactory;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Model\Coupon as CouponModel;
|
||||
@@ -65,18 +66,6 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$this->createOrUpdate($coupon, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurring when a Coupon rule is about to be created
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
*/
|
||||
public function createRule(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
$coupon = $event->getCoupon();
|
||||
|
||||
$this->createOrUpdate($coupon, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurring when a Coupon rule is about to be updated
|
||||
*
|
||||
@@ -86,19 +75,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
$coupon = $event->getCoupon();
|
||||
|
||||
$this->createOrUpdate($coupon, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Occurring when a Coupon rule is about to be deleted
|
||||
*
|
||||
* @param CouponCreateOrUpdateEvent $event Event creation or update Event
|
||||
*/
|
||||
public function deleteRule(CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
$coupon = $event->getCoupon();
|
||||
|
||||
$this->createOrUpdate($coupon, $event);
|
||||
$this->createOrUpdateRule($coupon, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +104,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->getTitle(),
|
||||
$event->getAmount(),
|
||||
$event->getEffect(),
|
||||
$event->isRemovingPostage(),
|
||||
$event->getShortDescription(),
|
||||
$event->getDescription(),
|
||||
$event->isEnabled(),
|
||||
@@ -134,7 +112,28 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
$event->isAvailableOnSpecialOffers(),
|
||||
$event->isCumulative(),
|
||||
$event->getMaxUsage(),
|
||||
$event->getRules(),
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
$event->setCoupon($coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the Model and delegate the create or delete action
|
||||
* Feed the Event with the updated model
|
||||
*
|
||||
* @param CouponModel $coupon Model to save
|
||||
* @param CouponCreateOrUpdateEvent $event Event containing data
|
||||
*/
|
||||
protected function createOrUpdateRule(CouponModel $coupon, CouponCreateOrUpdateEvent $event)
|
||||
{
|
||||
$coupon->setDispatcher($this->getDispatcher());
|
||||
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
|
||||
$coupon->createOrUpdateRules(
|
||||
$constraintFactory->serializeCouponRuleCollection($event->getRules()),
|
||||
$event->getLocale()
|
||||
);
|
||||
|
||||
@@ -169,8 +168,7 @@ class Coupon extends BaseAction implements EventSubscriberInterface
|
||||
TheliaEvents::COUPON_DISABLE => array("disable", 128),
|
||||
TheliaEvents::COUPON_ENABLE => array("enable", 128),
|
||||
TheliaEvents::COUPON_CONSUME => array("consume", 128),
|
||||
TheliaEvents::COUPON_RULE_UPDATE => array("updateRule", 128),
|
||||
TheliaEvents::COUPON_RULE_DELETE => array("deleteRule", 128)
|
||||
TheliaEvents::COUPON_RULE_UPDATE => array("updateRule", 128)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
<forms>
|
||||
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
|
||||
<form name="thelia.customer.modification" class="Thelia\Form\CustomerModification"/>
|
||||
<form name="thelia.customer.lostpassword" class="Thelia\Form\CustomerLostPasswordForm"/>
|
||||
|
||||
<form name="thelia.customer.login" class="Thelia\Form\CustomerLogin"/>
|
||||
<form name="thelia.admin.login" class="Thelia\Form\AdminLogin"/>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- Customer routes -->
|
||||
<route id="customer.create.process" path="/customer/create" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
|
||||
<default key="_view">connexion</default>
|
||||
<default key="_view">register</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.create.view" path="/register">
|
||||
@@ -34,10 +34,20 @@
|
||||
<default key="_view">login</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.logout.process" path="/customer/logout">
|
||||
<route id="customer.logout.process" path="/logout">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::logoutAction</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.password.retrieve.view" path="/password" methods="get">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">password</default>
|
||||
</route>
|
||||
|
||||
<route id="customer.password.retrieve.process" path="/password" methods="post">
|
||||
<default key="_controller">Thelia\Controller\Front\CustomerController::newPasswordAction</default>
|
||||
<default key="_view">password</default>
|
||||
</route>
|
||||
|
||||
<!-- end customer routes -->
|
||||
|
||||
<!-- customer address routes -->
|
||||
@@ -57,6 +67,10 @@
|
||||
<!-- end customer address routes -->
|
||||
|
||||
<!-- cart routes -->
|
||||
<route id="cart.view" path="/cart">
|
||||
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
|
||||
<default key="_view">cart</default>
|
||||
</route>
|
||||
<route id="cart.add.process" path="/cart/add">
|
||||
<default key="_controller">Thelia\Controller\Front\CartController::addItem</default>
|
||||
<default key="_view">cart</default>
|
||||
|
||||
@@ -73,70 +73,6 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
)
|
||||
);
|
||||
|
||||
// /** @var RuleValidator Price Validator */
|
||||
// protected $priceValidator = null;
|
||||
|
||||
// /**
|
||||
// * Check if backoffice inputs are relevant or not
|
||||
// *
|
||||
// * @throws InvalidRuleOperatorException if Operator is not allowed
|
||||
// * @throws InvalidRuleValueException if Value is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkBackOfficeInput()
|
||||
// {
|
||||
// if (!isset($this->validators)
|
||||
// || empty($this->validators)
|
||||
// ||!isset($this->validators[self::PARAM1_PRICE])
|
||||
// ||!isset($this->validators[self::PARAM1_PRICE])
|
||||
// ) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE);
|
||||
// }
|
||||
//
|
||||
// /** @var RuleValidator $ruleValidator */
|
||||
// $ruleValidator = $this->validators[self::PARAM1_PRICE];
|
||||
// /** @var PriceParam $price */
|
||||
// $price = $ruleValidator->getParam();
|
||||
//
|
||||
// if (!$price instanceof PriceParam) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE);
|
||||
// }
|
||||
//
|
||||
// $this->checkBackOfficeInputsOperators();
|
||||
//
|
||||
// return $this->isPriceValid($price->getPrice(), $price->getCurrency());
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Check if Checkout inputs are relevant or not
|
||||
// *
|
||||
// * @throws InvalidRuleValueException if Value is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkCheckoutInput()
|
||||
// {
|
||||
// $currency = $this->adapter->getCheckoutCurrency();
|
||||
// if (empty($currency)) {
|
||||
// throw new InvalidRuleValueException(
|
||||
// get_class(), self::PARAM1_CURRENCY
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $price = $this->adapter->getCartTotalPrice();
|
||||
// if (empty($price)) {
|
||||
// throw new InvalidRuleValueException(
|
||||
// get_class(), self::PARAM1_PRICE
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $this->paramsToValidate = array(
|
||||
// self::PARAM1_PRICE => $this->adapter->getCartTotalPrice(),
|
||||
// self::PARAM1_CURRENCY => $this->adapter->getCheckoutCurrency()
|
||||
// );
|
||||
//
|
||||
// return $this->isPriceValid($price, $currency);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Check validators relevancy and store them
|
||||
*
|
||||
@@ -249,49 +185,6 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
return false;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Check if a price is valid
|
||||
// *
|
||||
// * @param float $price Price to check
|
||||
// * @param string $currency Price currency
|
||||
// *
|
||||
// * @throws InvalidRuleValueException if Value is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// protected function isPriceValid($price, $currency)
|
||||
// {
|
||||
// $priceValidator = $this->priceValidator;
|
||||
//
|
||||
// /** @var PriceParam $param */
|
||||
// $param = $priceValidator->getParam();
|
||||
// if ($currency == $param->getCurrency()) {
|
||||
// try {
|
||||
// $priceValidator->getParam()->compareTo($price);
|
||||
// } catch(\InvalidArgumentException $e) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_PRICE);
|
||||
// }
|
||||
// } else {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_CURRENCY);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Generate current Rule param to be validated from adapter
|
||||
// *
|
||||
// * @return $this
|
||||
// */
|
||||
// protected function setParametersToValidate()
|
||||
// {
|
||||
// $this->paramsToValidate = array(
|
||||
// self::PARAM1_PRICE => $this->adapter->getCartTotalPrice(),
|
||||
// self::PARAM1_CURRENCY => $this->adapter->getCheckoutCurrency()
|
||||
// );
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get I18n name
|
||||
*
|
||||
@@ -377,41 +270,4 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract
|
||||
);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Populate a Rule from a form admin
|
||||
// *
|
||||
// * @param array $operators Rule Operator set by the Admin
|
||||
// * @param array $values Rule Values set by the Admin
|
||||
// *
|
||||
// * @throws \InvalidArgumentException
|
||||
// * @return $this
|
||||
// */
|
||||
// public function populateFromForm(array $operators, array $values)
|
||||
// {
|
||||
// if ($values[self::PARAM1_PRICE] === null
|
||||
// || $values[self::PARAM1_CURRENCY] === null
|
||||
// ) {
|
||||
// throw new \InvalidArgumentException(
|
||||
// 'The Rule ' . get_class() . 'needs at least a quantity set (' . self::PARAM1_PRICE . ', ' . self::PARAM1_CURRENCY . ')'
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $this->priceValidator = new RuleValidator(
|
||||
// $operators[self::PARAM1_PRICE],
|
||||
// new PriceParam(
|
||||
// $this->translator,
|
||||
// $values[self::PARAM1_PRICE],
|
||||
// $values[self::PARAM1_CURRENCY]
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// $this->validators = array(self::PARAM1_PRICE => $this->priceValidator);
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -63,77 +63,6 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
)
|
||||
);
|
||||
|
||||
// /** @var QuantityParam Quantity Validator */
|
||||
// protected $quantityValidator = null;
|
||||
|
||||
// /**
|
||||
// * Check if backoffice inputs are relevant or not
|
||||
// *
|
||||
// * @throws InvalidRuleOperatorException if Operator is not allowed
|
||||
// * @throws InvalidRuleValueException if Value is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkBackOfficeInput()
|
||||
// {
|
||||
// if (!isset($this->validators)
|
||||
// || empty($this->validators)
|
||||
// ||!isset($this->validators[self::PARAM1_QUANTITY])
|
||||
// ||!isset($this->validators[self::PARAM1_QUANTITY])
|
||||
// ) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY);
|
||||
// }
|
||||
//
|
||||
// /** @var RuleValidator $ruleValidator */
|
||||
// $ruleValidator = $this->validators[self::PARAM1_QUANTITY];
|
||||
// /** @var QuantityParam $quantity */
|
||||
// $quantity = $ruleValidator->getParam();
|
||||
//
|
||||
// if (!$quantity instanceof QuantityParam) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY);
|
||||
// }
|
||||
//
|
||||
// $this->checkBackOfficeInputsOperators();
|
||||
//
|
||||
// return $this->isQuantityValid($quantity->getInteger());
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Generate current Rule param to be validated from adapter
|
||||
// *
|
||||
// * @param CouponAdapterInterface $adapter allowing to gather
|
||||
// * all necessary Thelia variables
|
||||
// *
|
||||
// * @return $this
|
||||
// */
|
||||
// protected function setParametersToValidate()
|
||||
// {
|
||||
// $this->paramsToValidate = array(
|
||||
// self::PARAM1_QUANTITY => $this->adapter->getNbArticlesInCart()
|
||||
// );
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Check if Checkout inputs are relevant or not
|
||||
// *
|
||||
// * @throws \Thelia\Exception\InvalidRuleValueException
|
||||
// * @return bool
|
||||
// */
|
||||
// public function checkCheckoutInput()
|
||||
// {
|
||||
// if (!isset($this->paramsToValidate)
|
||||
// || empty($this->paramsToValidate)
|
||||
// ||!isset($this->paramsToValidate[self::PARAM1_QUANTITY])
|
||||
// ) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY);
|
||||
// }
|
||||
//
|
||||
// $price = $this->paramsToValidate[self::PARAM1_QUANTITY];
|
||||
//
|
||||
// return $this->isQuantityValid($price);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Check validators relevancy and store them
|
||||
*
|
||||
@@ -174,7 +103,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_int($quantityValue) || $quantityValue <= 0) {
|
||||
if ((int) $quantityValue <= 0) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Value for quantity field is not legit'
|
||||
);
|
||||
@@ -210,26 +139,6 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
return false;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Check if a quantity is valid
|
||||
// *
|
||||
// * @param int $quantity Quantity to check
|
||||
// *
|
||||
// * @throws InvalidRuleValueException if Value is not allowed
|
||||
// * @return bool
|
||||
// */
|
||||
// protected function isQuantityValid($quantity)
|
||||
// {
|
||||
// $quantityValidator = $this->quantityValidator;
|
||||
// try {
|
||||
// $quantityValidator->getParam()->compareTo($quantity);
|
||||
// } catch(InvalidArgumentException $e) {
|
||||
// throw new InvalidRuleValueException(get_class(), self::PARAM1_QUANTITY);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get I18n name
|
||||
*
|
||||
@@ -267,36 +176,6 @@ class AvailableForXArticlesManager extends CouponRuleAbstract
|
||||
return $toolTip;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Populate a Rule from a form admin
|
||||
// *
|
||||
// * @param array $operators Rule Operator set by the Admin
|
||||
// * @param array $values Rule Values set by the Admin
|
||||
// *
|
||||
// * @throws InvalidArgumentException
|
||||
// * @return $this
|
||||
// */
|
||||
// public function populateFromForm(array $operators, array $values)
|
||||
// {
|
||||
// if ($values[self::PARAM1_QUANTITY] === null) {
|
||||
// throw new InvalidArgumentException(
|
||||
// 'The Rule ' . get_class() . 'needs at least a quantity set (' . self::PARAM1_QUANTITY. ')'
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $this->quantityValidator = new RuleValidator(
|
||||
// $operators[self::PARAM1_QUANTITY],
|
||||
// new QuantityParam(
|
||||
// $this->adapter,
|
||||
// $values[self::PARAM1_QUANTITY]
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// $this->validators = array(self::PARAM1_QUANTITY => $this->quantityValidator);
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Generate inputs ready to be drawn
|
||||
*
|
||||
|
||||
@@ -26,12 +26,17 @@ namespace Thelia\Controller\Admin;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Constraint\ConstraintFactory;
|
||||
use Thelia\Constraint\ConstraintFactoryTest;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmount;
|
||||
use Thelia\Constraint\Rule\CouponRuleInterface;
|
||||
use Thelia\Constraint\Validator\PriceParam;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Coupon\CouponEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\HttpFoundation\Session\Session;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\AuthorizationException;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Coupon\CouponAdapterInterface;
|
||||
use Thelia\Coupon\CouponManager;
|
||||
@@ -153,6 +158,13 @@ class CouponController extends BaseAdminController
|
||||
);
|
||||
} else {
|
||||
// Prepare the data that will hydrate the form
|
||||
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
$rules = $constraintFactory->unserializeCouponRuleCollection(
|
||||
$coupon->getSerializedRules()
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'code' => $coupon->getCode(),
|
||||
'title' => $coupon->getTitle(),
|
||||
@@ -166,18 +178,12 @@ class CouponController extends BaseAdminController
|
||||
'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
'maxUsage' => $coupon->getMaxUsage(),
|
||||
'rules' => new CouponRuleCollection(array()),
|
||||
'rules' => $rules,
|
||||
'locale' => $coupon->getLocale(),
|
||||
);
|
||||
|
||||
$args['rulesObject'] = array();
|
||||
|
||||
/** @var ConstraintFactory $constraintFactory */
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
$rules = $constraintFactory->unserializeCouponRuleCollection(
|
||||
$coupon->getSerializedRules()
|
||||
);
|
||||
|
||||
/** @var CouponRuleInterface $rule */
|
||||
foreach ($rules->getRules() as $rule) {
|
||||
$args['rulesObject'][] = array(
|
||||
@@ -188,6 +194,8 @@ class CouponController extends BaseAdminController
|
||||
);
|
||||
}
|
||||
|
||||
$args['rules'] = $this->cleanRuleForTemplate($rules);
|
||||
|
||||
// Setup the object form
|
||||
$changeForm = new CouponCreationForm($this->getRequest(), 'form', $data);
|
||||
|
||||
@@ -211,99 +219,103 @@ class CouponController extends BaseAdminController
|
||||
|
||||
$args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
|
||||
return $this->render(
|
||||
'coupon-update',
|
||||
$args
|
||||
);
|
||||
return $this->render('coupon-update', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons Rule creation display
|
||||
*
|
||||
* @param int $couponId Coupon id
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function createRuleAction($couponId)
|
||||
{
|
||||
// Check current user authorization
|
||||
$response = $this->checkAuth('admin.coupon.update');
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
/** @var Coupon $coupon */
|
||||
$coupon = CouponQuery::create()->findOneById($couponId);
|
||||
if (!$coupon) {
|
||||
$this->pageNotFound();
|
||||
}
|
||||
|
||||
// Parameters given to the template
|
||||
$args = array();
|
||||
|
||||
$i18n = new I18n();
|
||||
/** @var Lang $lang */
|
||||
$lang = $this->getSession()->get('lang');
|
||||
$eventToDispatch = TheliaEvents::COUPON_RULE_CREATE;
|
||||
|
||||
if ($this->getRequest()->isMethod('POST')) {
|
||||
$this->validateCreateOrUpdateForm(
|
||||
$i18n,
|
||||
$lang,
|
||||
$eventToDispatch,
|
||||
'updated',
|
||||
'update'
|
||||
);
|
||||
} else {
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'code' => $coupon->getCode(),
|
||||
'title' => $coupon->getTitle(),
|
||||
'amount' => $coupon->getAmount(),
|
||||
'effect' => $coupon->getType(),
|
||||
'shortDescription' => $coupon->getShortDescription(),
|
||||
'description' => $coupon->getDescription(),
|
||||
'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()),
|
||||
'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
|
||||
'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
'maxUsage' => $coupon->getMaxUsage(),
|
||||
'rules' => new CouponRuleCollection(array()),
|
||||
'locale' => $coupon->getLocale(),
|
||||
);
|
||||
|
||||
/** @var CouponAdapterInterface $adapter */
|
||||
$adapter = $this->container->get('thelia.adapter');
|
||||
/** @var Translator $translator */
|
||||
$translator = $this->container->get('thelia.translator');
|
||||
|
||||
$args['rulesObject'] = array();
|
||||
/** @var CouponRuleInterface $rule */
|
||||
foreach ($coupon->getRules()->getRules() as $rule) {
|
||||
$args['rulesObject'][] = array(
|
||||
'name' => $rule->getName($translator),
|
||||
'tooltip' => $rule->getToolTip($translator),
|
||||
'validators' => $rule->getValidators()
|
||||
);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Manage Coupons Rule creation display
|
||||
// *
|
||||
// * @param int $couponId Coupon id
|
||||
// *
|
||||
// * @return \Symfony\Component\HttpFoundation\Response
|
||||
// */
|
||||
// public function createRuleAction($couponId)
|
||||
// {
|
||||
// // Check current user authorization
|
||||
// $response = $this->checkAuth('admin.coupon.update');
|
||||
// if ($response !== null) {
|
||||
// return $response;
|
||||
// }
|
||||
//
|
||||
// /** @var Coupon $coupon */
|
||||
// $coupon = CouponQuery::create()->findOneById($couponId);
|
||||
// if (!$coupon) {
|
||||
// $this->pageNotFound();
|
||||
// }
|
||||
//
|
||||
// // Parameters given to the template
|
||||
// $args = array();
|
||||
//
|
||||
// $i18n = new I18n();
|
||||
// /** @var Lang $lang */
|
||||
// $lang = $this->getSession()->get('lang');
|
||||
// $eventToDispatch = TheliaEvents::COUPON_RULE_CREATE;
|
||||
//
|
||||
// if ($this->getRequest()->isMethod('POST')) {
|
||||
// $this->validateCreateOrUpdateForm(
|
||||
// $i18n,
|
||||
// $lang,
|
||||
// $eventToDispatch,
|
||||
// 'updated',
|
||||
// 'update'
|
||||
// );
|
||||
// } else {
|
||||
// // Prepare the data that will hydrate the form
|
||||
//
|
||||
// /** @var ConstraintFactory $constraintFactory */
|
||||
// $constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
//
|
||||
// $data = array(
|
||||
// 'code' => $coupon->getCode(),
|
||||
// 'title' => $coupon->getTitle(),
|
||||
// 'amount' => $coupon->getAmount(),
|
||||
// 'effect' => $coupon->getType(),
|
||||
// 'shortDescription' => $coupon->getShortDescription(),
|
||||
// 'description' => $coupon->getDescription(),
|
||||
// 'isEnabled' => ($coupon->getIsEnabled() == 1),
|
||||
// 'expirationDate' => $coupon->getExpirationDate($lang->getDateFormat()),
|
||||
// 'isAvailableOnSpecialOffers' => ($coupon->getIsAvailableOnSpecialOffers() == 1),
|
||||
// 'isCumulative' => ($coupon->getIsCumulative() == 1),
|
||||
// 'isRemovingPostage' => ($coupon->getIsRemovingPostage() == 1),
|
||||
// 'maxUsage' => $coupon->getMaxUsage(),
|
||||
// 'rules' => $constraintFactory->unserializeCouponRuleCollection($coupon->getSerializedRules()),
|
||||
// 'locale' => $coupon->getLocale(),
|
||||
// );
|
||||
//
|
||||
// /** @var CouponAdapterInterface $adapter */
|
||||
// $adapter = $this->container->get('thelia.adapter');
|
||||
// /** @var Translator $translator */
|
||||
// $translator = $this->container->get('thelia.translator');
|
||||
//
|
||||
// $args['rulesObject'] = array();
|
||||
// /** @var CouponRuleInterface $rule */
|
||||
// foreach ($coupon->getRules()->getRules() as $rule) {
|
||||
// $args['rulesObject'][] = array(
|
||||
// 'name' => $rule->getName($translator),
|
||||
// 'tooltip' => $rule->getToolTip($translator),
|
||||
// 'validators' => $rule->getValidators()
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// $args['rules'] = $this->cleanRuleForTemplate($coupon->getRules()->getRules());
|
||||
//
|
||||
// // Setup the object form
|
||||
// $changeForm = new CouponCreationForm($this->getRequest(), 'form', $data);
|
||||
//
|
||||
// // Pass it to the parser
|
||||
// $this->getParserContext()->addForm($changeForm);
|
||||
// }
|
||||
//
|
||||
// $args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
//
|
||||
// return $this->render(
|
||||
// 'coupon-update',
|
||||
// $args
|
||||
// );
|
||||
// }
|
||||
|
||||
// Setup the object form
|
||||
$changeForm = new CouponCreationForm($this->getRequest(), 'form', $data);
|
||||
|
||||
// Pass it to the parser
|
||||
$this->getParserContext()->addForm($changeForm);
|
||||
}
|
||||
|
||||
$args['formAction'] = 'admin/coupon/update/' . $couponId;
|
||||
|
||||
return $this->render(
|
||||
'coupon-update',
|
||||
$args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
@@ -367,6 +379,7 @@ class CouponController extends BaseAdminController
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
*
|
||||
@@ -404,7 +417,6 @@ class CouponController extends BaseAdminController
|
||||
$constraintFactory = $this->container->get('thelia.constraint.factory');
|
||||
$rulesReceived = json_decode($this->getRequest()->get('rules'));
|
||||
foreach ($rulesReceived as $ruleReceived) {
|
||||
var_dump('building ', $ruleReceived->values);
|
||||
$rule = $constraintFactory->build(
|
||||
$ruleReceived->serviceId,
|
||||
(array) $ruleReceived->operators,
|
||||
@@ -433,6 +445,7 @@ class CouponController extends BaseAdminController
|
||||
$rules,
|
||||
$coupon->getLocale()
|
||||
);
|
||||
$couponEvent->setCoupon($coupon);
|
||||
|
||||
$eventToDispatch = TheliaEvents::COUPON_RULE_UPDATE;
|
||||
// Dispatch Event to the Action
|
||||
@@ -688,4 +701,6 @@ class CouponController extends BaseAdminController
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -215,8 +215,6 @@ class BaseController extends ContainerAware
|
||||
$url = $this->getRequest()->get("success_url");
|
||||
}
|
||||
|
||||
echo "url=$url";
|
||||
|
||||
if (null !== $url) $this->redirect($url);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,13 @@ namespace Thelia\Controller\Front;
|
||||
|
||||
use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\CustomerLoginEvent;
|
||||
use Thelia\Core\Event\LostPasswordEvent;
|
||||
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\UsernameNotFoundException;
|
||||
use Thelia\Form\CustomerCreation;
|
||||
use Thelia\Form\CustomerLogin;
|
||||
use Thelia\Form\CustomerLostPasswordForm;
|
||||
use Thelia\Form\CustomerModification;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\Customer;
|
||||
@@ -44,6 +46,42 @@ use Thelia\Core\Security\Exception\WrongPasswordException;
|
||||
*/
|
||||
class CustomerController extends BaseFrontController
|
||||
{
|
||||
use \Thelia\Cart\CartTrait;
|
||||
|
||||
public function newPasswordAction()
|
||||
{
|
||||
if (! $this->getSecurityContext()->hasCustomerUser()) {
|
||||
$message = false;
|
||||
|
||||
$passwordLost = new CustomerLostPasswordForm($this->getRequest());
|
||||
|
||||
try {
|
||||
|
||||
$form = $this->validateForm($passwordLost);
|
||||
|
||||
$event = new LostPasswordEvent($form->get("email")->getData());
|
||||
|
||||
$this->dispatch(TheliaEvents::LOST_PASSWORD, $event);
|
||||
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$message = sprintf("Sorry, an error occured: %s", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($message !== false) {
|
||||
Tlog::getInstance()->error(sprintf("Error during customer creation process : %s. Exception was %s", $message, $e->getMessage()));
|
||||
|
||||
$passwordLost->setErrorMessage($message);
|
||||
|
||||
$this->getParserContext()
|
||||
->addForm($passwordLost)
|
||||
->setGeneralError($message)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new customer.
|
||||
* On success, redirect to success_url if exists, otherwise, display the same view again.
|
||||
@@ -65,7 +103,12 @@ class CustomerController extends BaseFrontController
|
||||
|
||||
$this->processLogin($customerCreateEvent->getCustomer());
|
||||
|
||||
$this->redirectSuccess($customerCreation);
|
||||
$cart = $this->getCart($this->getRequest());
|
||||
if($cart->getCartItems()->count() > 0) {
|
||||
$this->redirectToRoute("cart.view");
|
||||
} else {
|
||||
$this->redirectSuccess($customerCreation);
|
||||
}
|
||||
} catch (FormValidationException $e) {
|
||||
$message = sprintf("Please check your input: %s", $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
@@ -232,7 +275,7 @@ class CustomerController extends BaseFrontController
|
||||
$data["country"],
|
||||
isset($data["email"])?$data["email"]:null,
|
||||
isset($data["password"]) ? $data["password"]:null,
|
||||
$this->getRequest()->getSession()->getLang(),
|
||||
$this->getRequest()->getSession()->getLang()->getId(),
|
||||
isset($data["reseller"])?$data["reseller"]:null,
|
||||
isset($data["sponsor"])?$data["sponsor"]:null,
|
||||
isset($data["discount"])?$data["discount"]:null
|
||||
|
||||
51
core/lib/Thelia/Core/Event/LostPasswordEvent.php
Normal file
51
core/lib/Thelia/Core/Event/LostPasswordEvent.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class LostPasswordEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LostPasswordEvent extends ActionEvent {
|
||||
|
||||
protected $email;
|
||||
|
||||
public function __construct($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -71,6 +71,10 @@ final class TheliaEvents
|
||||
*/
|
||||
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
|
||||
|
||||
/**
|
||||
* sent when a customer need a new password
|
||||
*/
|
||||
const LOST_PASSWORD = "action.lostPassword";
|
||||
/**
|
||||
* Sent before the logout of the administrator.
|
||||
*/
|
||||
@@ -294,21 +298,6 @@ final class TheliaEvents
|
||||
*/
|
||||
const AFTER_COUPON_RULE_UPDATE = "action.after_update_coupon_rule";
|
||||
|
||||
/**
|
||||
* Sent when attempting to delete Coupon Rule
|
||||
*/
|
||||
const COUPON_RULE_DELETE = "action.delete_coupon_rule";
|
||||
|
||||
/**
|
||||
* Sent just before an attempt to delete a Coupon Rule
|
||||
*/
|
||||
const BEFORE_COUPON_RULE_DELETE = "action.before_delete_coupon_rule";
|
||||
|
||||
/**
|
||||
* Sent just after an attempt to delete a Coupon Rule
|
||||
*/
|
||||
const AFTER_COUPON_RULE_DELETE = "action.after_delete_coupon_rule";
|
||||
|
||||
// -- Configuration management ---------------------------------------------
|
||||
|
||||
const CONFIG_CREATE = "action.createConfig";
|
||||
@@ -358,4 +347,5 @@ final class TheliaEvents
|
||||
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
|
||||
const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ abstract class BaseLoop
|
||||
$loopType = isset($nameValuePairs['type']) ? $nameValuePairs['type'] : "undefined";
|
||||
$loopName = isset($nameValuePairs['name']) ? $nameValuePairs['name'] : "undefined";
|
||||
|
||||
$this->args->rewind();
|
||||
while (($argument = $this->args->current()) !== false) {
|
||||
$this->args->next();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class Thelia extends Kernel
|
||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
|
||||
if ($this->isDebug()) {
|
||||
//$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||
$con->useDebug(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,18 @@ class TaxEngineException extends \RuntimeException
|
||||
{
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const BAD_RECORDED_TYPE = 101;
|
||||
const BAD_RECORDED_REQUIREMENTS = 102;
|
||||
|
||||
const TAX_TYPE_BAD_ABSTRACT_METHOD = 201;
|
||||
const TAX_TYPE_REQUIREMENT_NOT_FOUND = 202;
|
||||
const TAX_TYPE_BAD_REQUIREMENT_VALUE = 203;
|
||||
|
||||
const UNDEFINED_PRODUCT = 501;
|
||||
const UNDEFINED_COUNTRY = 502;
|
||||
const UNDEFINED_TAX_RULES_COLLECTION = 503;
|
||||
const UNDEFINED_REQUIREMENTS = 504;
|
||||
const UNDEFINED_REQUIREMENT_VALUE = 505;
|
||||
|
||||
const BAD_AMOUNT_FORMAT = 601;
|
||||
|
||||
|
||||
39
core/lib/Thelia/Exception/TypeException.php
Executable file
39
core/lib/Thelia/Exception/TypeException.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Exception;
|
||||
|
||||
class TypeException extends \RuntimeException
|
||||
{
|
||||
const UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
const MODEL_NOT_FOUND = 404;
|
||||
|
||||
public function __construct($message, $code = null, $previous = null)
|
||||
{
|
||||
if ($code === null) {
|
||||
$code = self::UNKNOWN_EXCEPTION;
|
||||
}
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,10 @@ class CustomerCreation extends BaseForm
|
||||
"label_attr" => array(
|
||||
"for" => "address"
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Street Address")
|
||||
"label" => Translator::getInstance()->trans("Street Address"),
|
||||
"label_attr" => array(
|
||||
"for" => "address1"
|
||||
)
|
||||
))
|
||||
->add("address2", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Address Line 2"),
|
||||
@@ -80,7 +83,7 @@ class CustomerCreation extends BaseForm
|
||||
)
|
||||
))
|
||||
->add("company", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Company name"),
|
||||
"label" => Translator::getInstance()->trans("Company Name"),
|
||||
"label_attr" => array(
|
||||
"for" => "company"
|
||||
)
|
||||
|
||||
96
core/lib/Thelia/Form/CustomerLostPasswordForm.php
Normal file
96
core/lib/Thelia/Form/CustomerLostPasswordForm.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
/**
|
||||
* Class CustomerLostPasswordForm
|
||||
* @package Thelia\Form
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class CustomerLostPasswordForm extends BaseForm {
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("email", "email", array(
|
||||
"constraints" => array(
|
||||
new NotBlank(),
|
||||
new Email(),
|
||||
new Callback(array(
|
||||
"methods" => array(
|
||||
array($this,
|
||||
"verifyExistingEmail")
|
||||
)
|
||||
))
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Please enter your email address"),
|
||||
"label_attr" => array(
|
||||
"for" => "forgot-email"
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function verifyExistingEmail($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOneByEmail($value);
|
||||
if (null === $customer) {
|
||||
$context->addViolation("This email does not exists exists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_customer_creation";
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
*/
|
||||
protected $product_id;
|
||||
|
||||
/**
|
||||
* The value for the ref field.
|
||||
* @var string
|
||||
*/
|
||||
protected $ref;
|
||||
|
||||
/**
|
||||
* The value for the quantity field.
|
||||
* @var double
|
||||
@@ -452,6 +458,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [ref] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [quantity] column value.
|
||||
*
|
||||
@@ -582,6 +599,27 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
return $this;
|
||||
} // setProductId()
|
||||
|
||||
/**
|
||||
* Set the value of [ref] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\ProductSaleElements The current object (for fluent API support)
|
||||
*/
|
||||
public function setRef($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->ref !== $v) {
|
||||
$this->ref = $v;
|
||||
$this->modifiedColumns[] = ProductSaleElementsTableMap::REF;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setRef()
|
||||
|
||||
/**
|
||||
* Set the value of [quantity] column.
|
||||
*
|
||||
@@ -759,25 +797,28 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProductSaleElementsTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->product_id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductSaleElementsTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProductSaleElementsTableMap::translateFieldName('Ref', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->ref = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductSaleElementsTableMap::translateFieldName('Quantity', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->quantity = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProductSaleElementsTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductSaleElementsTableMap::translateFieldName('Promo', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->promo = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProductSaleElementsTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductSaleElementsTableMap::translateFieldName('Newness', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->newness = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->weight = (null !== $col) ? (double) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::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 ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -790,7 +831,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 8; // 8 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e);
|
||||
@@ -1089,6 +1130,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'PRODUCT_ID';
|
||||
}
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::REF)) {
|
||||
$modifiedColumns[':p' . $index++] = 'REF';
|
||||
}
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) {
|
||||
$modifiedColumns[':p' . $index++] = 'QUANTITY';
|
||||
}
|
||||
@@ -1124,6 +1168,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
case 'PRODUCT_ID':
|
||||
$stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'REF':
|
||||
$stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'QUANTITY':
|
||||
$stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR);
|
||||
break;
|
||||
@@ -1211,21 +1258,24 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
return $this->getProductId();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getQuantity();
|
||||
return $this->getRef();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getPromo();
|
||||
return $this->getQuantity();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getNewness();
|
||||
return $this->getPromo();
|
||||
break;
|
||||
case 5:
|
||||
return $this->getWeight();
|
||||
return $this->getNewness();
|
||||
break;
|
||||
case 6:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getWeight();
|
||||
break;
|
||||
case 7:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 8:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -1259,12 +1309,13 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getProductId(),
|
||||
$keys[2] => $this->getQuantity(),
|
||||
$keys[3] => $this->getPromo(),
|
||||
$keys[4] => $this->getNewness(),
|
||||
$keys[5] => $this->getWeight(),
|
||||
$keys[6] => $this->getCreatedAt(),
|
||||
$keys[7] => $this->getUpdatedAt(),
|
||||
$keys[2] => $this->getRef(),
|
||||
$keys[3] => $this->getQuantity(),
|
||||
$keys[4] => $this->getPromo(),
|
||||
$keys[5] => $this->getNewness(),
|
||||
$keys[6] => $this->getWeight(),
|
||||
$keys[7] => $this->getCreatedAt(),
|
||||
$keys[8] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1326,21 +1377,24 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
$this->setProductId($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setQuantity($value);
|
||||
$this->setRef($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setPromo($value);
|
||||
$this->setQuantity($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setNewness($value);
|
||||
$this->setPromo($value);
|
||||
break;
|
||||
case 5:
|
||||
$this->setWeight($value);
|
||||
$this->setNewness($value);
|
||||
break;
|
||||
case 6:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setWeight($value);
|
||||
break;
|
||||
case 7:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 8:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1369,12 +1423,13 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setQuantity($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setPromo($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setNewness($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setWeight($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setQuantity($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setPromo($arr[$keys[4]]);
|
||||
if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]);
|
||||
if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1388,6 +1443,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::ID)) $criteria->add(ProductSaleElementsTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::PRODUCT_ID)) $criteria->add(ProductSaleElementsTableMap::PRODUCT_ID, $this->product_id);
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::REF)) $criteria->add(ProductSaleElementsTableMap::REF, $this->ref);
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::QUANTITY)) $criteria->add(ProductSaleElementsTableMap::QUANTITY, $this->quantity);
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo);
|
||||
if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness);
|
||||
@@ -1458,6 +1514,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setProductId($this->getProductId());
|
||||
$copyObj->setRef($this->getRef());
|
||||
$copyObj->setQuantity($this->getQuantity());
|
||||
$copyObj->setPromo($this->getPromo());
|
||||
$copyObj->setNewness($this->getNewness());
|
||||
@@ -2383,6 +2440,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface
|
||||
{
|
||||
$this->id = null;
|
||||
$this->product_id = null;
|
||||
$this->ref = null;
|
||||
$this->quantity = null;
|
||||
$this->promo = null;
|
||||
$this->newness = null;
|
||||
|
||||
@@ -23,6 +23,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
*
|
||||
* @method ChildProductSaleElementsQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildProductSaleElementsQuery orderByProductId($order = Criteria::ASC) Order by the product_id column
|
||||
* @method ChildProductSaleElementsQuery orderByRef($order = Criteria::ASC) Order by the ref column
|
||||
* @method ChildProductSaleElementsQuery orderByQuantity($order = Criteria::ASC) Order by the quantity column
|
||||
* @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column
|
||||
* @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column
|
||||
@@ -32,6 +33,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
*
|
||||
* @method ChildProductSaleElementsQuery groupById() Group by the id column
|
||||
* @method ChildProductSaleElementsQuery groupByProductId() Group by the product_id column
|
||||
* @method ChildProductSaleElementsQuery groupByRef() Group by the ref column
|
||||
* @method ChildProductSaleElementsQuery groupByQuantity() Group by the quantity column
|
||||
* @method ChildProductSaleElementsQuery groupByPromo() Group by the promo column
|
||||
* @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column
|
||||
@@ -64,6 +66,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
*
|
||||
* @method ChildProductSaleElements findOneById(int $id) Return the first ChildProductSaleElements filtered by the id column
|
||||
* @method ChildProductSaleElements findOneByProductId(int $product_id) Return the first ChildProductSaleElements filtered by the product_id column
|
||||
* @method ChildProductSaleElements findOneByRef(string $ref) Return the first ChildProductSaleElements filtered by the ref column
|
||||
* @method ChildProductSaleElements findOneByQuantity(double $quantity) Return the first ChildProductSaleElements filtered by the quantity column
|
||||
* @method ChildProductSaleElements findOneByPromo(int $promo) Return the first ChildProductSaleElements filtered by the promo column
|
||||
* @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column
|
||||
@@ -73,6 +76,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
*
|
||||
* @method array findById(int $id) Return ChildProductSaleElements objects filtered by the id column
|
||||
* @method array findByProductId(int $product_id) Return ChildProductSaleElements objects filtered by the product_id column
|
||||
* @method array findByRef(string $ref) Return ChildProductSaleElements objects filtered by the ref column
|
||||
* @method array findByQuantity(double $quantity) Return ChildProductSaleElements objects filtered by the quantity column
|
||||
* @method array findByPromo(int $promo) Return ChildProductSaleElements objects filtered by the promo column
|
||||
* @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column
|
||||
@@ -167,7 +171,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, PRODUCT_ID, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -340,6 +344,35 @@ abstract class ProductSaleElementsQuery extends ModelCriteria
|
||||
return $this->addUsingAlias(ProductSaleElementsTableMap::PRODUCT_ID, $productId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the ref column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByRef('fooValue'); // WHERE ref = 'fooValue'
|
||||
* $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $ref The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildProductSaleElementsQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByRef($ref = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($ref)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $ref)) {
|
||||
$ref = str_replace('*', '%', $ref);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(ProductSaleElementsTableMap::REF, $ref, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the quantity column
|
||||
*
|
||||
|
||||
@@ -66,10 +66,16 @@ abstract class Tax implements ActiveRecordInterface
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The value for the rate field.
|
||||
* @var double
|
||||
* The value for the type field.
|
||||
* @var string
|
||||
*/
|
||||
protected $rate;
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The value for the serialized_requirements field.
|
||||
* @var string
|
||||
*/
|
||||
protected $serialized_requirements;
|
||||
|
||||
/**
|
||||
* The value for the created_at field.
|
||||
@@ -395,14 +401,25 @@ abstract class Tax implements ActiveRecordInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [rate] column value.
|
||||
* Get the [type] column value.
|
||||
*
|
||||
* @return double
|
||||
* @return string
|
||||
*/
|
||||
public function getRate()
|
||||
public function getType()
|
||||
{
|
||||
|
||||
return $this->rate;
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [serialized_requirements] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSerializedRequirements()
|
||||
{
|
||||
|
||||
return $this->serialized_requirements;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,25 +484,46 @@ abstract class Tax implements ActiveRecordInterface
|
||||
} // setId()
|
||||
|
||||
/**
|
||||
* Set the value of [rate] column.
|
||||
* Set the value of [type] column.
|
||||
*
|
||||
* @param double $v new value
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Tax The current object (for fluent API support)
|
||||
*/
|
||||
public function setRate($v)
|
||||
public function setType($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (double) $v;
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->rate !== $v) {
|
||||
$this->rate = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::RATE;
|
||||
if ($this->type !== $v) {
|
||||
$this->type = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::TYPE;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setRate()
|
||||
} // setType()
|
||||
|
||||
/**
|
||||
* Set the value of [serialized_requirements] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return \Thelia\Model\Tax The current object (for fluent API support)
|
||||
*/
|
||||
public function setSerializedRequirements($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (string) $v;
|
||||
}
|
||||
|
||||
if ($this->serialized_requirements !== $v) {
|
||||
$this->serialized_requirements = $v;
|
||||
$this->modifiedColumns[] = TaxTableMap::SERIALIZED_REQUIREMENTS;
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
} // setSerializedRequirements()
|
||||
|
||||
/**
|
||||
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||
@@ -569,16 +607,19 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : TaxTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->id = (null !== $col) ? (int) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Rate', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->rate = (null !== $col) ? (double) $col : null;
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : TaxTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->type = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : TaxTableMap::translateFieldName('SerializedRequirements', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$this->serialized_requirements = (null !== $col) ? (string) $col : null;
|
||||
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : TaxTableMap::translateFieldName('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 ? 3 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : TaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||
if ($col === '0000-00-00 00:00:00') {
|
||||
$col = null;
|
||||
}
|
||||
@@ -591,7 +632,7 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 4; // 4 = TaxTableMap::NUM_HYDRATE_COLUMNS.
|
||||
return $startcol + 5; // 5 = TaxTableMap::NUM_HYDRATE_COLUMNS.
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating \Thelia\Model\Tax object", 0, $e);
|
||||
@@ -852,8 +893,11 @@ abstract class Tax implements ActiveRecordInterface
|
||||
if ($this->isColumnModified(TaxTableMap::ID)) {
|
||||
$modifiedColumns[':p' . $index++] = 'ID';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::RATE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'RATE';
|
||||
if ($this->isColumnModified(TaxTableMap::TYPE)) {
|
||||
$modifiedColumns[':p' . $index++] = 'TYPE';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) {
|
||||
$modifiedColumns[':p' . $index++] = 'SERIALIZED_REQUIREMENTS';
|
||||
}
|
||||
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) {
|
||||
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||
@@ -875,8 +919,11 @@ abstract class Tax implements ActiveRecordInterface
|
||||
case 'ID':
|
||||
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
|
||||
break;
|
||||
case 'RATE':
|
||||
$stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR);
|
||||
case 'TYPE':
|
||||
$stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
|
||||
break;
|
||||
case 'SERIALIZED_REQUIREMENTS':
|
||||
$stmt->bindValue($identifier, $this->serialized_requirements, 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);
|
||||
@@ -950,12 +997,15 @@ abstract class Tax implements ActiveRecordInterface
|
||||
return $this->getId();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getRate();
|
||||
return $this->getType();
|
||||
break;
|
||||
case 2:
|
||||
return $this->getCreatedAt();
|
||||
return $this->getSerializedRequirements();
|
||||
break;
|
||||
case 3:
|
||||
return $this->getCreatedAt();
|
||||
break;
|
||||
case 4:
|
||||
return $this->getUpdatedAt();
|
||||
break;
|
||||
default:
|
||||
@@ -988,9 +1038,10 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$keys = TaxTableMap::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getId(),
|
||||
$keys[1] => $this->getRate(),
|
||||
$keys[2] => $this->getCreatedAt(),
|
||||
$keys[3] => $this->getUpdatedAt(),
|
||||
$keys[1] => $this->getType(),
|
||||
$keys[2] => $this->getSerializedRequirements(),
|
||||
$keys[3] => $this->getCreatedAt(),
|
||||
$keys[4] => $this->getUpdatedAt(),
|
||||
);
|
||||
$virtualColumns = $this->virtualColumns;
|
||||
foreach($virtualColumns as $key => $virtualColumn)
|
||||
@@ -1043,12 +1094,15 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$this->setId($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setRate($value);
|
||||
$this->setType($value);
|
||||
break;
|
||||
case 2:
|
||||
$this->setCreatedAt($value);
|
||||
$this->setSerializedRequirements($value);
|
||||
break;
|
||||
case 3:
|
||||
$this->setCreatedAt($value);
|
||||
break;
|
||||
case 4:
|
||||
$this->setUpdatedAt($value);
|
||||
break;
|
||||
} // switch()
|
||||
@@ -1076,9 +1130,10 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$keys = TaxTableMap::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setType($arr[$keys[1]]);
|
||||
if (array_key_exists($keys[2], $arr)) $this->setSerializedRequirements($arr[$keys[2]]);
|
||||
if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]);
|
||||
if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1091,7 +1146,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
$criteria = new Criteria(TaxTableMap::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(TaxTableMap::ID)) $criteria->add(TaxTableMap::ID, $this->id);
|
||||
if ($this->isColumnModified(TaxTableMap::RATE)) $criteria->add(TaxTableMap::RATE, $this->rate);
|
||||
if ($this->isColumnModified(TaxTableMap::TYPE)) $criteria->add(TaxTableMap::TYPE, $this->type);
|
||||
if ($this->isColumnModified(TaxTableMap::SERIALIZED_REQUIREMENTS)) $criteria->add(TaxTableMap::SERIALIZED_REQUIREMENTS, $this->serialized_requirements);
|
||||
if ($this->isColumnModified(TaxTableMap::CREATED_AT)) $criteria->add(TaxTableMap::CREATED_AT, $this->created_at);
|
||||
if ($this->isColumnModified(TaxTableMap::UPDATED_AT)) $criteria->add(TaxTableMap::UPDATED_AT, $this->updated_at);
|
||||
|
||||
@@ -1157,7 +1213,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
|
||||
{
|
||||
$copyObj->setRate($this->getRate());
|
||||
$copyObj->setType($this->getType());
|
||||
$copyObj->setSerializedRequirements($this->getSerializedRequirements());
|
||||
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||
|
||||
@@ -1729,7 +1786,8 @@ abstract class Tax implements ActiveRecordInterface
|
||||
public function clear()
|
||||
{
|
||||
$this->id = null;
|
||||
$this->rate = null;
|
||||
$this->type = null;
|
||||
$this->serialized_requirements = null;
|
||||
$this->created_at = null;
|
||||
$this->updated_at = null;
|
||||
$this->alreadyInSave = false;
|
||||
|
||||
@@ -23,12 +23,14 @@ use Thelia\Model\Map\TaxTableMap;
|
||||
*
|
||||
*
|
||||
* @method ChildTaxQuery orderById($order = Criteria::ASC) Order by the id column
|
||||
* @method ChildTaxQuery orderByRate($order = Criteria::ASC) Order by the rate column
|
||||
* @method ChildTaxQuery orderByType($order = Criteria::ASC) Order by the type column
|
||||
* @method ChildTaxQuery orderBySerializedRequirements($order = Criteria::ASC) Order by the serialized_requirements column
|
||||
* @method ChildTaxQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||
* @method ChildTaxQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||
*
|
||||
* @method ChildTaxQuery groupById() Group by the id column
|
||||
* @method ChildTaxQuery groupByRate() Group by the rate column
|
||||
* @method ChildTaxQuery groupByType() Group by the type column
|
||||
* @method ChildTaxQuery groupBySerializedRequirements() Group by the serialized_requirements column
|
||||
* @method ChildTaxQuery groupByCreatedAt() Group by the created_at column
|
||||
* @method ChildTaxQuery groupByUpdatedAt() Group by the updated_at column
|
||||
*
|
||||
@@ -48,12 +50,14 @@ use Thelia\Model\Map\TaxTableMap;
|
||||
* @method ChildTax findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTax matching the query, or a new ChildTax object populated from the query conditions when no match is found
|
||||
*
|
||||
* @method ChildTax findOneById(int $id) Return the first ChildTax filtered by the id column
|
||||
* @method ChildTax findOneByRate(double $rate) Return the first ChildTax filtered by the rate column
|
||||
* @method ChildTax findOneByType(string $type) Return the first ChildTax filtered by the type column
|
||||
* @method ChildTax findOneBySerializedRequirements(string $serialized_requirements) Return the first ChildTax filtered by the serialized_requirements column
|
||||
* @method ChildTax findOneByCreatedAt(string $created_at) Return the first ChildTax filtered by the created_at column
|
||||
* @method ChildTax findOneByUpdatedAt(string $updated_at) Return the first ChildTax filtered by the updated_at column
|
||||
*
|
||||
* @method array findById(int $id) Return ChildTax objects filtered by the id column
|
||||
* @method array findByRate(double $rate) Return ChildTax objects filtered by the rate column
|
||||
* @method array findByType(string $type) Return ChildTax objects filtered by the type column
|
||||
* @method array findBySerializedRequirements(string $serialized_requirements) Return ChildTax objects filtered by the serialized_requirements column
|
||||
* @method array findByCreatedAt(string $created_at) Return ChildTax objects filtered by the created_at column
|
||||
* @method array findByUpdatedAt(string $updated_at) Return ChildTax objects filtered by the updated_at column
|
||||
*
|
||||
@@ -144,7 +148,7 @@ abstract class TaxQuery extends ModelCriteria
|
||||
*/
|
||||
protected function findPkSimple($key, $con)
|
||||
{
|
||||
$sql = 'SELECT ID, RATE, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
|
||||
$sql = 'SELECT ID, TYPE, SERIALIZED_REQUIREMENTS, CREATED_AT, UPDATED_AT FROM tax WHERE ID = :p0';
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||
@@ -275,44 +279,61 @@ abstract class TaxQuery extends ModelCriteria
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the rate column
|
||||
* Filter the query on the type column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterByRate(1234); // WHERE rate = 1234
|
||||
* $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34)
|
||||
* $query->filterByRate(array('min' => 12)); // WHERE rate > 12
|
||||
* $query->filterByType('fooValue'); // WHERE type = 'fooValue'
|
||||
* $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $rate 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 $type The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildTaxQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByRate($rate = null, $comparison = null)
|
||||
public function filterByType($type = null, $comparison = null)
|
||||
{
|
||||
if (is_array($rate)) {
|
||||
$useMinMax = false;
|
||||
if (isset($rate['min'])) {
|
||||
$this->addUsingAlias(TaxTableMap::RATE, $rate['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($rate['max'])) {
|
||||
$this->addUsingAlias(TaxTableMap::RATE, $rate['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
if (null === $comparison) {
|
||||
if (is_array($type)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $type)) {
|
||||
$type = str_replace('*', '%', $type);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(TaxTableMap::RATE, $rate, $comparison);
|
||||
return $this->addUsingAlias(TaxTableMap::TYPE, $type, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the serialized_requirements column
|
||||
*
|
||||
* Example usage:
|
||||
* <code>
|
||||
* $query->filterBySerializedRequirements('fooValue'); // WHERE serialized_requirements = 'fooValue'
|
||||
* $query->filterBySerializedRequirements('%fooValue%'); // WHERE serialized_requirements LIKE '%fooValue%'
|
||||
* </code>
|
||||
*
|
||||
* @param string $serializedRequirements The value to use as filter.
|
||||
* Accepts wildcards (* and % trigger a LIKE)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return ChildTaxQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterBySerializedRequirements($serializedRequirements = null, $comparison = null)
|
||||
{
|
||||
if (null === $comparison) {
|
||||
if (is_array($serializedRequirements)) {
|
||||
$comparison = Criteria::IN;
|
||||
} elseif (preg_match('/[\%\*]/', $serializedRequirements)) {
|
||||
$serializedRequirements = str_replace('*', '%', $serializedRequirements);
|
||||
$comparison = Criteria::LIKE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->addUsingAlias(TaxTableMap::SERIALIZED_REQUIREMENTS, $serializedRequirements, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,24 +49,25 @@ class Coupon extends BaseCoupon
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Create or Update this Coupon
|
||||
*
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $effect Coupon effect
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
* @param \DateTime $expirationDate Coupon expiration date
|
||||
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
|
||||
* @param boolean $isCumulative Is cumulative
|
||||
* @param boolean $isRemovingPostage Is removing Postage
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param CouponRuleCollection $rules CouponRuleInterface to add
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $effect Coupon effect
|
||||
* @param bool $isRemovingPostage Is removing Postage
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
* @param \DateTime $expirationDate Coupon expiration date
|
||||
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
|
||||
* @param boolean $isCumulative Is cumulative
|
||||
* @param int $maxUsage Coupon quantity
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
function createOrUpdate($code, $title, $amount, $effect, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $rules, $locale = null)
|
||||
function createOrUpdate($code, $title, $amount, $effect, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null)
|
||||
{
|
||||
$this->setCode($code)
|
||||
->setTitle($title)
|
||||
@@ -74,13 +75,13 @@ class Coupon extends BaseCoupon
|
||||
->setDescription($description)
|
||||
->setType($effect)
|
||||
->setAmount($amount)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setType($amount)
|
||||
->setIsEnabled($isEnabled)
|
||||
->setExpirationDate($expirationDate)
|
||||
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
|
||||
->setIsCumulative($isCumulative)
|
||||
->setMaxUsage($maxUsage)
|
||||
->setRules($rules);
|
||||
->setMaxUsage($maxUsage);
|
||||
|
||||
// Set object language (i18n)
|
||||
if (!is_null($locale)) {
|
||||
@@ -99,33 +100,34 @@ class Coupon extends BaseCoupon
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Set the value of [serialized_rules] column.
|
||||
// * Convert a CouponRuleCollection into a serialized array of SerializableRule
|
||||
// *
|
||||
// * @param CouponRuleCollection $rules A set of Rules
|
||||
// *
|
||||
// * @return \Thelia\Model\Coupon The current object (for fluent API support)
|
||||
// */
|
||||
// public function setRules(CouponRuleCollection $rules)
|
||||
// {
|
||||
// $serializedRules = null;
|
||||
// if ($rules !== null) {
|
||||
// /** @var $rule CouponRuleInterface */
|
||||
// foreach ($rules->getRules() as $rule) {
|
||||
// $serializedRules[] = $rule->getSerializableRule();
|
||||
// }
|
||||
//
|
||||
// $serializedRules = (string) base64_encode(serialize($serializedRules));
|
||||
// }
|
||||
//
|
||||
// if ($this->serialized_rules !== $serializedRules) {
|
||||
// $this->serialized_rules = $serializedRules;
|
||||
// $this->modifiedColumns[] = CouponTableMap::SERIALIZED_RULES;
|
||||
// }
|
||||
//
|
||||
// return $this;
|
||||
// }
|
||||
/**
|
||||
* Create or Update this coupon rule
|
||||
*
|
||||
* @param string $serializableRules Serialized rules ready to be saved
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
function createOrUpdateRules($serializableRules, $locale)
|
||||
{
|
||||
$this->setSerializedRules($serializableRules);
|
||||
|
||||
// Set object language (i18n)
|
||||
if (!is_null($locale)) {
|
||||
$this->setLocale($locale);
|
||||
}
|
||||
|
||||
$con = Propel::getWriteConnection(CouponTableMap::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
try {
|
||||
$this->save($con);
|
||||
$con->commit();
|
||||
|
||||
} catch(\Exception $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 8;
|
||||
const NUM_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 8;
|
||||
const NUM_HYDRATE_COLUMNS = 9;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -79,6 +79,11 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
*/
|
||||
const PRODUCT_ID = 'product_sale_elements.PRODUCT_ID';
|
||||
|
||||
/**
|
||||
* the column name for the REF field
|
||||
*/
|
||||
const REF = 'product_sale_elements.REF';
|
||||
|
||||
/**
|
||||
* the column name for the QUANTITY field
|
||||
*/
|
||||
@@ -121,12 +126,12 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'ProductId', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'product_id', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -136,12 +141,12 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Quantity' => 2, 'Promo' => 3, 'Newness' => 4, 'Weight' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
|
||||
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::QUANTITY => 2, ProductSaleElementsTableMap::PROMO => 3, ProductSaleElementsTableMap::NEWNESS => 4, ProductSaleElementsTableMap::WEIGHT => 5, ProductSaleElementsTableMap::CREATED_AT => 6, ProductSaleElementsTableMap::UPDATED_AT => 7, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'QUANTITY' => 2, 'PROMO' => 3, 'NEWNESS' => 4, 'WEIGHT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'quantity' => 2, 'promo' => 3, 'newness' => 4, 'weight' => 5, 'created_at' => 6, 'updated_at' => 7, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ),
|
||||
self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 8, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'created_at' => 7, 'updated_at' => 8, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -162,6 +167,7 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null);
|
||||
$this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null);
|
||||
$this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null);
|
||||
$this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0);
|
||||
$this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0);
|
||||
@@ -343,6 +349,7 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::ID);
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::PRODUCT_ID);
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::REF);
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::QUANTITY);
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO);
|
||||
$criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS);
|
||||
@@ -352,6 +359,7 @@ class ProductSaleElementsTableMap extends TableMap
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.PRODUCT_ID');
|
||||
$criteria->addSelectColumn($alias . '.REF');
|
||||
$criteria->addSelectColumn($alias . '.QUANTITY');
|
||||
$criteria->addSelectColumn($alias . '.PROMO');
|
||||
$criteria->addSelectColumn($alias . '.NEWNESS');
|
||||
|
||||
@@ -57,7 +57,7 @@ class TaxTableMap extends TableMap
|
||||
/**
|
||||
* The total number of columns
|
||||
*/
|
||||
const NUM_COLUMNS = 4;
|
||||
const NUM_COLUMNS = 5;
|
||||
|
||||
/**
|
||||
* The number of lazy-loaded columns
|
||||
@@ -67,7 +67,7 @@ class TaxTableMap extends TableMap
|
||||
/**
|
||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||
*/
|
||||
const NUM_HYDRATE_COLUMNS = 4;
|
||||
const NUM_HYDRATE_COLUMNS = 5;
|
||||
|
||||
/**
|
||||
* the column name for the ID field
|
||||
@@ -75,9 +75,14 @@ class TaxTableMap extends TableMap
|
||||
const ID = 'tax.ID';
|
||||
|
||||
/**
|
||||
* the column name for the RATE field
|
||||
* the column name for the TYPE field
|
||||
*/
|
||||
const RATE = 'tax.RATE';
|
||||
const TYPE = 'tax.TYPE';
|
||||
|
||||
/**
|
||||
* the column name for the SERIALIZED_REQUIREMENTS field
|
||||
*/
|
||||
const SERIALIZED_REQUIREMENTS = 'tax.SERIALIZED_REQUIREMENTS';
|
||||
|
||||
/**
|
||||
* the column name for the CREATED_AT field
|
||||
@@ -110,12 +115,12 @@ class TaxTableMap extends TableMap
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
protected static $fieldNames = array (
|
||||
self::TYPE_PHPNAME => array('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'rate', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::RATE, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'rate', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
self::TYPE_PHPNAME => array('Id', 'Type', 'SerializedRequirements', 'CreatedAt', 'UpdatedAt', ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id', 'type', 'serializedRequirements', 'createdAt', 'updatedAt', ),
|
||||
self::TYPE_COLNAME => array(TaxTableMap::ID, TaxTableMap::TYPE, TaxTableMap::SERIALIZED_REQUIREMENTS, TaxTableMap::CREATED_AT, TaxTableMap::UPDATED_AT, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID', 'TYPE', 'SERIALIZED_REQUIREMENTS', 'CREATED_AT', 'UPDATED_AT', ),
|
||||
self::TYPE_FIELDNAME => array('id', 'type', 'serialized_requirements', 'created_at', 'updated_at', ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -125,12 +130,12 @@ class TaxTableMap extends TableMap
|
||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
protected static $fieldKeys = array (
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ),
|
||||
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::RATE => 1, TaxTableMap::CREATED_AT => 2, TaxTableMap::UPDATED_AT => 3, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
||||
self::TYPE_PHPNAME => array('Id' => 0, 'Type' => 1, 'SerializedRequirements' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ),
|
||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'type' => 1, 'serializedRequirements' => 2, 'createdAt' => 3, 'updatedAt' => 4, ),
|
||||
self::TYPE_COLNAME => array(TaxTableMap::ID => 0, TaxTableMap::TYPE => 1, TaxTableMap::SERIALIZED_REQUIREMENTS => 2, TaxTableMap::CREATED_AT => 3, TaxTableMap::UPDATED_AT => 4, ),
|
||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'TYPE' => 1, 'SERIALIZED_REQUIREMENTS' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ),
|
||||
self::TYPE_FIELDNAME => array('id' => 0, 'type' => 1, 'serialized_requirements' => 2, 'created_at' => 3, 'updated_at' => 4, ),
|
||||
self::TYPE_NUM => array(0, 1, 2, 3, 4, )
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -150,7 +155,8 @@ class TaxTableMap extends TableMap
|
||||
$this->setUseIdGenerator(true);
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('RATE', 'Rate', 'FLOAT', true, null, null);
|
||||
$this->addColumn('TYPE', 'Type', 'VARCHAR', true, 255, null);
|
||||
$this->addColumn('SERIALIZED_REQUIREMENTS', 'SerializedRequirements', 'LONGVARCHAR', true, null, null);
|
||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||
} // initialize()
|
||||
@@ -327,12 +333,14 @@ class TaxTableMap extends TableMap
|
||||
{
|
||||
if (null === $alias) {
|
||||
$criteria->addSelectColumn(TaxTableMap::ID);
|
||||
$criteria->addSelectColumn(TaxTableMap::RATE);
|
||||
$criteria->addSelectColumn(TaxTableMap::TYPE);
|
||||
$criteria->addSelectColumn(TaxTableMap::SERIALIZED_REQUIREMENTS);
|
||||
$criteria->addSelectColumn(TaxTableMap::CREATED_AT);
|
||||
$criteria->addSelectColumn(TaxTableMap::UPDATED_AT);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.RATE');
|
||||
$criteria->addSelectColumn($alias . '.TYPE');
|
||||
$criteria->addSelectColumn($alias . '.SERIALIZED_REQUIREMENTS');
|
||||
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Thelia\Model;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Base\Tax as BaseTax;
|
||||
use Thelia\TaxEngine\TaxType\BaseTaxType;
|
||||
|
||||
class Tax extends BaseTax
|
||||
{
|
||||
@@ -33,14 +34,37 @@ class Tax extends BaseTax
|
||||
return $taxRuleCountryPosition;
|
||||
}
|
||||
|
||||
public function getTaxRuleRateSum()
|
||||
public function getTypeInstance()
|
||||
{
|
||||
try {
|
||||
$taxRuleRateSum = $this->getVirtualColumn(TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM);
|
||||
} catch(PropelException $e) {
|
||||
throw new PropelException("Virtual column `" . TaxRuleQuery::ALIAS_FOR_TAX_RATE_SUM . "` does not exist in Tax::getTaxRuleRateSum");
|
||||
$class = '\\Thelia\\TaxEngine\\TaxType\\' . $this->getType();
|
||||
|
||||
/* test type */
|
||||
if(!class_exists($class)) {
|
||||
throw new TaxEngineException('Recorded type `' . $class . '` does not exists', TaxEngineException::BAD_RECORDED_TYPE);
|
||||
}
|
||||
|
||||
return $taxRuleRateSum;
|
||||
$instance = new $class;
|
||||
|
||||
if(!$instance instanceof BaseTaxType) {
|
||||
throw new TaxEngineException('Recorded type `' . $class . '` does not extends BaseTaxType', TaxEngineException::BAD_RECORDED_TYPE);
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function setRequirements($requirements)
|
||||
{
|
||||
return parent::setSerializedRequirements(base64_encode(json_encode($requirements)));
|
||||
}
|
||||
|
||||
public function getRequirements()
|
||||
{
|
||||
$requirements = json_decode(base64_decode(parent::getSerializedRequirements()), true);
|
||||
|
||||
if(json_last_error() != JSON_ERROR_NONE || !is_array($requirements)) {
|
||||
throw new TaxEngineException('BAD RECORDED REQUIREMENTS', TaxEngineException::BAD_RECORDED_REQUIREMENTS);
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,21 +20,18 @@ use Thelia\Model\Map\TaxTableMap;
|
||||
class TaxRuleQuery extends BaseTaxRuleQuery
|
||||
{
|
||||
const ALIAS_FOR_TAX_RULE_COUNTRY_POSITION = 'taxRuleCountryPosition';
|
||||
const ALIAS_FOR_TAX_RATE_SUM = 'taxRateSum';
|
||||
|
||||
public function getTaxCalculatorGroupedCollection(Product $product, Country $country)
|
||||
public function getTaxCalculatorCollection(Product $product, Country $country)
|
||||
{
|
||||
$search = TaxQuery::create()
|
||||
->filterByTaxRuleCountry(
|
||||
TaxRuleCountryQuery::create()
|
||||
->filterByCountry($country, Criteria::EQUAL)
|
||||
->filterByTaxRuleId($product->getTaxRuleId())
|
||||
->groupByPosition()
|
||||
->orderByPosition()
|
||||
->find()
|
||||
)
|
||||
->withColumn(TaxRuleCountryTableMap::POSITION, self::ALIAS_FOR_TAX_RULE_COUNTRY_POSITION)
|
||||
->withColumn('ROUND(SUM(' . TaxTableMap::RATE . '), 2)', self::ALIAS_FOR_TAX_RATE_SUM)
|
||||
;
|
||||
|
||||
return $search->find();
|
||||
|
||||
@@ -34,9 +34,15 @@ use Thelia\Model\TaxRuleQuery;
|
||||
*/
|
||||
class Calculator
|
||||
{
|
||||
/**
|
||||
* @var TaxRuleQuery
|
||||
*/
|
||||
protected $taxRuleQuery = null;
|
||||
|
||||
protected $taxRulesGroupedCollection = null;
|
||||
/**
|
||||
* @var null|\Propel\Runtime\Collection\ObjectCollection
|
||||
*/
|
||||
protected $taxRulesCollection = null;
|
||||
|
||||
protected $product = null;
|
||||
protected $country = null;
|
||||
@@ -50,7 +56,7 @@ class Calculator
|
||||
{
|
||||
$this->product = null;
|
||||
$this->country = null;
|
||||
$this->taxRulesGroupedCollection = null;
|
||||
$this->taxRulesCollection = null;
|
||||
|
||||
if($product->getId() === null) {
|
||||
throw new TaxEngineException('Product id is empty in Calculator::load', TaxEngineException::UNDEFINED_PRODUCT);
|
||||
@@ -62,34 +68,47 @@ class Calculator
|
||||
$this->product = $product;
|
||||
$this->country = $country;
|
||||
|
||||
$this->taxRulesGroupedCollection = $this->taxRuleQuery->getTaxCalculatorGroupedCollection($product, $country);
|
||||
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($product, $country);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxAmount($amount)
|
||||
public function getTaxAmount($untaxedPrice)
|
||||
{
|
||||
if(null === $this->taxRulesGroupedCollection) {
|
||||
return $this->getTaxedPrice($untaxedPrice) - $untaxedPrice;
|
||||
}
|
||||
|
||||
public function getTaxedPrice($untaxedPrice)
|
||||
{
|
||||
if(null === $this->taxRulesCollection) {
|
||||
throw new TaxEngineException('Tax rules collection is empty in Calculator::getTaxAmount', TaxEngineException::UNDEFINED_TAX_RULES_COLLECTION);
|
||||
}
|
||||
|
||||
if(false === filter_var($amount, FILTER_VALIDATE_FLOAT)) {
|
||||
if(false === filter_var($untaxedPrice, FILTER_VALIDATE_FLOAT)) {
|
||||
throw new TaxEngineException('BAD AMOUNT FORMAT', TaxEngineException::BAD_AMOUNT_FORMAT);
|
||||
}
|
||||
|
||||
$totalTaxAmount = 0;
|
||||
foreach($this->taxRulesGroupedCollection as $taxRule) {
|
||||
$rateSum = $taxRule->getTaxRuleRateSum();
|
||||
$taxAmount = $amount * $rateSum * 0.01;
|
||||
$totalTaxAmount += $taxAmount;
|
||||
$amount += $taxAmount;
|
||||
$taxedPrice = $untaxedPrice;
|
||||
$currentPosition = 1;
|
||||
$currentTax = 0;
|
||||
|
||||
foreach($this->taxRulesCollection as $taxRule) {
|
||||
$position = (int)$taxRule->getTaxRuleCountryPosition();
|
||||
|
||||
$taxType = $taxRule->getTypeInstance();
|
||||
$taxType->loadRequirements( $taxRule->getRequirements() );
|
||||
|
||||
if($currentPosition !== $position) {
|
||||
$taxedPrice += $currentTax;
|
||||
$currentTax = 0;
|
||||
$currentPosition = $position;
|
||||
}
|
||||
|
||||
$currentTax += $taxType->calculate($taxedPrice);
|
||||
}
|
||||
|
||||
return $totalTaxAmount;
|
||||
}
|
||||
$taxedPrice += $currentTax;
|
||||
|
||||
public function getTaxedPrice($amount)
|
||||
{
|
||||
return $amount + $this->getTaxAmount($amount);
|
||||
return $taxedPrice;
|
||||
}
|
||||
}
|
||||
|
||||
78
core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php
Executable file
78
core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Type\TypeInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class BaseTaxType
|
||||
{
|
||||
protected $requirements = null;
|
||||
|
||||
public abstract function calculate($untaxedPrice);
|
||||
|
||||
public abstract function getRequirementsList();
|
||||
|
||||
public function loadRequirements($requirementsValues)
|
||||
{
|
||||
$this->requirements = $this->getRequirementsList();
|
||||
|
||||
if(!is_array($this->requirements)) {
|
||||
throw new TaxEngineException('getRequirementsList must return an array', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD);
|
||||
}
|
||||
|
||||
foreach($this->requirements as $requirement => $requirementType) {
|
||||
if(!$requirementType instanceof TypeInterface) {
|
||||
throw new TaxEngineException('getRequirementsList must return an array of TypeInterface', TaxEngineException::TAX_TYPE_BAD_ABSTRACT_METHOD);
|
||||
}
|
||||
|
||||
if(!array_key_exists($requirement, $requirementsValues)) {
|
||||
throw new TaxEngineException('Cannot load requirements : requirement value for `' . $requirement . '` not found', TaxEngineException::TAX_TYPE_REQUIREMENT_NOT_FOUND);
|
||||
}
|
||||
|
||||
if(!$requirementType->isValid($requirementsValues[$requirement])) {
|
||||
throw new TaxEngineException('Requirement value for `' . $requirement . '` does not match required type', TaxEngineException::TAX_TYPE_BAD_REQUIREMENT_VALUE);
|
||||
}
|
||||
|
||||
$this->requirements[$requirement] = $requirementsValues[$requirement];
|
||||
}
|
||||
}
|
||||
|
||||
public function getRequirement($key)
|
||||
{
|
||||
if($this->requirements === null) {
|
||||
throw new TaxEngineException('Requirements are empty in BaseTaxType::getRequirement', TaxEngineException::UNDEFINED_REQUIREMENTS);
|
||||
}
|
||||
|
||||
if(!array_key_exists($key, $this->requirements)) {
|
||||
throw new TaxEngineException('Requirement value for `' . $key . '` does not exists in BaseTaxType::$requirements', TaxEngineException::UNDEFINED_REQUIREMENT_VALUE);
|
||||
}
|
||||
|
||||
return $this->requirements[$key];
|
||||
}
|
||||
}
|
||||
47
core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php
Executable file
47
core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Type\FloatToFloatArrayType;
|
||||
use Thelia\Type\ModelType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class featureSlicePercentTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getRequirementsList()
|
||||
{
|
||||
return array(
|
||||
'featureId' => new ModelType('Currency'),
|
||||
'slices' => new FloatToFloatArrayType(),
|
||||
);
|
||||
}
|
||||
}
|
||||
45
core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php
Executable file
45
core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Type\FloatType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class FixAmountTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
return $this->getRequirement("amount");
|
||||
}
|
||||
|
||||
public function getRequirementsList()
|
||||
{
|
||||
return array(
|
||||
'amount' => new FloatType(),
|
||||
);
|
||||
}
|
||||
}
|
||||
45
core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php
Executable file
45
core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\TaxEngine\TaxType;
|
||||
|
||||
use Thelia\Type\FloatType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class PricePercentTaxType extends BaseTaxType
|
||||
{
|
||||
public function calculate($untaxedPrice)
|
||||
{
|
||||
return $untaxedPrice * $this->getRequirement("percent") * 0.01;
|
||||
}
|
||||
|
||||
public function getRequirementsList()
|
||||
{
|
||||
return array(
|
||||
'percent' => new FloatType(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Thelia\Core\HttpFoundation\Session\Session;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -82,9 +83,32 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->securityContext = new SecurityContext($this->request);*/
|
||||
|
||||
$stubRouterAdmin = $this->getMockBuilder('\Symfony\Component\Routing\Router')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getContext'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext = $this->getMockBuilder('\Symfony\Component\Routing\RequestContext')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getHost'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext->expects($this->any())
|
||||
->method('getHost')
|
||||
->will($this->returnValue('localhost'));
|
||||
|
||||
$stubRouterAdmin->expects($this->any())
|
||||
->method('getContext')
|
||||
->will($this->returnValue(
|
||||
$stubRequestContext
|
||||
));
|
||||
|
||||
|
||||
$this->container->set('request', $request);
|
||||
$this->container->set('event_dispatcher', new EventDispatcher());
|
||||
$this->container->set('thelia.securityContext', new SecurityContext($request));
|
||||
$this->container->set('router.admin', $stubRouterAdmin);
|
||||
$this->container->set('thelia.url.manager', new URL($this->container));
|
||||
|
||||
$this->instance = $this->getTestedInstance();
|
||||
$this->instance->initializeArgs($this->getMandatoryArguments());
|
||||
@@ -107,4 +131,42 @@ abstract class BaseLoopTestor extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertInstanceOf('\Thelia\Core\Template\Element\LoopResult', $methodReturn);
|
||||
}
|
||||
|
||||
public function baseTestSearchById($id)
|
||||
{
|
||||
$this->instance->initializeArgs(array_merge(
|
||||
$this->getMandatoryArguments(),
|
||||
array(
|
||||
"type" => "foo",
|
||||
"name" => "foo",
|
||||
"id" => $id,
|
||||
)
|
||||
));
|
||||
|
||||
$dummy = null;
|
||||
$loopResults = $this->instance->exec($dummy);
|
||||
|
||||
$this->assertEquals(1, $loopResults->getCount());
|
||||
|
||||
$substitutions = $loopResults->current()->getVarVal();
|
||||
|
||||
$this->assertEquals($id, $substitutions['ID']);
|
||||
}
|
||||
|
||||
public function baseTestSearchWithLimit($limit)
|
||||
{
|
||||
$this->instance->initializeArgs(array_merge(
|
||||
$this->getMandatoryArguments(),
|
||||
array(
|
||||
"type" => "foo",
|
||||
"name" => "foo",
|
||||
"limit" => $limit,
|
||||
)
|
||||
));
|
||||
|
||||
$dummy = null;
|
||||
$loopResults = $this->instance->exec($dummy);
|
||||
|
||||
$this->assertEquals($limit, $loopResults->getCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Category;
|
||||
@@ -48,4 +49,16 @@ class CategoryTest extends BaseLoopTestor
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$category = CategoryQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($category->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Content;
|
||||
@@ -48,4 +49,16 @@ class ContentTest extends BaseLoopTestor
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$content = ContentQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($content->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Folder;
|
||||
@@ -48,4 +49,16 @@ class FolderTest extends BaseLoopTestor
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$folder = FolderQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($folder->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Core\Template\Loop;
|
||||
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Tests\Core\Template\Element\BaseLoopTestor;
|
||||
|
||||
use Thelia\Core\Template\Loop\Product;
|
||||
@@ -48,4 +49,16 @@ class ProductTest extends BaseLoopTestor
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function testSearchById()
|
||||
{
|
||||
$product = ProductQuery::create()->findOne();
|
||||
|
||||
$this->baseTestSearchById($product->getId());
|
||||
}
|
||||
|
||||
public function testSearchLimit()
|
||||
{
|
||||
$this->baseTestSearchWithLimit(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Tests\Rewriting;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Thelia\Model\RewritingUrl;
|
||||
use Thelia\Rewriting\RewritingRetriever;
|
||||
use Thelia\Tools\URL;
|
||||
@@ -34,6 +35,36 @@ use Thelia\Tools\URL;
|
||||
*/
|
||||
class RewritingRetrieverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $container = null;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->container = new ContainerBuilder();
|
||||
|
||||
$stubRouterAdmin = $this->getMockBuilder('\Symfony\Component\Routing\Router')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getContext'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext = $this->getMockBuilder('\Symfony\Component\Routing\RequestContext')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('getHost'))
|
||||
->getMock();
|
||||
|
||||
$stubRequestContext->expects($this->any())
|
||||
->method('getHost')
|
||||
->will($this->returnValue('localhost'));
|
||||
|
||||
$stubRouterAdmin->expects($this->any())
|
||||
->method('getContext')
|
||||
->will($this->returnValue(
|
||||
$stubRequestContext
|
||||
));
|
||||
|
||||
$this->container->set('router.admin', $stubRouterAdmin);
|
||||
$this->container->set('thelia.url.manager', new URL($this->container));
|
||||
}
|
||||
|
||||
protected function getMethod($name)
|
||||
{
|
||||
$class = new \ReflectionClass('\Thelia\Rewriting\RewritingRetriever');
|
||||
|
||||
@@ -83,9 +83,9 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorGroupedCollection'));
|
||||
$taxRuleQuery = $this->getMock('\Thelia\Model\TaxRuleQuery', array('getTaxCalculatorCollection'));
|
||||
$taxRuleQuery->expects($this->once())
|
||||
->method('getTaxCalculatorGroupedCollection')
|
||||
->method('getTaxCalculatorCollection')
|
||||
->with($productQuery, $countryQuery)
|
||||
->will($this->returnValue('foo'));
|
||||
|
||||
@@ -104,7 +104,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
$this->assertEquals(
|
||||
'foo',
|
||||
$this->getProperty('taxRulesGroupedCollection')->getValue($calculator)
|
||||
$this->getProperty('taxRulesCollection')->getValue($calculator)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,35 +124,40 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetTaxAmountBadAmount()
|
||||
{
|
||||
$taxRulesGroupedCollection = new ObjectCollection();
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesGroupedCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesGroupedCollection);
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$calculator->getTaxAmount('foo');
|
||||
}
|
||||
|
||||
public function testGetTaxAmountAndGetTaxedPrice()
|
||||
{
|
||||
$taxRulesGroupedCollection = new ObjectCollection();
|
||||
$taxRulesGroupedCollection->setModel('\Thelia\Model\Tax');
|
||||
/* consecutives taxes */
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$tax = new Tax();
|
||||
$tax->setVirtualColumn('taxRateSum', 10);
|
||||
$tax->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 10))
|
||||
->setVirtualColumn('taxRuleCountryPosition', 1);
|
||||
|
||||
$taxRulesGroupedCollection->append($tax);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$tax = new Tax();
|
||||
$tax->setVirtualColumn('taxRateSum', 8);
|
||||
$tax->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 8))
|
||||
->setVirtualColumn('taxRuleCountryPosition', 2);
|
||||
|
||||
$taxRulesGroupedCollection->append($tax);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesGroupedCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesGroupedCollection);
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmount(500);
|
||||
$taxedPrice = $calculator->getTaxedPrice(500);
|
||||
@@ -165,5 +170,40 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
$this->assertEquals(94, $taxAmount);
|
||||
$this->assertEquals(594, $taxedPrice);
|
||||
|
||||
/* same position taxes */
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$tax = new Tax();
|
||||
$tax->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 10))
|
||||
->setVirtualColumn('taxRuleCountryPosition', 1);
|
||||
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$tax = new Tax();
|
||||
$tax->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 8))
|
||||
->setVirtualColumn('taxRuleCountryPosition', 1);
|
||||
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmount(500);
|
||||
$taxedPrice = $calculator->getTaxedPrice(500);
|
||||
|
||||
/*
|
||||
* expect :
|
||||
* tax 1 = 500*0.10 = 50 // amout with tax 1 : 550
|
||||
* tax 2 = 500*0.08 = 40 // amout with tax 2 : 590
|
||||
* total tax amount = 90
|
||||
*/
|
||||
$this->assertEquals(90, $taxAmount);
|
||||
$this->assertEquals(590, $taxedPrice);
|
||||
}
|
||||
}
|
||||
|
||||
56
core/lib/Thelia/Type/FloatToFloatArrayType.php
Executable file
56
core/lib/Thelia/Type/FloatToFloatArrayType.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
|
||||
class FloatToFloatArrayType implements TypeInterface
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return 'Float key to float value array type';
|
||||
}
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
if(!is_array($value))
|
||||
return false;
|
||||
|
||||
foreach($value as $key => $value) {
|
||||
if( filter_var($key, FILTER_VALIDATE_FLOAT) === false || filter_var($value, FILTER_VALIDATE_FLOAT) === false ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFormattedValue($value)
|
||||
{
|
||||
return $this->isValid($value) ? $value : null;
|
||||
}
|
||||
}
|
||||
66
core/lib/Thelia/Type/ModelType.php
Executable file
66
core/lib/Thelia/Type/ModelType.php
Executable file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Type;
|
||||
|
||||
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
|
||||
use Thelia\Exception\TypeException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ModelType implements TypeInterface
|
||||
{
|
||||
protected $expectedModelActiveRecord = null;
|
||||
|
||||
/**
|
||||
* @param $expectedModelActiveRecord
|
||||
* @throws TypeException
|
||||
*/
|
||||
public function __construct($expectedModelActiveRecord)
|
||||
{
|
||||
$class = '\\Thelia\\Model\\' . $expectedModelActiveRecord;
|
||||
|
||||
if(!(class_exists($class) && new $class instanceof ActiveRecordInterface)) {
|
||||
throw new TypeException('MODEL NOT FOUND', TypeException::MODEL_NOT_FOUND);
|
||||
}
|
||||
|
||||
$this->expectedModelActiveRecord = $class;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'Model type';
|
||||
}
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
return $value instanceof $this->expectedModelActiveRecord;
|
||||
}
|
||||
|
||||
public function getFormattedValue($value)
|
||||
{
|
||||
return $this->isValid($value) ? $value : null;
|
||||
}
|
||||
}
|
||||
@@ -319,6 +319,7 @@ try {
|
||||
for($i=0; $i<rand(1,7); $i++) {
|
||||
$stock = new \Thelia\Model\ProductSaleElements();
|
||||
$stock->setProductId($productId);
|
||||
$stock->setRef($productId . '_' . $i . '_' . $faker->randomNumber(8));
|
||||
$stock->setQuantity($faker->randomNumber(1,50));
|
||||
$stock->setPromo($faker->randomNumber(0,1));
|
||||
$stock->setNewness($faker->randomNumber(0,1));
|
||||
|
||||
@@ -17,9 +17,10 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
|
||||
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
|
||||
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
|
||||
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
|
||||
('use_tax_free_amounts', '1', 0, 0, NOW(), NOW());
|
||||
('use_tax_free_amounts', 0, 1, 0, NOW(), NOW()),
|
||||
('process_assets', '1', 0, 0, NOW(), NOW());
|
||||
|
||||
|
||||
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
|
||||
(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW());
|
||||
|
||||
@@ -1112,9 +1113,9 @@ INSERT INTO `country_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `po
|
||||
(268, 'es_ES', 'USA - Alabama', '', '', ''),
|
||||
(268, 'fr_FR', 'USA - Alabama', '', '', '');
|
||||
|
||||
INSERT INTO `tax` (`id`, `rate`, `created_at`, `updated_at`)
|
||||
INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, '19.6', NOW(), NOW());
|
||||
(1, 'PricePercentTaxType', 'eyJwZXJjZW50IjoxOS42fQ==', NOW(), NOW());
|
||||
|
||||
INSERT INTO `tax_i18n` (`id`, `locale`, `title`)
|
||||
VALUES
|
||||
|
||||
116
install/tax_faker.php
Executable file
116
install/tax_faker.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
use Thelia\Constraint\ConstraintFactory;
|
||||
use Thelia\Constraint\ConstraintManager;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmount;
|
||||
use Thelia\Constraint\Rule\AvailableForTotalAmountManager;
|
||||
use Thelia\Constraint\Rule\AvailableForXArticlesManager;
|
||||
use Thelia\Constraint\Rule\Operators;
|
||||
use Thelia\Coupon\CouponRuleCollection;
|
||||
use Thelia\Model\ProductImage;
|
||||
use Thelia\Model\CategoryImage;
|
||||
use Thelia\Model\FolderImage;
|
||||
use Thelia\Model\ContentImage;
|
||||
use Imagine\Image\Color;
|
||||
use Imagine\Image\Point;
|
||||
|
||||
require __DIR__ . '/../core/bootstrap.php';
|
||||
|
||||
$thelia = new Thelia\Core\Thelia("dev", true);
|
||||
$thelia->boot();
|
||||
|
||||
$faker = Faker\Factory::create();
|
||||
|
||||
$con = \Propel\Runtime\Propel::getConnection(
|
||||
Thelia\Model\Map\ProductTableMap::DATABASE_NAME
|
||||
);
|
||||
$con->beginTransaction();
|
||||
|
||||
$currency = \Thelia\Model\CurrencyQuery::create()->filterByCode('EUR')->findOne();
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare("SET foreign_key_checks = 0");
|
||||
$stmt->execute();
|
||||
|
||||
\Thelia\Model\TaxQuery::create()
|
||||
->find()
|
||||
->delete();
|
||||
|
||||
\Thelia\Model\Base\TaxRuleQuery::create()
|
||||
->find()
|
||||
->delete();
|
||||
|
||||
\Thelia\Model\Base\TaxRuleCountryQuery::create()
|
||||
->find()
|
||||
->delete();
|
||||
|
||||
$stmt = $con->prepare("SET foreign_key_checks = 1");
|
||||
$stmt->execute();
|
||||
|
||||
/* 10% tax */
|
||||
$tax10p = new \Thelia\Model\Tax();
|
||||
$tax10p->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 10))
|
||||
->save();
|
||||
|
||||
/* 8% tax */
|
||||
$tax8p = new \Thelia\Model\Tax();
|
||||
$tax8p->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 8))
|
||||
->save();
|
||||
|
||||
/* fix 5 tax */
|
||||
$tax5 = new \Thelia\Model\Tax();
|
||||
$tax5->setType('FixAmountTaxType')
|
||||
->setRequirements(array('amount' => 5))
|
||||
->save();
|
||||
|
||||
/* 1% tax */
|
||||
$tax1p = new \Thelia\Model\Tax();
|
||||
$tax1p->setType('PricePercentTaxType')
|
||||
->setRequirements(array('percent' => 1))
|
||||
->save();
|
||||
|
||||
/* tax rule */
|
||||
$taxRule = new \Thelia\Model\TaxRule();
|
||||
$taxRule->save();
|
||||
|
||||
/* add 4 taxes to the rule for France (64) */
|
||||
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
|
||||
$taxRuleCountry->setTaxRule($taxRule)
|
||||
->setCountryId(64)
|
||||
->setTax($tax10p)
|
||||
->setPosition(1)
|
||||
->save();
|
||||
|
||||
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
|
||||
$taxRuleCountry->setTaxRule($taxRule)
|
||||
->setCountryId(64)
|
||||
->setTax($tax8p)
|
||||
->setPosition(1)
|
||||
->save();
|
||||
|
||||
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
|
||||
$taxRuleCountry->setTaxRule($taxRule)
|
||||
->setCountryId(64)
|
||||
->setTax($tax5)
|
||||
->setPosition(2)
|
||||
->save();
|
||||
|
||||
$taxRuleCountry = new \Thelia\Model\TaxRuleCountry();
|
||||
$taxRuleCountry->setTaxRule($taxRule)
|
||||
->setCountryId(64)
|
||||
->setTax($tax1p)
|
||||
->setPosition(3)
|
||||
->save();
|
||||
|
||||
foreach(\Thelia\Model\ProductQuery::create()->find() as $productActiveRecord) {
|
||||
$productActiveRecord->setTaxRule($taxRule)
|
||||
->save();
|
||||
}
|
||||
|
||||
$con->commit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "error : ".$e->getMessage()."\n";
|
||||
$con->rollBack();
|
||||
}
|
||||
@@ -111,7 +111,8 @@ DROP TABLE IF EXISTS `tax`;
|
||||
CREATE TABLE `tax`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`rate` FLOAT NOT NULL,
|
||||
`type` VARCHAR(255) NOT NULL,
|
||||
`serialized_requirements` TEXT NOT NULL,
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`)
|
||||
@@ -348,6 +349,7 @@ CREATE TABLE `product_sale_elements`
|
||||
(
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`product_id` INTEGER NOT NULL,
|
||||
`ref` VARCHAR(45) NOT NULL,
|
||||
`quantity` FLOAT NOT NULL,
|
||||
`promo` TINYINT DEFAULT 0,
|
||||
`newness` TINYINT DEFAULT 0,
|
||||
@@ -355,6 +357,7 @@ CREATE TABLE `product_sale_elements`
|
||||
`created_at` DATETIME,
|
||||
`updated_at` DATETIME,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `ref_UNIQUE` (`ref`),
|
||||
INDEX `idx_product_sale_element_product_id` (`product_id`),
|
||||
CONSTRAINT `fk_product_sale_element_product_id`
|
||||
FOREIGN KEY (`product_id`)
|
||||
|
||||
@@ -86,7 +86,8 @@
|
||||
</table>
|
||||
<table name="tax" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="rate" required="true" type="FLOAT" />
|
||||
<column name="type" required="true" size="255" type="VARCHAR" />
|
||||
<column name="serialized_requirements" required="true" type="LONGVARCHAR" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="LONGVARCHAR" />
|
||||
<behavior name="timestampable" />
|
||||
@@ -263,6 +264,7 @@
|
||||
<table name="product_sale_elements" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="product_id" required="true" type="INTEGER" />
|
||||
<column name="ref" required="true" size="45" type="VARCHAR" />
|
||||
<column name="quantity" required="true" type="FLOAT" />
|
||||
<column defaultValue="0" name="promo" type="TINYINT" />
|
||||
<column defaultValue="0" name="newness" type="TINYINT" />
|
||||
@@ -273,6 +275,9 @@
|
||||
<index name="idx_product_sale_element_product_id">
|
||||
<index-column name="product_id" />
|
||||
</index>
|
||||
<unique name="ref_UNIQUE">
|
||||
<unique-column name="ref" />
|
||||
</unique>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table isCrossRef="true" name="attribute_category" namespace="Thelia\Model">
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
<services>
|
||||
<service id="debugBar" class="DebugBar\StandardDebugBar"/>
|
||||
<service id="debugBar" class="DebugBar\DebugBar"/>
|
||||
|
||||
<service id="smarty.debugbar" class="DebugBar\Smarty\Plugin\DebugBar">
|
||||
<argument type="service" id="debugBar"/>
|
||||
|
||||
@@ -66,8 +66,8 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
return array(
|
||||
'nb_statements' => count($this->statements),
|
||||
'nb_failed_statements' => 0,
|
||||
'accumulated_duration' => '10',
|
||||
'accumulated_duration_str' => $this->formatDuration(1),
|
||||
'accumulated_duration' => $this->accumulatedTime,
|
||||
'accumulated_duration_str' => $this->formatDuration($this->accumulatedTime),
|
||||
'peak_memory_usage' => $this->peakMemory,
|
||||
'peak_memory_usage_str' => $this->formatBytes($this->peakMemory),
|
||||
'statements' => $this->statements
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar\Listeners;
|
||||
use DebugBar\DataCollector\MemoryCollector;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use DebugBar\DataCollector\PhpInfoCollector;
|
||||
use DebugBar\DataCollector\PropelCollector;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Thelia\Action\BaseAction;
|
||||
@@ -40,6 +44,12 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface {
|
||||
{
|
||||
$debugBar = $this->container->get("debugBar");
|
||||
|
||||
|
||||
$debugBar->addCollector(new PhpInfoCollector());
|
||||
//$debugBar->addCollector(new MessagesCollector());
|
||||
//$debugBar->addCollector(new RequestDataCollector());
|
||||
$debugBar->addCollector(new TimeDataCollector());
|
||||
$debugBar->addCollector(new MemoryCollector());
|
||||
$debugBar->addCollector(new PropelCollector());
|
||||
}
|
||||
|
||||
|
||||
@@ -104,23 +104,6 @@ class DebugBar extends AbstractSmartyPlugin
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderHead($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if ($this->debugMode) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assets = $javascriptRenderer->getAssets();
|
||||
|
||||
$cssCollection = $assets[0];
|
||||
$jsCollection = $assets[1];
|
||||
|
||||
$render .= sprintf('<style media="screen" type="text/css">%s</style>', $cssCollection->dump());
|
||||
$render .= sprintf('<script>%s</script>', $jsCollection->dump());
|
||||
}
|
||||
|
||||
return $render;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of SmartyPluginDescriptor
|
||||
*/
|
||||
|
||||
25
run_casperjs.sh
Executable file
25
run_casperjs.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# @author Guillaume MOREL
|
||||
|
||||
echo "Force dropping database. All data will be lost."
|
||||
|
||||
cd local/config/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n"
|
||||
../../bin/propel build -v --output-dir=../../core/lib/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n"
|
||||
../../bin/propel sql:build -v --output-dir=../../install/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Reloaded Thelia2 database\e[00m\n"
|
||||
cd ../..
|
||||
rm install/sqldb.map
|
||||
php Thelia thelia:dev:reloadDB
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Installing fixtures\e[00m\n"
|
||||
php install/faker.php
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Adding admin\e[00m\n"
|
||||
php Thelia thelia:create-admin --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2
|
||||
|
||||
casperjs test ./tests/functionnal/casperjs/exe --pre=./tests/functionnal/casperjs/conf/local.js --direct
|
||||
@@ -224,7 +224,7 @@
|
||||
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
|
||||
|
||||
{debugbar_renderjs}
|
||||
{debugbar_renderresult}
|
||||
|
||||
|
||||
{block name="after-javascript-include"}{/block}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 13 KiB |
BIN
templates/admin/default/assets/img/top-bar-logo-save.png
Normal file
BIN
templates/admin/default/assets/img/top-bar-logo-save.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 7.1 KiB |
148
templates/admin/default/assets/js/coupon.js
Normal file
148
templates/admin/default/assets/js/coupon.js
Normal file
@@ -0,0 +1,148 @@
|
||||
$(function($){
|
||||
|
||||
// Clean array from deleteValue (undefined) keys
|
||||
Array.prototype.clean = function(deleteValue) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (this[i] == deleteValue) {
|
||||
this.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
// Remove 1 Rule then Save Rules AJAX
|
||||
couponManager.removeRuleAjax = function(id) {
|
||||
// Delete rule in temporary array
|
||||
delete couponManager.rulesToSave[id];
|
||||
couponManager.rulesToSave.clean(undefined);
|
||||
|
||||
// Save
|
||||
couponManager.saveRuleAjax();
|
||||
};
|
||||
|
||||
// Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX
|
||||
couponManager.addRuleAjax = function(id) {
|
||||
console.log('addRuleAjax '+ id);
|
||||
// If create
|
||||
if(!id) {
|
||||
console.log('pushing');
|
||||
couponManager.rulesToSave.push(couponManager.ruleToSave);
|
||||
} else { // else update
|
||||
console.log('editing ' + id);
|
||||
couponManager.rulesToSave[id] = couponManager.ruleToSave;
|
||||
// reset edit mode to off
|
||||
couponManager.ruleIdToUpdate = false;
|
||||
}
|
||||
|
||||
// Save
|
||||
couponManager.saveRuleAjax();
|
||||
};
|
||||
|
||||
// Set rule inputs to allow editing
|
||||
couponManager.updateRuleAjax = function(id) {
|
||||
couponManager.ruleToUpdate = couponManager.rulesToSave[id];
|
||||
console.log('Set id to edit to ' + id);
|
||||
couponManager.ruleIdToUpdate = id;
|
||||
|
||||
// Deleting this rule, we will reset it
|
||||
delete couponManager.rulesToSave[id];
|
||||
|
||||
// Set the rule selector
|
||||
$("#category-rule option").filter(function() {
|
||||
return $(this).val() == couponManager.ruleToUpdate.serviceId;
|
||||
}).prop('selected', true);
|
||||
|
||||
// Force rule input refresh
|
||||
couponManager.loadRuleInputs(couponManager.ruleToUpdate.serviceId, function() {
|
||||
couponManager.fillInRuleInputs();
|
||||
});
|
||||
};
|
||||
|
||||
// Fill in rule inputs
|
||||
couponManager.fillInRuleInputs = function() {
|
||||
console.log('fillInRuleInputs with');
|
||||
console.log(couponManager.ruleToUpdate);
|
||||
var operatorId = null;
|
||||
var valueId = null;
|
||||
var idName = null;
|
||||
|
||||
for (idName in couponManager.ruleToUpdate.operators) {
|
||||
// Setting idName operator select
|
||||
operatorId = idName + '-operator';
|
||||
$('#' + operatorId).val(couponManager.ruleToUpdate.operators[idName]);
|
||||
|
||||
valueId = idName + '-value';
|
||||
// Setting idName value input
|
||||
$('#' + valueId).val(couponManager.ruleToUpdate.values[idName]);
|
||||
}
|
||||
couponManager.ruleToSave = couponManager.ruleToUpdate;
|
||||
|
||||
var id = couponManager.ruleIdToUpdate;
|
||||
console.log('id to edit = ' + id);
|
||||
if(id) {
|
||||
console.log('setint rulesToSave[' + id + ']');
|
||||
console.log(couponManager.ruleToSave);
|
||||
couponManager.rulesToSave[id] = couponManager.ruleToSave;
|
||||
}
|
||||
};
|
||||
|
||||
// Save rules on click
|
||||
couponManager.onClickSaveRule = function() {
|
||||
$('#constraint-save-btn').on('click', function () {
|
||||
couponManager.addRuleAjax(couponManager.ruleIdToUpdate);
|
||||
});
|
||||
};
|
||||
couponManager.onClickSaveRule();
|
||||
|
||||
// Remove rule on click
|
||||
couponManager.onClickDeleteRule = function() {
|
||||
$('.constraint-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
couponManager.removeRuleAjax($this.attr('data-int'));
|
||||
});
|
||||
};
|
||||
couponManager.onClickDeleteRule();
|
||||
|
||||
// Update rule on click
|
||||
couponManager.onClickUpdateRule = function() {
|
||||
$('.constraint-update-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
couponManager.updateRuleAjax($this.attr('data-int'));
|
||||
|
||||
// Hide row being updated
|
||||
$this.parent().parent().remove();
|
||||
});
|
||||
};
|
||||
couponManager.onClickUpdateRule();
|
||||
|
||||
// Reload effect inputs when changing effect
|
||||
couponManager.onEffectChange = function() {
|
||||
$('#effect').on('change', function () {
|
||||
var optionSelected = $("option:selected", this);
|
||||
$('#effectToolTip').html(optionSelected.attr("data-description"));
|
||||
});
|
||||
};
|
||||
couponManager.onEffectChange();
|
||||
|
||||
// Reload rule inputs when changing effect
|
||||
couponManager.onRuleChange = function() {
|
||||
$('#category-rule').on('change', function () {
|
||||
couponManager.loadRuleInputs($(this).val(), function(ruleToSave) {});
|
||||
});
|
||||
};
|
||||
couponManager.onRuleChange();
|
||||
|
||||
// Fill in ready to be saved rule array
|
||||
// var onInputsChange = function()
|
||||
// In AJAX response
|
||||
|
||||
});
|
||||
|
||||
// Rule to save
|
||||
|
||||
var couponManager = {};
|
||||
couponManager.ruleToSave = {};
|
||||
couponManager.ruleIdToUpdate = false;
|
||||
@@ -40,7 +40,7 @@
|
||||
line-height: @topBarHeight;
|
||||
height: @topBarHeight;
|
||||
background: url("@{imgDir}/top-bar-logo.png") left -3px no-repeat;
|
||||
padding-left: 100px;
|
||||
padding-left: 170px;
|
||||
text-shadow: 0px 1px 1px black;
|
||||
color: #6d737b;
|
||||
}
|
||||
@@ -261,6 +261,6 @@
|
||||
|
||||
.loading{
|
||||
background: url("@{imgDir}/ajax-loader.gif") no-repeat;
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}}}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} noRules=true}
|
||||
{/form}
|
||||
|
||||
</section> <!-- #wrapper -->
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
</div>
|
||||
|
||||
{form name="thelia.admin.coupon.creation"}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form}
|
||||
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noRules=false}
|
||||
{/form}
|
||||
|
||||
|
||||
</section> <!-- #wrapper -->
|
||||
{/block}
|
||||
|
||||
@@ -37,19 +38,19 @@
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
{javascripts file='assets/js/coupon.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
$(function($){
|
||||
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Init Rules
|
||||
var initRule = function() {
|
||||
couponManager.initRules = function() {
|
||||
var rules = [];
|
||||
{foreach from=$rulesObject key=k item=rule}
|
||||
// Init rule
|
||||
var rule = {};
|
||||
rule['serviceId'] = '{$rule.serviceId nofilter}';
|
||||
rule['operators'] = {};
|
||||
@@ -59,24 +60,24 @@
|
||||
rule['operators']['{$input nofilter}'] = '{$operator nofilter}';
|
||||
rule['values']['{$input nofilter}'] = '{$rule.validators.setValues[$input] nofilter}';
|
||||
{/foreach}
|
||||
|
||||
// Add rule
|
||||
rules.push(rule);
|
||||
{/foreach}
|
||||
|
||||
return rules;
|
||||
}
|
||||
};
|
||||
|
||||
// Save Rules AJAX
|
||||
var saveRuleAjax = function() {
|
||||
couponManager.saveRuleAjax = function() {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
console.log('about to save');
|
||||
console.log(couponManager.rulesToSave);
|
||||
var $url = '{$urlAjaxUpdateRules}';
|
||||
console.log('save');
|
||||
console.log('{$urlAjaxUpdateRules}');
|
||||
console.log(rules);
|
||||
console.log(JSON.stringify(rules));
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $url,
|
||||
{*data: {literal}{{/literal}rules:rules{literal}}{/literal},*}
|
||||
data: {literal}{{/literal}rules:JSON.stringify(rules){literal}}{/literal},
|
||||
data: {literal}{{/literal}rules:JSON.stringify(couponManager.rulesToSave){literal}}{/literal},
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
@@ -87,75 +88,34 @@
|
||||
}).done(function(data) {
|
||||
$('#constraint-list').html(data);
|
||||
$('#constraint-add-operators-values').html('');
|
||||
couponManager.onClickUpdateRule();
|
||||
couponManager.onClickDeleteRule();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Remove 1 Rule then Save Rules AJAX
|
||||
var removeRuleAjax = function($id) {
|
||||
rules.slice($id, 1);
|
||||
saveRuleAjax();
|
||||
}
|
||||
|
||||
// Add 1 Rule then Save Rules AJAX
|
||||
var addRuleAjax = function() {
|
||||
rules.push(ruleToSave);
|
||||
saveRuleAjax();
|
||||
}
|
||||
|
||||
|
||||
var rules = initRule();
|
||||
console.log(rules);
|
||||
|
||||
|
||||
// Save rules on click
|
||||
var onClickSaveRule = function() {
|
||||
$('#constraint-save-btn').on('click', function (e) {
|
||||
addRuleAjax();
|
||||
});
|
||||
}
|
||||
onClickSaveRule();
|
||||
|
||||
// Remove rule on click
|
||||
var onClickDeleteRule = function() {
|
||||
$('#constraint-delete-btn').on('click', function (e) {
|
||||
// removeRuleAjax();
|
||||
});
|
||||
}
|
||||
onClickDeleteRule();
|
||||
|
||||
// Reload effect inputs when changing effect
|
||||
var onEffectChange = function() {
|
||||
$('#effect').on('change', function (e) {
|
||||
var optionSelected = $("option:selected", this);
|
||||
$('#effectToolTip').html(optionSelected.attr("data-description"));
|
||||
});
|
||||
}
|
||||
onEffectChange();
|
||||
|
||||
// Reload rule inputs when changing effect
|
||||
var onRuleChange = function() {
|
||||
$('#category-rule').on('change', function (e) {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
var url = "{$urlAjaxGetRuleInput}";
|
||||
url = url.replace('ruleId', $(this).val())
|
||||
$.ajax({
|
||||
url: url,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
'{intl l='Please select another rule'}'
|
||||
);
|
||||
}
|
||||
// Reload rule inputs
|
||||
couponManager.loadRuleInputs = function(ruleId, callBack) {
|
||||
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
|
||||
var url = "{$urlAjaxGetRuleInput}";
|
||||
url = url.replace('ruleId', ruleId)
|
||||
$.ajax({
|
||||
url: url,
|
||||
statusCode: {
|
||||
404: function() {
|
||||
$('#constraint-add-operators-values').html(
|
||||
'{intl l='Please select another rule'}'
|
||||
);
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#constraint-add-operators-values').html(data);
|
||||
});
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#constraint-add-operators-values').html(data);
|
||||
|
||||
return callBack();
|
||||
});
|
||||
}
|
||||
onRuleChange();
|
||||
};
|
||||
|
||||
// Rules which will be saved
|
||||
couponManager.rulesToSave = couponManager.initRules();
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
{/block}
|
||||
|
||||
@@ -161,134 +161,122 @@
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<table class="table table-striped">
|
||||
<caption class="clearfix">
|
||||
{intl l='Rules'}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Conditions'}</th>
|
||||
<th>{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="constraint-list">
|
||||
{include file='coupon/rules.html' rules=$rulesObject}
|
||||
{*{foreach from=$rulesObject item=rule name=rulesForeach}*}
|
||||
{*<tr>*}
|
||||
{*<td>*}
|
||||
{*{if !$smarty.foreach.rulesForeach.first}*}
|
||||
{*<span class="label label-info">{intl l='And'}</span>*}
|
||||
{*{/if}*}
|
||||
{*{$rule.tooltip nofilter}*}
|
||||
{*</td>*}
|
||||
|
||||
{*<td>*}
|
||||
{*<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}</a>*}
|
||||
{*<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#delete"><span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}</a>*}
|
||||
{*</td>*}
|
||||
{*</tr>*}
|
||||
{*{/foreach}*}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator clearfix">
|
||||
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
|
||||
<div id="rule-add-organizer" class="form-group col-md-2">
|
||||
<label for="type">{intl l='Condition type :'}</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" value="2"> {intl l='Or'}
|
||||
</label>
|
||||
{if $noRules}
|
||||
{include file='includes/notifications.html' message={intl l='Please save your Coupon in oder to affect it some application fields'}}
|
||||
{else}
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<table class="table table-striped">
|
||||
<caption class="clearfix">
|
||||
{intl l='Rules'}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{intl l='Conditions'}</th>
|
||||
<th>{intl l='Actions'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="constraint-list">
|
||||
{include file='coupon/rules.html' rules=$rules}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div id="rule-add-type" class="form-group col-md-4">
|
||||
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
|
||||
<select name="categoryRule" id="category-rule" class="form-control">
|
||||
{foreach from=$availableRules item=availableRule}
|
||||
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<section class="row">
|
||||
<div class="col-md-12 general-block-decorator clearfix">
|
||||
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
|
||||
<span class="glyphicon glyphicon-plus-sign"></span>
|
||||
</a>
|
||||
|
||||
<div id="rule-add-organizer" class="form-group col-md-2">
|
||||
<label for="type">{intl l='Condition type :'}</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input type="radio" name="type" value="2"> {intl l='Or'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="rule-add-type" class="form-group col-md-4">
|
||||
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
|
||||
<select name="categoryRule" id="category-rule" class="form-control">
|
||||
{foreach from=$availableRules item=availableRule}
|
||||
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="constraint-add-operators-values" class="form-group col-md-6">
|
||||
{*<label for="operator">{intl l='Operator :'}</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon">€</span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{**}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-12">*}
|
||||
{*<table class="table table-bordered">*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-breadcrumb"></td>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<th><span class="icon-th-list"></span> Categories list</th>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-categories"></td>*}
|
||||
{*</tr>*}
|
||||
{*</table>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="constraint-add-operators-values" class="form-group col-md-6">
|
||||
{*<label for="operator">{intl l='Operator :'}</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon">€</span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{**}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
|
||||
{*<label for="operator">Operator :</label>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<select name="operator" id="operator" class="form-control">*}
|
||||
{*<option value="1">is superior to</option>*}
|
||||
{*<option value="2">equals to</option>*}
|
||||
{*<option value="3">is inferior to</option>*}
|
||||
{*<option value="4">is inferior or equals to</option>*}
|
||||
{*<option value="5">is superior or equals to</option>*}
|
||||
{*</select>*}
|
||||
{*</div>*}
|
||||
{*<div class="col-lg-6">*}
|
||||
{*<input type="text" name="value" class="form-control">*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
{*<div class="row">*}
|
||||
{*<div class="col-lg-12">*}
|
||||
{*<table class="table table-bordered">*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-breadcrumb"></td>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<th><span class="icon-th-list"></span> Categories list</th>*}
|
||||
{*</tr>*}
|
||||
{*<tr>*}
|
||||
{*<td id="minibrowser-categories"></td>*}
|
||||
{*</tr>*}
|
||||
{*</table>*}
|
||||
{*</div>*}
|
||||
{*</div>*}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{*{$inputs.inputs|var_dump}*}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
<label for="operator">{$input.title}</label>
|
||||
<div class="row">
|
||||
@@ -71,32 +70,33 @@
|
||||
{*</div>*}
|
||||
|
||||
<script>
|
||||
var ruleToSave = {};
|
||||
ruleToSave['serviceId'] = '{$ruleId}';
|
||||
ruleToSave['operators'] = {};
|
||||
ruleToSave['values'] = {};
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
|
||||
ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
|
||||
{/foreach}
|
||||
|
||||
// Init Rules to set
|
||||
couponManager.ruleToSave['serviceId'] = '{$ruleId}';
|
||||
couponManager.ruleToSave['operators'] = {literal}{}{/literal};
|
||||
couponManager.ruleToSave['values'] = {literal}{}{/literal};
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
|
||||
couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
|
||||
{/foreach}
|
||||
|
||||
|
||||
// Update ruleToSave Array ready to be saved
|
||||
var onInputsChange = function() {literal}{{/literal}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
$('#{$name}-operator').change(function (e) {
|
||||
var $this = $(this);
|
||||
ruleToSave['operators']['{$name nofilter}'] = $this.val();
|
||||
console.log('#{$name}-operator changed ' + $this.val());
|
||||
console.log(ruleToSave);
|
||||
});
|
||||
$('#{$name}-value').change(function (e) {
|
||||
var $this = $(this);
|
||||
ruleToSave['values']['{$name nofilter}'] = $this.val();
|
||||
console.log('#{$name}-value changed ' + $this.val());
|
||||
console.log(ruleToSave);
|
||||
});
|
||||
{/foreach}
|
||||
// Fill in ready to be saved rule array
|
||||
couponManager.onInputsChange = function() {literal}{{/literal}
|
||||
{foreach from=$inputs.inputs key=name item=input}
|
||||
// Operator selector
|
||||
$('#{$name}-operator').change(function (e) {
|
||||
console.log('changin operator');
|
||||
var $this = $(this);
|
||||
couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val();
|
||||
});
|
||||
// Value input
|
||||
$('#{$name}-value').change(function (e) {
|
||||
console.log('changin value');
|
||||
var $this = $(this);
|
||||
couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val();
|
||||
});
|
||||
{/foreach}
|
||||
{literal}}{/literal}
|
||||
onInputsChange();
|
||||
couponManager.onInputsChange();
|
||||
</script>
|
||||
@@ -1,4 +1,4 @@
|
||||
{foreach from=$rules item=rule name=rulesForeach}
|
||||
{foreach from=$rules item=rule key=i name=rulesForeach}
|
||||
<tr>
|
||||
<td>
|
||||
{if !$smarty.foreach.rulesForeach.first}
|
||||
@@ -7,10 +7,10 @@
|
||||
{$rule nofilter}
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-primary btn-medium" href="{$urlEdit}">
|
||||
<a data-int="{$i}" class="btn btn-default btn-primary btn-medium constraint-update-btn" href="{$urlEdit}">
|
||||
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
|
||||
</a>
|
||||
<a data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium" href="{$urlDelete}">
|
||||
<a data-int="{$i}" data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium constraint-delete-btn" href="{$urlDelete}">
|
||||
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
|
||||
{form_field form=$form field='username'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="text" class="input" placeholder="{intl l='User name'}" name="{$name}" value="{$value}" {$attr} />
|
||||
<input type="text" id="username" class="input" placeholder="{intl l='User name'}" name="{$name}" value="{$value}" {$attr} />
|
||||
</span>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='password'}
|
||||
<span {if $error}class="error"{/if}>
|
||||
<input type="password" class="input" placeholder="{intl l='Password'}" name="{$name}" {$attr} />
|
||||
<input type="password" id="password" class="input" placeholder="{intl l='Password'}" name="{$name}" {$attr} />
|
||||
</span>
|
||||
{/form_field}
|
||||
|
||||
|
||||
@@ -34,10 +34,8 @@
|
||||
<li class="item">
|
||||
<article itemscope itemtype="http://schema.org/Product">
|
||||
<!-- Use the meta tag to specify content that is not visible on the page in any way -->
|
||||
<meta itemprop="manufacturer" content="Diesel">
|
||||
<meta itemprop="category" content="Category1">
|
||||
<meta itemprop="condition" content="new"> <!-- List of condition : new, used, refurbished -->
|
||||
<meta itemprop="identifier" content="mpn:925872"> <!-- List of identifier : asin, isbn, mpn, upc, sku -->
|
||||
<meta itemprop="brand" content="Diesel">
|
||||
<meta itemprop="productID" content="isbn:925872">
|
||||
|
||||
<a href="{$URL}" itemprop="url" tabindex="-1" class="product-image">
|
||||
{ifloop rel="image_product_new" }
|
||||
@@ -59,8 +57,11 @@
|
||||
|
||||
<div class="product-price">
|
||||
<div class="price-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<meta itemprop="currency" content="{currency attr="code"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<link itemprop="availability" href="http://schema.org/InStock" content="In Stock" />
|
||||
<meta itemprop="category" content="Category1">
|
||||
<meta itemprop="itemCondition" itemscope itemtype="http://schema.org/NewCondition"> <!-- List of condition : NewCondition, DamagedCondition, UsedCondition, RefurbishedCondition -->
|
||||
<meta itemprop="priceCurrency" content="{currency attr="code"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<link itemprop="availability" href="http://schema.org/InStock" content="in_stock" />
|
||||
|
||||
<!-- List of availibility :
|
||||
out_of_stock : http://schema.org/OutOfStock
|
||||
in_stock : http://schema.org/InStock
|
||||
@@ -92,10 +93,8 @@
|
||||
<li class="item">
|
||||
<article itemscope itemtype="http://schema.org/Product">
|
||||
<!-- Use the meta tag to specify content that is not visible on the page in any way -->
|
||||
<meta itemprop="manufacturer" content="Diesel">
|
||||
<meta itemprop="category" content="Category1">
|
||||
<meta itemprop="condition" content="new"> <!-- List of condition : new, used, refurbished -->
|
||||
<meta itemprop="identifier" content="mpn:925872"> <!-- List of identifier : asin, isbn, mpn, upc, sku -->
|
||||
<meta itemprop="brand" content="Diesel">
|
||||
<meta itemprop="productID" content="isbn:925872">
|
||||
|
||||
<a href="{$URL}" itemprop="url" tabindex="-1" class="product-image">
|
||||
{ifloop rel="image_product_promo" }
|
||||
@@ -117,8 +116,10 @@
|
||||
|
||||
<div class="product-price">
|
||||
<div class="price-container" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
||||
<meta itemprop="currency" content="USD"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<link itemprop="availability" href="http://schema.org/InStock" content="In Stock" />
|
||||
<meta itemprop="category" content="Category1">
|
||||
<meta itemprop="itemCondition" itemscope itemtype="http://schema.org/NewCondition"> <!-- List of condition : NewCondition, DamagedCondition, UsedCondition, RefurbishedCondition -->
|
||||
<meta itemprop="priceCurrency" content="{currency attr="code"}"> <!-- List of currency : The currency used to describe the product price, in three-letter ISO format. -->
|
||||
<link itemprop="availability" href="http://schema.org/InStock" content="in_stock" />
|
||||
<!-- List of availibility :
|
||||
out_of_stock : http://schema.org/OutOfStock
|
||||
in_stock : http://schema.org/InStock
|
||||
|
||||
@@ -84,8 +84,15 @@ URL: http://www.thelia.net
|
||||
{/loop}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-cart navbar-right">
|
||||
{loop type="auth" name="customer_info_block" roles="CUSTOMER" context="front"}
|
||||
<li><a href="{url path="/logout"}" class="register">{intl l="Log out!"}</a></li>
|
||||
<li><a href="{url path="/customer/account"}" class="login">{intl l="My Account"}</a></li>
|
||||
{/loop}
|
||||
|
||||
{elseloop rel="customer_info_block" rel="customer_info_block"}
|
||||
<li><a href="{url path="/register"}" class="register">{intl l="Register"}!</a></li>
|
||||
<li><a href="{url path="/login"}" class="login">{intl l="Log In!"}</a></li>
|
||||
{/elseloop}
|
||||
<li class="dropdown">
|
||||
<a href="cart.html" class="dropdown-toggle cart" data-toggle="dropdown">
|
||||
Cart <span class="badge">2</span>
|
||||
@@ -113,7 +120,7 @@ URL: http://www.thelia.net
|
||||
<div class="input-group">
|
||||
<input type="search" name="q" id="q" placeholder="Search..." class="form-control" aria-required="true" required pattern=". { 2,}" title="Minmimum 2 characters.">
|
||||
<div class="input-group-btn">
|
||||
<button type="submit" class="btn btn-search"><span class="icon-search"></span> <span>Search</span></button>
|
||||
<button type="submit" class="btn btn-search"><i class="icon-search"></i> <span>Search</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
|
||||
<strong id="breadcrumb-label">{intl l="You are here"}: </strong>
|
||||
<ul class="breadcrumb" itemprop="breadcrumb">
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="index.php" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{url path="/"}" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"><span itemprop="title">{intl l="Login"}</span></li>
|
||||
</ul>
|
||||
</nav><!-- /.nav-breadcrumb -->
|
||||
@@ -67,7 +67,7 @@
|
||||
</fieldset>
|
||||
|
||||
<div class="group-btn">
|
||||
<a href="{url path="/customer/password"}" class="forgot-password">{intl l="Forgot your Password ?"}</a>
|
||||
<a href="{url path="/password"}" class="forgot-password">{intl l="Forgot your Password ?"}</a>
|
||||
<button type="submit" class="btn btn-login">{intl l="Next"}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
42
templates/default/password.html
Normal file
42
templates/default/password.html
Normal file
@@ -0,0 +1,42 @@
|
||||
{extends file="layout.tpl"}
|
||||
|
||||
{block name="breadcrumb"}
|
||||
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
|
||||
<strong id="breadcrumb-label">{intl l="You are here"} </strong>
|
||||
<ul class="breadcrumb" itemprop="breadcrumb">
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{url path="/"}" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"><span itemprop="title">{intl l="Password"}</span></li>
|
||||
</ul>
|
||||
</nav><!-- /.nav-breadcrumb -->
|
||||
{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="main">
|
||||
<article class="col-main" role="main" aria-labelledby="main-label">
|
||||
<h1 id="main-label" class="page-header">{intl l="Password Forgotten"}</h1>
|
||||
{form name="thelia.customer.lostpassword"}
|
||||
<form id="form-forgotpassword" action="{url path="/password"}" method="post" role="form">
|
||||
|
||||
<p>{intl l="Please enter your email address below." {intl l="You will receive a link to reset your password."}</p>
|
||||
{form_field form=$form field="email"}
|
||||
<div class="form-group group-email {if $error}has-error{elseif !$error && $value != ""}has-success{/if}">
|
||||
<label for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="email" name="{$name}" value="{$value}" id="{$label_attr.for}" class="form-control" aria-required="true" autofocus required>
|
||||
{if $error}
|
||||
<span class="help-block"><span class="icon-remove"></span> {$message}</span>
|
||||
{elseif !$error && $value != ""}
|
||||
<span class="help-block"><span class="icon-ok"></span> {intl l="You will receive a link to reset your password."}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
<div class="group-btn">
|
||||
<a href="{url path="/"}" class="btn btn-cancel">{intl l="Cancel"}</a>
|
||||
<button type="submit" class="btn btn-forgot">{intl l="Send"}</button>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</article>
|
||||
</div>
|
||||
{/block}
|
||||
@@ -4,7 +4,7 @@
|
||||
<nav class="nav-breadcrumb" role="navigation" aria-labelledby="breadcrumb-label">
|
||||
<strong id="breadcrumb-label">{intl l="You are here"}: </strong>
|
||||
<ul class="breadcrumb" itemprop="breadcrumb">
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="index.php" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="{url path="/"}" itemprop="url"><span itemprop="title">{intl l="Home"}</span></a></li>
|
||||
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"><span itemprop="title">{intl l="Register"}</span></li>
|
||||
</ul>
|
||||
</nav><!-- /.nav-breadcrumb -->
|
||||
@@ -19,18 +19,44 @@
|
||||
<h1 id="main-label" class="page-header">{intl l="Create New Account"}</h1>
|
||||
{form name="thelia.customer.creation"}
|
||||
<form id="form-register" class="form-horizontal" action="{url path="/customer/create"}" method="post" role="form">
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{navigate to="return_to"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='error_message'}
|
||||
<input type="hidden" name="{$name}" value="{intl l="missing or invalid data"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
{form_hidden_fields form=$form}
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
<fieldset id="register-info" class="panel panel">
|
||||
<div class="panel-heading">
|
||||
1. {intl l="Personal Informations"}
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
{form_field form=$form field="title"}
|
||||
<div class="form-group group-title {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<select name="{$name}" id="{$label_attr.for}" class="form-control" required autofocus>
|
||||
<option value="">-- {intl l="Select Title"} --</option>
|
||||
{loop type="title" name="country.list"}
|
||||
<option value="{$ID}" {if $value == $ID}selected{/if} >{$LONG}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field="firstname"}
|
||||
<div class="form-group group-firstname {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
||||
<div class="form-group group-firstname {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus required>
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" required>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
@@ -40,7 +66,7 @@
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field="lastname"}
|
||||
<div class="form-group group-lastname {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
||||
<div class="form-group group-lastname {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus required>
|
||||
@@ -53,7 +79,7 @@
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field="email"}
|
||||
<div class="form-group group-email {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
||||
<div class="form-group group-email {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
|
||||
<div class="control-input">
|
||||
@@ -67,7 +93,7 @@
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field="phone"}
|
||||
<div class="form-group group-phone {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
||||
<div class="form-group group-phone {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
||||
@@ -80,7 +106,7 @@
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field="cellphone"}
|
||||
<div class="form-group group-cellphone {if $error}has-error{elseif $value != "" && !$error}has_success{/if}">
|
||||
<div class="form-group group-cellphone {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="John" value="{$value}" autofocus>
|
||||
@@ -101,74 +127,129 @@
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="form-group group-company">
|
||||
<label class="control-label" for="company">Company Name: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="company" id="company" class="form-control" placeholder="Thelia" required>
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="company"}
|
||||
<div class="form-group group-company {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="Thelia" value="{$value}" autofocus>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-address">
|
||||
<label class="control-label" for="address">Street Address: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="asresss" id="address" class="form-control" placeholder="Street address" required>
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="address1"}
|
||||
<div class="form-group group-address1 {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="{$label}" value="{$value}" autofocus required>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-address_2">
|
||||
<label class="control-label" for="address_2">Address 2:</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="address_2" id="address_2" class="form-control" placeholder="">
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="address2"}
|
||||
<div class="form-group group-address2 {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="" value="{$value}" autofocus>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-city">
|
||||
<label class="control-label" for="city">City: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="city" id="city" class="form-control" placeholder="New york" required>
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="city"}
|
||||
<div class="form-group group-city {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="New York" value="{$value}" autofocus required>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-zip">
|
||||
<label class="control-label" for="zip">Postal Code: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="zip" id="zip" class="form-control" placeholder="H2T 2V6" required>
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="zipcode"}
|
||||
<div class="form-group group-zip {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" placeholder="H2T 2V6" value="{$value}" autofocus required>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-country">
|
||||
<label class="control-label" for="country">Country: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<select name"country" id="country" class="form-control" required>
|
||||
<option value="">-- Select Country --</option>
|
||||
<option value="1">Country1</option>
|
||||
<option value="2">Country2</option>
|
||||
<option value="3">Country3</option>
|
||||
<option value="4">Country4</option>
|
||||
</select>
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="country"}
|
||||
<div class="form-group group-country {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<select name="{$name}" id="{$label_attr.for}" class="form-control" required>
|
||||
<option value="">-- {intl l="Select Country"} --</option>
|
||||
{loop type="country" name="country.list"}
|
||||
<option value="{$ID}" {if $value == $ID}selected{/if} >{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="register-login" class="panel">
|
||||
<div class="panel-heading">
|
||||
3. Login Information
|
||||
3. {intl l="Login Information"}
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="form-group group-password">
|
||||
<label class="control-label" for="password">Password: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="password" name="password" id="password" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="password"}
|
||||
<div class="form-group group-password {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
|
||||
<div class="form-group group-confirm_password">
|
||||
<label class="control-label" for="confirm_password">Confirm Password: <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="password" name="confirm_password" id="confirm_password" class="form-control" required autocomplete="off">
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{form_field form=$form field="password_confirm"}
|
||||
<div class="form-group group-password_confirm {if $error}has-error{elseif $value != "" && !$error}has-success{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<div class="control-input">
|
||||
<input type="password" name="{$name}" id="{$label_attr.for}" class="form-control" required autocomplete="off">
|
||||
{if $error }
|
||||
<span class="help-block"><i class="icon-remove"></i> {$message}</span>
|
||||
{elseif $value != "" && !$error}
|
||||
<span class="help-block"><i class="icon-ok"></i></span>
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -176,7 +257,7 @@
|
||||
<div class="control-input">
|
||||
<div class="checkbox">
|
||||
<label class="control-label" for="agreed">
|
||||
<input type="checkbox" name="agreed" id="agreed" value="1"> I've read and agreed on <a href="#">Terms & Conditions</a>.
|
||||
<input type="checkbox" name="agreed" id="agreed" value="1" required> I've read and agreed on <a href="#">Terms & Conditions</a>.
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
<html>
|
||||
<head>
|
||||
{debugbar_renderHead}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Category page</h1>
|
||||
|
||||
<div style="border: solid 8px; margin: 0px; padding: 0px; width: 45%; float: left">
|
||||
@@ -148,8 +142,4 @@
|
||||
{/loop}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
{debugbar_render}
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
@@ -8,7 +8,7 @@ Index : {navigate to="index"}<br />
|
||||
|
||||
{ifloop rel="product"}
|
||||
|
||||
{loop type="product" name="product" current="true" min_price="50" max_price="100"}
|
||||
{loop type="product" name="product" current="true"}
|
||||
|
||||
<div style="border: dashed 2px red; padding: 20px; margin: 10px;">
|
||||
<h2>PRODUCT ({$ID}) : {$REF}</h2>
|
||||
@@ -68,7 +68,7 @@ Index : {navigate to="index"}<br />
|
||||
{$ATTRIBUTE_TITLE} = {$ATTRIBUTE_AVAILABILITY_TITLE}<br />
|
||||
{/loop}
|
||||
<br />{$WEIGHT} g
|
||||
<br /><strong>{if $IS_PROMO == 1} {$PROMO_PRICE} {currency attr="symbol"} HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} {currency attr="symbol"} TTC (instead of {$PRICE_HT} // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC){else} {$PRICE} {currency attr="symbol"} HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC{/if}</strong>
|
||||
<br /><strong>{if $IS_PROMO == 1} {$PROMO_PRICE} {currency attr="symbol"} HT // TAX : {$PROMO_PRICE_TAX} ; {$TAXED_PROMO_PRICE} {currency attr="symbol"} TTC (instead of {$PRICE} HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC){else} {$PRICE} {currency attr="symbol"} HT // TAX : {$PRICE_TAX} ; {$TAXED_PRICE} {currency attr="symbol"} TTC{/if}</strong>
|
||||
<br /><br />
|
||||
Add
|
||||
<select>
|
||||
|
||||
3
tests/functionnal/casperjs/conf/local.js
Normal file
3
tests/functionnal/casperjs/conf/local.js
Normal file
@@ -0,0 +1,3 @@
|
||||
//LOCAL = ton pc
|
||||
var thelia2_base_url = 'http://www.thelia2.dev/index_dev.php/';
|
||||
casper.test.done(0);
|
||||
17
tests/functionnal/casperjs/exe/00_parameters.js
Normal file
17
tests/functionnal/casperjs/exe/00_parameters.js
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
casper.test.comment('Please edit 00_parameters.js to add your configuration');
|
||||
|
||||
var thelia2_login_admin_url = thelia2_base_url + 'admin/login';
|
||||
var thelia2_login_coupon_list_url = thelia2_base_url + 'admin/login';
|
||||
var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create';
|
||||
var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1';
|
||||
var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1';
|
||||
|
||||
|
||||
|
||||
//var findMyId = /([0-9]+)$/;
|
||||
//var currentId;
|
||||
|
||||
casper.test.comment('Variables are set');
|
||||
|
||||
casper.test.done(0);
|
||||
27
tests/functionnal/casperjs/exe/10_login.js
Normal file
27
tests/functionnal/casperjs/exe/10_login.js
Normal file
@@ -0,0 +1,27 @@
|
||||
casper.test.comment('Testing login');
|
||||
|
||||
casper.start(thelia2_login_admin_url, function() {
|
||||
this.echo('\nLOGIN');
|
||||
this.test.assertTitle('Welcome - Thelia Back Office', 'Web page title OK');
|
||||
this.sendKeys('input#username', 'thelia2');
|
||||
this.sendKeys('input#password', 'thelia2');
|
||||
this.click('form[action*="checklogin"] button[type="submit"]');
|
||||
});
|
||||
|
||||
casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
casper.then(function(){
|
||||
this.echo('\nDASHBOARD');
|
||||
|
||||
console.log('Now on : ' + this.getCurrentUrl());
|
||||
// @todo implement dashboard
|
||||
// this.test.assertTitle('Back-office home - Thelia Back Office', 'Web page title OK');
|
||||
// this.test.assertSelectorHasText('#wrapper > div', ' This is the administration home page. Put some interesting statistics here, and display useful information :) ', 'Web page main content OK');
|
||||
});
|
||||
|
||||
//RUN
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
||||
58
tests/functionnal/casperjs/exe/30_coupons.js
Normal file
58
tests/functionnal/casperjs/exe/30_coupons.js
Normal file
@@ -0,0 +1,58 @@
|
||||
casper.test.comment('Testing coupons');
|
||||
|
||||
|
||||
////LIST
|
||||
// @todo implement
|
||||
|
||||
////CREATE
|
||||
// @todo implement
|
||||
|
||||
//UPDATE COUPON RULE
|
||||
casper.start(thelia2_login_coupon_update_url, function() {
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
|
||||
this.echo('\nCOUPON RULE - EDIT');
|
||||
this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK');
|
||||
// this.test.assertSelectorHasText('#content-header > h1', 'Liste des pays', 'Web page main content OK');
|
||||
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1st default rule found');
|
||||
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2nd default rule found');
|
||||
|
||||
// Create rule
|
||||
this.evaluate(function() {
|
||||
$('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change();
|
||||
return true;
|
||||
});
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png');
|
||||
});
|
||||
|
||||
casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#quantity-operator').val('>=').change();
|
||||
return true;
|
||||
});
|
||||
this.sendKeys('input#quantity-value', '4');
|
||||
this.click('#constraint-save-btn');
|
||||
});
|
||||
|
||||
casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
casper.then(function(){
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png');
|
||||
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equals to 4','3rd rule found');
|
||||
});
|
||||
|
||||
////EDIT CHECK
|
||||
// @todo implement
|
||||
|
||||
////DELETE
|
||||
// @todo implement
|
||||
|
||||
//RUN
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
||||
Reference in New Issue
Block a user