Browse Source

Backend : structure admin etablissements + page liste des boulangeries

master
keun 8 years ago
parent
commit
bd9c0eb459
7 changed files with 205 additions and 4 deletions
  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 View File

<?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 View File

'allow' => true, 'allow' => true,
'roles' => ['@'], 'roles' => ['@'],
'matchCallback' => function ($rule, $action) { '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; || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
} }
] ]
} }
public function actionFacturation()
{
return $this->render('facturation') ;
}
protected function findModel($id) protected function findModel($id)
{ {
if (($model = Etablissement::findOne($id)) !== null) { if (($model = Etablissement::findOne($id)) !== null) {

+ 6
- 0
backend/views/etablissement-admin/facturation.php View File

<?php

?>

<h1>Facturation</h1>


+ 101
- 0
backend/views/etablissement-admin/index.php View File

<?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 View File

<?php

?>

<h1>Facturation</h1>

+ 2
- 2
backend/views/layouts/main.php View File

'items' => [ 'items' => [
[ [
'label' => '<span class="glyphicon glyphicon-th-list"></span> Boulangeries', 'label' => '<span class="glyphicon glyphicon-th-list"></span> Boulangeries',
'url' => ['/etablissement/index'],
'url' => ['etablissement-admin/index'],
'visible'=> !Yii::$app->user->isGuest, 'visible'=> !Yii::$app->user->isGuest,
], ],
[ [
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation', 'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation',
'url' => ['/etablissement/facturation-admin'],
'url' => ['etablissement-admin/facturation'],
'visible'=> !Yii::$app->user->isGuest, 'visible'=> !Yii::$app->user->isGuest,
], ],
] ]

+ 12
- 1
common/models/Etablissement.php View File

'delai_commande' => 'Délai de commande', 'delai_commande' => 'Délai de commande',
'solde_negatif' => 'Solde négatif', 'solde_negatif' => 'Solde négatif',
'credit_pain' => 'Crédit pain', '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() public static function getEtablissementsPopulateDropdown()
{ {

Loading…
Cancel
Save