- implementation Coupon Read page
This commit is contained in:
gmorel
2013-09-03 11:02:02 +02:00
parent 6383de251e
commit 6ee99b6cad
4 changed files with 79 additions and 33 deletions

View File

@@ -59,8 +59,7 @@
<default key="action">edit</default>
</route>
<route id="admin.coupon.read" path="/admin/coupon/read/{id}">
<default key="_controller">Thelia\Controller\Admin\CouponController::processAction</default>
<default key="action">read</default>
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
</route>

View File

@@ -23,6 +23,7 @@
namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Event\Coupon\CouponCreateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Security\Exception\AuthenticationException;
@@ -143,15 +144,23 @@ class CouponController extends BaseAdminController
/**
* Manage Coupons read display
*
* @param array $args GET arguments
* @param int $id Coupon Id
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function readCoupon($args)
public function readAction($id)
{
$this->checkAuth("ADMIN", "admin.coupon.view");
return $this->render('coupon/read', $args);
// Database request repeated in the loop but cached
$search = CouponQuery::create();
$coupon = $search->findOneById($id);
if ($coupon === null) {
return $this->pageNotFound();
}
return $this->render('coupon/read', array('couponId' => $id));
}
/**

View File

@@ -72,7 +72,7 @@ class Coupon extends BaseI18nLoop
$search = CouponQuery::create();
/* manage translations */
$locale = $this->configureI18nProcessing($search, array());
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION', 'SHORT_DESCRIPTION'));
$id = $this->getId();
@@ -91,9 +91,17 @@ class Coupon extends BaseI18nLoop
$loopResultRow->set("ID", $coupon->getId())
->set("IS_TRANSLATED", $coupon->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE", $locale)
->set("CODE", $coupon->getCode())
->set("TITLE", $coupon->getVirtualColumn('i18n_TITLE'))
->set("CODE", $coupon->getVirtualColumn('i18n_CODE'));
->set("SHORT_DESCRIPTION", $coupon->getVirtualColumn('i18n_SHORT_DESCRIPTION'))
->set("DESCRIPTION", $coupon->getVirtualColumn('i18n_DESCRIPTION'))
->set("EXPIRATION_DATE", $coupon->getExpirationDate())
->set("USAGE_LEFT", $coupon->getMaxUsage())
->set("IS_CUMULATIVE", $coupon->getIsCumulative())
->set("IS_REMOVING_POSTAGE", $coupon->getIsRemovingPostage())
->set("IS_ENABLED", $coupon->getIsEnabled())
->set("AMOUNT", $coupon->getAmount())
->set("APPLICATION_CONDITIONS", $coupon->getRules());
$loopResult->addRow($loopResultRow);
}

View File

@@ -18,42 +18,78 @@
<h1>Coupons : <small>Read coupon n°1</small></h1>
</div>
<section class="row-fluid">
<div class="span12 general-block-decorator">
{loop type="coupon" name="read_coupon" id=1 backend_context="true"}
<div class="alert alert-info">
<span class="icon-question-sign"></span> This coupon is disabled, you can enable to the bottom of this form.
<span class="icon-question-sign"></span>
{if #IS_ENABLED}{else}This coupon is disabled, you can enable to the bottom of this form.{/if}
</div>
<table class="table table-striped">
<table class="table table-striped">
<tbody>
<tr>
<td>Code</td>
<td>XMAS13</td>
<td>#CODE</td>
</tr>
<tr>
<td>Title</td>
<td>Coupon for XMAS -30 &euro;</td>
<td>#TITLE</td>
</tr>
<tr>
<td>Expiration date</td>
<td>25/12/2013</td>
<td>EXPIRATION_DATE</td>
</tr>
<tr>
<td>Usage left</td>
<td>49 times</td>
<td>
{if #USAGE_LEFT}
<span class="label label-success">
#USAGE_LEFT
</span>
{else}
<span class="label label-important">
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-important">
{intl l="Can't be cumulative"}
</span>
{/if}
</td>
</tr>
<tr>
<td>May be combined</td>
<td><span class="label label-success">Yes</span></td>
<td colspan="2">
{if #IS_REMOVING_POSTAGE}
<span class="label label-important">
{intl l="Will remove postage"}
</span>
{else}
<span class="label label-success">
{intl l="Won't remove postage"}
</span>
{/if}
</td>
</tr>
<tr>
<td>Cancel shipping</td>
<td><span class="label label-important">No</span></td>
</tr>
<tr>
<td>Effect</td>
<td>Remove 30 &euro; to the cart price</td>
<td>Amount</td>
<td>#AMOUNT</td>
</tr>
<tr>
<td>Conditions of application</td>
@@ -73,10 +109,12 @@
</td>
</tr>
</tbody>
</table>
</table>
{/loop}
</div>
</section>
</section> <!-- #wrapper -->
<aside id="enable" class="modal hide fade" role="dialog">
@@ -92,14 +130,6 @@
</div>
</aside> <!-- #enable / Enable confirmation -->
boucle coupon
{loop type="coupon" name="read_coupon" backend_context="true"}
inside
#ID
#CODE
#TITLE
{/loop}
{include file='includes/js.inc.html'}
{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'}