Ver código fonte

[global] Abonnements : gestion du champs "commentaire"

dev
Guillaume Bourgeois 5 anos atrás
pai
commit
b808c66e3f
10 arquivos alterados com 73 adições e 19 exclusões
  1. +5
    -1
      backend/controllers/SubscriptionController.php
  2. +2
    -0
      backend/views/subscription/_form.php
  3. +1
    -1
      backend/web/js/vuejs/subscription-form.js
  4. +7
    -2
      common/models/Subscription.php
  5. +5
    -2
      common/models/SubscriptionForm.php
  6. +17
    -0
      console/migrations/m190806_084324_ajout_champs_comment_subscription.php
  7. +9
    -0
      producer/views/subscription/_form.php
  8. +18
    -12
      producer/web/css/screen.css
  9. +4
    -1
      producer/web/js/vuejs/subscription-form.js
  10. +5
    -0
      producer/web/sass/subscription/_form.scss

+ 5
- 1
backend/controllers/SubscriptionController.php Ver arquivo

@@ -153,6 +153,7 @@ class SubscriptionController extends BackendController
$model = new SubscriptionForm;
$model->isAdmin = true ;
$subscription = Subscription::findOne($id);
if ($subscription) {
$model->id = $id;
$model->id_producer = $subscription->id_producer;
@@ -163,7 +164,7 @@ class SubscriptionController extends BackendController
if (strlen($subscription->date_end)) {
$model->date_end = date('d/m/Y', strtotime($subscription->date_end));
}
$model->monday = $subscription->monday;
$model->tuesday = $subscription->tuesday;
$model->wednesday = $subscription->wednesday;
@@ -173,6 +174,9 @@ class SubscriptionController extends BackendController
$model->sunday = $subscription->sunday;
$model->auto_payment = $subscription->auto_payment;
$model->week_frequency = $subscription->week_frequency;
if(strlen($subscription->comment)) {
$model->comment = $subscription->comment ;
}

// produits
$arrayProductsSubscription = ProductSubscription::searchAll([

+ 2
- 0
backend/views/subscription/_form.php Ver arquivo

@@ -127,6 +127,8 @@ use common\models\PointSale ;
</table>
</div>
<?= $form->field($model, 'comment')->textarea(['rows' => 6]) ?>
<?= Html::submitButton('Enregistrer' , ['class' => 'btn btn-primary']) ?>
<?php ActiveForm::end(); ?>
</div>

+ 1
- 1
backend/web/js/vuejs/subscription-form.js Ver arquivo

@@ -75,7 +75,7 @@ var app = new Vue({
}
},
changeQuantityProductSubscription: function(increase, product) {
var step = parseFloat(product.step) ;
var step = step ? parseFloat(product.step) : 1 ;
if(!product.quantity) product.quantity = 0 ;
var quantity = parseFloat(product.quantity) ;
if(!increase) {

+ 7
- 2
common/models/Subscription.php Ver arquivo

@@ -66,6 +66,7 @@ use common\models\User ;
* @property integer $week_frequency
* @property string $username
* @property string $auto_payment
* @property string $comment
*/
class Subscription extends ActiveRecordCommon
{
@@ -87,7 +88,7 @@ class Subscription extends ActiveRecordCommon
[['id_user', 'id_producer', 'id_point_sale', 'monday', 'tuesday',
'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'week_frequency'], 'integer'],
[['auto_payment'], 'boolean'],
[['date_begin', 'date_end', 'username'], 'safe'],
[['date_begin', 'date_end', 'username','comment'], 'safe'],
];
}

@@ -111,7 +112,8 @@ class Subscription extends ActiveRecordCommon
'saturday' => 'Samedi',
'sunday' => 'Dimanche',
'week_frequency' => 'Périodicité',
'auto_payment' => 'Paiement automatique'
'auto_payment' => 'Paiement automatique',
'comment' => 'Commentaire'
];
}

@@ -190,6 +192,9 @@ class Subscription extends ActiveRecordCommon
$order->id_point_sale = $this->id_point_sale;
$order->id_distribution = $distribution->id;
$order->id_subscription = $this->id;
if(strlen($this->comment)) {
$order->comment = $this->comment ;
}
$pointSale = PointSale::findOne($this->id_point_sale) ;
$creditFunctioning = $pointSale->getCreditFunctioning() ;

+ 5
- 2
common/models/SubscriptionForm.php Ver arquivo

@@ -66,6 +66,7 @@ class SubscriptionForm extends Model
public $week_frequency;
public $products;
public $auto_payment;
public $comment ;

/**
* @inheritdoc
@@ -77,7 +78,7 @@ class SubscriptionForm extends Model
[['date_begin', 'date_end'], 'date', 'format' => 'php:d/m/Y'],
[['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'auto_payment'], 'boolean'],
[['id_point_sale', 'id_producer', 'date_begin'], 'required', 'message' => 'Champs obligatoire'],
[['products', 'id_user', 'username'], 'safe'],
[['products', 'id_user', 'username','comment'], 'safe'],
['id_user', function ($attribute, $params) {
if (!$this->id_user && !strlen($this->username)) {
$this->addError($attribute, 'Vous devez sélectionner ou saisir un utilisateur.');
@@ -104,7 +105,8 @@ class SubscriptionForm extends Model
'sunday' => 'Dimanche',
'week_frequency' => 'Périodicité (semaines)',
'username' => 'Nom d\'utilisateur',
'auto_payment' => 'Paiement automatique'
'auto_payment' => 'Paiement automatique',
'comment' => 'Commentaire'
];
}

@@ -146,6 +148,7 @@ class SubscriptionForm extends Model
$subscription->sunday = $this->sunday;
$subscription->week_frequency = $this->week_frequency;
$subscription->auto_payment = $this->auto_payment;
$subscription->comment = $this->comment;

$subscription->save();


+ 17
- 0
console/migrations/m190806_084324_ajout_champs_comment_subscription.php Ver arquivo

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

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

class m190806_084324_ajout_champs_comment_subscription extends Migration
{
public function up()
{
$this->addColumn('subscription', 'comment', Schema::TYPE_TEXT) ;
}

public function down()
{
$this->dropColumn('subscription', 'comment') ;
}
}

+ 9
- 0
producer/views/subscription/_form.php Ver arquivo

@@ -246,6 +246,15 @@ use common\models\PointSale ;
</div>
</div>
<div class="clr"></div>

<div>
<h3><span>Commentaire</span></h3>
<div class="form-group">
<textarea id="subscriptionform-comment" class="form-control comment-textarea" v-model="comment"></textarea>
</div>
</div>
<button class="btn btn-primary" disabled="disabled" v-if="disableSubmitButton">Enregistrer</button>
<button class="btn btn-primary" v-else>Enregistrer</button>
</form>

+ 18
- 12
producer/web/css/screen.css Ver arquivo

@@ -1644,7 +1644,13 @@ termes.
width: 100%;
display: block;
}
/* line 58, ../sass/subscription/_form.scss */
/* line 57, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .comment-textarea,
.subscription-update .subscription-form .comment-textarea {
width: 100%;
height: 100px;
}
/* line 63, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .monday, .subscription-create .subscription-form .products .tuesday, .subscription-create .subscription-form .products .wednesday, .subscription-create .subscription-form .products .thursday,
.subscription-create .subscription-form .products .friday, .subscription-create .subscription-form .products .saturday, .subscription-create .subscription-form .products .sunday, .subscription-create .subscription-form .products .no-day,
.subscription-update .subscription-form .products .monday,
@@ -1657,7 +1663,7 @@ termes.
.subscription-update .subscription-form .products .no-day {
display: none;
}
/* line 63, ../sass/subscription/_form.scss */
/* line 68, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .monday-active .monday,
.subscription-create .subscription-form .products .tuesday-active .tuesday,
.subscription-create .subscription-form .products .wednesday-active .wednesday,
@@ -1674,60 +1680,60 @@ termes.
.subscription-update .subscription-form .products .sunday-active .sunday {
display: block;
}
/* line 73, ../sass/subscription/_form.scss */
/* line 78, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products td.quantity,
.subscription-update .subscription-form .products td.quantity {
width: 180px;
}
/* line 76, ../sass/subscription/_form.scss */
/* line 81, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products td.quantity input,
.subscription-update .subscription-form .products td.quantity input {
text-align: center;
border-right: 0px none;
}
/* line 79, ../sass/subscription/_form.scss */
/* line 84, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products td.quantity input.has-quantity,
.subscription-update .subscription-form .products td.quantity input.has-quantity {
font-weight: bold;
}
/* line 84, ../sass/subscription/_form.scss */
/* line 89, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products td.quantity .input-group-addon,
.subscription-update .subscription-form .products td.quantity .input-group-addon {
background-color: white;
padding-left: 0px;
border-left: 0px none;
}
/* line 91, ../sass/subscription/_form.scss */
/* line 96, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .name,
.subscription-update .subscription-form .products .name {
font-family: "capsuularegular";
font-size: 20px;
color: black;
}
/* line 97, ../sass/subscription/_form.scss */
/* line 102, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .description,
.subscription-update .subscription-form .products .description {
font-style: italic;
}
/* line 101, ../sass/subscription/_form.scss */
/* line 106, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .recipe,
.subscription-update .subscription-form .products .recipe {
font-size: 12px;
}
/* line 105, ../sass/subscription/_form.scss */
/* line 110, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .price-unit, .subscription-create .subscription-form .products .price-total,
.subscription-update .subscription-form .products .price-unit,
.subscription-update .subscription-form .products .price-total {
text-align: center;
width: 150px;
}
/* line 110, ../sass/subscription/_form.scss */
/* line 115, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products .unit,
.subscription-update .subscription-form .products .unit {
color: gray;
font-size: 13px;
}
/* line 115, ../sass/subscription/_form.scss */
/* line 120, ../sass/subscription/_form.scss */
.subscription-create .subscription-form .products tr.total .price-total,
.subscription-update .subscription-form .products tr.total .price-total {
text-align: center;

+ 4
- 1
producer/web/js/vuejs/subscription-form.js Ver arquivo

@@ -23,6 +23,7 @@ var app = new Vue({
errors: [],
disableSubmitButton: false,
lastCountDays: 0,
comment: ''
},
mounted: function() {
this.init();
@@ -59,6 +60,7 @@ var app = new Vue({
app.friday = response.data.friday ;
app.saturday = response.data.saturday ;
app.sunday = response.data.sunday ;
app.comment = response.data.comment ;
}
app.loading = false ;
@@ -218,7 +220,8 @@ var app = new Vue({
friday: this.friday == true ? 1 : 0,
saturday: this.saturday == true ? 1 : 0,
sunday: this.sunday == true ? 1 : 0,
products: productsArray
products: productsArray,
comment: this.comment
}
}).then(function(response) {
window.location.href = opendistrib_base_url(true)+'subscription/index' ;

+ 5
- 0
producer/web/sass/subscription/_form.scss Ver arquivo

@@ -54,6 +54,11 @@
}
}
.comment-textarea {
width: 100% ;
height: 100px ;
}
.products {
.monday, .tuesday, .wednesday, .thursday,
.friday, .saturday, .sunday, .no-day {

Carregando…
Cancelar
Salvar