Merge branch 'refs/heads/Issue_1851_cockipt_permissions'

Conflicts:
	include/controllers/default/cockpit/charts/community.php
	include/controllers/default/cockpit/restaurants/index.php
	include/views/default/cockpit/home/index.phtml
	include/views/default/cockpit/layout/core.phtml
	include/views/default/cockpit/restaurants/index.phtml
This commit is contained in:
Daniel Camargo 2013-10-30 14:13:18 -02:00
commit 14da4fc315
45 changed files with 530 additions and 177 deletions

View File

@ -6,11 +6,11 @@ class Controller_api_siteconfig extends Crunchbutton_Controller_RestAccount {
case 'post':
if (is_array($this->request()['key']) && is_array($this->request()['value'])) {
foreach ($this->request()['key'] as $k => $key) {
c::config()->site->config($key)->set($this->request()['value'][$k]);
$this->save( $key, $this->request()['value'][$k] );
}
} elseif ($this->request()['key'] && $this->request()['value']) {
c::config()->site->config($this->request()['key'])->set($this->request()['value']);
$this->save( $this->request()['key'], $this->request()['value'] );
}
break;
@ -19,4 +19,30 @@ class Controller_api_siteconfig extends Crunchbutton_Controller_RestAccount {
break;
}
}
private function save( $key, $value ){
$hasPermisstion = c::admin()->permission()->check( [ 'global' ] );
if( !$hasPermisstion ){
switch ( $key ) {
case 'support-phone-afterhours':
$hasPermisstion = c::admin()->permission()->check( [ 'global', 'support-all', 'support-settings' ] );
break;
case 'referral-inviter-credit-value':
case 'referral-invited-credit-value':
case 'referral-add-credit-to-invited':
case 'referral-limit-per-code':
case 'referral-is-enable':
case 'referral-invites-limit-per-code':
$hasPermisstion = c::admin()->permission()->check( [ 'global', 'invite-promo' ] );
break;
}
}
if( $hasPermisstion ){
c::config()->site->config($key)->set($value);
}
}
}

View File

@ -3,15 +3,27 @@
class Controller_charts_community extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global','community-metrics-all','community-metrics-view'])) {
if (!c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities', 'metrics-communities-page'] )) {
return ;
}
$hasPermissionFullPermission = c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities-all' ] );
c::view()->communities = c::admin()->communities();
$communities = Restaurant::getCommunitiesWithRestaurantsNumber();
if( !$hasPermissionFullPermission ){
$_communities = [];
foreach ( $communities as $community ) {
$permission_name = strtolower( $community->community );
$permission_name = str_replace( ' ' , '-', $permission_name );
$permission_name = "metrics-communities-{$permission_name}";
if( c::admin()->permission()->check( [ $permission_name ] ) ){
$_communities[] = $community;
}
}
$communities = $_communities;
}
c::view()->communities = $communities;
c::view()->display( 'charts/community/index' );
}
}

View File

@ -3,7 +3,7 @@
class Controller_charts extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'metrics-manage-cohorts'])) {
return ;
}
switch ( c::getPagePiece(1) ) {

View File

@ -2,7 +2,7 @@
class Controller_customers extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','customers-all'])) {
return ;
}
c::view()->display('customers/index');

View File

@ -4,10 +4,12 @@ class Controller_giftcards_content extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
return ;
$restaurant_id = $_REQUEST['restaurant'];
if( !c::admin()->permission()->check( [ 'global', 'orders-all', "gift-card-list-restaurant-{$restaurant_id}", "gift-card-list-restaurant-{$restaurant_id}", "gift-card-restaurant-{$restaurant_id}" ] ) ){
return;
}
$search = [];
if ($_REQUEST['limit']) {

View File

@ -4,7 +4,7 @@ class Controller_giftcards_credits extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-anti-cheat'])) {
return ;
}

View File

@ -4,7 +4,7 @@ class Controller_giftcards_groups extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-groups'])) {
return ;
}

View File

@ -3,13 +3,19 @@
class Controller_giftcards extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'gift-card-all', 'gift-card-list-page', 'gift-card-list-all'])) {
return ;
}
c::view()->page = 'giftcards';
if( c::getPagePiece(1) == 'new' ){
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-create', 'gift-card-create-all'])) {
return ;
}
$id_user = $_GET[ 'id_user' ];
if( $id_user != '' ){
$user = Crunchbutton_User::o( $id_user );
@ -39,12 +45,23 @@ class Controller_giftcards extends Crunchbutton_Controller_Account {
c::view()->display('giftcards/new');
} else if( c::getPagePiece(1) == 'sms' ){
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-create', 'gift-card-create-all'])) {
return ;
}
c::view()->display('giftcards/sms');
} else if( c::getPagePiece(1) == 'email' ){
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-create', 'gift-card-create-all'])) {
return ;
}
c::view()->display('giftcards/email');
} else if( c::getPagePiece(1) == 'print' ){
$giftcards = Crunchbutton_Promo::multiple( c::getPagePiece(2) );
c::view()->layout('layout/blank');
c::view()->giftcards = $giftcards;
@ -61,6 +78,11 @@ class Controller_giftcards extends Crunchbutton_Controller_Account {
c::view()->display('giftcards/print/brown');
} else {
$giftcard = Crunchbutton_Promo::o(c::getPagePiece(1));
if (!c::admin()->permission()->check(['global','gift-card-all', 'gift-card-create-all', 'gift-card-list-page', "gift-card-list-restaurant-{$giftcard->id_restaurant}", "gift-card-create-restaurant-{$giftcard->id_restaurant}", "gift-card-restaurant-{$giftcard->id_restaurant}"])) {
return;
}
if ($giftcard->id_promo) {
c::view()->users = Crunchbutton_User::q('SELECT u.id_user, u.name, u.phone, u.email FROM user u INNER JOIN user_auth ua ON ua.id_user = u.id_user WHERE u.active = 1 ORDER BY u.name ASC');;
c::view()->giftcard = $giftcard;

View File

@ -19,10 +19,13 @@ class Controller_home_charts extends Crunchbutton_Controller_Account {
foreach( $tags as $tag ){
$hasTag = true;
$hasPermission = c::admin()->permission()->check( [ "metrics-{$tag}" ] );
if( !$hasPermission && $tag == 'reps' ){
$hasPermission = c::admin()->permission()->check( [ 'metrics-communities-all', "metrics-communities-{$_REQUEST[ 'community' ]}" ] );
}
if( $hasPermission ){ break; }
}
}
if( !$hasTag ){
$hasPermission = c::admin()->permission()->check( [ 'metrics-no-grouped-charts' ] );
}

View File

@ -4,7 +4,7 @@ class Controller_home_curation extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'curation'])) {
return ;
}

