Browse Source

[Backend] Switch boulangerie

Mise en place d'une liste sélective permettant à l'administrateur de switcher
entre les différentes boulangeries.
master
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

|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER; || 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' => [ 'verbs' => [


return $this->goHome(); 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

use yii\bootstrap\NavBar; use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs; use yii\widgets\Breadcrumbs;
use common\models\Etablissement ; use common\models\Etablissement ;
use common\models\User ;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper ;


/* @var $this \yii\web\View */ /* @var $this \yii\web\View */
/* @var $content string */ /* @var $content string */
<div class="container-fluid container-body"> <div class="container-fluid container-body">
<?php if(!Yii::$app->user->isGuest): ?> <?php if(!Yii::$app->user->isGuest): ?>
<div class="nom-boulange"> <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 $etat_paiement_etablissement = Yii::$app->user->identity->etatPaiementEtablissement(); ?>
<?php if($etat_paiement_etablissement == 'essai'): ?> <?php if($etat_paiement_etablissement == 'essai'): ?>
<span id="etat-paiement-etablissement">Période d'essai gratuite <span id="etat-paiement-etablissement">Période d'essai gratuite

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

chat_index_commandes_points_vente() ; chat_index_commandes_points_vente() ;
chat_btn_plus_moins() ; chat_btn_plus_moins() ;
chat_commandeauto() ; 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() { function chat_commandeauto() {
// dates // dates

Loading…
Cancel
Save