@@ -220,6 +220,7 @@ class CronController extends BackendController | |||
if ($hour == '00') { | |||
$date = date('Y-m-d'); | |||
$hour = 24 ; | |||
} else { | |||
$date = date('Y-m-d', time() + 24 * 60 * 60); | |||
} |
@@ -157,8 +157,10 @@ class PointSaleController extends BackendController | |||
public function initForm($id = 0) | |||
{ | |||
$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(); | |||
return [ | |||
'users' => $users | |||
]; | |||
@@ -199,9 +201,14 @@ class PointSaleController extends BackendController | |||
$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.') ; | |||
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']); |
@@ -122,12 +122,14 @@ $this->addButton(['label' => '+', 'url' => 'point-sale/create', 'class' => 'btn | |||
'contentOptions' => ['class' => 'td-default'], | |||
'value' => function($model) { | |||
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 | |||
{ | |||
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' | |||
]); | |||
} | |||
@@ -496,11 +496,12 @@ class Producer extends ActiveRecordCommon | |||
$apiKeysArray = explode(':', $apiKeys) ; | |||
if(count($apiKeysArray) == 2) { | |||
if($type == 'private') { | |||
return $apiKeysArray[1] ; | |||
$key = $apiKeysArray[1] ; | |||
} | |||
else { | |||
return $apiKeysArray[0] ; | |||
$key = $apiKeysArray[0] ; | |||
} | |||
return trim($key) ; | |||
} | |||
} | |||
} |