255], [['comment'], 'string', 'max' => 2048], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id_user' => 'Utilisateur', 'id_user_action' => 'Utilisateur', 'date' => 'Date', 'amount' => 'Montant', 'type' => 'Type', 'id_producer' => 'Producteur', 'mean_payment' => 'Moyen de paiement', 'comment' => 'Commentaire', 'send_mail' => 'Prévenir l\'utilisateur', ]; } /** * Enregistre un modèle CreditHistorique. */ public function save() { $userModule = UserModule::getInstance(); $userProducerModule = UserProducerModule::getInstance(); $paymentManager = PaymentModule::getInstance(); if ($this->validate()) { $user = $userModule->findOneUserById($this->id_user); $paymentManager->creditOrDebitUser($this->type, $user, $this->amount, $this->mean_payment, $userModule->getCurrent(), $this->comment); // on prévient l'utilisateur que son compte vient d'être crédité if($this->send_mail) { $producer = GlobalParam::getCurrentProducer() ; $userProducer = $userProducerModule->findOneUserProducer($user); \Yii::$app->mailerService->sendFromProducer( 'Mouvement de crédit', 'creditUser', [ 'user' => $user, 'producer' => $producer, 'userProducer' => $userProducer, 'creditForm' => $this ], $user->email, $producer ); } } } }