Merge branch 'catalog'
Conflicts: local/config/schema.xml
This commit is contained in:
@@ -67,11 +67,11 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
|||||||
->findOne($con);
|
->findOne($con);
|
||||||
|
|
||||||
if ($salesElement == null) {
|
if ($salesElement == null) {
|
||||||
// Create a new product sale element
|
// Create a new default product sale element
|
||||||
$salesElement = $event->getProduct()->createDefaultProductSaleElement($con, 0, 0, $event->getCurrencyId(), true);
|
$salesElement = $event->getProduct()->createDefaultProductSaleElement($con, 0, 0, $event->getCurrencyId(), true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// This one is the default
|
// This (new) one is the default
|
||||||
$salesElement->setIsDefault(true)->save($con);
|
$salesElement->setIsDefault(true)->save($con);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +122,9 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// Update the product's tax rule
|
||||||
|
$event->getProduct()->setTaxRuleId($event->getTaxRuleId())->save($con);
|
||||||
|
|
||||||
// If product sale element is not defined, create it.
|
// If product sale element is not defined, create it.
|
||||||
if ($salesElement == null) {
|
if ($salesElement == null) {
|
||||||
$salesElement = new ProductSaleElements();
|
$salesElement = new ProductSaleElements();
|
||||||
@@ -158,11 +161,25 @@ class ProductSaleElement extends BaseAction implements EventSubscriberInterface
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
$productPrice
|
// Check if we have to store the price
|
||||||
->setPromoPrice($event->getSalePrice())
|
$productPrice->setFromDefaultCurrency($event->getFromDefaultCurrency());
|
||||||
->setPrice($event->getPrice())
|
|
||||||
->save($con)
|
if ($event->getFromDefaultCurrency() == 0) {
|
||||||
;
|
// Store the price
|
||||||
|
$productPrice
|
||||||
|
->setPromoPrice($event->getSalePrice())
|
||||||
|
->setPrice($event->getPrice())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Do not store the price.
|
||||||
|
$productPrice
|
||||||
|
->setPromoPrice(0)
|
||||||
|
->setPrice(0)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
$productPrice->save($con);
|
||||||
|
|
||||||
// Store all the stuff !
|
// Store all the stuff !
|
||||||
$con->commit();
|
$con->commit();
|
||||||
|
|||||||
@@ -303,10 +303,14 @@
|
|||||||
<default key="_controller">Thelia\Controller\Admin\ProductController::updateContentPositionAction</default>
|
<default key="_controller">Thelia\Controller\Admin\ProductController::updateContentPositionAction</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="admin.product.update-content-position" path="/admin/product/calculate-price">
|
<route id="admin.product.calculate-price" path="/admin/product/calculate-price">
|
||||||
<default key="_controller">Thelia\Controller\Admin\ProductController::priceCaclulator</default>
|
<default key="_controller">Thelia\Controller\Admin\ProductController::priceCaclulator</default>
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route id="admin.product.load-converted-prices" path="/admin/product/load-converted-prices">
|
||||||
|
<default key="_controller">Thelia\Controller\Admin\ProductController::loadConvertedPrices</default>
|
||||||
|
</route>
|
||||||
|
|
||||||
<!-- accessories -->
|
<!-- accessories -->
|
||||||
|
|
||||||
<route id="admin.products.accessories.add" path="/admin/products/accessory/add">
|
<route id="admin.products.accessories.add" path="/admin/products/accessory/add">
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ use Thelia\Model\CurrencyQuery;
|
|||||||
use Thelia\Form\CurrencyModificationForm;
|
use Thelia\Form\CurrencyModificationForm;
|
||||||
use Thelia\Form\CurrencyCreationForm;
|
use Thelia\Form\CurrencyCreationForm;
|
||||||
use Thelia\Core\Event\UpdatePositionEvent;
|
use Thelia\Core\Event\UpdatePositionEvent;
|
||||||
|
use Thelia\Core\Security\AccessManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages currencies
|
* Manages currencies
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ use Thelia\Model\Country;
|
|||||||
use Thelia\Model\CountryQuery;
|
use Thelia\Model\CountryQuery;
|
||||||
use Thelia\Model\TaxRuleQuery;
|
use Thelia\Model\TaxRuleQuery;
|
||||||
use Thelia\Tools\NumberFormat;
|
use Thelia\Tools\NumberFormat;
|
||||||
|
use Thelia\Model\Product;
|
||||||
|
use Thelia\Model\CurrencyQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages products
|
* Manages products
|
||||||
@@ -187,6 +189,23 @@ class ProductController extends AbstractCrudController
|
|||||||
return $event->hasProduct();
|
return $event->hasProduct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function updatePriceFromDefaultCurrency($productPrice, $saleElement, $defaultCurrency, $currentCurrency) {
|
||||||
|
|
||||||
|
// Get price for default currency
|
||||||
|
$priceForDefaultCurrency = ProductPriceQuery::create()
|
||||||
|
->filterByCurrency($defaultCurrency)
|
||||||
|
->filterByProductSaleElements($saleElement)
|
||||||
|
->findOne()
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($priceForDefaultCurrency !== null) {
|
||||||
|
$productPrice
|
||||||
|
->setPrice($priceForDefaultCurrency->getPrice() * $currentCurrency->getRate())
|
||||||
|
->setPromoPrice($priceForDefaultCurrency->getPromoPrice() * $currentCurrency->getRate())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function hydrateObjectForm($object)
|
protected function hydrateObjectForm($object)
|
||||||
{
|
{
|
||||||
$defaultPseData = $combinationPseData = array();
|
$defaultPseData = $combinationPseData = array();
|
||||||
@@ -196,17 +215,36 @@ class ProductController extends AbstractCrudController
|
|||||||
->filterByProduct($object)
|
->filterByProduct($object)
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
|
$defaultCurrency = Currency::getDefaultCurrency();
|
||||||
|
$currentCurrency = $this->getCurrentEditionCurrency();
|
||||||
|
|
||||||
foreach($saleElements as $saleElement) {
|
foreach($saleElements as $saleElement) {
|
||||||
|
|
||||||
// Get the product price for the current currency
|
// Get the product price for the current currency
|
||||||
|
|
||||||
$productPrice = ProductPriceQuery::create()
|
$productPrice = ProductPriceQuery::create()
|
||||||
->filterByCurrency($this->getCurrentEditionCurrency())
|
->filterByCurrency($currentCurrency)
|
||||||
->filterByProductSaleElements($saleElement)
|
->filterByProductSaleElements($saleElement)
|
||||||
->findOne()
|
->findOne()
|
||||||
;
|
;
|
||||||
|
|
||||||
if ($productPrice == null) $productPrice = new ProductPrice();
|
// No one exists ?
|
||||||
|
if ($productPrice === null) {
|
||||||
|
$productPrice = new ProductPrice();
|
||||||
|
|
||||||
|
// If the current currency is not the default one, calculate the price
|
||||||
|
// using default currency price and current currency rate
|
||||||
|
if ($currentCurrency->getId() != $defaultCurrency->getId()) {
|
||||||
|
|
||||||
|
$productPrice->setFromDefaultCurrency(true);
|
||||||
|
|
||||||
|
$this->updatePriceFromDefaultCurrency($productPrice, $saleElement, $defaultCurrency, $currentCurrency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Caclulate prices if we have to use the rate * defaulkt currency price
|
||||||
|
if ($productPrice->getFromDefaultCurrency() == true) {
|
||||||
|
$this->updatePriceFromDefaultCurrency($productPrice, $saleElement, $defaultCurrency, $currentCurrency);
|
||||||
|
}
|
||||||
|
|
||||||
$isDefaultPse = count($saleElement->getAttributeCombinations()) == 0;
|
$isDefaultPse = count($saleElement->getAttributeCombinations()) == 0;
|
||||||
|
|
||||||
@@ -219,18 +257,19 @@ class ProductController extends AbstractCrudController
|
|||||||
"product_sale_element_id" => $saleElement->getId(),
|
"product_sale_element_id" => $saleElement->getId(),
|
||||||
"reference" => $saleElement->getRef(),
|
"reference" => $saleElement->getRef(),
|
||||||
"price" => $productPrice->getPrice(),
|
"price" => $productPrice->getPrice(),
|
||||||
|
"price_with_tax" => $this->computePrice($productPrice->getPrice(), 'without_tax', $object),
|
||||||
"use_exchange_rate" => $productPrice->getFromDefaultCurrency() ? 1 : 0,
|
"use_exchange_rate" => $productPrice->getFromDefaultCurrency() ? 1 : 0,
|
||||||
"tax_rule" => $object->getTaxRuleId(),
|
"tax_rule" => $object->getTaxRuleId(),
|
||||||
"currency" => $productPrice->getCurrencyId(),
|
"currency" => $productPrice->getCurrencyId(),
|
||||||
"weight" => $saleElement->getWeight(),
|
"weight" => $saleElement->getWeight(),
|
||||||
"quantity" => $saleElement->getQuantity(),
|
"quantity" => $saleElement->getQuantity(),
|
||||||
"sale_price" => $productPrice->getPromoPrice(),
|
"sale_price" => $productPrice->getPromoPrice(),
|
||||||
|
"sale_price_with_tax" => $this->computePrice($productPrice->getPromoPrice(), 'without_tax', $object),
|
||||||
"onsale" => $saleElement->getPromo() > 0 ? 1 : 0,
|
"onsale" => $saleElement->getPromo() > 0 ? 1 : 0,
|
||||||
"isnew" => $saleElement->getNewness() > 0 ? 1 : 0,
|
"isnew" => $saleElement->getNewness() > 0 ? 1 : 0,
|
||||||
"isdefault" => $saleElement->getIsDefault() > 0 ? 1 : 0,
|
"isdefault" => $saleElement->getIsDefault() > 0 ? 1 : 0,
|
||||||
"ean_code" => $saleElement->getEanCode()
|
"ean_code" => $saleElement->getEanCode()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
}
|
}
|
||||||
@@ -240,9 +279,13 @@ class ProductController extends AbstractCrudController
|
|||||||
|
|
||||||
$combinationPseForm = new ProductSaleElementUpdateForm($this->getRequest(), "form", $combinationPseData);
|
$combinationPseForm = new ProductSaleElementUpdateForm($this->getRequest(), "form", $combinationPseData);
|
||||||
$this->getParserContext()->addForm($combinationPseForm);
|
$this->getParserContext()->addForm($combinationPseForm);
|
||||||
|
|
||||||
|
var_dump($defaultPseData);
|
||||||
|
|
||||||
|
var_dump($combinationPseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the data that will hydrate the form
|
// Prepare the data that will hydrate the form(s)
|
||||||
$data = array(
|
$data = array(
|
||||||
'id' => $object->getId(),
|
'id' => $object->getId(),
|
||||||
'ref' => $object->getRef(),
|
'ref' => $object->getRef(),
|
||||||
@@ -254,8 +297,6 @@ class ProductController extends AbstractCrudController
|
|||||||
'visible' => $object->getVisible(),
|
'visible' => $object->getVisible(),
|
||||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||||
'default_category' => $object->getDefaultCategoryId()
|
'default_category' => $object->getDefaultCategoryId()
|
||||||
|
|
||||||
// A terminer pour les prix
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Setup the object form
|
// Setup the object form
|
||||||
@@ -847,7 +888,7 @@ class ProductController extends AbstractCrudController
|
|||||||
protected function processProductSaleElementUpdate($changeForm) {
|
protected function processProductSaleElementUpdate($changeForm) {
|
||||||
|
|
||||||
// Check current user authorization
|
// Check current user authorization
|
||||||
if (null !== $response = $this->checkAuth("admin.products.update")) return $response;
|
if (null !== $response = $this->checkAuth($this->resourceCode, AccessManager::UPDATE)) return $response;
|
||||||
|
|
||||||
$error_msg = false;
|
$error_msg = false;
|
||||||
|
|
||||||
@@ -875,7 +916,8 @@ class ProductController extends AbstractCrudController
|
|||||||
->setIsnew($data['isnew'])
|
->setIsnew($data['isnew'])
|
||||||
->setIsdefault($data['isdefault'])
|
->setIsdefault($data['isdefault'])
|
||||||
->setEanCode($data['ean_code'])
|
->setEanCode($data['ean_code'])
|
||||||
->setTaxrule($data['tax_rule'])
|
->setTaxRuleId($data['tax_rule'])
|
||||||
|
->setFromDefaultCurrency($data['use_exchange_rate'])
|
||||||
;
|
;
|
||||||
|
|
||||||
$this->dispatch(TheliaEvents::PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT, $event);
|
$this->dispatch(TheliaEvents::PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT, $event);
|
||||||
@@ -928,24 +970,102 @@ class ProductController extends AbstractCrudController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked through Ajax; this methow calculate the taxed price from the unaxed price, and
|
||||||
|
* vice versa.
|
||||||
|
*/
|
||||||
public function priceCaclulator() {
|
public function priceCaclulator() {
|
||||||
|
|
||||||
$price = floatval($this->getRequest()->get('price', 0));
|
$return_price = 0;
|
||||||
$tax_rule = intval($this->getRequest()->get('tax_rule_id', 0)); // The tax rule ID
|
|
||||||
$action = $this->getRequest()->get('action', ''); // With ot without tax
|
$price = floatval($this->getRequest()->get('price', 0));
|
||||||
$convert = intval($this->getRequest()->get('convert_from_default_currency', 0));
|
$product_id = intval($this->getRequest()->get('product_id', 0));
|
||||||
|
$action = $this->getRequest()->get('action', ''); // With ot without tax
|
||||||
|
$convert = intval($this->getRequest()->get('convert_from_default_currency', 0));
|
||||||
|
|
||||||
|
if (null !== $product = ProductQuery::create()->findPk($product_id)) {
|
||||||
|
|
||||||
|
if ($action == 'to_tax') {
|
||||||
|
$return_price = $this->computePrice($price, 'without_tax', $product);
|
||||||
|
}
|
||||||
|
else if ($action == 'from_tax') {
|
||||||
|
$return_price = $this->computePrice($price, 'with_tax', $product);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return_price = $price;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($convert != 0) {
|
||||||
|
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResponse(array('result' => $return_price));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadConvertedPrices() {
|
||||||
|
|
||||||
|
$product_sale_element_id = intval($this->getRequest()->get('product_sale_element_id', 0));
|
||||||
|
$currency_id = intval($this->getRequest()->get('currency_id', 0));
|
||||||
|
|
||||||
|
$price_with_tax = $price_without_tax = $sale_price_with_tax = $sale_price_without_tax = 0;
|
||||||
|
|
||||||
|
if (null !== $pse = ProductSaleElementsQuery::create()->findPk($product_sale_element_id)) {
|
||||||
|
if ($currency_id > 0
|
||||||
|
&&
|
||||||
|
$currency_id != Currency::getDefaultCurrency()->getId()
|
||||||
|
&&
|
||||||
|
null !== $currency = CurrencyQuery::create()->findPk($currency_id)) {
|
||||||
|
|
||||||
|
// Get the default currency price
|
||||||
|
$productPrice = ProductPriceQuery::create()
|
||||||
|
->filterByCurrency(Currency::getDefaultCurrency())
|
||||||
|
->filterByProductSaleElementsId($product_sale_element_id)
|
||||||
|
->findOne()
|
||||||
|
;
|
||||||
|
|
||||||
|
// Calculate the converted price
|
||||||
|
if (null !== $productPrice) {
|
||||||
|
$price_without_tax = $productPrice->getPrice() * $currency->getRate();
|
||||||
|
$sale_price_without_tax = $productPrice->getPromoPrice() * $currency->getRate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $product = $pse->getProduct()) {
|
||||||
|
$price_with_tax = $this->computePrice($price_without_tax, 'with_tax', $product);
|
||||||
|
$sale_price_with_tax = $this->computePrice($sale_price_without_tax, 'with_tax', $product);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResponse(array(
|
||||||
|
'price_with_tax' => NumberFormat::getInstance($this->getRequest())->format($price_with_tax, null, '.'),
|
||||||
|
'price_without_tax' => NumberFormat::getInstance($this->getRequest())->format($price_without_tax, null, '.'),
|
||||||
|
'sale_price_with_tax' => NumberFormat::getInstance($this->getRequest())->format($sale_price_with_tax, null, '.'),
|
||||||
|
'sale_price_without_tax' => NumberFormat::getInstance($this->getRequest())->format($sale_price_without_tax, null, '.')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate taxed/untexted price for a product
|
||||||
|
*
|
||||||
|
* @param unknown $price
|
||||||
|
* @param unknown $price_type
|
||||||
|
* @param Product $product
|
||||||
|
* @return Ambigous <unknown, number>
|
||||||
|
*/
|
||||||
|
protected function computePrice($price, $price_type, Product $product, $convert = false) {
|
||||||
|
|
||||||
$calc = new Calculator();
|
$calc = new Calculator();
|
||||||
|
|
||||||
$calc->loadTaxRule(
|
$calc->load(
|
||||||
TaxRuleQuery::create()->findPk($tax_rule),
|
$product,
|
||||||
Country::getShopLocation()
|
Country::getShopLocation()
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($action == 'to_tax') {
|
if ($price_type == 'without_tax') {
|
||||||
$return_price = $calc->getTaxedPrice($price);
|
$return_price = $calc->getTaxedPrice($price);
|
||||||
}
|
}
|
||||||
else if ($action == 'from_tax') {
|
else if ($price_type == 'with_tax') {
|
||||||
$return_price = $calc->getUntaxedPrice($price);
|
$return_price = $calc->getUntaxedPrice($price);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -955,10 +1075,7 @@ class ProductController extends AbstractCrudController
|
|||||||
if ($convert != 0) {
|
if ($convert != 0) {
|
||||||
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
|
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the number using '.', to perform further calculation
|
// Format the number using '.', to perform further calculation
|
||||||
$return_price = NumberFormat::getInstance($this->getRequest())->format($return_price, null, '.');
|
return NumberFormat::getInstance($this->getRequest())->format($return_price, null, '.');
|
||||||
|
|
||||||
return new JsonResponse(array('result' => $return_price));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
|
|||||||
protected $isnew;
|
protected $isnew;
|
||||||
protected $isdefault;
|
protected $isdefault;
|
||||||
protected $ean_code;
|
protected $ean_code;
|
||||||
protected $taxrule;
|
protected $tax_rule_id;
|
||||||
|
protected $from_default_currency;
|
||||||
|
|
||||||
public function __construct(Product $product, $product_sale_element_id)
|
public function __construct(Product $product, $product_sale_element_id)
|
||||||
{
|
{
|
||||||
@@ -196,16 +197,27 @@ class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTaxrule()
|
public function getTaxRuleId()
|
||||||
{
|
{
|
||||||
return $this->taxrule;
|
return $this->tax_rule_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxrule($taxrule)
|
public function setTaxRuleId($tax_rule_id)
|
||||||
{
|
{
|
||||||
$this->taxrule = $taxrule;
|
$this->tax_rule_id = $tax_rule_id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFromDefaultCurrency()
|
||||||
|
{
|
||||||
|
return $this->from_default_currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFromDefaultCurrency($from_default_currency)
|
||||||
|
{
|
||||||
|
$this->from_default_currency = $from_default_currency;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -668,6 +668,7 @@ class Product extends BaseI18nLoop
|
|||||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||||
->set("DEFAULT_CATEGORY" , $default_category_id)
|
->set("DEFAULT_CATEGORY" , $default_category_id)
|
||||||
|
->set("TAX_RULE_ID" , $product->getTaxRuleId())
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -28,4 +28,4 @@ class ProductDefaultSaleElementUpdateForm extends ProductSaleElementUpdateForm
|
|||||||
{
|
{
|
||||||
return "thelia_product_default_sale_element_update_form";
|
return "thelia_product_default_sale_element_update_form";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,10 @@ class ProductSaleElementUpdateForm extends BaseForm
|
|||||||
"label" => Translator::getInstance()->trans("Product price excluding taxes *"),
|
"label" => Translator::getInstance()->trans("Product price excluding taxes *"),
|
||||||
"label_attr" => array("for" => "price_field")
|
"label_attr" => array("for" => "price_field")
|
||||||
))
|
))
|
||||||
|
->add("price_with_tax", "number", array(
|
||||||
|
"label" => Translator::getInstance()->trans("Product price including taxes"),
|
||||||
|
"label_attr" => array("for" => "price_with_tax_field")
|
||||||
|
))
|
||||||
->add("currency", "integer", array(
|
->add("currency", "integer", array(
|
||||||
"constraints" => array(new NotBlank()),
|
"constraints" => array(new NotBlank()),
|
||||||
"label" => Translator::getInstance()->trans("Price currency *"),
|
"label" => Translator::getInstance()->trans("Price currency *"),
|
||||||
@@ -73,9 +77,13 @@ class ProductSaleElementUpdateForm extends BaseForm
|
|||||||
"label_attr" => array("for" => "quantity_field")
|
"label_attr" => array("for" => "quantity_field")
|
||||||
))
|
))
|
||||||
->add("sale_price", "number", array(
|
->add("sale_price", "number", array(
|
||||||
"label" => Translator::getInstance()->trans("Sale price without taxes *"),
|
"label" => Translator::getInstance()->trans("Sale price without taxes"),
|
||||||
"label_attr" => array("for" => "price_with_tax_field")
|
"label_attr" => array("for" => "price_with_tax_field")
|
||||||
))
|
))
|
||||||
|
->add("sale_price_with_tax", "number", array(
|
||||||
|
"label" => Translator::getInstance()->trans("Sale price including taxes"),
|
||||||
|
"label_attr" => array("for" => "sale_price_with_tax_field")
|
||||||
|
))
|
||||||
->add("onsale", "integer", array(
|
->add("onsale", "integer", array(
|
||||||
"label" => Translator::getInstance()->trans("This product is on sale"),
|
"label" => Translator::getInstance()->trans("This product is on sale"),
|
||||||
"label_attr" => array("for" => "onsale_field")
|
"label_attr" => array("for" => "onsale_field")
|
||||||
@@ -88,7 +96,7 @@ class ProductSaleElementUpdateForm extends BaseForm
|
|||||||
"label" => Translator::getInstance()->trans("Is it the default product sale element ?"),
|
"label" => Translator::getInstance()->trans("Is it the default product sale element ?"),
|
||||||
"label_attr" => array("for" => "isdefault_field")
|
"label_attr" => array("for" => "isdefault_field")
|
||||||
))
|
))
|
||||||
->add("ean_code", "integer", array(
|
->add("ean_code", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("EAN Code"),
|
"label" => Translator::getInstance()->trans("EAN Code"),
|
||||||
"label_attr" => array("for" => "ean_code_field")
|
"label_attr" => array("for" => "ean_code_field")
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Thelia\Model\Base;
|
namespace Thelia\Model\Base;
|
||||||
|
|
||||||
|
use \DateTime;
|
||||||
use \Exception;
|
use \Exception;
|
||||||
use \PDO;
|
use \PDO;
|
||||||
use Propel\Runtime\Propel;
|
use Propel\Runtime\Propel;
|
||||||
@@ -14,6 +15,8 @@ use Propel\Runtime\Exception\BadMethodCallException;
|
|||||||
use Propel\Runtime\Exception\PropelException;
|
use Propel\Runtime\Exception\PropelException;
|
||||||
use Propel\Runtime\Map\TableMap;
|
use Propel\Runtime\Map\TableMap;
|
||||||
use Propel\Runtime\Parser\AbstractParser;
|
use Propel\Runtime\Parser\AbstractParser;
|
||||||
|
use Propel\Runtime\Util\PropelDateTime;
|
||||||
|
use Thelia\Model\Newsletter as ChildNewsletter;
|
||||||
use Thelia\Model\NewsletterQuery as ChildNewsletterQuery;
|
use Thelia\Model\NewsletterQuery as ChildNewsletterQuery;
|
||||||
use Thelia\Model\Map\NewsletterTableMap;
|
use Thelia\Model\Map\NewsletterTableMap;
|
||||||
|
|
||||||
@@ -75,6 +78,24 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
*/
|
*/
|
||||||
protected $lastname;
|
protected $lastname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the locale field.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the created_at field.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $created_at;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the updated_at field.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $updated_at;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to prevent endless save loop, if this object is referenced
|
* Flag to prevent endless save loop, if this object is referenced
|
||||||
* by another object which falls in this transaction.
|
* by another object which falls in this transaction.
|
||||||
@@ -385,6 +406,57 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
return $this->lastname;
|
return $this->lastname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [locale] column value.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getLocale()
|
||||||
|
{
|
||||||
|
|
||||||
|
return $this->locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [created_at] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw \DateTime object will be returned.
|
||||||
|
*
|
||||||
|
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
|
||||||
|
*
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getCreatedAt($format = NULL)
|
||||||
|
{
|
||||||
|
if ($format === null) {
|
||||||
|
return $this->created_at;
|
||||||
|
} else {
|
||||||
|
return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [updated_at] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw \DateTime object will be returned.
|
||||||
|
*
|
||||||
|
* @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
|
||||||
|
*
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getUpdatedAt($format = NULL)
|
||||||
|
{
|
||||||
|
if ($format === null) {
|
||||||
|
return $this->updated_at;
|
||||||
|
} else {
|
||||||
|
return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of [id] column.
|
* Set the value of [id] column.
|
||||||
*
|
*
|
||||||
@@ -469,6 +541,69 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
return $this;
|
return $this;
|
||||||
} // setLastname()
|
} // setLastname()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [locale] column.
|
||||||
|
*
|
||||||
|
* @param string $v new value
|
||||||
|
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setLocale($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (string) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->locale !== $v) {
|
||||||
|
$this->locale = $v;
|
||||||
|
$this->modifiedColumns[] = NewsletterTableMap::LOCALE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setLocale()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
||||||
|
*
|
||||||
|
* @param mixed $v string, integer (timestamp), or \DateTime value.
|
||||||
|
* Empty strings are treated as NULL.
|
||||||
|
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setCreatedAt($v)
|
||||||
|
{
|
||||||
|
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
|
||||||
|
if ($this->created_at !== null || $dt !== null) {
|
||||||
|
if ($dt !== $this->created_at) {
|
||||||
|
$this->created_at = $dt;
|
||||||
|
$this->modifiedColumns[] = NewsletterTableMap::CREATED_AT;
|
||||||
|
}
|
||||||
|
} // if either are not null
|
||||||
|
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setCreatedAt()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of [updated_at] column to a normalized version of the date/time value specified.
|
||||||
|
*
|
||||||
|
* @param mixed $v string, integer (timestamp), or \DateTime value.
|
||||||
|
* Empty strings are treated as NULL.
|
||||||
|
* @return \Thelia\Model\Newsletter The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setUpdatedAt($v)
|
||||||
|
{
|
||||||
|
$dt = PropelDateTime::newInstance($v, null, '\DateTime');
|
||||||
|
if ($this->updated_at !== null || $dt !== null) {
|
||||||
|
if ($dt !== $this->updated_at) {
|
||||||
|
$this->updated_at = $dt;
|
||||||
|
$this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT;
|
||||||
|
}
|
||||||
|
} // if either are not null
|
||||||
|
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setUpdatedAt()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the columns in this object are only set to default values.
|
* Indicates whether the columns in this object are only set to default values.
|
||||||
*
|
*
|
||||||
@@ -517,6 +652,21 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
|
|
||||||
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : NewsletterTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : NewsletterTableMap::translateFieldName('Lastname', TableMap::TYPE_PHPNAME, $indexType)];
|
||||||
$this->lastname = (null !== $col) ? (string) $col : null;
|
$this->lastname = (null !== $col) ? (string) $col : null;
|
||||||
|
|
||||||
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : NewsletterTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)];
|
||||||
|
$this->locale = (null !== $col) ? (string) $col : null;
|
||||||
|
|
||||||
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : NewsletterTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||||
|
if ($col === '0000-00-00 00:00:00') {
|
||||||
|
$col = null;
|
||||||
|
}
|
||||||
|
$this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||||
|
|
||||||
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : NewsletterTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)];
|
||||||
|
if ($col === '0000-00-00 00:00:00') {
|
||||||
|
$col = null;
|
||||||
|
}
|
||||||
|
$this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null;
|
||||||
$this->resetModified();
|
$this->resetModified();
|
||||||
|
|
||||||
$this->setNew(false);
|
$this->setNew(false);
|
||||||
@@ -525,7 +675,7 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
$this->ensureConsistency();
|
$this->ensureConsistency();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $startcol + 4; // 4 = NewsletterTableMap::NUM_HYDRATE_COLUMNS.
|
return $startcol + 7; // 7 = NewsletterTableMap::NUM_HYDRATE_COLUMNS.
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new PropelException("Error populating \Thelia\Model\Newsletter object", 0, $e);
|
throw new PropelException("Error populating \Thelia\Model\Newsletter object", 0, $e);
|
||||||
@@ -656,8 +806,19 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
$ret = $this->preSave($con);
|
$ret = $this->preSave($con);
|
||||||
if ($isInsert) {
|
if ($isInsert) {
|
||||||
$ret = $ret && $this->preInsert($con);
|
$ret = $ret && $this->preInsert($con);
|
||||||
|
// timestampable behavior
|
||||||
|
if (!$this->isColumnModified(NewsletterTableMap::CREATED_AT)) {
|
||||||
|
$this->setCreatedAt(time());
|
||||||
|
}
|
||||||
|
if (!$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||||
|
$this->setUpdatedAt(time());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret = $ret && $this->preUpdate($con);
|
$ret = $ret && $this->preUpdate($con);
|
||||||
|
// timestampable behavior
|
||||||
|
if ($this->isModified() && !$this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||||
|
$this->setUpdatedAt(time());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($ret) {
|
if ($ret) {
|
||||||
$affectedRows = $this->doSave($con);
|
$affectedRows = $this->doSave($con);
|
||||||
@@ -746,6 +907,15 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) {
|
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) {
|
||||||
$modifiedColumns[':p' . $index++] = 'LASTNAME';
|
$modifiedColumns[':p' . $index++] = 'LASTNAME';
|
||||||
}
|
}
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::LOCALE)) {
|
||||||
|
$modifiedColumns[':p' . $index++] = 'LOCALE';
|
||||||
|
}
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) {
|
||||||
|
$modifiedColumns[':p' . $index++] = 'CREATED_AT';
|
||||||
|
}
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) {
|
||||||
|
$modifiedColumns[':p' . $index++] = 'UPDATED_AT';
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'INSERT INTO newsletter (%s) VALUES (%s)',
|
'INSERT INTO newsletter (%s) VALUES (%s)',
|
||||||
@@ -769,6 +939,15 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
case 'LASTNAME':
|
case 'LASTNAME':
|
||||||
$stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
|
$stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR);
|
||||||
break;
|
break;
|
||||||
|
case 'LOCALE':
|
||||||
|
$stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
|
||||||
|
break;
|
||||||
|
case 'CREATED_AT':
|
||||||
|
$stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||||
|
break;
|
||||||
|
case 'UPDATED_AT':
|
||||||
|
$stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -843,6 +1022,15 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
case 3:
|
case 3:
|
||||||
return $this->getLastname();
|
return $this->getLastname();
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
return $this->getLocale();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
return $this->getCreatedAt();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
return $this->getUpdatedAt();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
break;
|
break;
|
||||||
@@ -875,6 +1063,9 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
$keys[1] => $this->getEmail(),
|
$keys[1] => $this->getEmail(),
|
||||||
$keys[2] => $this->getFirstname(),
|
$keys[2] => $this->getFirstname(),
|
||||||
$keys[3] => $this->getLastname(),
|
$keys[3] => $this->getLastname(),
|
||||||
|
$keys[4] => $this->getLocale(),
|
||||||
|
$keys[5] => $this->getCreatedAt(),
|
||||||
|
$keys[6] => $this->getUpdatedAt(),
|
||||||
);
|
);
|
||||||
$virtualColumns = $this->virtualColumns;
|
$virtualColumns = $this->virtualColumns;
|
||||||
foreach ($virtualColumns as $key => $virtualColumn) {
|
foreach ($virtualColumns as $key => $virtualColumn) {
|
||||||
@@ -926,6 +1117,15 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
case 3:
|
case 3:
|
||||||
$this->setLastname($value);
|
$this->setLastname($value);
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
$this->setLocale($value);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
$this->setCreatedAt($value);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
$this->setUpdatedAt($value);
|
||||||
|
break;
|
||||||
} // switch()
|
} // switch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,6 +1154,9 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
if (array_key_exists($keys[1], $arr)) $this->setEmail($arr[$keys[1]]);
|
if (array_key_exists($keys[1], $arr)) $this->setEmail($arr[$keys[1]]);
|
||||||
if (array_key_exists($keys[2], $arr)) $this->setFirstname($arr[$keys[2]]);
|
if (array_key_exists($keys[2], $arr)) $this->setFirstname($arr[$keys[2]]);
|
||||||
if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]);
|
if (array_key_exists($keys[3], $arr)) $this->setLastname($arr[$keys[3]]);
|
||||||
|
if (array_key_exists($keys[4], $arr)) $this->setLocale($arr[$keys[4]]);
|
||||||
|
if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]);
|
||||||
|
if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -969,6 +1172,9 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
if ($this->isColumnModified(NewsletterTableMap::EMAIL)) $criteria->add(NewsletterTableMap::EMAIL, $this->email);
|
if ($this->isColumnModified(NewsletterTableMap::EMAIL)) $criteria->add(NewsletterTableMap::EMAIL, $this->email);
|
||||||
if ($this->isColumnModified(NewsletterTableMap::FIRSTNAME)) $criteria->add(NewsletterTableMap::FIRSTNAME, $this->firstname);
|
if ($this->isColumnModified(NewsletterTableMap::FIRSTNAME)) $criteria->add(NewsletterTableMap::FIRSTNAME, $this->firstname);
|
||||||
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) $criteria->add(NewsletterTableMap::LASTNAME, $this->lastname);
|
if ($this->isColumnModified(NewsletterTableMap::LASTNAME)) $criteria->add(NewsletterTableMap::LASTNAME, $this->lastname);
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::LOCALE)) $criteria->add(NewsletterTableMap::LOCALE, $this->locale);
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::CREATED_AT)) $criteria->add(NewsletterTableMap::CREATED_AT, $this->created_at);
|
||||||
|
if ($this->isColumnModified(NewsletterTableMap::UPDATED_AT)) $criteria->add(NewsletterTableMap::UPDATED_AT, $this->updated_at);
|
||||||
|
|
||||||
return $criteria;
|
return $criteria;
|
||||||
}
|
}
|
||||||
@@ -1035,6 +1241,9 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
$copyObj->setEmail($this->getEmail());
|
$copyObj->setEmail($this->getEmail());
|
||||||
$copyObj->setFirstname($this->getFirstname());
|
$copyObj->setFirstname($this->getFirstname());
|
||||||
$copyObj->setLastname($this->getLastname());
|
$copyObj->setLastname($this->getLastname());
|
||||||
|
$copyObj->setLocale($this->getLocale());
|
||||||
|
$copyObj->setCreatedAt($this->getCreatedAt());
|
||||||
|
$copyObj->setUpdatedAt($this->getUpdatedAt());
|
||||||
if ($makeNew) {
|
if ($makeNew) {
|
||||||
$copyObj->setNew(true);
|
$copyObj->setNew(true);
|
||||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||||
@@ -1072,6 +1281,9 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
$this->email = null;
|
$this->email = null;
|
||||||
$this->firstname = null;
|
$this->firstname = null;
|
||||||
$this->lastname = null;
|
$this->lastname = null;
|
||||||
|
$this->locale = null;
|
||||||
|
$this->created_at = null;
|
||||||
|
$this->updated_at = null;
|
||||||
$this->alreadyInSave = false;
|
$this->alreadyInSave = false;
|
||||||
$this->clearAllReferences();
|
$this->clearAllReferences();
|
||||||
$this->resetModified();
|
$this->resetModified();
|
||||||
@@ -1105,6 +1317,20 @@ abstract class Newsletter implements ActiveRecordInterface
|
|||||||
return (string) $this->exportTo(NewsletterTableMap::DEFAULT_STRING_FORMAT);
|
return (string) $this->exportTo(NewsletterTableMap::DEFAULT_STRING_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timestampable behavior
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the current object so that the update date doesn't get updated during next save
|
||||||
|
*
|
||||||
|
* @return ChildNewsletter The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function keepUpdateDateUnchanged()
|
||||||
|
{
|
||||||
|
$this->modifiedColumns[] = NewsletterTableMap::UPDATED_AT;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code to be run before persisting the object
|
* Code to be run before persisting the object
|
||||||
* @param ConnectionInterface $con
|
* @param ConnectionInterface $con
|
||||||
|
|||||||
@@ -22,11 +22,17 @@ use Thelia\Model\Map\NewsletterTableMap;
|
|||||||
* @method ChildNewsletterQuery orderByEmail($order = Criteria::ASC) Order by the email column
|
* @method ChildNewsletterQuery orderByEmail($order = Criteria::ASC) Order by the email column
|
||||||
* @method ChildNewsletterQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
|
* @method ChildNewsletterQuery orderByFirstname($order = Criteria::ASC) Order by the firstname column
|
||||||
* @method ChildNewsletterQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
|
* @method ChildNewsletterQuery orderByLastname($order = Criteria::ASC) Order by the lastname column
|
||||||
|
* @method ChildNewsletterQuery orderByLocale($order = Criteria::ASC) Order by the locale column
|
||||||
|
* @method ChildNewsletterQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
|
||||||
|
* @method ChildNewsletterQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
|
||||||
*
|
*
|
||||||
* @method ChildNewsletterQuery groupById() Group by the id column
|
* @method ChildNewsletterQuery groupById() Group by the id column
|
||||||
* @method ChildNewsletterQuery groupByEmail() Group by the email column
|
* @method ChildNewsletterQuery groupByEmail() Group by the email column
|
||||||
* @method ChildNewsletterQuery groupByFirstname() Group by the firstname column
|
* @method ChildNewsletterQuery groupByFirstname() Group by the firstname column
|
||||||
* @method ChildNewsletterQuery groupByLastname() Group by the lastname column
|
* @method ChildNewsletterQuery groupByLastname() Group by the lastname column
|
||||||
|
* @method ChildNewsletterQuery groupByLocale() Group by the locale column
|
||||||
|
* @method ChildNewsletterQuery groupByCreatedAt() Group by the created_at column
|
||||||
|
* @method ChildNewsletterQuery groupByUpdatedAt() Group by the updated_at column
|
||||||
*
|
*
|
||||||
* @method ChildNewsletterQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
* @method ChildNewsletterQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||||
* @method ChildNewsletterQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
* @method ChildNewsletterQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||||
@@ -39,11 +45,17 @@ use Thelia\Model\Map\NewsletterTableMap;
|
|||||||
* @method ChildNewsletter findOneByEmail(string $email) Return the first ChildNewsletter filtered by the email column
|
* @method ChildNewsletter findOneByEmail(string $email) Return the first ChildNewsletter filtered by the email column
|
||||||
* @method ChildNewsletter findOneByFirstname(string $firstname) Return the first ChildNewsletter filtered by the firstname column
|
* @method ChildNewsletter findOneByFirstname(string $firstname) Return the first ChildNewsletter filtered by the firstname column
|
||||||
* @method ChildNewsletter findOneByLastname(string $lastname) Return the first ChildNewsletter filtered by the lastname column
|
* @method ChildNewsletter findOneByLastname(string $lastname) Return the first ChildNewsletter filtered by the lastname column
|
||||||
|
* @method ChildNewsletter findOneByLocale(string $locale) Return the first ChildNewsletter filtered by the locale column
|
||||||
|
* @method ChildNewsletter findOneByCreatedAt(string $created_at) Return the first ChildNewsletter filtered by the created_at column
|
||||||
|
* @method ChildNewsletter findOneByUpdatedAt(string $updated_at) Return the first ChildNewsletter filtered by the updated_at column
|
||||||
*
|
*
|
||||||
* @method array findById(int $id) Return ChildNewsletter objects filtered by the id column
|
* @method array findById(int $id) Return ChildNewsletter objects filtered by the id column
|
||||||
* @method array findByEmail(string $email) Return ChildNewsletter objects filtered by the email column
|
* @method array findByEmail(string $email) Return ChildNewsletter objects filtered by the email column
|
||||||
* @method array findByFirstname(string $firstname) Return ChildNewsletter objects filtered by the firstname column
|
* @method array findByFirstname(string $firstname) Return ChildNewsletter objects filtered by the firstname column
|
||||||
* @method array findByLastname(string $lastname) Return ChildNewsletter objects filtered by the lastname column
|
* @method array findByLastname(string $lastname) Return ChildNewsletter objects filtered by the lastname column
|
||||||
|
* @method array findByLocale(string $locale) Return ChildNewsletter objects filtered by the locale column
|
||||||
|
* @method array findByCreatedAt(string $created_at) Return ChildNewsletter objects filtered by the created_at column
|
||||||
|
* @method array findByUpdatedAt(string $updated_at) Return ChildNewsletter objects filtered by the updated_at column
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class NewsletterQuery extends ModelCriteria
|
abstract class NewsletterQuery extends ModelCriteria
|
||||||
@@ -132,7 +144,7 @@ abstract class NewsletterQuery extends ModelCriteria
|
|||||||
*/
|
*/
|
||||||
protected function findPkSimple($key, $con)
|
protected function findPkSimple($key, $con)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT ID, EMAIL, FIRSTNAME, LASTNAME FROM newsletter WHERE ID = :p0';
|
$sql = 'SELECT ID, EMAIL, FIRSTNAME, LASTNAME, LOCALE, CREATED_AT, UPDATED_AT FROM newsletter WHERE ID = :p0';
|
||||||
try {
|
try {
|
||||||
$stmt = $con->prepare($sql);
|
$stmt = $con->prepare($sql);
|
||||||
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
$stmt->bindValue(':p0', $key, PDO::PARAM_INT);
|
||||||
@@ -349,6 +361,121 @@ abstract class NewsletterQuery extends ModelCriteria
|
|||||||
return $this->addUsingAlias(NewsletterTableMap::LASTNAME, $lastname, $comparison);
|
return $this->addUsingAlias(NewsletterTableMap::LASTNAME, $lastname, $comparison);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the locale column
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
* <code>
|
||||||
|
* $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
|
||||||
|
* $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $locale The value to use as filter.
|
||||||
|
* Accepts wildcards (* and % trigger a LIKE)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByLocale($locale = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (null === $comparison) {
|
||||||
|
if (is_array($locale)) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
} elseif (preg_match('/[\%\*]/', $locale)) {
|
||||||
|
$locale = str_replace('*', '%', $locale);
|
||||||
|
$comparison = Criteria::LIKE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->addUsingAlias(NewsletterTableMap::LOCALE, $locale, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the created_at column
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
* <code>
|
||||||
|
* $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
|
||||||
|
* $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
|
||||||
|
* $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param mixed $createdAt The value to use as filter.
|
||||||
|
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||||
|
* Empty strings are treated as NULL.
|
||||||
|
* Use scalar values for equality.
|
||||||
|
* Use array values for in_array() equivalent.
|
||||||
|
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByCreatedAt($createdAt = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($createdAt)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($createdAt['min'])) {
|
||||||
|
$this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($createdAt['max'])) {
|
||||||
|
$this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, $createdAt, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the updated_at column
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
* <code>
|
||||||
|
* $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
|
||||||
|
* $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
|
||||||
|
* $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param mixed $updatedAt The value to use as filter.
|
||||||
|
* Values can be integers (unix timestamps), DateTime objects, or strings.
|
||||||
|
* Empty strings are treated as NULL.
|
||||||
|
* Use scalar values for equality.
|
||||||
|
* Use array values for in_array() equivalent.
|
||||||
|
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByUpdatedAt($updatedAt = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($updatedAt)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($updatedAt['min'])) {
|
||||||
|
$this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($updatedAt['max'])) {
|
||||||
|
$this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, $updatedAt, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclude object from result
|
* Exclude object from result
|
||||||
*
|
*
|
||||||
@@ -440,4 +567,70 @@ abstract class NewsletterQuery extends ModelCriteria
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timestampable behavior
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by the latest updated
|
||||||
|
*
|
||||||
|
* @param int $nbDays Maximum age of the latest update in days
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function recentlyUpdated($nbDays = 7)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(NewsletterTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter by the latest created
|
||||||
|
*
|
||||||
|
* @param int $nbDays Maximum age of in days
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function recentlyCreated($nbDays = 7)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(NewsletterTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order by update date desc
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function lastUpdatedFirst()
|
||||||
|
{
|
||||||
|
return $this->addDescendingOrderByColumn(NewsletterTableMap::UPDATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order by update date asc
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function firstUpdatedFirst()
|
||||||
|
{
|
||||||
|
return $this->addAscendingOrderByColumn(NewsletterTableMap::UPDATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order by create date desc
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function lastCreatedFirst()
|
||||||
|
{
|
||||||
|
return $this->addDescendingOrderByColumn(NewsletterTableMap::CREATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order by create date asc
|
||||||
|
*
|
||||||
|
* @return ChildNewsletterQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function firstCreatedFirst()
|
||||||
|
{
|
||||||
|
return $this->addAscendingOrderByColumn(NewsletterTableMap::CREATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
} // NewsletterQuery
|
} // NewsletterQuery
|
||||||
|
|||||||
@@ -72,19 +72,21 @@ abstract class ProductPrice implements ActiveRecordInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the price field.
|
* The value for the price field.
|
||||||
|
* Note: this column has a database default value of: 0
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
protected $price;
|
protected $price;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the promo_price field.
|
* The value for the promo_price field.
|
||||||
|
* Note: this column has a database default value of: 0
|
||||||
* @var double
|
* @var double
|
||||||
*/
|
*/
|
||||||
protected $promo_price;
|
protected $promo_price;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the from_default_currency field.
|
* The value for the from_default_currency field.
|
||||||
* Note: this column has a database default value of: false
|
* Note: this column has a database default value of: true
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $from_default_currency;
|
protected $from_default_currency;
|
||||||
@@ -127,7 +129,9 @@ abstract class ProductPrice implements ActiveRecordInterface
|
|||||||
*/
|
*/
|
||||||
public function applyDefaultValues()
|
public function applyDefaultValues()
|
||||||
{
|
{
|
||||||
$this->from_default_currency = false;
|
$this->price = 0;
|
||||||
|
$this->promo_price = 0;
|
||||||
|
$this->from_default_currency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -658,7 +662,15 @@ abstract class ProductPrice implements ActiveRecordInterface
|
|||||||
*/
|
*/
|
||||||
public function hasOnlyDefaultValues()
|
public function hasOnlyDefaultValues()
|
||||||
{
|
{
|
||||||
if ($this->from_default_currency !== false) {
|
if ($this->price !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->promo_price !== 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->from_default_currency !== true) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class NewsletterTableMap extends TableMap
|
|||||||
/**
|
/**
|
||||||
* The total number of columns
|
* The total number of columns
|
||||||
*/
|
*/
|
||||||
const NUM_COLUMNS = 4;
|
const NUM_COLUMNS = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of lazy-loaded columns
|
* The number of lazy-loaded columns
|
||||||
@@ -67,7 +67,7 @@ class NewsletterTableMap extends TableMap
|
|||||||
/**
|
/**
|
||||||
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS)
|
||||||
*/
|
*/
|
||||||
const NUM_HYDRATE_COLUMNS = 4;
|
const NUM_HYDRATE_COLUMNS = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the column name for the ID field
|
* the column name for the ID field
|
||||||
@@ -89,6 +89,21 @@ class NewsletterTableMap extends TableMap
|
|||||||
*/
|
*/
|
||||||
const LASTNAME = 'newsletter.LASTNAME';
|
const LASTNAME = 'newsletter.LASTNAME';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the column name for the LOCALE field
|
||||||
|
*/
|
||||||
|
const LOCALE = 'newsletter.LOCALE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the column name for the CREATED_AT field
|
||||||
|
*/
|
||||||
|
const CREATED_AT = 'newsletter.CREATED_AT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the column name for the UPDATED_AT field
|
||||||
|
*/
|
||||||
|
const UPDATED_AT = 'newsletter.UPDATED_AT';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default string format for model objects of the related table
|
* The default string format for model objects of the related table
|
||||||
*/
|
*/
|
||||||
@@ -101,12 +116,12 @@ class NewsletterTableMap extends TableMap
|
|||||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||||
*/
|
*/
|
||||||
protected static $fieldNames = array (
|
protected static $fieldNames = array (
|
||||||
self::TYPE_PHPNAME => array('Id', 'Email', 'Firstname', 'Lastname', ),
|
self::TYPE_PHPNAME => array('Id', 'Email', 'Firstname', 'Lastname', 'Locale', 'CreatedAt', 'UpdatedAt', ),
|
||||||
self::TYPE_STUDLYPHPNAME => array('id', 'email', 'firstname', 'lastname', ),
|
self::TYPE_STUDLYPHPNAME => array('id', 'email', 'firstname', 'lastname', 'locale', 'createdAt', 'updatedAt', ),
|
||||||
self::TYPE_COLNAME => array(NewsletterTableMap::ID, NewsletterTableMap::EMAIL, NewsletterTableMap::FIRSTNAME, NewsletterTableMap::LASTNAME, ),
|
self::TYPE_COLNAME => array(NewsletterTableMap::ID, NewsletterTableMap::EMAIL, NewsletterTableMap::FIRSTNAME, NewsletterTableMap::LASTNAME, NewsletterTableMap::LOCALE, NewsletterTableMap::CREATED_AT, NewsletterTableMap::UPDATED_AT, ),
|
||||||
self::TYPE_RAW_COLNAME => array('ID', 'EMAIL', 'FIRSTNAME', 'LASTNAME', ),
|
self::TYPE_RAW_COLNAME => array('ID', 'EMAIL', 'FIRSTNAME', 'LASTNAME', 'LOCALE', 'CREATED_AT', 'UPDATED_AT', ),
|
||||||
self::TYPE_FIELDNAME => array('id', 'email', 'firstname', 'lastname', ),
|
self::TYPE_FIELDNAME => array('id', 'email', 'firstname', 'lastname', 'locale', 'created_at', 'updated_at', ),
|
||||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,12 +131,12 @@ class NewsletterTableMap extends TableMap
|
|||||||
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0
|
||||||
*/
|
*/
|
||||||
protected static $fieldKeys = array (
|
protected static $fieldKeys = array (
|
||||||
self::TYPE_PHPNAME => array('Id' => 0, 'Email' => 1, 'Firstname' => 2, 'Lastname' => 3, ),
|
self::TYPE_PHPNAME => array('Id' => 0, 'Email' => 1, 'Firstname' => 2, 'Lastname' => 3, 'Locale' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ),
|
||||||
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, ),
|
self::TYPE_STUDLYPHPNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, 'locale' => 4, 'createdAt' => 5, 'updatedAt' => 6, ),
|
||||||
self::TYPE_COLNAME => array(NewsletterTableMap::ID => 0, NewsletterTableMap::EMAIL => 1, NewsletterTableMap::FIRSTNAME => 2, NewsletterTableMap::LASTNAME => 3, ),
|
self::TYPE_COLNAME => array(NewsletterTableMap::ID => 0, NewsletterTableMap::EMAIL => 1, NewsletterTableMap::FIRSTNAME => 2, NewsletterTableMap::LASTNAME => 3, NewsletterTableMap::LOCALE => 4, NewsletterTableMap::CREATED_AT => 5, NewsletterTableMap::UPDATED_AT => 6, ),
|
||||||
self::TYPE_RAW_COLNAME => array('ID' => 0, 'EMAIL' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, ),
|
self::TYPE_RAW_COLNAME => array('ID' => 0, 'EMAIL' => 1, 'FIRSTNAME' => 2, 'LASTNAME' => 3, 'LOCALE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ),
|
||||||
self::TYPE_FIELDNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, ),
|
self::TYPE_FIELDNAME => array('id' => 0, 'email' => 1, 'firstname' => 2, 'lastname' => 3, 'locale' => 4, 'created_at' => 5, 'updated_at' => 6, ),
|
||||||
self::TYPE_NUM => array(0, 1, 2, 3, )
|
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, )
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,6 +159,9 @@ class NewsletterTableMap extends TableMap
|
|||||||
$this->addColumn('EMAIL', 'Email', 'VARCHAR', true, 255, null);
|
$this->addColumn('EMAIL', 'Email', 'VARCHAR', true, 255, null);
|
||||||
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', false, 255, null);
|
$this->addColumn('FIRSTNAME', 'Firstname', 'VARCHAR', false, 255, null);
|
||||||
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', false, 255, null);
|
$this->addColumn('LASTNAME', 'Lastname', 'VARCHAR', false, 255, null);
|
||||||
|
$this->addColumn('LOCALE', 'Locale', 'VARCHAR', false, 5, null);
|
||||||
|
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||||
|
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||||
} // initialize()
|
} // initialize()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,6 +171,19 @@ class NewsletterTableMap extends TableMap
|
|||||||
{
|
{
|
||||||
} // buildRelations()
|
} // buildRelations()
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Gets the list of behaviors registered for this table
|
||||||
|
*
|
||||||
|
* @return array Associative array (name => parameters) of behaviors
|
||||||
|
*/
|
||||||
|
public function getBehaviors()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ),
|
||||||
|
);
|
||||||
|
} // getBehaviors()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||||
*
|
*
|
||||||
@@ -295,11 +326,17 @@ class NewsletterTableMap extends TableMap
|
|||||||
$criteria->addSelectColumn(NewsletterTableMap::EMAIL);
|
$criteria->addSelectColumn(NewsletterTableMap::EMAIL);
|
||||||
$criteria->addSelectColumn(NewsletterTableMap::FIRSTNAME);
|
$criteria->addSelectColumn(NewsletterTableMap::FIRSTNAME);
|
||||||
$criteria->addSelectColumn(NewsletterTableMap::LASTNAME);
|
$criteria->addSelectColumn(NewsletterTableMap::LASTNAME);
|
||||||
|
$criteria->addSelectColumn(NewsletterTableMap::LOCALE);
|
||||||
|
$criteria->addSelectColumn(NewsletterTableMap::CREATED_AT);
|
||||||
|
$criteria->addSelectColumn(NewsletterTableMap::UPDATED_AT);
|
||||||
} else {
|
} else {
|
||||||
$criteria->addSelectColumn($alias . '.ID');
|
$criteria->addSelectColumn($alias . '.ID');
|
||||||
$criteria->addSelectColumn($alias . '.EMAIL');
|
$criteria->addSelectColumn($alias . '.EMAIL');
|
||||||
$criteria->addSelectColumn($alias . '.FIRSTNAME');
|
$criteria->addSelectColumn($alias . '.FIRSTNAME');
|
||||||
$criteria->addSelectColumn($alias . '.LASTNAME');
|
$criteria->addSelectColumn($alias . '.LASTNAME');
|
||||||
|
$criteria->addSelectColumn($alias . '.LOCALE');
|
||||||
|
$criteria->addSelectColumn($alias . '.CREATED_AT');
|
||||||
|
$criteria->addSelectColumn($alias . '.UPDATED_AT');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,9 +157,9 @@ class ProductPriceTableMap extends TableMap
|
|||||||
// columns
|
// columns
|
||||||
$this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null);
|
$this->addForeignPrimaryKey('PRODUCT_SALE_ELEMENTS_ID', 'ProductSaleElementsId', 'INTEGER' , 'product_sale_elements', 'ID', true, null, null);
|
||||||
$this->addForeignPrimaryKey('CURRENCY_ID', 'CurrencyId', 'INTEGER' , 'currency', 'ID', true, null, null);
|
$this->addForeignPrimaryKey('CURRENCY_ID', 'CurrencyId', 'INTEGER' , 'currency', 'ID', true, null, null);
|
||||||
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, null);
|
$this->addColumn('PRICE', 'Price', 'FLOAT', true, null, 0);
|
||||||
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', false, null, null);
|
$this->addColumn('PROMO_PRICE', 'PromoPrice', 'FLOAT', true, null, 0);
|
||||||
$this->addColumn('FROM_DEFAULT_CURRENCY', 'FromDefaultCurrency', 'BOOLEAN', true, 1, false);
|
$this->addColumn('FROM_DEFAULT_CURRENCY', 'FromDefaultCurrency', 'BOOLEAN', true, 1, true);
|
||||||
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
$this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null);
|
||||||
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
$this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null);
|
||||||
} // initialize()
|
} // initialize()
|
||||||
|
|||||||
@@ -1270,9 +1270,9 @@ CREATE TABLE `product_price`
|
|||||||
(
|
(
|
||||||
`product_sale_elements_id` INTEGER NOT NULL,
|
`product_sale_elements_id` INTEGER NOT NULL,
|
||||||
`currency_id` INTEGER NOT NULL,
|
`currency_id` INTEGER NOT NULL,
|
||||||
`price` FLOAT NOT NULL,
|
`price` FLOAT DEFAULT 0 NOT NULL,
|
||||||
`promo_price` FLOAT,
|
`promo_price` FLOAT DEFAULT 0 NOT NULL,
|
||||||
`from_default_currency` TINYINT(1) DEFAULT 0 NOT NULL,
|
`from_default_currency` TINYINT(1) DEFAULT 1 NOT NULL,
|
||||||
`created_at` DATETIME,
|
`created_at` DATETIME,
|
||||||
`updated_at` DATETIME,
|
`updated_at` DATETIME,
|
||||||
PRIMARY KEY (`product_sale_elements_id`,`currency_id`),
|
PRIMARY KEY (`product_sale_elements_id`,`currency_id`),
|
||||||
@@ -1607,7 +1607,11 @@ CREATE TABLE `newsletter`
|
|||||||
`email` VARCHAR(255) NOT NULL,
|
`email` VARCHAR(255) NOT NULL,
|
||||||
`firstname` VARCHAR(255),
|
`firstname` VARCHAR(255),
|
||||||
`lastname` VARCHAR(255),
|
`lastname` VARCHAR(255),
|
||||||
PRIMARY KEY (`id`)
|
`locale` VARCHAR(5),
|
||||||
|
`created_at` DATETIME,
|
||||||
|
`updated_at` DATETIME,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE INDEX `email_UNIQUE` (`email`)
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -83,7 +83,7 @@
|
|||||||
<select id="tax_rule_field" required="required" name="{$name}" class="form-control">
|
<select id="tax_rule_field" required="required" name="{$name}" class="form-control">
|
||||||
<option value="">{intl l="Select a tax tule"}</option>
|
<option value="">{intl l="Select a tax tule"}</option>
|
||||||
{loop name="tax" type="tax-rule" backend_context="1"}
|
{loop name="tax" type="tax-rule" backend_context="1"}
|
||||||
<option value="{$ID}" {if $IS_DEFAULT}selected="selected"{/if}>{$TITLE}</option>
|
<option value="{$ID}" {if $ID == $TAX_RULE_ID}selected="selected"{/if}>{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="use_exchange_rate_box" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
|
<input type="checkbox" data-pse-id="{$default_product_sale_element_id}" class="use_exchange_rate_box" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
|
||||||
{$label}
|
{$label}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -129,19 +129,21 @@
|
|||||||
<label for="price_without_tax" class="control-label">{$label} : </label>
|
<label for="price_without_tax" class="control-label">{$label} : </label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input {if !$show_pricing_fields}readonly{/if} data-price-type="without-tax" data-rel-price="price_with_tax" type="text" id="price_without_tax" required="required" name="{$name}" class="automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Price excl. taxes'}">
|
<input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="price-without-tax" data-rel-price="price_with_tax" type="text" id="price_without_tax" required="required" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Price excl. taxes'}">
|
||||||
<span class="input-group-addon">{$currency_symbol}</span>
|
<span class="input-group-addon">{$currency_symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
<div class="form-group">
|
{form_field form=$form field='price_with_tax'}
|
||||||
<label for="price_with_tax" class="control-label">{intl l="Product price including taxes"} : </label>
|
<div class="form-group">
|
||||||
<div class="input-group">
|
<label for="price_with_tax" class="control-label">{intl l="Product price including taxes"} : </label>
|
||||||
<input {if !$show_pricing_fields}readonly{/if} data-price-type="with-tax" data-rel-price="price_without_tax" type="text" id="price_with_tax" name="price_with_tax" class="automatic_price_field form-control" value="" title="{intl l='Product price including taxes'}" placeholder="{intl l='Price incl. taxes'}">
|
<div class="input-group">
|
||||||
<span class="input-group-addon">{$currency_symbol}</span>
|
<input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="price-with-tax" data-rel-price="price_without_tax" type="text" id="price_with_tax" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$value}" placeholder="{intl l='Price incl. taxes'}">
|
||||||
</div>
|
<span class="input-group-addon">{$currency_symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
{module_include location='product_details_pricing_form'}
|
{module_include location='product_details_pricing_form'}
|
||||||
</div>
|
</div>
|
||||||
@@ -203,19 +205,21 @@
|
|||||||
<label for="sale_price_without_tax" class="control-label">{$label} : </label>
|
<label for="sale_price_without_tax" class="control-label">{$label} : </label>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input {if !$show_pricing_fields}readonly{/if} data-price-type="without-tax" data-rel-price="sale_price_with_tax" type="text" id="sale_price_without_tax" required="required" name="{$name}" class="automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
|
<input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="sale-price-without-tax" data-rel-price="sale_price_with_tax" type="text" id="sale_price_without_tax" required="required" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
|
||||||
<span class="input-group-addon">{$currency_symbol}</span>
|
<span class="input-group-addon">{$currency_symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
|
{form_field form=$form field='sale_price_with_tax'}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="sale_price_with_tax" class="control-label">{intl l="Sale price including taxes"} : </label>
|
<label for="sale_price_with_tax" class="control-label">{$label} : </label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input {if !$show_pricing_fields}readonly{/if} data-price-type="with-tax" data-rel-price="sale_price_without_tax" type="text" id="sale_price_with_tax" name="sale_price_with_tax" class="automatic_price_field form-control" value="" title="{intl l='Sale price including taxes'}" placeholder="{intl l='Sale price incl. taxes'}">
|
<input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="sale-price-with-tax" data-rel-price="sale_price_without_tax" type="text" id="sale_price_with_tax" name="sale_price_with_tax" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Sale price incl. taxes'}">
|
||||||
<span class="input-group-addon">{$currency_symbol}</span>
|
<span class="input-group-addon">{$currency_symbol}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='onsale'}
|
{form_field form=$form field='onsale'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
@@ -276,7 +280,7 @@
|
|||||||
<select id="tax_rule_field" required="required" name="{$name}" class="form-control">
|
<select id="tax_rule_field" required="required" name="{$name}" class="form-control">
|
||||||
<option value="">{intl l="Select a tax tule"}</option>
|
<option value="">{intl l="Select a tax tule"}</option>
|
||||||
{loop name="tax" type="tax-rule" backend_context="1"}
|
{loop name="tax" type="tax-rule" backend_context="1"}
|
||||||
<option value="{$ID}" {if $IS_DEFAULT}selected="selected"{/if}>{$TITLE}</option>
|
<option value="{$ID}" {if $ID == $TAX_RULE_ID}selected="selected"{/if}>{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -275,48 +275,83 @@ $(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// In details tab, process exchange rate usage checkbox changes
|
// In details tab, process exchange rate usage checkbox changes
|
||||||
$('use_exchange_rate_box').change(function(ev) {
|
$('.use_exchange_rate_box').change(function(ev) {
|
||||||
$('.')
|
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
|
||||||
|
var pse_id = $(this).data('pse-id');
|
||||||
|
|
||||||
|
$('.price_field').prop('readonly', true);
|
||||||
|
|
||||||
|
// Reload prices
|
||||||
|
$.ajax({
|
||||||
|
url : '{url path="/admin/product/load-converted-prices"}',
|
||||||
|
data : {
|
||||||
|
product_sale_element_id : pse_id,
|
||||||
|
currency_id : {$edit_currency_id}
|
||||||
|
},
|
||||||
|
type : 'get',
|
||||||
|
dataType : 'json',
|
||||||
|
success : function(json) {
|
||||||
|
console.log(json);
|
||||||
|
|
||||||
|
$('input[data-pse-id="'+pse_id+'"][data-price-type="price-with-tax"]').val(json.price_with_tax);
|
||||||
|
$('input[data-pse-id="'+pse_id+'"][data-price-type="price-without-tax"]').val(json.price_without_tax);
|
||||||
|
$('input[data-pse-id="'+pse_id+'"][data-price-type="sale-price-with-tax"]').val(json.sale_price_with_tax);
|
||||||
|
$('input[data-pse-id="'+pse_id+'"][data-price-type="sale-price-without-tax"]').val(json.sale_price_without_tax);
|
||||||
|
},
|
||||||
|
error : function(jqXHR, textStatus, errorThrown) {
|
||||||
|
alert("{intl l='Failed to get converted prices. Please try again.'} (" +errorThrown+ ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.price_field').prop('readonly', false)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function update_price(price, price_type, dest_field_id) {
|
||||||
|
var tax_rule_id = $('#tax_rule_field').val();
|
||||||
|
|
||||||
|
if (tax_rule_id != "") {
|
||||||
|
|
||||||
|
var operation;
|
||||||
|
|
||||||
|
if (price_type.indexOf('with-tax') != -1)
|
||||||
|
operation = 'from_tax';
|
||||||
|
else if (price_type.indexOf('without-tax') != -1)
|
||||||
|
operation = 'to_tax';
|
||||||
|
else
|
||||||
|
operation = '';
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url : '{url path="/admin/product/calculate-price"}',
|
||||||
|
data : {
|
||||||
|
price : price,
|
||||||
|
action : operation,
|
||||||
|
product_id : {$product_id}
|
||||||
|
},
|
||||||
|
type : 'get',
|
||||||
|
dataType : 'json',
|
||||||
|
success : function(json) {
|
||||||
|
$('#' + dest_field_id).val(json.result);
|
||||||
|
},
|
||||||
|
error : function(jqXHR, textStatus, errorThrown) {
|
||||||
|
alert("{intl l='Failed to get prices. Please try again.'} (" +errorThrown+ ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Automatic update of price fields: any change in the taxed (resp. untaxed) price
|
// Automatic update of price fields: any change in the taxed (resp. untaxed) price
|
||||||
// will update the untaxed (resp. taxed) one
|
// will update the untaxed (resp. taxed) one
|
||||||
$('.automatic_price_field').typeWatch({
|
$('.automatic_price_field').typeWatch({
|
||||||
captureLength: 1,
|
captureLength: 1,
|
||||||
callback: function () {
|
callback: function () {
|
||||||
|
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
|
||||||
var tax_rule_id = $('#tax_rule_field').val();
|
|
||||||
|
|
||||||
if (tax_rule_id != "") {
|
|
||||||
var priceType = $(this).data('price-type');
|
|
||||||
var dest_field_id = $(this).data('rel-price');
|
|
||||||
|
|
||||||
var operation;
|
|
||||||
|
|
||||||
if (priceType == 'with-tax')
|
|
||||||
operation = 'from_tax';
|
|
||||||
else if (priceType == 'without-tax')
|
|
||||||
operation = 'to_tax';
|
|
||||||
else
|
|
||||||
operation = '';
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url : '{url path="/admin/product/calculate-price"}',
|
|
||||||
data : {
|
|
||||||
price : $(this).val(),
|
|
||||||
action : operation,
|
|
||||||
tax_rule_id : $('#tax_rule_field').val()
|
|
||||||
},
|
|
||||||
type : 'get',
|
|
||||||
dataType : 'json',
|
|
||||||
success : function(json) {
|
|
||||||
$('#' + dest_field_id).val(json.result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user