WIP
- Add Coupon BackOffice controller - Add Coupon BackOffice template skeleton - Add Coupon BackOffice routes
This commit is contained in:
@@ -36,9 +36,18 @@
|
||||
</route>
|
||||
|
||||
<!-- Route to the Coupon controller (process Coupon browsing) -->
|
||||
<route id="admin.coupon" path="/admin/coupon">
|
||||
<route id="admin.coupon.list" path="/admin/coupon">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::indexAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.create" path="/admin/coupon/create">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::createAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.edit" path="/admin/coupon/edit">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::editAction</default>
|
||||
</route>
|
||||
<route id="admin.coupon.read" path="/admin/coupon/read">
|
||||
<default key="_controller">Thelia\Controller\Admin\CouponController::readAction</default>
|
||||
</route>
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
|
||||
@@ -1,92 +1,170 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Core\Security\Exception\AuthorizationException;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/19/13
|
||||
* Time: 3:24 PM
|
||||
*
|
||||
* Control View and Action (Model) via Events
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CouponController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected function browseCoupon($args)
|
||||
{
|
||||
$this->checkAuth("ADMIN", "admin.coupon.view");
|
||||
|
||||
return $this->render('coupons', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all Coupons Action
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
return $this->processAction();
|
||||
}
|
||||
|
||||
public function processAction()
|
||||
/**
|
||||
* Create a Coupon Action
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function createAction()
|
||||
{
|
||||
return $this->processAction('create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Coupon Action
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function editAction()
|
||||
{
|
||||
return $this->processAction('edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a Coupon Action
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function readAction()
|
||||
{
|
||||
return $this->processAction('read');
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons list display
|
||||
*
|
||||
* @param array $args GET arguments
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function browseCoupons($args)
|
||||
{
|
||||
$this->checkAuth("ADMIN", "admin.coupon.view");
|
||||
|
||||
return $this->render('coupon/list', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons creation display
|
||||
*
|
||||
* @param array $args GET arguments
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function createCoupon($args)
|
||||
{
|
||||
$this->checkAuth("ADMIN", "admin.coupon.view");
|
||||
|
||||
return $this->render('coupon/edit', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons edition display
|
||||
*
|
||||
* @param array $args GET arguments
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function editCoupon($args)
|
||||
{
|
||||
$this->checkAuth("ADMIN", "admin.coupon.view");
|
||||
|
||||
return $this->render('coupon/edit', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Coupons read display
|
||||
*
|
||||
* @param array $args GET arguments
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected function readCoupon($args)
|
||||
{
|
||||
$this->checkAuth("ADMIN", "admin.coupon.view");
|
||||
|
||||
return $this->render('coupon/read', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process all Actions
|
||||
*
|
||||
* @param string $action Action to process
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function processAction($action = 'browse')
|
||||
{
|
||||
// Get the current action
|
||||
$action = $this->getRequest()->get('action', 'browse');
|
||||
// $action = $this->getRequest()->get('action', 'browse');
|
||||
|
||||
// Get the category ID
|
||||
$id = $this->getRequest()->get('id', 0);
|
||||
// $id = $this->getRequest()->get('id', 0);
|
||||
|
||||
$args = array(
|
||||
'action' => $action,
|
||||
'current_coupon_id' => $id
|
||||
// 'current_coupon_id' => $id
|
||||
);
|
||||
|
||||
try {
|
||||
switch ($action) {
|
||||
case 'browse' : // Browse coupon
|
||||
|
||||
return $this->browseCoupons($args);
|
||||
|
||||
case 'create' : // Create a new category
|
||||
|
||||
// return $this->createNewCategory($args);
|
||||
|
||||
case 'edit' : // Edit an existing category
|
||||
|
||||
// return $this->editCategory($args);
|
||||
|
||||
case 'delete' : // Delete an existing category
|
||||
|
||||
// return $this->deleteCategory($args);
|
||||
|
||||
case 'visibilityToggle' : // Toggle visibility
|
||||
|
||||
// return $this->visibilityToggle($id);
|
||||
|
||||
case 'changePosition' : // Change position
|
||||
|
||||
// return $this->changePosition($args);
|
||||
|
||||
case 'positionUp' : // Move up category
|
||||
|
||||
// return $this->positionUp($args);
|
||||
|
||||
case 'positionDown' : // Move down category
|
||||
|
||||
// return $this->positionDown($args);
|
||||
case 'create' : // Create a new coupon
|
||||
return $this->createCoupon($args);
|
||||
case 'edit' : // Edit an existing coupon
|
||||
return $this->editCoupon($args);
|
||||
case 'read' : // Read an existing coupon
|
||||
return $this->readCoupon($args);
|
||||
}
|
||||
} catch (AuthorizationException $ex) {
|
||||
return $this->errorPage($ex->getMessage());
|
||||
|
||||
30
templates/admin/default/coupon/edit.html
Executable file
30
templates/admin/default/coupon/edit.html
Executable file
@@ -0,0 +1,30 @@
|
||||
{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"}
|
||||
|
||||
{$page_title={intl l='Coupon'}}
|
||||
|
||||
{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"}
|
||||
|
||||
{include file='includes/header.inc.html'}
|
||||
|
||||
<div class="coupons">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<ul class="breadcrumb">
|
||||
{include file="includes/coupon_breadcrumb.html"}
|
||||
</ul>
|
||||
|
||||
<h1>EDIT</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{include file='includes/js.inc.html'}
|
||||
|
||||
{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
</script>
|
||||
|
||||
{include file='includes/footer.inc.html'}
|
||||
29
templates/admin/default/coupon/list.html
Executable file
29
templates/admin/default/coupon/list.html
Executable file
@@ -0,0 +1,29 @@
|
||||
{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"}
|
||||
|
||||
{$page_title={intl l='Coupon'}}
|
||||
|
||||
{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"}
|
||||
|
||||
{include file='includes/header.inc.html'}
|
||||
|
||||
<div class="coupons">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<ul class="breadcrumb">
|
||||
{include file="includes/coupon_breadcrumb.html"}
|
||||
</ul>
|
||||
<h1>List</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{include file='includes/js.inc.html'}
|
||||
|
||||
{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
</script>
|
||||
|
||||
{include file='includes/footer.inc.html'}
|
||||
29
templates/admin/default/coupon/read.html
Executable file
29
templates/admin/default/coupon/read.html
Executable file
@@ -0,0 +1,29 @@
|
||||
{check_auth context="admin" roles="ADMIN" permissions="admin.coupon.view" login_tpl="/admin/login"}
|
||||
|
||||
{$page_title={intl l='Coupon'}}
|
||||
|
||||
{$thelia_page_css_file = "assets/bootstrap-editable/css/bootstrap-editable.css"}
|
||||
|
||||
{include file='includes/header.inc.html'}
|
||||
|
||||
<div class="coupons">
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<ul class="breadcrumb">
|
||||
{include file="includes/coupon_breadcrumb.html"}
|
||||
</ul>
|
||||
<h1>Read</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{include file='includes/js.inc.html'}
|
||||
|
||||
{javascripts file='../assets/bootstrap-editable/js/bootstrap-editable.js'}
|
||||
<script src="{$asset_url}"></script>
|
||||
{/javascripts}
|
||||
|
||||
<script>
|
||||
</script>
|
||||
|
||||
{include file='includes/footer.inc.html'}
|
||||
8
templates/admin/default/includes/coupon_breadcrumb.html
Executable file
8
templates/admin/default/includes/coupon_breadcrumb.html
Executable file
@@ -0,0 +1,8 @@
|
||||
{* Breadcrumb for coupon browsing and editing *}
|
||||
|
||||
<li><a href="{url path='admin/home'}">Home</a> <span class="divider">/</span></li>
|
||||
<li><a href="{url path='admin/coupon'}">Coupon</a></li>
|
||||
|
||||
<li><span class="divider">/</span></li>
|
||||
<li><a href="{url path="admin/coupon/browse/$ID"}">Browse</a> <span class="divider">/</span></li>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<h1>Coupon page</h1>
|
||||
|
||||
<div style="border: solid 8px; margin: 0px; padding: 0px; width: 45%; float: left">
|
||||
|
||||
<h2>COUPON</h2>
|
||||
Reference in New Issue
Block a user