diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 0bc05462d..bb43c0d0c 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -59,8 +59,7 @@ edit - Thelia\Controller\Admin\CouponController::processAction - read + Thelia\Controller\Admin\CouponController::readAction diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 0895c52bf..23c231801 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -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)); } /** diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 75fda3d72..ee3cc0a5a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -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); } diff --git a/templates/admin/default/coupon/read.html b/templates/admin/default/coupon/read.html index 81557ef36..05cf19795 100755 --- a/templates/admin/default/coupon/read.html +++ b/templates/admin/default/coupon/read.html @@ -18,42 +18,78 @@

Coupons : Read coupon n°1

+
- + {loop type="coupon" name="read_coupon" id=1 backend_context="true"}
- This coupon is disabled, you can enable to the bottom of this form. + + {if #IS_ENABLED}{else}This coupon is disabled, you can enable to the bottom of this form.{/if}
- +
- + - + - + - + + + + + + + + + + - - + - - - - - - + + @@ -73,10 +109,12 @@ -
CodeXMAS13#CODE
TitleCoupon for XMAS -30 €#TITLE
Expiration date25/12/2013EXPIRATION_DATE
Usage left49 times + {if #USAGE_LEFT} + + #USAGE_LEFT + + {else} + + 0 + + {/if} +
#SHORT_DESCRIPTION
#DESCRIPTION
+ {if #IS_CUMULATIVE} + + {intl l="May be cumulative"} + + {else} + + {intl l="Can't be cumulative"} + + {/if} +
May be combinedYes + {if #IS_REMOVING_POSTAGE} + + {intl l="Will remove postage"} + + {else} + + {intl l="Won't remove postage"} + + {/if} +
Cancel shippingNo
EffectRemove 30 € to the cart priceAmount#AMOUNT
Conditions of application
- + + {/loop}
+ + -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'}