Browse Source

Possibilité de définir le point de vente par défaut via la liste des points de vente.

dev
Guillaume Bourgeois 5 years ago
parent
commit
e7011de789
5 changed files with 54 additions and 2 deletions
  1. +21
    -1
      backend/controllers/PointSaleController.php
  2. +18
    -0
      backend/views/point-sale/index.php
  3. +5
    -0
      backend/web/css/screen.css
  4. +8
    -0
      backend/web/sass/point_sale/_index.scss
  5. +2
    -1
      backend/web/sass/screen.scss

+ 21
- 1
backend/controllers/PointSaleController.php View File

use common\models\User; use common\models\User;
use common\models\UserPointSale; use common\models\UserPointSale;
use common\models\Order ; use common\models\Order ;
use common\models\Producer ;
use yii\helpers\Html; use yii\helpers\Html;


/** /**
return $this->redirect(['index']); return $this->redirect(['index']);
} }
/**
* Définit un point de vente par défaut.
*
* @param integer $id
*/
public function actionDefault($id)
{
$pointSale = $this->findModel($id) ;
if($pointSale) {
PointSale::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => Producer::getId()]) ;
$pointSale->default = 1 ;
$pointSale->save() ;
Yii::$app->getSession()->setFlash('success', 'Point de vente <strong>'.Html::encode($pointSale->name).'</strong> défini par défaut.') ;
}
return $this->redirect(['index']);
}


/** /**
* Recherche un point de vente en fonction de son ID. * Recherche un point de vente en fonction de son ID.
{ {
if (($model = PointSale::findOne($id)) !== null) { if (($model = PointSale::findOne($id)) !== null) {
return $model; return $model;
} else {
}
else {
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }

+ 18
- 0
backend/views/point-sale/index.php View File

return '' ; return '' ;
} }
], ],
[
'attribute' => 'default',
'label' => 'Par défaut',
'format' => 'raw',
'contentOptions' => ['class' => 'td-default'],
'value' => function($model) {
if($model->default) {
return '<span class="glyphicon glyphicon-star"></span>' ;
}
else
{
return Html::a('<span class="glyphicon glyphicon-star-empty"></span>', ['point-sale/default','id' => $model->id], [
'title' => Yii::t('app', 'Point de vente par défaut'), 'class' => 'btn btn-default'
]);
}
}
],
[ [
'class' => 'yii\grid\ActionColumn', 'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}', 'template' => '{update} {delete}',

+ 5
- 0
backend/web/css/screen.css View File

.producer-update #nav-params button { .producer-update #nav-params button {
margin-right: 10px; margin-right: 10px;
} }

/* line 4, ../sass/point_sale/_index.scss */
.point-sale-index table .td-default {
text-align: center;
}

+ 8
- 0
backend/web/sass/point_sale/_index.scss View File


.point-sale-index {
table {
.td-default {
text-align: center ;
}
}
}

+ 2
- 1
backend/web/sass/screen.scss View File

@import "stats/_products.scss" ; @import "stats/_products.scss" ;
@import "distribution/_index.scss" ; @import "distribution/_index.scss" ;
@import "user/_emails.scss" ; @import "user/_emails.scss" ;
@import "producer/_update.scss" ;
@import "producer/_update.scss" ;
@import "point_sale/_index.scss" ;

Loading…
Cancel
Save