View File

@ -4,7 +4,7 @@ class Controller_home_marketing extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','marketing-events'])) {
return ;
}

View File

@ -4,7 +4,7 @@
class Controller_issues extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','github'])) {
return ;
}

View File

@ -3,7 +3,7 @@
class Controller_loc extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check([ 'global','locations'])) {
return ;
}

View File

@ -3,7 +3,7 @@
class Controller_logs_content extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','logs'])) {
return ;
}

View File

@ -3,7 +3,7 @@
class Controller_logs extends Crunchbutton_Controller_Account {
public function init() {
// @permission
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','logs'])) {
return ;
}
c::view()->display('logs/index');

View File

@ -2,10 +2,14 @@
class Controller_orders_content extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global', 'orders'])) {
return ;
$restaurant_id = $_REQUEST['restaurant'];
if( !c::admin()->permission()->check( [ 'global', 'orders-all', "orders-list-restaurant-{$restaurant_id}" ] ) ){
return;
}
$search = [];
if ($_REQUEST['limit']) {
$search['limit'] = intval($_REQUEST['limit']);
}
@ -37,7 +41,7 @@ class Controller_orders_content extends Crunchbutton_Controller_Account {
if ($_REQUEST['restaurant']) {
$search['restaurant'] = $_REQUEST['restaurant'];
}
if ($_REQUEST['community']) {
$search['community'] = $_REQUEST['community'];
}
@ -45,6 +49,11 @@ class Controller_orders_content extends Crunchbutton_Controller_Account {
c::view()->orders = Order::find($search);
if ($_REQUEST['export']) {
if( !c::admin()->permission()->check(['global','orders-all','orders-export'] ) ) {
return;
}
c::view()->layout('layout/csv');
c::view()->display('orders/csv', ['display' => true, 'filter' => false]);
} else {

View File

@ -2,7 +2,7 @@
class Controller_orders extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','orders-all','orders-list-page'])) {
return ;
}
c::view()->display('orders/index');

View File

@ -2,7 +2,7 @@
class Controller_orders_newusers extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','orders-all','orders-new-users'])) {
return ;
}
if( c::getPagePiece( 2 ) == 'sendemail' ){

View File

@ -2,7 +2,7 @@
class Controller_orders_notify extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','orders-all','orders-notification'])) {
return ;
}
$order = new Order(c::getPagePiece(3));

View File

@ -2,7 +2,7 @@
class Controller_referral extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global','invite-promo'])) {
return ;
}

View File

@ -41,16 +41,18 @@ class Controller_restaurants extends Crunchbutton_Controller_Account {
*
* @return void
*/
private function _list() {
private function _list()
{
$view = Cana::view();
/* @var $view Cana_View */
$communities = Crunchbutton_Community::q('SELECT * FROM community');
c::view()->restaurants = c::admin()->restaurants();
c::view()->communities = $communities;
c::view()->display('restaurants/index');
$communities = Crunchbutton_Community::q('SELECT * FROM community');
$view->communities = $communities;
$view->display('restaurants/index');
}
public function init() {
c::view()->page = 'restaurants';
if(c::getPagePiece(1) == 'legacy') {
@ -65,13 +67,20 @@ class Controller_restaurants extends Crunchbutton_Controller_Account {
$restaurant = Restaurant::o(c::getPagePiece($page_piece_index));
if( $restaurant->id_restaurant != '' && $restaurant->id_restaurant ){
if( !c::admin()->permission()->check( [ 'global', 'restaurants-all', 'restaurants-crud', "restaurant-{$restaurant->id_restaurant}-edit", "restaurant-{$restaurant->id_restaurant}-all" ] ) ){
return;
}
}
/* @var $restaurant Crunchbutton_Restaurant */
$this->restaurant = $restaurant;
c::view()->restaurant = $restaurant;
if (c::getPagePiece($page_piece_index) == 'new') {
// @permission check for restaurant permissions
if (!c::admin()->permission()->check(['global','restaurants-all', 'restaurants-create'])) {
if (!c::admin()->permission()->check(['global','restaurants-all', 'restaurants-crud'])) {
return;
}
$restaurant->save();
@ -88,7 +97,7 @@ class Controller_restaurants extends Crunchbutton_Controller_Account {
break;
case 'image':
// @permission
if (!c::admin()->permission()->check(['global','restaurants-all','restaurant-'.$restaurant->id_restaurant.'-all','restaurant-'.$restaurant->id_restaurant.'-image'])) {
if (!c::admin()->permission()->check(['global','restaurants-all', 'restaurants-crud', 'restaurant-'.$restaurant->id_restaurant.'-all', 'restaurant-'.$restaurant->id_restaurant.'-edit','restaurant-'.$restaurant->id_restaurant.'-image'])) {
return;
}
if ($_FILES['image']) {
@ -104,7 +113,7 @@ class Controller_restaurants extends Crunchbutton_Controller_Account {
break;
case 'fax':
// @permission
if (!c::admin()->permission()->check(['global','restaurants-all','restaurant-'.$restaurant->id_restaurant.'-all','restaurant-'.$restaurant->id_restaurant.'-fax'])) {
if (!c::admin()->permission()->check(['global', 'restaurants-all','restaurant-'.$restaurant->id_restaurant.'-all','restaurant-'.$restaurant->id_restaurant.'-fax'])) {
return;
}
c::view()->notification = $restaurant->fax();
@ -112,7 +121,7 @@ class Controller_restaurants extends Crunchbutton_Controller_Account {
break;
default:
// @permission
if (!c::admin()->permission()->check(['global','restaurants-all','restaurant-'.$restaurant->id_restaurant,'restaurant-'.$restaurant->id_restaurant.'-all','restaurant-'.$restaurant->id_restaurant.'-edit'])) {
if (!c::admin()->permission()->check(['global','restaurants-all','restaurants-crud','restaurant-'.$restaurant->id_restaurant.'-all','restaurant-'.$restaurant->id_restaurant.'-edit'])) {
return;
}
$this->_form();

View File

@ -33,7 +33,7 @@ class Controller_Restaurants_Weight extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'restaurants-all', 'restaurants-crud', 'restaurants-weight-adj-page'])) {
return;
}

View File

@ -4,8 +4,9 @@ class Controller_suggestions_content extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
return ;
$restaurant_id = $_REQUEST['restaurant'];
if( !c::admin()->permission()->check( [ 'global', 'suggestions-all', "suggestions-list-restaurant-{$restaurant_id}" ] ) ){
return;
}
$search = [];

View File

@ -3,7 +3,7 @@
class Controller_suggestions extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'suggestions-all', 'suggestions-list-page'])) {
return ;
}

View File

@ -3,7 +3,7 @@
class Controller_support extends Crunchbutton_Controller_Account {
public function init() {
if (!c::admin()->permission()->check(['global'])) {
if (!c::admin()->permission()->check(['global', 'support-all', 'support-view', 'support-crud' ])) {
return ;
}
@ -11,6 +11,11 @@ class Controller_support extends Crunchbutton_Controller_Account {
switch ($action) {
case 'new':
if (!c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) {
return ;
}
self::create($support, $_REQUEST);
header('Location: /support/'.$support->id_support);
exit;
@ -40,26 +45,34 @@ class Controller_support extends Crunchbutton_Controller_Account {
break;
case 'conversation' :
self::setRep($support);
$sn = self::respond($support, $_POST);
c::view()->display('support/conversation.note', ['set' => ['note' => $sn]]);
exit;
if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) {
self::setRep($support);
$sn = self::respond($support, $_POST);
c::view()->display('support/conversation.note', ['set' => ['note' => $sn]]);
exit;
}
break;
case 'note' :
$support->addNote($_POST['text'], 'rep', 'internal');
exit;
if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) {
$support->addNote($_POST['text'], 'rep', 'internal');
exit;
}
break;
case 'update':
self::update( $support, $_POST );
echo $support->json();
exit;
if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) {
self::update( $support, $_POST );
echo $support->json();
exit;
}
break;
case 'actions':
self::setRep($support);
self::action($support, $_POST);
if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) {
self::setRep($support);
self::action($support, $_POST);
}
break;
}

View File

@ -8,6 +8,36 @@ class Controller_api_Giftcard extends Crunchbutton_Controller_Rest {
case 'post':
if ($_SESSION['admin']) {
// Verify the permissions
switch ( c::getPagePiece( 2 ) ) {
case 'sms':
case 'email':
case 'bunchemail':
case 'bunchsms':
case 'generate':
$ids_restaurant = $this->request()['id_restaurant'];
foreach ( $ids_restaurant as $id_restaurant ) {
if (!c::admin()->permission()->check( [ 'global','gift-card-all', 'gift-card-create-all', "gift-card-create-restaurant-{$id_restaurant}", "gift-card-restaurant-{$id_restaurant}"])) {
return ;
}
}
break;
case 'relateuser':
$giftcard = Crunchbutton_Promo::o( $this->request()['id_promo'] );
if (!c::admin()->permission()->check( [ 'global','gift-card-all', 'gift-card-create-all', "gift-card-create-restaurant-{$giftcard->id_restaurant}", "gift-card-restaurant-{$giftcard->id_restaurant}"])) {
return;
}
break;
case 'delete':
case 'removecredit':
if (!c::admin()->permission()->check( [ 'global','gift-card-all', 'gift-card-delete'])) {
return ;
}
break;
}
switch ( c::getPagePiece( 2 ) ) {
case 'generate':
@ -42,6 +72,7 @@ class Controller_api_Giftcard extends Crunchbutton_Controller_Rest {
foreach( $ids_restaurant as $id_restaurant ){
if( trim( $id_restaurant ) != '' ){
for( $i = 1; $i<= $total; $i++) {
$giftcard = new Crunchbutton_Promo;
// id_restaurant == * means any restaurant

View File

@ -17,6 +17,11 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
switch (c::getPagePiece(3)) {
case 'refund':
if ( !c::admin()->permission()->check(['global','orders-all','orders-refund'])) {
return ;
}
if (!$order->get(0)->refund()) {
echo json_encode(['status' => 'false', 'errors' => 'failed to refund']);
exit;
@ -24,6 +29,11 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
break;
case 'pay_if_refunded':
if ( !c::admin()->permission()->check(['global','orders-all','orders-refund'])) {
return ;
}
$order->pay_if_refunded = c::getPagePiece(4);
$order->save();
echo json_encode(['status' => 'success']);
@ -31,6 +41,11 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
break;
case 'resend_notification':
if ( !c::admin()->permission()->check(['global','orders-all','orders-notification'])) {
return ;
}
if ( $order->resend_notify() ) {
echo json_encode(['status' => 'success']);
exit;

View File

@ -8,6 +8,10 @@ class Controller_api_referral extends Crunchbutton_Controller_Rest {
case 'save':
if ( $_SESSION['admin'] && $this->method() == 'post' ) {
if( !c::admin()->permission()->check( [ 'global', 'invite-promo' ] ) ){
return;
}
Crunchbutton_Config::store( Crunchbutton_Referral::KEY_IS_REFERRAL_ENABLE, $this->request()['enabled'] );
Crunchbutton_Config::store( Crunchbutton_Referral::KEY_INVITER_CREDIT_VALUE, $this->request()['inviter_credit'] );
Crunchbutton_Config::store( Crunchbutton_Referral::KEY_INVITED_CREDIT_VALUE, $this->request()['invited_credit'] );

View File

@ -139,6 +139,42 @@ class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
$r = Restaurant::o(c::getPagePiece(2));
/* @var $r Crunchbutton_Restaurant */
// Permissions
if( !c::admin() ){
return;
}
$hasPermission = c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$r->id_restaurant}-all" ]);
if( !$hasPermission ){
switch ($action) {
case 'fake-merchant':
case 'fakeremove-merchant':
case 'remove-bankinfo':
case 'paymentinfo':
case 'merchant':
case 'credit':
case 'bankinfo':
$hasPermission = c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$r->id_restaurant}-pay" ]);
break;
case 'weight-adj':
case 'categories':
case 'notifications':
case 'hours':
case 'delete-category':
case 'delete-dish':
case 'save-dish':
case 'dishes':
default:
$hasPermission = c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$r->id_restaurant}-edit" ]);
break;
}
}
if( !$hasPermission ){
return;
}
$action = c::getPagePiece(3);
switch ($action) {
case 'categories':
@ -259,7 +295,7 @@ class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
$weight_adj = $this->request()['weight_adj'];
$r->weight_adj = $weight_adj;
$r->save();
echo json_encode( [ 'success' => 'dish saved' ] );
echo json_encode( [ 'success' => 'saved' ] );
break;
default:

View File

@ -160,14 +160,18 @@ if ( $credit->id_credit ) {
<a target="_blank" class="btn btn-gray" href="/giftcards/print/<?=$this->giftcard->id_promo;?>"><i class="icon-print"></i> Print</a>&nbsp;
<a target="_blank" class="btn btn-blue" href="/giftcards/print-flyer/<?=$this->giftcard->id_promo;?>"><i class="icon-picture"></i> Print flyer</a>&nbsp;
<?php } ?>
<?php if( $this->giftcard->phone ) { ?>
<div class="btn btn-blue admin-giftcard-sms"><i class="icon-phone"></i> Send by sms</div>&nbsp;
<?php } ?>
<?php if( $this->giftcard->email ) { ?>
<div class="btn btn-blue admin-giftcard-email"><i class="icon-envelope"></i> Send by email</div>&nbsp;
<?php } ?>
<?php if( !$this->giftcard->user()->id_user && !$this->giftcard->note ) { ?>
<div class="btn btn-green admin-giftcard-save"><i class="icon-user"></i> Relate user</div>&nbsp;
<?php
if( c::admin()->permission()->check( [ 'global', 'gift-card-all', 'gift-card-create-all', "gift-card-restaurant-{$this->giftcard->id_restaurant}", "gift-card-restaurant-create-{$this->giftcard->id_restaurant}" ] ) ){
?>
<?php if( $this->giftcard->phone ) { ?>
<div class="btn btn-blue admin-giftcard-sms"><i class="icon-phone"></i> Send by sms</div>&nbsp;
<?php } ?>
<?php if( $this->giftcard->email ) { ?>
<div class="btn btn-blue admin-giftcard-email"><i class="icon-envelope"></i> Send by email</div>&nbsp;
<?php } ?>
<?php if( !$this->giftcard->user()->id_user && !$this->giftcard->note ) { ?>
<div class="btn btn-green admin-giftcard-save"><i class="icon-user"></i> Relate user</div>&nbsp;
<?php } ?>
<?php } ?>
</td>
</tr>
@ -259,6 +263,9 @@ if ( $credit->id_credit ) {
</div>
<!-- box track info end -->
<!-- box danger zone start -->
<?php
if (c::admin()->permission()->check( [ 'global','gift-card-all', 'gift-card-delete'])) {
?>
<div class="box">
<div class="box-header">
<span class="title">Danger Zone</span>
@ -281,6 +288,7 @@ if ( $credit->id_credit ) {
<?php } ?>
</div>
</div>
<?php } ?>
<!-- box danger zone end -->
</div>
</div>

View File

@ -1,6 +1,9 @@
<?
$this->title = 'Gift cards';
$this->titleicon = 'gift';
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'gift-card-all', 'gift-card-list-all' ] );
?>
<!-- content -->
<div class="container-fluid padded">
@ -49,10 +52,21 @@
<label class="span3">Restaurant</label>
<span class="span8 pull-right">
<select name="restaurant" class="chzn-select">
<option value="" selected>[ All ]</option>
<? foreach (Restaurant::q('select * from restaurant order by name') as $restaurant) : ?>
<option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option>
<? endforeach ; ?>
<?php
$restaurants = Restaurant::q('select * from restaurant order by name');
if( $hasPermissionToAllRestaurants ){
echo '<option value="" selected>[ All ]</option>';
foreach ( $restaurants as $restaurant ) {
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
} else {
foreach ( $restaurants as $restaurant ) {
if( c::admin()->permission()->check( [ "gift-card-list-restaurant-{$restaurant->id_restaurant}", "gift-card-restaurant-{$restaurant->id_restaurant}" ] ) ){
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
}
}
?>
</select>
</span>
<div class="clearfix"></div>
@ -65,11 +79,20 @@
</div>
<div style="text-align: center;">
<?php if (c::admin()->permission()->check(['global','gift-card-all', 'gift-card-anti-cheat'])) { ?>
<a href="/giftcards/credits/" class="btn btn-red"><i class=" icon-warning-sign"></i>&nbsp;&nbsp; Anti Cheat </a>
&nbsp;&nbsp;&nbsp;
<?php } ?>
<button type="submit" class="btn btn-blue admin-giftcard-search"><i class="icon-search"></i>&nbsp;&nbsp;&nbsp; Search </button>
<?php if (c::admin()->permission()->check(['global','gift-card-all', 'gift-card-groups'])) { ?>
&nbsp;&nbsp;&nbsp;
<a href="/giftcards/groups/" class="btn btn-green admin-giftcard-group-new"><i class="icon-group"></i>&nbsp;&nbsp;&nbsp; Groups </a>
<?php } ?>
<?php if (c::admin()->permission()->check(['global','gift-card-all', 'gift-card-create', 'gift-card-create-all'])) { ?>
&nbsp;&nbsp;&nbsp;
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
@ -82,6 +105,7 @@
<li><a href="/giftcards/sms">Send by sms</a></li>
</ul>
</div>
<?php } ?>
&nbsp;&nbsp;&nbsp;
</div>

View File

@ -5,6 +5,9 @@
$this->title2 = 'Create';
$this->title2icon = 'file';
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'gift-card-all', 'gift-card-create-all' ] );
?>
<!-- Preview stuff -->
<link href='http://fonts.googleapis.com/css?family=Atomic+Age' rel='stylesheet' type='text/css'>
@ -65,10 +68,21 @@
<label>Restaurant</label>
<span>
<select id="id_restaurant" multiple class="chzn-select" name="id_restaurant" data-placeholder="Choose a restaurant" style="width:100%;">
<option value="*" <?php if( !$this->id_restaurant){ echo 'selected'; } ?>>** ANY RESTAURANT **</option>
<? foreach (Restaurant::q('SELECT * FROM restaurant WHERE giftcard = 1 ORDER BY name') as $restaurant) : ?>
<option value="<?=$restaurant->id_restaurant?>" <?php if( $this->id_restaurant == $restaurant->id_restaurant ){ echo 'selected="selected"'; } ?> ><?=$restaurant->name?></option>
<? endforeach ; ?>
<?php
$restaurants = Restaurant::q('SELECT * FROM restaurant WHERE giftcard = 1 ORDER BY name');
if( $hasPermissionToAllRestaurants ){
echo '<option value="" selected>[ All ]</option>';
foreach ( $restaurants as $restaurant ) {
?><option value="<?=$restaurant->id_restaurant?>" <?php if( $this->id_restaurant == $restaurant->id_restaurant ){ echo 'selected="selected"'; } ?> ><?=$restaurant->name?></option><?php
}
} else {
foreach ( $restaurants as $restaurant ) {
if( c::admin()->permission()->check( [ "gift-card-restaurant-{$restaurant->id_restaurant}", "gift-card-create-restaurant-{$restaurant->id_restaurant}" ] ) ){
?><option value="<?=$restaurant->id_restaurant?>" <?php if( $this->id_restaurant == $restaurant->id_restaurant ){ echo 'selected="selected"'; } ?> ><?=$restaurant->name?></option><?php
}
}
}
?>
</select>
</span>
</li>

View File

@ -1,12 +1,12 @@
<?
$this->title = 'Dashboard';
$this->subtitle = 'Crunchbutton overview';
$this->titleicon = 'dashboard';
?>
$this->title = 'Dashboard';
$this->subtitle = 'Crunchbutton overview';
$this->titleicon = 'dashboard';
?>
<!-- content -->
<div class="container-fluid padded">
<div class="row-fluid action-nav-normal">
<? if ( c::admin()->permission()->check( [ 'global','restaurants-all','restaurants-create'] ) ) : ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'restaurants-all', 'restaurants-crud','restaurants-create'] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="/restaurants/new" title="New Restaurant">
@ -16,19 +16,19 @@
<span class="triangle-button red"><i class="icon-plus"></i></span>
</div>
</div>
<? endif ; ?>
<? if ( c::admin()->permission()->check( [ 'global','support'] ) ) : ?>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global','support-all', 'support-view', 'support-crud', 'support-settings' ] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="/support" title="Support">
<i class="icon-comments-alt"></i>
<span>Support</span>
<span>Support</span>
</a>
<span class="label label-black"><?=$this->data['all']['tickets']?></span>
</div>
</div>
<? endif ; ?>
<? if ( c::admin()->permission()->check( [ 'global','issues'] ) ) : ?>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'github'] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="https://github.com/crunchbutton/crunchbutton" title="Github" target="_blank">
@ -37,9 +37,9 @@
</a>
</div>
</div>
<? endif ; ?>
<?php } ?>
<? if ( c::admin()->permission()->check( [ 'global','curation-all','curation-view'] ) ) : ?>
<?php if ( c::admin()->permission()->check( [ 'global','curation'] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="/home/curation" title="Curation">
@ -48,8 +48,8 @@
</a>
</div>
</div>
<? endif ; ?>
<? if ( c::admin()->permission()->check( [ 'global','marketing-all','marketing-view'] ) ) : ?>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global','marketing-events'] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="/home/marketing" title="Curation">
@ -58,8 +58,8 @@
</a>
</div>
</div>
<? endif ; ?>
<? if ( c::admin()->permission()->check( [ 'global','community-metrics-all','community-metrics-view'] ) ) : ?>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities', 'metrics-communities-page'] ) ) { ?>
<div class="span2">
<div class="span12 action-nav-button">
<a href="/charts/community" title="Metrics by Community">
@ -68,9 +68,9 @@
</a>
</div>
</div>
<? endif ; ?>
<?php } ?>
</div>
<? if ( c::admin()->permission()->check( [ 'global','metrics-all','metrics-view'] ) ) : ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-main', 'metrics-investors', 'metrics-detailed-analytics', 'metrics-no-grouped-charts' ] ) ) { ?>
<div class="box">
<div class="box-header">
<span class="title">Metrics</span>
@ -81,36 +81,39 @@
</ul>
</div>
<div class="box-content padded">
<? foreach ($this->graphs as $category => $graphs) : ?>
<h5><?=$category?></h5>
<?
$count = 1;
foreach ($graphs as $id => $graph) {
if ($count == 1) {
echo '<div class="row-fluid">';
}
$title = $graph['title'];
$divId = $id;
?>
<?php
foreach ($this->graphs as $category => $graphs ){
?>
<h5><?php echo $category;?></h5>
<?php
$count = 1;
foreach ($graphs as $id => $graph ){
if( $count == 1 ){
echo '<div class="row-fluid">';
}
$title = $graph[ 'title' ];
$divId = $id;
?>
<div class="span4">
<div>
<input type="checkbox"
class="icheck cat-<?=strtolower(str_replace(' ', '-', $category))?>"
id="checkbox-<?=$divId?>"
data-divId="<?=$divId?>"
name="checkbox-<?=$divId?>">
<label for="checkbox-<?=$divId?>"><?=$title?></label>
</div>
<div>
<input type="checkbox"
class="icheck cat-<?php echo strtolower( str_replace( ' ', '-', $category ) ); ?>"
id="checkbox-<?php echo $divId;?>"
data-divId="<?php echo $divId;?>"
name="checkbox-<?php echo $divId;?>">
<label for="checkbox-<?php echo $divId;?>"><?php echo $title; ?></label>
</div>
</div>
<?
if( $count % 3 == 0 ){
echo '</div>';
$count = 0;
}
$count++;
}
if( $count != 1){ echo '</div>'; }
?>
if( $count % 3 == 0 ){
echo '</div>';
$count = 0;
}
$count++;
}
if( $count != 1){ echo '</div>'; }
?>
<hr/>
<?
foreach ( $graphs as $id => $graph ){
@ -122,7 +125,7 @@
<div style="clear:both;"></div>
<?php
endforeach ;
}
?>
<!-- Settings -->
<div class="row-fluid">
@ -169,7 +172,7 @@
</div>
</div>
</div>
<? endif ; ?>
<?php } ?>
</div>
<div id="modal-simple" class="modal hide fade" style="display: none;" aria-hidden="true">
<div class="modal-header">
@ -196,8 +199,10 @@
<?php
}
?>
<h4>Cohorts</h4>
<a href="/charts/cohort/" class="btn btn-green"><i class="icon-group"></i> Manage cohorts </a>
<?php if ( c::admin()->permission()->check( ['global','metrics-manage-cohorts'] ) ) { ?>
<h4>Cohorts</h4>
<a href="/charts/cohort/" class="btn btn-green"><i class="icon-group"></i> Manage cohorts </a>
<?php } ?>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">Close</button>

View File

@ -61,7 +61,7 @@
</li>
<li class="divider"></li>
<li><a href="http://log:out@<?=$_SERVER['HTTP_HOST']?>"><i class="icon-off"></i> <span>Logout</span></a></li>
<li><a href="#"><i class="icon-off"></i> <span>Logout</span></a></li>
</ul>
</li>
</ul>
@ -89,7 +89,6 @@
<!-- side nav -->
<div class="primary-sidebar">
<ul class="nav nav-collapse collapse nav-collapse-primary">
<li class="<?=$this->page == 'home' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/dashboard">
@ -97,8 +96,7 @@
<span>Dashboard</span>
</a>
</li>
<?php if ( c::admin()->permission()->check( [ 'global','orders-all','orders-view'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','orders','orders-all','orders-list-page','orders-new-users'] ) ) { ?>
<li class="dark-nav <?=$this->page == 'orders' ? 'active' : ''?>">
<span class="glow"></span>
@ -149,7 +147,7 @@
*/ ?>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global','restaurants-view'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','restaurants-all','restaurants-list-page','restaurants-crud','restaurants-create'] ) ) { ?>
<li class="<?=$this->page == 'restaurants' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/restaurants">
@ -158,7 +156,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global','customers-all','customers-view'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'customers-all'] ) ) { ?>
<li class="<?=$this->page == 'customers' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/customers">
@ -167,7 +165,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if (c::admin()->permission()->check(['global', 'suggestions-all', 'suggestions-list-page'])) { ?>
<li class="<?=$this->page == 'suggestions' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/suggestions">
@ -176,7 +174,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if (c::admin()->permission()->check(['global', 'gift-card-all', 'gift-card-list-page', 'gift-card-list-all'])) { ?>
<li class="<?=$this->page == 'giftcards' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/giftcards">
@ -185,7 +183,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global','support-all','support-view'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','support-all', 'support-view', 'support-crud', 'support-settings' ] ) ) { ?>
<li class="<?=$this->page == 'support' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/support">
@ -194,7 +192,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global', 'github'] ) ) { ?>
<li class="<?=$this->page == 'issues' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/issues">
@ -203,7 +201,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','locations'] ) ) { ?>
<li class="<?=$this->page == 'loc' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/loc">
@ -212,7 +210,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','logs'] ) ) { ?>
<li class="<?=$this->page == 'logs' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/logs">
@ -221,7 +219,7 @@
</a>
</li>
<?php } ?>
<?php if ( c::admin()->permission()->check( [ 'global'] ) ) { ?>
<?php if ( c::admin()->permission()->check( [ 'global','invite-promo'] ) ) { ?>
<li class="<?=$this->page == 'referral' ? 'active' : ''?>">
<span class="glow"></span>
<a href="/referral">

View File

@ -27,6 +27,15 @@
</tr>
</thead>
<?php
$permissionRefund = c::admin()->permission()->check(['global','orders-all','orders-refund']);
$permissionNotification = c::admin()->permission()->check(['global','orders-all','orders-notification']);
$permissionGiftCard = c::admin()->permission()->check(['global','orders-all','gift-card-all','gift-card-crud']);
$permissionSupportCreate = c::admin()->permission()->check(['global','support-all','support-crud']);
$permissionSupportView = c::admin()->permission()->check(['global','support-all','support-crud', 'support-view']);
?>
<? foreach ($this->orders as $order) : /* @var $order Crunchbutton_Order */?>
<? $date = $order->date(); ?>
<tr class="list-order-item">
@ -37,11 +46,15 @@
<?=$order->env?>
<br/>
<br/>
<?php if( $permissionRefund ) { ?>
<? if ($order->refunded) : ?>
REFUNDED
<? else : ?>
<a href="javascript:;" class="refund" data-charged="<?php echo $order->charged(); ?>" data-gift="<?php if( $order->chargedByCredit() > 0 ){ echo $order->chargedByCredit(); } else { echo '0'; } ?>" data-uuid="<?=$order->uuid?>">REFUND</a>
<? endif ; ?>
<?php } ?>
<?php
$credit = $order->hasCredit();
if( $credit > 0 ){
@ -56,19 +69,27 @@
?>
<br />
<br />
<div class="pointer pay_if_refunded" data-value="<?php if( $order->pay_if_refunded ){ echo 1; } else { echo 0; } ?>" data-uuid="<?=$order->uuid?>">
<span><?php if( $order->pay_if_refunded ) { echo '<i class="icon-check"></i>'; } else { echo '<i class="icon-check-empty"></i>'; } ?></span> Pay if Refunded?
</div>
<?php if( $permissionRefund ) { ?>
<div class="pointer pay_if_refunded" data-value="<?php if( $order->pay_if_refunded ){ echo 1; } else { echo 0; } ?>" data-uuid="<?=$order->uuid?>">
<span><?php if( $order->pay_if_refunded ) { echo '<i class="icon-check"></i>'; } else { echo '<i class="icon-check-empty"></i>'; } ?></span> Pay if Refunded?
</div>
<?php } ?>
<br/>
<?
$support = Support::getSupportForOrder($order->id);
if($support) {
echo '<i class="icon-comments"></i> <a href="/support/' . $support->id . '">View support ticket</a>';
if($suppor ) {
if( $permissionSupportCreate ){
echo '<i class="icon-comments"></i> <a href="/support/' . $support->id . '">View support ticket</a>';
}
}
else {
echo '<i class="icon-comments"></i> <a href="javascript:create_support_from_order(' . $order->id . ');">Create support ticket</a>';
if( $permissionSupportView ){
echo '<i class="icon-comments"></i> <a href="javascript:create_support_from_order(' . $order->id . ');">Create support ticket</a>';
}
}
?>
@ -88,7 +109,9 @@
}
echo '<br/><br/>';
} ?>
<i class="icon-bullhorn"></i> <a href="javascript:;" class="resend_notification" data-confirmed="<?php echo $order->confirmed; ?>" data-uuid="<?=$order->uuid?>">Resend notification</a>
<?php if( $permissionNotification ) { ?>
<i class="icon-bullhorn"></i> <a href="javascript:;" class="resend_notification" data-confirmed="<?php echo $order->confirmed; ?>" data-uuid="<?=$order->uuid?>">Resend notification</a>
<?php } ?>
</td>
<td style="width: 300px; white-space: normal;">
<ul>
@ -177,12 +200,14 @@
</td>
</tr>
<? endif ?>
<?php if( $permissionGiftCard ){ ?>
<tr>
<td>
<br/>
<a href="/giftcards/new?id_user=<?php echo $order->user()->id_user; ?>&id_restaurant=<?php echo $order->restaurant()->id_restaurant; ?>&id_order_reference=<?php echo $order->id_order; ?>"><i class="icon-gift"></i> Add gift card</a>
</td>
</tr>
<?php } ?>
</table>
</td>
</tr>

View File

@ -2,6 +2,9 @@
$this->title = 'Orders';
$this->subtitle = 'people order shit! then eat it!';
$this->titleicon = 'truck';
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'orders-all' ] );
?>
@ -75,10 +78,21 @@
<label class="span3">Restaurant</label>
<span class="span8 pull-right">
<select name="restaurant" class="chzn-select">
<option value="" selected>[ All ]</option>
<? foreach (Restaurant::q('select * from restaurant order by name') as $restaurant) : ?>
<option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option>
<? endforeach ; ?>
<?php
$restaurants = Restaurant::q('select * from restaurant order by name');
if( $hasPermissionToAllRestaurants ){
echo '<option value="" selected>[ All ]</option>';
foreach ( $restaurants as $restaurant ) {
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
} else {
foreach ( $restaurants as $restaurant ) {
if( c::admin()->permission()->check( [ "orders-list-restaurant-{$restaurant->id_restaurant}" ] ) ){
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
}
}
?>
</select>
</span>
<div class="clearfix"></div>
@ -88,9 +102,11 @@
<span class="span8 pull-right">
<select name="community" class="chzn-select">
<option value="" selected>[ All ]</option>
<?php if( $hasPermissionToAllRestaurants ) { ?>
<? foreach (Restaurant::getCommunities() as $community) : ?>
<option value="<?=$community?>"><?=$community?></option>
<? endforeach ; ?>
<?php } ?>
</select>
</span>
<div class="clearfix"></div>
@ -105,19 +121,22 @@
<center>
<button type="submit" class="btn btn-blue admin-order-search"> Search </button>
&nbsp;&nbsp;
<?php if( c::admin()->permission()->check(['global','orders-all','orders-new-users']) ) { ?>
<a class="btn btn-green" href="/orders/newusers/">New users</a>
<?php } ?>
</center>
<br />
</div>
<div class="box">
<div class="box-header"><span class="title">Results</span>
<?php if( c::admin()->permission()->check(['global','orders-all','orders-export']) ) { ?>
<ul class="box-toolbar">
<li class="toolbar-link">
<a href="javascript:;" class="admin-order-export" title="Export"><i class="icon-download-alt"></i></a>
</li>
</ul>
<?php } ?>
</div>
<div class="box-content">
<div class="orders-loader"><center><i class="icon-spinner icon-spin" style="font-size: 50px;"></i></center></div>

View File

@ -1,6 +1,9 @@
<?
$this->title = 'Restaurants';
$this->titleicon = 'food';
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'restaurants-all', 'restaurants-crud' ] );
?>
<!-- restaurants page -->
@ -12,14 +15,27 @@
<select id="restaurant-id" class="chosen-select" style="width:480px;">
<option value="" selected>Choose...</option>
<? foreach ($this->restaurants as $restaurant) : ?>
<option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?> (permalink: <?=$restaurant->permalink?>)</option>
<? endforeach ; ?>
<?php
$restaurants = Restaurant::q('select * from restaurant order by name');
if( $hasPermissionToAllRestaurants ){
foreach ( $restaurants as $restaurant ) {
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
} else {
foreach ( $restaurants as $restaurant ) {
if( c::admin()->permission()->check( [ "restaurant-{$restaurant->id_restaurant}-edit", "restaurant-{$restaurant->id_restaurant}-all" ] ) ){
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
}
}
?>
</select>
<div class="divider"></div>
<br><br>
<?php if (c::admin()->permission()->check(['global', 'restaurants-all', 'restaurants-crud'])) { ?>
<button type="submit" class="btn btn-blue new-restaurant">Create New</button>
<?php if (c::admin()->permission()->check(['global'])) { ?>
<?php } ?>
<?php if (c::admin()->permission()->check(['global', 'restaurants-all', 'restaurants-crud', 'restaurants-weight-adj-page'])) { ?>
&nbsp;&nbsp;
<a href="/restaurants/weight/" class="btn btn-green">Weight adjustment</a>
<?php } ?>

View File

@ -30,13 +30,19 @@
<span>Notes</span>
</li>
<?php if (c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$this->restaurant->id_restaurant}-all", "restaurant-{$this->restaurant->id_restaurant}-fax" ])) { ?>
<li class="action-nav-button">
<a href="/restaurants/<?=$this->restaurant->id_restaurant?>/fax" class="tip" title="" data-original-title="Fax">
<i class="icon-print"></i>
</a>
<span>Fax</span>
</li>
<?php } ?>
<?php if (c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$this->restaurant->id_restaurant}-all", "restaurant-{$this->restaurant->id_restaurant}-pay" ])) { ?>
<li class="action-nav-button">
<a href="/restaurants/<?=$this->restaurant->id_restaurant?>/pay" class="tip" title="" data-original-title="Pay">
<i class="icon-money"></i>
@ -44,6 +50,8 @@
<span>Pay</span>
</li>
<?php } ?>
<li class="action-nav-button">
<a href="http://crunchbutton.com/food-delivery/<?=$this->restaurant->permalink?>" class="tip" title="" data-original-title="View" target="_blank">
<i class="icon-file"></i>
@ -51,12 +59,16 @@
<span>View</span>
</li>
<?php if (c::admin()->permission()->check(['global', 'restaurants-all' ])) { ?>
<li class="action-nav-button">
<a href="/restaurants/legacy/<?=$this->restaurant->id_restaurant?>" class="tip" title="" data-original-title="Old Admin">
<i class="icon-book"></i>
</a>
<span>Old Admin</span>
</li>
<?php } ?>
<li class="action-nav-button">
<a href="javascript:;" class="tip" title="" data-original-title="Revert" id="revert-button">

View File

@ -1,4 +1,7 @@
<?php
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'restaurants-all', 'restaurants-crud' ] );
$restaurants = $this->restaurants;
if ( sizeof( $restaurants ) == 0 ) { ?>
<div class="span12 padded">
@ -21,7 +24,22 @@ if ( sizeof( $restaurants ) == 0 ) { ?>
<td><?php echo $restaurant->name; ?></td>
<td><?php echo $restaurant->_weight_old; ?></td>
<td>
<input type="text" class="weight_adj" id="<?php echo $restaurant->id_restaurant; ?>" value="<?php echo $restaurant->weight_adj; ?>"/>
<?php
if( $hasPermissionToAllRestaurants ){
$hasPermission = true;
} else {
$hasPermission = c::admin()->permission()->check( [ "restaurant-{$restaurant->id_restaurant}-edit", "restaurant-{$restaurant->id_restaurant}-all" ] );
}
if( $hasPermission ){
?>
<input type="text" class="weight_adj" id="<?php echo $restaurant->id_restaurant; ?>" value="<?php echo $restaurant->weight_adj; ?>"/>
<?php
} else {
echo $restaurant->weight_adj;
}
?>
</td>
<td><?php echo $restaurant->_weight; ?></td>
<td><?php if( $restaurant->delivery == 1 ){ echo '<span style="color:green;">Yes</span>'; } else { echo '<span style="color:grey;">No</span>'; } ?></td>

View File

@ -2,6 +2,9 @@
$this->title = 'Suggestions';
$this->subtitle = 'people want shit.';
$this->titleicon = 'envelope-alt';
$hasPermissionToAllRestaurants = c::admin()->permission()->check( [ 'global', 'suggestions-all' ] );
?>
<!-- content -->
<div class="container-fluid padded">
@ -70,10 +73,21 @@
<label class="span3">Restaurant</label>
<span class="span8 pull-right">
<select name="restaurant" class="chzn-select">
<option value="" selected>[ All ]</option>
<? foreach (Restaurant::q('select * from restaurant order by name') as $restaurant) : ?>
<option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option>
<? endforeach ; ?>
<?php
$restaurants = Restaurant::q('select * from restaurant order by name');
if( $hasPermissionToAllRestaurants ){
echo '<option value="" selected>[ All ]</option>';
foreach ( $restaurants as $restaurant ) {
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
} else {
foreach ( $restaurants as $restaurant ) {
if( c::admin()->permission()->check( [ "suggestions-list-restaurant-{$restaurant->id_restaurant}" ] ) ){
?><option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option><?php
}
}
}
?>
</select>
</span>
<div class="clearfix"></div>
@ -83,9 +97,11 @@
<span class="span8 pull-right">
<select name="community" class="chzn-select">
<option value="" selected>[ All ]</option>
<? foreach (Community::q('select * from community order by name') as $community) : ?>
<option value="<?=$community->id_community?>"><?=$community->name?></option>
<?php if( $hasPermissionToAllRestaurants ) { ?>
<? foreach (Restaurant::getCommunities() as $community) : ?>
<option value="<?=$community?>"><?=$community?></option>
<? endforeach ; ?>
<?php } ?>
</select>
</span>
<div class="clearfix"></div>

View File

@ -5,6 +5,7 @@ $support = $this->support;
<div class="alert alert-refund" style="display:none;">
<span class="alert-message"></span>
</div>
<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-crud' ] ) ) { ?>
<div class="box">
<div class="box-header">
<span class="title">Actions</span>
@ -30,4 +31,5 @@ $support = $this->support;
</ul>
</div>
</div>
<?php } ?>
<?php } ?>

View File

@ -1,21 +1,24 @@
<div class="alert alert-note" style="display:none;">
<span class="alert-message"></span>
</div>
<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-crud' ] ) ) { ?>
<div class="box">
<div class="box-header">
<span class="title">Add Note</span>
</div>
<div class="box-content ">
<form class="fill-up">
<ul class="box-list">
<li class="input add-note-field" style="display:none">
<textarea name="add-note-text" placeholder="Type your note here" id="add-note-text"></textarea>
</li>
<li class="input">
<button type="button" class="btn btn-green button-add-note"><i class="icon-edit"></i> Add Note</button>
</li>
<div class="box">
<div class="box-header">
<span class="title">Add Note</span>
</ul>
</form>
</div>
</div>
<div class="box-content ">
<form class="fill-up">
<ul class="box-list">
<li class="input add-note-field" style="display:none">
<textarea name="add-note-text" placeholder="Type your note here" id="add-note-text"></textarea>
</li>
<li class="input">
<button type="button" class="btn btn-green button-add-note"><i class="icon-edit"></i> Add Note</button>
</li>
</ul>
</form>
</div>
</div>
<?php } ?>

View File

@ -5,9 +5,11 @@
<div id="history" class="box-content chat-box-wrapper"></div>
<? /* <p class="note text-center">Last message received at 14:55</p> */ ?>
<hr class="divider">
<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-crud' ] ) ) { ?>
<div class="box-footer flat padded">
<div class="input-append">
<input type="text" name="text-conversation-reply" id="text-conversation-reply" placeholder="Reply to customer">
<ul class="add-on">
<li>
<button class="btn btn-blue btn-conversation-reply"><i class="icon-mobile-phone"></i> Reply to Customer</button>
@ -15,6 +17,7 @@
</ul>
</div>
</div>
<?php } ?>
<div class="box-footer flat padded">
<div class="span6">

View File

@ -19,9 +19,11 @@
<input type="text" placeholder="" name="support-phone-afterhours" id="support-phone-afterhours" value='<?=c::config()->site->config('support-phone-afterhours')->value?>'>
</span>
</li>
<li class="input">
<button type="button" class="btn btn-blue button-save-settings">Save changes</button>
</li>
<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-settings' ] ) ) { ?>
<li class="input">
<button type="button" class="btn btn-blue button-save-settings">Save changes</button>
</li>
<?php } ?>
</ul>
</form>
</div>
@ -31,9 +33,11 @@
<div class="span6">
<div class="box">
<div class="box-header"><span class="title">Stuff</span></div>
<?php if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) { ?>
<div class="box-content padded">
<a href="/support/new"><button type="submit" class="btn btn-blue new-restaurant">New Support Ticket</button></a>
</div>
<?php } ?>
</div>
</div>
</div>
@ -47,10 +51,11 @@
<span class="title">Recent Issues</span>
<ul class="box-toolbar">
<li><span class="label label-green"><?=$this->total?> open</span></li>
<?php if (c::admin()->permission()->check(['global', 'support-all', 'support-crud' ])) { ?>
<li class="toolbar-link">
<a href="/support/new" title="Create new"><i class="icon-edit"></i></a>
</li>
<?php } ?>
</ul>
</div>
<div class="box-content">

View File

@ -87,9 +87,11 @@ $support = $this->support;
<label>How to Prevent This in the Future?</label>
<textarea name="how_to_prevent" id="how_to_prevent"><?php echo $support->how_to_prevent;?></textarea>
</li>
<?php if( c::admin()->permission()->check( [ 'global', 'support-all', 'support-crud' ] ) ) { ?>
<li class="input">
<button type="button" class="btn btn-blue button-update">Save changes</button>
</li>
<?php } ?>
</ul>
</form>
</div>