Merge pull request #2 from thelia/coupon

Coupon
This commit is contained in:
Manuel Raynaud
2013-09-27 04:21:50 -07:00
116 changed files with 6487 additions and 10517 deletions

View File

@@ -147,7 +147,7 @@
{loop name="menu-auth-coupon" type="auth" roles="ADMIN" permissions="admin.coupon.view"}
<li class="{if $admin_current_location == 'coupon'}active{/if}" id="coupon_menu">
<a href="{url path='/admin/coupon/'}">{intl l="Coupons"}</a>
<a href="{url path='/admin/coupon'}">{intl l="Coupons"}</a>
</li>
{/loop}

View File

@@ -1,5 +1,17 @@
$(function($){
// Manage how coupon and conditions are saved
$.couponManager = {};
// Condition to be saved
$.couponManager.conditionToSave = {};
$.couponManager.conditionToSave.serviceId = false;
$.couponManager.conditionToSave.operators = {};
$.couponManager.conditionToSave.values = {};
// Conditions payload to save
$.couponManager.conditionsToSave = [];
// Condition being updated id
$.couponManager.conditionToUpdateId = false;
// Clean array from deleteValue (undefined) keys
Array.prototype.clean = function(deleteValue) {
for (var i = 0; i < this.length; i++) {
@@ -11,112 +23,112 @@ $(function($){
return this;
};
// Remove 1 Rule then Save Rules AJAX
couponManager.removeRuleAjax = function(id) {
// Delete rule in temporary array
delete couponManager.rulesToSave[id];
couponManager.rulesToSave.clean(undefined);
// Remove 1 Condition then Save Conditions AJAX
$.couponManager.removeConditionAjax = function(id) {
// Delete condition in temporary array
delete $.couponManager.conditionsToSave[id];
$.couponManager.conditionsToSave.clean(undefined);
// Save
couponManager.saveRuleAjax();
$.couponManager.saveConditionAjax();
};
// Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX
couponManager.createOrUpdateRuleAjax = function() {
var id = couponManager.ruleToUpdateId;
// Add 1 Condition / or update the temporary Conditions array then Save Conditions via AJAX
$.couponManager.createOrUpdateConditionAjax = function() {
var id = $.couponManager.conditionToUpdateId;
// If create
if(!id) {
couponManager.rulesToSave.push(couponManager.ruleToSave);
$.couponManager.conditionsToSave.push($.couponManager.conditionToSave);
} else { // else update
couponManager.rulesToSave[id] = couponManager.ruleToSave;
$.couponManager.conditionsToSave[id] = $.couponManager.conditionToSave;
// reset edit mode to off
couponManager.ruleToUpdateId = false;
$.couponManager.conditionToUpdateId = false;
}
// Save
couponManager.saveRuleAjax();
$.couponManager.saveConditionAjax();
};
// Set rule inputs to allow editing
couponManager.updateRuleSelectAjax = function(id) {
couponManager.ruleToUpdateId = id;
couponManager.ruleToSave = couponManager.rulesToSave[id];
// Set condition inputs to allow editing
$.couponManager.updateConditionSelectAjax = function(id) {
$.couponManager.conditionToUpdateId = id;
$.couponManager.conditionToSave = $.couponManager.conditionsToSave[id];
// Set the rule selector
// Set the condition selector
$("#category-rule option").filter(function() {
return $(this).val() == couponManager.ruleToSave.serviceId;
return $(this).val() == $.couponManager.conditionToSave.serviceId;
}).prop('selected', true);
// Force rule input refresh
couponManager.loadRuleInputs(couponManager.ruleToSave.serviceId, function() {
couponManager.fillInRuleInputs();
// Force condition input refresh
$.couponManager.loadConditionInputs($.couponManager.conditionToSave.serviceId, function() {
$.couponManager.fillInConditionInputs();
});
};
// Fill in rule inputs
couponManager.fillInRuleInputs = function() {
// Fill in condition inputs
$.couponManager.fillInConditionInputs = function() {
var operatorId = null;
var valueId = null;
var idName = null;
var id = couponManager.ruleToUpdateId;
var id = $.couponManager.conditionToUpdateId;
if(id) {
couponManager.ruleToSave = couponManager.rulesToSave[id];
$.couponManager.conditionToSave = $.couponManager.conditionsToSave[id];
}
for (idName in couponManager.ruleToSave.operators) {
for (idName in $.couponManager.conditionToSave.operators) {
// Setting idName operator select
operatorId = idName + '-operator';
$('#' + operatorId).val(couponManager.ruleToSave.operators[idName]);
$('#' + operatorId).val($.couponManager.conditionToSave.operators[idName]);
// Setting idName value input
valueId = idName + '-value';
$('#' + valueId).val(couponManager.ruleToSave.values[idName]);
$('#' + valueId).val($.couponManager.conditionToSave.values[idName]);
}
};
// Save rules on click
couponManager.onClickSaveRule = function() {
// Save conditions on click
$.couponManager.onClickSaveCondition = function() {
$('#constraint-save-btn').on('click', function () {
if($('#category-rule').val() == 'thelia.constraint.rule.available_for_everyone') {
// @todo translate + modal
var r= confirm("Do you really want to set this coupon available to everyone ?");
if($('#category-rule').val() == 'thelia.condition.match_for_everyone') {
// // @todo translate message + put it in modal
var r = confirm("Do you really want to set this coupon available to everyone ?");
if (r == true) {
couponManager.createOrUpdateRuleAjax();
$.couponManager.createOrUpdateConditionAjax();
}
} else {
$.couponManager.createOrUpdateConditionAjax();
}
return false;
});
};
couponManager.onClickSaveRule();
$.couponManager.onClickSaveCondition();
// Remove rule on click
couponManager.onClickDeleteRule = function() {
// Remove condition on click
$.couponManager.onClickDeleteCondition = function() {
$('.constraint-delete-btn').on('click', function (e) {
e.preventDefault();
var $this = $(this);
couponManager.removeRuleAjax($this.attr('data-int'));
return false;
$.couponManager.removeConditionAjax($this.attr('data-int'));
});
};
couponManager.onClickDeleteRule();
$.couponManager.onClickDeleteCondition();
// Update rule on click
couponManager.onClickUpdateRule = function() {
$('.constraint-update-btn').on('click', function (e) {
// Update condition on click
$.couponManager.onClickUpdateCondition = function() {
$('.condition-update-btn').on('click', function (e) {
e.preventDefault();
var $this = $(this);
couponManager.updateRuleSelectAjax($this.attr('data-int'));
$.couponManager.updateConditionSelectAjax($this.attr('data-int'));
// Hide row being updated
$this.parent().parent().remove();
return false;
});
};
couponManager.onClickUpdateRule();
$.couponManager.onClickUpdateCondition();
// Reload effect inputs when changing effect
couponManager.onEffectChange = function() {
$.couponManager.onEffectChange = function() {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
$('#effect').on('change', function () {
@@ -124,51 +136,47 @@ $(function($){
$('#effectToolTip').html(optionSelected.attr("data-description"));
});
};
couponManager.onEffectChange();
$.couponManager.onEffectChange();
// Reload rule inputs when changing effect
couponManager.onRuleChange = function() {
// Reload condition inputs when changing effect
$.couponManager.onConditionChange = function() {
$('#category-rule').on('change', function () {
couponManager.loadRuleInputs($(this).val(), function() {});
$.couponManager.loadConditionInputs($(this).val(), function() {});
});
};
couponManager.onRuleChange();
$.couponManager.onConditionChange();
// Fill in ready to be saved rule array
// Fill in ready to be saved condition array
// var onInputsChange = function()
// In AJAX response
// Set max usage to unlimited or not
couponManager.onUsageUnlimitedChange = function() {
if (!$('#max-usage').parent().hasClass('has-error')) {
$('#max-usage').hide().attr('value', '-1');
$.couponManager.onUsageUnlimitedChange = function() {
var isUnlimited = $('#is-unlimited');
if ($('#max-usage').val() == -1) {
isUnlimited.prop('checked', true);
$('#max-usage').hide();
$('#max-usage-label').hide();
} else {
$isUnlimited.prop('checked', false);
$('#max-usage').show();
$('#max-usage-label').show();
}
$('#is-unlimited').change(function(){
isUnlimited.change(function(){
var $this = $(this);
if ($this.is(':checked')) {
$('#max-usage').hide().attr('value', '-1');
$('#max-usage').hide().val('-1');
$('#max-usage-label').hide();
} else {
$('#max-usage').show().val('').attr('value', '');
$('#max-usage').show().val('');
$('#max-usage-label').show();
}
});
};
couponManager.onUsageUnlimitedChange();
$.couponManager.onUsageUnlimitedChange();
});
// Rule to save
var couponManager = {};
// Rule to be saved
couponManager.ruleToSave = {};
couponManager.ruleToSave.serviceId = false;
couponManager.ruleToSave.operators = {};
couponManager.ruleToSave.values = {};
// Rules payload to save
couponManager.rulesToSave = [];
// Rule being updated id
couponManager.ruleToUpdateId = false;

View File

@@ -54,23 +54,36 @@
// -- Confirm Box --
if($('[data-toggle="confirm"]').length){
$('[data-toggle="confirm"]').click(function(e){
$('[data-toggle="confirm"]').click(function(e){
var $link = $(this);
var modal = $(this).data('target');
var $this = $(this);
var $modal = $($this.data('target'));
$(modal).modal('show');
$modal.modal('show');
$(modal).on('shown', function () {
$('[data-confirm]').attr('href', $link.attr('href'));
$modal.on('shown', function () {
if($this.data('script')){
$('[data-confirm]').click(function(){
eval($this.data('script'));
$modal.modal('hide');
return false;
});
}
else{
$('[data-confirm]').attr('href', $this.attr('href'));
}
});
if($(modal).is(':hidden')){
if($modal.is(':hidden')){
e.preventDefault();
}
});
}
}
// -- Mini browser --
miniBrowser = function (root, url){

View File

@@ -8,7 +8,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/coupon/'}">{intl l='Coupon'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{intl l='Create'}</li>
</ul>
</nav>
@@ -18,7 +18,7 @@
</div>
{form name="thelia.admin.coupon.creation"}
{include file='coupon/form.html' formAction={url path={$formAction}} noRules=true}
{include file='coupon/form.html' formAction={url path={$formAction}} noConditions=true}
{/form}
</section> <!-- #wrapper -->

View File

@@ -8,7 +8,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/coupon/'}">{intl l='Coupon'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{intl l='Browse'}</li>
</ul>
</nav>
@@ -31,7 +31,7 @@
<tr>
<th>{block name="coupon-label-code"}{intl l='Code'}{/block}</th>
<th>{block name="coupon-label-title"}{intl l='Title'}{/block}</th>
<th>{block name="coupon-label-expiration-date"}{intl l='Expiration date'}{/block}</th>
<th>{block name="coupon-label-expiration-date"}{intl l='Days before expiration'}{/block}</th>
<th>{block name="coupon-label-usage-left"}{intl l='Usage left'}{/block}</th>
<th class="sorter-false filter-false">{block name="coupon-label-action"}{/block}</th>
</tr>
@@ -39,13 +39,29 @@
<tbody>
{loop type="coupon" name="list_coupon" is_enabled="1" backend_context="true"}
<tr>
<td>{block name="coupon-code"}<a href="{$urlReadCoupon|replace:'couponId':$ID}">{$CODE}</a>{/block}</td>
<td>{block name="coupon-code"}<a href="{$urlReadCoupon|replace:'0':$ID}">{$CODE}</a>{/block}</td>
<td>{block name="coupon-title"}{$TITLE}{/block}</td>
<td>{block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block}</td>
<td>{block name="coupon-usage-left"}{$USAGE_LEFT}{/block}</td>
<td>{block name="coupon-expiration-date"}{$DAY_LEFT_BEFORE_EXPIRATION}{/block}</td>
<td>
{block name="coupon-usage-left"}
{if $USAGE_LEFT == -1}
<span class="label label-success">
{intl l="Unlimited"}
</span>
{elseif $USAGE_LEFT}
<span class="label label-success">
{$USAGE_LEFT}
</span>
{else}
<span class="label label-warning">
0
</span>
{/if}
{/block}
</td>
<td>
{block name="coupon-action"}
<a href="{$urlEditCoupon|replace:'couponId':$ID}" class="btn btn-default btn-primary btn-medium">
<a href="{$urlEditCoupon|replace:'0':$ID}" class="btn btn-default btn-primary btn-medium">
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
</a>
{/block}
@@ -80,7 +96,23 @@
<td>{block name="coupon-code"}<a href="{$urlReadCoupon|replace:'couponId':$ID}">{$CODE}</a>{/block}</td>
<td>{block name="coupon-title"}{$TITLE}{/block}</td>
<td>{block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block}</td>
<td>{block name="coupon-usage-left"}{$USAGE_LEFT}{/block}</td>
<td>
{block name="coupon-usage-left"}
{if $USAGE_LEFT == -1}
<span class="label label-success">
{intl l="Unlimited"}
</span>
{elseif $USAGE_LEFT}
<span class="label label-success">
{$USAGE_LEFT}
</span>
{else}
<span class="label label-warning">
0
</span>
{/if}
{/block}
</td>
<td>
{block name="coupon-action"}
<a href="{$urlEditCoupon|replace:'couponId':$ID}" class="btn btn-default btn-primary btn-medium">

View File

@@ -8,7 +8,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/coupon/'}">{intl l='Coupon'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{$CODE}</li>
</ul>
</nav>
@@ -64,7 +64,11 @@
<tr>
<td>{intl l='Usage left'}</td>
<td>
{if $USAGE_LEFT}
{if $USAGE_LEFT == -1}
<span class="label label-success">
{intl l="Unlimited"}
</span>
{elseif $USAGE_LEFT}
<span class="label label-success">
{$USAGE_LEFT}
</span>
@@ -118,11 +122,11 @@
<td>{intl l='Application field'}</td>
<td>
<ul class="list-unstyled">
{foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach}
{if !$smarty.foreach.rulesForeach.first}
{foreach from=$APPLICATION_CONDITIONS item=condition name=conditionsForeach}
{if !$smarty.foreach.conditionsForeach.first}
<li><span class="label label-info">{intl l='And'}</span></li>
{/if}
<li>{$rule nofilter}</li>
<li>{$condition nofilter}</li>
{/foreach}
</ul>
</td>

View File

@@ -8,7 +8,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/coupon/'}">{intl l='Coupon'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{intl l='Update'} {$couponCode}</li>
</ul>
</nav>
@@ -18,14 +18,12 @@
</div>
{form name="thelia.admin.coupon.creation"}
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noRules=false}
{include file='coupon/form.html' formAction={url path={$formAction}} form=$form noConditions=false}
{/form}
</section> <!-- #wrapper -->
{/block}
{include file='includes/confirmation-modal.html'}
{block name="javascript-initialization"}
{javascripts file='assets/bootstrap-datepicker/js/bootstrap-datepicker.js'}
<script src="{$asset_url}"></script>
@@ -47,87 +45,87 @@
$(function($){
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
// Init Rules
couponManager.initRules = function() {
var rules = [];
{foreach from=$rulesObject key=k item=rule}
// Init rule
var rule = {};
rule['serviceId'] = '{$rule.serviceId nofilter}';
rule['operators'] = {};
rule['values'] = {};
// Init Conditions
$.couponManager.initConditions = function() {
var conditions = [];
{foreach from=$conditionsObject key=k item=condition}
// Init condition
var condition = {};
condition['serviceId'] = '{$condition.serviceId nofilter}';
condition['operators'] = {};
condition['values'] = {};
{foreach from=$rule.validators.setOperators key=input item=operator}
rule['operators']['{$input nofilter}'] = '{$operator nofilter}';
rule['values']['{$input nofilter}'] = '{$rule.validators.setValues[$input] nofilter}';
{foreach from=$condition.validators.setOperators key=input item=operator}
condition['operators']['{$input nofilter}'] = '{$operator nofilter}';
condition['values']['{$input nofilter}'] = '{$condition.validators.setValues[$input] nofilter}';
{/foreach}
// Add rule
rules.push(rule);
// Add condition
conditions.push(condition);
{/foreach}
return rules;
return conditions;
};
// Save Rules AJAX
couponManager.saveRuleAjax = function() {
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
var $url = '{$urlAjaxUpdateRules}';
// Save Conditions AJAX
$.couponManager.saveConditionAjax = function() {
$('#condition-add-operators-values').html('<div class="loading" ></div>');
var $url = '{$urlAjaxUpdateConditions}';
$.ajax({
type: "POST",
url: $url,
data: {literal}{{/literal}rules:JSON.stringify(couponManager.rulesToSave){literal}}{/literal},
data: {literal}{{/literal}conditions:JSON.stringify($.couponManager.conditionsToSave){literal}}{/literal},
statusCode: {
404: function() {
$('#constraint-add-operators-values').html(
$('#condition-add-operators-values').html(
'{intl l='Please retry'}'
);
}
}
}).done(function(data) {
$('#constraint-list').html(data);
$('#constraint-add-operators-values').html('');
// Set the rule selector
$("#category-rule option").filter(function() {
return $(this).val() == 'thelia.constraint.rule.available_for_everyone';
$('#condition-list').html(data);
$('#condition-add-operators-values').html('');
// Set the condition selector
$("#category-condition option").filter(function() {
return $(this).val() == 'thelia.condition.match_for_everyone';
}).prop('selected', true);
couponManager.onClickUpdateRule();
couponManager.onClickDeleteRule();
$.couponManager.onClickUpdateCondition();
$.couponManager.onClickDeleteCondition();
});
};
// Reload rule inputs
couponManager.loadRuleInputs = function(ruleId, callBack) {
$('#constraint-add-operators-values').html('<div class="loading" ></div>');
var url = "{$urlAjaxGetRuleInput}";
url = url.replace('ruleId', ruleId)
// Reload condition inputs
$.couponManager.loadConditionInputs = function(conditionId, callBack) {
$('#condition-add-operators-values').html('<div class="loading" ></div>');
var url = "{$urlAjaxGetConditionInput}";
url = url.replace('conditionId', conditionId)
$.ajax({
url: url,
statusCode: {
404: function() {
$('#constraint-add-operators-values').html(
'{intl l='Please select another rule'}'
$('#condition-add-operators-values').html(
'{intl l='Please select another condition'}'
);
}
}
}).done(function(data) {
$('#constraint-add-operators-values').html(data);
couponManager.ruleToSave.serviceId = ruleId;
if (ruleId == -1) {
$('#condition-add-operators-values').html(data);
$.couponManager.conditionToSave.serviceId = conditionId;
if (conditionId == -1) {
// Placeholder can't be saved
$('#constraint-save-btn').hide();
$('#condition-save-btn').hide();
} else {
$('#constraint-save-btn').show();
$('#condition-save-btn').show();
}
return callBack();
});
};
// Rules which will be saved
couponManager.rulesToSave = couponManager.initRules();
// Conditions which will be saved
$.couponManager.conditionsToSave = $.couponManager.initConditions();
$('#constraint-save-btn').hide();
$('#condition-save-btn').hide();
});
</script>

View File

@@ -71,34 +71,34 @@
<script>
// Init Rules to set
// Update only if no rule are already set
if(!couponManager.ruleToSave){
couponManager.ruleToSave['serviceId'] = '{$ruleId}';
couponManager.ruleToSave['operators'] = {literal}{}{/literal};
couponManager.ruleToSave['values'] = {literal}{}{/literal};
// Init conditions to set
// Update only if no condition are already set
if(!$.couponManager.conditionToSave){
$.couponManager.conditionToSave['serviceId'] = '{$conditionId}';
$.couponManager.conditionToSave['operators'] = {literal}{}{/literal};
$.couponManager.conditionToSave['values'] = {literal}{}{/literal};
} else {
}
{foreach from=$inputs.inputs key=name item=input}
couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
$.couponManager.conditionToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
$.couponManager.conditionToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
{/foreach}
// Fill in ready to be saved rule array
couponManager.onInputsChange = function() {literal}{{/literal}
// Fill in ready to be saved condition array
$.couponManager.onInputsChange = function() {literal}{{/literal}
{foreach from=$inputs.inputs key=name item=input}
// Operator selector
$('#{$name}-operator').change(function (e) {
var $this = $(this);
couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val();
$.couponManager.conditionToSave['operators']['{$name nofilter}'] = $this.val();
});
// Value input
$('#{$name}-value').change(function (e) {
var $this = $(this);
couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val();
$.couponManager.conditionToSave['values']['{$name nofilter}'] = $this.val();
});
{/foreach}
{literal}}{/literal}
couponManager.onInputsChange();
$.couponManager.onInputsChange();
</script>

View File

@@ -0,0 +1,20 @@
{foreach from=$conditions item=condition key=i name=conditionsForeach}
<tr>
<td>
{if !$smarty.foreach.conditionsForeach.first}
<span class="label label-info">{intl l='And'}</span>
{/if}
{$condition nofilter}
</td>
<td>
<a data-int="{$i}" class="btn btn-default btn-primary btn-medium condition-update-btn" href="{$urlEdit}">
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
</a>
{if $conditions|count != 1}
<a data-int="{$i}" data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium condition-delete-btn" href="{$urlDelete}">
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
</a>
{/if}
</td>
</tr>
{/foreach}

View File

@@ -11,7 +11,7 @@
{/form_field}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/coupon/update/{id}/'}" />
<input type="hidden" name="{$name}" value="{url path='/admin/coupon/update/{id}'}" />
{/form_field}
<div class="span4">
@@ -36,7 +36,7 @@
{form_field form=$form field='isEnabled'}
<div class="form-group {if $error}has-error{/if}">
<label for="is-enabled" class="checkbox control-label">
<input id="is-enabled" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
<input id="is-enabled" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
{if $error}{$message}{/if}
{intl l='Is enabled'}
</label>
@@ -45,8 +45,9 @@
{form_field form=$form field='isAvailableOnSpecialOffers'}
<div class="form-group {if $error}has-error{/if}">
{$value|var_dump}
<label for="is-available-on-special-offers" class="checkbox control-label">
<input id="is-available-on-special-offers" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
<input id="is-available-on-special-offers" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
{if $error}{$message}{/if}
{intl l='Is available on special offers'}
</label>
@@ -56,7 +57,7 @@
{form_field form=$form field='isCumulative'}
<div class="form-group {if $error}has-error{/if}">
<label for="is-cumulative" class="checkbox control-label">
<input id="is-cumulative" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
<input id="is-cumulative" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
{if $error}{$message}{/if}
{intl l='Is cumulative'}
</label>
@@ -66,7 +67,7 @@
{form_field form=$form field='isRemovingPostage'}
<div class="form-group {if $error}has-error{/if}">
<label for="is-removing-postage" class="checkbox control-label">
<input id="is-removing-postage" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
<input id="is-removing-postage" type="checkbox" name="{$name}" {if $value}value="1" checked{/if} />
{if $error}{$message}{/if}
{intl l='Is removing postage'}
</label>
@@ -88,11 +89,11 @@
<div class="form-group {if $error}has-error{/if}">
<label for="is-unlimited" class="checkbox control-label">
<input id="is-unlimited" type="checkbox" name="is-unlimited" {if $error}{else}checked{/if} >
<input id="is-unlimited" type="checkbox" name="is-unlimited" >
{intl l='Is unlimited'}
</label>
<label id="max-usage-label" for="max-usage" class="control-label">{intl l='Max usage :'}</label>
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='max usage'}">
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{if !$value}-1{else}{$value}{/if}" placeholder="{intl l='max usage'}">
{if $error}{$message}{/if}
</div>
{/form_field}
@@ -101,17 +102,19 @@
<div class="col-md-8">
<div class="well clearfix">
<div class="col-md-6">
{form_field form=$form field='effect'}
{form_field form=$form field='type'}
<div class="form-group {if $error}has-error{/if}">
<label for="effect" class="control-label">{intl l='Effect :'}</label>
<select name="{$name}" value="{$value}" id="effect" class="col-md-12 form-control">
<option value="-1" data-description="">{intl l='Please select an effect'}</option>
<label for="type" class="control-label">{intl l='Type :'}</label>
<select name="{$name}" id="type" class="col-md-12 form-control">
<option value="-1" data-description="">{intl l='Please select a coupon type'}</option>
{foreach from=$availableCoupons item=availableCoupon}
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" {if $value == $availableCoupon.serviceId}selected="selected"{/if}>{$availableCoupon.name}</option>
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" {if $value == $availableCoupon.serviceId}selected{/if}>
{$availableCoupon.name}
</option>
{/foreach}
</select>
{if $error}{$message}{/if}
<span id="effectToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
<span id="typeToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
</div>
{/form_field}
</div>
@@ -164,14 +167,14 @@
</div>
</section>
{if $noRules}
{include file='includes/notifications.html' message={intl l='Please save your Coupon in oder to affect it some application fields'}}
{if $noConditions}
{include file='includes/notifications.html' message={intl l='Please save your Coupon in oder to affect it some conditions'}}
{else}
<section class="row">
<div class="col-md-12 general-block-decorator">
<table class="table table-striped">
<caption class="clearfix">
{intl l='Rules'}
{intl l='Conditions'}
</caption>
<thead>
<tr>
@@ -179,8 +182,8 @@
<th>{intl l='Actions'}</th>
</tr>
</thead>
<tbody id="constraint-list">
{include file='coupon/rules.html' rules=$rules}
<tbody id="condition-list">
{include file='coupon/conditions.html' conditions=$conditions}
</tbody>
</table>
</div>
@@ -188,11 +191,11 @@
<section class="row">
<div class="col-md-12 general-block-decorator clearfix">
<a id="constraint-save-btn" title="{intl l='Save this rule'}" class="btn btn-default btn-primary pull-right">
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this rule'}
<a id="condition-save-btn" title="{intl l='Save this condition'}" class="btn btn-default btn-primary pull-right" data-toggle="confirm" data-script="">
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this condition'}
</a>
<div id="rule-add-organizer" class="form-group col-md-2">
<div id="condition-add-organizer" class="form-group col-md-2">
<label for="type">{intl l='Condition type :'}</label>
<label class="radio">
<input type="radio" name="type" class="form-control" id="type" value="1" checked> {intl l='And'}
@@ -202,17 +205,17 @@
</label>
</div>
<div id="rule-add-type" class="form-group col-md-4">
<label for="categoryRule">{intl l='Rule\'s category :'}</label>
<select name="categoryRule" id="category-rule" class="form-control">
<option value="-1" >{intl l='Please select a rule category'}</option>
{foreach from=$availableRules item=availableRule}
<option value="{$availableRule.serviceId}" data-description="{$availableRule.toolTip}">{$availableRule.name}</option>
<div id="condition-add-type" class="form-group col-md-4">
<label for="categoryCondition">{intl l='Condition\'s category :'}</label>
<select name="categoryCondition" id="category-condition" class="form-control">
<option value="-1" >{intl l='Please select a condition category'}</option>
{foreach from=$availableConditions item=availableCondition}
<option value="{$availableCondition.serviceId}" data-description="{$availableCondition.toolTip}">{$availableCondition.name}</option>
{/foreach}
</select>
</div>
<div id="constraint-add-operators-values" class="form-group col-md-6">
<div id="condition-add-operators-values" class="form-group col-md-6">
{*<label for="operator">{intl l='Operator :'}</label>*}
{*<div class="row">*}
{*<div class="col-lg-6">*}
@@ -283,4 +286,3 @@
</section>
{/if}
</form>

View File

@@ -1,18 +0,0 @@
{foreach from=$rules item=rule key=i name=rulesForeach}
<tr>
<td>
{if !$smarty.foreach.rulesForeach.first}
<span class="label label-info">{intl l='And'}</span>
{/if}
{$rule nofilter}
</td>
<td>
<a data-int="{$i}" class="btn btn-default btn-primary btn-medium constraint-update-btn" href="{$urlEdit}">
<span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
</a>
<a data-int="{$i}" data-target="#delete" data-toggle="confirm" class="btn btn-default btn-danger btn-medium constraint-delete-btn" href="{$urlDelete}">
<span class="glyphicon glyphicon-remove"></span> {intl l='Delete'}
</a>
</td>
</tr>
{/foreach}