+ Timezone of dates is now providing by user

This commit is contained in:
Djery-Tom 2020-11-13 19:47:26 +01:00
parent 45c54a1155
commit 2379d3efae
2 changed files with 51 additions and 10 deletions

View File

@ -233,7 +233,7 @@ na.validation_code as validation_code,ag.id as agentId,na.solde AS balance,na.et
*/
public function getAgentWithCodeMembre($code){
$listIdmemberParrain=mysqli_query($this->con,
"SELECT na.id as agentId,na.transactionNumber as transactionNumber,ag.email as email, ag.lastname, ag.firstname , cc.currency_code,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 , ne.name as reseau from agents ag RIGHT JOIN networks_agents na on ag.id=na.agent_id RIGHT JOIN codeGenerer cg ON cg.id=na.codeGenerer_id
"SELECT na.id as agentId,na.transactionNumber as transactionNumber,ag.email as email, ag.lastname, ag.firstname , cc.code_country , cc.currency_code,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 , ne.name as reseau from agents ag RIGHT JOIN networks_agents na on ag.id=na.agent_id RIGHT JOIN codeGenerer cg ON cg.id=na.codeGenerer_id
INNER JOIN towns t ON ag.town_id = t.id INNER JOIN countries_currencies cc ON cc.id = t.country_id INNER JOIN networks ne ON ne.id = na.network_id WHERE cg.code_membre='$code'");
if($listIdmemberParrain){
$membre=mysqli_fetch_array($listIdmemberParrain,MYSQLI_ASSOC);
@ -757,7 +757,8 @@ na.id as networkAgentId,
$agent=$this->getAgentWithCodeMembre($code);
if($agent) {
$idag=$agent['agentId'];
$q = mysqli_query($this->con, "INSERT INTO demandeCredits(network_agent_id,montant,status) VALUES('$idag','$montant','0')");
$datetime = $this->getCurrentTimeByUserID($agent['code_country']);
$q = mysqli_query($this->con, "INSERT INTO demandeCredits(network_agent_id,montant,status,date_creation) VALUES('$idag','$montant','0',$datetime)");
$id = mysqli_insert_id($this->con);
if ($q) {
return ['success' => 1, "agent" => $agent, "id" => $id,
@ -807,9 +808,10 @@ na.id as networkAgentId,
if(isset($town->id)) {
$townid = $town->id;
$datetime = $this->getCurrentTimeByNetworkID($network->id);
$agentCreateResult = mysqli_prepare($this->con, "INSERT INTO agents(uid,adresse,
lastname,email,longitude,latitude
,balance,encrypted_password,salt,active,date_created,town_id) VALUES (?,?,?,?,?,?,?,?,?,?,NOW(),?)");
,balance,encrypted_password,salt,active,date_created,town_id) VALUES (?,?,?,?,?,?,?,?,?,?,'$datetime',?)");
mysqli_stmt_bind_param($agentCreateResult,'ssssddissii' ,$uuid , $fname,$lname,$email,$longitude,$latitude,$balance,$encrypted_password,$salt,$etat, $townid);
$agentCreateResult = mysqli_stmt_execute($agentCreateResult);
// mysqli_stmt_get_result($agentCreateResult);
@ -904,13 +906,15 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
private function adddemandeAdhesionAgent($agent)
{
$codeparrain=$agent['code_parrain'];
$resParrain=mysqli_query($this->con,"SELECT na.id as agentId FROM agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id WHERE cg.code_membre='$codeparrain'");
$resParrain=mysqli_query($this->con,"SELECT na.id as agentId , c.code_country 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 n on n.id = na.network_id INNER JOIN countries c ON c.id = n.country_id WHERE cg.code_membre='$codeparrain'");
if($resParrain){
$parrain=mysqli_fetch_array($resParrain,MYSQLI_ASSOC);
$agentId=$parrain['agentId'];
if($agentId){
$phone=$agent['phone'];
$resDemande=mysqli_query($this->con,"INSERT INTO demandeAdhesion(phone,networks_agent_id) VALUES ('$phone','$agentId')");
$datetime = $this->getCurrentTimeByCountryCode($agent['code_country']);
$resDemande=mysqli_query($this->con,"INSERT INTO demandeAdhesion(phone,networks_agent_id,date_creation) VALUES ('$phone','$agentId','$datetime')");
if($resDemande){
return ['success'=>1];
}else{
@ -954,11 +958,12 @@ VALUES('$network->id','$agent_id','$balance','$etat','$code_id','$phone','$valid
$codeCorrect=$rowcount<0;
}while($codeCorrect);
$networkid=$network->id;
$datetime = $this->getCurrentTimeByNetworkID($networkid);
$result = mysqli_query($this->con,
"INSERT INTO users(uid, adresse,lastname, phone, email,user_code, solde, encrypted_password,
salt,validation_code, active,network_id) VALUES
salt,validation_code, active,network_id , date_created , date_modified) VALUES
('$uuid', '$firstname', '$lastname', '$phone','$email','$user_code','$balance','$encrypted_password', '$salt',
'$validation_code','0','$networkid')");
'$validation_code','0','$networkid','$datetime','$datetime')");
// check for successful store
if ($result) {
// get user details
@ -1249,4 +1254,39 @@ ag.adresse,
}else return false;
}else return false;
}
// Obtenir l'heure en fonction du pays de l'utilisateur
public function getCurrentTimeByUserID($id_user){
$result = mysqli_query($this->con,"SELECT code_country FROM countries c INNER JOIN networks n on n.country_id = c.id INNER JOIN users u ON u.network_id = n.id WHERE u.id = '$id_user'");
if($result){
$array=mysqli_fetch_array($result,MYSQLI_ASSOC);
$country_code = isset($array['code_country']) ? $array['code_country'] : 'GA';
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
$date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime();
return $date->format('Y-m-d H:i:s');
}else{
return date('Y-m-d H:i:s');
}
}
// Obtenir l'heure en fonction du code du pays pays de l'utilisateur
public function getCurrentTimeByCountryCode($country_code){
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
$date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime();
return $date->format('Y-m-d H:i:s');
}
// Obtenir l'heure en fonction de l'id du reseau
public function getCurrentTimeByNetworkID($id_network){
$result = mysqli_query($this->con,"SELECT code_country FROM countries c INNER JOIN networks n on n.country_id = c.id WHERE n.id = '$id_network'");
if($result){
$array=mysqli_fetch_array($result,MYSQLI_ASSOC);
$country_code = isset($array['code_country']) ? $array['code_country'] : 'GA';
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
$date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime();
return $date->format('Y-m-d H:i:s');
}else{
return date('Y-m-d H:i:s');
}
}
}

View File

@ -876,14 +876,15 @@ class Requester
*/
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'");
$idsUser=mysqli_query($this->db->con,"SELECT c.code_country , 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 networks n on n.id = na.network_id INNER JOIN countries c ON c.id = n.country_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'");
if($idsUser){
$idsusr=mysqli_fetch_array($idsUser,MYSQLI_ASSOC);
$idAgent=$idsusr['agent_id'];
$demandeId=$idsusr['demande_id'];
$code_membre=$idsusr['code_membre'];
$udateDemande=mysqli_query($this->db->con,"UPDATE demandeAdhesion SET etat='1' , date_modified = CURRENT_TIMESTAMP WHERE id='$demandeId'");
$datetime = $this->db->getCurrentTimeByCountryCode($idsusr['code_country']);
$udateDemande=mysqli_query($this->db->con,"UPDATE demandeAdhesion SET etat='1' , date_modified = '$datetime' WHERE id='$demandeId'");
if($udateDemande){
$user=$idsusr;
$validation = $user["validation_code"];