Merge branch 'master' into tax
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";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -251,6 +251,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>
|
||||
|
||||
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