瀏覽代碼

Backend : structure admin etablissements + page liste des boulangeries

master
keun 8 年之前
父節點
當前提交
bd9c0eb459
共有 7 個檔案被更改,包括 205 行新增4 行删除
  1. +73
    -0
      backend/controllers/EtablissementAdminController.php
  2. +6
    -1
      backend/controllers/EtablissementController.php
  3. +6
    -0
      backend/views/etablissement-admin/facturation.php
  4. +101
    -0
      backend/views/etablissement-admin/index.php
  5. +5
    -0
      backend/views/etablissement/facturation.php
  6. +2
    -2
      backend/views/layouts/main.php
  7. +12
    -1
      common/models/Etablissement.php

+ 73
- 0
backend/controllers/EtablissementAdminController.php 查看文件

@@ -0,0 +1,73 @@
<?php

namespace backend\controllers;

use Yii;
use common\models\User;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\helpers\Upload ;
use common\models\Etablissement ;
use yii\data\ActiveDataProvider ;

/**
* UserController implements the CRUD actions for User model.
*/
class EtablissementAdminController extends BackendController
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN ;
}
]
],
],
];
}
public function actionIndex()
{
$datas_etablissements = new ActiveDataProvider([
'query' => Etablissement::find()
->with('userEtablissement','user')
->orderBy('date_creation DESC'),
'pagination' => [
'pageSize' => 1000,
],
]);

return $this->render('index', [
'datas_etablissements' => $datas_etablissements,
]);
}
public function actionFacturation()
{
return $this->render('facturation') ;
}
protected function findModel($id)
{
if (($model = Etablissement::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

+ 6
- 1
backend/controllers/EtablissementController.php 查看文件

@@ -34,7 +34,7 @@ class EtablissementController extends BackendController
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action) {
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
return Yii::$app->user->identity->status == USER::STATUS_ADMIN
|| Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
}
]
@@ -75,6 +75,11 @@ class EtablissementController extends BackendController
}
public function actionFacturation()
{
return $this->render('facturation') ;
}
protected function findModel($id)
{
if (($model = Etablissement::findOne($id)) !== null) {

+ 6
- 0
backend/views/etablissement-admin/facturation.php 查看文件

@@ -0,0 +1,6 @@
<?php

?>

<h1>Facturation</h1>


+ 101
- 0
backend/views/etablissement-admin/index.php 查看文件

@@ -0,0 +1,101 @@
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User ;

$this->title = 'Boulangeries';
$this->params['breadcrumbs'][] = 'Administration' ;
$this->params['breadcrumbs'][] = $this->title;

?>

<h1>Boulangeries</h1>

<?= GridView::widget([
'dataProvider' => $datas_etablissements,
'columns' => [
'nom',
[
'attribute' => 'date_creation',
'format' => 'raw',
'value' => function($model) {
return date('d/m/Y', strtotime($model->date_creation)) ;
}
],
[
'attribute' => 'Lieu',
'format' => 'raw',
'value' => function($model) {
return Html::encode($model->ville.' ('.$model->code_postal.')') ;
}
],
[
'attribute' => 'Clients',
'format' => 'raw',
'value' => function($model) {
if(!$model->userEtablissement || !count($model->userEtablissement))
{
return 'Aucun client' ;
}
else {
$clients = count($model->userEtablissement).' client' ;
if(count($model->userEtablissement) > 1)
$clients .= 's' ;
return $clients ;
}
}
],
[
'attribute' => 'Contact',
'format' => 'raw',
'value' => function($model) {
if(!isset($model->user) || (isset($model->user) && count($model->user) == 0))
{
return 'Aucun contact' ;
}
else {
foreach($model->user as $u)
{
if($u->status == User::STATUS_BOULANGER)
{
return Html::encode($u->prenom.' '.$u->nom)
.'<br />'.Html::encode($u->email)
.'<br />'.Html::encode($u->telephone) ;
}
}
}
}
],
[
'attribute' => 'actif',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if($model->actif)
$html .= '<span class="label label-success">En ligne</span>' ;
else
$html .= '<span class="label label-danger">Hors-ligne</span>' ;
if(strlen($model->code))
{
$html .= ' <span class="glyphicon glyphicon-lock" data-toggle="tooltip" data-placement="bottom" data-original-title="'.Html::encode($model->code).'"></span>' ;
}
return $html ;
}
],
[
'attribute' => 'Gratuit',
'format' => 'raw',
'value' => function($model) {
if($model->gratuit)
return '<span class="label label-success">Compte gratuit</span>' ;
else
return '' ;
}
],
],
]); ?>

+ 5
- 0
backend/views/etablissement/facturation.php 查看文件

@@ -0,0 +1,5 @@
<?php

?>

<h1>Facturation</h1>

+ 2
- 2
backend/views/layouts/main.php 查看文件

@@ -109,12 +109,12 @@ AppAsset::register($this);
'items' => [
[
'label' => '<span class="glyphicon glyphicon-th-list"></span> Boulangeries',
'url' => ['/etablissement/index'],
'url' => ['etablissement-admin/index'],
'visible'=> !Yii::$app->user->isGuest,
],
[
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['/etablissement/facturation-admin'],
'url' => ['etablissement-admin/facturation'],
'visible'=> !Yii::$app->user->isGuest,
],
]

+ 12
- 1
common/models/Etablissement.php 查看文件

@@ -79,10 +79,21 @@ class Etablissement extends \yii\db\ActiveRecord
'delai_commande' => 'Délai de commande',
'solde_negatif' => 'Solde négatif',
'credit_pain' => 'Crédit pain',
'actif' => 'Actif'
'actif' => 'Actif',
'date_creation' => 'Date de création'
];
}
public function getUserEtablissement()
{
return $this->hasMany(UserEtablissement::className(), ['id_etablissement' => 'id']) ;
}
public function getUser()
{
return $this->hasMany(User::className(), ['id_etablissement' => 'id']) ;
}
public static function getEtablissementsPopulateDropdown()
{

Loading…
取消
儲存