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.'); | ||||
} | } | ||||
} | } |
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}', |
.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; | |||||
} |
.point-sale-index { | |||||
table { | |||||
.td-default { | |||||
text-align: center ; | |||||
} | |||||
} | |||||
} |
@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" ; |