2020-03-23 17:03:36 +00:00
< ? php
2022-03-28 23:50:56 +00:00
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
2020-09-28 15:44:45 +00:00
2020-05-01 09:30:08 +00:00
use Spatie\Async\Pool ;
2020-03-23 17:03:36 +00:00
class Gestion extends CI_Controller
{
2020-09-09 07:27:25 +00:00
public function __construct ()
2020-04-17 15:28:27 +00:00
{
2020-09-09 07:27:25 +00:00
parent :: __construct ();
$this -> load -> model ( 'wallet_model' );
$this -> load -> model ( 'nano_credit_model' );
2021-02-25 08:41:02 +00:00
$this -> load -> model ( 'nano_health_model' );
2020-04-17 15:28:27 +00:00
}
public function index ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$data [ 'list_villes' ] = $this -> user_model -> getAllVilles ();
$data [ 'pays' ] = $this -> user_model -> getAllPays ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " villes " ;
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_villes' );
$this -> load -> view ( 'footer' );
}
}
public function activer ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$villes = $this -> input -> post ( 'villes' );
$max = sizeof ( $villes );
$number_success = 0 ;
for ( $i = 0 ; $i < $max ; $i ++ ) {
$res = $this -> user_model -> changeVilleStatut ( $villes [ $i ], 1 );
if ( $res == true ) {
$number_success ++ ;
}
}
if ( $number_success == $max ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function update ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id_country = $this -> input -> post ( 'id_country' );
$id_town = $this -> input -> post ( 'id_town' );
$town = $this -> input -> post ( 'town' );
$res = $this -> user_model -> updateVille ( $id_country , $id_town , $town );
if ( $res == true ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function activer_desactiver ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$aVilles = $this -> input -> post ( 'aVilles' );
$maxA = sizeof ( $aVilles );
$number_successA = 0 ;
$dVilles = $this -> input -> post ( 'dVilles' );
$maxD = sizeof ( $dVilles );
$number_successD = 0 ;
$this -> db -> trans_begin ();
for ( $i = 0 ; $i < $maxD ; $i ++ ) {
$res = $this -> user_model -> changeVilleStatut ( $dVilles [ $i ], 0 );
if ( $res == true ) {
$number_successD ++ ;
}
}
for ( $i = 0 ; $i < $maxA ; $i ++ ) {
$res = $this -> user_model -> changeVilleStatut ( $aVilles [ $i ], 1 );
if ( $res == true ) {
$number_successA ++ ;
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
public function desactiver ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$villes = $this -> input -> post ( 'villes' );
$max = sizeof ( $villes );
$number_success = 0 ;
for ( $i = 0 ; $i < $max ; $i ++ ) {
$res = $this -> user_model -> changeVilleStatut ( $villes [ $i ], 0 );
if ( $res == true ) {
$number_success ++ ;
}
}
if ( $number_success == $max ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function suppress ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$villes = $this -> input -> post ( 'ville' );
$res = $this -> user_model -> deleteVille ( $villes );
if ( $res = true ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function ajout ()
{
if ( $this -> input -> post ( 'pays' ) && $this -> input -> post ( 'ville' )) {
$ville = $this -> input -> post ( 'ville' );
$id_pays = $this -> input -> post ( 'pays' );
$stat = 0 ;
$data = array ( 'name' => $ville , 'country_id' => $id_pays , 'status' => $stat );
$query = $this -> db -> insert ( 'towns' , $data );
if ( $query ) {
$data [ 'alert' ] = " ok " ;
$data [ 'success' ] = " ok " ;
$data [ 'message' ] = " La ville " . $ville . " a bien été ajouté! " ;
$data [ 'active' ] = " villes " ;
$data [ 'list_villes' ] = $this -> user_model -> getAllVilles ();
$data [ 'pays' ] = $this -> user_model -> getAllPays ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_villes' );
$this -> load -> view ( 'footer' );
} else {
$data [ 'alert' ] = " ok " ;
$data [ 'success' ] = " error " ;
$data [ 'message' ] = " Une erreur s'est produite " ;
$data [ 'active' ] = " villes " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'list_villes' ] = $this -> user_model -> getAllVilles ();
$data [ 'pays' ] = $this -> user_model -> getAllPays ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_villes' );
$this -> load -> view ( 'footer' );
}
}
}
public function networks ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
2020-10-27 10:50:41 +00:00
// $data['list_villes'] = $this->user_model->getAllVilles();
2020-04-17 15:28:27 +00:00
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " networks " ;
$data [ 'networks' ] = $this -> user_model -> getAllNetworksNames ();
$data [ 'assigned_networks' ] = $this -> user_model -> getAllAssignedNetworks ();
//wallet
2020-05-05 08:25:12 +00:00
// $data['networks'] = $this->user_model->getActiveNetwork();
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_networks' );
$this -> load -> view ( 'footer' );
}
}
public function creat_network ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$network = $this -> input -> post ( 'new_network' );
$data = array ( 'name' => $network );
$query = $this -> db -> insert ( 'networks' , $data );
if ( $query ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function assignation ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$network = $this -> input -> post ( 'network' );
$existe = 0 ;
$this -> db -> trans_begin ();
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'id_country' ] as $country ) {
2020-04-17 15:28:27 +00:00
$res = $this -> user_model -> checkIfAssignationExiste ( $country , $network );
if ( $res == false ) {
$data = array ( 'country_id' => $country , 'name' => $network );
$this -> db -> insert ( 'networks' , $data );
} else {
$existe = $existe + 1 ;
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} elseif ( $existe > 0 ) {
$this -> db -> trans_commit ();
echo json_encode ( " existe " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
public function update_network ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$old_network = $this -> input -> post ( 'old_name' );
$new_network = $this -> input -> post ( 'new_network' );
$res = $this -> user_model -> updateNetwork ( $old_network , $new_network );
if ( $res == true ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function change_status_network ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$activations = $this -> input -> post ( 'activations' );
$desactivation = $this -> input -> post ( 'desactivations' );
$this -> db -> trans_begin ();
if ( ! empty ( $_POST [ 'activations' ])) {
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'activations' ] as $network ) {
2020-04-17 15:28:27 +00:00
$data = array ( 'status' => 1 );
$this -> db -> where ( 'id' , $network );
$this -> db -> update ( 'networks' , $data );
}
}
if ( ! empty ( $_POST [ 'desactivations' ])) {
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'desactivations' ] as $network ) {
2020-04-17 15:28:27 +00:00
$data = array ( 'status' => 0 );
$this -> db -> where ( 'id' , $network );
$this -> db -> update ( 'networks' , $data );
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
public function admin ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$data [ 'list_admin' ] = $this -> user_model -> getAllAdmin ();
$data [ 'list_villes' ] = $this -> user_model -> getAllVilles ();
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " admin " ;
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_admin' );
$this -> load -> view ( 'footer' );
}
}
public function create_admin ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$category = 1 ;
$firstname = $this -> input -> post ( 'prenom' );
$lastname = $this -> input -> post ( 'nom' );
$email = $this -> input -> post ( 'email' );
$emailExist = $this -> user_model -> isEmailExist ( $email );
if ( $emailExist == false ) {
$phone = $this -> input -> post ( 'contact' );
$phoneExist = $this -> user_model -> isPhoneExist ( $phone );
if ( $phoneExist == false ) {
$adresse = $this -> input -> post ( 'adresse' );
$country = $this -> input -> post ( 'country' );
$token = null ;
do {
$token = bin2hex ( openssl_random_pseudo_bytes ( 16 ));
$tokenExist = $this -> user_model -> getToken ( $token );
} while ( $tokenExist == true );
$data = array ( 'firstname' => $firstname , 'lastname' => $lastname , 'email' => $email , 'phone' => $phone , 'adresse' => $adresse , 'country' => $country , 'category' => $category , 'token' => $token );
$query = $this -> db -> insert ( 'admin' , $data );
if ( $query ) {
2021-10-14 14:33:02 +00:00
$link = base_url ( " Admin_password/?token= " . $token );
2020-04-17 15:28:27 +00:00
$this -> load -> library ( 'email' );
$this -> email -> from ( 'noreply@ilink-app.com' , 'iLink World' );
$this -> email -> to ( $email );
$this -> email -> subject ( $this -> lang -> line ( " Confirmation de création d'un compte administrateur " ));
$this -> email -> message ( $firstname . ' ' . $lastname . ' ' . $this -> lang -> line ( " votre compte administrateur a bien été créé. Veuillez suivre ce lien pour configurer votre mot de passe. " ) . ' ' . $link );
$this -> email -> send ();
echo json_encode ( " completed " );
} else {
echo json_encode ( $this -> lang -> line ( " Une erreur s'est produite " ));
}
} else {
echo json_encode ( $this -> lang -> line ( " Le numéro de téléphone entré est déjà utilisé " ));
}
} else {
echo json_encode ( $this -> lang -> line ( " L'email entré est déjà utilisé " ));
}
}
}
}
public function modif_admin ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id = $this -> input -> post ( 'id' );
$firstname = $this -> input -> post ( 'prenom' );
$lastname = $this -> input -> post ( 'nom' );
$email = $this -> input -> post ( 'email' );
$phone = $this -> input -> post ( 'contact' );
$adresse = $this -> input -> post ( 'adresse' );
$country = $this -> input -> post ( 'country' );
$category = $this -> input -> post ( 'category' );
$res = $this -> user_model -> updateAdmin ( $id , $firstname , $lastname , $email , $phone , $adresse , $country , $category );
if ( $res ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( $this -> lang -> line ( " Une erreur s'est produite " ));
}
}
}
}
public function delete_admin ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id = $this -> input -> post ( 'id' );
$res = $this -> user_model -> deleteAdmin ( $id );
if ( $res ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( $this -> lang -> line ( " Une erreur s'est produite " ));
}
}
}
}
public function codes ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$data [ 'list_villes' ] = $this -> user_model -> getAllVilles ();
$data [ 'pays' ] = $this -> user_model -> getAllPays ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " codes-hyper " ;
$data [ 'list' ] = $this -> user_model -> getGeneratedHyperCodes ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'codeg' );
$this -> load -> view ( 'footer' );
}
}
public function generateCode ()
{
if ( $this -> input -> post ( 'c' ) && $this -> input -> post ( 'a' )) {
$number = intval ( $this -> input -> post ( 'c' ));
$member_code = $this -> input -> post ( 'a' );
if ( $number > 0 ) {
for ( $i = 0 ; $i < $number ; $i ++ ) {
$code = $this -> randomString ();
// $data = array('code_parrain' => $member_code, 'code_membre' => $code, 'etat' => 0, 'category' => 'hyper');
$data = array ( 'code_parrain' => $code , 'code_membre' => $code , 'etat' => 0 , 'category' => 'hyper' );
$query = $this -> db -> insert ( 'codeGenerer' , $data );
}
}
$data [ 'alert' ] = " ok " ;
$data [ 'success' ] = " ok " ;
$data [ 'message' ] = " $number codes have been added! " ;
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'list' ] = $this -> user_model -> getGeneratedHyperCodes ();
2021-01-25 09:51:05 +00:00
$data [ 'active' ] = " codes-hyper " ;
2020-04-17 15:28:27 +00:00
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'codeg' );
$this -> load -> view ( 'footer' );
} else {
$data [ 'alert' ] = " ok " ;
$data [ 'success' ] = " " ;
$data [ 'active' ] = " members " ;
$data [ 'message' ] = " Can't add codes! " ;
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'hyper' ] = $this -> user_model -> getAllHyper ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'ville' ] = $this -> user_model -> getVilleNetworkByHyper ( $data [ 'hyper' ] -> first_row () -> code_membre );
$data [ 'list' ] = $this -> user_model -> getGeneratedHyperCodes ();
$data [ 'active' ] = " codes " ;
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'codeg' );
$this -> load -> view ( 'footer' );
}
}
private function randomString ( $length = 10 )
{
2022-03-28 23:50:56 +00:00
do {
2021-05-24 07:40:09 +00:00
$str = " " ;
$characters = array_merge ( range ( 'A' , 'Z' ), range ( 'a' , 'z' ), range ( '0' , '9' ));
$max = count ( $characters ) - 1 ;
for ( $i = 0 ; $i < $length ; $i ++ ) {
$rand = mt_rand ( 0 , $max );
$str .= $characters [ $rand ];
}
2022-03-28 23:50:56 +00:00
$q = $this -> db -> get_where ( 'codeGenerer' , [ 'code_membre' => $str ]);
} while ( $q -> num_rows () != 0 );
2020-04-17 15:28:27 +00:00
2021-05-24 07:40:09 +00:00
return $str ;
2020-04-17 15:28:27 +00:00
}
public function geolocalisation ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'villes' ] = $this -> user_model -> getVillesByPays ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'active_ville_name' ] = $data [ 'villes' ] -> first_row () -> name ;
$data [ 'active_ville_id' ] = $data [ 'villes' ] -> first_row () -> id ;
$data [ 'agent' ] = $this -> user_model -> getAgentsFromCountry ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'networks' ] = $this -> user_model -> getNetworks ( $data [ 'pays' ] -> first_row () -> id );
2021-01-25 09:51:05 +00:00
$data [ 'current_agent' ] = $data [ 'agent' ] ? $data [ 'agent' ] -> first_row () -> lastname : null ;
2020-04-17 15:28:27 +00:00
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " geoloc " ;
$number_geolocalisation = array ();
$network_geolocalisation = array ();
$count = 0 ;
2022-03-28 23:50:56 +00:00
if ( $data [ 'networks' ]) {
2021-01-25 09:51:05 +00:00
foreach ( $data [ 'networks' ] -> result () as $row ) {
$number_geolocalisation [ $count ] = $this -> user_model -> getPointGeolocalised ( $row -> id , $data [ 'current_agent' ]);
$network_geolocalisation [ $count ] = $row -> name ;
$count ++ ;
}
2020-04-17 15:28:27 +00:00
}
$data [ " number_geolocalisation " ] = $number_geolocalisation ;
$data [ " network_geolocalisation " ] = $network_geolocalisation ;
$data [ " total " ] = $count ;
$data [ 'assigned_networks' ] = $this -> user_model -> getAllAssignedNetworks ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_geolocalisation' );
$this -> load -> view ( 'footer' );
}
}
public function infos_geolocalisation ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$pays = $this -> input -> post ( 'pays' );
$ville = $this -> input -> post ( 'ville' );
$lastname = $this -> input -> post ( 'agent' );
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'villes' ] = $this -> user_model -> getVillesByPays ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'active_ville_name' ] = $data [ 'villes' ] -> first_row () -> name ;
$data [ 'active_ville_id' ] = $data [ 'villes' ] -> first_row () -> id ;
$data [ 'agent' ] = $this -> user_model -> getAgentsFromCountry ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'networks' ] = $this -> user_model -> getNetworks ( $pays );
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " geoloc " ;
$number_geolocalisation = array ();
$network_geolocalisation = array ();
$count = 0 ;
2022-03-28 23:50:56 +00:00
if ( $data [ 'networks' ]) {
2021-01-25 09:51:05 +00:00
foreach ( $data [ 'networks' ] -> result () as $row ) {
$number_geolocalisation [ $count ] = $this -> user_model -> getPointGeolocalised ( $row -> id , $lastname );
$network_geolocalisation [ $count ] = $row -> name ;
$count ++ ;
}
2020-04-17 15:28:27 +00:00
}
$data [ 'current_agent' ] = $lastname ;
$data [ " number_geolocalisation " ] = $number_geolocalisation ;
$data [ " network_geolocalisation " ] = $network_geolocalisation ;
$data [ " total " ] = $count ;
$data [ 'assigned_networks' ] = $this -> user_model -> getAllAssignedNetworks ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_geolocalisation' );
$this -> load -> view ( 'footer' );
}
}
}
public function getVilleByPays ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
redirect ( 'index.php' , $data );
} else {
if ( $this -> input -> is_ajax_request ()) {
$ajaxhyp = $this -> user_model -> getVillesByPays ( $this -> input -> post ( 'pays' ));
echo json_encode ( $ajaxhyp -> result_array ());
}
}
}
public function getAgentByVilles ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
redirect ( 'index.php' , $data );
} else {
if ( $this -> input -> is_ajax_request ()) {
$ajaxhyp = $this -> user_model -> getAgentsFromCountry ( $this -> input -> post ( 'id_country' ));
echo json_encode ( $ajaxhyp -> result_array ());
}
}
}
public function campagne ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$debut = date ( 'Y-m-d H:i:s' , strtotime ( $this -> user_model -> getMostOldDateCreationAgent ()));
$fin = date ( " Y-m-d H:i:s " );
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$pays = $data [ 'pays' ] -> first_row () -> id ;
if ( ! empty ( $_POST )) {
$debut = $this -> input -> post ( 'date-debut' );
$fin = $this -> input -> post ( 'date-fin' );
$pays = $this -> input -> post ( 'pays' );
}
$data [ 'debut' ] = $debut ;
$data [ 'fin' ] = $fin ;
$data [ 'villes' ] = $this -> user_model -> getVillesByPays ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'active_ville_name' ] = $data [ 'villes' ] -> first_row () -> name ;
$data [ 'active_ville_id' ] = $data [ 'villes' ] -> first_row () -> id ;
$data [ 'agent' ] = $this -> user_model -> getAgentsFromCountry ( $pays );
$data [ 'networks' ] = $this -> user_model -> getNetworks ( $pays );
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " campagne " ;
$agent [][] = null ;
$geo_correct [][] = null ;
$number_geolocalisation [][] = null ;
$network_geolocalisation [][] = null ;
$number_correct [][] = null ;
$count = 0 ;
$countA = 0 ;
$total = 0 ;
$network_count = 0 ;
$total_physique = 0 ;
$contact_correct = 0 ;
$networks_compte [] = null ;
$networks_name [] = null ;
2022-04-19 10:38:29 +00:00
if ( $data [ 'agent' ]) {
2022-03-28 23:50:56 +00:00
foreach ( $data [ 'agent' ] -> result () as $row1 ) {
2020-04-17 15:28:27 +00:00
if ( ! strstr ( $row1 -> lastname , " Super - " ) and ! strstr ( $row1 -> lastname , " Airtel " )) {
$totalGeo = 0 ;
$totalGeoCorrect = 0 ;
$agent [ $countA ][ 0 ] = $row1 -> lastname ;
2022-03-28 23:50:56 +00:00
foreach ( $data [ 'networks' ] -> result () as $row2 ) {
2020-04-17 15:28:27 +00:00
$number_geolocalisation [ $countA ][ $count ] = $this -> user_model -> getPointGeolocalisedByDate ( $row2 -> id , $row1 -> lastname , $debut , $fin );
$number_correct [ $countA ][ $count ] = $this -> user_model -> getCorrectPointGeolocalisedByDate ( $row2 -> id , $row1 -> lastname , $debut , $fin );
$network_geolocalisation [ $countA ][ $count ] = $row2 -> name ;
$totalGeo = $totalGeo + $number_geolocalisation [ $countA ][ $count ];
$totalGeoCorrect = $totalGeoCorrect + $number_correct [ $countA ][ $count ];
$count ++ ;
}
$agent [ $countA ][ 1 ] = $totalGeo ;
$agent [ $countA ][ 2 ] = $this -> user_model -> getPhysicalPointBySupervisor ( $debut , $fin , $row1 -> lastname );
$total_physique = $total_physique + $agent [ $countA ][ 2 ];
$geo_correct [ $countA ][ 1 ] = $totalGeoCorrect ;
$total = $total + $totalGeo ;
$contact_correct = $contact_correct + $totalGeoCorrect ;
$countA ++ ;
}
}
}
2022-03-28 23:50:56 +00:00
foreach ( $data [ 'networks' ] -> result () as $row ) {
2020-04-17 15:28:27 +00:00
$networks_compte [ $network_count ] = $this -> user_model -> getPointGeolocalisedByNetwork ( $row -> id , $debut , $fin );
$networks_name [ $network_count ] = $row -> name ;
$network_count ++ ;
}
$data [ " networks_compte " ] = $networks_compte ;
$data [ " networks_name " ] = $networks_name ;
$data [ " network_count " ] = $network_count ;
$data [ " total_physique " ] = $total_physique ;
$data [ 'geo_correct' ] = $geo_correct ;
$data [ 'contact_correct' ] = $total ;
if ( $pays == 78 ) {
$data [ 'contact_correct' ] = $contact_correct ;
}
$data [ " agents " ] = $agent ;
$data [ " total_points " ] = $total ;
$data [ " countA " ] = $countA ;
2021-01-25 09:51:05 +00:00
$data [ 'current_agent' ] = $data [ 'agent' ] ? $data [ 'agent' ] -> first_row () -> lastname : null ;
2020-04-17 15:28:27 +00:00
$data [ " number_geolocalisation " ] = $number_geolocalisation ;
$data [ " network_geolocalisation " ] = $network_geolocalisation ;
$data [ " total " ] = $count ;
$data [ 'assigned_networks' ] = $this -> user_model -> getAllAssignedNetworks ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_campagne' );
$this -> load -> view ( 'footer' );
}
}
public function redirect_info_agent ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_GET )) {
$lastname = $this -> input -> get ( 'agent' );
$debut = $this -> input -> get ( 'debut' );
$fin = $this -> input -> get ( 'fin' );
$id_country = $this -> user_model -> getAgentNetwork ( $lastname );
$data [ 'pays' ] = $this -> user_model -> getAllCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'villes' ] = $this -> user_model -> getVillesByPays ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'active_ville_name' ] = $data [ 'villes' ] -> first_row () -> name ;
$data [ 'active_ville_id' ] = $data [ 'villes' ] -> first_row () -> id ;
$data [ 'agent' ] = $this -> user_model -> getAgentsFromCountry ( $data [ 'pays' ] -> first_row () -> id );
$data [ 'networks' ] = $this -> user_model -> getNetworks ( $id_country );
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " geoloc " ;
$number_geolocalisation = array ();
$network_geolocalisation = array ();
$count = 0 ;
2022-03-28 23:50:56 +00:00
foreach ( $data [ 'networks' ] -> result () as $row ) {
2020-04-17 15:28:27 +00:00
$number_geolocalisation [ $count ] = $this -> user_model -> getPointGeolocalisedByDate ( $row -> id , $lastname , $debut , $fin );
$network_geolocalisation [ $count ] = $row -> name ;
$count ++ ;
}
$data [ 'current_agent' ] = $lastname ;
$data [ " number_geolocalisation " ] = $number_geolocalisation ;
$data [ " network_geolocalisation " ] = $network_geolocalisation ;
$data [ " total " ] = $count ;
$data [ 'assigned_networks' ] = $this -> user_model -> getAllAssignedNetworks ();
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_geolocalisation' );
$this -> load -> view ( 'footer' );
}
}
}
public function map ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$data [ 'positions' ] = $this -> user_model -> getAllpositionsForWorld ();
$data [ 'latitude' ] = 0 ;
$data [ 'longitude' ] = 0 ;
$data [ 'lastname' ] = $this -> session -> userdata ( 'lastname' );
$data [ 'active' ] = " map " ;
$data [ 'code_parrain' ] = $this -> session -> userdata ( 'code_parrain' );
$data [ 'alert' ] = " " ;
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_map' );
$this -> load -> view ( 'footer' );
}
}
public function game ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$pays = 1 ;
if ( ! empty ( $_POST )) {
$pays = $this -> input -> post ( 'pays' );
$pays_name = $this -> user_model -> getNameCountry ( $pays );
$this -> session -> set_userdata ( 'current_game_country' , $pays );
$this -> session -> set_userdata ( 'current_game_country_name' , $pays_name );
} elseif ( ! empty ( $this -> session -> userdata ( 'current_game_country' ))) {
$pays = $this -> session -> userdata ( 'current_game_country' );
$pays_name = $this -> session -> userdata ( 'current_game_country_name' );
}
$max = 999999 ;
$data [ 'paliers' ] = $this -> user_model -> getPaliers ();
$data [ 'pays' ] = $this -> user_model -> getAllGameCountries ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'q1' ] = $this -> user_model -> getQuota ( 1 );
$data [ 'q2' ] = $this -> user_model -> getQuota ( 2 );
$data [ 'q3' ] = $this -> user_model -> getQuota ( 3 );
$data [ 'q4' ] = $this -> user_model -> getQuota ( 4 );
2022-03-28 23:50:56 +00:00
$data [ 'list' ] = $this -> user_model -> getMembers ( $pays , $data [ 'q1' ]);
2020-04-17 15:28:27 +00:00
$data [ 'quota1' ] = $this -> user_model -> getCoutForQuota ( $pays , $data [ 'q1' ], $data [ 'q2' ]);
$data [ 'quota2' ] = $this -> user_model -> getCoutForQuota ( $pays , $data [ 'q2' ], $data [ 'q3' ]);
$data [ 'quota3' ] = $this -> user_model -> getCoutForQuota ( $pays , $data [ 'q3' ], $data [ 'q4' ]);
$data [ 'quota4' ] = $this -> user_model -> getCoutForQuota ( $pays , $data [ 'q4' ], $max );
$data [ 'lastname' ] = $this -> session -> userdata ( 'lastname' );
$data [ 'active' ] = " game " ;
$data [ 'code_parrain' ] = $this -> session -> userdata ( 'code_parrain' );
$data [ 'alert' ] = " " ;
2020-05-05 08:25:12 +00:00
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'game' );
$this -> load -> view ( 'footer' );
}
}
public function activerGame ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$pays = $this -> input -> post ( 'pays' );
$max = sizeof ( $pays );
$number_success = 0 ;
for ( $i = 0 ; $i < $max ; $i ++ ) {
$checkContryExist = $this -> user_model -> checkCountryGameExist ( $pays [ $i ]);
if ( $checkContryExist == true ) {
$res = $this -> user_model -> activeGameOnCountry ( $pays [ $i ], 1 );
} else {
$add = $this -> user_model -> addContryToGame ( $pays [ $i ]);
if ( $add == true ) {
$res = $this -> user_model -> activeGameOnCountry ( $pays [ $i ], 1 );
} else {
echo json_encode ( " error " );
}
}
if ( $res == true ) {
$number_success ++ ;
}
}
if ( $number_success == $max ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function desactiverGame ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$pays = $this -> input -> post ( 'pays' );
$max = sizeof ( $pays );
$number_success = 0 ;
for ( $i = 0 ; $i < $max ; $i ++ ) {
$res = $this -> user_model -> activeGameOnCountry ( $pays [ $i ], 0 );
if ( $res == true ) {
$number_success ++ ;
}
}
if ( $number_success == $max ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function activer_desactiverGame ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first ! " ;
$this -> load -> view ( 'login' , $data );
} else {
if ( isset ( $_POST )) {
$apays = $this -> input -> post ( 'apays' );
$maxA = sizeof ( $apays );
$number_successA = 0 ;
$dpays = $this -> input -> post ( 'dpays' );
$maxD = sizeof ( $dpays );
$number_successD = 0 ;
$this -> db -> trans_begin ();
for ( $i = 0 ; $i < $maxD ; $i ++ ) {
$res = $this -> user_model -> activeGameOnCountry ( $dpays [ $i ], 0 );
if ( $res == true ) {
$number_successD ++ ;
}
}
for ( $i = 0 ; $i < $maxA ; $i ++ ) {
$checkContryExist = $this -> user_model -> checkCountryGameExist ( $apays [ $i ]);
if ( $checkContryExist == true ) {
$res = $this -> user_model -> activeGameOnCountry ( $apays [ $i ], 1 );
} else {
$add = $this -> user_model -> addContryToGame ( $apays [ $i ]);
if ( $add == true ) {
$res = $this -> user_model -> activeGameOnCountry ( $apays [ $i ], 1 );
} else {
echo json_encode ( " error " );
}
}
if ( $res == true ) {
$number_successA ++ ;
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
public function modifierPalier ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$n1 = $this -> input -> post ( 'n1' );
$n2 = $this -> input -> post ( 'n2' );
$n3 = $this -> input -> post ( 'n3' );
$n4 = $this -> input -> post ( 'n4' );
$max = 4 ;
$number_success = 0 ;
$res1 = $this -> user_model -> modifPalier ( $n1 , 1 );
if ( $res1 == true ) {
$number_success ++ ;
$res2 = $this -> user_model -> modifPalier ( $n2 , 2 );
if ( $res2 == true ) {
$number_success ++ ;
$res3 = $this -> user_model -> modifPalier ( $n3 , 3 );
if ( $res3 ) {
$number_success ++ ;
$res4 = $this -> user_model -> modifPalier ( $n4 , 4 );
if ( $res4 == true ) {
$number_success ++ ;
} else {
echo json_encode ( " error " );
}
} else {
echo json_encode ( " error " );
}
} else {
echo json_encode ( " error " );
}
} else {
echo json_encode ( " error " );
}
if ( $number_success == $max ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
public function change_country ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first ! " ;
$this -> load -> view ( 'login' , $data );
} else {
if ( isset ( $_POST )) {
$pays = $this -> input -> post ( 'pays' );
$pays_name = $this -> user_model -> getNameCountry ( $pays );
2022-04-19 10:38:29 +00:00
if ( $pays_name ) {
2020-04-17 15:28:27 +00:00
$this -> session -> set_userdata ( 'current_game_country' , $pays );
$this -> session -> set_userdata ( 'current_game_country_name' , $pays_name );
echo 1 ;
} else {
echo 0 ;
}
} else {
echo 0 ;
}
}
}
public function recherche ()
{
2020-03-23 17:03:36 +00:00
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " recherche " ;
$data [ 'result_search' ] = 0 ;
$data [ 'default_phone' ] = '' ;
$data [ 'default_transac' ] = '' ;
$data [ 'default_code' ] = '' ;
$data [ 'default_nom' ] = '' ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'networks' ] = $this -> user_model -> getActiveNetwork ();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_recherche' );
$this -> load -> view ( 'footer' );
}
}
2020-04-17 15:28:27 +00:00
public function get_user ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-03-23 17:03:36 +00:00
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
2020-03-23 17:03:36 +00:00
$nom = $this -> input -> post ( 'nom' );
$phone = $this -> input -> post ( 'phone' );
$simple_users = null ;
2020-04-17 15:28:27 +00:00
if ( $phone != '' && $nom != '' ) {
$phone_condition = " phone LIKE ' " . $phone . " %' " ;
$nom_condition = " AND lastname LIKE '% " . $nom . " %' " ;
$simple_users = $this -> user_model -> get_simple_user ( $phone , $nom );
} elseif ( $phone != '' && $nom == '' ) {
$phone_condition = " phone LIKE ' " . $phone . " %' " ;
2020-03-23 17:03:36 +00:00
$nom_condition = 'AND lastname IS NOT NULL' ;
2020-04-17 15:28:27 +00:00
$simple_users = $this -> user_model -> get_simple_user ( $phone , '%' );
} elseif ( $phone == '' && $nom != '' ) {
2020-03-23 17:03:36 +00:00
$phone_condition = 'phone IS NOT NULL' ;
2020-04-17 15:28:27 +00:00
$nom_condition = " AND lastname LIKE '% " . $nom . " %' " ;
$simple_users = $this -> user_model -> get_simple_user ( '%' , $nom );
} elseif ( $phone == '' && $nom == '' ) {
2020-03-23 17:03:36 +00:00
$phone_condition = 'phone IS NOT NULL' ;
$nom_condition = 'AND lastname IS NOT NULL' ;
}
$transac = $this -> input -> post ( 'transac' );
2020-04-17 15:28:27 +00:00
if ( $transac != '' ) {
$transac_condition = " AND transactionNumber LIKE' " . $transac . " %' " ;
} else {
2020-03-23 17:03:36 +00:00
$transac_condition = 'AND transactionNumber IS NOT NULL' ;
}
$code = $this -> input -> post ( 'code' );
2020-04-17 15:28:27 +00:00
if ( $code != '' ) {
$code_condition = " AND code_membre = ' " . $code . " ' " ;
} else {
2020-03-23 17:03:36 +00:00
$code_condition = 'AND code_membre IS NOT NULL' ;
}
2020-04-17 15:28:27 +00:00
$where_clause = " WHERE " . $phone_condition . ' ' . $transac_condition . ' ' . $code_condition . ' ' . $nom_condition ;
2020-03-23 17:03:36 +00:00
$res = $this -> user_model -> get_user ( $where_clause );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2020-03-23 17:03:36 +00:00
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$count_users = $res -> num_rows ();
2020-04-17 15:28:27 +00:00
if ( $simple_users != null ) {
$count_users = $res -> num_rows () + $simple_users -> num_rows ();
2020-03-23 17:03:36 +00:00
}
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " recherche " ;
$data [ 'result_search' ] = 1 ;
$data [ 'res_users' ] = $res ;
$data [ 'res_simple_users' ] = $simple_users ;
$data [ 'num_res' ] = $count_users ;
$data [ 'default_phone' ] = $phone ;
$data [ 'default_nom' ] = $nom ;
$data [ 'default_transac' ] = $transac ;
$data [ 'default_code' ] = $code ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'networks' ] = $this -> user_model -> getActiveNetwork ();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_recherche' );
$this -> load -> view ( 'footer' );
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
$ville = $this -> session -> userdata ( 'current_ville' );
$hyper = $this -> session -> userdata ( 'current_hyper' );
$pays = $this -> session -> userdata ( 'current_pays' );
$data [ 'alert' ] = " " ;
$data [ 'active' ] = " recherche " ;
$data [ 'result_search' ] = 2 ;
$data [ 'res_simple_users' ] = $simple_users ;
$data [ 'default_phone' ] = '' ;
$data [ 'default_transac' ] = '' ;
$data [ 'default_code' ] = '' ;
$data [ 'default_nom' ] = '' ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'networks' ] = $this -> user_model -> getActiveNetwork ();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_recherche' );
$this -> load -> view ( 'footer' );
}
}
}
}
2020-04-17 15:28:27 +00:00
public function update_info_user ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id = $_POST [ 'user_id' ];
2020-03-23 17:03:36 +00:00
$phone = $_POST [ 'contact' ];
$adresse = $_POST [ 'adresse' ];
$email = $_POST [ 'email' ];
$nom = $_POST [ 'nom' ];
2020-04-17 15:28:27 +00:00
$res = $this -> user_model -> update_user_infos ( $nom , $adresse , $email , $phone , $id );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 200 " );
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 500 " );
}
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
}
}
}
2020-04-17 15:28:27 +00:00
public function update_info_geolocated ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id_agent = $_POST [ 'user_id' ];
$id_netAg = $_POST [ 'id_netAg' ];
2020-03-23 17:03:36 +00:00
$phone = $_POST [ 'contact' ];
$transac = $_POST [ 'transac' ];
$adresse = $_POST [ 'adresse' ];
$email = $_POST [ 'email' ];
$nom = $_POST [ 'nom' ];
2022-03-28 23:50:56 +00:00
if ( $this -> user_model -> isAgentPhoneExist ( $id_netAg , $phone , $transac )) {
2021-03-01 16:53:59 +00:00
echo json_encode ( " 400 " );
2022-03-28 23:50:56 +00:00
} else {
2021-03-01 16:53:59 +00:00
$res = $this -> user_model -> update_geolocated_infos ( $nom , $adresse , $email , $id_agent , $transac , $phone , $id_netAg );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2021-03-01 16:53:59 +00:00
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
2020-03-23 17:03:36 +00:00
}
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
}
}
}
2020-04-17 15:28:27 +00:00
public function pub ()
{
2020-03-23 17:03:36 +00:00
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
2020-04-17 15:28:27 +00:00
$data [ 'countries_list' ] = $this -> user_model -> getPubCountries ();
2020-03-23 17:03:36 +00:00
$data [ 'active' ] = " pub " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'networks' ] = $this -> user_model -> getActiveNetwork ();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_publicite' );
$this -> load -> view ( 'footer' );
}
}
2020-04-17 15:28:27 +00:00
public function changePubState ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id_pub = $_POST [ 'pub_id' ];
$etat = $_POST [ 'etat' ];
if ( $etat == 0 ) {
$res = $this -> user_model -> updateStatePub ( $id_pub , 1 );
} elseif ( $etat == 1 ) {
$res = $this -> user_model -> updateStatePub ( $id_pub , 0 );
2020-03-23 17:03:36 +00:00
}
2022-04-19 10:38:29 +00:00
if ( $res ) {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 200 " );
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 500 " );
}
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
}
}
}
2020-04-17 15:28:27 +00:00
public function addPubRow ()
2022-03-28 23:50:56 +00:00
{
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$id_country = $_POST [ 'country_id' ];
2020-03-23 17:03:36 +00:00
$res = $this -> user_model -> createPubRow ( $id_country );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2020-04-17 15:28:27 +00:00
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
//Wallet
public function wallet ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
} else {
if ( $this -> input -> get ( 'id' )) {
2020-04-24 10:40:34 +00:00
2020-04-17 15:28:27 +00:00
$network_id = $this -> input -> get ( 'id' );
2022-03-28 23:50:56 +00:00
if ( $this -> input -> get ( 'history' )) {
$this -> historique ( $network_id , $this -> input -> get ( 'd' ), $this -> input -> get ( 'f' ), $this -> input -> get ( 'history' ));
} else {
2020-04-24 10:40:34 +00:00
$taux = $this -> user_model -> getTaux ( $network_id );
2020-09-28 15:44:45 +00:00
$data [ 'currency' ] = $this -> wallet_model -> getCurrency ( $network_id );
2020-04-24 10:40:34 +00:00
if ( $taux != null ) {
2020-05-05 08:25:12 +00:00
$taux = $taux -> first_row ();
2020-06-01 11:21:06 +00:00
$data [ 'idConfig' ] = $taux -> id ;
2021-10-11 00:14:08 +00:00
$data [ 'type' ] = $taux -> type ;
2022-03-28 23:50:56 +00:00
if ( $taux -> type == 'visa' ) {
2020-06-01 11:21:06 +00:00
$data [ 'taux_client_r' ] = $taux -> taux_com_client_retrait ;
$data [ 'taux_client_d' ] = $taux -> taux_com_client_depot ;
$data [ 'taux_ag_r' ] = $taux -> taux_com_ag_retrait ;
$data [ 'taux_ag_d' ] = $taux -> taux_com_ag_depot ;
$data [ 'taux_sup_r' ] = $taux -> taux_com_sup_retrait ;
$data [ 'taux_sup_d' ] = $taux -> taux_com_sup_depot ;
$data [ 'taux_bq_d' ] = $taux -> part_banque_depot ;
$data [ 'taux_bq_r' ] = $taux -> part_banque_retrait ;
$data [ 'frais_d' ] = $taux -> frais_min_banque_depot ;
2020-06-24 12:06:52 +00:00
2022-03-28 23:50:56 +00:00
$data [ 'transactions' ] = $this -> user_model -> getTransactions ( null , null , $network_id );
2020-06-24 12:06:52 +00:00
$totalCommissionBanque = 0 ;
2022-03-28 23:50:56 +00:00
if ( $data [ 'transactions' ]) {
2020-06-24 12:06:52 +00:00
foreach ( $data [ 'transactions' ] -> result () as $row ) {
$totalCommissionBanque += $row -> commission_banque ;
}
}
2022-03-28 23:50:56 +00:00
$data [ 'totalCommissionBanque' ] = $totalCommissionBanque ;
2020-06-24 12:06:52 +00:00
2022-03-28 23:50:56 +00:00
} elseif ( $taux -> type == 'ilink' ) {
2020-09-28 15:44:45 +00:00
$data [ 'plr_user_wallet_wallet' ] = $this -> wallet_model -> getPalierConfigWallet ( " user_wallet_wallet_international " , $data [ 'idConfig' ]);
$data [ 'plr_user_wallet_cash' ] = $this -> wallet_model -> getPalierConfigWallet ( " user_wallet_cash_international " , $data [ 'idConfig' ]);
2022-03-28 23:50:56 +00:00
$data [ 'plr_agent_depot_wallet_ilink' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_depot_wallet_ilink_international " , $data [ 'idConfig' ]);
$data [ 'plr_agent_depot_autre_wallet' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_depot_autre_wallet_international " , $data [ 'idConfig' ]);
2020-09-28 15:44:45 +00:00
$data [ 'plr_agent_cash_cash' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_cash_cash_international " , $data [ 'idConfig' ]);
$data [ 'plr_user_wallet_wallet_national' ] = $this -> wallet_model -> getPalierConfigWallet ( " user_wallet_wallet_national " , $data [ 'idConfig' ]);
$data [ 'plr_user_wallet_cash_national' ] = $this -> wallet_model -> getPalierConfigWallet ( " user_wallet_cash_national " , $data [ 'idConfig' ]);
2022-03-28 23:50:56 +00:00
$data [ 'plr_agent_depot_wallet_ilink_national' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_depot_wallet_ilink_national " , $data [ 'idConfig' ]);
$data [ 'plr_agent_depot_autre_wallet_national' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_depot_autre_wallet_national " , $data [ 'idConfig' ]);
2020-09-28 15:44:45 +00:00
$data [ 'plr_agent_cash_cash_national' ] = $this -> wallet_model -> getPalierConfigWallet ( " agent_cash_cash_national " , $data [ 'idConfig' ]);
2020-06-13 14:47:09 +00:00
2020-09-09 07:27:25 +00:00
$data [ 'taxes' ] = $this -> wallet_model -> getTaxes ( $data [ 'idConfig' ]);
2020-06-13 14:47:09 +00:00
2020-06-01 11:21:06 +00:00
$data [ 'taux_u_w_cart' ] = $taux -> taux_com_user_wallet_carte ;
$data [ 'taux_u_c_w' ] = $taux -> taux_com_user_carte_wallet ;
$data [ 'taux_u_c_c' ] = $taux -> taux_com_user_carte_cash ;
$data [ 'taux_ag_d_c_c' ] = $taux -> taux_com_wallet_ag_envoi_cash_carte ;
$data [ 'taux_ag_cart_c' ] = $taux -> taux_com_wallet_ag_carte_cash ;
$data [ 'taux_ag_cash_c' ] = $taux -> taux_com_wallet_ag_depot_carte ;
$data [ 'taux_ag_s_c' ] = $taux -> taux_com_ag_envoi_cash ;
$data [ 'taux_sup_s_c' ] = $taux -> taux_com_sup_envoi_cash ;
$data [ 'taux_hyp_s_c' ] = $taux -> taux_com_hyp_envoi_cash ;
$data [ 'taux_ag_r_c' ] = $taux -> taux_com_ag_retrait_cash ;
$data [ 'taux_sup_r_c' ] = $taux -> taux_com_sup_retrait_cash ;
$data [ 'taux_hyp_r_c' ] = $taux -> taux_com_hyp_retrait_cash ;
$data [ 'taux_ag_d_c' ] = $taux -> taux_com_ag_depot_cash_carte ;
$data [ 'taux_sup_d_c' ] = $taux -> taux_com_sup_depot_cash_carte ;
$data [ 'taux_hyp_d_c' ] = $taux -> taux_com_hyp_depot_cash_carte ;
$data [ 'taux_bq_d_c' ] = $taux -> taux_com_banque_depot_cash_carte ;
$data [ 'taux_ag_r_cart' ] = $taux -> taux_com_ag_retrait_carte_cash ;
$data [ 'taux_sup_r_cart' ] = $taux -> taux_com_sup_retrait_carte_cash ;
$data [ 'taux_hyp_r_cart' ] = $taux -> taux_com_hyp_retrait_carte_cash ;
$data [ 'taux_bq_r_cart' ] = $taux -> taux_com_banque_retrait_carte_cash ;
2020-06-18 09:07:18 +00:00
$data [ 'taux_hyp_r_cart_ilink' ] = $taux -> taux_com_hyp_retrait_carte_cash_ilink ;
$data [ 'taux_bq_r_cart_ilink' ] = $taux -> taux_com_banque_retrait_carte_cash_ilink ;
2020-06-24 12:06:52 +00:00
2020-09-28 15:44:45 +00:00
$data [ 'transactions' ] = $this -> wallet_model -> getNetworkIlinTransactions ( $network_id );
2020-06-24 12:06:52 +00:00
$totalCommissionBanque = 0 ;
if ( $data [ 'transactions' ]) {
foreach ( $data [ 'transactions' ] -> result () as $trans ) {
$totalCommissionBanque += $trans -> commission_banque ;
}
}
$data [ " totalCommissionBanque " ] = $totalCommissionBanque ;
2022-03-28 23:50:56 +00:00
} elseif ( $taux -> type == 'autre' ) {
2020-09-28 15:44:45 +00:00
$res = $this -> wallet_model -> getSharingRateByNetwork ( $network_id );
2022-03-28 23:50:56 +00:00
$data [ 'commission' ] = $res ? $res -> first_row () -> balance_com : 0 ;
} elseif ( $taux -> type == 'ilink_sante' ) {
2021-10-11 00:14:08 +00:00
$nh_config = $this -> nano_health_model -> getConfig ( $network_id );
2022-03-28 23:50:56 +00:00
$data [ 'nh_config' ] = $nh_config ? $nh_config -> first_row () : null ;
$data [ 'config_id' ] = $data [ 'nh_config' ] ? $data [ 'nh_config' ] -> id : null ;
2021-10-11 00:14:08 +00:00
$data [ 'years_prices_grid' ] = $this -> nano_health_model -> getConfigYearsPricesGrid ( $data [ 'config_id' ]);
$data [ 'months_prices_grid' ] = $this -> nano_health_model -> getConfigMonthsPricesGrid ( $data [ 'config_id' ]);
$data [ 'acts' ] = $this -> nano_health_model -> getConfigActs ( $data [ 'config_id' ]);
2021-10-05 06:34:11 +00:00
}
2020-04-24 10:40:34 +00:00
2020-04-17 15:28:27 +00:00
2022-03-28 23:50:56 +00:00
$hyper = $this -> wallet_model -> getNetworkHyper ( $network_id ) -> first_row ();
$data [ 'walletHyper' ] = $this -> wallet_model -> getWallet ( $hyper -> agent_id );
$data [ 'network_id' ] = $network_id ;
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
if ( $networkDetails ) {
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
}
2020-04-24 10:40:34 +00:00
// $data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($network_id);
2022-03-28 23:50:56 +00:00
$data [ 'active' ] = " wallet " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'networks' ] = $this -> user_model -> getActiveNetwork ();
$this -> load -> view ( 'header_gestion' , $data );
if ( $taux -> type == 'visa' )
$this -> load -> view ( 'gestion_wallet' );
elseif ( $taux -> type == 'ilink' )
$this -> load -> view ( 'gestion_wallet_ilink' );
elseif ( $taux -> type == 'ilink_sante' )
$this -> load -> view ( 'nano_health/admin/gestion_wallet' );
elseif ( $taux -> type == 'autre' )
$this -> load -> view ( 'gestion_wallet_autre' );
$this -> load -> view ( 'footer' );
2020-06-01 11:21:06 +00:00
}
2020-04-17 15:28:27 +00:00
}
} else {
$data [ 'active' ] = " wallet " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-09-28 15:44:45 +00:00
$data [ 'networks' ] = $this -> wallet_model -> getAllActivatedNetworks ();
2020-04-17 15:28:27 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_wallets' );
$this -> load -> view ( 'footer' );
}
}
}
public function config_wallet ( $method = 'create' )
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
2020-06-01 11:21:06 +00:00
$type = $_POST [ 'type' ];
2022-04-14 18:27:49 +00:00
$this -> db -> trans_begin ();
2022-03-28 23:50:56 +00:00
if ( $method == 'create' ) {
2021-10-11 00:14:08 +00:00
$country_id = $_POST [ 'country_id' ];
$network_id = $_POST [ 'network_id' ];
2022-03-28 23:50:56 +00:00
if ( $type == 'ilink' ) {
$exist = $this -> wallet_model -> verifyConfigWalletInCountry ( $type , $country_id );
if ( $exist ) {
2021-10-05 06:34:11 +00:00
echo json_encode ( " 403 " );
return ;
}
}
2022-03-28 23:50:56 +00:00
$res = $this -> wallet_model -> addConfigWallet ( $network_id , $type );
2020-04-17 15:28:27 +00:00
2022-03-28 23:50:56 +00:00
} else if ( $method == 'update' ) {
2020-05-05 08:25:12 +00:00
2021-10-11 00:14:08 +00:00
$idConfig = $_POST [ 'id_config' ];
2022-03-28 23:50:56 +00:00
if ( $type == 'visa' ) {
2020-06-01 11:21:06 +00:00
$taux_client_r = $_POST [ 'taux_client_r' ];
$taux_client_d = $_POST [ 'taux_client_d' ];
$taux_ag_d = $_POST [ 'taux_ag_d' ];
$taux_ag_r = $_POST [ 'taux_ag_r' ];
$taux_sup_d = $_POST [ 'taux_sup_d' ];
$taux_sup_r = $_POST [ 'taux_sup_r' ];
$taux_bq_d = $_POST [ 'taux_bq_d' ];
$taux_bq_r = $_POST [ 'taux_bq_r' ];
$frais_d = $_POST [ 'frais_d' ];
2022-03-28 23:50:56 +00:00
$res = $this -> wallet_model -> updateConfigWallet ( $idConfig , $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 );
2020-06-01 11:21:06 +00:00
2022-03-28 23:50:56 +00:00
} else if ( $type == 'ilink' ) {
2021-10-11 00:14:08 +00:00
2020-07-06 15:56:17 +00:00
$config = $_POST [ 'config' ];
$fields = isset ( $_POST [ 'fields' ]) ? $_POST [ 'fields' ] : [];
2020-06-01 11:21:06 +00:00
$rows = [];
//Convert fields to simple array
foreach ( $fields as $field ) {
$array = json_decode ( json_encode ( $field ), true );
2022-03-28 23:50:56 +00:00
$i = 0 ;
2020-06-01 11:21:06 +00:00
$name = " " ;
2022-03-28 23:50:56 +00:00
foreach ( $array as $key => $value ) {
if ( $i == 0 )
2020-07-06 15:56:17 +00:00
$name = $value ;
2020-06-01 11:21:06 +00:00
else
$rows [ $name ] = $value ;
$i ++ ;
}
}
2022-03-28 23:50:56 +00:00
switch ( $config ) {
2020-07-06 15:56:17 +00:00
case 'user_wallet_wallet' :
2022-04-19 10:38:29 +00:00
$plr_user_wallet_wallet = $_POST [ 'plr_user_wallet_wallet' ] ? ? null ;
$plr_user_wallet_wallet_national = $_POST [ 'plr_user_wallet_wallet_national' ] ? ? null ;
2022-03-28 23:50:56 +00:00
$this -> insertPalier ( $plr_user_wallet_wallet , " user_wallet_wallet_international " , $idConfig );
$this -> insertPalier ( $plr_user_wallet_wallet_national , " user_wallet_wallet_national " , $idConfig );
2020-07-06 15:56:17 +00:00
break ;
case 'user_wallet_carte' :
2022-04-19 10:38:29 +00:00
$plr_user_wallet_cart_national = $_POST [ 'plr_user_wallet_cart_national' ] ? ? null ;
$plr_hyp_user_wallet_cart_national = $_POST [ 'plr_hyp_user_wallet_cart_national' ] ? ? null ;
$plr_bank_user_wallet_cart_national = $_POST [ 'plr_bank_user_wallet_cart_national' ] ? ? null ;
$plr_user_wallet_cart_international = $_POST [ 'plr_user_wallet_cart_international' ] ? ? null ;
$plr_hyp_user_wallet_cart_international = $_POST [ 'plr_hyp_user_wallet_cart_international' ] ? ? null ;
$plr_bank_user_wallet_cart_international = $_POST [ 'plr_bank_user_wallet_cart_international' ] ? ? null ;
$this -> insertPalier ( $plr_user_wallet_cart_national , " user_wallet_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_user_wallet_cart_national , " hyp_user_wallet_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_user_wallet_cart_national , " bank_user_wallet_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_user_wallet_cart_international , " user_wallet_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_user_wallet_cart_international , " hyp_user_wallet_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_user_wallet_cart_international , " bank_user_wallet_cart_international " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
case 'user_wallet_cash' :
2022-04-19 10:38:29 +00:00
$plr_user_wallet_cash = $_POST [ 'plr_user_wallet_cash' ] ? ? null ;
$plr_user_wallet_cash_national = $_POST [ 'plr_user_wallet_cash_national' ] ? ? null ;
2022-03-28 23:50:56 +00:00
$this -> insertPalier ( $plr_user_wallet_cash , " user_wallet_cash_international " , $idConfig );
$this -> insertPalier ( $plr_user_wallet_cash_national , " user_wallet_cash_national " , $idConfig );
2020-07-06 15:56:17 +00:00
break ;
case 'user_carte_wallet' :
2022-04-19 10:38:29 +00:00
$plr_user_cart_wallet_international = $_POST [ 'plr_user_cart_wallet_international' ] ? ? null ;
$plr_user_cart_wallet_national = $_POST [ 'plr_user_cart_wallet_national' ] ? ? null ;
$plr_user_cart_cash_international = $_POST [ 'plr_user_cart_cash_international' ] ? ? null ;
$plr_user_cart_cash_national = $_POST [ 'plr_user_cart_cash_national' ] ? ? null ;
$plr_hyp_user_cart_cash_international = $_POST [ 'plr_hyp_user_cart_cash_international' ] ? ? null ;
$plr_hyp_user_cart_cash_national = $_POST [ 'plr_hyp_user_cart_cash_national' ] ? ? null ;
$plr_bank_user_cart_cash_international = $_POST [ 'plr_bank_user_cart_cash_international' ] ? ? null ;
$plr_bank_user_cart_cash_national = $_POST [ 'plr_bank_user_cart_cash_national' ] ? ? null ;
$this -> insertPalier ( $plr_user_cart_wallet_international , " user_cart_wallet_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_user_cart_wallet_national , " user_cart_wallet_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_user_cart_cash_international , " user_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_user_cart_cash_national , " user_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_user_cart_cash_international , " hyp_user_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_user_cart_cash_national , " hyp_user_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_user_cart_cash_international , " bank_user_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_user_cart_cash_national , " bank_user_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
case 'agent_remove_cash' :
2022-04-19 10:38:29 +00:00
$plr_agent_wallet_cash_national = $_POST [ 'plr_agent_wallet_cash_national' ] ? ? null ;
$plr_sup_wallet_cash_national = $_POST [ 'plr_sup_wallet_cash_national' ] ? ? null ;
$plr_hyp_wallet_cash_national = $_POST [ 'plr_hyp_wallet_cash_national' ] ? ? null ;
$plr_agent_wallet_cash_international = $_POST [ 'plr_agent_wallet_cash_international' ] ? ? null ;
$plr_sup_wallet_cash_international = $_POST [ 'plr_sup_wallet_cash_international' ] ? ? null ;
$plr_hyp_wallet_cash_international = $_POST [ 'plr_hyp_wallet_cash_international' ] ? ? null ;
$this -> insertPalier ( $plr_agent_wallet_cash_national , " agent_wallet_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_wallet_cash_national , " sup_wallet_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_wallet_cash_national , " hyp_wallet_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_wallet_cash_international , " agent_wallet_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_wallet_cash_international , " sup_wallet_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_wallet_cash_international , " hyp_wallet_cash_international " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
case 'agent_remove_carte_cash' :
2022-04-19 10:38:29 +00:00
$plr_customer_cart_cash_international = $_POST [ 'plr_customer_cart_cash_international' ] ? ? null ;
$plr_customer_cart_cash_national = $_POST [ 'plr_customer_cart_cash_national' ] ? ? null ;
$plr_agent_cart_cash_international = $_POST [ 'plr_agent_cart_cash_international' ] ? ? null ;
$plr_agent_cart_cash_national = $_POST [ 'plr_agent_cart_cash_national' ] ? ? null ;
$plr_sup_cart_cash_international = $_POST [ 'plr_sup_cart_cash_international' ] ? ? null ;
$plr_sup_cart_cash_national = $_POST [ 'plr_sup_cart_cash_national' ] ? ? null ;
$plr_hyp_cart_cash_international = $_POST [ 'plr_hyp_cart_cash_international' ] ? ? null ;
$plr_hyp_cart_cash_national = $_POST [ 'plr_hyp_cart_cash_national' ] ? ? null ;
$plr_bank_cart_cash_international = $_POST [ 'plr_bank_cart_cash_international' ] ? ? null ;
$plr_bank_cart_cash_national = $_POST [ 'plr_bank_cart_cash_national' ] ? ? null ;
$this -> insertPalier ( $plr_customer_cart_cash_international , " customer_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_customer_cart_cash_national , " customer_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_cart_cash_international , " agent_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_cart_cash_national , " agent_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cart_cash_international , " sup_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cart_cash_national , " sup_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cart_cash_international , " hyp_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cart_cash_national , " hyp_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_cart_cash_international , " bank_cart_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_cart_cash_national , " bank_cart_cash_national " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
case 'agent_send_cash_carte' :
2022-04-19 10:38:29 +00:00
$plr_customer_cash_cart_international = $_POST [ 'plr_customer_cash_cart_international' ] ? ? null ;
$plr_customer_cash_cart_national = $_POST [ 'plr_customer_cash_cart_national' ] ? ? null ;
$plr_agent_cash_cart_international = $_POST [ 'plr_agent_cash_cart_international' ] ? ? null ;
$plr_agent_cash_cart_national = $_POST [ 'plr_agent_cash_cart_national' ] ? ? null ;
$plr_sup_cash_cart_international = $_POST [ 'plr_sup_cash_cart_international' ] ? ? null ;
$plr_sup_cash_cart_national = $_POST [ 'plr_sup_cash_cart_national' ] ? ? null ;
$plr_hyp_cash_cart_international = $_POST [ 'plr_hyp_cash_cart_international' ] ? ? null ;
$plr_hyp_cash_cart_national = $_POST [ 'plr_hyp_cash_cart_national' ] ? ? null ;
$plr_bank_cash_cart_international = $_POST [ 'plr_bank_cash_cart_international' ] ? ? null ;
$plr_bank_cash_cart_national = $_POST [ 'plr_bank_cash_cart_national' ] ? ? null ;
$this -> insertPalier ( $plr_customer_cash_cart_international , " customer_cash_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_customer_cash_cart_national , " customer_cash_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_cash_cart_international , " agent_cash_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_cash_cart_national , " agent_cash_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cash_cart_international , " sup_cash_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cash_cart_national , " sup_cash_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cash_cart_international , " hyp_cash_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cash_cart_national , " hyp_cash_cart_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_cash_cart_international , " bank_cash_cart_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_bank_cash_cart_national , " bank_cash_cart_national " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
case 'agent_send_cash_canal' :
2022-04-19 10:38:29 +00:00
$plr_agent_depot_wallet_ilink = $_POST [ 'plr_agent_depot_wallet_ilink' ] ? ? null ;
$plr_agent_depot_autre_wallet = $_POST [ 'plr_agent_depot_autre_wallet' ] ? ? null ;
$plr_agent_cash_cash = $_POST [ 'plr_agent_cash_cash' ] ? ? null ;
2020-07-06 15:56:17 +00:00
2022-04-19 10:38:29 +00:00
$plr_agent_depot_wallet_ilink_national = $_POST [ 'plr_agent_depot_wallet_ilink_national' ] ? ? null ;
$plr_agent_depot_autre_wallet_national = $_POST [ 'plr_agent_depot_autre_wallet_national' ] ? ? null ;
$plr_agent_cash_cash_national = $_POST [ 'plr_agent_cash_cash_national' ] ? ? null ;
2020-07-06 15:56:17 +00:00
2022-03-28 23:50:56 +00:00
$this -> insertPalier ( $plr_agent_depot_wallet_ilink , " agent_depot_wallet_ilink_international " , $idConfig );
$this -> insertPalier ( $plr_agent_depot_autre_wallet , " agent_depot_autre_wallet_international " , $idConfig );
$this -> insertPalier ( $plr_agent_cash_cash , " agent_cash_cash_international " , $idConfig );
2020-07-06 15:56:17 +00:00
2022-03-28 23:50:56 +00:00
$this -> insertPalier ( $plr_agent_depot_wallet_ilink_national , " agent_depot_wallet_ilink_national " , $idConfig );
$this -> insertPalier ( $plr_agent_depot_autre_wallet_national , " agent_depot_autre_wallet_national " , $idConfig );
$this -> insertPalier ( $plr_agent_cash_cash_national , " agent_cash_cash_national " , $idConfig );
2020-07-06 15:56:17 +00:00
2022-04-19 10:38:29 +00:00
// Paliers des commissions
$plr_agent_cash_wallet_or_cash_international = $_POST [ 'plr_agent_cash_wallet_or_cash_international' ] ? ? null ;
$plr_agent_cash_wallet_or_cash_national = $_POST [ 'plr_agent_cash_wallet_or_cash_national' ] ? ? null ;
$plr_sup_cash_wallet_or_cash_international = $_POST [ 'plr_sup_cash_wallet_or_cash_international' ] ? ? null ;
$plr_sup_cash_wallet_or_cash_national = $_POST [ 'plr_sup_cash_wallet_or_cash_national' ] ? ? null ;
$plr_hyp_cash_wallet_or_cash_international = $_POST [ 'plr_hyp_cash_wallet_or_cash_international' ] ? ? null ;
$plr_hyp_cash_wallet_or_cash_national = $_POST [ 'plr_hyp_cash_wallet_or_cash_national' ] ? ? null ;
$this -> insertPalier ( $plr_agent_cash_wallet_or_cash_international , " agent_cash_wallet_or_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_agent_cash_wallet_or_cash_national , " agent_cash_wallet_or_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cash_wallet_or_cash_international , " sup_cash_wallet_or_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_sup_cash_wallet_or_cash_national , " sup_cash_wallet_or_cash_national " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cash_wallet_or_cash_international , " hyp_cash_wallet_or_cash_international " , $idConfig , 'paliers_commissions_wallet' );
$this -> insertPalier ( $plr_hyp_cash_wallet_or_cash_national , " hyp_cash_wallet_or_cash_national " , $idConfig , 'paliers_commissions_wallet' );
2020-07-06 15:56:17 +00:00
break ;
}
2020-05-05 08:25:12 +00:00
2022-04-14 18:27:49 +00:00
2022-03-28 23:50:56 +00:00
} else if ( $type == 'ilink_sante' ) {
unset ( $_POST [ 'id_config' ], $_POST [ 'type' ]);
$this -> nano_health_model -> updateConfig ( $idConfig , $_POST );
2022-04-14 18:27:49 +00:00
2020-06-01 11:21:06 +00:00
}
2020-04-17 15:28:27 +00:00
}
2022-04-14 18:27:49 +00:00
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
2020-04-17 15:28:27 +00:00
echo json_encode ( " 500 " );
2022-04-14 18:27:49 +00:00
} else {
$this -> db -> trans_commit ();
echo json_encode ( " 200 " );
2020-04-17 15:28:27 +00:00
}
}
}
}
2022-03-28 23:50:56 +00:00
public function saveTaxes ()
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
2020-06-10 14:20:30 +00:00
$idConfig = $_POST [ 'id_config' ];
2020-08-14 16:21:08 +00:00
$taxes = isset ( $_POST [ 'taxes' ]) ? $_POST [ 'taxes' ] : null ;
$categorie = isset ( $_POST [ 'categorie' ]) ? $_POST [ 'categorie' ] : 'wallet' ;
$this -> insertTaxes ( $taxes , $idConfig , $categorie );
2020-06-10 14:20:30 +00:00
$res = true ;
if ( $res ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2022-04-19 10:38:29 +00:00
private function insertPalier ( $palier , $type , $idConfig , $table = 'paliersConfigWallet' )
2022-03-28 23:50:56 +00:00
{
2022-04-19 10:38:29 +00:00
$this -> db -> delete ( $table ,[ 'type' => $type , 'idConfig' => $idConfig ]);
2020-06-01 11:21:06 +00:00
2022-03-28 23:50:56 +00:00
if ( $palier ) {
2022-04-14 18:27:49 +00:00
$data = [];
2020-06-01 11:21:06 +00:00
foreach ( $palier as $p ) {
2022-04-14 18:27:49 +00:00
$data [] = [
'type' => $type ,
'min' => $p [ 0 ],
'max' => $p [ 1 ],
'taux' => $p [ 2 ],
'plafond' => ! empty ( $p [ 3 ]) ? $p [ 3 ] : null ,
'idConfig' => $idConfig
];
}
if ( sizeof ( $data ) > 0 ){
2022-04-19 10:38:29 +00:00
$this -> db -> insert_batch ( $table , $data );
2020-06-01 11:21:06 +00:00
}
}
}
2020-08-14 16:21:08 +00:00
private function insertTaxes ( $palier , $idConfig , $categorie )
{
2020-06-10 14:20:30 +00:00
2020-09-28 15:44:45 +00:00
$exist = $this -> wallet_model -> getTaxes ( $idConfig , $categorie );
2020-08-14 16:21:08 +00:00
if ( $exist ) {
2020-09-28 15:44:45 +00:00
$this -> wallet_model -> deleteTaxes ( $idConfig , $categorie );
2020-06-10 14:20:30 +00:00
}
2020-08-14 16:21:08 +00:00
if ( $palier ) {
2020-06-10 14:20:30 +00:00
foreach ( $palier as $p ) {
$array = json_decode ( json_encode ( $p ), true );
$row = [];
2020-08-14 16:21:08 +00:00
foreach ( $array as $key => $value ) {
2020-06-10 14:20:30 +00:00
$row [] = $value ;
}
2020-08-14 16:21:08 +00:00
if ( $categorie == 'wallet' )
2020-09-28 15:44:45 +00:00
$this -> wallet_model -> addTaxe ( $idConfig , $row [ 0 ], $row [ 1 ], $row [ 2 ], $row [ 3 ]);
2020-08-14 16:21:08 +00:00
else
2020-09-28 15:44:45 +00:00
$this -> wallet_model -> addTaxe ( $idConfig , $row [ 0 ], $row [ 1 ], $row [ 2 ], 'national' , $categorie );
2020-06-10 14:20:30 +00:00
}
}
}
2020-04-17 15:28:27 +00:00
public function delete_config_wallet ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-04-17 15:28:27 +00:00
if ( isset ( $_POST )) {
$network_id = $_POST [ 'network_id' ];
2020-09-28 15:44:45 +00:00
$res = $this -> wallet_model -> deleteConfigWallet ( $network_id );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 200 " );
2020-04-17 15:28:27 +00:00
} else {
2020-03-23 17:03:36 +00:00
echo json_encode ( " 500 " );
}
}
}
2020-04-17 15:28:27 +00:00
}
2021-10-05 06:34:11 +00:00
public function disable_config_wallet ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2021-10-05 06:34:11 +00:00
if ( isset ( $_POST )) {
$network_id = $_POST [ 'network_id' ];
$res = $this -> wallet_model -> disableConfigWallet ( $network_id );
2022-04-19 10:38:29 +00:00
if ( $res ) {
2021-10-05 06:34:11 +00:00
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2020-04-17 15:28:27 +00:00
private function isLogged ()
{
if ( ! $this -> session -> userdata ( 'email' )) {
$this -> session -> set_flashdata ( 'error' , 'log in first' );
$data [ 'alert' ] = " ok " ;
$data [ 'message' ] = " Login first! " ;
$this -> load -> view ( 'login' , $data );
return false ;
}
return true ;
}
2022-03-28 23:50:56 +00:00
public function generateAllWallets ()
{
2020-05-01 09:30:08 +00:00
// Asynchrous method
$network_id = $_POST [ 'network_id' ];
2020-06-23 06:41:44 +00:00
$type = $_POST [ 'type' ];
2022-03-28 23:50:56 +00:00
if ( $type != 'autre' ) {
2020-06-23 06:41:44 +00:00
$pool = Pool :: create ();
$pool -> add ( function () use ( $network_id ) {
// Fetch all agents , hyperviseur , superviseur
2022-03-28 23:50:56 +00:00
$f_agents = $this -> wallet_model -> getAllAgentsForNetwork ( $network_id );
if ( $f_agents ) {
foreach ( $f_agents -> result () as $row ) {
2020-06-23 06:41:44 +00:00
//Create wallet if it not exist
2020-09-28 15:44:45 +00:00
$res = $this -> wallet_model -> getWallet ( $row -> agent_id );
2022-03-28 23:50:56 +00:00
if ( $res ) {
2020-06-23 06:41:44 +00:00
// Reinitialize the wallet
2020-09-28 15:44:45 +00:00
// $this->wallet_model->reinitializeWallet($res->first_row()->wallet_id);
2022-03-28 23:50:56 +00:00
} else {
2020-09-28 15:44:45 +00:00
$this -> wallet_model -> addWallet ( $row -> agent_id );
2020-06-23 06:41:44 +00:00
}
2020-04-17 15:28:27 +00:00
}
}
2020-06-23 06:41:44 +00:00
}) -> then ( function () {
});
await ( $pool );
}
2020-04-17 15:28:27 +00:00
2020-03-23 17:03:36 +00:00
}
2022-03-28 23:50:56 +00:00
private function historique ( $network_id , $startDate , $endDate , $type )
2020-04-24 10:40:34 +00:00
{
2020-05-02 10:49:34 +00:00
2020-09-09 07:27:25 +00:00
$data [ 'configWallet' ] = $this -> wallet_model -> getConfigWallet ( $network_id );
2022-03-28 23:50:56 +00:00
$format = $this -> session -> userdata ( 'site_lang' ) === 'french' ? 'd-m-Y' : 'Y-m-d' ;
$data [ 'startDate' ] = $startDate ? date ( $format , strtotime ( $startDate )) : null ;
$data [ 'endDate' ] = $endDate ? date ( $format , strtotime ( $endDate )) : null ;
$endDate = Date ( 'Y-m-d' , strtotime ( $endDate . " +1 day " ));
2020-12-17 08:28:53 +00:00
if ( $type == 'recharge' )
2020-09-28 15:44:45 +00:00
$data [ 'transactions' ] = $this -> wallet_model -> getRecharges ( $startDate , $endDate , $network_id );
2020-05-04 13:18:44 +00:00
2020-04-24 10:40:34 +00:00
$data [ 'active' ] = " wallet " ;
$data [ 'alert' ] = " " ;
2020-09-28 15:44:45 +00:00
$data [ 'networks' ] = $this -> wallet_model -> getAllActivatedNetworks ();
2020-04-24 10:40:34 +00:00
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
2022-03-28 23:50:56 +00:00
if ( $networkDetails ) {
2020-04-24 10:40:34 +00:00
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
2020-08-31 16:34:03 +00:00
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
$data [ 'currency_name_fr' ] = $networkDetails -> first_row () -> currency_name_fr ;
$data [ 'currency_name_en' ] = $networkDetails -> first_row () -> currency_name_en ;
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
2020-04-24 10:40:34 +00:00
}
2020-10-03 11:14:16 +00:00
$data [ 'id_network' ] = $network_id ;
2020-04-24 10:40:34 +00:00
$this -> load -> view ( 'header_gestion' , $data );
2020-06-24 12:06:52 +00:00
if ( $type == 'transaction' )
2020-05-04 13:18:44 +00:00
$this -> load -> view ( 'historique_transactions' );
2020-12-17 08:28:53 +00:00
else if ( $type == 'deleted_transactions' )
$this -> load -> view ( 'historique_transactions_deleted' );
2020-06-24 12:06:52 +00:00
else if ( $type == 'transaction_ilink' )
$this -> load -> view ( 'historique_transactions_ilink' );
2020-05-04 13:18:44 +00:00
else
$this -> load -> view ( 'historique_recharges' );
2020-04-24 10:40:34 +00:00
$this -> load -> view ( 'footer' );
}
2020-06-01 11:21:06 +00:00
public function currency ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-06-01 11:21:06 +00:00
$data [ 'active' ] = " currency " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-05-04 13:18:44 +00:00
2020-06-01 11:21:06 +00:00
if ( $this -> input -> get ( 'id' )) {
$network_id = $this -> input -> get ( 'id' );
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
2022-03-28 23:50:56 +00:00
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
$data [ 'currency_name_fr' ] = $networkDetails -> first_row () -> currency_name_fr ;
$data [ 'currency_name_en' ] = $networkDetails -> first_row () -> currency_name_en ;
2020-06-01 11:21:06 +00:00
2020-09-28 15:44:45 +00:00
$data [ 'currencies' ] = $this -> wallet_model -> getWalletsCountriesCurrencies ( $data [ 'currency_code' ]);
2020-06-01 11:21:06 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_monnaie' );
$this -> load -> view ( 'footer' );
2022-03-28 23:50:56 +00:00
} else {
2020-06-01 11:21:06 +00:00
2020-09-28 15:44:45 +00:00
$data [ 'networks' ] = $this -> wallet_model -> getAllActivatedWalletNetworks ();
2020-06-01 11:21:06 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_monnaies' );
$this -> load -> view ( 'footer' );
}
}
}
2020-05-04 13:18:44 +00:00
2022-03-28 23:50:56 +00:00
public function fetchExchangeRates ()
{
2020-06-05 16:53:04 +00:00
if ( $this -> isLogged ()) {
2022-03-28 23:50:56 +00:00
$api = " c4e31fe540cd49c98abffc06cc5948c8 " ; ///// Provide your openexchangerates.org api key here
$string = file_get_contents ( " https://openexchangerates.org/api/latest.json?app_id= $api " );
$json = json_decode ( $string , true );
2020-06-05 16:53:04 +00:00
2022-03-28 23:50:56 +00:00
$res = false ;
2020-06-05 16:53:04 +00:00
2022-03-28 23:50:56 +00:00
foreach ( $json [ 'rates' ] as $key => $value ) {
if ( $this -> wallet_model -> getExchangeRate ( $key ))
$this -> wallet_model -> updateExchangeRate ( $key , $value );
else
$this -> wallet_model -> insertExchangeRate ( $key , $value );
}
$res = true ;
if ( $res ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
2020-06-05 16:53:04 +00:00
}
}
2020-06-08 18:54:36 +00:00
public function cancelTransation ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-06-08 18:54:36 +00:00
if ( isset ( $_POST )) {
$id_transacton = $_POST [ 'id_transaction' ];
/* API URL */
2022-03-28 23:50:56 +00:00
$url = WALLET_SERVICE_URL . '/transactions/' . $id_transacton ;
2020-06-08 18:54:36 +00:00
/* Init cURL resource */
$ch = curl_init ( $url );
curl_setopt ( $ch , CURLOPT_CUSTOMREQUEST , " DELETE " );
/* set the content type json */
curl_setopt ( $ch , CURLOPT_HTTPHEADER , array (
'Content-Type:application/json' ,
2022-03-28 23:50:56 +00:00
'Authorization:' . WALLET_SERVICE_TOKEN ,
'X-localization:' . $this -> session -> userdata ( 'site_lang' ) == 'french' ? 'fr' : 'en'
2020-06-08 18:54:36 +00:00
));
/* set return type json */
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
/* execute request */
$result = curl_exec ( $ch );
/* close cURL resource */
curl_close ( $ch );
if ( $result ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2020-07-17 13:46:50 +00:00
public function cancelIlinkTransation ()
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$id_transacton = $_POST [ 'id_transaction' ];
/* API URL */
2020-12-21 08:42:45 +00:00
$url = WALLET_SERVICE_URL . '/transactions/ilink/' . $id_transacton ;
2020-07-17 13:46:50 +00:00
/* Init cURL resource */
$ch = curl_init ( $url );
curl_setopt ( $ch , CURLOPT_CUSTOMREQUEST , " DELETE " );
/* set the content type json */
curl_setopt ( $ch , CURLOPT_HTTPHEADER , array (
'Content-Type:application/json' ,
2022-03-28 23:50:56 +00:00
'Authorization:' . WALLET_SERVICE_TOKEN ,
'X-localization:' . $this -> session -> userdata ( 'site_lang' ) == 'french' ? 'fr' : 'en'
2020-07-17 13:46:50 +00:00
));
/* set return type json */
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true );
/* execute request */
$result = curl_exec ( $ch );
/* close cURL resource */
curl_close ( $ch );
if ( $result ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2020-08-06 06:26:28 +00:00
public function nano_credit ()
{
if ( $this -> isLogged ()) {
$data [ 'active' ] = " nano_credit " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-08-10 18:11:05 +00:00
if ( $this -> input -> get ( 'id' )) {
$data [ 'network_id' ] = $this -> input -> get ( 'id' );
2020-08-31 16:34:03 +00:00
if ( $this -> input -> get ( 'history' )) {
$this -> historique_nano_credit ( $data [ 'network_id' ], $this -> input -> get ( 'd' ), $this -> input -> get ( 'f' ), $this -> input -> get ( 'history' ));
2020-10-03 11:14:16 +00:00
} elseif ( $this -> input -> get ( 'group' )) {
2022-03-28 23:50:56 +00:00
$this -> users_group_details ( $data [ 'network_id' ], $this -> input -> get ( 'group' ));
2020-08-31 16:34:03 +00:00
} else {
2020-09-28 15:44:45 +00:00
$data [ 'groups' ] = $this -> nano_credit_model -> getUsersGroups ( $data [ 'network_id' ]);
2020-09-09 07:27:25 +00:00
$data [ 'configWallet' ] = $this -> wallet_model -> getConfigWallet ( $data [ 'network_id' ]) -> first_row ();
2020-08-31 16:34:03 +00:00
$networkDetails = $this -> user_model -> getNetworkDetails ( $data [ 'network_id' ]);
if ( $networkDetails ) {
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
}
2020-09-28 15:44:45 +00:00
$data [ 'rates_nano_credit' ] = $this -> nano_credit_model -> getNanoCreditRates ( $data [ 'configWallet' ] -> id );
$data [ 'taxes_nano_credit' ] = $this -> wallet_model -> getTaxes ( $data [ 'configWallet' ] -> id , 'nano_credit' );
2020-08-31 16:34:03 +00:00
2020-09-28 15:44:45 +00:00
$data [ 'rates_epargne' ] = $this -> nano_credit_model -> getNanoCreditRates ( $data [ 'configWallet' ] -> id , 'epargne' );
$data [ 'taxes_epargne' ] = $this -> wallet_model -> getTaxes ( $data [ 'configWallet' ] -> id , 'epargne' );
2020-08-31 16:34:03 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'nano_credit/gestion_nano_credit_admin' );
$this -> load -> view ( 'footer' );
2020-08-10 18:11:05 +00:00
}
} else {
2020-09-28 15:44:45 +00:00
$data [ 'networks' ] = $this -> nano_credit_model -> getAllIlinkWorldNetworks ();
2020-08-10 18:11:05 +00:00
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'nano_credit/gestion_nano_credits' );
$this -> load -> view ( 'footer' );
}
2020-08-06 06:26:28 +00:00
}
}
2020-08-31 16:34:03 +00:00
private function historique_nano_credit ( $network_id , $startDate , $endDate , $type )
{
2020-09-09 07:27:25 +00:00
$data [ 'configWallet' ] = $this -> wallet_model -> getConfigWallet ( $network_id );
2020-08-31 16:34:03 +00:00
$format = $this -> session -> userdata ( 'site_lang' ) === 'french' ? 'd-m-Y' : 'Y-m-d' ;
$data [ 'startDate' ] = $startDate ? date ( $format , strtotime ( $startDate )) : null ;
$data [ 'endDate' ] = $endDate ? date ( $format , strtotime ( $endDate )) : null ;
$endDate = Date ( 'Y-m-d' , strtotime ( $endDate . " +1 day " ));
if ( $type == 'nano_credit' ) {
2020-09-28 15:44:45 +00:00
$data [ 'transactions' ] = $this -> nano_credit_model -> getUserDemandesCredit ( $startDate , $endDate , $network_id );
2020-08-31 16:34:03 +00:00
} else if ( $type == 'savings' ) {
2020-10-03 11:14:16 +00:00
$data [ 'transactions' ] = $this -> nano_credit_model -> getUsersSavings ( $startDate , $endDate , $network_id );
2020-08-31 16:34:03 +00:00
}
$data [ 'active' ] = " nano_credit " ;
$data [ 'alert' ] = " " ;
2020-09-28 15:44:45 +00:00
$data [ 'networks' ] = $this -> wallet_model -> getAllActivatedNetworks ();
2020-08-31 16:34:03 +00:00
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2020-10-03 11:14:16 +00:00
$data [ 'id_network' ] = $network_id ;
2020-08-31 16:34:03 +00:00
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
if ( $networkDetails ) {
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
$data [ 'currency_name_fr' ] = $networkDetails -> first_row () -> currency_name_fr ;
$data [ 'currency_name_en' ] = $networkDetails -> first_row () -> currency_name_en ;
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
}
$this -> load -> view ( 'header_gestion' , $data );
2020-10-03 11:14:16 +00:00
if ( $type == 'savings' )
2020-08-31 16:34:03 +00:00
$this -> load -> view ( 'nano_credit/historique_savings' );
else
$this -> load -> view ( 'nano_credit/historique_nano_credit' );
$this -> load -> view ( 'footer' );
}
2022-03-28 23:50:56 +00:00
private function users_group_details ( $network_id , $group_code )
2020-10-03 11:14:16 +00:00
{
$data [ 'active' ] = " nano_credit " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
if ( $networkDetails ) {
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
}
$data [ 'category' ] = $this -> session -> userdata ( 'category' );
$data [ 'members' ] = $this -> nano_credit_model -> getGroupMembers ( $group_code );
$data [ 'group' ] = $this -> nano_credit_model -> getGroup ( $group_code );
//Calcul de la capacite d'emprunt
$CE = 0 ;
2022-03-28 23:50:56 +00:00
if ( $data [ 'members' ]) {
2020-10-03 11:14:16 +00:00
$sommeCredits = 0 ;
$sommeEpargnes = 0 ;
2022-03-28 23:50:56 +00:00
foreach ( $data [ 'members' ] -> result () as $user ) {
2020-12-02 17:22:18 +00:00
$sum_credit = $this -> nano_credit_model -> sumGroupCredit ( $user -> id_user ) ? $this -> nano_credit_model -> sumGroupCredit ( $user -> id_user ) -> credit : 0 ;
$sommeCredits += $sum_credit ;
2020-10-03 11:14:16 +00:00
$sommeEpargnes += $user -> balance_epargne ;
}
$CE = $sommeEpargnes - $sommeCredits ;
}
$data [ 'CE' ] = $CE ;
$data [ 'group_code' ] = $group_code ;
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'nano_credit/users_group_detail' );
$this -> load -> view ( 'footer' );
}
2020-08-06 06:26:28 +00:00
public function activate_nano_credit ()
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$id_network = $_POST [ 'id_network' ];
2020-09-28 15:44:45 +00:00
$this -> nano_credit_model -> insertCreditLimit ( 0 , 0 , '1' , $id_network );
2020-08-06 06:26:28 +00:00
$res = true ;
if ( $res ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
public function delete_nano_credit ()
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$id_network = $_POST [ 'id_network' ];
2020-09-28 15:44:45 +00:00
$this -> nano_credit_model -> insertCreditLimit ( 0 , 0 , '0' , $id_network );
2020-08-06 06:26:28 +00:00
$res = true ;
if ( $res ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2020-07-17 13:46:50 +00:00
2020-09-28 15:44:45 +00:00
public function regulations ()
{
2022-03-28 23:50:56 +00:00
if ( $this -> isLogged ()) {
2020-09-28 15:44:45 +00:00
$data [ 'active' ] = " regulations " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
if ( $this -> input -> get ( 'id' )) {
$network_id = $this -> input -> get ( 'id' );
$networkDetails = $this -> user_model -> getNetworkDetails ( $network_id );
$data [ 'network' ] = $networkDetails -> first_row () -> network ;
2022-03-28 23:50:56 +00:00
$data [ 'country' ] = $networkDetails -> first_row () -> country ;
2020-09-28 15:44:45 +00:00
$data [ 'currency_code' ] = $networkDetails -> first_row () -> currency_code ;
2022-03-28 23:50:56 +00:00
$data [ 'currency_name_fr' ] = $networkDetails -> first_row () -> currency_name_fr ;
$data [ 'currency_name_en' ] = $networkDetails -> first_row () -> currency_name_en ;
2020-09-28 15:44:45 +00:00
$data [ 'currencies' ] = $this -> wallet_model -> getWalletsCountriesCurrencies ( $data [ 'currency_code' ]);
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_monnaie' );
$this -> load -> view ( 'footer' );
2022-03-28 23:50:56 +00:00
} else {
2020-09-28 15:44:45 +00:00
$data [ 'countries' ] = $this -> wallet_model -> getRegulationsCountries ();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_reglementations' );
$this -> load -> view ( 'footer' );
}
}
}
2022-03-28 23:50:56 +00:00
public function setRegulationsLimits ()
{
2020-09-28 15:44:45 +00:00
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$country_id = $_POST [ 'country_id' ];
2020-10-05 16:46:35 +00:00
$max_day_national = $_POST [ 'max_day_national' ];
$max_week_national = $_POST [ 'max_week_national' ];
$max_month_national = $_POST [ 'max_month_national' ];
$max_day_international = $_POST [ 'max_day_international' ];
$max_week_international = $_POST [ 'max_week_international' ];
$max_month_international = $_POST [ 'max_month_international' ];
2020-09-28 15:44:45 +00:00
$limits = $this -> wallet_model -> getRegulationsLimits ( $country_id );
2022-03-28 23:50:56 +00:00
if ( $limits ) {
$this -> wallet_model -> updateRegulationsLimits ( $country_id , $max_day_national , $max_week_national , $max_month_national ,
$max_day_international , $max_week_international , $max_month_international );
} else {
$this -> wallet_model -> insertRegulationsLimits ( $country_id , $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
}
$res = true ;
if ( $res ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
}
2020-11-06 17:47:42 +00:00
public function operators ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
2020-11-06 17:47:42 +00:00
$data [ 'operators' ] = $this -> wallet_model -> getAllOperatorsCountries ();
2020-10-27 10:50:41 +00:00
$data [ 'pays' ] = $this -> user_model -> getAllPays ();
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
$data [ 'alert' ] = " " ;
2020-11-06 17:47:42 +00:00
$data [ 'active' ] = " operators " ;
$data [ 'distinct_operators' ] = $this -> wallet_model -> getAllOperators ();
$data [ 'operators_types' ] = $this -> db -> get ( 'type_operators' );
2020-10-27 10:50:41 +00:00
$this -> load -> view ( 'header_gestion' , $data );
2020-11-06 17:47:42 +00:00
$this -> load -> view ( 'gestion_operateurs_admin' );
2020-10-27 10:50:41 +00:00
$this -> load -> view ( 'footer' );
}
}
2020-11-06 17:47:42 +00:00
public function add_operator ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$data = array (
'nom' => $this -> input -> post ( 'name' ),
2020-11-06 17:47:42 +00:00
'type' => $this -> input -> post ( 'type' )
2022-03-28 23:50:56 +00:00
);
2020-10-27 10:50:41 +00:00
2020-11-06 17:47:42 +00:00
$query = $this -> db -> insert ( 'operators' , $data );
2020-10-27 10:50:41 +00:00
if ( $query ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
2020-11-28 08:18:58 +00:00
public function add_operator_type ()
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
2022-03-28 23:50:56 +00:00
$query = $this -> db -> get_where ( 'type_operators' , array ( 'code' => $this -> input -> post ( 'code' )), 1 );
2020-11-28 08:18:58 +00:00
$exist = $query -> num_rows () > 0 ;
2022-03-28 23:50:56 +00:00
if ( $exist ) {
2020-11-28 08:18:58 +00:00
echo json_encode ( 422 );
2022-03-28 23:50:56 +00:00
} else {
2020-11-28 08:18:58 +00:00
$data = array (
'code' => $this -> input -> post ( 'code' ),
'description_fr' => $this -> input -> post ( 'description_fr' ),
'description_en' => $this -> input -> post ( 'description_fr' )
);
$query = $this -> db -> insert ( 'type_operators' , $data );
if ( $query ) {
echo json_encode ( 200 );
} else {
echo json_encode ( 500 );
}
}
}
}
}
2020-11-06 17:47:42 +00:00
public function delete_operator ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
2020-11-06 17:47:42 +00:00
$id_operator = $this -> input -> post ( 'id_operator' );
2020-10-27 10:50:41 +00:00
$id_country = $this -> input -> post ( 'id_country' );
2020-11-06 17:47:42 +00:00
$query = $this -> wallet_model -> deleteOperatorCountry ( $id_operator , $id_country );
2020-10-27 10:50:41 +00:00
if ( $query ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
2020-11-06 17:47:42 +00:00
public function assign_operator ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
2020-11-06 17:47:42 +00:00
$id_operator = $this -> input -> post ( 'id_operator' );
2020-10-27 10:50:41 +00:00
$existe = 0 ;
$this -> db -> trans_begin ();
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'id_country' ] as $country ) {
2020-11-06 17:47:42 +00:00
$res = $this -> wallet_model -> checkIfOperatorAssignationExist ( $country , $id_operator );
2020-10-27 10:50:41 +00:00
if ( $res == false ) {
2022-03-28 23:50:56 +00:00
$data = array ( 'id_country' => $country , 'id_operator' => $id_operator );
2020-11-06 17:47:42 +00:00
$this -> db -> insert ( 'operators_countries' , $data );
2020-10-27 10:50:41 +00:00
} else {
$existe = $existe + 1 ;
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} elseif ( $existe > 0 ) {
$this -> db -> trans_commit ();
echo json_encode ( " existe " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
2020-11-06 17:47:42 +00:00
public function update_operator ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
2020-11-06 17:47:42 +00:00
$id_operator = $this -> input -> post ( 'id_operator' );
2020-10-27 10:50:41 +00:00
$id_country = $this -> input -> post ( 'id_country' );
$name = $this -> input -> post ( 'name' );
$address = $this -> input -> post ( 'address' );
2020-11-05 17:02:13 +00:00
$code = $this -> input -> post ( 'code' );
2020-10-27 10:50:41 +00:00
2022-03-28 23:50:56 +00:00
$res = $this -> wallet_model -> updateOperator ( $id_operator , $id_country , $name , $address , $code );
2020-10-27 10:50:41 +00:00
if ( $res == true ) {
echo json_encode ( " completed " );
} else {
echo json_encode ( " error " );
}
}
}
}
2020-11-06 17:47:42 +00:00
public function change_operator_status ()
2020-10-27 10:50:41 +00:00
{
if ( $this -> isLogged ()) {
if ( isset ( $_POST )) {
$activations = $this -> input -> post ( 'activations' );
$desactivation = $this -> input -> post ( 'desactivations' );
$this -> db -> trans_begin ();
if ( ! empty ( $_POST [ 'activations' ])) {
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'activations' ] as $row ) {
2020-10-27 10:50:41 +00:00
$data = array ( 'status' => 1 );
2020-11-06 17:47:42 +00:00
$this -> db -> where ( 'id_operator' , $row [ 'id_operator' ]);
2020-10-27 10:50:41 +00:00
$this -> db -> where ( 'id_country' , $row [ 'id_country' ]);
2020-11-06 17:47:42 +00:00
$this -> db -> update ( 'operators_countries' , $data );
2020-10-27 10:50:41 +00:00
}
}
if ( ! empty ( $_POST [ 'desactivations' ])) {
2022-03-28 23:50:56 +00:00
foreach ( $_POST [ 'desactivations' ] as $row ) {
2020-10-27 10:50:41 +00:00
$data = array ( 'status' => 0 );
2020-11-06 17:47:42 +00:00
$this -> db -> where ( 'id_operator' , $row [ 'id_operator' ]);
2020-10-27 10:50:41 +00:00
$this -> db -> where ( 'id_country' , $row [ 'id_country' ]);
2020-11-06 17:47:42 +00:00
$this -> db -> update ( 'operators_countries' , $data );
2020-10-27 10:50:41 +00:00
}
}
if ( $this -> db -> trans_status () === FALSE ) {
$this -> db -> trans_rollback ();
echo json_encode ( " error " );
} else {
$this -> db -> trans_commit ();
echo json_encode ( " completed " );
}
}
}
}
2022-03-28 23:50:56 +00:00
public function settings ()
{
2021-05-24 07:40:09 +00:00
if ( $this -> isLogged ()) {
$data [ 'active' ] = " settings " ;
$data [ 'alert' ] = " " ;
$data [ 'game_pays' ] = $this -> user_model -> getGameCountry ();
2022-03-28 23:50:56 +00:00
$data [ 'pas_chargement' ] = $this -> user_model -> getAdminConfig ( 'pas_chargement' );
$data [ 'active_pub' ] = $this -> user_model -> getAdminConfig ( 'active_pub' , 'bool' );
2021-05-24 07:40:09 +00:00
// $data['enable_sms_notifications'] = $this->user_model->getAdminConfig('enable_sms_notifications', 'bool');
// $data['towns'] = $this->user_model->getAllVilles();
$this -> load -> view ( 'header_gestion' , $data );
$this -> load -> view ( 'gestion_settings' );
$this -> load -> view ( 'footer' );
}
}
2022-03-28 23:50:56 +00:00
public function update_settings ()
{
2021-05-24 07:40:09 +00:00
if ( $this -> isLogged ()) {
$pas = $this -> input -> post ( 'pas' );
$jours = $this -> input -> post ( 'jours' );
$default_locality = $this -> input -> post ( 'default_locality' );
$enable_sms_notifications = $this -> input -> post ( 'enable_sms_notifications' );
$office_penalty_percent = $this -> input -> post ( 'office_penalty_percent' );
$month_delay_penalty_percent = $this -> input -> post ( 'month_delay_penalty_percent' );
$payment_deadline_date = $this -> input -> post ( 'payment_deadline_date' );
2022-03-28 23:50:56 +00:00
if ( isset ( $pas )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'pas_chargement' , $pas );
}
2022-03-28 23:50:56 +00:00
if ( isset ( $jours )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'jours_calendaires' , $jours );
}
2022-03-28 23:50:56 +00:00
if ( isset ( $default_locality )) {
$result = $this -> user_model -> insertAdminConfig ( 'default_locality' , $default_locality , '' );
2021-05-24 07:40:09 +00:00
}
2022-03-28 23:50:56 +00:00
if ( isset ( $enable_sms_notifications )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'enable_sms_notifications' , $enable_sms_notifications , 'bool' );
}
2022-03-28 23:50:56 +00:00
if ( isset ( $office_penalty_percent )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'office_penalty_percent' , $office_penalty_percent );
}
2022-03-28 23:50:56 +00:00
if ( isset ( $month_delay_penalty_percent )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'month_delay_penalty_percent' , $month_delay_penalty_percent );
}
2022-03-28 23:50:56 +00:00
if ( isset ( $payment_deadline_date )) {
2021-05-24 07:40:09 +00:00
$result = $this -> user_model -> insertAdminConfig ( 'payment_deadline_date' , $payment_deadline_date , 'date' );
}
if ( $result ) {
echo json_encode ( " 200 " );
} else {
echo json_encode ( " 500 " );
}
}
}
2020-03-23 17:03:36 +00:00
}
2020-04-24 10:40:34 +00:00