Selaa lähdekoodia

[Backend] Switch boulangerie

Mise en place d'une liste sélective permettant à l'administrateur de switcher
entre les différentes boulangeries.
master
keun 7 vuotta sitten
vanhempi
commit
598b01828a
3 muutettua tiedostoa jossa 37 lisäystä ja 1 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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…
Peruuta
Tallenna