Browse Source

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

prodstable
Guillaume Bourgeois 6 years ago
parent
commit
6979b3518e
1 changed files with 24 additions and 1 deletions
  1. +24
    -1
      common/models/Subscription.php

+ 24
- 1
common/models/Subscription.php View File

use common\models\UserPointSale; use common\models\UserPointSale;
use common\models\Order; use common\models\Order;
use common\models\ProductOrder; use common\models\ProductOrder;
use common\models\User ;


/** /**
* This is the model class for table "commande_auto". * This is the model class for table "commande_auto".
$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;
$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([ $userPointSale = UserPointSale::searchOne([
'id_point_sale' => $this->id_point_sale, 'id_point_sale' => $this->id_point_sale,

Loading…
Cancel
Save