$model = new SubscriptionForm; | $model = new SubscriptionForm; | ||||
$model->isAdmin = true ; | $model->isAdmin = true ; | ||||
$subscription = Subscription::findOne($id); | $subscription = Subscription::findOne($id); | ||||
if ($subscription) { | if ($subscription) { | ||||
$model->id = $id; | $model->id = $id; | ||||
$model->id_producer = $subscription->id_producer; | $model->id_producer = $subscription->id_producer; | ||||
if (strlen($subscription->date_end)) { | if (strlen($subscription->date_end)) { | ||||
$model->date_end = date('d/m/Y', strtotime($subscription->date_end)); | $model->date_end = date('d/m/Y', strtotime($subscription->date_end)); | ||||
} | } | ||||
$model->monday = $subscription->monday; | $model->monday = $subscription->monday; | ||||
$model->tuesday = $subscription->tuesday; | $model->tuesday = $subscription->tuesday; | ||||
$model->wednesday = $subscription->wednesday; | $model->wednesday = $subscription->wednesday; | ||||
$model->sunday = $subscription->sunday; | $model->sunday = $subscription->sunday; | ||||
$model->auto_payment = $subscription->auto_payment; | $model->auto_payment = $subscription->auto_payment; | ||||
$model->week_frequency = $subscription->week_frequency; | $model->week_frequency = $subscription->week_frequency; | ||||
if(strlen($subscription->comment)) { | |||||
$model->comment = $subscription->comment ; | |||||
} | |||||
// produits | // produits | ||||
$arrayProductsSubscription = ProductSubscription::searchAll([ | $arrayProductsSubscription = ProductSubscription::searchAll([ |
</table> | </table> | ||||
</div> | </div> | ||||
<?= $form->field($model, 'comment')->textarea(['rows' => 6]) ?> | |||||
<?= Html::submitButton('Enregistrer' , ['class' => 'btn btn-primary']) ?> | <?= Html::submitButton('Enregistrer' , ['class' => 'btn btn-primary']) ?> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> | ||||
</div> | </div> |
} | } | ||||
}, | }, | ||||
changeQuantityProductSubscription: function(increase, product) { | changeQuantityProductSubscription: function(increase, product) { | ||||
var step = parseFloat(product.step) ; | |||||
var step = step ? parseFloat(product.step) : 1 ; | |||||
if(!product.quantity) product.quantity = 0 ; | if(!product.quantity) product.quantity = 0 ; | ||||
var quantity = parseFloat(product.quantity) ; | var quantity = parseFloat(product.quantity) ; | ||||
if(!increase) { | if(!increase) { |
* @property integer $week_frequency | * @property integer $week_frequency | ||||
* @property string $username | * @property string $username | ||||
* @property string $auto_payment | * @property string $auto_payment | ||||
* @property string $comment | |||||
*/ | */ | ||||
class Subscription extends ActiveRecordCommon | class Subscription extends ActiveRecordCommon | ||||
{ | { | ||||
[['id_user', 'id_producer', 'id_point_sale', 'monday', 'tuesday', | [['id_user', 'id_producer', 'id_point_sale', 'monday', 'tuesday', | ||||
'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'week_frequency'], 'integer'], | 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'week_frequency'], 'integer'], | ||||
[['auto_payment'], 'boolean'], | [['auto_payment'], 'boolean'], | ||||
[['date_begin', 'date_end', 'username'], 'safe'], | |||||
[['date_begin', 'date_end', 'username','comment'], 'safe'], | |||||
]; | ]; | ||||
} | } | ||||
'saturday' => 'Samedi', | 'saturday' => 'Samedi', | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
'week_frequency' => 'Périodicité', | 'week_frequency' => 'Périodicité', | ||||
'auto_payment' => 'Paiement automatique' | |||||
'auto_payment' => 'Paiement automatique', | |||||
'comment' => 'Commentaire' | |||||
]; | ]; | ||||
} | } | ||||
$order->id_point_sale = $this->id_point_sale; | $order->id_point_sale = $this->id_point_sale; | ||||
$order->id_distribution = $distribution->id; | $order->id_distribution = $distribution->id; | ||||
$order->id_subscription = $this->id; | $order->id_subscription = $this->id; | ||||
if(strlen($this->comment)) { | |||||
$order->comment = $this->comment ; | |||||
} | |||||
$pointSale = PointSale::findOne($this->id_point_sale) ; | $pointSale = PointSale::findOne($this->id_point_sale) ; | ||||
$creditFunctioning = $pointSale->getCreditFunctioning() ; | $creditFunctioning = $pointSale->getCreditFunctioning() ; |
public $week_frequency; | public $week_frequency; | ||||
public $products; | public $products; | ||||
public $auto_payment; | public $auto_payment; | ||||
public $comment ; | |||||
/** | /** | ||||
* @inheritdoc | * @inheritdoc | ||||
[['date_begin', 'date_end'], 'date', 'format' => 'php:d/m/Y'], | [['date_begin', 'date_end'], 'date', 'format' => 'php:d/m/Y'], | ||||
[['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'auto_payment'], 'boolean'], | [['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'auto_payment'], 'boolean'], | ||||
[['id_point_sale', 'id_producer', 'date_begin'], 'required', 'message' => 'Champs obligatoire'], | [['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) { | ['id_user', function ($attribute, $params) { | ||||
if (!$this->id_user && !strlen($this->username)) { | if (!$this->id_user && !strlen($this->username)) { | ||||
$this->addError($attribute, 'Vous devez sélectionner ou saisir un utilisateur.'); | $this->addError($attribute, 'Vous devez sélectionner ou saisir un utilisateur.'); | ||||
'sunday' => 'Dimanche', | 'sunday' => 'Dimanche', | ||||
'week_frequency' => 'Périodicité (semaines)', | 'week_frequency' => 'Périodicité (semaines)', | ||||
'username' => 'Nom d\'utilisateur', | 'username' => 'Nom d\'utilisateur', | ||||
'auto_payment' => 'Paiement automatique' | |||||
'auto_payment' => 'Paiement automatique', | |||||
'comment' => 'Commentaire' | |||||
]; | ]; | ||||
} | } | ||||
$subscription->sunday = $this->sunday; | $subscription->sunday = $this->sunday; | ||||
$subscription->week_frequency = $this->week_frequency; | $subscription->week_frequency = $this->week_frequency; | ||||
$subscription->auto_payment = $this->auto_payment; | $subscription->auto_payment = $this->auto_payment; | ||||
$subscription->comment = $this->comment; | |||||
$subscription->save(); | $subscription->save(); | ||||
<?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') ; | |||||
} | |||||
} |
</div> | </div> | ||||
</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" disabled="disabled" v-if="disableSubmitButton">Enregistrer</button> | ||||
<button class="btn btn-primary" v-else>Enregistrer</button> | <button class="btn btn-primary" v-else>Enregistrer</button> | ||||
</form> | </form> |
width: 100%; | width: 100%; | ||||
display: block; | 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 .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-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, | .subscription-update .subscription-form .products .monday, | ||||
.subscription-update .subscription-form .products .no-day { | .subscription-update .subscription-form .products .no-day { | ||||
display: none; | 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 .monday-active .monday, | ||||
.subscription-create .subscription-form .products .tuesday-active .tuesday, | .subscription-create .subscription-form .products .tuesday-active .tuesday, | ||||
.subscription-create .subscription-form .products .wednesday-active .wednesday, | .subscription-create .subscription-form .products .wednesday-active .wednesday, | ||||
.subscription-update .subscription-form .products .sunday-active .sunday { | .subscription-update .subscription-form .products .sunday-active .sunday { | ||||
display: block; | display: block; | ||||
} | } | ||||
/* line 73, ../sass/subscription/_form.scss */ | |||||
/* line 78, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products td.quantity, | .subscription-create .subscription-form .products td.quantity, | ||||
.subscription-update .subscription-form .products td.quantity { | .subscription-update .subscription-form .products td.quantity { | ||||
width: 180px; | width: 180px; | ||||
} | } | ||||
/* line 76, ../sass/subscription/_form.scss */ | |||||
/* line 81, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products td.quantity input, | .subscription-create .subscription-form .products td.quantity input, | ||||
.subscription-update .subscription-form .products td.quantity input { | .subscription-update .subscription-form .products td.quantity input { | ||||
text-align: center; | text-align: center; | ||||
border-right: 0px none; | 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-create .subscription-form .products td.quantity input.has-quantity, | ||||
.subscription-update .subscription-form .products td.quantity input.has-quantity { | .subscription-update .subscription-form .products td.quantity input.has-quantity { | ||||
font-weight: bold; | 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-create .subscription-form .products td.quantity .input-group-addon, | ||||
.subscription-update .subscription-form .products td.quantity .input-group-addon { | .subscription-update .subscription-form .products td.quantity .input-group-addon { | ||||
background-color: white; | background-color: white; | ||||
padding-left: 0px; | padding-left: 0px; | ||||
border-left: 0px none; | border-left: 0px none; | ||||
} | } | ||||
/* line 91, ../sass/subscription/_form.scss */ | |||||
/* line 96, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products .name, | .subscription-create .subscription-form .products .name, | ||||
.subscription-update .subscription-form .products .name { | .subscription-update .subscription-form .products .name { | ||||
font-family: "capsuularegular"; | font-family: "capsuularegular"; | ||||
font-size: 20px; | font-size: 20px; | ||||
color: black; | color: black; | ||||
} | } | ||||
/* line 97, ../sass/subscription/_form.scss */ | |||||
/* line 102, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products .description, | .subscription-create .subscription-form .products .description, | ||||
.subscription-update .subscription-form .products .description { | .subscription-update .subscription-form .products .description { | ||||
font-style: italic; | font-style: italic; | ||||
} | } | ||||
/* line 101, ../sass/subscription/_form.scss */ | |||||
/* line 106, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products .recipe, | .subscription-create .subscription-form .products .recipe, | ||||
.subscription-update .subscription-form .products .recipe { | .subscription-update .subscription-form .products .recipe { | ||||
font-size: 12px; | 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-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-unit, | ||||
.subscription-update .subscription-form .products .price-total { | .subscription-update .subscription-form .products .price-total { | ||||
text-align: center; | text-align: center; | ||||
width: 150px; | width: 150px; | ||||
} | } | ||||
/* line 110, ../sass/subscription/_form.scss */ | |||||
/* line 115, ../sass/subscription/_form.scss */ | |||||
.subscription-create .subscription-form .products .unit, | .subscription-create .subscription-form .products .unit, | ||||
.subscription-update .subscription-form .products .unit { | .subscription-update .subscription-form .products .unit { | ||||
color: gray; | color: gray; | ||||
font-size: 13px; | 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-create .subscription-form .products tr.total .price-total, | ||||
.subscription-update .subscription-form .products tr.total .price-total { | .subscription-update .subscription-form .products tr.total .price-total { | ||||
text-align: center; | text-align: center; |
errors: [], | errors: [], | ||||
disableSubmitButton: false, | disableSubmitButton: false, | ||||
lastCountDays: 0, | lastCountDays: 0, | ||||
comment: '' | |||||
}, | }, | ||||
mounted: function() { | mounted: function() { | ||||
this.init(); | this.init(); | ||||
app.friday = response.data.friday ; | app.friday = response.data.friday ; | ||||
app.saturday = response.data.saturday ; | app.saturday = response.data.saturday ; | ||||
app.sunday = response.data.sunday ; | app.sunday = response.data.sunday ; | ||||
app.comment = response.data.comment ; | |||||
} | } | ||||
app.loading = false ; | app.loading = false ; | ||||
friday: this.friday == true ? 1 : 0, | friday: this.friday == true ? 1 : 0, | ||||
saturday: this.saturday == true ? 1 : 0, | saturday: this.saturday == true ? 1 : 0, | ||||
sunday: this.sunday == true ? 1 : 0, | sunday: this.sunday == true ? 1 : 0, | ||||
products: productsArray | |||||
products: productsArray, | |||||
comment: this.comment | |||||
} | } | ||||
}).then(function(response) { | }).then(function(response) { | ||||
window.location.href = opendistrib_base_url(true)+'subscription/index' ; | window.location.href = opendistrib_base_url(true)+'subscription/index' ; |
} | } | ||||
} | } | ||||
.comment-textarea { | |||||
width: 100% ; | |||||
height: 100px ; | |||||
} | |||||
.products { | .products { | ||||
.monday, .tuesday, .wednesday, .thursday, | .monday, .tuesday, .wednesday, .thursday, | ||||
.friday, .saturday, .sunday, .no-day { | .friday, .saturday, .sunday, .no-day { |