From 19bd44b0036ff83544d618ab390700e9577f376f Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 24 Jan 2022 11:58:10 +0100 Subject: [PATCH] + Send QR code to email when new simple user register --- database/Requester.php | 49 ++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/database/Requester.php b/database/Requester.php index 1862849..046d23a 100644 --- a/database/Requester.php +++ b/database/Requester.php @@ -443,7 +443,7 @@ class Requester //Envoyez le mail de bienvenue try{ /* API URL */ - $url = WALLET_SERVICE_URL.'/notify-new-agent'; + $url = WALLET_SERVICE_URL.'/notify-new-user'; /* Init cURL resource */ $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); @@ -461,7 +461,8 @@ class Requester $body->email = $user['email']; $body->message = $user['category'] == 'super' ? $message2 : $message1; $body->category = $user['category']; - $body->agent_id = $user['agentId']; + $body->user_id = $user['agentId']; + $body->user_type = 'agent'; curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); /* execute request */ curl_exec($ch); @@ -985,23 +986,39 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM $validation_code=$user['validation_code']; $ct=$this->messageText['USER_']; $message1 =sprintf($this->messageText['MESSAGE_1_USER'],$username,$ct,$phone,$request->password,$validation_code); - $message2 = sprintf($this->messageText['MESSAGE_2'],$username,$ct,$phone,$request->password,""); - - $from = "noreply@ilink-app.com"; - $headers = "From:" . $from; - $name = "ilink"; - - $this->messenger->setReceiverMail($user['email']); - $this->messenger->setContact($user['phone']); - $this->messenger->setMessage($message1); - $this->messenger->setSubject($subject); - $this->messenger->setHeader($headers); +// $message2 = sprintf($this->messageText['MESSAGE_2'],$username,$ct,$phone,$request->password,""); + //Envoyez le mail de bienvenue try{ - $this->messenger->sendMail(); - }catch (\Throwable $e){ - $this->write_log($e->getMessage().'\n'.$e->getTraceAsString());; + /* API URL */ + $url = WALLET_SERVICE_URL.'/notify-new-user'; + /* Init cURL resource */ + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + /* set the content type json */ + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type:application/json', + 'Authorization:'.WALLET_SERVICE_TOKEN, + )); + /* set return type json */ + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, 1); + + $body = new \stdClass(); + $body->subject = $subject; + $body->email = $user['email']; + $body->message = $message1; + $body->user_id = $user['agentId']; + $body->user_type = 'user'; + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); + /* execute request */ + curl_exec($ch); + /* close cURL resource */ + curl_close($ch); + }catch (Throwable $e){ + $this->write_log("Error Notify New Simple user ".$request->lastname." : ".$e->getMessage()."\n"); } + $this->messenger->setContact($user['phone']); $sms = $this->messenger->sendSms(); } else {