Ver código fonte

Merge branch 'dev'

master
Guillaume Bourgeois 5 anos atrás
pai
commit
821a65bda9
9 arquivos alterados com 101 adições e 18 exclusões
  1. +20
    -13
      backend/controllers/DistributionController.php
  2. +21
    -1
      backend/controllers/PointSaleController.php
  3. +18
    -0
      backend/views/point-sale/index.php
  4. +5
    -0
      backend/web/css/screen.css
  5. +8
    -1
      backend/web/js/vuejs/distribution-index.js
  6. +8
    -0
      backend/web/sass/point_sale/_index.scss
  7. +2
    -1
      backend/web/sass/screen.scss
  8. +4
    -2
      common/models/PointSale.php
  9. +15
    -0
      console/migrations/m190220_073434_ajout_champs_point_vente_defaut.php

+ 20
- 13
backend/controllers/DistributionController.php Ver arquivo

@@ -190,19 +190,6 @@ class DistributionController extends BackendController
$json['orders'] = $ordersArray ;
// order create
$productOrderArray = [] ;
foreach($productsArray as $product) {
$productOrderArray[$product['id']] = 0 ;
}
$json['order_create'] = [
'id_point_sale' => 0,
'id_user' => 0,
'username' => '',
'comment' => '',
'productOrder' => $productOrderArray
] ;
// points de vente
$pointsSaleArray = PointSale::find()
->joinWith(['pointSaleDistribution' => function($q) use ($distribution) {
@@ -214,8 +201,28 @@ class DistributionController extends BackendController
->asArray()
->all();
$idPointSaleDefault = 0 ;
foreach($pointsSaleArray as $pointSale) {
if($pointSale['default']) {
$idPointSaleDefault = $pointSale['id'] ;
}
}
$json['points_sale'] = $pointsSaleArray ;
// order create
$productOrderArray = [] ;
foreach($productsArray as $product) {
$productOrderArray[$product['id']] = 0 ;
}
$json['order_create'] = [
'id_point_sale' => $idPointSaleDefault,
'id_user' => 0,
'username' => '',
'comment' => '',
'productOrder' => $productOrderArray
] ;
// utilisateurs
$usersArray = User::findBy()->all() ;
$json['users'] = $usersArray ;

+ 21
- 1
backend/controllers/PointSaleController.php Ver arquivo

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

+ 18
- 0
backend/views/point-sale/index.php Ver arquivo

@@ -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}',

+ 5
- 0
backend/web/css/screen.css Ver arquivo

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

+ 8
- 1
backend/web/js/vuejs/distribution-index.js Ver arquivo

@@ -15,6 +15,7 @@ var app = new Vue({
countActiveProducts: 0,
pointsSale: [],
idActivePointSale: 0,
idDefaultPointSale: 0,
countActivePointsSale: 0,
countOrdersByPointSale: [],
orders: [],
@@ -134,6 +135,7 @@ var app = new Vue({
if(response.data.order_create) {
app.orderCreate = response.data.order_create ;
app.idDefaultPointSale = app.orderCreate.id_point_sale ;
}
if(response.data.points_sale) {
@@ -283,7 +285,12 @@ var app = new Vue({
},
setIdActivePointSale: function(id) {
this.idActivePointSale = id ;
this.orderCreate.id_point_sale = id ;
if(!id) {
this.orderCreate.id_point_sale = this.idDefaultPointSale ;
}
else {
this.orderCreate.id_point_sale = id ;
}
},
orderCreatedUpdated: function() {
this.showModalFormOrderCreate = false ;

+ 8
- 0
backend/web/sass/point_sale/_index.scss Ver arquivo

@@ -0,0 +1,8 @@

.point-sale-index {
table {
.td-default {
text-align: center ;
}
}
}

+ 2
- 1
backend/web/sass/screen.scss Ver arquivo

@@ -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" ;

+ 4
- 2
common/models/PointSale.php Ver arquivo

@@ -51,6 +51,7 @@ use common\components\ActiveRecordCommon ;
* @property string $name
* @property string $address
* @property integer $id_producer
* @property integer $default
*/
class PointSale extends ActiveRecordCommon
{
@@ -83,7 +84,7 @@ class PointSale extends ActiveRecordCommon
'infos_saturday', 'infos_sunday','credit_functioning'], 'string'],
[['point_production', 'credit', 'delivery_monday', 'delivery_tuesday',
'delivery_wednesday', 'delivery_thursday', 'delivery_friday',
'delivery_saturday', 'delivery_sunday'], 'boolean'],
'delivery_saturday', 'delivery_sunday','default'], 'boolean'],
['point_production', 'default', 'value' => 0],
['id_producer', 'integer'],
['id_producer', 'required'],
@@ -119,7 +120,8 @@ class PointSale extends ActiveRecordCommon
'delivery_saturday' => 'Samedi',
'delivery_sunday' => 'Dimanche',
'code' => 'Code',
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur'
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur',
'default' => 'Point de vente par défaut',
];
}


+ 15
- 0
console/migrations/m190220_073434_ajout_champs_point_vente_defaut.php Ver arquivo

@@ -0,0 +1,15 @@
<?php

use yii\db\Migration;
use yii\db\mysql\Schema;

class m190220_073434_ajout_champs_point_vente_defaut extends Migration {

public function up() {
$this->addColumn('point_sale', 'default', Schema::TYPE_BOOLEAN) ;
}

public function down() {
$this->dropColumn('point_sale', 'default') ;
}
}

Carregando…
Cancelar
Salvar