From db15eec68b29bdc9055dd83a71ca607198250459 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Sun, 20 Nov 2011 14:50:20 +0000 Subject: [PATCH] // BO : cart rules form improved git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10290 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/themes/default/admin.css | 2 +- .../themes/template/cart_rules/conditions.tpl | 4 +- admin-dev/themes/template/cart_rules/form.js | 29 ++++++ admin-dev/themes/template/cart_rules/form.tpl | 90 +++++++++---------- .../template/cart_rules/informations.tpl | 58 ++++++++++++ .../admin/AdminCartRulesController.php | 15 +--- 6 files changed, 134 insertions(+), 64 deletions(-) create mode 100644 admin-dev/themes/template/cart_rules/informations.tpl diff --git a/admin-dev/themes/default/admin.css b/admin-dev/themes/default/admin.css index 05288cd45..1f3eb0d01 100644 --- a/admin-dev/themes/default/admin.css +++ b/admin-dev/themes/default/admin.css @@ -186,7 +186,7 @@ div.fix-toolbar {border-bottom: 1px solid #E0E0E0;position:fixed;top:0;opacity:0 #productBox { position:relative; width:100%; float:left;} /*tab-pane*/ -form#product, form#access_form{ background-color:#ebedf4; border:1px solid #ccced7; min-height:300px; padding: 5px 10px 10px; margin-left:140px;} +form#product, form#access_form, form#cart_rule_form { background-color:#ebedf4; border:1px solid #ccced7; min-height:300px; padding: 5px 10px 10px; margin-left:140px;} /*form.defaultForm{ background-color:#ebedf4; border:1px solid #ccced7; min-height:300px; padding: 5px 10px 10px;}*/ .tab-row {} .tab-row .tab {background:#EFEFEF;width:100px;} diff --git a/admin-dev/themes/template/cart_rules/conditions.tpl b/admin-dev/themes/template/cart_rules/conditions.tpl index 79901fd46..9bcbdbe76 100644 --- a/admin-dev/themes/template/cart_rules/conditions.tpl +++ b/admin-dev/themes/template/cart_rules/conditions.tpl @@ -7,9 +7,9 @@
{l s='from'} - + {l s='to'} - +

{l s='Default period is one year.'}

diff --git a/admin-dev/themes/template/cart_rules/form.js b/admin-dev/themes/template/cart_rules/form.js index 2ebc1a86c..c3b2bf223 100644 --- a/admin-dev/themes/template/cart_rules/form.js +++ b/admin-dev/themes/template/cart_rules/form.js @@ -298,3 +298,32 @@ $('#customerFilter') $('#id_customer').val(data.id_customer); $('#customerFilter').val(data.cname + ' (' + data.email + ')'); }); + +function displayCartRuleTab(tab) +{ + $('.cart_rule_tab').hide(); + $('.tab-page').removeClass('selected'); + $('#cart_rule_' + tab).show(); + $('#cart_rule_link_' + tab).addClass('selected'); +} + +$('.cart_rule_tab').hide(); +$('.tab-page').removeClass('selected'); +$('#cart_rule_informations').show(); +$('#cart_rule_link_informations').addClass('selected'); + +var date = new Date(); +var hours = date.getHours(); +if (hours < 10) + hours = "0" + hours; +var mins = date.getMinutes(); +if (mins < 10) + mins = "0" + mins; +var secs = date.getSeconds(); +if (secs < 10) + secs = "0" + secs; +$('.datepicker').datepicker({ + prevText: '', + nextText: '', + dateFormat: 'yy-mm-dd ' + hours + ':' + mins + ':' + secs +}); \ No newline at end of file diff --git a/admin-dev/themes/template/cart_rules/form.tpl b/admin-dev/themes/template/cart_rules/form.tpl index ffdc6c372..4f74e5052 100644 --- a/admin-dev/themes/template/cart_rules/form.tpl +++ b/admin-dev/themes/template/cart_rules/form.tpl @@ -1,59 +1,49 @@ +
+ +
-
- {l s='Cart Rule'} - {if $currentObject->id}{/if} - -
- - {foreach from=$languages item=language} - -
- {/foreach} -

