+ 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 '../init/init.php';
|
||||
|
||||
/**
|
||||
* Cette classe assure la connexion à la base de données et toutes les requetes nécéssaires
|
||||
*/
|
||||
class DataBaseConnector
|
||||
{
|
||||
/**
|
||||
* @var Messenger
|
||||
*/
|
||||
var $messenger;
|
||||
/**
|
||||
* @var false|mysqli Connexion
|
||||
*/
|
||||
var $con;
|
||||
|
||||
/**
|
||||
* DataBaseConnector constructor.
|
||||
* @param bool $isTest
|
||||
*/
|
||||
public function __construct($isTest=false)
|
||||
{
|
||||
|
||||
|
@ -24,10 +39,20 @@ class DataBaseConnector
|
|||
$this->messenger = new Messenger();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
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){
|
||||
$result = mysqli_query($this->con,"SELECT * from publiciteConfig WHERE id_config = '2' AND id_country='$id_country'");
|
||||
$no_of_rows = mysqli_num_rows($result);
|
||||
|
@ -39,6 +64,11 @@ class DataBaseConnector
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste de configuration administrateur
|
||||
* @return array|bool|null
|
||||
*/
|
||||
public function getPasValue(){
|
||||
$result = mysqli_query($this->con,"SELECT * from adminConfig WHERE cle = 'pas_chargement'");
|
||||
$no_of_rows = mysqli_num_rows($result);
|
||||
|
@ -50,6 +80,11 @@ class DataBaseConnector
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phone
|
||||
* @return bool
|
||||
*/
|
||||
public function isPhoneExistedSimple($phone) {
|
||||
// connecting to mysql
|
||||
|
||||
|
@ -63,6 +98,10 @@ class DataBaseConnector
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getNetwork(){
|
||||
$r=mysqli_query($this->con,"select * from networks");
|
||||
|
||||
|
@ -77,6 +116,11 @@ class DataBaseConnector
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phone
|
||||
* @return bool
|
||||
*/
|
||||
public function isPhoneExisted($phone) {
|
||||
$result = mysqli_query($this->con,"SELECT phone from users WHERE phone = '$phone'");
|
||||
$no_of_rows = mysqli_num_rows($result);
|
||||
|
@ -88,7 +132,15 @@ class DataBaseConnector
|
|||
return false;
|
||||
}
|
||||
}
|
||||
public function isPhoneExistedInCategory($phone,$category=null,$phoneTransaction=null){
|
||||
|
||||
/**
|
||||
* 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){
|
||||
|
||||
$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'");
|
||||
if($result) {
|
||||
|
@ -101,6 +153,10 @@ class DataBaseConnector
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phone
|
||||
* @return bool
|
||||
*/
|
||||
public function checknumberValidity($phone){
|
||||
try {
|
||||
return true;//$this->messenger->checkPhoneExist($phone);
|
||||
|
@ -108,6 +164,11 @@ class DataBaseConnector
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $codemembre
|
||||
* @return bool
|
||||
*/
|
||||
public function isMemberCodeExisted($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)
|
||||
{
|
||||
|
||||
|
@ -148,6 +213,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
* @return array|bool|null
|
||||
*/
|
||||
public function getAgentWithCodeMembre($code){
|
||||
$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'");
|
||||
|
@ -156,6 +226,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
return $membre;
|
||||
}else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAgentNetworkByCode($code){
|
||||
$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'");
|
||||
|
@ -164,6 +239,11 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
return $membre;
|
||||
}else return ['error'=>mysqli_error($this->con)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return array|bool|null
|
||||
*/
|
||||
public function getAgentById($id){
|
||||
$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,
|
||||
|
@ -193,7 +273,21 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
}
|
||||
}
|
||||
|
||||
public function storeUser($fname, $lname, $email, $phone, $password, $network, $member,$latitude, $longitude,$town,$phoneTransaction)
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
//on verifie si y a un agent qui utilise ce code
|
||||
if(isset($town->id)){
|
||||
|
@ -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()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $country
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getAllPointInCountry($country){
|
||||
$etat=1;
|
||||
$si=1;
|
||||
|
@ -268,7 +369,7 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
mysqli_stmt_execute($result);
|
||||
$r = mysqli_stmt_get_result($result);
|
||||
$rows=[];
|
||||
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC )) {
|
||||
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC )) {
|
||||
$rows[]=$row;
|
||||
}
|
||||
|
||||
|
@ -292,6 +393,10 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @return array|bool
|
||||
*/
|
||||
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));
|
||||
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){
|
||||
$result=mysqli_query($this->con,"SELECT category,etat FROM codeGenerer where code_membre = '$codeparrain'");
|
||||
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()
|
||||
{
|
||||
$result=[];
|
||||
|
@ -322,7 +434,12 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function getSuperviseurNetwork($codeparrain,$user_id){
|
||||
/**
|
||||
* @param $codeparrain
|
||||
* @param $user_id
|
||||
* @return array
|
||||
*/
|
||||
public function getSuperviseurNetwork($codeparrain, $user_id){
|
||||
$self=$this->getAgentByCodeMembre($codeparrain);
|
||||
$catparrain=$self['category'];
|
||||
$catchild=($catparrain=='hyper')?'super':($catparrain=='super'?'geolocated':null);
|
||||
|
@ -354,7 +471,13 @@ INNER JOIN networks nt ON na.network_id=nt.id INNER JOIN agents ag ON ag.id=na.a
|
|||
return $re;
|
||||
}
|
||||
|
||||
public function getPointsNetwork($network,$user_id){
|
||||
/**
|
||||
* 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){
|
||||
$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
|
||||
FROM agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN
|
||||
|
@ -371,7 +494,14 @@ codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.net
|
|||
}
|
||||
}
|
||||
|
||||
private function getUserByPhoneAndPassword($phone, $password,$table) {
|
||||
/**
|
||||
* 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) {
|
||||
$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
|
||||
$no_of_rows = mysqli_num_rows($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) {
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phone
|
||||
* @param $encrypted_password
|
||||
* @param $salt
|
||||
* @return bool
|
||||
*/
|
||||
public function forgotPasswordSimple($phone, $encrypted_password, $salt)
|
||||
{
|
||||
$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){
|
||||
$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(){
|
||||
echo "request";
|
||||
$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)];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $salt
|
||||
* @param $password
|
||||
* @return string
|
||||
*/
|
||||
private function checkhashSSHA($salt, $password) {
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $phone
|
||||
* @param $password
|
||||
* @return array|null
|
||||
*/
|
||||
public function getUserByPhoneAndPasswordGeolocated($phone, $password) {
|
||||
// connecting to mysql
|
||||
$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){
|
||||
$listIdmemberParrain=mysqli_query($this->con, "SELECT ag.uid as uid,ag.firstname AS firstname,
|
||||
ag.lastname AS lastname,
|
||||
|
@ -543,7 +704,14 @@ na.id as networkAgentId,
|
|||
|
||||
}
|
||||
|
||||
public function storeDemandeCredit($phone,$montant,$code){
|
||||
/**
|
||||
* Enregistre une demande de credit
|
||||
* @param $phone
|
||||
* @param $montant
|
||||
* @param $code
|
||||
* @return array|bool
|
||||
*/
|
||||
public function storeDemandeCredit($phone, $montant, $code){
|
||||
$agent=$this->getAgentWithCodeMembre($code);
|
||||
if($agent) {
|
||||
$idag=$agent['agentId'];
|
||||
|
@ -556,7 +724,21 @@ na.id as networkAgentId,
|
|||
|
||||
}
|
||||
|
||||
private function createAgent($fname, $lname, $email, $phone, $password, $network, $member, $latitude, $longitude, $town,$phoneTransaction)
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
|
||||
$resultFreeCode = mysqli_query($this->con, "SELECT id,code_membre,category,code_parrain from codeGenerer cg WHERE code_membre='$member' ");
|
||||
|
@ -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)
|
||||
{
|
||||
$code=null;
|
||||
|
@ -666,6 +853,10 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
|
|||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $agent
|
||||
* @return array
|
||||
*/
|
||||
private function adddemandeAdhesionAgent($agent)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$uuid = uniqid('', true);
|
||||
|
@ -725,7 +925,13 @@ salt,validation_code, active,network_id) VALUES
|
|||
|
||||
}
|
||||
|
||||
public function generateNetworkAgent($phone, $code_parrain,$agent)
|
||||
/**
|
||||
* @param $phone
|
||||
* @param string $code_parrain
|
||||
* @param $agent
|
||||
* @return array
|
||||
*/
|
||||
public function generateNetworkAgent($phone, $code_parrain, $agent)
|
||||
{
|
||||
$code=$this->generateValideCode($code_parrain,"geolocated");
|
||||
$resParrain=mysqli_query($this->con,"SELECT * 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 towns tw ON ag.town_id=tw.id INNER JOIN countries ct ON tw.country_id=ct.id WHERE cg.code_membre='$code_parrain'");
|
||||
|
@ -778,6 +984,10 @@ salt,validation_code, active,network_id) VALUES
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $validation_code
|
||||
* @return array|bool|null
|
||||
*/
|
||||
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");
|
||||
|
@ -797,6 +1007,11 @@ salt,validation_code, active,network_id) VALUES
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $idAgent
|
||||
* @param $idNetworkAgent
|
||||
* @return array
|
||||
*/
|
||||
public function assignNetworkAgent($idAgent, $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)];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
|
||||
$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){
|
||||
$rows=[];
|
||||
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)
|
||||
{
|
||||
$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){
|
||||
$rows=[];
|
||||
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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$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,7 +1134,15 @@ salt,validation_code, active,network_id) VALUES
|
|||
}
|
||||
}
|
||||
|
||||
public function getPointInDistance($reseau,$position, $distance,$page)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$mlat=$position->latitude;
|
||||
$mlong=$position->longitude;
|
||||
|
@ -913,4 +1164,8 @@ ag.adresse,
|
|||
return $li;
|
||||
}else return mysqli_error($this->con);
|
||||
}
|
||||
|
||||
public function vir(){
|
||||
|
||||
}
|
||||
}
|
|
@ -8,15 +8,34 @@
|
|||
|
||||
|
||||
include 'DataBaseConnector.php';
|
||||
|
||||
/**
|
||||
* Cette classe matérialise la resource qui execute une requete
|
||||
*/
|
||||
class Requester
|
||||
{
|
||||
|
||||
//TODO ajouter la comparaison partiel de la ville query with la ville
|
||||
// Step 3: instantiate a new Twilio Rest Client
|
||||
/**
|
||||
* @var Messenger Le messenger de TWILIO
|
||||
*/
|
||||
var $messenger;
|
||||
/**
|
||||
* @var DataBaseConnector Le connecteur de base de données
|
||||
*/
|
||||
var $db;
|
||||
/**
|
||||
* @var int ID de l'utilisateur
|
||||
*/
|
||||
var $user_id;
|
||||
/**
|
||||
* @var mixed le message
|
||||
*/
|
||||
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"];
|
||||
/**
|
||||
* Requester constructor.
|
||||
|
@ -54,16 +73,33 @@ class Requester
|
|||
$this->messenger->sendMail();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la config administrateur sans chargement
|
||||
* @return false|string
|
||||
*/
|
||||
public function getPasValue(){
|
||||
$pasObject=$this->db->getPasValue();
|
||||
if($pasObject)return json_encode(['pas'=>$pasObject]);
|
||||
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){
|
||||
$pasObject=$this->db->getPubValue($id_country);
|
||||
if($pasObject)return json_encode(['pub'=>$pasObject]);
|
||||
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){
|
||||
$agent=$this->db->getAgentWithCodeMembre($code);
|
||||
if($agent){
|
||||
|
@ -73,6 +109,13 @@ class Requester
|
|||
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)
|
||||
{
|
||||
// check for user
|
||||
|
@ -87,6 +130,12 @@ class Requester
|
|||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne toutes les infos sur un agent
|
||||
* @param string $code code agent
|
||||
* @return false|string
|
||||
*/
|
||||
public function getAgentInfoByCode($code){
|
||||
$codes=$this->getChildCode($code);
|
||||
if(isset($codes["child"])){
|
||||
|
@ -94,6 +143,12 @@ class Requester
|
|||
}
|
||||
return json_encode($codes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les reseaux d'un superviseur
|
||||
* @param string $codesuperviseur
|
||||
* @return array
|
||||
*/
|
||||
public function getSuperviseurNetwork($codesuperviseur)
|
||||
{
|
||||
$point = $this->db->getSuperviseurNetwork($codesuperviseur, $this->user_id);
|
||||
|
@ -109,6 +164,12 @@ class Requester
|
|||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recupere la liste des coordonnées des points agents d'une ville
|
||||
* @param $country
|
||||
* @return array
|
||||
*/
|
||||
public function getAllCountryPoint($country)
|
||||
{
|
||||
$point = $this->db->getAllPointInCountry($country);
|
||||
|
@ -121,6 +182,12 @@ class Requester
|
|||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrouve le mot de passe oublié d'un agent
|
||||
* @param string $number
|
||||
* @return array
|
||||
*/
|
||||
public function recoverPasswordAgent($number)
|
||||
{
|
||||
if ($this->db->isPhoneExistedSimple($number)) {
|
||||
|
@ -165,6 +232,12 @@ class Requester
|
|||
}else
|
||||
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)
|
||||
{
|
||||
if ($this->db->isPhoneExistedSimple($number)) {
|
||||
|
@ -209,10 +282,24 @@ class Requester
|
|||
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)
|
||||
{
|
||||
mail($email, $subject, $message, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Envoi un message
|
||||
* @param string $message
|
||||
* @param string $number
|
||||
*/
|
||||
private function sendMessage($message, $number)
|
||||
{
|
||||
$sms = $this->client->account->messages->create(
|
||||
|
@ -228,11 +315,26 @@ class Requester
|
|||
)
|
||||
);
|
||||
}
|
||||
public function getPointAroundKm($reseau,$position, $distance,$page)
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$list=$this->db->getPointInDistance($reseau,$position,$distance,$page);
|
||||
return json_encode($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne tous les points agents d'un réseau
|
||||
* @param $network
|
||||
* @return false|string
|
||||
*/
|
||||
public function getNetworkPoint($network)
|
||||
{
|
||||
$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]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
|
||||
|
@ -263,6 +374,12 @@ class Requester
|
|||
return $miles;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inscrire un agent
|
||||
* @param $request Requete d'inscription
|
||||
* @return false|string
|
||||
*/
|
||||
public function registerGeolocated($request)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
$user = $this->db->getUserByPhoneAndPasswordSimple($phone, $password);
|
||||
|
@ -350,6 +479,13 @@ class Requester
|
|||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connecte un agent (superviseur ou hyperviseur)
|
||||
* @param string $phone
|
||||
* @param string $password
|
||||
* @return array|null
|
||||
*/
|
||||
public function loginAgent($phone, $password)
|
||||
{
|
||||
$user = $this->db->getUserByPhoneAndPasswordGeolocated($phone, $password);
|
||||
|
@ -364,6 +500,12 @@ class Requester
|
|||
return $user;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des demandes d'adhesion d'un superviseur
|
||||
* @param string $codeparrain
|
||||
* @return array|string
|
||||
*/
|
||||
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'");
|
||||
|
@ -393,6 +535,12 @@ class Requester
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la categorie des "fils" d'un menbre
|
||||
* @param string $codeparrain
|
||||
* @return array|null
|
||||
*/
|
||||
public function getChildCode($codeparrain)
|
||||
{
|
||||
$r=$this->db->getCategoryAgent($codeparrain);
|
||||
|
@ -408,6 +556,11 @@ class Requester
|
|||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Corrige un erreur d'accent sur les champs firstname de la table users_simple
|
||||
* @return array|bool|mysqli_result
|
||||
*/
|
||||
public function updateWrongPoint()
|
||||
{
|
||||
$result=[];
|
||||
|
@ -420,7 +573,15 @@ class Requester
|
|||
|
||||
return $result;
|
||||
}
|
||||
public function storeCreditAsk($phone,$montant,$code)
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$result=$this->db->storeDemandeCredit($phone,$montant,$code);
|
||||
if ($result) {
|
||||
|
@ -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)
|
||||
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
||||
|
@ -514,7 +689,15 @@ class Requester
|
|||
|
||||
}
|
||||
|
||||
public function validateAgent($phone, $code_validation,$mbre_reseau=null,$mr_sous_reseau=null)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if(isset($phone) && isset($code_validation)){
|
||||
$res=mysqli_query($this->db->con,"SELECT na.id as agentId,ag.id as agId,cg.category as category,cg.code_membre as code_membre,cg.code_parrain AS code_parrain FROM agents ag INNER JOIN networks_agents na on ag.id=na.agent_id inner JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE (na.phone='$phone' OR na.transactionNumber='$phone') AND na.validation_code='$code_validation' ORDER BY agId DESC LIMIT 1");
|
||||
|
@ -624,7 +807,13 @@ class Requester
|
|||
|
||||
}
|
||||
|
||||
public function activeSupervisorAdhesion($code,$phone)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$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,
|
||||
na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN demandeAdhesion ds ON 1=1 INNER JOIN codeGenerer cg ON na.codeGenerer_id=cg.id WHERE ds.phone='$phone' AND cg.code_membre='$code'");
|
||||
|
@ -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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if ($this->db->isPhoneExistedInCategory($phone)) {
|
||||
|
@ -752,7 +952,14 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
|||
|
||||
}
|
||||
|
||||
public function assignNetworkToAgent($agentId, $code_parrain,$phone)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$agent = $this->db->getAgentById($agentId);
|
||||
if ($agent) {
|
||||
|
@ -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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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']);
|
||||
} }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $phone
|
||||
* @return false|string
|
||||
*/
|
||||
public function treatDemand($phone)
|
||||
{
|
||||
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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
|
||||
|
@ -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){
|
||||
$res=mysqli_query($this->db->con,"SELECT * FROM wallets where id_networkAgent=$idAgent");
|
||||
if($res){
|
||||
|
@ -949,7 +1203,17 @@ na.id as agent_id,ds.id,cg.code_membre as code_membre ,ds.id as demande_id FROM
|
|||
}
|
||||
return null;
|
||||
}
|
||||
function createRequestRetrait($numCarte,$cvv,$montant,$taxe,$idAgent){
|
||||
|
||||
/**
|
||||
* 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){
|
||||
$agent=$this->getAgentWallet($idAgent);
|
||||
$agentCommission=floatval($taxe*0.8);
|
||||
$newBalance=floatval($agent['balance_princ'])+floatval($montant);
|
||||
|
@ -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");
|
||||
}else{
|
||||
echo mysqli_error($this->db->con);
|
||||
|
||||
}
|
||||
}else{
|
||||
echo mysqli_error($this->db->con);
|
||||
|
@ -970,4 +1233,16 @@ function createRequestRetrait($numCarte,$cvv,$montant,$taxe,$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
|
||||
/*fichier de configuration test */
|
||||
/**
|
||||
* fichier de configuration
|
||||
* Contient les constantes globales initiales
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hote de la base de données
|
||||
*/
|
||||
define("DB_HOST", "localhost");
|
||||
/**
|
||||
* Utilisateur
|
||||
*/
|
||||
define("DB_USER", "root");
|
||||
/**
|
||||
* Mot de passe
|
||||
*/
|
||||
define("DB_PASSWORD", "vps@2017GA");
|
||||
define("DB_DATABASE","iLink_test2");
|
||||
/**
|
||||
* Base de données
|
||||
*/
|
||||
define("DB_DATABASE","iLink_cannary");
|
||||
/**
|
||||
*
|
||||
*/
|
||||
define("GEOLOCATED_AGENT_ETAT",0);
|
||||
?>
|
Loading…
Reference in New Issue