if ($hour == '00') { | if ($hour == '00') { | ||||
$date = date('Y-m-d'); | $date = date('Y-m-d'); | ||||
$hour = 24 ; | |||||
} else { | } else { | ||||
$date = date('Y-m-d', time() + 24 * 60 * 60); | $date = date('Y-m-d', time() + 24 * 60 * 60); | ||||
} | } |
public function initForm($id = 0) | public function initForm($id = 0) | ||||
{ | { | ||||
$users = User::findBy() | $users = User::findBy() | ||||
->orderBy('name ASC') | |||||
->leftJoin('user_point_sale', 'user_point_sale.id_user = user.id AND user_point_sale.id_point_sale = :id_point_sale',[':id_point_sale' => $id]) | |||||
->orderBy('user_point_sale.id_point_sale DESC, lastname ASC, name ASC') | |||||
->all(); | ->all(); | ||||
return [ | return [ | ||||
'users' => $users | 'users' => $users | ||||
]; | ]; | ||||
$pointSale = $this->findModel($id) ; | $pointSale = $this->findModel($id) ; | ||||
if($pointSale) { | if($pointSale) { | ||||
PointSale::updateAll(['default' => 0], 'id_producer = :id_producer', [':id_producer' => Producer::getId()]) ; | 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.') ; | |||||
if(!$pointSale->default) { | |||||
$pointSale->default = 1 ; | |||||
$pointSale->save() ; | |||||
Yii::$app->getSession()->setFlash('success', 'Point de vente <strong>'.Html::encode($pointSale->name).'</strong> défini par défaut.') ; | |||||
} | |||||
else { | |||||
Yii::$app->getSession()->setFlash('success', 'Aucun point de vente défini par défaut') ; | |||||
} | |||||
} | } | ||||
return $this->redirect(['index']); | return $this->redirect(['index']); |
'contentOptions' => ['class' => 'td-default'], | 'contentOptions' => ['class' => 'td-default'], | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
if($model->default) { | if($model->default) { | ||||
return '<span class="glyphicon glyphicon-star"></span>' ; | |||||
return Html::a('<span class="glyphicon glyphicon-star"></span>', ['point-sale/default','id' => $model->id], [ | |||||
'title' => Yii::t('app', 'Point de vente par défaut'), 'class' => 'btn btn-default' | |||||
]); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
return Html::a('<span class="glyphicon glyphicon-star-empty"></span>', ['point-sale/default','id' => $model->id], [ | 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' | |||||
'title' => Yii::t('app', 'Point de vente par défaut'), 'class' => 'btn btn-default' | |||||
]); | ]); | ||||
} | } | ||||
$apiKeysArray = explode(':', $apiKeys) ; | $apiKeysArray = explode(':', $apiKeys) ; | ||||
if(count($apiKeysArray) == 2) { | if(count($apiKeysArray) == 2) { | ||||
if($type == 'private') { | if($type == 'private') { | ||||
return $apiKeysArray[1] ; | |||||
$key = $apiKeysArray[1] ; | |||||
} | } | ||||
else { | else { | ||||
return $apiKeysArray[0] ; | |||||
$key = $apiKeysArray[0] ; | |||||
} | } | ||||
return trim($key) ; | |||||
} | } | ||||
} | } | ||||
} | } |