Browse Source

Merge branch 'dev'

prodstable
Guillaume Bourgeois 5 years ago
parent
commit
821a65bda9
9 changed files with 101 additions and 18 deletions
  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 View File

$json['orders'] = $ordersArray ; $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 // points de vente
$pointsSaleArray = PointSale::find() $pointsSaleArray = PointSale::find()
->joinWith(['pointSaleDistribution' => function($q) use ($distribution) { ->joinWith(['pointSaleDistribution' => function($q) use ($distribution) {
->asArray() ->asArray()
->all(); ->all();
$idPointSaleDefault = 0 ;
foreach($pointsSaleArray as $pointSale) {
if($pointSale['default']) {
$idPointSaleDefault = $pointSale['id'] ;
}
}
$json['points_sale'] = $pointsSaleArray ; $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 // utilisateurs
$usersArray = User::findBy()->all() ; $usersArray = User::findBy()->all() ;
$json['users'] = $usersArray ; $json['users'] = $usersArray ;

+ 21
- 1
backend/controllers/PointSaleController.php View File

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

+ 18
- 0
backend/views/point-sale/index.php View File

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

+ 5
- 0
backend/web/css/screen.css View File

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

+ 8
- 1
backend/web/js/vuejs/distribution-index.js View File

countActiveProducts: 0, countActiveProducts: 0,
pointsSale: [], pointsSale: [],
idActivePointSale: 0, idActivePointSale: 0,
idDefaultPointSale: 0,
countActivePointsSale: 0, countActivePointsSale: 0,
countOrdersByPointSale: [], countOrdersByPointSale: [],
orders: [], orders: [],
if(response.data.order_create) { if(response.data.order_create) {
app.orderCreate = response.data.order_create ; app.orderCreate = response.data.order_create ;
app.idDefaultPointSale = app.orderCreate.id_point_sale ;
} }
if(response.data.points_sale) { if(response.data.points_sale) {
}, },
setIdActivePointSale: function(id) { setIdActivePointSale: function(id) {
this.idActivePointSale = 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() { orderCreatedUpdated: function() {
this.showModalFormOrderCreate = false ; this.showModalFormOrderCreate = false ;

+ 8
- 0
backend/web/sass/point_sale/_index.scss View File


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

+ 2
- 1
backend/web/sass/screen.scss View File

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

+ 4
- 2
common/models/PointSale.php View File

* @property string $name * @property string $name
* @property string $address * @property string $address
* @property integer $id_producer * @property integer $id_producer
* @property integer $default
*/ */
class PointSale extends ActiveRecordCommon class PointSale extends ActiveRecordCommon
{ {
'infos_saturday', 'infos_sunday','credit_functioning'], 'string'], 'infos_saturday', 'infos_sunday','credit_functioning'], 'string'],
[['point_production', 'credit', 'delivery_monday', 'delivery_tuesday', [['point_production', 'credit', 'delivery_monday', 'delivery_tuesday',
'delivery_wednesday', 'delivery_thursday', 'delivery_friday', 'delivery_wednesday', 'delivery_thursday', 'delivery_friday',
'delivery_saturday', 'delivery_sunday'], 'boolean'],
'delivery_saturday', 'delivery_sunday','default'], 'boolean'],
['point_production', 'default', 'value' => 0], ['point_production', 'default', 'value' => 0],
['id_producer', 'integer'], ['id_producer', 'integer'],
['id_producer', 'required'], ['id_producer', 'required'],
'delivery_saturday' => 'Samedi', 'delivery_saturday' => 'Samedi',
'delivery_sunday' => 'Dimanche', 'delivery_sunday' => 'Dimanche',
'code' => 'Code', '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 View File

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

Loading…
Cancel
Save