From bb452c2efc31a57cb0cb4dbfd54e7da5e4befbc5 Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Thu, 23 Jan 2014 15:35:52 +0100
Subject: [PATCH 01/50] Changed "Details" by "Price"
---
CHANGELOG.md | 3 +-
.../default/includes/product-prices-tab.html | 770 ++++++++++++++++++
.../backOffice/default/product-edit.html | 10 +-
3 files changed, 777 insertions(+), 6 deletions(-)
create mode 100644 templates/backOffice/default/includes/product-prices-tab.html
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d5355019..bd7c7078c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,8 @@
#2.0.0-beta4
- Tinymce is now a dedicated module. You need to activate it.
- Fix PDF creation. Bug #180
-- Fix many translation issues.
+- Fix many translation issues.
+- The TaxManager is now a service
#2.0.0-beta3
- Coupon effect inputs are now more customisable (input text, select, ajax, etc.. are usable) and unlimited amount of input for coupon effect are now possible too
diff --git a/templates/backOffice/default/includes/product-prices-tab.html b/templates/backOffice/default/includes/product-prices-tab.html
new file mode 100644
index 000000000..32aa42af6
--- /dev/null
+++ b/templates/backOffice/default/includes/product-prices-tab.html
@@ -0,0 +1,770 @@
+
+
+{* -- Adding a new combination ------------------------------------------------- *}
+
+{* Capture the dialog body, to pass it to the generic dialog *}
+
+{capture "combination_creation_dialog"}
+
+
+
+
+
+ {intl l="Attribute"} :
+
+ {intl l='Select an attribute...'}
+ {loop name="product-attributes" type="attribute" order="manual" product=$product_id backend_context="1" lang=$edit_language_id}
+ {$TITLE}
+ {/loop}
+
+ {intl l='Select an attribute and click (+) to view available values'}
+
+
+
+
+
+ {* {intl l="Attribute values"} : *}
+
+
+ {intl l='Select an attribute value...'}
+
+
+
+
+
+
+
+
{intl l='Select a value click (+) to add it to the combination'}
+
+
+
+
+ {intl l="No available value for this attribute"}
+
+
+
+
+
+{/capture}
+
+{include
+ file = "includes/generic-create-dialog.html"
+
+ dialog_id = "combination_creation_dialog"
+ dialog_title = {intl l="Create a new combination"}
+ dialog_body = {$smarty.capture.combination_creation_dialog nofilter}
+
+ dialog_ok_label = {intl l="Create this combination"}
+
+ form_action = {url path='/admin/product/combination/add'}
+ form_enctype = ''
+ form_error_message = ''
+
+ ok_button_id = "combination_creation_dialog_ok"
+}
+
+
+{* -- Delete combination confirmation dialog ----------------------------------- *}
+
+{capture "combination_delete_dialog"}
+
+
+
+
+
+
+ {module_include location='category_delete_form'}
+
+{/capture}
+
+{include
+ file = "includes/generic-confirm-dialog.html"
+
+ dialog_id = "combination_delete_dialog"
+ dialog_title = {intl l="Delete a combination"}
+ dialog_message = {intl l="Do you really want to delete this combination ?"}
+
+ form_action = {url path='/admin/product/combination/delete'}
+ form_content = {$smarty.capture.combination_delete_dialog nofilter}
+}
+
+{* -- Combination builder dialog -------------------------------------------- *}
+
+{* Capture the dialog body, to pass it to the generic dialog *}
+
+{form name="thelia.admin.product_combination.build"}
+
+{capture "combination_builder_dialog"}
+
+ {* Be sure to get the product ID and current tab, even if the form could not be validated *}
+
+
+
+ {form_hidden_fields form=$form}
+
+ {form_field form=$form field='product_id'}
+
+ {/form_field}
+
+ {if $form_error}{$form_error_message}
{/if}
+
+ {loop type="currency" name="get-currency-symbol" id=$edit_currency_id backend_context="1"}
+ {$currency_symbol = $SYMBOL}
+
+ {form_field form=$form field='currency'}
+
+ {/form_field}
+ {/loop}
+
+ {form_field form=$form field='success_url'}
+
+ {/form_field}
+
+
+ {intl l='Select attribute values to combine. You may enter a default value for some of the fields of the generated combinations.'}
+
+
+
+
+
+
+ {form_field form=$form field='price'}
+
+ {/form_field}
+
+ {form_field form=$form field='reference'}
+
+ {/form_field}
+
+ {form_field form=$form field='ean_code'}
+
+ {/form_field}
+
+
+
+ {form_field form=$form field='weight'}
+
+ {/form_field}
+
+
+
+ {form_field form=$form field='quantity'}
+
+ {/form_field}
+
+
+
+ {form_field form=$form field='sale_price'}
+
+ {/form_field}
+
+ {form_field form=$form field='onsale'}
+
+ {/form_field}
+
+ {form_field form=$form field='isnew'}
+
+ {/form_field}
+
+
{intl l='0 combinations'}
+
+
+
+{/capture}
+
+{include
+ file = "includes/generic-create-dialog.html"
+
+ dialog_id = "combination_builder_dialog"
+ dialog_title = {intl l="Create combinations"}
+ dialog_body = {$smarty.capture.combination_builder_dialog nofilter}
+
+ dialog_ok_label = {intl l="Create combinations"}
+
+ form_action = {url path='/admin/product/combination/build'}
+ form_enctype = {form_enctype form=$form}
+ form_error_message = ''
+
+ ok_button_id = "combination_builder_dialog_ok"
+}
+
+{/form}
diff --git a/templates/backOffice/default/product-edit.html b/templates/backOffice/default/product-edit.html
index 36eff1a6e..7a91f2647 100644
--- a/templates/backOffice/default/product-edit.html
+++ b/templates/backOffice/default/product-edit.html
@@ -38,7 +38,7 @@
From edbc63bb53c5970843909eafe3cd381848e4ba57 Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Fri, 24 Jan 2014 15:18:50 +0100
Subject: [PATCH 09/50] Fixed Customer namespace problem
---
core/lib/Thelia/Action/Order.php | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php
index 3b7dfbd85..cf4a88432 100644
--- a/core/lib/Thelia/Action/Order.php
+++ b/core/lib/Thelia/Action/Order.php
@@ -23,33 +23,30 @@
namespace Thelia\Action;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Cart\CartTrait;
use Thelia\Core\Event\Cart\CartEvent;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
+use Thelia\Core\Event\Order\OrderManualEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\TheliaProcessException;
use Thelia\Model\AddressQuery;
+use Thelia\Model\Cart as CartModel;
use Thelia\Model\ConfigQuery;
-use Thelia\Model\MessageQuery;
-use Thelia\Model\OrderProductAttributeCombination;
-use Thelia\Model\ModuleQuery;
-use Thelia\Model\OrderProduct;
-use Thelia\Model\OrderStatus;
+use Thelia\Model\Currency;
+use Thelia\Model\Customer as CustomerModel;
+use Thelia\Model\Lang;
use Thelia\Model\Map\OrderTableMap;
+use Thelia\Model\MessageQuery;
+use Thelia\Model\ModuleQuery;
+use Thelia\Model\Order as ModelOrder;
use Thelia\Model\OrderAddress;
+use Thelia\Model\OrderProduct;
+use Thelia\Model\OrderProductAttributeCombination;
+use Thelia\Model\OrderStatus;
use Thelia\Model\OrderStatusQuery;
use Thelia\Tools\I18n;
-use Thelia\Model\Currency;
-use Thelia\Model\Lang;
-use Thelia\Model\Country;
-use Thelia\Model\Customer;
-use Thelia\Core\Event\Order\OrderManualEvent;
-
-use Thelia\Model\Cart as CartModel;
-use Thelia\Model\Order as ModelOrder;
/**
*
@@ -121,7 +118,7 @@ class Order extends BaseAction implements EventSubscriberInterface
$event->setOrder($order);
}
- protected function createOrder(ModelOrder $sessionOrder, Currency $currency, Lang $lang, CartModel $cart, Customer $customer)
+ protected function createOrder(ModelOrder $sessionOrder, Currency $currency, Lang $lang, CartModel $cart, CustomerModel $customer)
{
$con = \Propel\Runtime\Propel::getConnection(
OrderTableMap::DATABASE_NAME
@@ -129,7 +126,7 @@ class Order extends BaseAction implements EventSubscriberInterface
$con->beginTransaction();
- /* use a copy to avoid errored reccord in session */
+ /* use a copy to avoid errored record in session */
$placedOrder = $sessionOrder->copy();
$placedOrder->setDispatcher($this->getDispatcher());
@@ -319,7 +316,7 @@ class Order extends BaseAction implements EventSubscriberInterface
/* but memorize placed order */
$event->setOrder(new \Thelia\Model\Order());
$event->setPlacedOrder($placedOrder);
-
+var_dump($placedOrder);
/* empty cart */
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
From af47399f09b86988b7d65912d45ceeeffe09fd7a Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Fri, 24 Jan 2014 15:19:16 +0100
Subject: [PATCH 10/50] Minor cosmetic changes
---
core/lib/Thelia/Core/Event/Cart/CartEvent.php | 9 +++++++--
core/lib/Thelia/Form/TaxCreationForm.php | 1 +
core/lib/Thelia/Model/Product.php | 2 ++
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/core/lib/Thelia/Core/Event/Cart/CartEvent.php b/core/lib/Thelia/Core/Event/Cart/CartEvent.php
index 4e1ed304d..b62f18f86 100644
--- a/core/lib/Thelia/Core/Event/Cart/CartEvent.php
+++ b/core/lib/Thelia/Core/Event/Cart/CartEvent.php
@@ -48,6 +48,7 @@ class CartEvent extends ActionEvent
public function setAppend($append)
{
$this->append = $append;
+ return $this;
}
/**
@@ -64,6 +65,7 @@ class CartEvent extends ActionEvent
public function setCartItem($cartItem)
{
$this->cartItem = $cartItem;
+ return $this;
}
/**
@@ -80,6 +82,7 @@ class CartEvent extends ActionEvent
public function setNewness($newness)
{
$this->newness = $newness;
+ return $this;
}
/**
@@ -96,6 +99,7 @@ class CartEvent extends ActionEvent
public function setProduct($product)
{
$this->product = $product;
+ return $this;
}
/**
@@ -112,6 +116,7 @@ class CartEvent extends ActionEvent
public function setProductSaleElementsId($productSaleElementsId)
{
$this->productSaleElementsId = $productSaleElementsId;
+ return $this;
}
/**
@@ -128,6 +133,7 @@ class CartEvent extends ActionEvent
public function setQuantity($quantity)
{
$this->quantity = $quantity;
+ return $this;
}
/**
@@ -145,5 +151,4 @@ class CartEvent extends ActionEvent
{
return $this->cart;
}
-
-}
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php
index 6ff0cc81e..d3483aa4e 100644
--- a/core/lib/Thelia/Form/TaxCreationForm.php
+++ b/core/lib/Thelia/Form/TaxCreationForm.php
@@ -28,6 +28,7 @@ use Thelia\Core\Form\Type\TheliaType;
use Thelia\Core\Translation\Translator;
use Thelia\TaxEngine\TaxEngine;
use Thelia\Model\Tax;
+use Thelia\Core\HttpFoundation\Request;
/**
* Class TaxCreationForm
diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php
index 12b98c890..5bcc56b46 100644
--- a/core/lib/Thelia/Model/Product.php
+++ b/core/lib/Thelia/Model/Product.php
@@ -55,6 +55,8 @@ class Product extends BaseProduct
/**
* Return the default PSE for this product.
+ *
+ * @return ProductSaleElements
*/
public function getDefaultSaleElements() {
return ProductSaleElementsQuery::create()->filterByProductId($this->id)->filterByIsDefault(true)->find();
From 24ffc81b36297ad6796cbb51f5b51e0e087ae058 Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Fri, 24 Jan 2014 15:27:56 +0100
Subject: [PATCH 11/50] Fixed typo
---
core/lib/Thelia/Action/Order.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php
index cf4a88432..69d8645ac 100644
--- a/core/lib/Thelia/Action/Order.php
+++ b/core/lib/Thelia/Action/Order.php
@@ -316,7 +316,7 @@ class Order extends BaseAction implements EventSubscriberInterface
/* but memorize placed order */
$event->setOrder(new \Thelia\Model\Order());
$event->setPlacedOrder($placedOrder);
-var_dump($placedOrder);
+
/* empty cart */
$this->getDispatcher()->dispatch(TheliaEvents::CART_CLEAR, new CartEvent($this->getCart($this->getRequest())));
From 3e3ecc8edf975182c602ce2c61fb005975a5a18a Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Fri, 24 Jan 2014 23:07:37 +0100
Subject: [PATCH 12/50] Fixed undefined $search
---
core/lib/Thelia/Action/Config.php | 39 +++++++++++++++++++------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/core/lib/Thelia/Action/Config.php b/core/lib/Thelia/Action/Config.php
index 8bb1e9fbf..b1c714a0e 100644
--- a/core/lib/Thelia/Action/Config.php
+++ b/core/lib/Thelia/Action/Config.php
@@ -23,15 +23,12 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-
-use Thelia\Model\ConfigQuery;
-use Thelia\Model\Config as ConfigModel;
-
-use Thelia\Core\Event\TheliaEvents;
-
-use Thelia\Core\Event\Config\ConfigUpdateEvent;
use Thelia\Core\Event\Config\ConfigCreateEvent;
use Thelia\Core\Event\Config\ConfigDeleteEvent;
+use Thelia\Core\Event\Config\ConfigUpdateEvent;
+use Thelia\Core\Event\TheliaEvents;
+use Thelia\Model\Config as ConfigModel;
+use Thelia\Model\ConfigQuery;
class Config extends BaseAction implements EventSubscriberInterface
{
@@ -44,9 +41,14 @@ class Config extends BaseAction implements EventSubscriberInterface
{
$config = new ConfigModel();
- $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
- ->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden())
- ->setSecured($event->getSecured())->save();
+ $config->setDispatcher($this->getDispatcher())
+ ->setName($event->getEventName())
+ ->setValue($event->getValue())
+ ->setLocale($event->getLocale())
+ ->setTitle($event->getTitle())
+ ->setHidden($event->getHidden())
+ ->setSecured($event->getSecured())
+ ->save();
$event->setConfig($config);
}
@@ -59,7 +61,7 @@ class Config extends BaseAction implements EventSubscriberInterface
public function setValue(ConfigUpdateEvent $event)
{
- if (null !== $config = $search->findPk($event->getConfigId())) {
+ if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
if ($event->getValue() !== $config->getValue()) {
@@ -80,10 +82,17 @@ class Config extends BaseAction implements EventSubscriberInterface
if (null !== $config = ConfigQuery::create()->findPk($event->getConfigId())) {
- $config->setDispatcher($this->getDispatcher())->setName($event->getEventName())->setValue($event->getValue())
- ->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale())
- ->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())
- ->setPostscriptum($event->getPostscriptum())->save();
+ $config->setDispatcher($this->getDispatcher())
+ ->setName($event->getEventName())
+ ->setValue($event->getValue())
+ ->setHidden($event->getHidden())
+ ->setSecured($event->getSecured())
+ ->setLocale($event->getLocale())
+ ->setTitle($event->getTitle())
+ ->setDescription($event->getDescription())
+ ->setChapo($event->getChapo())
+ ->setPostscriptum($event->getPostscriptum())
+ ->save();
$event->setConfig($config);
}
From c2b310fd73bf0ce151e1998ebf4eb6dee649725e Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Sat, 25 Jan 2014 00:30:09 +0100
Subject: [PATCH 13/50] Created TlogDestinationRotatingFile and set it the
default destination
---
.../Thelia/Log/AbstractTlogDestination.php | 14 ++-
.../Log/Destination/TlogDestinationFile.php | 39 ++-----
.../TlogDestinationRotatingFile.php | 101 ++++++++++++++++++
core/lib/Thelia/Log/Tlog.php | 2 +-
4 files changed, 118 insertions(+), 38 deletions(-)
create mode 100644 core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php
diff --git a/core/lib/Thelia/Log/AbstractTlogDestination.php b/core/lib/Thelia/Log/AbstractTlogDestination.php
index 5dcb76f71..718679d76 100644
--- a/core/lib/Thelia/Log/AbstractTlogDestination.php
+++ b/core/lib/Thelia/Log/AbstractTlogDestination.php
@@ -26,31 +26,29 @@ namespace Thelia\Log;
abstract class AbstractTlogDestination
{
//Tableau de TlogDestinationConfig paramétrant la destination
- protected $_configs;
+ protected $_configs = array();
//Tableau des lignes de logs stockés avant utilisation par ecrire()
- protected $_logs;
+ protected $_logs = array();
public function __construct()
{
- $this->_configs = array();
- $this->_logs = array();
-
// Initialiser les variables de configuration
- $this->_configs = $this->getConfigs();
+ $this->_configs = $this->getConfigs();
// Appliquer la configuration
$this->configure();
}
//Affecte une valeur à une configuration de la destination
- public function setConfig($name, $value)
+ public function setConfig($name, $value, $apply_changes = true)
{
foreach ($this->_configs as $config) {
if ($config->getName() == $name) {
$config->setValue($value);
+
// Appliquer les changements
- $this->configure();
+ if ($apply_changes) $this->configure();
return true;
}
diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
index 08b7aab66..2f21583a3 100644
--- a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
+++ b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
@@ -37,9 +37,6 @@ class TlogDestinationFile extends AbstractTlogDestination
const VAR_MODE = "tlog_destinationfile_mode";
const VALEUR_MODE_DEFAULT = "A";
- const VAR_MAX_FILE_SIZE_KB = "tlog_destinationfile_max_file_size";
- const MAX_FILE_SIZE_KB_DEFAULT = 1024; // 1 Mb
-
protected $path_defaut = false;
protected $fh = false;
@@ -49,10 +46,18 @@ class TlogDestinationFile extends AbstractTlogDestination
parent::__construct();
}
+ protected function getFilePath() {
+ return $this->getConfig(self::VAR_PATH_FILE);
+ }
+
+ protected function getOpenMode() {
+ return strtolower($this->getConfig(self::VAR_MODE, self::VALEUR_MODE_DEFAULT)) == 'a' ? 'a' : 'w';
+ }
+
public function configure()
{
- $file_path = $this->getConfig(self::VAR_PATH_FILE);
- $mode = strtolower($this->getConfig(self::VAR_MODE, self::VALEUR_MODE_DEFAULT)) == 'a' ? 'a' : 'w';
+ $file_path = $this->getFilePath();
+ $mode = $this->getOpenMode();
if (! empty($file_path)) {
if (! is_file($file_path)) {
@@ -67,23 +72,6 @@ class TlogDestinationFile extends AbstractTlogDestination
if ($this->fh) @fclose($this->fh);
- if (filesize($file_path) > 1024 * $this->getConfig(self::VAR_MAX_FILE_SIZE_KB, self::MAX_FILE_SIZE_KB_DEFAULT)) {
-
- $idx = 1;
-
- do {
- $file_path_bk = "$file_path.$idx";
-
- $idx++;
-
- } while (file_exists($file_path_bk));
-
- @rename($file_path, $file_path_bk);
-
- @touch($file_path);
- @chmod($file_path, 0666);
- }
-
$this->fh = fopen($file_path, $mode);
}
}
@@ -114,13 +102,6 @@ class TlogDestinationFile extends AbstractTlogDestination
'Enter E to empty this file for each request, or A to always append logs. Consider resetting the file from time to time',
self::VALEUR_MODE_DEFAULT,
TlogDestinationConfig::TYPE_TEXTFIELD
- ),
- new TlogDestinationConfig(
- self::VAR_MAX_FILE_SIZE_KB,
- 'Maximum log file size, in Kb',
- 'When this size if exeeded, a backup copy of the file is made, and a new log file is opened. As the file size check is performed only at the beginning of a request, the file size may be bigger thant this limit. Note: 1 Mb = 1024 Kb',
- self::MAX_FILE_SIZE_KB_DEFAULT,
- TlogDestinationConfig::TYPE_TEXTFIELD
)
);
}
diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php
new file mode 100644
index 000000000..dfd225347
--- /dev/null
+++ b/core/lib/Thelia/Log/Destination/TlogDestinationRotatingFile.php
@@ -0,0 +1,101 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Log\Destination;
+
+use Thelia\Log\AbstractTlogDestination;
+use Thelia\Log\TlogDestinationConfig;
+use Thelia\Core\Translation\Translator;
+
+class TlogDestinationRotatingFile extends TlogDestinationFile
+{
+ // Nom des variables de configuration
+ // ----------------------------------
+
+ const VAR_MAX_FILE_SIZE_KB = "tlog_destinationfile_max_file_size";
+ const MAX_FILE_SIZE_KB_DEFAULT = 1024; // 1 Mb
+
+ public function __construct($maxFileSize = self::MAX_FILE_SIZE_KB_DEFAULT)
+ {
+ $this->path_defaut = THELIA_ROOT . "log" . DS . self::TLOG_DEFAULT_NAME;
+
+ $this->setConfig(self::VAR_MAX_FILE_SIZE_KB, $maxFileSize, false);
+
+ parent::__construct();
+ }
+
+ public function configure()
+ {
+ parent::configure();
+
+ $file_path = $this->getFilePath();
+ $mode = $this->getOpenMode();
+
+ if ($this->fh) @fclose($this->fh);
+
+ if (filesize($file_path) > 1024 * $this->getConfig(self::VAR_MAX_FILE_SIZE_KB, self::MAX_FILE_SIZE_KB_DEFAULT)) {
+
+ $idx = 1;
+
+ do {
+ $file_path_bk = "$file_path.$idx";
+
+ $idx++;
+
+ } while (file_exists($file_path_bk));
+
+ @rename($file_path, $file_path_bk);
+
+ @touch($file_path);
+ @chmod($file_path, 0666);
+ }
+
+ $this->fh = fopen($file_path, $mode);
+ }
+
+ public function getTitle()
+ {
+ return Translator::getInstance()->trans('Rotated Text File');
+ }
+
+ public function getDescription()
+ {
+ return Translator::getInstance()->trans('Store logs into text file, up to a certian size, then a new file is created');
+ }
+
+ public function getConfigs()
+ {
+ $arr = parent::getConfigs();
+
+ $arr[] =
+ new TlogDestinationConfig(
+ self::VAR_MAX_FILE_SIZE_KB,
+ 'Maximum log file size, in Kb',
+ 'When this size if exeeded, a backup copy of the file is made, and a new log file is opened. As the file size check is performed only at the beginning of a request, the file size may be bigger thant this limit. Note: 1 Mb = 1024 Kb',
+ self::MAX_FILE_SIZE_KB_DEFAULT,
+ TlogDestinationConfig::TYPE_TEXTFIELD
+ );
+
+ return $arr;
+ }
+}
\ No newline at end of file
diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php
index 426ea5c7c..5e3d0537a 100644
--- a/core/lib/Thelia/Log/Tlog.php
+++ b/core/lib/Thelia/Log/Tlog.php
@@ -69,7 +69,7 @@ class Tlog Implements LoggerInterface
// default values
const DEFAULT_LEVEL = self::DEBUG;
- const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationFile";
+ const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationRotatingFile";
const DEFAUT_PREFIXE = "#INDEX: #LEVEL [#FILE:#FUNCTION()] {#LINE} #DATE #HOUR: ";
const DEFAUT_FILES = "*";
const DEFAUT_IP = "";
From 099e5d68e59a3dd81992994101183e4f643ceece Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Sat, 25 Jan 2014 02:39:53 +0100
Subject: [PATCH 14/50] Restored propel debug (was commented out)
---
core/lib/Thelia/Core/Thelia.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php
index 8cb1271d3..844eb3d29 100644
--- a/core/lib/Thelia/Core/Thelia.php
+++ b/core/lib/Thelia/Core/Thelia.php
@@ -87,7 +87,7 @@ class Thelia extends Kernel
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
if ($this->isDebug()) {
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
- //$con->useDebug(true);
+ $con->useDebug(true);
}
}
From 5f883a41a41416b0545ef1543cd634aefec486db Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Sat, 25 Jan 2014 19:00:29 +0100
Subject: [PATCH 15/50] Introduced money_format smarty plugin, and the related
formatting class. TODO: define the currency symbol location (left or right)
in i18n params !
---
core/lib/Thelia/Tools/MoneyFormat.php | 57 +++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
create mode 100644 core/lib/Thelia/Tools/MoneyFormat.php
diff --git a/core/lib/Thelia/Tools/MoneyFormat.php b/core/lib/Thelia/Tools/MoneyFormat.php
new file mode 100644
index 000000000..94239907c
--- /dev/null
+++ b/core/lib/Thelia/Tools/MoneyFormat.php
@@ -0,0 +1,57 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Tools;
+
+use Symfony\Component\HttpFoundation\Request;
+
+class MoneyFormat extends NumberFormat
+{
+ public static function getInstance(Request $request)
+ {
+ return new MoneyFormat($request);
+ }
+
+ /**
+ * Get a standard number, with '.' as decimal point no thousands separator, and no currency symbol
+ * so that this number can be used to perform calculations.
+ *
+ * @param float $number the number
+ * @param string $decimals number of decimal figures
+ */
+ public function formatStandardMoney($number, $decimals = null)
+ {
+ return parent::formatStandardNumber($number, $decimals);
+ }
+
+ public function format($number, $decimals = null, $decPoint = null, $thousandsSep = null, $symbol = null)
+ {
+ $number = parent::format($number, $decimals, $decPoint, $thousandsSep);
+
+ if ($symbol !== null) {
+ // FIXME: should be a parameter related to i18n configuration
+ $number = $number . ' ' . $symbol;
+ }
+ return $number;
+ }
+}
From 6b78a33f974ee504addc029b1203be771ed7c1fa Mon Sep 17 00:00:00 2001
From: Franck Allimant
Date: Sat, 25 Jan 2014 19:14:57 +0100
Subject: [PATCH 16/50] Improved order management in back-office
---
.../Controller/Admin/OrderController.php | 6 +-
core/lib/Thelia/Core/Template/Loop/Order.php | 73 ++++++++++++++++++-
.../Core/Template/Smarty/Plugins/Format.php | 40 +++++++++-
.../Core/Template/Smarty/Plugins/Module.php | 3 +-
.../backOffice/default/customer-edit.html | 8 ++
templates/backOffice/default/order-edit.html | 64 +++++++++-------
templates/backOffice/default/orders.html | 73 ++++++++++++++++---
7 files changed, 219 insertions(+), 48 deletions(-)
diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php
index c04e2c93e..97713a589 100644
--- a/core/lib/Thelia/Controller/Admin/OrderController.php
+++ b/core/lib/Thelia/Controller/Admin/OrderController.php
@@ -46,7 +46,11 @@ class OrderController extends BaseAdminController
public function indexAction()
{
if (null !== $response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::VIEW)) return $response;
- return $this->render("orders", array("display_order" => 20));
+
+ return $this->render("orders", array(
+ "display_order" => 20,
+ "orders_order" => $this->getListOrderFromSession("orders", "orders_order", "create-date-reverse")
+ ));
}
public function viewAction($order_id)
diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php
index 3fb04d60c..c3e48dc8e 100644
--- a/core/lib/Thelia/Core/Template/Loop/Order.php
+++ b/core/lib/Thelia/Core/Template/Loop/Order.php
@@ -26,17 +26,20 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
-
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface;
use Thelia\Core\Template\Element\SearchLoopInterface;
-use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
+use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
+use Thelia\Model\Base\Customer;
use Thelia\Model\CustomerQuery;
+use Thelia\Model\Map\CustomerTableMap;
+use Thelia\Model\Map\OrderAddressTableMap;
use Thelia\Model\OrderAddressQuery;
use Thelia\Model\OrderQuery;
-use Thelia\Type\TypeCollection;
use Thelia\Type;
+use Thelia\Type\TypeCollection;
+
/**
*
* @package Thelia\Core\Template\Loop
@@ -72,7 +75,14 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
new Argument(
'order',
new TypeCollection(
- new Type\EnumListType(array('create-date', 'create-date-reverse'))
+ new Type\EnumListType(array(
+ 'id', 'id-reverse',
+ 'reference', 'reference-reverse',
+ 'create-date', 'create-date-reverse',
+ 'company', 'company-reverse',
+ 'customer-name', 'customer-name-reverse',
+ 'status', 'status-reverse'
+ ))
),
'create-date-reverse'
)
@@ -165,12 +175,67 @@ class Order extends BaseLoop implements SearchLoopInterface, PropelSearchLoopInt
foreach ($orderers as $orderer) {
switch ($orderer) {
+ case 'id':
+ $search->orderById(Criteria::ASC);
+ break;
+ case 'id_reverse':
+ $search->orderById(Criteria::DESC);
+ break;
+
+ case 'reference':
+ $search->orderByRef(Criteria::ASC);
+ break;
+ case 'reference_reverse':
+ $search->orderByRef(Criteria::DESC);
+ break;
+
case "create-date":
$search->orderByCreatedAt(Criteria::ASC);
break;
case "create-date-reverse":
$search->orderByCreatedAt(Criteria::DESC);
break;
+
+ case "status":
+ $search->orderByStatusId(Criteria::ASC);
+ break;
+ case "status":
+ $search->orderByStatusId(Criteria::DESC);
+ break;
+
+ case 'company' :
+ $search
+ ->joinOrderAddressRelatedByDeliveryOrderAddressId()
+ ->withColumn(OrderAddressTableMap::COMPANY, 'company')
+ ->orderBy('company', Criteria::ASC)
+ ;
+ break;
+ case 'companyreverse' :
+ $search
+ ->joinOrderAddressRelatedByDeliveryOrderAddressId()
+ ->withColumn(OrderAddressTableMap::COMPANY, 'company')
+ ->orderBy('company', Criteria::DESC)
+ ;
+ break;
+
+ case 'customer-name' :
+ $search
+ ->joinCustomer()
+ ->withColumn(CustomerTableMap::FIRSTNAME, 'firstname')
+ ->withColumn(CustomerTableMap::LASTNAME, 'lastname')
+ ->orderBy('lastname', Criteria::ASC)
+ ->orderBy('firstname', Criteria::ASC)
+ ;
+ break;
+ case 'customer-name-reverse' :
+ $search
+ ->joinCustomer()
+ ->withColumn(CustomerTableMap::FIRSTNAME, 'firstname')
+ ->withColumn(CustomerTableMap::LASTNAME, 'lastname')
+ ->orderBy('lastname', Criteria::DESC)
+ ->orderBy('firstname', Criteria::DESC)
+ ;
+ break;
}
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php
index d0f021ef5..f022cf0c5 100644
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Format.php
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\Exception\SmartyPluginException;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Tools\DateTimeFormat;
+use Thelia\Tools\MoneyFormat;
use Thelia\Tools\NumberFormat;
/**
@@ -135,6 +136,40 @@ class Format extends AbstractSmartyPlugin
$this->getParam($params, "thousands_sep", null)
);
}
+ /**
+ *
+ * display a amount in expected format
+ *
+ * available parameters :
+ * number => int or float number
+ * decimals => how many decimals format expected
+ * dec_point => separator for the decimal point
+ * thousands_sep => thousands separator
+ * symbol => Currency symbol
+ *
+ * ex : {format_money number="1246.12" decimals="1" dec_point="," thousands_sep=" " symbol="€"} will output "1 246,1 €"
+ *
+ * @param $params
+ * @param null $template
+ * @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException
+ * @return string the expected number formatted
+ */
+ public function formatMoney($params, $template = null)
+ {
+ $number = $this->getParam($params, "number", false);
+
+ if ($number === false || $number == '') {
+ return "";
+ }
+
+ return MoneyFormat::getInstance($this->request)->format(
+ $number,
+ $this->getParam($params, "decimals", null),
+ $this->getParam($params, "dec_point", null),
+ $this->getParam($params, "thousands_sep", null),
+ $this->getParam($params, "symbol", null)
+ );
+ }
/**
* @return an array of SmartyPluginDescriptor
@@ -143,7 +178,8 @@ class Format extends AbstractSmartyPlugin
{
return array(
new SmartyPluginDescriptor("function", "format_date", $this, "formatDate"),
- new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber")
- );
+ new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber"),
+ new SmartyPluginDescriptor("function", "format_money", $this, "formatMoney")
+ );
}
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
index 4c92ee85c..da98ce14d 100644
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
@@ -82,8 +82,9 @@ class Module extends AbstractSmartyPlugin
}
}
- if (! empty($content))
+ if (! empty($content)) {
return $template->fetch(sprintf("string:%s", $content));
+ }
return "";
}
diff --git a/templates/backOffice/default/customer-edit.html b/templates/backOffice/default/customer-edit.html
index d5b48f3d6..9747c935c 100644
--- a/templates/backOffice/default/customer-edit.html
+++ b/templates/backOffice/default/customer-edit.html
@@ -160,6 +160,7 @@
+ {ifloop rel="address"}
+ {/ifloop}
+
+ {elseloop rel="address"}
+
+ {intl l="This customer has not defined any delivery address"}
+
+ {/elseloop}
diff --git a/templates/backOffice/default/order-edit.html b/templates/backOffice/default/order-edit.html
index fc7903e1c..12915da92 100644
--- a/templates/backOffice/default/order-edit.html
+++ b/templates/backOffice/default/order-edit.html
@@ -28,22 +28,30 @@
{loop type="order" name="the-order" id=$order_id customer="*"}
{loop type="currency" name="order-currency" id=$CURRENCY}
- {assign "orderCurrency" $SYMBOL}
+ {$orderCurrency=$SYMBOL}
{/loop}
{assign "orderStatusId" $STATUS}
-