Browse Source

[Backend] Switch boulangerie

Mise en place d'une liste sélective permettant à l'administrateur de switcher
entre les différentes boulangeries.
prodstable
keun 8 years ago
parent
commit
598b01828a
3 changed files with 37 additions and 1 deletions
  1. +15
    -0
      backend/controllers/SiteController.php
  2. +13
    -1
      backend/views/layouts/main.php
  3. +9
    -0
      backend/web/js/lechatdesnoisettes.js

+ 15
- 0
backend/controllers/SiteController.php View File

@@ -35,6 +35,14 @@ class SiteController extends BackendController
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
],
[
'actions' => ['change-etablissement'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN ;
}
],
],
],
'verbs' => [
@@ -85,4 +93,11 @@ class SiteController extends BackendController

return $this->goHome();
}
public function actionChangeEtablissement($id)
{
Yii::$app->user->identity->id_etablissement = $id ;
Yii::$app->user->identity->save() ;
$this->redirect(['commande/index']) ;
}
}

+ 13
- 1
backend/views/layouts/main.php View File

@@ -5,6 +5,9 @@ use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\models\Etablissement ;
use common\models\User ;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;

/* @var $this \yii\web\View */
/* @var $content string */
@@ -73,7 +76,16 @@ AppAsset::register($this);
<div class="container-fluid container-body">
<?php if(!Yii::$app->user->isGuest): ?>
<div class="nom-boulange">
<span><?= Html::encode(Yii::$app->user->identity->getNomMagasin()) ; ?></span>
<?php if(Yii::$app->user->identity->status == User::STATUS_BOULANGER): ?>
<span><?= Html::encode(Yii::$app->user->identity->getNomMagasin()) ; ?></span>
<?php elseif(Yii::$app->user->identity->status == User::STATUS_ADMIN): ?>
<?php $form = ActiveForm::begin() ; ?>
<?= Html::dropDownList('select_etablissement', Yii::$app->user->identity->id_etablissement, ArrayHelper::map(Etablissement::find()->orderBy('nom ASC')->all(), 'id', function($model, $defaultValue) {
return Html::encode($model->nom) ;
})) ; ?>
<?php ActiveForm::end(); ?>
<?php endif; ?>
<?php $etat_paiement_etablissement = Yii::$app->user->identity->etatPaiementEtablissement(); ?>
<?php if($etat_paiement_etablissement == 'essai'): ?>
<span id="etat-paiement-etablissement">Période d'essai gratuite

+ 9
- 0
backend/web/js/lechatdesnoisettes.js View File

@@ -9,8 +9,17 @@ $(document).ready(function() {
chat_index_commandes_points_vente() ;
chat_btn_plus_moins() ;
chat_commandeauto() ;
// admin
chat_select_etablissement() ;
}) ;

function chat_select_etablissement() {
$('select[name="select_etablissement"]').change(function() {
window.location.href = 'index.php?r=site/change-etablissement&id='+$(this).val() ;
}) ;
}

function chat_commandeauto() {
// dates

Loading…
Cancel
Save