+ Documentation and update demande_credits result fields
This commit is contained in:
parent
5febd4d014
commit
ec5d8f39b6
|
@ -7,10 +7,25 @@
|
||||||
*/
|
*/
|
||||||
include '../interacted/Messenger.php';
|
include '../interacted/Messenger.php';
|
||||||
include '../init/init.php';
|
include '../init/init.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette classe assure la connexion à la base de données et toutes les requetes nécéssaires
|
||||||
|
*/
|
||||||
class DataBaseConnector
|
class DataBaseConnector
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Messenger
|
||||||
|
*/
|
||||||
var $messenger;
|
var $messenger;
|
||||||
|
/**
|
||||||
|
* @var false|mysqli Connexion
|
||||||
|
*/
|
||||||
var $con;
|
var $con;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataBaseConnector constructor.
|
||||||
|
* @param bool $isTest
|
||||||
|
*/
|
||||||
public function __construct($isTest=false)
|
public function __construct($isTest=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,10 +39,20 @@ class DataBaseConnector
|
||||||
$this->messenger = new Messenger();
|
$this->messenger = new Messenger();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
mysqli_close($this->con);
|
mysqli_close($this->con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la config de la publicité en fonction du pays
|
||||||
|
* @param $id_country ID du pays
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getPubValue($id_country){
|
public function getPubValue($id_country){
|
||||||
$result = mysqli_query($this->con,"SELECT * from publiciteConfig WHERE id_config = '2' AND id_country='$id_country'");
|
$result = mysqli_query($this->con,"SELECT * from publiciteConfig WHERE id_config = '2' AND id_country='$id_country'");
|
||||||
$no_of_rows = mysqli_num_rows($result);
|
$no_of_rows = mysqli_num_rows($result);
|
||||||
|
@ -39,6 +64,11 @@ class DataBaseConnector
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste de configuration administrateur
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getPasValue(){
|
public function getPasValue(){
|
||||||
$result = mysqli_query($this->con,"SELECT * from adminConfig WHERE cle = 'pas_chargement'");
|
$result = mysqli_query($this->con,"SELECT * from adminConfig WHERE cle = 'pas_chargement'");
|
||||||
$no_of_rows = mysqli_num_rows($result);
|
$no_of_rows = mysqli_num_rows($result);
|
||||||
|
@ -50,6 +80,11 @@ class DataBaseConnector
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isPhoneExistedSimple($phone) {
|
public function isPhoneExistedSimple($phone) {
|
||||||
// connecting to mysql
|
// connecting to mysql
|
||||||
|
|
||||||
|
@ -63,6 +98,10 @@ class DataBaseConnector
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getNetwork(){
|
public function getNetwork(){
|
||||||
$r=mysqli_query($this->con,"select * from networks");
|
$r=mysqli_query($this->con,"select * from networks");
|
||||||
|
|
||||||
|
@ -77,6 +116,11 @@ class DataBaseConnector
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isPhoneExisted($phone) {
|
public function isPhoneExisted($phone) {
|
||||||
$result = mysqli_query($this->con,"SELECT phone from users WHERE phone = '$phone'");
|
$result = mysqli_query($this->con,"SELECT phone from users WHERE phone = '$phone'");
|
||||||
$no_of_rows = mysqli_num_rows($result);
|
$no_of_rows = mysqli_num_rows($result);
|
||||||
|
@ -88,6 +132,14 @@ class DataBaseConnector
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifie si un numéro de téléphone existe dans la table networks_agents
|
||||||
|
* @param $phone
|
||||||
|
* @param null $category
|
||||||
|
* @param null $phoneTransaction
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isPhoneExistedInCategory($phone, $category=null, $phoneTransaction=null){
|
public function isPhoneExistedInCategory($phone, $category=null, $phoneTransaction=null){
|
||||||
|
|
||||||
$result = mysqli_query($this->con,"SELECT na.phone from networks_agents na INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE na.transactionNumber ='$phoneTransaction'");
|
$result = mysqli_query($this->con,"SELECT na.phone from networks_agents na INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE na.transactionNumber ='$phoneTransaction'");
|
||||||
|
@ -101,6 +153,10 @@ class DataBaseConnector
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function checknumberValidity($phone){
|
public function checknumberValidity($phone){
|
||||||
try {
|
try {
|
||||||
return true;//$this->messenger->checkPhoneExist($phone);
|
return true;//$this->messenger->checkPhoneExist($phone);
|
||||||
|
@ -108,6 +164,11 @@ class DataBaseConnector
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $codemembre
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function isMemberCodeExisted($codemembre)
|
public function isMemberCodeExisted($codemembre)
|
||||||
{
|
{
|
||||||
$result = mysqli_query($this->con, "SELECT * from codeGenerer WHERE code_membre = '$codemembre' ");
|
$result = mysqli_query($this->con, "SELECT * from codeGenerer WHERE code_membre = '$codemembre' ");
|
||||||
|
@ -120,6 +181,10 @@ class DataBaseConnector
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getAgentByCodeMembre($code)
|
public function getAgentByCodeMembre($code)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -148,6 +213,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getAgentWithCodeMembre($code){
|
public function getAgentWithCodeMembre($code){
|
||||||
$listIdmemberParrain=mysqli_query($this->con,
|
$listIdmemberParrain=mysqli_query($this->con,
|
||||||
"SELECT na.id as agentId,na.transactionNumber as transactionNumber,ag.email as email,ag.number_super as nbre_reseau,ag.number_geoBySuper as nbre_sous_reseau,cg.category as category, cg.code_parrain as code_parrain,cg.code_membre as code_membre,cg.id as idCode from agents ag RIGHT JOIN networks_agents na on ag.id=na.agent_id RIGHT JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE cg.code_membre='$code'");
|
"SELECT na.id as agentId,na.transactionNumber as transactionNumber,ag.email as email,ag.number_super as nbre_reseau,ag.number_geoBySuper as nbre_sous_reseau,cg.category as category, cg.code_parrain as code_parrain,cg.code_membre as code_membre,cg.id as idCode from agents ag RIGHT JOIN networks_agents na on ag.id=na.agent_id RIGHT JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE cg.code_membre='$code'");
|
||||||
|
@ -156,6 +226,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return $membre;
|
return $membre;
|
||||||
}else return false;
|
}else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getAgentNetworkByCode($code){
|
public function getAgentNetworkByCode($code){
|
||||||
$listIdmemberParrain=mysqli_query($this->con,
|
$listIdmemberParrain=mysqli_query($this->con,
|
||||||
"SELECT ne.id, ne.name,ne.status from networks ne INNER JOIN networks_agents na ON na.network_id=ne.id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE cg.code_membre='$code'");
|
"SELECT ne.id, ne.name,ne.status from networks ne INNER JOIN networks_agents na ON na.network_id=ne.id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE cg.code_membre='$code'");
|
||||||
|
@ -164,6 +239,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return $membre;
|
return $membre;
|
||||||
}else return ['error'=>mysqli_error($this->con)];
|
}else return ['error'=>mysqli_error($this->con)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getAgentById($id){
|
public function getAgentById($id){
|
||||||
$listIdmemberParrain=mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,ag.lastname AS lastname,
|
$listIdmemberParrain=mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,ag.lastname AS lastname,
|
||||||
ag.email AS email,ag.longitude as longitude,ag.latitude AS latitude,ag.active as active,
|
ag.email AS email,ag.longitude as longitude,ag.latitude AS latitude,ag.active as active,
|
||||||
|
@ -193,6 +273,20 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $fname
|
||||||
|
* @param $lname
|
||||||
|
* @param $email
|
||||||
|
* @param $phone
|
||||||
|
* @param $password
|
||||||
|
* @param $network
|
||||||
|
* @param $member
|
||||||
|
* @param $latitude
|
||||||
|
* @param $longitude
|
||||||
|
* @param $town
|
||||||
|
* @param $phoneTransaction
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function storeUser($fname, $lname, $email, $phone, $password, $network, $member, $latitude, $longitude, $town, $phoneTransaction)
|
public function storeUser($fname, $lname, $email, $phone, $password, $network, $member, $latitude, $longitude, $town, $phoneTransaction)
|
||||||
{
|
{
|
||||||
//on verifie si y a un agent qui utilise ce code
|
//on verifie si y a un agent qui utilise ce code
|
||||||
|
@ -244,6 +338,9 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function random_string()
|
public function random_string()
|
||||||
{
|
{
|
||||||
$character_set_array = array();
|
$character_set_array = array();
|
||||||
|
@ -259,6 +356,10 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return implode('', $temp_array);
|
return implode('', $temp_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $country
|
||||||
|
* @return array|bool
|
||||||
|
*/
|
||||||
public function getAllPointInCountry($country){
|
public function getAllPointInCountry($country){
|
||||||
$etat=1;
|
$etat=1;
|
||||||
$si=1;
|
$si=1;
|
||||||
|
@ -292,6 +393,10 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @return array|bool
|
||||||
|
*/
|
||||||
public function getUserCountryPoint($user_id){
|
public function getUserCountryPoint($user_id){
|
||||||
$result = mysqli_query($this->con,"SELECT * FROM agents ag inner JOIN networks_agents na ON na.agent_id=ag.id INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.category='geolocated' AND na.etat=1") or die(mysqli_error($this->con));
|
$result = mysqli_query($this->con,"SELECT * FROM agents ag inner JOIN networks_agents na ON na.agent_id=ag.id INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.category='geolocated' AND na.etat=1") or die(mysqli_error($this->con));
|
||||||
if($result) {
|
if($result) {
|
||||||
|
@ -304,6 +409,10 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $codeparrain
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getCategoryAgent($codeparrain){
|
public function getCategoryAgent($codeparrain){
|
||||||
$result=mysqli_query($this->con,"SELECT category,etat FROM codeGenerer where code_membre = '$codeparrain'");
|
$result=mysqli_query($this->con,"SELECT category,etat FROM codeGenerer where code_membre = '$codeparrain'");
|
||||||
if($result) {
|
if($result) {
|
||||||
|
@ -315,6 +424,9 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function updateWrongPoints()
|
public function updateWrongPoints()
|
||||||
{
|
{
|
||||||
$result=[];
|
$result=[];
|
||||||
|
@ -322,6 +434,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $codeparrain
|
||||||
|
* @param $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getSuperviseurNetwork($codeparrain, $user_id){
|
public function getSuperviseurNetwork($codeparrain, $user_id){
|
||||||
$self=$this->getAgentByCodeMembre($codeparrain);
|
$self=$this->getAgentByCodeMembre($codeparrain);
|
||||||
$catparrain=$self['category'];
|
$catparrain=$self['category'];
|
||||||
|
@ -354,6 +471,12 @@ INNER JOIN networks nt ON na.network_id=nt.id INNER JOIN agents ag ON ag.id=na.a
|
||||||
return $re;
|
return $re;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne tous les points agents d'un réseau
|
||||||
|
* @param int $network ID du réseau
|
||||||
|
* @param $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getPointsNetwork($network, $user_id){
|
public function getPointsNetwork($network, $user_id){
|
||||||
$result=mysqli_query($this->con,"SELECT ag.firstname,cg.code_membre,cg.code_parrain,ag.adresse,
|
$result=mysqli_query($this->con,"SELECT ag.firstname,cg.code_membre,cg.code_parrain,ag.adresse,
|
||||||
ag.lastname,na.phone,ag.email,na.solde,cg.category,ne.name as network,ct.id as country,ag.longitude,ag.latitude,ag.id as AgentId,ne.id as network_id,ct.id as country_id
|
ag.lastname,na.phone,ag.email,na.solde,cg.category,ne.name as network,ct.id as country,ag.longitude,ag.latitude,ag.id as AgentId,ne.id as network_id,ct.id as country_id
|
||||||
|
@ -371,6 +494,13 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifie qu'un mot de passe correspond à un utilisateur dans la table
|
||||||
|
* @param $phone
|
||||||
|
* @param $password
|
||||||
|
* @param $table
|
||||||
|
* @return array|bool|mysqli_result|null
|
||||||
|
*/
|
||||||
private function getUserByPhoneAndPassword($phone, $password, $table) {
|
private function getUserByPhoneAndPassword($phone, $password, $table) {
|
||||||
$result = mysqli_query($this->con,"SELECT usr.active,usr.salt,usr.encrypted_password,usr.firstname,usr.lastname,usr.id,usr.phone,usr.email,usr.solde,usr.validation_code,usr.active,usr.network_id,ne.name as network,ne.country_id,ct.name as country,ct.code_dial,ct.code_country FROM $table usr INNER JOIN networks ne ON usr.network_id=ne.id INNER JOIN countries ct ON ct.id=ne.country_id WHERE phone = '$phone'") or die(mysqli_error($this->con));
|
$result = mysqli_query($this->con,"SELECT usr.active,usr.salt,usr.encrypted_password,usr.firstname,usr.lastname,usr.id,usr.phone,usr.email,usr.solde,usr.validation_code,usr.active,usr.network_id,ne.name as network,ne.country_id,ct.name as country,ct.code_dial,ct.code_country FROM $table usr INNER JOIN networks ne ON usr.network_id=ne.id INNER JOIN countries ct ON ct.id=ne.country_id WHERE phone = '$phone'") or die(mysqli_error($this->con));
|
||||||
// check for result
|
// check for result
|
||||||
|
@ -393,6 +523,10 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $password
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function hashSSHA($password) {
|
public function hashSSHA($password) {
|
||||||
|
|
||||||
$salt = sha1(rand());
|
$salt = sha1(rand());
|
||||||
|
@ -402,6 +536,12 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @param $encrypted_password
|
||||||
|
* @param $salt
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function forgotPasswordSimple($phone, $encrypted_password, $salt)
|
public function forgotPasswordSimple($phone, $encrypted_password, $salt)
|
||||||
{
|
{
|
||||||
$result = mysqli_query($this->con, "UPDATE `users` SET `encrypted_password` = '$encrypted_password',`salt` = '$salt' WHERE `phone` = '$phone'");
|
$result = mysqli_query($this->con, "UPDATE `users` SET `encrypted_password` = '$encrypted_password',`salt` = '$salt' WHERE `phone` = '$phone'");
|
||||||
|
@ -415,6 +555,10 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getEmailSimple($phone){
|
public function getEmailSimple($phone){
|
||||||
$result = mysqli_query($this->con,"SELECT email FROM users WHERE phone = '$phone'");
|
$result = mysqli_query($this->con,"SELECT email FROM users WHERE phone = '$phone'");
|
||||||
|
|
||||||
|
@ -430,6 +574,9 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function listNetwork(){
|
public function listNetwork(){
|
||||||
echo "request";
|
echo "request";
|
||||||
$res=mysqli_query($this->con,"SELECT * FROM network");
|
$res=mysqli_query($this->con,"SELECT * FROM network");
|
||||||
|
@ -439,6 +586,11 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
}else return ['error'=>'unable to make request','error_'=>mysqli_error($this->con)];
|
}else return ['error'=>'unable to make request','error_'=>mysqli_error($this->con)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $salt
|
||||||
|
* @param $password
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function checkhashSSHA($salt, $password) {
|
private function checkhashSSHA($salt, $password) {
|
||||||
|
|
||||||
$hash = base64_encode(sha1($password . $salt, true) . $salt);
|
$hash = base64_encode(sha1($password . $salt, true) . $salt);
|
||||||
|
@ -464,6 +616,11 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
||||||
return $randomString;
|
return $randomString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @param $password
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getUserByPhoneAndPasswordGeolocated($phone, $password) {
|
public function getUserByPhoneAndPasswordGeolocated($phone, $password) {
|
||||||
// connecting to mysql
|
// connecting to mysql
|
||||||
$result = mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,ag.lastname AS lastname,
|
$result = mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,ag.lastname AS lastname,
|
||||||
|
@ -513,6 +670,10 @@ ne.id as network_id,ag.date_created as date_created,cg.category as category,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getAgentNetworkByPhone($phone){
|
public function getAgentNetworkByPhone($phone){
|
||||||
$listIdmemberParrain=mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,
|
$listIdmemberParrain=mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,
|
||||||
ag.lastname AS lastname,
|
ag.lastname AS lastname,
|
||||||
|
@ -543,6 +704,13 @@ na.id as networkAgentId,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enregistre une demande de credit
|
||||||
|
* @param $phone
|
||||||
|
* @param $montant
|
||||||
|
* @param $code
|
||||||
|
* @return array|bool
|
||||||
|
*/
|
||||||
public function storeDemandeCredit($phone, $montant, $code){
|
public function storeDemandeCredit($phone, $montant, $code){
|
||||||
$agent=$this->getAgentWithCodeMembre($code);
|
$agent=$this->getAgentWithCodeMembre($code);
|
||||||
if($agent) {
|
if($agent) {
|
||||||
|
@ -556,6 +724,20 @@ na.id as networkAgentId,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $fname
|
||||||
|
* @param $lnameu
|
||||||
|
* @param $email
|
||||||
|
* @param $phone
|
||||||
|
* @param $password
|
||||||
|
* @param $network
|
||||||
|
* @param $member
|
||||||
|
* @param $latitude
|
||||||
|
* @param $longitude
|
||||||
|
* @param $town
|
||||||
|
* @param $phoneTransaction
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
private function createAgent($fname, $lname, $email, $phone, $password, $network, $member, $latitude, $longitude, $town, $phoneTransaction)
|
private function createAgent($fname, $lname, $email, $phone, $password, $network, $member, $latitude, $longitude, $town, $phoneTransaction)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -644,6 +826,11 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $membre
|
||||||
|
* @param $category
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
public function generateValideCode($membre, $category)
|
public function generateValideCode($membre, $category)
|
||||||
{
|
{
|
||||||
$code=null;
|
$code=null;
|
||||||
|
@ -666,6 +853,10 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $agent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function adddemandeAdhesionAgent($agent)
|
private function adddemandeAdhesionAgent($agent)
|
||||||
{
|
{
|
||||||
$codeparrain=$agent['code_parrain'];
|
$codeparrain=$agent['code_parrain'];
|
||||||
|
@ -687,6 +878,15 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $firstname
|
||||||
|
* @param $lastname
|
||||||
|
* @param $email
|
||||||
|
* @param $phone
|
||||||
|
* @param $password
|
||||||
|
* @param $network
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function storeUserSimple($firstname, $lastname, $email, $phone, $password, $network)
|
public function storeUserSimple($firstname, $lastname, $email, $phone, $password, $network)
|
||||||
{
|
{
|
||||||
$uuid = uniqid('', true);
|
$uuid = uniqid('', true);
|
||||||
|
@ -725,6 +925,12 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $phone
|
||||||
|
* @param string $code_parrain
|
||||||
|
* @param $agent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function generateNetworkAgent($phone, $code_parrain, $agent)
|
public function generateNetworkAgent($phone, $code_parrain, $agent)
|
||||||
{
|
{
|
||||||
$code=$this->generateValideCode($code_parrain,"geolocated");
|
$code=$this->generateValideCode($code_parrain,"geolocated");
|
||||||
|
@ -778,6 +984,10 @@ salt,validation_code, active,network_id) VALUES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $validation_code
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getGeoLocatedFreeWithValidationCode($validation_code)
|
public function getGeoLocatedFreeWithValidationCode($validation_code)
|
||||||
{
|
{
|
||||||
$qu=mysqli_query($this->con,"SELECT na.id as id,na.validation_code as validation_code,na.etat as etat, na.agent_id as agent_id,cg.code_membre as code_membre,cg.code_parrain as code_parrain, cg.category as category FROM networks_agents na INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE na.validation_code='$validation_code' AND cg.category='geolocated' AND na.agent_id is null");
|
$qu=mysqli_query($this->con,"SELECT na.id as id,na.validation_code as validation_code,na.etat as etat, na.agent_id as agent_id,cg.code_membre as code_membre,cg.code_parrain as code_parrain, cg.category as category FROM networks_agents na INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE na.validation_code='$validation_code' AND cg.category='geolocated' AND na.agent_id is null");
|
||||||
|
@ -797,6 +1007,11 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $idAgent
|
||||||
|
* @param $idNetworkAgent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function assignNetworkAgent($idAgent, $idNetworkAgent)
|
public function assignNetworkAgent($idAgent, $idNetworkAgent)
|
||||||
{
|
{
|
||||||
$re=mysqli_query($this->con,"UPDATE networks_agents SET agent_id='$idAgent',etat='1' WHERE id='$idNetworkAgent'");
|
$re=mysqli_query($this->con,"UPDATE networks_agents SET agent_id='$idAgent',etat='1' WHERE id='$idNetworkAgent'");
|
||||||
|
@ -805,6 +1020,11 @@ salt,validation_code, active,network_id) VALUES
|
||||||
}else return ['error'=>mysqli_error($this->con)];
|
}else return ['error'=>mysqli_error($this->con)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste de de tous les réseaux géolocalisés d'un agent
|
||||||
|
* @param $user_id ID de l'agent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getListNetworkOfGeoPoint($user_id)
|
public function getListNetworkOfGeoPoint($user_id)
|
||||||
{
|
{
|
||||||
$q=mysqli_query($this->con,"SELECT na.id as id,na.network_id as network_id,na.solde as solde,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name from agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE ag.id='$user_id'");
|
$q=mysqli_query($this->con,"SELECT na.id as id,na.network_id as network_id,na.solde as solde,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name from agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE ag.id='$user_id'");
|
||||||
|
@ -819,6 +1039,11 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste de de tous les réseaux libre d'un agent
|
||||||
|
* @param string $code_parrain
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getListFreeNetworkOfGeoPoint($code_parrain)
|
public function getListFreeNetworkOfGeoPoint($code_parrain)
|
||||||
{
|
{
|
||||||
$q=mysqli_query($this->con,"SELECT na.id as id,na.network_id as network_id,na.solde as solde,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name,na.validation_code as validation_code from networks_agents na INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE cg.code_parrain='$code_parrain' AND cg.code_membre!='$code_parrain' AND na.agent_id IS NULL");
|
$q=mysqli_query($this->con,"SELECT na.id as id,na.network_id as network_id,na.solde as solde,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name,na.validation_code as validation_code from networks_agents na INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE cg.code_parrain='$code_parrain' AND cg.code_membre!='$code_parrain' AND na.agent_id IS NULL");
|
||||||
|
@ -833,10 +1058,15 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $codeparrain
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getListDemandeReceiveAgent($codeparrain)
|
public function getListDemandeReceiveAgent($codeparrain)
|
||||||
{
|
{
|
||||||
|
|
||||||
$q=mysqli_query($this->con,"SELECT dc.id as id,dc.montant as montant,dc.date_creation,dc.date_modification,dc.status as status,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name,ne.name as reseau from demandeCredits dc INNER JOIN networks_agents na ON na.id=dc.network_agent_id INNER JOIN agents ag ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE cg.code_parrain='$codeparrain'");
|
$q=mysqli_query($this->con,"SELECT dc.id as id,dc.montant as montant,dc.date_creation,dc.date_modification,dc.status as status,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name,ne.name as reseau, ag.firstname, ag.lastname
|
||||||
|
from demandeCredits dc INNER JOIN networks_agents na ON na.id=dc.network_agent_id INNER JOIN agents ag ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE cg.code_parrain='$codeparrain'");
|
||||||
if($q){
|
if($q){
|
||||||
$rows=[];
|
$rows=[];
|
||||||
while($row=mysqli_fetch_array($q,MYSQLI_ASSOC)){
|
while($row=mysqli_fetch_array($q,MYSQLI_ASSOC)){
|
||||||
|
@ -848,9 +1078,14 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getListDemandeSendAgent($user_id)
|
public function getListDemandeSendAgent($user_id)
|
||||||
{
|
{
|
||||||
$q=mysqli_query($this->con,"SELECT ne.name as reseau, dc.id as id,dc.montant as montant,dc.date_creation,dc.date_modification,dc.status as status,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name from demandeCredits dc INNER JOIN networks_agents na ON na.id=dc.network_agent_id INNER JOIN agents ag ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE ag.id='$user_id'");
|
$q=mysqli_query($this->con,"SELECT ne.name as reseau, dc.id as id,dc.montant as montant,dc.date_creation,dc.date_modification,dc.status as status,na.phone as phone,cg.code_membre as code_membre, cg.code_parrain as code_parrain,cg.category as category,ne.name as name,ag.firstname, ag.lastname
|
||||||
|
from demandeCredits dc INNER JOIN networks_agents na ON na.id=dc.network_agent_id INNER JOIN agents ag ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id WHERE ag.id='$user_id'");
|
||||||
if($q){
|
if($q){
|
||||||
$rows=[];
|
$rows=[];
|
||||||
while($row=mysqli_fetch_array($q,MYSQLI_ASSOC)){
|
while($row=mysqli_fetch_array($q,MYSQLI_ASSOC)){
|
||||||
|
@ -862,6 +1097,10 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $user_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function treatDemand($user_id)
|
public function treatDemand($user_id)
|
||||||
{
|
{
|
||||||
$dat=date ("Y-m-d H:i:s");
|
$dat=date ("Y-m-d H:i:s");
|
||||||
|
@ -881,6 +1120,10 @@ salt,validation_code, active,network_id) VALUES
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code_membre
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
private function getNbMemberOf($code_membre)
|
private function getNbMemberOf($code_membre)
|
||||||
{
|
{
|
||||||
$q=mysqli_query($this->con,"SELECT DISTINCT COUNT(*) AS nbr_membre FROM agents ag INNER JOIN networks_agents na ON na.agent_id=ag.id INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.code_parrain='$code_membre' AND cg.code_membre!='$code_membre' AND na.etat='1'");
|
$q=mysqli_query($this->con,"SELECT DISTINCT COUNT(*) AS nbr_membre FROM agents ag INNER JOIN networks_agents na ON na.agent_id=ag.id INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.code_parrain='$code_membre' AND cg.code_membre!='$code_membre' AND na.etat='1'");
|
||||||
|
@ -891,6 +1134,14 @@ salt,validation_code, active,network_id) VALUES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les points agents d'un réseau autour d'un rayon de kilometres
|
||||||
|
* @param $reseau
|
||||||
|
* @param $position
|
||||||
|
* @param float $distance
|
||||||
|
* @param int $page
|
||||||
|
* @return array|string
|
||||||
|
*/
|
||||||
public function getPointInDistance($reseau, $position, $distance, $page)
|
public function getPointInDistance($reseau, $position, $distance, $page)
|
||||||
{
|
{
|
||||||
$mlat=$position->latitude;
|
$mlat=$position->latitude;
|
||||||
|
@ -913,4 +1164,8 @@ ag.adresse,
|
||||||
return $li;
|
return $li;
|
||||||
}else return mysqli_error($this->con);
|
}else return mysqli_error($this->con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function vir(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -8,15 +8,34 @@
|
||||||
|
|
||||||
|
|
||||||
include 'DataBaseConnector.php';
|
include 'DataBaseConnector.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cette classe matérialise la resource qui execute une requete
|
||||||
|
*/
|
||||||
class Requester
|
class Requester
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO ajouter la comparaison partiel de la ville query with la ville
|
//TODO ajouter la comparaison partiel de la ville query with la ville
|
||||||
// Step 3: instantiate a new Twilio Rest Client
|
// Step 3: instantiate a new Twilio Rest Client
|
||||||
|
/**
|
||||||
|
* @var Messenger Le messenger de TWILIO
|
||||||
|
*/
|
||||||
var $messenger;
|
var $messenger;
|
||||||
|
/**
|
||||||
|
* @var DataBaseConnector Le connecteur de base de données
|
||||||
|
*/
|
||||||
var $db;
|
var $db;
|
||||||
|
/**
|
||||||
|
* @var int ID de l'utilisateur
|
||||||
|
*/
|
||||||
var $user_id;
|
var $user_id;
|
||||||
|
/**
|
||||||
|
* @var mixed le message
|
||||||
|
*/
|
||||||
var $messageText;
|
var $messageText;
|
||||||
|
/**
|
||||||
|
* @var array Les langues anglaises
|
||||||
|
*/
|
||||||
var $enLangs=["en","en-US","en_US","ca","in","gb","GB","us","en-029","en-AU","en-BZ","en-CA","en-GB","en-IE","en-IN","en-JM","en-MY","en-NZ","en-PH","en-SG","en-TT","en-US","en-ZA","en-ZW","au","bz","ie","in","jm","my","nz","ph","sg","tt","za"];
|
var $enLangs=["en","en-US","en_US","ca","in","gb","GB","us","en-029","en-AU","en-BZ","en-CA","en-GB","en-IE","en-IN","en-JM","en-MY","en-NZ","en-PH","en-SG","en-TT","en-US","en-ZA","en-ZW","au","bz","ie","in","jm","my","nz","ph","sg","tt","za"];
|
||||||
/**
|
/**
|
||||||
* Requester constructor.
|
* Requester constructor.
|
||||||
|
@ -54,16 +73,33 @@ class Requester
|
||||||
$this->messenger->sendMail();
|
$this->messenger->sendMail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la config administrateur sans chargement
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getPasValue(){
|
public function getPasValue(){
|
||||||
$pasObject=$this->db->getPasValue();
|
$pasObject=$this->db->getPasValue();
|
||||||
if($pasObject)return json_encode(['pas'=>$pasObject]);
|
if($pasObject)return json_encode(['pas'=>$pasObject]);
|
||||||
else return json_encode(['error'=>mysqli_error($this->db->con)]);
|
else return json_encode(['error'=>mysqli_error($this->db->con)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la config de la publicité en fonction du pays
|
||||||
|
* @param $id_country ID du pays
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getPubValue($id_country){
|
public function getPubValue($id_country){
|
||||||
$pasObject=$this->db->getPubValue($id_country);
|
$pasObject=$this->db->getPubValue($id_country);
|
||||||
if($pasObject)return json_encode(['pub'=>$pasObject]);
|
if($pasObject)return json_encode(['pub'=>$pasObject]);
|
||||||
else return json_encode(['error'=>mysqli_error($this->db->con)]);
|
else return json_encode(['error'=>mysqli_error($this->db->con)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supprime un agent
|
||||||
|
* @param string $code code agent
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function deleteAgent($code){
|
public function deleteAgent($code){
|
||||||
$agent=$this->db->getAgentWithCodeMembre($code);
|
$agent=$this->db->getAgentWithCodeMembre($code);
|
||||||
if($agent){
|
if($agent){
|
||||||
|
@ -73,6 +109,13 @@ class Requester
|
||||||
return json_encode(['count_network'=>mysqli_num_rows($res),"count_code"=>mysqli_num_rows($re)]);
|
return json_encode(['count_network'=>mysqli_num_rows($res),"count_code"=>mysqli_num_rows($re)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connecte un utilisateur avec son numero de telephone et son mot de passe
|
||||||
|
* @param string $phone
|
||||||
|
* @param string $password
|
||||||
|
* @return array|bool|mysqli_result|null L'utilisateur ou un message d'erreur
|
||||||
|
*/
|
||||||
public function loginPhonePassword($phone, $password)
|
public function loginPhonePassword($phone, $password)
|
||||||
{
|
{
|
||||||
// check for user
|
// check for user
|
||||||
|
@ -87,6 +130,12 @@ class Requester
|
||||||
}
|
}
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne toutes les infos sur un agent
|
||||||
|
* @param string $code code agent
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getAgentInfoByCode($code){
|
public function getAgentInfoByCode($code){
|
||||||
$codes=$this->getChildCode($code);
|
$codes=$this->getChildCode($code);
|
||||||
if(isset($codes["child"])){
|
if(isset($codes["child"])){
|
||||||
|
@ -94,6 +143,12 @@ class Requester
|
||||||
}
|
}
|
||||||
return json_encode($codes);
|
return json_encode($codes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les reseaux d'un superviseur
|
||||||
|
* @param string $codesuperviseur
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getSuperviseurNetwork($codesuperviseur)
|
public function getSuperviseurNetwork($codesuperviseur)
|
||||||
{
|
{
|
||||||
$point = $this->db->getSuperviseurNetwork($codesuperviseur, $this->user_id);
|
$point = $this->db->getSuperviseurNetwork($codesuperviseur, $this->user_id);
|
||||||
|
@ -109,6 +164,12 @@ class Requester
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recupere la liste des coordonnées des points agents d'une ville
|
||||||
|
* @param $country
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getAllCountryPoint($country)
|
public function getAllCountryPoint($country)
|
||||||
{
|
{
|
||||||
$point = $this->db->getAllPointInCountry($country);
|
$point = $this->db->getAllPointInCountry($country);
|
||||||
|
@ -121,6 +182,12 @@ class Requester
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrouve le mot de passe oublié d'un agent
|
||||||
|
* @param string $number
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function recoverPasswordAgent($number)
|
public function recoverPasswordAgent($number)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedSimple($number)) {
|
if ($this->db->isPhoneExistedSimple($number)) {
|
||||||
|
@ -165,6 +232,12 @@ class Requester
|
||||||
}else
|
}else
|
||||||
return ['error' => -5, 'message' => "Ce numéro n'existe pas",'phone'=>$number];
|
return ['error' => -5, 'message' => "Ce numéro n'existe pas",'phone'=>$number];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrouve le mot de passe oublié d'un utilisateur
|
||||||
|
* @param string $number
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function recoverUserPassword($number)
|
public function recoverUserPassword($number)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedSimple($number)) {
|
if ($this->db->isPhoneExistedSimple($number)) {
|
||||||
|
@ -209,10 +282,24 @@ class Requester
|
||||||
return ['error' => -5, 'message' => 'Ce numéro n\'existe pas',"phone"=>"$number"];
|
return ['error' => -5, 'message' => 'Ce numéro n\'existe pas',"phone"=>"$number"];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Envoie un mail
|
||||||
|
* @param string $email
|
||||||
|
* @param string $subject
|
||||||
|
* @param string $message
|
||||||
|
* @param string $headers
|
||||||
|
*/
|
||||||
private function sendMail($email, $subject, $message, $headers)
|
private function sendMail($email, $subject, $message, $headers)
|
||||||
{
|
{
|
||||||
mail($email, $subject, $message, $headers);
|
mail($email, $subject, $message, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Envoi un message
|
||||||
|
* @param string $message
|
||||||
|
* @param string $number
|
||||||
|
*/
|
||||||
private function sendMessage($message, $number)
|
private function sendMessage($message, $number)
|
||||||
{
|
{
|
||||||
$sms = $this->client->account->messages->create(
|
$sms = $this->client->account->messages->create(
|
||||||
|
@ -228,11 +315,26 @@ class Requester
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les points agents d'un réseau autour d'un rayon de kilometres
|
||||||
|
* @param string $reseau
|
||||||
|
* @param $position
|
||||||
|
* @param float $distance
|
||||||
|
* @param int $page
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getPointAroundKm($reseau, $position, $distance, $page)
|
public function getPointAroundKm($reseau, $position, $distance, $page)
|
||||||
{
|
{
|
||||||
$list=$this->db->getPointInDistance($reseau,$position,$distance,$page);
|
$list=$this->db->getPointInDistance($reseau,$position,$distance,$page);
|
||||||
return json_encode($list);
|
return json_encode($list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne tous les points agents d'un réseau
|
||||||
|
* @param $network
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getNetworkPoint($network)
|
public function getNetworkPoint($network)
|
||||||
{
|
{
|
||||||
$points = $this->db->getPointsNetwork($network, $this->user_id);
|
$points = $this->db->getPointsNetwork($network, $this->user_id);
|
||||||
|
@ -243,6 +345,15 @@ class Requester
|
||||||
return json_encode(['error' => -4, 'error_msg' => 'error query','mysql'=> mysqli_error($this->db->con),"data"=>$points,"network"=>$network,"user"=>$this->user_id]);
|
return json_encode(['error' => -4, 'error_msg' => 'error query','mysql'=> mysqli_error($this->db->con),"data"=>$points,"network"=>$network,"user"=>$this->user_id]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcule la distance entre 2 points sur la carte
|
||||||
|
* @param int $lat1 Latitude du 1er point
|
||||||
|
* @param int $lon1 Longitude du 1er point
|
||||||
|
* @param int $lat2 Latitude du 2eme point
|
||||||
|
* @param int $lon2 Longitude du 2eme point
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
function distance($lat1, $lon1, $lat2, $lon2)
|
function distance($lat1, $lon1, $lat2, $lon2)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -263,6 +374,12 @@ class Requester
|
||||||
return $miles;
|
return $miles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inscrire un agent
|
||||||
|
* @param $request Requete d'inscription
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function registerGeolocated($request)
|
public function registerGeolocated($request)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedInCategory($request->phone, $request->category,$request->phone_transaction)) {
|
if ($this->db->isPhoneExistedInCategory($request->phone, $request->category,$request->phone_transaction)) {
|
||||||
|
@ -325,10 +442,22 @@ class Requester
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne tous les réseaux
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getNetwork()
|
public function getNetwork()
|
||||||
{
|
{
|
||||||
return json_encode($this->db->getNetwork());
|
return json_encode($this->db->getNetwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connecter un utilisateur
|
||||||
|
* @param string $phone
|
||||||
|
* @param $password
|
||||||
|
* @return array|bool|mysqli_result|null
|
||||||
|
*/
|
||||||
public function loginUser($phone, $password)
|
public function loginUser($phone, $password)
|
||||||
{
|
{
|
||||||
$user = $this->db->getUserByPhoneAndPasswordSimple($phone, $password);
|
$user = $this->db->getUserByPhoneAndPasswordSimple($phone, $password);
|
||||||
|
@ -350,6 +479,13 @@ class Requester
|
||||||
}
|
}
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connecte un agent (superviseur ou hyperviseur)
|
||||||
|
* @param string $phone
|
||||||
|
* @param string $password
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function loginAgent($phone, $password)
|
public function loginAgent($phone, $password)
|
||||||
{
|
{
|
||||||
$user = $this->db->getUserByPhoneAndPasswordGeolocated($phone, $password);
|
$user = $this->db->getUserByPhoneAndPasswordGeolocated($phone, $password);
|
||||||
|
@ -364,6 +500,12 @@ class Requester
|
||||||
return $user;
|
return $user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste des demandes d'adhesion d'un superviseur
|
||||||
|
* @param string $codeparrain
|
||||||
|
* @return array|string
|
||||||
|
*/
|
||||||
public function getSupervisorAdhesionList($codeparrain)
|
public function getSupervisorAdhesionList($codeparrain)
|
||||||
{
|
{
|
||||||
$resparrain=mysqli_query($this->db->con,"SELECT na.id as id FROM networks_agents na INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.code_membre='$codeparrain'");
|
$resparrain=mysqli_query($this->db->con,"SELECT na.id as id FROM networks_agents na INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE cg.code_membre='$codeparrain'");
|
||||||
|
@ -393,6 +535,12 @@ class Requester
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la categorie des "fils" d'un menbre
|
||||||
|
* @param string $codeparrain
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
public function getChildCode($codeparrain)
|
public function getChildCode($codeparrain)
|
||||||
{
|
{
|
||||||
$r=$this->db->getCategoryAgent($codeparrain);
|
$r=$this->db->getCategoryAgent($codeparrain);
|
||||||
|
@ -408,6 +556,11 @@ class Requester
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Corrige un erreur d'accent sur les champs firstname de la table users_simple
|
||||||
|
* @return array|bool|mysqli_result
|
||||||
|
*/
|
||||||
public function updateWrongPoint()
|
public function updateWrongPoint()
|
||||||
{
|
{
|
||||||
$result=[];
|
$result=[];
|
||||||
|
@ -420,6 +573,14 @@ class Requester
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enregistre une demande de credit
|
||||||
|
* @param string $phone Numero du demandeur
|
||||||
|
* @param float $montant
|
||||||
|
* @param string $code Code de l'agent
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function storeCreditAsk($phone, $montant, $code)
|
public function storeCreditAsk($phone, $montant, $code)
|
||||||
{
|
{
|
||||||
$result=$this->db->storeDemandeCredit($phone,$montant,$code);
|
$result=$this->db->storeDemandeCredit($phone,$montant,$code);
|
||||||
|
@ -463,7 +624,11 @@ class Requester
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les reseaux d'un pays en fonction de l'indicatif
|
||||||
|
* @param string $indicatif
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getCountryNetWork($indicatif)
|
public function getCountryNetWork($indicatif)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -481,6 +646,11 @@ class Requester
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les infos d'une ville en focntion du nom
|
||||||
|
* @params string $name Nom de la ville
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getTownInfoByName($name)
|
public function getTownInfoByName($name)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -499,6 +669,11 @@ class Requester
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste des villes d'un pays en focntion de l'indicatif
|
||||||
|
* @param string $indicatif
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function getListTownsCountry($indicatif)
|
public function getListTownsCountry($indicatif)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -514,6 +689,14 @@ class Requester
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valider un compte agent en verifiant son code de validation
|
||||||
|
* @param string $phone Numero telephone
|
||||||
|
* @param string $code_validation Code
|
||||||
|
* @param int $mbre_reseau Nombre d'utilisateurs du reseau , pour un hyperviseur
|
||||||
|
* @param boolean $mr_sous_reseau
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function validateAgent($phone, $code_validation, $mbre_reseau=null, $mr_sous_reseau=null)
|
public function validateAgent($phone, $code_validation, $mbre_reseau=null, $mr_sous_reseau=null)
|
||||||
{
|
{
|
||||||
if(isset($phone) && isset($code_validation)){
|
if(isset($phone) && isset($code_validation)){
|
||||||
|
@ -624,6 +807,12 @@ class Requester
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide une demande d'adhesion vers un superviseur
|
||||||
|
* @param string $code Code du demandeur
|
||||||
|
* @param string $phone Numero de telephone du demande
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function activeSupervisorAdhesion($code, $phone)
|
public function activeSupervisorAdhesion($code, $phone)
|
||||||
{
|
{
|
||||||
$idsUser=mysqli_query($this->db->con,"SELECT ag.email as email,ag.firstname as firstname,ag.lastname as lastname,na.validation_code as validation_code,na.phone as phone,
|
$idsUser=mysqli_query($this->db->con,"SELECT ag.email as email,ag.firstname as firstname,ag.lastname as lastname,na.validation_code as validation_code,na.phone as phone,
|
||||||
|
@ -670,6 +859,11 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inscrire un nouvel utilisateur
|
||||||
|
* @param $request Requete d'inscription
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function registerUser($request)
|
public function registerUser($request)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedSimple($request->phone)) {
|
if ($this->db->isPhoneExistedSimple($request->phone)) {
|
||||||
|
@ -719,6 +913,12 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generer un agent geolocalisé vide pour un agent
|
||||||
|
* @param string $phone
|
||||||
|
* @param $code_parrain
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function generateEmptyAgentNetworkForAgent($phone, $code_parrain)
|
public function generateEmptyAgentNetworkForAgent($phone, $code_parrain)
|
||||||
{
|
{
|
||||||
if ($this->db->isPhoneExistedInCategory($phone)) {
|
if ($this->db->isPhoneExistedInCategory($phone)) {
|
||||||
|
@ -752,6 +952,13 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigner un reseau à un agent
|
||||||
|
* @param int $agentId
|
||||||
|
* @param string $code_parrain
|
||||||
|
* @param string $phone
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function assignNetworkToAgent($agentId, $code_parrain, $phone)
|
public function assignNetworkToAgent($agentId, $code_parrain, $phone)
|
||||||
{
|
{
|
||||||
$agent = $this->db->getAgentById($agentId);
|
$agent = $this->db->getAgentById($agentId);
|
||||||
|
@ -805,6 +1012,10 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste de de tous les réseaux géolocalisés d'un agent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function listNetworksGeo()
|
public function listNetworksGeo()
|
||||||
{
|
{
|
||||||
if($this->user_id){
|
if($this->user_id){
|
||||||
|
@ -821,6 +1032,10 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la liste de de tous les réseaux libre d'un agent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function listFreeNetworksForSuper()
|
public function listFreeNetworksForSuper()
|
||||||
{
|
{
|
||||||
if($this->user_id){
|
if($this->user_id){
|
||||||
|
@ -836,6 +1051,10 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les demandes de credits recues
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getAgentReceiveDemande()
|
public function getAgentReceiveDemande()
|
||||||
{
|
{
|
||||||
if($this->user_id){
|
if($this->user_id){
|
||||||
|
@ -852,6 +1071,10 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les demandes de crédits envoyés
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function getAgentSendDemande()
|
public function getAgentSendDemande()
|
||||||
{
|
{
|
||||||
if($this->user_id){
|
if($this->user_id){
|
||||||
|
@ -866,6 +1089,11 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
return json_encode(['error'=>'unable to find user_id']);
|
return json_encode(['error'=>'unable to find user_id']);
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $phone
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function treatDemand($phone)
|
public function treatDemand($phone)
|
||||||
{
|
{
|
||||||
if($this->user_id){
|
if($this->user_id){
|
||||||
|
@ -882,6 +1110,10 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne les pays actifs dans la plateforme
|
||||||
|
* @return array|false|string
|
||||||
|
*/
|
||||||
public function getActiveCountries()
|
public function getActiveCountries()
|
||||||
{
|
{
|
||||||
$mq=mysqli_query($this->db->con,"SELECT DISTINCT ct.id,ct.code_dial,ct.name,ct.code_country FROM countries ct INNER JOIN networks ne ON ne.country_id=ct.id");
|
$mq=mysqli_query($this->db->con,"SELECT DISTINCT ct.id,ct.code_dial,ct.name,ct.code_country FROM countries ct INNER JOIN networks ne ON ne.country_id=ct.id");
|
||||||
|
@ -895,11 +1127,22 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne un agent en fonction de son ID
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public function getAgentById()
|
public function getAgentById()
|
||||||
{
|
{
|
||||||
return$this->db->getAgentById($this->user_id);
|
return$this->db->getAgentById($this->user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mettre a jour la position d'un agent
|
||||||
|
* @param int $agentId
|
||||||
|
* @param float $longitude
|
||||||
|
* @param float $latitude
|
||||||
|
* @return false|string
|
||||||
|
*/
|
||||||
public function updatePosition($agentId, $longitude, $latitude)
|
public function updatePosition($agentId, $longitude, $latitude)
|
||||||
{
|
{
|
||||||
$result=[];
|
$result=[];
|
||||||
|
@ -910,6 +1153,11 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valide un utilisateur
|
||||||
|
* @param string $phone
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function validateUser($phone)
|
public function validateUser($phone)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -941,6 +1189,12 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne le porte feuille d'un agent
|
||||||
|
* @param int $idAgent
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
function getAgentWallet($idAgent){
|
function getAgentWallet($idAgent){
|
||||||
$res=mysqli_query($this->db->con,"SELECT * FROM wallets where id_networkAgent=$idAgent");
|
$res=mysqli_query($this->db->con,"SELECT * FROM wallets where id_networkAgent=$idAgent");
|
||||||
if($res){
|
if($res){
|
||||||
|
@ -949,6 +1203,16 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creer un requete de retrait dans une carte de crédit
|
||||||
|
* @param string $numCarte Numero de la carte
|
||||||
|
* @param int $cvv
|
||||||
|
* @param float $montant
|
||||||
|
* @param $taxe
|
||||||
|
* @param int $idAgent
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function createRequestRetrait($numCarte, $cvv, $montant, $taxe, $idAgent){
|
function createRequestRetrait($numCarte, $cvv, $montant, $taxe, $idAgent){
|
||||||
$agent=$this->getAgentWallet($idAgent);
|
$agent=$this->getAgentWallet($idAgent);
|
||||||
$agentCommission=floatval($taxe*0.8);
|
$agentCommission=floatval($taxe*0.8);
|
||||||
|
@ -962,7 +1226,6 @@ function createRequestRetrait($numCarte,$cvv,$montant,$taxe,$idAgent){
|
||||||
$resCredit=mysqli_query($this->db->con,"UPDATE wallets SET balance_princ=$newBalance,balance_com=$commission where id=$id");
|
$resCredit=mysqli_query($this->db->con,"UPDATE wallets SET balance_princ=$newBalance,balance_com=$commission where id=$id");
|
||||||
}else{
|
}else{
|
||||||
echo mysqli_error($this->db->con);
|
echo mysqli_error($this->db->con);
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
echo mysqli_error($this->db->con);
|
echo mysqli_error($this->db->con);
|
||||||
|
@ -970,4 +1233,16 @@ function createRequestRetrait($numCarte,$cvv,$montant,$taxe,$idAgent){
|
||||||
return ["result"=>"success","agent"=>$this->getAgentWallet($idAgent)];
|
return ["result"=>"success","agent"=>$this->getAgentWallet($idAgent)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function virementComission($idAgent){
|
||||||
|
$wallet=$this->getAgentWallet($idAgent);
|
||||||
|
$newBalancePrinc = $wallet["balance_princ"] + $wallet["balance_com"];
|
||||||
|
$id=$wallet["id"];
|
||||||
|
$result =mysqli_query($this->db->con,"UPDATE wallets SET balance_princ= $newBalancePrinc ,balance_com=0 where id=$id");
|
||||||
|
if($result){
|
||||||
|
return ["result"=>"success","agent"=>$this->getAgentWallet($idAgent)];
|
||||||
|
}else{
|
||||||
|
return ["result"=>"failed","error"=>mysqli_error($this->db->con)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
/*fichier de configuration test */
|
/**
|
||||||
|
* fichier de configuration
|
||||||
|
* Contient les constantes globales initiales
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hote de la base de données
|
||||||
|
*/
|
||||||
define("DB_HOST", "localhost");
|
define("DB_HOST", "localhost");
|
||||||
|
/**
|
||||||
|
* Utilisateur
|
||||||
|
*/
|
||||||
define("DB_USER", "root");
|
define("DB_USER", "root");
|
||||||
|
/**
|
||||||
|
* Mot de passe
|
||||||
|
*/
|
||||||
define("DB_PASSWORD", "vps@2017GA");
|
define("DB_PASSWORD", "vps@2017GA");
|
||||||
define("DB_DATABASE","iLink_test2");
|
/**
|
||||||
|
* Base de données
|
||||||
|
*/
|
||||||
|
define("DB_DATABASE","iLink_cannary");
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
define("GEOLOCATED_AGENT_ETAT",0);
|
define("GEOLOCATED_AGENT_ETAT",0);
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue