Working : Coupon : fix links and errors display

This commit is contained in:
gmorel
2013-09-13 12:42:33 +02:00
parent 530c3d1102
commit ed4809bac4
14 changed files with 411 additions and 397 deletions

View File

@@ -103,25 +103,25 @@
<!-- Route to the Coupon controller (process Coupon browsing) -->
<route id="admin.coupon.list" path="/admin/coupon">
<route id="admin.coupon.list" path="/admin/coupon/">
<default key="_controller">Thelia\Controller\Admin\CouponController::browseAction</default>
</route>
<route id="admin.coupon.create" path="/admin/coupon/create">
<route id="admin.coupon.create" path="/admin/coupon/create/">
<default key="_controller">Thelia\Controller\Admin\CouponController::createAction</default>
</route>
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}">
<route id="admin.coupon.update" path="/admin/coupon/update/{couponId}/">
<default key="_controller">Thelia\Controller\Admin\CouponController::updateAction</default>
</route>
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}">
<route id="admin.coupon.read" path="/admin/coupon/read/{couponId}/">
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
</route>
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}">
<route id="admin.coupon.rule.input" path="/admin/coupon/rule/{ruleId}/">
<default key="_controller">Thelia\Controller\Admin\CouponController::getRuleInputAction</default>
</route>
<route id="admin.coupon.rule.update" path="/admin/coupon/{couponId}/rule/update/">
<default key="_controller">Thelia\Controller\Admin\CouponController::updateRulesAction</default>
</route>
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}">
<route id="admin.coupon.consume" path="/admin/coupon/consume/{couponCode}/">
<default key="_controller">Thelia\Controller\Admin\CouponController::consumeAction</default>
</route>

View File

