2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								defined ( 'BASEPATH' )  OR  exit ( 'No direct script access allowed' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Created  by  PhpStorm . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  User :  capp 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Date :  29 / 05 / 2018 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Time :  15 : 49 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  Wallet_model  extends  CI_Model  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  __construct () 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> load -> model ( 'nano_health_model' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//wallet
 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    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 );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 14:37:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  $query -> num_rows ()  >  0  ?  $query  :  false ;  
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									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 );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  function  getInfosWalletAgentForHyper ( $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  wallet_agent 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `network_id` = " . $id_network );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-26 14:37:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  $query -> num_rows ()  >  0  ?  $query  :  false ;  
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/** 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ 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);
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/** 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  @ 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 " );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/** 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 *  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."' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                  " );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									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 (){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT networks.name AS network,networks.status AS status,networks.id,countries.name AS country,networks.country_id ,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								       configWallet . id_network  ,  configWallet . type  ,  configWallet . enabled  FROM  `networks` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 		INNER  JOIN  countries  ON  networks . country_id = countries . id  LEFT  JOIN  configWallet  ON  configWallet . id_network  =  networks . id  WHERE  status  =  1 " );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getConfigWallet ( $id_network ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'configWallet'  ,  [ 'id_network'  =>  $id_network ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  verifyConfigWalletInCountry ( $type ,  $country_id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql = ' SELECT  *  FROM  `configWallet`  cw  JOIN  networks  n  ON  cw . id_network  =  n . id  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											WHERE  cw . type  =  ?  AND  n . country_id  =  ? ; '  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $type , $country_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows () > 0  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									public  function  addConfigWallet ( $network_id  ,  $type ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$this -> db -> trans_start (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$existQuery  =  $this -> db -> get_where ( 'configWallet'  ,  [ 'id_network'  =>  $network_id ]); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( $existQuery -> num_rows ()  >  0 ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'id_network' ,  $network_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> update ( 'configWallet' ,  [ 'enabled'  =>  1  ,  'type'  =>  $type ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$query  =  $nhConfigExist  =  $this -> db -> get_where ( 'nh_networks_configs'  ,  [ 'network_id'  =>  $network_id ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( $nhConfigExist -> num_rows ()  ==  0  &&  $type  ==  'ilink_sante' ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$this -> createNanoHealthWalletConfig ( $network_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> trans_complete (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} else { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$query  =  $this -> db -> insert ( 'configWallet'  ,  [ 'id_network'  =>  $network_id ,  'type'  =>  $type ]); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( $query  &&  $type  ==  'ilink_sante' ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$this -> createNanoHealthWalletConfig ( $network_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> trans_complete (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									private  function  createNanoHealthWalletConfig ( $network_id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Creer la config du nano santé
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$configID  =  $this -> nano_health_model -> createConfig ( $network_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> where ( 'id_network' ,  $network_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$this -> db -> update ( 'configWallet' ,  [ 'nh_network_config_id'  =>  $configID ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWallet ( $config_id  ,  $taux_client_r  ,  $taux_client_d ,   $taux_ag_r  ,  $taux_ag_d  ,   $taux_sup_r  ,  $taux_sup_d  ,  $taux_bq_r  ,  $taux_bq_d  ,  $frais_d  ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  ' UPDATE  `configWallet`  SET   `taux_com_client_retrait`  =  ? ,  `taux_com_client_depot`  =  ? ,  `taux_com_ag_retrait`  =  ? ,  `taux_com_ag_depot`  =  ? ,  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        `taux_com_sup_retrait`  =  ?  ,  `taux_com_sup_depot`  =   ? ,   `part_banque_retrait`  =  ? ,  `part_banque_depot`  =  ? ,  `frais_min_banque_depot`  =  ?  WHERE  ( `id`  =  ? ); ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_client_r , $taux_client_d , $taux_ag_r , $taux_ag_d , $taux_sup_r , $taux_sup_d ,  $taux_bq_r  ,  $taux_bq_d  ,  $frais_d  ,  $config_id )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  disableConfigWallet ( $network_id ){ 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-28 14:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " UPDATE `configWallet` SET enabled = 0 AND type = null WHERE `configWallet`.`id_network` = ' " . $network_id . " ' " ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-05 06:34:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									public  function  deleteConfigWallet ( $network_id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " DELETE FROM `configWallet` WHERE `configWallet`.`id_network` = ' " . $network_id . " ' " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getWallet ( $id_agent ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'wallet_agent'  ,  [ 'agent_id'  =>  $id_agent ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  addWallet ( $id_agent ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'networks_agents'  ,  [ 'agent_id'  =>  $id_agent ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if ( $query -> num_rows () > 0 ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$id_networkAgent  =  $query -> first_row () -> id ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$query  =  $this -> db -> insert ( 'wallets'  ,  [ 'id_networkAgent'  =>  $id_networkAgent ]); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} else { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getAgentTransactions ( $id_wallet ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'wallet_transaction'  ,  [ 'id_wallet'  =>  $id_wallet ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getAgentiLinkTransactions ( $id_wallet ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'infos_ilink_transaction'  ,  [ 'id_wallet_ag'  =>  $id_wallet ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getNetworkHyper ( $id_network ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'hyper_infos'  ,  [ 'network_id'  =>  $id_network ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getAllAgentsForNetwork ( $id_network ){ 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> get_where ( 'hyper_infos'  ,  [ 'network_id'  =>  $id_network ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  reinitializeWallet ( $id_wallet ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `wallets` SET `balance_princ` = '0', `balance_com` = '0', `created_date` = ? WHERE (`id` = ?) " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( new  DateTime (), $id_wallet )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Mot de passe du wallet
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getAllActivatedWalletNetworks (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT n.id AS id_network , n.name AS network,n.status AS status,c.name AS country,c.currency_name_fr, c.currency_name_en , c.currency_code, wp.id AS wallet_password FROM networks n
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 												INNER  JOIN  countries_currencies  c  ON  n . country_id = c . id  INNER  JOIN  configWallet  cw  ON  cw . id_network  =  n . id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                                LEFT  JOIN  walletsPassword  wp  ON  wp . network_id  =  n . id  WHERE  status  =  1 ; " );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  addWalletPassword ( $network_id ,  $encrypted_password ,  $salt ,  $email ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `walletsPassword` (`network_id`, `encrypted_password`, `salt`, `email`) VALUES ( ?, ?, ?, ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $network_id ,  $encrypted_password ,  $salt ,  $email )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateWalletPassword ( $wallet_password_id ,  $encrypted_password ,  $salt ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `walletsPassword` SET `encrypted_password` = ? , `salt` = ? WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $encrypted_password ,  $salt ,  $wallet_password_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getWalletPassword ( $network_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT * FROM walletsPassword WHERE network_id = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $network_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getRecharges ( $debut  ,   $fin  ,  $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?   "  AND date BETWEEN ' " . $debut . " ' AND ' " . $fin . " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  infos_recharges 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `network_id` = " . $id_network . $chain );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 11:56:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									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 )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateWalletBalance ( $montant , $wallet_id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `wallets` SET balance_princ = balance_princ + ? WHERE (`id` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $montant , $wallet_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Wallet ilink
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  addPalierConfigWallet ( $type ,  $idConfig ,  $min ,  $max ,  $taux ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `paliersConfigWallet` (`type`, `min`, `max`, `taux`, `idConfig`) VALUES (?,?,?,?,?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $type ,  $min ,  $max ,  $taux ,  $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  addTaxe ( $idConfig ,  $nom ,  $type ,  $valeur ,  $destination ,  $categorie  =  'wallet' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `taxes` (`nom`, `type`, `valeur`, `destination`,`categorie`, `idConfig`) VALUES (?,?,?,?,?,?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $nom ,  $type ,  $valeur ,  $destination ,  $categorie ,  $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updatePalierConfigWallet ( $id ,  $min ,  $max ,  $taux ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `paliersConfigWallet` SET `min` = ? , `max` =  ? , `taux` = ?  WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $min ,  $max ,  $taux ,  $id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getPalierConfigWallet ( $type ,  $idConfig ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `paliersConfigWallet` WHERE (`type` = ?  AND `idConfig` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $type ,  $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getTaxes ( $idConfig ,  $categorie  =  'wallet' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `taxes` WHERE (`idConfig` = ? AND `categorie` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $idConfig ,  $categorie )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getOnePalierConfigWallet ( $id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `paliersConfigWallet` WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $id )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  deletePalierConfigWallet ( $type ,  $idConfig ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " DELETE FROM `paliersConfigWallet` WHERE (`type` = ? AND `idConfig` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $type ,  $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  deleteTaxes ( $idConfig ,  $categorie  =  'wallet' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " DELETE FROM `taxes` WHERE (`idConfig` = ? AND `categorie` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $idConfig ,  $categorie )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_a_s_c ( $taux_ag_s_c ,  $taux_sup_s_c ,  $taux_hyp_s_c ,  $idConfig ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET  `taux_com_ag_envoi_cash` = ?, `taux_com_sup_envoi_cash` = ?, `taux_com_hyp_envoi_cash` = ? WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $taux_ag_s_c ,  $taux_sup_s_c ,  $taux_hyp_s_c ,  $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_u_w_cart ( $taux_u_w_cart , $taux_hyp_s_wallet_cart_ilink , $taux_bq_s_wallet_cart_ilink ,  $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET `taux_com_user_wallet_carte` = ?,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 			  `taux_com_hyp_envoi_wallet_carte_ilink`  =  ? ,  `taux_com_banque_envoi_wallet_carte_ilink`  =  ?  WHERE  ( `id`  =  ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_u_w_cart , $taux_hyp_s_wallet_cart_ilink , $taux_bq_s_wallet_cart_ilink , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_u_c_w ( $taux_u_c_w , $taux_u_c_c , $taux_hyp_r_cart_ilink , $taux_bq_r_cart_ilink  ,  $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET `taux_com_user_carte_wallet` = ?, `taux_com_user_carte_cash` = ?, `taux_com_hyp_retrait_carte_cash_ilink` = ?, `taux_com_banque_retrait_carte_cash_ilink` = ?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 			  WHERE  ( `id`  =  ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_u_c_w , $taux_u_c_c , $taux_hyp_r_cart_ilink , $taux_bq_r_cart_ilink , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_a_r_c ( $taux_ag_r_c , $taux_sup_r_c , $taux_hyp_r_c , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET `taux_com_ag_retrait_cash` = ?, `taux_com_sup_retrait_cash` = ?, `taux_com_hyp_retrait_cash` = ? WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_ag_r_c , $taux_sup_r_c , $taux_hyp_r_c , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_a_r_cart ( $taux_ag_cart_c , $taux_ag_r_cart , $taux_sup_r_cart , $taux_hyp_r_cart , $taux_bq_r_cart  , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET `taux_com_wallet_ag_carte_cash` = ?, `taux_com_ag_retrait_carte_cash` = ?, `taux_com_sup_retrait_carte_cash` = ?, 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												`taux_com_hyp_retrait_carte_cash`  =  ? ,  `taux_com_banque_retrait_carte_cash`  =  ?  WHERE  ( `id`  =  ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_ag_cart_c , $taux_ag_r_cart , $taux_sup_r_cart , $taux_hyp_r_cart ,  $taux_bq_r_cart  , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateConfigWalletIlink_a_s_cc ( $taux_ag_d_c_c , $taux_ag_d_c , $taux_sup_d_c , $taux_hyp_d_c , $taux_bq_d_c  ,  $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `configWallet` SET `taux_com_wallet_ag_envoi_cash_carte` = ?,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 			  `taux_com_ag_depot_cash_carte`  =  ? ,  `taux_com_sup_depot_cash_carte`  =  ? ,  `taux_com_hyp_depot_cash_carte`  =  ? ,  `taux_com_banque_depot_cash_carte`  =  ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 			  WHERE  ( `id`  =  ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $taux_ag_d_c_c ,  $taux_ag_d_c , $taux_sup_d_c , $taux_hyp_d_c , $taux_bq_d_c  , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// La liste des monnaies pour les pays actifs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCurrencies ( $code ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  " SELECT * FROM currencies WHERE id IN(
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													SELECT  idCurrency  FROM  countries  WHERE  id  IN  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 SELECT  distinct  country_id  FROM  networks  WHERE  status  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													)  AND  code  <>  ?  ; " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $code )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//Liste des monnaies pour les pays dont un wallet est actif
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getWalletsCountriesCurrencies ( $code ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  " SELECT * FROM currencies WHERE id IN(
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													SELECT  idCurrency  FROM  countries  WHERE  id  IN  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 SELECT  distinct  c . id  FROM  networks  n  INNER  JOIN  countries_currencies  c  ON  n . country_id = c . id  INNER  JOIN  configWallet  cw  ON  cw . id_network  =  n . id  WHERE  status  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													)  AND  code  <>  ?  ; " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $code )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  insertExchangeRate ( $currency  , $rate ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `exchange_rate` (`target_currency`, `exchange_rate`) VALUES ( ?, ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $currency , $rate )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getExchangeRate ( $currency ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `exchange_rate` WHERE `target_currency` =  ?; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $currency )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  updateExchangeRate ( $currency , $rate ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `exchange_rate` SET `exchange_rate` = ? WHERE (`target_currency` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $currency , $rate )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//Liste des pays dont un wallet est actif
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getWalletsCountries (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  " SELECT id , name , currency_code FROM countries_currencies WHERE id IN (
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 SELECT  distinct  c . id  FROM  networks  n  INNER  JOIN  countries_currencies  c  ON  n . country_id = c . id  INNER  JOIN  configWallet  cw  ON  cw . id_network  =  n . id  WHERE  status  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getActiveCountries (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  " SELECT id , name FROM countries WHERE id IN (
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 SELECT  distinct  n . country_id  FROM  networks  n  WHERE  n . status  =  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCountry ( $id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql =  " SELECT name FROM countries WHERE id =  $id " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  cancelCreditRequest ( $id_demand ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `info_demandeCredits` WHERE `demande_id` =  ?; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_demand )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( $query -> num_rows () > 0 ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$demand  =  $query -> first_row (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  =  " SELECT *  FROM `wallet_agent` WHERE `codeMembre` =  ?; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$query  =  $this -> db -> query ( $sql  ,  array ( $demand -> codeMembre )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$query2  =  $this -> db -> query ( $sql  ,  array ( $demand -> codeParrain )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$result  =  $query -> num_rows () > 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( $result ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$result  = $query2 -> num_rows () > 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if ( $result ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$sql  =  " UPDATE wallets SET balance_princ = ? WHERE (`id` =  ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$montant  =  $demand -> montant ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$montantAgent  =  $query -> first_row () -> balance_princ  -  $montant ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$montantParrain  =  $query2 -> first_row () -> balance_princ  +  $montant ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$this -> db -> query ( $sql  ,  array ( $montantAgent  ,  $query -> first_row () -> wallet_id  )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$this -> db -> query ( $sql  ,  array ( $montantParrain  ,  $query2 -> first_row () -> wallet_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$sql  =  " UPDATE `demandeCredits` SET `status` = '2' WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$this -> db -> query ( $sql  ,  array ( $demand -> demande_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} else { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  insertSimulateur ( $frais  ,  $montant  , $code  ,  $montant_init ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `simulateur` (`com_hyp` , `montant_retrait`, `code` ,`montant` ) VALUES ( ?, ?, ? , ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $frais , $montant , $code , $montant_init )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getSimulateur ( $code ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `simulateur` WHERE `code` =  ?; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $code )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  setSharingRate ( $network_id , $config_id , $rate ,  $url ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `paying_networks` WHERE `id_network` =  ? AND id_configWallet = ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $network_id , $config_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( $query -> num_rows () > 0 ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  =  " UPDATE `paying_networks` SET `taux_partage` =  ? ,`url` =  ? WHERE `id_network` =  ? AND id_configWallet = ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> query ( $sql  ,  array ( $rate ,  $url ,  $network_id , $config_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} else { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  =  " INSERT INTO `paying_networks` (`id_network`, `taux_partage`, `url`, `id_configWallet`) VALUES ( ?, ?, ? ,?); ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> query ( $sql  ,  array ( $network_id , $rate , $url , $config_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getSharingRate ( $id_network  , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT taux_partage , url FROM `paying_networks` WHERE `id_network` =  ? AND id_configWallet = ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_network , $idConfig )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getSharingRateByNetwork ( $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT balance_com FROM `paying_networks` WHERE `id_network` =  ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_network )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  countPayingNetworks ( $id_country  , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT count(id) as total FROM `paying_networks` WHERE `id_network` IN (SELECT distinct n.id  FROM countries c INNER JOIN
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													  networks  n  ON  n . country_id  =  c . id  WHERE   n . status  =  1  AND  c . id  =  ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													)  AND  id_configWallet  =  ?  ; " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_country ,  $idConfig )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getActiveNetworksByCountry ( $country_id  ,  $network_id ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT networks.name , networks.id , configWallet.type FROM `networks` INNER JOIN countries ON networks.country_id=countries.id 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	INNER  JOIN  configWallet  ON  configWallet . id_network  =  networks . id  WHERE  status  =  1  AND  networks . id  <>  $network_id  AND  countries . id  =  $country_id " );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getPayingNetworksByConfigWallet ( $id_config ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT n.name , n.id , cw.type , c.name as country ,c.currency_code, pw.taux_partage as rate , pw.balance_com , pw.balance_compensation, pw.id_configWallet as config_id FROM networks n INNER JOIN countries_currencies c ON n.country_id=c.id 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												INNER  JOIN  configWallet  cw  ON  cw . id_network  =  n . id  INNER  JOIN  paying_networks  pw  ON  pw . id_network  =  n . id  WHERE  pw . id_configWallet  =  $id_config  " );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getNetworkIlinTransactions ( $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  infos_ilink_transaction 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `network_emetteur` =  '".$id_network."' " );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCurrency ( $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT cc.currency_code as code FROM networks n INNER JOIN countries_currencies cc ON cc.id = n.country_id
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  n . id  =  '".$id_network."' " );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( $query -> num_rows () > 0 ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query -> first_row (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} else { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCommissionTransfers ( $debut  ,   $fin  ,  $codeMembre ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?   "  AND date BETWEEN ' " . $debut . " ' AND ' " . $fin . " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  infos_transferts_commission 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `codeParrain` = '".$codeMembre."' " . $chain );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-25 16:28:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCommissionTransfersByNetwork ( $debut  ,   $fin  ,  $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?   "  AND date BETWEEN ' " . $debut . " ' AND ' " . $fin . " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  infos_transferts_commission 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `network_id` = '".$id_network."' " . $chain );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getIlinkTransactionsSup ( $debut  ,   $fin  ,  $codeMembre ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?   "  AND date BETWEEN ' " . $debut . " ' AND ' " . $fin . " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  infos_ilink_transaction 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `code_parrain` = '".$codeMembre."' " . $chain );
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-11 00:14:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getInfosWalletAgentForSuper ( $codeMembre ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT *
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    FROM  wallet_agent 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                                    WHERE  `codeParrain` = '" . $codeMembre . "' " );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  insertRembourssementCompensation ( $montant ,  $id_network ,  $id_config ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT *  FROM `paying_networks` WHERE `id_network` =  ? AND id_configWallet = ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $id_network ,  $id_config )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$montant_init  =  $query -> first_row () -> balance_compensation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  (( $montant_init  -  $montant )  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												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 )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 11:56:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$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 )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getRefunds ( $debut ,  $fin ,  $id_network ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?  "  AND date BETWEEN ' "  .  $debut  .  " ' AND ' "  .  $fin  .  " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT rp.* , n.name as network , cc.name as country , cc.currency_code FROM remboursemment_compensation rp 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												INNER  JOIN  networks  n  ON  n . id  =  id_paying_network  INNER  JOIN  countries_currencies  cc  ON  cc . id  =  n . country_id  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												WHERE  rp . id_network  = "  .  $id_network  .  $chain );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-28 15:44:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Gestion reglementaire
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getRegulationsCountries (){ 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 16:46:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT distinct cc.id , cc.name as country , cc.currency_code,  r.id_country, r.montant_max_jour_national, r.montant_max_hebdo_national, r.montant_max_mensuel_national,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 		r . montant_max_jour_international ,  r . montant_max_hebdo_international ,  r . montant_max_mensuel_international  FROM  networks  n 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-28 15:44:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								INNER  JOIN  countries_currencies  cc  ON  n . country_id =  cc . id  INNER  JOIN  configWallet  cw  ON  cw . id_network  =  n . id  LEFT  JOIN  regulations  r  ON  r . id_country  =  cc . id ; " );
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getRegulationsLimits ( $id_country ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT * FROM regulations WHERE id_country =' "  .  $id_country  .  " ' " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query -> first_row (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 16:46:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  insertRegulationsLimits ( $id_country ,  $max_day_national  ,  $max_week_national  ,  $max_month_national ,  $max_day_international  ,  $max_week_international  ,  $max_month_international ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " INSERT INTO `regulations` (`id_country`, `montant_max_jour_national`, `montant_max_hebdo_national`, `montant_max_mensuel_national`,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									`montant_max_jour_international` ,  `montant_max_hebdo_international` ,  `montant_max_mensuel_international` )  VALUES  ( ? , ? ,  ? ,  ? , ? , ? , ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_country , $max_day_national , $max_week_national , $max_month_national , $max_day_international , $max_week_international , $max_month_international )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-28 15:44:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-05 16:46:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  updateRegulationsLimits ( $id_country ,  $max_day_national  ,  $max_week_national  ,  $max_month_national ,  $max_day_international  ,  $max_week_international  ,  $max_month_international ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `regulations` SET `montant_max_jour_national` = ? , `montant_max_hebdo_national` = ? , `montant_max_mensuel_national` = ?,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 	`montant_max_jour_international`  =  ?  ,  `montant_max_hebdo_international`  =  ?  ,  `montant_max_mensuel_international`  =  ?   WHERE  ( `id_country`  =  ? ); " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $max_day_national , $max_week_national , $max_month_national , $max_day_international , $max_week_international , $max_month_international , $id_country )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-28 15:44:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Operateurs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getAllOperatorsCountries (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT b.id, b.nom as operator_name , bc.adresse as operator_address , bc.code as operator_code , bc.status, c.name as country , c.id as country_id , top.description_fr as type_fr, top.description_en as type_en
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											FROM  operators_countries  bc  INNER  JOIN  operators  b  ON  b . id  =  bc . id_operator  INNER  JOIN  type_operators  top  ON  b . type  =  top . code  INNER  JOIN  countries  c  ON  c . id  =  bc . id_country  " );
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  getAllOperators (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT o.* , top.description_fr ,top.description_en FROM operators o INNER JOIN type_operators top ON o.type = top.code " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  checkIfOperatorAssignationExist ( $id_country , $id_operator ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT * FROM operators_countries WHERE id_country =' " . $id_country . " ' AND id_operator=' " . $id_operator . " ' " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  getOperator ( $id_operator ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT * FROM operators WHERE id=' " . $id_operator . " ' " ); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  updateOperator ( $id_operator , $id_country ,  $name  ,  $address  ,  $code ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " UPDATE `operators` SET `nom` = ? WHERE (`id` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 $this -> db -> query ( $sql  ,  array ( $name , $id_operator )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$sql  =  " UPDATE `operators_countries` SET `adresse` = ? , `code` = ? WHERE (`id_operator` = ? AND `id_country` = ?); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $this -> db -> query ( $sql  ,  array ( $address , $code , $id_operator , $id_country )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  deleteOperatorCountry ( $id_operator ,  $id_country ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " DELETE FROM `operators_countries` WHERE `id_operator` = ? AND  `id_country` = ? " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql ,  array ( $id_operator , $id_country )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 11:56:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									//Obtenir uniquement les operateurs qui sont dans le meme pays que le reseau0
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									public  function  getOperatorsForNetwork ( $id_network ){ 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 11:56:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$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
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-06 17:47:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								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  =  ? " ;
  
						 
					
						
							
								
									
										
										
										
											2020-10-27 10:50:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_network )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-29 19:07:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Reseaux emetteurs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getTransmittingNetwork ( $id_network  , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT * FROM `transmitting_networks` WHERE `id_network` =  ? AND id_configWallet = ? ; " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_network , $idConfig )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  countTransmittiongNetworks ( $id_country  , $idConfig ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$sql  =  " SELECT count(id) as total FROM `transmitting_networks` WHERE `id_network` IN (SELECT distinct n.id  FROM countries c INNER JOIN
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													  networks  n  ON  n . country_id  =  c . id  WHERE   n . status  =  1  AND  c . id  =  ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													)  AND  id_configWallet  =  ?  ; " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( $sql  ,  array ( $id_country ,  $idConfig )); 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-30 11:20:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  $query -> num_rows ()  >  0  ?  $query  :  false  ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getTransmittingNetworksByConfigWallet ( $id_config ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT n.name , n.id , cw.type , c.name as country ,c.currency_code, pw.taux_partage as rate , pw.balance_com , pw.balance_compensation, pw.id_configWallet as config_id FROM networks n INNER JOIN countries_currencies c ON n.country_id=c.id 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												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  ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-29 19:07:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-18 11:56:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// 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' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 15:34:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  payCommissionInCash ( $montant ,  $id_wallet_agent , $id_network ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										try { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> trans_begin (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$datetime  =  $this -> getCurrentTimeByNetworkID ( $id_network ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$walletAgent  =  $this -> db -> get_where ( 'wallets' ,[ 'id'  =>  $id_wallet_agent ]) -> first_row (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Mise à jour du compte
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$sql  =  " UPDATE `wallets` SET balance_com = balance_com - ? WHERE (`id` = ? ); " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> query ( $sql  ,  array ( $montant , $id_wallet_agent )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$data  =  array ( 'amount'  =>  $montant  ,  'initial_commission'  =>  $walletAgent -> balance_com  , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												'final_commission'  =>  $walletAgent -> balance_com  +  $montant ,  'id_wallet_agent'  =>  $id_wallet_agent  ,  'date' =>  $datetime ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										    $this -> db -> insert ( 'commission_payments' ,  $data ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> trans_commit (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} catch  ( Throwable  $e ){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> trans_rollback (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									public  function  getCommissionPayments ( $debut ,  $fin ,  $id_network ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$chain  =  $debut  ?  "  AND date BETWEEN ' "  .  $debut  .  " ' AND ' "  .  $fin  .  " ' "  :  " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$query  =  $this -> db -> query ( " SELECT cp.* , wa.lastname, wa.currency_code FROM commission_payments cp
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												INNER  JOIN  wallet_agent  wa  ON  cp . id_wallet_agent  =  wa . wallet_id  WHERE  wa . network_id  = "  .  $id_network  .  $chain );
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( $query -> num_rows ()  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-09-09 07:27:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}