$model->setPassword($password); | $model->setPassword($password); | ||||
$model->generateAuthKey(); | $model->generateAuthKey(); | ||||
$model->username = $model->email ; | $model->username = $model->email ; | ||||
if(!strlen($model->email)) | |||||
$model->username = 'inconnu@laboiteapain.net' ; | |||||
$model->save() ; | $model->save() ; | ||||
// liaison etablissement / user | // liaison etablissement / user | ||||
$user_etablissement->save() ; | $user_etablissement->save() ; | ||||
// send mail | // send mail | ||||
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ; | |||||
Yii::$app->mailer->compose() ; | |||||
$mail = Yii::$app->mailer->compose( | |||||
['html' => 'createUserAdmin-html', 'text' => 'createUserAdmin-text'], | |||||
['user' => $model, 'etablissement' => $etablissement, 'password' => $password]) | |||||
->setTo($model->email) | |||||
->setFrom(['contact@laboiteapain.net' => 'La boîte à pain']) | |||||
->setSubject('[La boîte à pain] Inscription') | |||||
->send() ; | |||||
if(strlen($model->email)) | |||||
{ | |||||
$etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement) ; | |||||
Yii::$app->mailer->compose() ; | |||||
$mail = Yii::$app->mailer->compose( | |||||
['html' => 'createUserAdmin-html', 'text' => 'createUserAdmin-text'], | |||||
['user' => $model, 'etablissement' => $etablissement, 'password' => $password]) | |||||
->setTo($model->email) | |||||
->setFrom(['contact@laboiteapain.net' => 'La boîte à pain']) | |||||
->setSubject('[La boîte à pain] Inscription') | |||||
->send() ; | |||||
} | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} else { | } else { | ||||
return $this->render('create', [ | return $this->render('create', [ |
['confiance','default','value'=>0], | ['confiance','default','value'=>0], | ||||
[['no_mail','mail_prod_lundi','mail_prod_mardi','mail_prod_mercredi','mail_prod_jeudi','mail_prod_vendredi','mail_prod_samedi','mail_prod_dimanche'],'boolean'], | [['no_mail','mail_prod_lundi','mail_prod_mardi','mail_prod_mercredi','mail_prod_jeudi','mail_prod_vendredi','mail_prod_samedi','mail_prod_dimanche'],'boolean'], | ||||
[['nom','prenom','telephone','adresse'], 'string'], | [['nom','prenom','telephone','adresse'], 'string'], | ||||
[['nom','prenom','email'],'required','message'=> 'Ce champs ne peut être vide'], | |||||
[['nom','prenom'],'required','message'=> 'Ce champs ne peut être vide'], | |||||
['email','email','message'=> 'Cette adresse email n\'est pas valide'], | ['email','email','message'=> 'Cette adresse email n\'est pas valide'], | ||||
['email','verifyEmail'], | ['email','verifyEmail'], | ||||
['status', 'default', 'value' => self::STATUS_ACTIVE], | ['status', 'default', 'value' => self::STATUS_ACTIVE], |