diff --git a/admin-dev/themes/template/specific_price_rule/form.tpl b/admin-dev/themes/template/specific_price_rule/form.tpl new file mode 100755 index 000000000..55afd5f50 --- /dev/null +++ b/admin-dev/themes/template/specific_price_rule/form.tpl @@ -0,0 +1,217 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8971 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{extends file="helper/form/form.tpl"} + +{block name="other_fieldsets"} + +
 
+
+
+
+ + + {l s='Add a new condition group'} + +
+ {l s='Conditions'} + +
+ + + + {l s='Add condition'} + +
+ +
+ + + + {l s='Add condition'} + +
+
+
+{/block} + +{block name="script"} +var current_id_condition_group = 0; +var last_condition_group = 0; +var conditions = new Array(); +function toggle_condition_group(id_condition_group) +{ + $('.condition_group > table').fadeOut(); + $('#condition_group_'+id_condition_group+' > table').fadeIn(); + current_id_condition_group = id_condition_group; +} +function add_condition(id_condition_group, type, value) +{ + var condition = new Array(); + condition.type = type; + condition.value = value; + condition.id_condition_group = id_condition_group; + conditions.push(condition); +} +function new_condition_group() +{ + last_condition_group++; + var html = '
{l s='Condition group'} '+last_condition_group+''; + html += '
{l s='Type'}{l s='Value'}
'; + html += '
{l s='OR'}
'; + toggle_condition_group(last_condition_group); + $('#condition_group_list').append(html); +} +$(document).ready(function() { + $('#specific_price_rule_form').live('submit', function(e) { + var html = ''; + $.each(conditions, function() { + html += ''; + }); + $('#conditions').append(html); + }); + $('#id_feature').change(function() { + $('.id_feature_value').hide(); + $('#id_feature_'+$(this).val()).show(); + }); + $('#id_attribute_group').change(function() { + $('.id_attribute').hide(); + $('#id_attribute_'+$(this).val()).show(); + }); + $('#add_condition_category').click(function() { + add_condition(current_id_condition_group, 'category', $('#id_category option:selected').val()); + var html = '{l s='Category'}'+$('#id_category option:selected').html()+''; + $('#condition_group_'+current_id_condition_group+' table tbody').append(html); + }); + $('#add_condition_manufacturer').click(function() { + add_condition(current_id_condition_group, 'manufacturer', $('#id_manufacturer option:selected').val()); + var html = '{l s='Manufacturer'}'+$('#id_manufacturer option:selected').html()+''; + $('#condition_group_'+current_id_condition_group+' table tbody').append(html); + }); + $('#add_condition_supplier').click(function() { + add_condition(current_id_condition_group, 'supplier', $('#id_supplier option:selected').val()); + var html = '{l s='Supplier'}'+$('#id_supplier option:selected').html()+''; + $('#condition_group_'+current_id_condition_group+' table tbody').append(html); + }); + $('#add_condition_attribute').click(function() { + add_condition(current_id_condition_group, 'attribute', $('#id_attribute_'+$('#id_attribute_group option:selected').val()+' option:selected').val()); + var html = '{l s='Attribute'}'+$('#id_attribute_group option:selected').html()+': '+$('#id_attribute_'+$('#id_attribute_group option:selected').val()+' option:selected').html()+''; + $('#condition_group_'+current_id_condition_group+' table tbody').append(html); + }); + $('#add_condition_feature').click(function() { + add_condition(current_id_condition_group, 'feature', $('#id_feature_'+$('#id_feature option:selected').val()+' option:selected').val()); + var html = '{l s='Feature'}'+$('#id_feature option:selected').html()+': '+$('#id_feature_'+$('#id_feature option:selected').val()+' option:selected').html()+''; + $('#condition_group_'+current_id_condition_group+' table tbody').append(html); + }); + $('#add_condition_group').click(function() { + new_condition_group(); + }); + $('.condition_group').live('click', function() { + var id = this.id.split('_'); + toggle_condition_group(id[2]); + }); + {if $conditions|@count == 0} + new_condition_group(); + {/if} + {foreach from=$conditions key='id_group_condition' item='condition_group'} + new_condition_group(); + {foreach from=$condition_group item='condition'} + {if $condition.type == 'attribute'} + $('#id_attribute_group option[value="{$condition.id_attribute_group}"]').attr('selected', 'selected'); + $('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]').attr('selected', 'selected'); + console.log('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]'); + {elseif $condition.type == 'feature'} + $('#id_feature[value="{$condition.id_feature}"]').attr('selected', 'selected'); + $('#id_feature_{$condition.id_feature} option[value="{$condition.value}"]').attr('selected', 'selected'); + {else} + $('#id_{$condition.type} option[value="{$condition.value}"]').attr('selected', 'selected'); + {/if} + $('#add_condition_{$condition.type}').click(); + {/foreach} + {/foreach} + $('#id_attribute_group').change(); + $('#id_feature').change(); +}); +{/block}