{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"}
{include file='includes/notifications.html' message=$general_error}
<form action="{$formAction}" {form_enctype form=$form} method="POST" >
    <section class="row">
        <div class="col-md-12 general-block-decorator">

            {form_hidden_fields form=$form}

            {form_field form=$form field='locale'}
                <input type="hidden" name="{$name}" value="{if $value}{$value}{else}{$edit_language_locale}{/if}" />
            {/form_field}

            {form_field form=$form field='success_url'}
                <input type="hidden" name="{$name}" value="{url path='/admin/coupon/update/{id}'}" />
            {/form_field}

            <div class="span4">
                <div class="control-group">
            <div class="col-md-4">
                {form_field form=$form field='code'}
                    <div class="form-group {if $error}has-error{/if}">
                        <label class="control-label" for="code">{intl l='Code :'}</label>
                        <input id="code" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='code'}">
                        {if $error}{$message}{/if}
                    </div>
                {/form_field}

                {form_field form=$form field='title'}
                    <div class="form-group {if $error}has-error{/if}">
                        <label for="title" class="control-label" >{intl l='Title :'}</label>
                        <input id="title" class="form-control" type="text" name="{$name}" value="{$value}" placeholder="{intl l='title'}">
                        {if $error}{$message}{/if}
                    </div>
                {/form_field}

                {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{/if} />
                            {if $error}{$message}{/if}
                            {intl l='Is enabled'}
                        </label>
                    </div>
                {/form_field}

                {form_field form=$form field='isAvailableOnSpecialOffers'}
                    <div class="form-group {if $error}has-error{/if}">
                        <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{/if} />
                            {if $error}{$message}{/if}
                            {intl l='Is available on special offers'}
                        </label>
                    </div>
                {/form_field}

                {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{/if} />
                            {if $error}{$message}{/if}
                            {intl l='Is cumulative'}
                        </label>
                    </div>
                {/form_field}

                {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{/if} />
                            {if $error}{$message}{/if}
                            {intl l='Is removing postage'}
                        </label>
                    </div>
                {/form_field}

                {form_field form=$form field='expirationDate'}
                    <div class="form-group {if $error}has-error{/if}">
                        <label for="expiration-date" class="control-label">{intl l='Expiration date :'}</label>
                        <div class="input-append date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">
                            <input type="text" id="expiration-date" name="{$name}" class="form-control datepicker" data-date-format="yyyy-mm-dd" value="{if $defaultDate}{$defaultDate}{else}{$value}{/if}" placeholder="{intl l='yyyy-mm-dd'}">
                            {if $error}{$message}{/if}
                            <span class="add-on"><span class="icon-th"></span></span>
                        </div>
                    </div>
                {/form_field}

                {form_field form=$form field='maxUsage'}
                    <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" >
                            {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="{if !$value}-1{else}{$value}{/if}" placeholder="{intl l='max usage'}">
                        {if $error}{$message}{/if}
                    </div>
                {/form_field}
            </div>

            <div class="col-md-8">
                <div class="well clearfix">
                    <div class="col-md-6">
                        {form_field form=$form field='type'}
                            <div class="form-group {if $error}has-error{/if}">
                                <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}" {if $value == $availableCoupon.serviceId}selected{/if}>
                                            {$availableCoupon.name}
                                        </option>
                                    {/foreach}
                                </select>
                                {if $error}{$message}{/if}
                                <span id="typeToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
                            </div>
                        {/form_field}
                    </div>

                    <div class="col-md-6">
                        {form_field form=$form field='amount'}
                            <div class="form-group {if $error}has-error{/if}">
                                <label for="amount" class="control-label">{intl l='Amount :'}</label>
                                <input id="amount" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='14.50'}">
                                {if $error}{$message}{/if}
                            </div>
                        {/form_field}
                        {*<div class="form-group {if $error}has-error{/if}">*}
                            {*<label for="category">Category :</label>*}
                            {*form_field form=$form field='category'*}
                                {*<select name="{$name}" value="{$value}" id="category" class="form-control">*}
                                    {*<option value="1">Category 1</option>*}
                                    {*<option value="1">Category 2</option>*}
                                    {*<option value="1">Category 3</option>*}
                                {*</select>*}
                                {*if $error}{$message}{/if}*}
                            {*/form_field*}
                        {*</div>*}
                    </div>
                </div>

                {form_field form=$form field='shortDescription'}
                    <div class="form-group {if $error}has-error{/if}">
                        <label for="short-description" class="control-label">{intl l='Short description :'}</label>
                        <textarea id="short-description" name="{$name}" class="form-control" placeholder="{intl l='short description'}" class="span12" rows="5">{$value nofilter}</textarea>
                        {if $error}{$message}{/if}
                    </div>
                {/form_field}
            </div>
            
            <div class="clearfix"></div>
            <div class="col-md-12">

                {form_field form=$form field='description'}
                    <div class="form-group {if $error}has-error{/if}">
                        <label for="description" class="control-label">{intl l='Long description :'}</label>
                        <textarea id="description" name="{$name}" placeholder="{intl l='long description'}" class="form-control wysiwyg" rows="10">{$value nofilter}</textarea>
                        {if $error}{$message}{/if}
                    </div>
                {/form_field}

                <button id="save-coupon-btn" type="submit" class="btn btn-default btn-primary">{intl l='Save your modifications'}</button>
            </div>

        </div>
    </section>
    {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='Conditions'}
                    </caption>
                    <thead>
                    <tr>
                        <th>{intl l='Conditions'}</th>
                        <th>{intl l='Actions'}</th>
                    </tr>
                    </thead>
                    <tbody id="condition-list">
                        {include file='coupon/conditions.html' conditions=$conditions}
                    </tbody>
                </table>
            </div>
        </section>

        <section class="row">
            <div class="col-md-12 general-block-decorator clearfix">
                <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="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'}*}
                    {*</label>*}
                    {*<label class="radio">*}
                        {*<input type="radio" name="type" class="form-control" value="2"> {intl l='Or'}*}
                    {*</label>*}
                </div>

                <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="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">*}
                            {*<select name="operator" id="operator" class="form-control">*}
                                {*<option value="1">is superior to</option>*}
                                {*<option value="2">equals to</option>*}
                                {*<option value="3">is inferior to</option>*}
                                {*<option value="4">is inferior or equals to</option>*}
                                {*<option value="5">is superior or equals to</option>*}
                            {*</select>*}
                        {*</div>*}
                        {*<div class="input-group col-lg-6">*}
                            {*<input type="text" name="value" class="form-control">*}
                            {*<span class="input-group-addon">&euro;</span>*}
                        {*</div>*}
                    {*</div>*}
                    {**}

                    {*<label for="operator">Operator :</label>*}
                    {*<div class="row">*}
                        {*<div class="col-lg-6">*}
                            {*<select name="operator" id="operator" class="form-control">*}
                                {*<option value="1">is superior to</option>*}
                                {*<option value="2">equals to</option>*}
                                {*<option value="3">is inferior to</option>*}
                                {*<option value="4">is inferior or equals to</option>*}
                                {*<option value="5">is superior or equals to</option>*}
                            {*</select>*}
                        {*</div>*}
                        {*<div class="input-group col-lg-6 date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">*}
                            {*<input type="text" name="value" class="form-control">*}
                            {*<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>*}
                        {*</div>*}
                    {*</div>*}

                    {*<label for="operator">Operator :</label>*}
                    {*<div class="row">*}
                        {*<div class="col-lg-6">*}
                            {*<select name="operator" id="operator" class="form-control">*}
                                {*<option value="1">is superior to</option>*}
                                {*<option value="2">equals to</option>*}
                                {*<option value="3">is inferior to</option>*}
                                {*<option value="4">is inferior or equals to</option>*}
                                {*<option value="5">is superior or equals to</option>*}
                            {*</select>*}
                        {*</div>*}
                        {*<div class="col-lg-6">*}
                            {*<input type="text" name="value" class="form-control">*}
                        {*</div>*}
                    {*</div>*}
                    {*<div class="row">*}
                        {*<div class="col-lg-12">*}
                            {*<table class="table table-bordered">*}
                                {*<tr>*}
                                    {*<td id="minibrowser-breadcrumb"></td>*}
                                {*</tr>*}
                                {*<tr>*}
                                    {*<th><span class="icon-th-list"></span> Categories list</th>*}
                                {*</tr>*}
                                {*<tr>*}
                                    {*<td id="minibrowser-categories"></td>*}
                                {*</tr>*}
                            {*</table>*}
                        {*</div>*}
                    {*</div>*}
                </div>
            </div>
        </section>
    {/if}
</form>
