diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 876814d5d..896144b2d 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -60,6 +60,7 @@
+ diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 1e0f65055..346f4b55f 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -250,6 +250,23 @@ class BaseAdminController extends BaseController $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); } + /** + * Get the current edition currency ID, checking if a change was requested in the current request. + */ + protected function getCurrentEditionCurrency() + { + // Return the new language if a change is required. + if (null !== $edit_currency_id = $this->getRequest()->get('edit_currency_id', null)) { + + if (null !== $edit_currency = LangQuery::create()->findOneById($edit_currency_id)) { + return $edit_currency; + } + } + + // Otherwise return the lang stored in session. + return $this->getSession()->getAdminEditionCurrency(); + } + /** * Get the current edition lang ID, checking if a change was requested in the current request. */ @@ -376,6 +393,9 @@ class BaseAdminController extends BaseController // Find the current edit language ID $edition_language = $this->getCurrentEditionLang(); + // Find the current edit currency ID + $edition_currency = $this->getCurrentEditionCurrency(); + // Prepare common template variables $args = array_merge($args, array( 'locale' => $session->getLang()->getLocale(), @@ -385,11 +405,16 @@ class BaseAdminController extends BaseController 'edit_language_id' => $edition_language->getId(), 'edit_language_locale' => $edition_language->getLocale(), + 'edit_currency_id' => $edition_currency->getId(), + 'current_url' => $this->getRequest()->getUri() )); - // Update the current edition language in session - $this->getSession()->setAdminEditionLang($edition_language); + // Update the current edition language & currency in session + $this->getSession() + ->setAdminEditionLang($edition_language) + ->setAdminEditionCurrency($edition_currency) + ; // Render the template. try { diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 2b1cc9550..f3b1b088e 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -152,11 +152,7 @@ class ProductController extends AbstractCrudController ->setVisible($formData['visible']) ->setUrl($formData['url']) ->setDefaultCategory($formData['default_category']) - ->setBasePrice($formData['price']) - ->setBaseWeight($formData['weight']) - ->setCurrencyId($formData['currency']) - ->setTaxRuleId($formData['tax_rule']) - ; + ; return $changeEvent; } diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 8a0952ff4..798a9c7fd 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -65,23 +65,6 @@ class Session extends BaseSession return $this; } - public function getAdminEditionLang() - { - $lang = $this->get('thelia.admin.edition.lang'); - - if (null === $lang) { - $lang = Lang::getDefaultLanguage(); - } - return $lang; - } - - public function setAdminEditionLang($langId) - { - $this->set('thelia.admin.edition.lang', $langId); - - return $this; - } - public function setCurrency(Currency $currency) { $this->set("thelia.current.currency", $currency); @@ -98,6 +81,43 @@ class Session extends BaseSession return $currency; } + // -- Admin lang and currency ---------------------------------------------- + + public function getAdminEditionCurrency() + { + $currency = $this->get('thelia.admin.edition.currency', null); + + if (null === $currency) { + $currency = Currency::getDefaultCurrency(); + } + + return $currency; + } + + public function setAdminEditionCurrency($currencyId) + { + $this->set('thelia.admin.edition.currency', $currencyId); + + return $this; + } + + public function getAdminEditionLang() + { + $lang = $this->get('thelia.admin.edition.lang'); + + if (null === $lang) { + $lang = Lang::getDefaultLanguage(); + } + return $lang; + } + + public function setAdminEditionLang($lang) + { + $this->set('thelia.admin.edition.lang', $lang); + + return $this; + } + // -- Customer user -------------------------------------------------------- public function setCustomerUser(UserInterface $user) diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 82208981e..c1b8bd6b4 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -63,27 +63,32 @@ class ProductCreationForm extends BaseForm "label" => Translator::getInstance()->trans("This product is online"), "label_attr" => array("for" => "visible_field") )) - ->add("price", "number", array( - "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), - "label_attr" => array("for" => "price_field") - )) - ->add("currency", "integer", array( - "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Price currency *"), - "label_attr" => array("for" => "currency_field") - )) - ->add("tax_rule", "integer", array( - "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Tax rule for this product *"), - "label_attr" => array("for" => "tax_rule_field") - )) - ->add("weight", "number", array( - "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Weight *"), - "label_attr" => array("for" => "weight_field") - )) ; + + if (! $change_mode) { + $this->formBuilder + ->add("price", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), + "label_attr" => array("for" => "price_field") + )) + ->add("currency", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Price currency *"), + "label_attr" => array("for" => "currency_field") + )) + ->add("tax_rule", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Tax rule for this product *"), + "label_attr" => array("for" => "tax_rule_field") + )) + ->add("weight", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Weight *"), + "label_attr" => array("for" => "weight_field") + )) + ; + } } public function checkDuplicateRef($value, ExecutionContextInterface $context) diff --git a/core/lib/Thelia/Form/ProductDetailsModificationForm.php b/core/lib/Thelia/Form/ProductDetailsModificationForm.php new file mode 100644 index 000000000..7ded6ff69 --- /dev/null +++ b/core/lib/Thelia/Form/ProductDetailsModificationForm.php @@ -0,0 +1,90 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints\GreaterThan; +use Thelia\Core\Translation\Translator; +use Symfony\Component\Validator\Constraints\NotBlank; + +class ProductDetailsModificationForm extends BaseForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm() + { + $this->formBuilder + ->add("id", "integer", array( + "label" => Translator::getInstance()->trans("Prodcut ID *"), + "label_attr" => array("for" => "product_id_field"), + "constraints" => array(new GreaterThan(array('value' => 0))) + )) + ->add("price", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), + "label_attr" => array("for" => "price_field") + )) + ->add("price_with_tax", "number", array( + "label" => Translator::getInstance()->trans("Product base price including taxes *"), + "label_attr" => array("for" => "price_with_tax_field") + )) + ->add("currency", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Price currency *"), + "label_attr" => array("for" => "currency_field") + )) + ->add("tax_rule", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Tax rule for this product *"), + "label_attr" => array("for" => "tax_rule_field") + )) + ->add("weight", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Weight *"), + "label_attr" => array("for" => "weight_field") + )) + ->add("quantity", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Current quantity *"), + "label_attr" => array("for" => "quantity_field") + )) + ->add("sale_price", "number", array( + "label" => Translator::getInstance()->trans("Sale price *"), + "label_attr" => array("for" => "price_with_tax_field") + )) + ->add("onsale", "integer", array( + "label" => Translator::getInstance()->trans("This product is on sale"), + "label_attr" => array("for" => "onsale_field") + )) + ->add("isnew", "integer", array( + "label" => Translator::getInstance()->trans("Advertise this product as new"), + "label_attr" => array("for" => "isnew_field") + )) + + ; + } + + public function getName() + { + return "thelia_product_details_modification"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 3070e1915..8e332a73b 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -98,10 +98,11 @@ class Product extends BaseProduct ->filterByDefaultCategory(true) ->findOne() ; +echo "newcat= $defaultCategoryId "; var_dump($productCategory); -exit; - if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) { + if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) { + exit; // Delete the old default category if ($productCategory !== null) $productCategory->delete(); diff --git a/templates/admin/default/ajax/product-attributes-tab.html b/templates/admin/default/ajax/product-attributes-tab.html index a3215f215..2c05217ab 100644 --- a/templates/admin/default/ajax/product-attributes-tab.html +++ b/templates/admin/default/ajax/product-attributes-tab.html @@ -81,7 +81,40 @@ {/if} -| {intl l='ID'} | +{intl l='Attribute Name'} | + + {module_include location='product_attributes_table_header'} +
|---|---|
| {$ID} | + +{$TITLE} | + + {module_include location='product_features_table_row'} +
|
+
+ {intl l="This product template does not contains any features"}
+
+ |
+ |
| {intl l='Feature Name'} | +{intl l='ID'} | +{intl l='Feature Name'} | {intl l='Feature value for this product'} | {module_include location='product_features_table_header'} @@ -122,6 +156,8 @@|
|---|---|---|---|---|
| {$ID} | +{$TITLE} | @@ -176,7 +212,7 @@ {elseloop rel="product-features"} | ||
| + |
{intl l="This product template does not contains any features"}
diff --git a/templates/admin/default/ajax/product-prices-tab.html b/templates/admin/default/ajax/product-prices-tab.html
deleted file mode 100644
index 2878e1d9d..000000000
--- a/templates/admin/default/ajax/product-prices-tab.html
+++ /dev/null
@@ -1,75 +0,0 @@
-{loop name="product_edit" type="product" visible="*" id=$product_id backend_context="1" lang=$edit_language_id}
-
-
-
\ No newline at end of file
diff --git a/templates/admin/default/includes/product-details-tab.html b/templates/admin/default/includes/product-details-tab.html
new file mode 100644
index 000000000..553bf55e9
--- /dev/null
+++ b/templates/admin/default/includes/product-details-tab.html
@@ -0,0 +1,197 @@
+
-
-{/loop}
\ No newline at end of file
diff --git a/templates/admin/default/includes/inner-form-toolbar.html b/templates/admin/default/includes/inner-form-toolbar.html
index f0ddeb924..65420f265 100755
--- a/templates/admin/default/includes/inner-form-toolbar.html
+++ b/templates/admin/default/includes/inner-form-toolbar.html
@@ -9,21 +9,19 @@ Parameters:
*}
+
-
-
- {intl l="Basic product information"}
-
-
-
-
-
-
- {form_field form=$form field='weight'}
-
- {form_field form=$form field='price'}
-
-
-
-
- {loop type="currency" name="default-currency" default_only="1" backend_context="1"}
-
-
- {/form_field}
-
-
- {$SYMBOL}
-
- {intl l='Enter here the product price in the default currency (%title)' title=$NAME}
-
- {form_field form=$form field='currency'}
-
- {/form_field}
-
- {/loop}
-
- {form_field form=$form field='tax_rule'}
-
-
-
-
-
- {/form_field}
-
-
-
-
- {intl l='Select here the tax applicable to this product'}
-
-
- Price w/tax
-
-
-
-
-
- {/form_field}
-
-
-
-
-
-
-
- {intl l="Kg"}
-
- {intl l='Enter here the product weight, in Kilogrammes'}
-
+
+ {form name="thelia.admin.product.details.modification"}
+
\ No newline at end of file
diff --git a/templates/admin/default/product-edit.html b/templates/admin/default/product-edit.html
index e41193e57..826b5746d 100644
--- a/templates/admin/default/product-edit.html
+++ b/templates/admin/default/product-edit.html
@@ -48,7 +48,7 @@
+ {include file="includes/product-details-tab.html"}
+
+
{intl l="Please wait, loading"}
| |||