Browse Source

Merge branch 'dev'

prodstable
Guillaume Bourgeois 5 years ago
parent
commit
dfd939f7a6
4 changed files with 19 additions and 8 deletions
  1. +1
    -0
      backend/controllers/CronController.php
  2. +11
    -4
      backend/controllers/PointSaleController.php
  3. +4
    -2
      backend/views/point-sale/index.php
  4. +3
    -2
      common/models/Producer.php

+ 1
- 0
backend/controllers/CronController.php View File



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);
} }

+ 11
- 4
backend/controllers/PointSaleController.php View File

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']);

+ 4
- 2
backend/views/point-sale/index.php View File

'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'
]); ]);
} }

+ 3
- 2
common/models/Producer.php View File

$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) ;
} }
} }
} }

Loading…
Cancel
Save