@@ -74,7 +74,54 @@ class CouponController extends BaseAdminController
{
$this->checkAuth('ADMIN', 'admin.coupon.view');
return $this->render('coupon-list');
$args['urlReadCoupon'] = $this->getRoute(
'admin.coupon.read',
array('couponId' => 'couponId'),
Router::ABSOLUTE_URL
);
$args['urlEditCoupon'] = $this->getRoute(
'admin.coupon.update',
array('couponId' => 'couponId'),
Router::ABSOLUTE_URL
);
$args['urlCreateCoupon'] = $this->getRoute(
'admin.coupon.create',
array(),
Router::ABSOLUTE_URL
);
return $this->render('coupon-list', $args);
}
/**
* Manage Coupons read display
*
* @param int $couponId Coupon Id
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction($couponId)
{
$this->checkAuth('ADMIN', 'admin.coupon.read');
// Database request repeated in the loop but cached
$search = CouponQuery::create();
$coupon = $search->findOneById($couponId);
if ($coupon === null) {
return $this->pageNotFound();
}
$args['couponId'] = $couponId;
$args['urlEditCoupon'] = $this->getRoute(
'admin.coupon.update',
array('couponId' => $couponId),
Router::ABSOLUTE_URL
);
return $this->render('coupon-read', $args);
}
/**
@@ -95,7 +142,7 @@ class CouponController extends BaseAdminController
$i18n = new I18n();
/** @var Lang $lang */
$lang = $this->getSession()->get('lang');
$lang = $this->getSession()->getLang();
$eventToDispatch = TheliaEvents::COUPON_CREATE;
if ($this->getRequest()->isMethod('POST')) {
@@ -113,7 +160,8 @@ class CouponController extends BaseAdminController
->format($lang->getDateFormat());
}
$args['formAction'] = 'admin/coupon/create';
$args['availableCoupons'] = $this->getAvailableCoupons();
$args['formAction'] = 'admin/coupon/create/';
return $this->render(
'coupon-create',
@@ -205,7 +253,7 @@ class CouponController extends BaseAdminController
// Pass it to the parser
$this->getParserContext()->addForm($changeForm);
}
$args['couponCode'] = $coupon->getCode();
$args['availableCoupons'] = $this->getAvailableCoupons();
$args['availableRules'] = $this->getAvailableRules();
$args['urlAjaxGetRuleInput'] = $this->getRoute(
@@ -320,27 +368,7 @@ class CouponController extends BaseAdminController
/**
* Manage Coupons read display
*
* @param int $couponId Coupon Id
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function readAction($couponId)
{
$this->checkAuth('ADMIN', 'admin.coupon.read');
// Database request repeated in the loop but cached
$search = CouponQuery::create();
$coupon = $search->findOneById($couponId);
if ($coupon === null) {
return $this->pageNotFound();
}
return $this->render('coupon-read', array('couponId' => $couponId));
}
/**
* Manage Coupons read display
@@ -657,17 +685,17 @@ class CouponController extends BaseAdminController
/** @var CouponManager $couponManager */
$couponManager = $this->container->get('thelia.coupon.manager');
$availableCoupons = $couponManager->getAvailableCoupons();
$cleanedRules = array();
$cleanedCoupons = array();
/** @var CouponInterface $availableCoupon */
foreach ($availableCoupons as $availableCoupon) {
$rule = array();
$rule['serviceId'] = $availableCoupon->getServiceId();
$rule['name'] = $availableCoupon->getName();
$rule['toolTip'] = $availableCoupon->getToolTip();
$cleanedRules[] = $rule;
$cleanedCoupons[] = $rule;
}
return $cleanedRules;
return $cleanedCoupons;
}
/**

View File

@@ -24,6 +24,7 @@
namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Util\PropelModelPager;
use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Core\HttpFoundation\Request;
@@ -38,6 +39,7 @@ use Thelia\Coupon\Type\CouponInterface;
use Thelia\Model\CouponQuery;
use Thelia\Model\Coupon as MCoupon;
use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/**
* Created by JetBrains PhpStorm.
@@ -53,17 +55,22 @@ use Thelia\Type;
class Coupon extends BaseI18nLoop
{
/**
* Define all args used in your loop
*
* @return ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntListTypeArgument('id')
Argument::createIntListTypeArgument('id'),
Argument::createBooleanOrBothTypeArgument('is_enabled', 1)
);
}
/**
* @param $pagination
* Execute Loop
*
* @param PropelModelPager $pagination
*
* @return \Thelia\Core\Template\Element\LoopResult
*/
@@ -75,11 +82,16 @@ class Coupon extends BaseI18nLoop
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
$id = $this->getId();
$isEnabled = $this->getIsEnabled();
if (null !== $id) {
$search->filterById($id, Criteria::IN);
}
if ($isEnabled != BooleanOrBothType::ANY) {
$search->filterByIsEnabled($isEnabled ? 1 : 0);
}
// Perform search
$coupons = $this->search($search, $pagination);
@@ -122,7 +134,7 @@ class Coupon extends BaseI18nLoop
$cleanedRules = array();
/** @var CouponRuleInterface $rule */
foreach ($rules->getRules() as $key => $rule) {
foreach ($rules->getRules() as $rule) {
$cleanedRules[] = $rule->getToolTip();
}
$loopResultRow->set("ID", $coupon->getId())

View File

@@ -23,7 +23,10 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\Date;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotEqualTo;
/**
* Created by JetBrains PhpStorm.
@@ -68,7 +71,6 @@ class CouponCreationForm extends BaseForm
'shortDescription',
'text',
array(
'invalid_message' => 'test',
'constraints' => array(
new NotBlank()
)
@@ -78,7 +80,6 @@ class CouponCreationForm extends BaseForm
'description',
'textarea',
array(
'invalid_message' => 'test',
'constraints' => array(
new NotBlank()
)
@@ -88,16 +89,23 @@ class CouponCreationForm extends BaseForm
'effect',
'text',
array(
'invalid_message' => 'test',
'constraints' => array(
new NotBlank()
new NotBlank(),
new NotEqualTo(
array(
'value' => -1
)
)
)
)
)
->add(
'amount',
'money',
array()
array(
'constraints' => array(
new NotBlank()
))
)
->add(
'isEnabled',
@@ -109,7 +117,8 @@ class CouponCreationForm extends BaseForm
'text',
array(
'constraints' => array(
new NotBlank()
new NotBlank(),
new Date()
)
)
)
@@ -133,7 +142,12 @@ class CouponCreationForm extends BaseForm
'text',
array(
'constraints' => array(
new NotBlank()
new NotBlank(),
new GreaterThanOrEqual(
array(
'value' => -1
)
)
)
)
)

View File

@@ -18,7 +18,7 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
('use_tax_free_amounts', 0, 1, 0, NOW(), NOW()),
('process_assets', '0', 0, 0, NOW(), NOW());
('process_assets', '1', 0, 0, NOW(), NOW());
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES

View File

@@ -146,7 +146,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-list'}">{intl l="Coupons"}</a>
<a href="{url path='/admin/coupon/'}">{intl l="Coupons"}</a>
</li>
{/loop}

View File

@@ -115,6 +115,8 @@ $(function($){
// Reload effect inputs when changing effect
couponManager.onEffectChange = function() {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
$('#effect').on('change', function () {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
@@ -134,6 +136,32 @@ $(function($){
// 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');
}
$('#is-unlimited').change(function(){
var $this = $(this);
if ($this.is(':checked')) {
$('#max-usage').hide().attr('value', '-1');
} else {
$('#max-usage').show().val('').attr('value', '');
}
});
};
couponManager.onUsageUnlimitedChange();
// // -- Effect description
// if($('[name=effect]').length){
// var $effectSelect = $('[name=effect]'),
// $helpBlock = $effectSelect.next('.help-block');
//
// $effectSelect.change(function(){
// var description = $(this).find(":selected").data('description');
// $helpBlock.text(description);
// });
// }
});
// Rule to save

View File

@@ -40,34 +40,7 @@
});
}*/
// -- Effect description
if($('[name=effect]').length){
var $effectSelect = $('[name=effect]'),
$helpBlock = $effectSelect.next('.help-block');
$effectSelect.change(function(){
var description = $(this).find(":selected").data('description');
$helpBlock.text(description);
});
}
// -- Max usage --
if($('#is-unlimited').length){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
$('#is-unlimited').change(function(){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
else{
$('#max-usage').show().val('').attr('value', '');
}
});
}
// -- Bootstrap tooltip --
if($('[rel="tooltip"]').length){

View File

@@ -7,12 +7,14 @@
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
<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='Create'}</li>
</ul>
</nav>
<div class="page-header">
<h1>Coupons : <small>Add a coupon</small></h1>
<h1>{intl l='Coupons : '}<small>{intl l='Create a new coupon'}</small></h1>
</div>
{form name="thelia.admin.coupon.creation"}
@@ -33,9 +35,11 @@
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function($){
miniBrowser(0, '/test_to_remove/datas_coupon_edit.json');
});
</script>
{javascripts file='assets/js/json2.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/coupon.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{/block}

View File

@@ -7,70 +7,50 @@
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
<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>Coupons : <small>List of coupons</small></h1>
<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">
<table class="table table-striped tablesorter">
<caption>
List of enabled coupons
{intl l='Enabled coupons'}
</caption>
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Expiration date</th>
<th>Usage left</th>
<th class="sorter-false filter-false">Actions</th>
<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>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>18/10/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>05/09/2013</td>
<td>20</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>03/12/2013</td>
<td>9</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
<tr>
<td><a href="#">XMAS13</a></td>
<td>Coupon for XMAS -30 &euro;</td>
<td>25/01/2013</td>
<td>4</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-danger btn-medium" data-toggle="confirm" data-target="#disable"><span class="glyphicon glyphicon-off"></span> Disable</a>
</td>
</tr>
{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-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-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>
@@ -80,58 +60,33 @@
<div class="col-md-12 general-block-decorator">
<table class="table table-striped tablesorter">
<caption>
List of disabled coupons
{intl l='Disabled coupons'}
</caption>
<thead>
<tr>
<th>Code</th>
<th>Title</th>
<th>Expiration date</th>
<th>Usage left</th>
<th class="sorter-false filter-false">Actions</th>
<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>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -30 &euro;</td>
<td>18/10/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -20 &euro;</td>
<td>05/09/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -50 &euro;</td>
<td>03/12/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
<tr>
<td>XMAS13</td>
<td>Coupon for XMAS -5 &euro;</td>
<td>25/01/2013</td>
<td>49</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="glyphicon glyphicon-edit"></span> Edit</a>
<a href="#url" class="btn btn-default btn-success btn-medium" data-toggle="confirm" data-target="#enable"><span class="glyphicon glyphicon-ok"></span> Enabled</a>
</td>
</tr>
{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"}{$USAGE_LEFT}{/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>
@@ -139,9 +94,6 @@
</section> <!-- #wrapper -->
{include file='includes/confirmation-modal.html' id="disable" message="{intl l='Do you really want to disable this element ?'}"}
{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"}
{/block}

View File

@@ -4,141 +4,146 @@
{block name="main-content"}
<section id="wrapper" class="container">
{loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"}
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
<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>{$CODE}</li>
</ul>
</nav>
{loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"}
<div class="page-header">
<h1>{intl l='Coupon : '}<small>{$CODE}</small></h1>
</div>
<section class="row">
<div class="col-md-12 general-block-decorator">
<div class="alert alert-info">
<span class="glyphicon glyphicon-question-sign"></span>
{if !$IS_ENABLED}{intl l='This coupon is disabled, you can enable to the bottom of this form.'}{/if}
</div>
<table class="table table-striped">
<tbody>
<tr>
<td>{intl l='Title'}</td>
<td>{$TITLE}</td>
</tr>
<tr>
<td colspan="2">
{if $IS_ENABLED}
<span class="label label-success">
{intl l="Is enabled"}
</span>
{else}
<span class="label label-warning">
{intl l="Is disabled"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{$TOOLTIP}
</td>
</tr>
<tr>
<td>{intl l='Expiration date'}</td>
<td>{$EXPIRATION_DATE} ({$DAY_LEFT_BEFORE_EXPIRATION} {intl l="days left"})</td>
</tr>
<tr>
<td>{intl l='Usage left'}</td>
<td>
{if $USAGE_LEFT}
<span class="label label-success">
{$USAGE_LEFT}
</span>
{else}
<span class="label label-warning">
0
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">{$SHORT_DESCRIPTION}</td>
</tr>
<tr>
<td colspan="2">{$DESCRIPTION}</td>
</tr>
<tr>
<td colspan="2">
{if $IS_CUMULATIVE}
<span class="label label-success">
{intl l="May be cumulative"}
</span>
{else}
<span class="label label-warning">
{intl l="Can't be cumulative"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if $IS_REMOVING_POSTAGE}
<span class="label label-warning">
{intl l="Will remove postage"}
</span>
{else}
<span class="label label-success">
{intl l="Won't remove postage"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if $IS_AVAILABLE_ON_SPECIAL_OFFERS}
<span class="label label-warning">
{intl l="Will be available on special offers"}
</span>
{else}
<span class="label label-success">
{intl l="Won't be available on special offers"}
</span>
{/if}
</td>
</tr>
<tr>
<td>{intl l='Amount'}</td>
<td>{$AMOUNT}</td>
</tr>
<tr>
<td>{intl l='Application field'}</td>
<td>
<ul class="list-unstyled">
{foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach}
{if !$smarty.foreach.rulesForeach.first}
<li><span class="label label-info">{intl l='And'}</span></li>
{/if}
<li>{$rule nofilter}</li>
{/foreach}
</ul>
</td>
</tr>
<tr>
<td>{intl l='Actions'}</td>
<td>
<a href="#url" class="btn btn-default btn-primary btn-medium"><span class="icon-edit icon-white"></span> {intl l='Edit'}</a>
</td>
</tr>
</tbody>
</table>
{/loop}
<div class="page-header">
<h1>{intl l='Coupon : '}<small>{$CODE}</small></h1>
</div>
</section>
<section class="row">
<div class="col-md-12 general-block-decorator">
{if !$IS_ENABLED}
<div class="alert alert-info">
<span class="glyphicon glyphicon-question-sign"></span>
{intl l='This coupon is disabled, you can enable to the bottom of this form.'}
</div>
{/if}
<table class="table table-striped">
<tbody>
<tr>
<td>{intl l='Title'}</td>
<td>{$TITLE}</td>
</tr>
<tr>
<td colspan="2">
{if $IS_ENABLED}
<span class="label label-success">
{intl l="Is enabled"}
</span>
{else}
<span class="label label-warning">
{intl l="Is disabled"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{$TOOLTIP}
</td>
</tr>
<tr>
<td>{intl l='Amount'}</td>
<td>{$AMOUNT}</td>
</tr>
<tr>
<td>{intl l='Expiration date'}</td>
<td>{$EXPIRATION_DATE} ({$DAY_LEFT_BEFORE_EXPIRATION} {intl l="days left"})</td>
</tr>
<tr>
<td>{intl l='Usage left'}</td>
<td>
{if $USAGE_LEFT}
<span class="label label-success">
{$USAGE_LEFT}
</span>
{else}
<span class="label label-warning">
0
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if $IS_CUMULATIVE}
<span class="label label-success">
{intl l="May be cumulative"}
</span>
{else}
<span class="label label-warning">
{intl l="Can't be cumulative"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if $IS_REMOVING_POSTAGE}
<span class="label label-warning">
{intl l="Will remove postage"}
</span>
{else}
<span class="label label-success">
{intl l="Won't remove postage"}
</span>
{/if}
</td>
</tr>
<tr>
<td colspan="2">
{if $IS_AVAILABLE_ON_SPECIAL_OFFERS}
<span class="label label-warning">
{intl l="Will be available on special offers"}
</span>
{else}
<span class="label label-success">
{intl l="Won't be available on special offers"}
</span>
{/if}
</td>
</tr>
<tr>
<td>{intl l='Application field'}</td>
<td>
<ul class="list-unstyled">
{foreach from=$APPLICATION_CONDITIONS item=rule name=rulesForeach}
{if !$smarty.foreach.rulesForeach.first}
<li><span class="label label-info">{intl l='And'}</span></li>
{/if}
<li>{$rule nofilter}</li>
{/foreach}
</ul>
</td>
</tr>
<tr>
<td colspan="2">{$SHORT_DESCRIPTION}</td>
</tr>
<tr>
<td colspan="2">{$DESCRIPTION}</td>
</tr>
<tr>
<td colspan="2">
<a href="{$urlEditCoupon}" class="btn btn-default btn-primary btn-medium">
<span class="icon-edit icon-white"></span> {intl l='Edit'}
</a>
</td>
</tr>
</tbody>
</table>
</div>
</section>
{/loop}
</section> <!-- #wrapper -->
{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"}

View File

@@ -7,12 +7,14 @@
<nav>
<ul class="breadcrumb">
{include file="includes/coupon_breadcrumb.html"}
<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='Update'} {$couponCode}</li>
</ul>
</nav>
<div class="page-header">
<h1>Coupons : <small>Update a coupon</small></h1>
<h1>{intl l='Coupons : '}<small>{intl l='Update'} {$couponCode}</small></h1>
</div>
{form name="thelia.admin.coupon.creation"}

View File

@@ -11,118 +11,119 @@
{/form_field}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/coupon/read/{id}'}" />
<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">
<div class="form-group">
<label for="code">{intl l='Code :'}</label>
{form_field form=$form field='code'}
{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}
{/form_field}
</div>
</div>
{/form_field}
<div class="form-group">
<label for="title">{intl l='Title :'}</label>
{form_field form=$form field='title'}
{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}
{/form_field}
</div>
</div>
{/form_field}
<div class="form-group">
<label for="enabled" class="checkbox">
{form_field form=$form field='isEnabled'}
{form_field form=$form field='isEnabled'}
<div class="form-group {if $error}has-error{/if}">
<label for="enabled" class="checkbox control-label">
<input id="enabled" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is enabled ?'}
</label>
</div>
{intl l='Is enabled ?'}
</label>
</div>
{/form_field}
<div class="form-group">
<label for="available-on-special-offers" class="checkbox">
{form_field form=$form field='isAvailableOnSpecialOffers'}
{form_field form=$form field='isAvailableOnSpecialOffers'}
<div class="form-group {if $error}has-error{/if}">
<label for="available-on-special-offers" class="checkbox control-label">
<input id="available-on-special-offers" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is available on special offers ?'}
</label>
</div>
{intl l='Is available on special offers ?'}
</label>
</div>
{/form_field}
<div class="form-group">
<label for="cumulative" class="checkbox">
{form_field form=$form field='isCumulative'}
{form_field form=$form field='isCumulative'}
<div class="form-group {if $error}has-error{/if}">
<label for="cumulative" class="checkbox control-label">
<input id="cumulative" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is cumulative ?'}
</label>
</div>
{intl l='Is cumulative ?'}
</label>
</div>
{/form_field}
<div class="form-group">
<label for="renoving-postage" class="checkbox">
{form_field form=$form field='isRemovingPostage'}
{form_field form=$form field='isRemovingPostage'}
<div class="form-group {if $error}has-error{/if}">
<label for="renoving-postage" class="checkbox control-label">
<input id="renoving-postage" type="checkbox" name="{$name}" {if $value}value="1" checked{else}value="0"{/if} >
{if $error}{$message}{/if}
{/form_field}
{intl l='Is removing postage ?'}
</label>
</div>
<div class="form-group">
<label for="expiration-date">{intl l='Expiration date :'}</label>
<div class="input-append date" data-date="12/02/2012" data-date-format="dd/mm/yyyy">
{form_field form=$form field='expirationDate'}
<input type="text" id="expiration-date" name="{$name}" value="{if $defaultDate}{$defaultDate}{else}{$value}{/if}">
{if $error}{$message}{/if}
{/form_field}
<span class="add-on"><span class="icon-th"></span></span>
{intl l='Is removing postage ?'}
</label>
</div>
</div>
{/form_field}
<div class="form-group">
<label for="max-usage">{intl l='Max usage :'}</label>
<label for="is-unlimited" class="checkbox">
<input id="is-unlimited" type="checkbox" name="is-unlimited" checked >
{intl l='Is unlimited ?'}
</label>
{form_field form=$form field='maxUsage'}
{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" value="{if $defaultDate}{$defaultDate}{else}{$value}{/if}">
{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="max-usage" class="control-label">{intl l='Max usage :'}</label>
<label for="is-unlimited" class="checkbox control-label">
<input id="is-unlimited" type="checkbox" name="is-unlimited" {if $error}{else}checked{/if} >
{intl l='Is unlimited ?'}
</label>
<input id="max-usage" type="text" class="form-control" name="{$name}" value="{$value}" placeholder="{intl l='max usage'}">
{if $error}{$message}{/if}
{/form_field}
</div>
</div>
{/form_field}
</div>
<div class="col-md-8">
<div class="well clearfix">
<div class="col-md-6">
<div class="form-group">
<label for="effect">{intl l='Effect :'}</label>
{form_field form=$form field='effect'}
{form_field form=$form field='effect'}
<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>
{foreach from=$availableCoupons item=availableCoupon}
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}">{$availableCoupon.name}</option>
<option value="{$availableCoupon.serviceId}" data-description="{$availableCoupon.toolTip}" {if $value == $availableCoupon.serviceId}selected="selected"{/if}>{$availableCoupon.name}</option>
{/foreach}
</select>
{if $error}{$message}{/if}
{/form_field}
<span id="effectToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
</div>
<span id="effectToolTip" class="help-block">{$availableCoupons.0.toolTip}</span>
</div>
{/form_field}
</div>
<div class="col-md-6">
<div class="form-group">
<label for="amount">{intl l='Amount :'}</label>
{form_field form=$form field='amount'}
{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}
{/form_field}
</div>
{*<div class="form-group">*}
</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">*}
@@ -136,27 +137,27 @@
</div>
</div>
<div class="form-group">
<label for="short-description">{intl l='Short description :'}</label>
{form_field form=$form field='shortDescription'}
<textarea id="short-description" name="{$name}" placeholder="{intl l='short description'}" class="span12" rows="5">{$value nofilter}</textarea>
{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}
{/form_field}
</div>
</div>
{/form_field}
</div>
<div class="clearfix"></div>
<div class="col-md-12">
<div class="form-group">
<label for="description">{intl l='Long description :'}</label>
{form_field form=$form field='description'}
{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}
{/form_field}
</div>
</div>
{/form_field}
<button type="submit" class="btn btn-default btn-primary">{intl l='Save'}</button>
<button type="submit" class="btn btn-default btn-primary">{intl l='Save your modifications'}</button>
</div>
</div>
@@ -186,16 +187,16 @@
<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>
<span class="glyphicon glyphicon-plus-sign"></span> {intl l='Save this rule'}
</a>
<div id="rule-add-organizer" class="form-group col-md-2">
<label for="type">{intl l='Condition type :'}</label>
<label class="radio">
<input type="radio" name="type" id="type" value="1" checked> {intl l='And'}
<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" value="2"> {intl l='Or'}
<input type="radio" name="type" class="form-control" value="2"> {intl l='Or'}
</label>
</div>

View File

@@ -1,5 +0,0 @@
{* Breadcrumb for coupon browsing and editing *}
<li><a href="{url path='admin/home'}">Home</a></li>
<li><a href="{url path='admin/coupon'}">Coupon</a></li>
<li><a href="{url path="admin/coupon/browse/$ID"}">Browse</a></li>