@@ -48,6 +48,7 @@ use yii\filters\VerbFilter; | |||
use common\models\User; | |||
use common\models\UserPointSale; | |||
use common\models\Order ; | |||
use common\models\Producer ; | |||
use yii\helpers\Html; | |||
/** | |||
@@ -187,6 +188,24 @@ class PointSaleController extends BackendController | |||
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. | |||
@@ -199,7 +218,8 @@ class PointSaleController extends BackendController | |||
{ | |||
if (($model = PointSale::findOne($id)) !== null) { | |||
return $model; | |||
} else { | |||
} | |||
else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
} | |||
} |
@@ -115,6 +115,24 @@ $this->addButton(['label' => '+', 'url' => 'point-sale/create', 'class' => 'btn | |||
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', | |||
'template' => '{update} {delete}', |
@@ -1970,3 +1970,8 @@ termes. | |||
.producer-update #nav-params button { | |||
margin-right: 10px; | |||
} | |||
/* line 4, ../sass/point_sale/_index.scss */ | |||
.point-sale-index table .td-default { | |||
text-align: center; | |||
} |
@@ -0,0 +1,8 @@ | |||
.point-sale-index { | |||
table { | |||
.td-default { | |||
text-align: center ; | |||
} | |||
} | |||
} |
@@ -1333,4 +1333,5 @@ a.btn, button.btn { | |||
@import "stats/_products.scss" ; | |||
@import "distribution/_index.scss" ; | |||
@import "user/_emails.scss" ; | |||
@import "producer/_update.scss" ; | |||
@import "producer/_update.scss" ; | |||
@import "point_sale/_index.scss" ; |