{l s='Will be displayed in the cart summary as well as on the invoice.'}

-
- -
- -

{l s='For you only, never displayed to the customer.'}

-
- -
- - -

{l s='Optional, the rule will automatically be applied if you leave this field blank.'}

-
- -
- -
- -
- -
- -
-    - getFieldValue($currentObject, 'active')|intval}checked="checked"{/if} /> - -    - getFieldValue($currentObject, 'active')|intval}checked="checked"{/if} /> - -
-
- {l s='Conditions'} +
+

{l s='Cart rule informations'}

+
+ {include file='cart_rules/informations.tpl'} +
+
+

{l s='Cart rule conditions'}

+
{include file='cart_rules/conditions.tpl'} -
 

- {l s='Actions'} +
+
+

{l s='Cart rule actions'}

+
{include file='cart_rules/actions.tpl'} -
- -
+ +
+
\ No newline at end of file diff --git a/admin-dev/themes/template/cart_rules/informations.tpl b/admin-dev/themes/template/cart_rules/informations.tpl new file mode 100644 index 000000000..c96ac0ba0 --- /dev/null +++ b/admin-dev/themes/template/cart_rules/informations.tpl @@ -0,0 +1,58 @@ + + + + + +
+ {if $currentObject->id}{/if} + +
+
+ {foreach from=$languages item=language} +
+ +
+ {/foreach} +
+

{l s='Will be displayed in the cart summary as well as on the invoice.'}

+
+ +
+ + +

{l s='Optional, the rule will automatically be applied if you leave this field blank.'}

+
+ +
+    + getFieldValue($currentObject, 'partial_use')|intval}checked="checked"{/if} /> + +    + getFieldValue($currentObject, 'partial_use')|intval}checked="checked"{/if} /> + +

+ {l s='Only applicable if the voucher value is greater than the cart total.'}
+ {l s='If you do not allow partial use, the voucher value will be lowered to the total order amount, but if you do, a new voucher will be created with the remainder.'} +

+
+ +
+ +

{l s='Cart rules are applied to the cart by priority. A cart rule with priority of "1" will be processed before a cart rule with a priority of "2".'}

+
+ +
+    + getFieldValue($currentObject, 'active')|intval}checked="checked"{/if} /> + +    + getFieldValue($currentObject, 'active')|intval}checked="checked"{/if} /> + +
+
+ +
+ +

{l s='For you only, never displayed to the customer.'}

+
+
\ No newline at end of file diff --git a/controllers/admin/AdminCartRulesController.php b/controllers/admin/AdminCartRulesController.php index 591175d48..e418437cc 100644 --- a/controllers/admin/AdminCartRulesController.php +++ b/controllers/admin/AdminCartRulesController.php @@ -296,6 +296,7 @@ class AdminCartRulesControllerCore extends AdminController 'giftProductFilter' => $giftProductFilter, 'reductionProductFilter' => $reductionProductFilter, 'defaultCurrency' => Configuration::get('PS_CURRENCY_DEFAULT'), + 'defaultLanguage' => Configuration::get('PS_LANG_DEFAULT'), 'currencies' => Currency::getCurrencies(), 'countries' => $currentObject->getAssociatedRestrictions('country', 1), 'carriers' => $currentObject->getAssociatedRestrictions('carrier', 1), @@ -312,24 +313,16 @@ class AdminCartRulesControllerCore extends AdminController ); $this->content .= Context::getContext()->smarty->fetch('cart_rules/form.tpl'); - - // Todo: replace by the new "includeDatepicker" version - $ob_content = ob_get_contents(); - ob_clean(); - includeDatepicker(array('date_from', 'date_to'), true); - $this->content .= ob_get_contents(); - ob_clean(); - echo $ob_content; - + + $this->addJqueryUI('ui.datepicker'); return parent::initForm(); } public function displayAjaxSearchCartRuleVouchers() { + $found = false; if ($vouchers = CartRule::getCartsRuleByCode(Tools::getValue('q'), (int)Context::getContext()->cookie->id_lang)) $found = true; - else - $found = false; echo Tools::jsonEncode(array('found' => $found, 'vouchers' => $vouchers)); }