255], ]; } /** * @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() { if ($this->validate()) { $creditHistory = new CreditHistory; $creditHistory->id_user = $this->id_user; $creditHistory->id_user_action = Yii::$app->user->identity->id; $creditHistory->id_producer = Producer::getId() ; $creditHistory->type = $this->type ; $creditHistory->comment = $this->comment ; $creditHistory->amount = $this->amount ; $creditHistory->mean_payment = $this->mean_payment ; $creditHistory->save(); // on prévient l'utilisateur que son compte vient d'être crédité if($this->send_mail) { $user = User::findOne($this->id_user) ; $producer = Producer::get() ; $userProducer = UserProducer::searchOne([ 'id_user' => $this->id_user ]); Mail::send($user->email, 'Votre compte vient d\'être crédité','creditUser', [ 'user' => $user, 'producer' => $producer, 'userProducer' => $userProducer, 'creditForm' => $this ]) ; } } } }