|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
|
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
|
|
$order = new Order; |
|
|
$order = new Order; |
|
|
$idProducer = $this->getProducer()->id; |
|
|
|
|
|
|
|
|
$producer = $this->getProducer() ; |
|
|
|
|
|
$idProducer = $producer->id; |
|
|
|
|
|
|
|
|
$posts = Yii::$app->request->post(); |
|
|
$posts = Yii::$app->request->post(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'email' => $posts['user']['email'] |
|
|
'email' => $posts['user']['email'] |
|
|
]) ; |
|
|
]) ; |
|
|
|
|
|
|
|
|
|
|
|
if($user) { |
|
|
|
|
|
$producer->addUser($user->id, $idProducer) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(!$user) { |
|
|
if(!$user) { |
|
|
$user = new User ; |
|
|
$user = new User ; |
|
|
$user->id_producer = 0; |
|
|
$user->id_producer = 0; |
|
|
|
|
|
|
|
|
$user->phone = $posts['user']['phone']; |
|
|
$user->phone = $posts['user']['phone']; |
|
|
$user->save() ; |
|
|
$user->save() ; |
|
|
|
|
|
|
|
|
// liaison etablissement / user |
|
|
|
|
|
$userProducer = new UserProducer(); |
|
|
|
|
|
$userProducer->id_user = $user->id; |
|
|
|
|
|
$userProducer->id_producer = $idProducer; |
|
|
|
|
|
$userProducer->credit = 0; |
|
|
|
|
|
$userProducer->active = 1; |
|
|
|
|
|
$userProducer->save(); |
|
|
|
|
|
|
|
|
// liaison producer / user |
|
|
|
|
|
$producer->addUser($user->id, $idProducer) ; |
|
|
|
|
|
|
|
|
|
|
|
// mail bienvenue |
|
|
$user->sendMailWelcome($password); |
|
|
$user->sendMailWelcome($password); |
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$producer->addUser($user->id, $idProducer) ; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$order = new Order; |
|
|
$order = new Order; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$distributionsArray = Distribution::searchAll([ |
|
|
$distributionsArray = Distribution::searchAll([ |
|
|
'active' => 1 |
|
|
'active' => 1 |
|
|
|
|
|
'id_producer' => $producer->id |
|
|
], [ |
|
|
], [ |
|
|
'conditions' => ['date > :date'], |
|
|
'conditions' => ['date > :date'], |
|
|
'params' => [':date' => $dateMini], |
|
|
'params' => [':date' => $dateMini], |