From 5427e66ac1717d9a4707f76f044e9edfadc5538a Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Tue, 19 Apr 2022 12:50:41 +0100 Subject: [PATCH] Fix update of users infos --- application/controllers/Admin_dash.php | 3 + application/controllers/Hyperviseur_dash.php | 3 + application/models/User_model.php | 20 +- application/models/Wallet_model.php | 207 +------------------ 4 files changed, 16 insertions(+), 217 deletions(-) diff --git a/application/controllers/Admin_dash.php b/application/controllers/Admin_dash.php index fe90e882..cb003cb9 100755 --- a/application/controllers/Admin_dash.php +++ b/application/controllers/Admin_dash.php @@ -357,6 +357,9 @@ class Admin_dash extends CI_Controller if($res){ $result = $res->result(); foreach ($result as $network){ + if($network->type == 'ilink_sante'){ + continue; + } $res = $this->wallet_model->getSharingRate($network->id , $data['idConfig']); $res2 = $this->wallet_model->getTransmittingNetwork($network->id , $data['idConfig']); if($res){ diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index 6a647511..88eab668 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -1361,6 +1361,9 @@ class Hyperviseur_dash extends CI_Controller if($res){ $result = $res->result(); foreach ($result as $network){ + if($network->type == 'ilink_sante'){ + continue; + } $res = $this->wallet_model->getSharingRate($network->id , $data['idConfig']); $res2 = $this->wallet_model->getTransmittingNetwork($network->id , $data['idConfig']); if($res){ diff --git a/application/models/User_model.php b/application/models/User_model.php index cbf22b46..1e3ed3f6 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -1781,10 +1781,8 @@ class User_model extends CI_Model * @return mixed */ public function update_user_infos($nom, $adresse, $email, $phone, $id){ - $query = $this->db->query("UPDATE `users` SET `lastname`='".$nom."',`phone`='".$phone."',`email`='".$email."',`adresse`='".$adresse."' WHERE users.id=".$id); - $sql = "UPDATE `users` SET `lastname`='".$nom."',`phone`='".$phone."',`email`='".$email."',`adresse`='".$adresse."' WHERE users.id=".$id; - - return $query; + $this->db->where('id', $id); + return $this->db->update('users', ['lastname' => $nom,'phone' => $phone , 'email' => $email , 'adresse' => $adresse]); } /** @@ -1800,16 +1798,16 @@ class User_model extends CI_Model public function update_geolocated_infos($nom, $adresse, $email, $id_agent, $transac, $phone, $id_netAg){ $this->db->trans_begin(); - $this->db->query("UPDATE `agents` SET `lastname`='".$nom."',`email`='".$email."',`adresse`='".$adresse."' WHERE `id`=".$id_agent); - $this->db->query("UPDATE `networks_agents` SET `phone`='".$phone."',`transactionNumber`='".$transac."' WHERE `id`=".$id_netAg); + $this->db->where('id', $id_agent); + $this->db->update('agents', ['lastname' => $nom, 'email' => $email , 'adresse' => $adresse]); + $this->db->where('id', $id_netAg); + $this->db->update('networks_agents', ['phone' => $phone, 'transactionNumber' => $transac]); + $this->db->trans_complete(); - if ($this->db->trans_status() === FALSE) - { + if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return false; - } - else - { + } else { $this->db->trans_commit(); return true; } diff --git a/application/models/Wallet_model.php b/application/models/Wallet_model.php index 827696f3..a01ac8ed 100644 --- a/application/models/Wallet_model.php +++ b/application/models/Wallet_model.php @@ -13,214 +13,9 @@ class Wallet_model extends CI_Model public function __construct() { + parent::__construct(); $this->load->model('nano_health_model'); } - - //wallet - public function getActiveNetwork(){ - $query = $this->db->query("SELECT networks.id,networks.name,countries.name AS country - FROM networks - INNER JOIN countries ON networks.country_id=countries.id - WHERE `status`=1"); - if($query->num_rows()>0){ - return $query; - }else{ - return null; - } - } - public function getTaux($id_network){ - $query = $this->db->query("SELECT * - FROM configWallet - WHERE `id_network`=".$id_network); - if($query->num_rows()>0){ - return $query; - }else{ - return null; - } - } - - public function getNetworkDetails($id_network){ - $query = $this->db->query("SELECT n.name AS network , c.name AS country , c.currency_name_fr , c.currency_code , c.currency_name_en FROM networks n INNER JOIN countries_currencies c ON n.country_id = c.id WHERE n.id = ".$id_network); - if($query->num_rows()>0){ - return $query; - }else{ - return null; - } - } - - public function getTransactions($debut , $fin , $id_network){ - $chain = $debut ? " AND date_created BETWEEN '".$debut."' AND '".$fin."'" : ""; - $query = $this->db->query("SELECT * - FROM infos_transaction - WHERE `network_id`=".$id_network.$chain); - return $query->num_rows() > 0 ? $query : false; - } - - public function getTransactionsSup($debut , $fin , $codeMembre){ - $chain = $debut ? " AND date_created BETWEEN '".$debut."' AND '".$fin."'" : ""; - $query = $this->db->query("SELECT * - FROM infos_transaction - WHERE `codeParrain`='".$codeMembre."'".$chain); - return $query->num_rows() > 0 ? $query : false ; - } - - public function getInfosWalletAgentForHyper($id_network){ - $query = $this->db->query("SELECT * - FROM wallet_agent - WHERE `network_id`=".$id_network); - return $query->num_rows() > 0 ? $query : false; - } - - /** - * @param $where_clause - * @return bool - */ - public function get_user($where_clause){ - $query = $this->db->query("SELECT agents.lastname, agents.adresse,agents.email,agents.date_created,agents.id AS userID, - codeGenerer.category, - networks.name AS network_name,towns.name AS town_name, - codeGenerer.code_parrain AS parrain,codeGenerer.code_membre AS code, - networks_agents.id AS networkAgent_id,networks_agents.phone,networks_agents.transactionNumber AS transac - FROM agents - INNER JOIN networks_agents ON agents.id=networks_agents.agent_id - INNER JOIN codeGenerer ON codeGenerer.id=networks_agents.codeGenerer_id - INNER JOIN networks ON networks.id =networks_agents.network_id - INNER JOIN towns ON towns.id=agents.town_id - ".$where_clause); - $statement = "SELECT agents.lastname, agents.adresse,agents.email,agents.date_created,agents.id AS userID, - codeGenerer.category, - networks.name AS network_name,towns.name AS town_name, - codeGenerer.code_parrain AS parrain,codeGenerer.code_membre AS code, - networks_agents.id AS networkAgent_id,networks_agents.phone,networks_agents.transactionNumber AS transac - FROM agents - INNER JOIN networks_agents ON agents.id=networks_agents.agent_id - INNER JOIN codeGenerer ON codeGenerer.id=networks_agents.codeGenerer_id - INNER JOIN networks ON networks.id =networks_agents.network_id - INNER JOIN towns ON towns.id=agents.town_id - ".$where_clause; - //var_dump($statement); - return $query->num_rows() > 0 ? $query : false ; - } - - /** - * @param $phone - * @param $name - * @return |null - */ - public function get_simple_user($phone, $name){ - $query = $this->db->query("SELECT users.id AS id_user,users.active AS etat,users.lastname,users.phone,users.email,users.adresse,users.date_created, - networks.name AS network,countries.name AS country - FROM users - INNER JOIN networks ON networks.id=users.network_id - INNER JOIN countries ON countries.id=networks.country_id - WHERE phone LIKE '".$phone."%' AND lastname LIKE '".$name."%'"); - - if($query->num_rows()>0){ - return $query; - }else{ - return null; - } - } - - /** - * @param $nom - * @param $adresse - * @param $email - * @param $phone - * @param int $id - * @return mixed - */ - public function update_user_infos($nom, $adresse, $email, $phone, $id){ - $query = $this->db->query("UPDATE `users` SET `lastname`='".$nom."',`phone`='".$phone."',`email`='".$email."',`adresse`='".$adresse."' WHERE users.id=".$id); - $sql = "UPDATE `users` SET `lastname`='".$nom."',`phone`='".$phone."',`email`='".$email."',`adresse`='".$adresse."' WHERE users.id=".$id; - - return $query; - } - - /** - * @param $nom - * @param $adresse - * @param $email - * @param int $id_agent - * @param $transac - * @param $phone - * @param int $id_netAg - * @return bool - */ - public function update_geolocated_infos($nom, $adresse, $email, $id_agent, $transac, $phone, $id_netAg){ - $this->db->trans_begin(); - - $this->db->query("UPDATE `agents` SET `lastname`='".$nom."',`email`='".$email."',`adresse`='".$adresse."' WHERE `id`=".$id_agent); - $this->db->query("UPDATE `networks_agents` SET `phone`='".$phone."',`transactionNumber`='".$transac."' WHERE `id`=".$id_netAg); - $this->db->trans_complete(); - if ($this->db->trans_status() === FALSE) - { - $this->db->trans_rollback(); - return false; - } - else - { - $this->db->trans_commit(); - return true; - } - } - - - /** - * @return bool - */ - public function getPubCountries(){ - $query = $this->db->query("SELECT countries.id AS id_country,countries.name AS pays,publiciteConfig.id,publiciteConfig.date_update AS maj ,publiciteConfig.partenariat,publiciteConfig.valeur_bool AS etat - FROM countries - INNER JOIN towns ON countries.id = towns.country_id - LEFT JOIN publiciteConfig ON countries.id=publiciteConfig.id_country AND publiciteConfig.id_config=2 - WHERE towns.status=1 - GROUP BY countries.id"); - return $query->num_rows() > 0 ? $query : false ; - } - - /** - * Met a jour l'etat de la publicite - * @param int $id ID de la configuration - * @param $newState Nouvel etat - * @return mixed - */ - public function updateStatePub($id, $newState){ - $query = $this->db->query("UPDATE publiciteConfig SET date_update = NOW(),valeur_bool = ".$newState." WHERE id =".$id); - return $query; - } - - /** - * Ajoute une nouvelle ligne de publicite - * @param int $id_country ID du pays - * @return mixed - */ - public function createPubRow($id_country){ - $query = $this->db->query("INSERT INTO publiciteConfig(id_config,id_country, valeur_bool) VALUE (2,".$id_country.",1)"); - return $query; - } - - public function getSuperNameAndCodeForSup($codeSup){ - - $query = $this->db->query("SELECT child.lastname AS lastname, child.code_membre AS member_code - FROM super_infos AS child - INNER JOIN super_infos AS dad - ON child.code_parrain='".$codeSup."' - WHERE child.category='geolocated' AND dad.category='super' AND dad.code_membre='".$codeSup."' - "); - - return $query->num_rows() > 0 ? $query : false ; - } - - public function nameOfCurrentGeolocatedUser_forSuper($geolocatedUser_memberCode){ - $query = $this->db->query("SELECT lastname FROM `super_infos` WHERE `code_membre`='".$geolocatedUser_memberCode."' "); - if($query->num_rows()>0){ - return $query->row()->lastname; - }else{ - return null; - } - } - // Wallet public function getAllActivatedNetworks(){