{extends file="admin-layout.tpl"}

{block name="check-resource"}admin.coupon{/block}
{block name="check-access"}view{/block}

{block name="page-title"}{intl l='Coupons'}{/block}

{block name="main-content"}
<section id="wrapper" class="container">

    <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>{intl l='Browse'}</li>
        </ul>
    </nav>

    <div class="page-header">
        <h1>{intl l='Coupons : '}<small>{intl l='List'}</small></h1>
        <a href="{$urlCreateCoupon}" class="btn btn-default btn-primary btn-medium">
            <span class="glyphicon glyphicon-add"></span> {intl l='Create a new coupon'}
        </a>
    </div>

    <section class="row">
		<div class="col-md-12 general-block-decorator">
            <div class="table-responsive">
    	    	<table class="table table-striped tablesorter">
    	    		<caption>
                        {intl l='Enabled coupons'}
    	    		</caption>
    	    		<thead>
    	    			<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='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>
    	    		</thead>
    	    		<tbody>
                        {loop type="coupon" name="list_coupon" is_enabled="1" backend_context="true"}
                            <tr>
                                <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"}{$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:'0':$ID}" class="btn btn-default btn-primary btn-medium">
                                            <span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
                                        </a>
                                    {/block}
                                </td>
                            </tr>
                        {/loop}
    	    		</tbody>
    	    	</table>
            </div>
		</div>
    </section>

    <section class="row">
		<div class="col-md-12 general-block-decorator">
            <div class="table-responsive">
    	    	<table class="table table-striped tablesorter">
    	    		<caption>
                        {intl l='Disabled coupons'}
    	    		</caption>
    	    		<thead>
    	    			<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-usage-left"}{intl l='Usage left'}{/block}</th>
                            <th class="sorter-false filter-false">{block name="coupon-label-action"}{/block}</th>
    	    			</tr>
    	    		</thead>
    	    		<tbody>
                        {loop type="coupon" name="list_coupon" is_enabled="0" backend_context="true"}
                            <tr>
                                <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"}
                                        {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">
                                        <span class="glyphicon glyphicon-edit"></span> {intl l='Edit'}
                                    </a>
                                    {/block}
                                </td>
                            </tr>
                        {/loop}
    	    		</tbody>
    	    	</table>
            </div>
		</div>
    </section>

</section> <!-- #wrapper -->

{/block}


{block name="javascript-initialization"}

    {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/tablesorter/jquery.tablesorter.min.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/tablesorter/jquery.metadata.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/tablesorter/jquery.tablesorter.widgets.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/tablesorter/jquery.tablesorter.widgets-filter-formatter.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}

    {javascripts file='assets/js/main.js'}
        <script src="{$asset_url}"></script>
    {/javascripts}
{/block}
