} | } | ||||
} | } | ||||
if ($model->load($posts)) { | |||||
$model->auto_payment = (int) $posts['auto_payment']; | |||||
if($model->validate() && $model->save()) { | |||||
if ($model->load($posts) && $model->validate() && $model->save()) { | |||||
$subscription = Subscription::searchOne([ | $subscription = Subscription::searchOne([ | ||||
'id' => $model->id | 'id' => $model->id | ||||
]); | ]); | ||||
Yii::$app->getSession()->setFlash('success', 'Abonnement ajouté'); | Yii::$app->getSession()->setFlash('success', 'Abonnement ajouté'); | ||||
} | } | ||||
} | } | ||||
} | |||||
} | } | ||||
/** | /** | ||||
$model->friday = $subscription->friday; | $model->friday = $subscription->friday; | ||||
$model->saturday = $subscription->saturday; | $model->saturday = $subscription->saturday; | ||||
$model->sunday = $subscription->sunday; | $model->sunday = $subscription->sunday; | ||||
$model->auto_payment = (int) $subscription->auto_payment; | |||||
$model->auto_payment = $subscription->auto_payment; | |||||
$model->week_frequency = $subscription->week_frequency; | $model->week_frequency = $subscription->week_frequency; | ||||
// produits | // produits |
<?php if(Producer::getConfig('credit')): ?> | <?php if(Producer::getConfig('credit')): ?> | ||||
<div class="form-group field-subscriptionform-auto_payment"> | <div class="form-group field-subscriptionform-auto_payment"> | ||||
<label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label> | <label><input type="checkbox" id="subscriptionform-auto_payment" name="SubscriptionForm[auto_payment]" v-model="autoPayment"> Paiement automatique</label> | ||||
<div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div> | |||||
<div class="hint-block">Cochez cette case si vous souhaitez que votre Crédit soit automatiquement débité.</div> | |||||
<div class="help-block"></div> | <div class="help-block"></div> | ||||
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> |
} | } | ||||
} | } | ||||
console.log(this.autoPayment); | |||||
axios.post('ajax-process', { | axios.post('ajax-process', { | ||||
idSubscription: this.idSubscription, | idSubscription: this.idSubscription, | ||||
SubscriptionForm: { | SubscriptionForm: { | ||||
date_begin: this.dateBegin ? this.formatDate(this.dateBegin) : '', | date_begin: this.dateBegin ? this.formatDate(this.dateBegin) : '', | ||||
date_end: this.dateEnd ? this.formatDate(this.dateEnd) : '', | date_end: this.dateEnd ? this.formatDate(this.dateEnd) : '', | ||||
week_frequency: this.weekFrequency, | week_frequency: this.weekFrequency, | ||||
auto_payment: parseInt(this.autoPayment), | |||||
auto_payment: this.autoPayment ? 1 : 0, | |||||
monday: this.monday == true ? 1 : 0, | monday: this.monday == true ? 1 : 0, | ||||
tuesday: this.tuesday == true ? 1 : 0, | tuesday: this.tuesday == true ? 1 : 0, | ||||
wednesday: this.wednesday == true ? 1 : 0, | wednesday: this.wednesday == true ? 1 : 0, |