diff --git a/application/controllers/Hyperviseur_dash.php b/application/controllers/Hyperviseur_dash.php index dfb63f0a..6163101e 100755 --- a/application/controllers/Hyperviseur_dash.php +++ b/application/controllers/Hyperviseur_dash.php @@ -622,7 +622,7 @@ class Hyperviseur_dash extends CI_Controller if ($encrypted_password == $hash) { $this->wallet_model->updateWalletBalance($montant, $wallet_id); - $res = $this->wallet_model->addWalletRecharge($montant, $wallet_id); + $res = $this->wallet_model->addWalletRecharge($montant, $wallet_id , $this->session->userdata('network_id')); $code = $res ? '200' : '500'; } else { $code = '400'; diff --git a/application/models/Wallet_model.php b/application/models/Wallet_model.php index 42139381..c13facb4 100644 --- a/application/models/Wallet_model.php +++ b/application/models/Wallet_model.php @@ -401,9 +401,10 @@ class Wallet_model extends CI_Model } } - public function addWalletRecharge($montant,$wallet_id){ - $sql = "INSERT INTO `wallet_recharge` (`montant`, `wallet_id`) VALUES (?, ?);"; - $query = $this->db->query($sql , array($montant,$wallet_id)); + public function addWalletRecharge($montant,$wallet_id , $id_network){ + $datetime = $this->getCurrentTimeByNetworkID($id_network); + $sql = "INSERT INTO `wallet_recharge` (`montant`, `wallet_id`, `date`) VALUES (?, ?, ?);"; + $query = $this->db->query($sql , array($montant,$wallet_id,$datetime)); return $query; } @@ -806,8 +807,9 @@ class Wallet_model extends CI_Model return false; $sql = "UPDATE `paying_networks` SET balance_compensation = ? WHERE `id_network` = ? AND id_configWallet = ?;"; $this->db->query($sql, array($montant_init - $montant, $id_network, $id_config)); - $sql = "INSERT INTO `remboursemment_compensation` (`montant` , `montant_restant`,`id_paying_network` , `id_network`) VALUES ( ?, ?, ? ,?);"; - $this->db->query($sql, array($montant, $montant_init - $montant, $id_network, $this->session->userdata('network_id'))); + $datetime = $this->getCurrentTimeByNetworkID($id_network); + $sql = "INSERT INTO `remboursemment_compensation` (`montant` , `montant_restant`,`id_paying_network` , `id_network` , `date`) VALUES ( ?, ?, ? ,?, ?);"; + $this->db->query($sql, array($montant, $montant_init - $montant, $id_network, $this->session->userdata('network_id'),$datetime)); return true; } return false; @@ -898,8 +900,9 @@ INNER JOIN countries_currencies cc ON n.country_id= cc.id INNER JOIN configWalle return $query; } + //Obtenir uniquement les operateurs qui sont dans le meme pays que le reseau0 public function getOperatorsForNetwork($id_network){ - $sql = "SELECT bc.id, b.nom as operator_name , bc.adresse as operator_address, bc.code as operator_code , c.name as country , c.id as country_id , nb.id_network , top.description_fr as type_fr, top.description_en as type_en + $sql = "SELECT b.type , n.country_id as network_country_id , bc.id, b.nom as operator_name , bc.adresse as operator_address, bc.code as operator_code , c.name as country , c.id as country_id , nb.id_network , top.description_fr as type_fr, top.description_en as type_en FROM networks n CROSS JOIN operators_countries bc INNER JOIN operators b ON b.id = bc.id_operator INNER JOIN countries c ON c.id = bc.id_country INNER JOIN type_operators top ON b.type = top.code LEFT JOIn networks_operators nb ON nb.id_operator_country = bc.id AND nb.id_network = n.id WHERE bc.status = 1 AND n.id = ?"; $query = $this->db->query($sql , array($id_network)); @@ -927,4 +930,18 @@ LEFT JOIn networks_operators nb ON nb.id_operator_country = bc.id AND nb.id_netw INNER JOIN configWallet cw ON cw.id_network = n.id INNER JOIN transmitting_networks pw ON pw.id_network = n.id WHERE pw.id_configWallet = $id_config "); return $query->num_rows() > 0 ? $query : false ; } + + // Obtenir l'heure en fonction de l'id du reseau + function getCurrentTimeByNetworkID($id_network) + { + $query= $this->db->query("SELECT code_country FROM countries c INNER JOIN networks n on n.country_id = c.id WHERE n.id = '$id_network'"); + if ($query->num_rows() > 0) { + $country_code = isset($query->first_row()->code_country) ? $query->first_row()->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'); + } + } } diff --git a/application/views/gestion_operateurs_hyp.php b/application/views/gestion_operateurs_hyp.php index 3703f457..d9a88e85 100755 --- a/application/views/gestion_operateurs_hyp.php +++ b/application/views/gestion_operateurs_hyp.php @@ -70,6 +70,9 @@
result() as $row) { + // Seuls les operateurs bancaires peuvent appartenir à des pays etrangers + if($row->type != 'bank' && ($row->country_id != $row->network_country_id)) + continue; $num ++; $type = $this->session->userdata('site_lang') === 'french' ? $row->type_fr : $row->type_en; echo "lang->line('Demandes traitées'); ?>
+lang->line('accepted_demands'); ?>