瀏覽代碼

Adaptation de l'option "Paiement automatique" en fonction du mode de Crédit choisi

dev
Guillaume Bourgeois 5 年之前
父節點
當前提交
6979b3518e
共有 1 個文件被更改,包括 24 次插入1 次删除
  1. +24
    -1
      common/models/Subscription.php

+ 24
- 1
common/models/Subscription.php 查看文件

@@ -45,6 +45,7 @@ use common\models\PointSale;
use common\models\UserPointSale;
use common\models\Order;
use common\models\ProductOrder;
use common\models\User ;

/**
* This is the model class for table "commande_auto".
@@ -189,7 +190,29 @@ class Subscription extends ActiveRecordCommon
$order->id_point_sale = $this->id_point_sale;
$order->id_distribution = $distribution->id;
$order->id_subscription = $this->id;
$order->auto_payment = $this->auto_payment ;
$pointSale = PointSale::findOne($this->id_point_sale) ;
$creditFunctioning = $pointSale->getCreditFunctioning() ;
$order->auto_payment = 0 ;
if($order->id_user && Producer::getConfig('credit') && $pointSale->credit) {
if($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
$order->auto_payment = $this->auto_payment ;
}
elseif($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
$order->auto_payment = 1 ;
}
elseif($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {
$user = User::findOne($order->id_user) ;
$userProducer = UserProducer::searchOne([
'id_user' => $order->id_user,
'id_producer' => $distribution->id_producer
]) ;
if($userProducer) {
$order->auto_payment = $userProducer->credit_active ;
}
}
}
$userPointSale = UserPointSale::searchOne([
'id_point_sale' => $this->id_point_sale,

Loading…
取消
儲存