diff --git a/application/config/config.php b/application/config/config.php index b7d60860..41597ba0 100755 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = 'https://'.$_SERVER['SERVER_NAME'].'/backoffice'; +$config['base_url'] = 'https://backoffice.ilink-app.com'; /* |-------------------------------------------------------------------------- diff --git a/application/config/config.php.save b/application/config/config.php.save new file mode 100755 index 00000000..f204b062 --- /dev/null +++ b/application/config/config.php.save @@ -0,0 +1,525 @@ + + +]+$/i +| +| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!! +| +*/ +$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; + +/* +|-------------------------------------------------------------------------- +| Enable Query Strings +|-------------------------------------------------------------------------- +| +| By default CodeIgniter uses search-engine friendly segment based URLs: +| example.com/who/what/where/ +| +| You can optionally enable standard query string based URLs: +| example.com?who=me&what=something&where=here +| +| Options are: TRUE or FALSE (boolean) +| +| The other items let you set the query string 'words' that will +| invoke your controllers and its functions: +| example.com/index.php?c=controller&m=function +| +| Please note that some of the helpers won't work as expected when +| this feature is enabled, since CodeIgniter is designed primarily to +| use segment based URLs. +| +*/ +$config['enable_query_strings'] = FALSE; +$config['controller_trigger'] = 'c'; +$config['function_trigger'] = 'm'; +$config['directory_trigger'] = 'd'; + +/* +|-------------------------------------------------------------------------- +| Allow $_GET array +|-------------------------------------------------------------------------- +| +| By default CodeIgniter enables access to the $_GET array. If for some +| reason you would like to disable it, set 'allow_get_array' to FALSE. +| +| WARNING: This feature is DEPRECATED and currently available only +| for backwards compatibility purposes! +| +*/ +$config['allow_get_array'] = TRUE; + +/* +|-------------------------------------------------------------------------- +| Error Logging Threshold +|-------------------------------------------------------------------------- +| +| You can enable error logging by setting a threshold over zero. The +| threshold determines what gets logged. Threshold options are: +| +| 0 = Disables logging, Error logging TURNED OFF +| 1 = Error Messages (including PHP errors) +| 2 = Debug Messages +| 3 = Informational Messages +| 4 = All Messages +| +| You can also pass an array with threshold levels to show individual error types +| +| array(2) = Debug Messages, without Error Messages +| +| For a live site you'll usually only enable Errors (1) to be logged otherwise +| your log files will fill up very fast. +| +*/ +$config['log_threshold'] = 0; + +/* +|-------------------------------------------------------------------------- +| Error Logging Directory Path +|-------------------------------------------------------------------------- +| +| Leave this BLANK unless you would like to set something other than the default +| application/logs/ directory. Use a full server path with trailing slash. +| +*/ +$config['log_path'] = ''; + +/* +|-------------------------------------------------------------------------- +| Log File Extension +|-------------------------------------------------------------------------- +| +| The default filename extension for log files. The default 'php' allows for +| protecting the log files via basic scripting, when they are to be stored +| under a publicly accessible directory. +| +| Note: Leaving it blank will default to 'php'. +| +*/ +$config['log_file_extension'] = ''; + +/* +|-------------------------------------------------------------------------- +| Log File Permissions +|-------------------------------------------------------------------------- +| +| The file system permissions to be applied on newly created log files. +| +| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal +| integer notation (i.e. 0700, 0644, etc.) +*/ +$config['log_file_permissions'] = 0644; + +/* +|-------------------------------------------------------------------------- +| Date Format for Logs +|-------------------------------------------------------------------------- +| +| Each item that is logged has an associated date. You can use PHP date +| codes to set your own date formatting +| +*/ +$config['log_date_format'] = 'Y-m-d H:i:s'; + +/* +|-------------------------------------------------------------------------- +| Error Views Directory Path +|-------------------------------------------------------------------------- +| +| Leave this BLANK unless you would like to set something other than the default +| application/views/errors/ directory. Use a full server path with trailing slash. +| +*/ +$config['error_views_path'] = ''; + +/* +|-------------------------------------------------------------------------- +| Cache Directory Path +|-------------------------------------------------------------------------- +| +| Leave this BLANK unless you would like to set something other than the default +| application/cache/ directory. Use a full server path with trailing slash. +| +*/ +$config['cache_path'] = ''; + +/* +|-------------------------------------------------------------------------- +| Cache Include Query String +|-------------------------------------------------------------------------- +| +| Whether to take the URL query string into consideration when generating +| output cache files. Valid options are: +| +| FALSE = Disabled +| TRUE = Enabled, take all query parameters into account. +| Please be aware that this may result in numerous cache +| files generated for the same page over and over again. +| array('q') = Enabled, but only take into account the specified list +| of query parameters. +| +*/ +$config['cache_query_string'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Encryption Key +|-------------------------------------------------------------------------- +| +| If you use the Encryption class, you must set an encryption key. +| See the user guide for more info. +| +| https://codeigniter.com/user_guide/libraries/encryption.html +| +*/ +$config['encryption_key'] = ''; + +/* +|-------------------------------------------------------------------------- +| Session Variables +|-------------------------------------------------------------------------- +| +| 'sess_driver' +| +| The storage driver to use: files, database, redis, memcached +| +| 'sess_cookie_name' +| +| The session cookie name, must contain only [0-9a-z_-] characters +| +| 'sess_expiration' +| +| The number of SECONDS you want the session to last. +| Setting to 0 (zero) means expire when the browser is closed. +| +| 'sess_save_path' +| +| The location to save sessions to, driver dependent. +| +| For the 'files' driver, it's a path to a writable directory. +| WARNING: Only absolute paths are supported! +| +| For the 'database' driver, it's a table name. +| Please read up the manual for the format with other session drivers. +| +| IMPORTANT: You are REQUIRED to set a valid save path! +| +| 'sess_match_ip' +| +| Whether to match the user's IP address when reading the session data. +| +| WARNING: If you're using the database driver, don't forget to update +| your session table's PRIMARY KEY when changing this setting. +| +| 'sess_time_to_update' +| +| How many seconds between CI regenerating the session ID. +| +| 'sess_regenerate_destroy' +| +| Whether to destroy session data associated with the old session ID +| when auto-regenerating the session ID. When set to FALSE, the data +| will be later deleted by the garbage collector. +| +| Other session cookie settings are shared with the rest of the application, +| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here. +| +*/ +$config['sess_driver'] = 'files'; +$config['sess_cookie_name'] = 'ci_session'; +$config['sess_expiration'] = 7200; +$config['sess_save_path'] = NULL; +$config['sess_match_ip'] = FALSE; +$config['sess_time_to_update'] = 300; +$config['sess_regenerate_destroy'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Cookie Related Variables +|-------------------------------------------------------------------------- +| +| 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions +| 'cookie_domain' = Set to .your-domain.com for site-wide cookies +| 'cookie_path' = Typically will be a forward slash +| 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists. +| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript) +| +| Note: These settings (with the exception of 'cookie_prefix' and +| 'cookie_httponly') will also affect sessions. +| +*/ +$config['cookie_prefix'] = ''; +$config['cookie_domain'] = ''; +$config['cookie_path'] = '/'; +$config['cookie_secure'] = FALSE; +$config['cookie_httponly'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Standardize newlines +|-------------------------------------------------------------------------- +| +| Determines whether to standardize newline characters in input data, +| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value. +| +| WARNING: This feature is DEPRECATED and currently available only +| for backwards compatibility purposes! +| +*/ +$config['standardize_newlines'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Global XSS Filtering +|-------------------------------------------------------------------------- +| +| Determines whether the XSS filter is always active when GET, POST or +| COOKIE data is encountered +| +| WARNING: This feature is DEPRECATED and currently available only +| for backwards compatibility purposes! +| +*/ +$config['global_xss_filtering'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Cross Site Request Forgery +|-------------------------------------------------------------------------- +| Enables a CSRF cookie token to be set. When set to TRUE, token will be +| checked on a submitted form. If you are accepting user data, it is strongly +| recommended CSRF protection be enabled. +| +| 'csrf_token_name' = The token name +| 'csrf_cookie_name' = The cookie name +| 'csrf_expire' = The number in seconds the token should expire. +| 'csrf_regenerate' = Regenerate token on every submission +| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks +*/ +$config['csrf_protection'] = FALSE; +$config['csrf_token_name'] = 'csrf_test_name'; +$config['csrf_cookie_name'] = 'csrf_cookie_name'; +$config['csrf_expire'] = 7200; +$config['csrf_regenerate'] = TRUE; +$config['csrf_exclude_uris'] = array(); + +/* +|-------------------------------------------------------------------------- +| Output Compression +|-------------------------------------------------------------------------- +| +| Enables Gzip output compression for faster page loads. When enabled, +| the output class will test whether your server supports Gzip. +| Even if it does, however, not all browsers support compression +| so enable only if you are reasonably sure your visitors can handle it. +| +| Only used if zlib.output_compression is turned off in your php.ini. +| Please do not use it together with httpd-level output compression. +| +| VERY IMPORTANT: If you are getting a blank page when compression is enabled it +| means you are prematurely outputting something to your browser. It could +| even be a line of whitespace at the end of one of your scripts. For +| compression to work, nothing can be sent before the output buffer is called +| by the output class. Do not 'echo' any values with compression enabled. +| +*/ +$config['compress_output'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Master Time Reference +|-------------------------------------------------------------------------- +| +| Options are 'local' or any PHP supported timezone. This preference tells +| the system whether to use your server's local time as the master 'now' +| reference, or convert it to the configured one timezone. See the 'date +| helper' page of the user guide for information regarding date handling. +| +*/ +$config['time_reference'] = 'local'; + +/* +|-------------------------------------------------------------------------- +| Rewrite PHP Short Tags +|-------------------------------------------------------------------------- +| +| If your PHP installation does not have short tag support enabled CI +| can rewrite the tags on-the-fly, enabling you to utilize that syntax +| in your view files. Options are TRUE or FALSE (boolean) +| +| Note: You need to have eval() enabled for this to work. +| +*/ +$config['rewrite_short_tags'] = FALSE; + +/* +|-------------------------------------------------------------------------- +| Reverse Proxy IPs +|-------------------------------------------------------------------------- +| +| If your server is behind a reverse proxy, you must whitelist the proxy +| IP addresses from which CodeIgniter should trust headers such as +| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify +| the visitor's IP address. +| +| You can use both an array or a comma-separated list of proxy addresses, +| as well as specifying whole subnets. Here are a few examples: +| +| Comma-separated: '10.0.1.200,192.168.5.0/24' +| Array: array('10.0.1.200', '192.168.5.0/24') +*/ +$config['proxy_ips'] = ''; diff --git a/application/config/constants.php b/application/config/constants.php index 42f1d01d..368c6cf0 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -87,13 +87,13 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto /* * Microservices constants */ -define('WALLET_SERVICE_URL','https://ilink-app.com:8081'); +define('WALLET_SERVICE_URL','https://test.ilink-app.com:8081'); define('WALLET_SERVICE_TOKEN','fywRtXSwEhHncwXaqn10wa9bJU9a63r2'); -define('WALLET_SERVICE_EXTERNE_URL','https://ilink-app.com:8085'); +define('WALLET_SERVICE_EXTERNE_URL','https://test.ilink-app.com:8085'); define('WALLET_SERVICE_EXTERNE_TOKEN','JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I'); -define('NOTIFICATION_SERVICE_URL','https://ilink-app.com:8083'); +define('NOTIFICATION_SERVICE_URL','https://test.ilink-app.com:8083'); define('NOTIFICATION_SERVICE_TOKEN','RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg'); -define('NANO_SANTE_SERVICE_URL','https://ilink-app.com:8086'); +define('NANO_SANTE_SERVICE_URL','https://test.ilink-app.com:8086'); define('NANO_SANTE_SERVICE_TOKEN','eStSQIoAfnTJ9nkCs0IJkJiKACxYVcQm'); -define('USER_SERVICE_URL','https://ilink-app.com:8088'); +define('USER_SERVICE_URL','https://test.ilink-app.com:8088'); define('USER_SERVICE_TOKEN','T3J0c9lQXPBs6UWebvPWWdnzqmqWOQM6'); diff --git a/application/config/database.php b/application/config/database.php index d0c4b28c..0d8ef22a 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -1,5 +1,4 @@ -db->last_query() and profiling of DB queries. +| When you run a query, with this setting set to TRUE (default), +| CodeIgniter will store the SQL statement for debugging purposes. +| However, this may cause high memory usage, especially if you run +| a lot of SQL queries ... disable this to avoid that problem. +| +| The $active_group variable lets you choose which connection group to +| make active. By default there is only one group (the 'default' group). +| +| The $query_builder variables lets you determine whether or not to load +| the query builder class. +*/ +$active_group = 'default'; +$query_builder = TRUE; + +$db['default'] = array( + 'dsn' => '', + 'hostname' => 'localhost', + 'username' => 'root', + 'password' => 'vps@2017GA', + 'database' => 'iLink_preprod', + 'wallet_service_url' => 'https://test.ilink-app.com:8081', + 'wallet_service_externe_url' => 'https://test.ilink-app.com:8085', + 'notification_service_url' => 'http://test.ilink-app.com:8083', + 'dbdriver' => 'mysqli', + 'dbprefix' => '', + 'pconnect' => FALSE, + 'db_debug' => (ENVIRONMENT !== 'production'), + 'cache_on' => FALSE, + 'cachedir' => '', + 'char_set' => 'utf8', + 'dbcollat' => 'utf8_general_ci', + 'swap_pre' => '', + 'encrypt' => FALSE, + 'compress' => FALSE, + 'stricton' => FALSE, + 'failover' => array(), + 'save_queries' => TRUE +); diff --git a/application/controllers/Gestion.php.save b/application/controllers/Gestion.php.save new file mode 100755 index 00000000..372aab48 --- /dev/null +++ b/application/controllers/Gestion.php.save @@ -0,0 +1,1738 @@ +load->model('user_model'); + date_default_timezone_set ($this->session->userdata('timezone')); + } + + 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'); + + + $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() + { + 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)) { + $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() + { + + 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)) { + $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() + { + + 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)) { + $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() + { + 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)) { + $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() + { + 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)) { + $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(); + + + $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(); + + + $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'); + + $data['list_villes'] = $this->user_model->getAllVilles(); + $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 +// $data['networks'] = $this->user_model->getActiveNetwork(); + + $this->load->view('header_gestion', $data); + $this->load->view('gestion_networks'); + $this->load->view('footer'); + } + } + + public function creat_network() + { + + 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)) { + $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() + { + + 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)) { + $network = $this->input->post('network'); + $existe = 0; + $this->db->trans_begin(); + foreach ($_POST['id_country'] AS $country) { + $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() + { + + 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)) { + $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() + { + + 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)) { + $activations = $this->input->post('activations'); + $desactivation = $this->input->post('desactivations'); + + $this->db->trans_begin(); + if (!empty($_POST['activations'])) { + foreach ($_POST['activations'] AS $network) { + + $data = array('status' => 1); + $this->db->where('id', $network); + $this->db->update('networks', $data); + + } + } + if (!empty($_POST['desactivations'])) { + foreach ($_POST['desactivations'] AS $network) { + + $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() + { + + 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)) { + $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) { + + $link = "https://ilink-app.com/backofficebeta/index.php/Admin_password/?token=" . $token; + $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() + { + + 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)) { + $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() + { + + 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)) { + $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() + { + + 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_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(); + + + $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['active'] = "members"; + $data['message'] = "$number codes have been added!"; + + + $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['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(); + $data['game_pays'] = $this->user_model->getGameCountry(); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['email'] = $this->session->userdata('email'); + + $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(); + $data['firstname'] = $this->session->userdata('firstname'); + $data['lastname'] = $this->session->userdata('lastname'); + $data['email'] = $this->session->userdata('email'); + + + $this->load->view('header_gestion', $data); + $this->load->view('codeg'); + $this->load->view('footer'); + } + + } + + private function randomString($length = 10) + { + $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]; + } + return $str; + + } + + 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 { + + $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['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); + $data['alert'] = ""; + $data['active'] = "geoloc"; + $number_geolocalisation = array(); + $network_geolocalisation = array(); + $count = 0; + + foreach ($data['networks']->result() AS $row) { + $number_geolocalisation[$count] = $this->user_model->getPointGeolocalised($row->id, $data['agent']->first_row()->lastname); + $network_geolocalisation[$count] = $row->name; + $count++; + } + $data['current_agent'] = $data['agent']->first_row()->lastname; + $data["number_geolocalisation"] = $number_geolocalisation; + $data["network_geolocalisation"] = $network_geolocalisation; + $data["total"] = $count; + $data['assigned_networks'] = $this->user_model->getAllAssignedNetworks(); + + + $this->load->view('header_gestion', $data); + $this->load->view('gestion_geolocalisation'); + $this->load->view('footer'); + } + } + + public function infos_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 { + + 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; + + foreach ($data['networks']->result() AS $row) { + $number_geolocalisation[$count] = $this->user_model->getPointGeolocalised($row->id, $lastname); + $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(); + + + $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; + + if ($data['agent'] != false) { + foreach ($data['agent']->result() AS $row1) { + if (!strstr($row1->lastname, "Super -") and !strstr($row1->lastname, "Airtel")) { + $totalGeo = 0; + $totalGeoCorrect = 0; + $agent[$countA][0] = $row1->lastname; + foreach ($data['networks']->result() AS $row2) { + $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++; + } + } + } + + foreach ($data['networks']->result() AS $row) { + $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; + $data['current_agent'] = $data['agent']->first_row()->lastname; + $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(); + + + $this->load->view('header_gestion', $data); + $this->load->view('gestion_campagne'); + $this->load->view('footer'); + } + } + + public function redirect_info_agent() + { + + 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($_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; + + foreach ($data['networks']->result() AS $row) { + $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(); + + + $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['list'] = $this->user_model->getMembers($pays); + $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); + $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'] = ""; + + $this->load->view('header_gestion', $data); + $this->load->view('game'); + $this->load->view('footer'); + } + } + + public function activerGame() + { + 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'); + $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() + { + 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'); + $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() + { + 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)) { + $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); + if ($pays_name != false) { + $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() + { + + 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'); + } + } + + public function get_user() + { + + 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)) { + $nom = $this->input->post('nom'); + + $phone = $this->input->post('phone'); + $simple_users = null; + 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 . "%'"; + $nom_condition = 'AND lastname IS NOT NULL'; + $simple_users = $this->user_model->get_simple_user($phone, '%'); + } elseif ($phone == '' && $nom != '') { + $phone_condition = 'phone IS NOT NULL'; + $nom_condition = "AND lastname LIKE '%" . $nom . "%'"; + $simple_users = $this->user_model->get_simple_user('%', $nom); + } elseif ($phone == '' && $nom == '') { + $phone_condition = 'phone IS NOT NULL'; + $nom_condition = 'AND lastname IS NOT NULL'; + } + + $transac = $this->input->post('transac'); + if ($transac != '') { + $transac_condition = "AND transactionNumber LIKE'" . $transac . "%'"; + } else { + $transac_condition = 'AND transactionNumber IS NOT NULL'; + } + $code = $this->input->post('code'); + if ($code != '') { + $code_condition = "AND code_membre = '" . $code . "'"; + } else { + $code_condition = 'AND code_membre IS NOT NULL'; + } + + $where_clause = "WHERE " . $phone_condition . ' ' . $transac_condition . ' ' . $code_condition . ' ' . $nom_condition; + + $res = $this->user_model->get_user($where_clause); + + if ($res != false) { + $ville = $this->session->userdata('current_ville'); + $hyper = $this->session->userdata('current_hyper'); + $pays = $this->session->userdata('current_pays'); + $count_users = $res->num_rows(); + if ($simple_users != null) { + $count_users = $res->num_rows() + $simple_users->num_rows(); + } + + $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'); + } 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'] = 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'); + } + } + } + } + + public function update_info_user() + { + + 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)) { + $id = $_POST['user_id']; + $phone = $_POST['contact']; + $adresse = $_POST['adresse']; + $email = $_POST['email']; + $nom = $_POST['nom']; + $res = $this->user_model->update_user_infos($nom, $adresse, $email, $phone, $id); + if ($res != false) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } else { + + } + } + } + + public function update_info_geolocated() + { + + 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)) { + $id_agent = $_POST['user_id']; + $id_netAg = $_POST['id_netAg']; + $phone = $_POST['contact']; + $transac = $_POST['transac']; + $adresse = $_POST['adresse']; + $email = $_POST['email']; + $nom = $_POST['nom']; + $res = $this->user_model->update_geolocated_infos($nom, $adresse, $email, $id_agent, $transac, $phone, $id_netAg); + if ($res != false) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } else { + + } + } + } + + public function pub() + { + + 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['countries_list'] = $this->user_model->getPubCountries(); + $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'); + } + } + + public function changePubState() + { + + 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)) { + $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); + } + if ($res != false) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } else { + + } + } + } + + public function addPubRow() + { + 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)) { + $id_country = $_POST['country_id']; + $res = $this->user_model->createPubRow($id_country); + if ($res != false) { + 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')) { + + $network_id = $this->input->get('id'); + if($this->input->get('history')){ + $this->historique($network_id,$this->input->get('d'),$this->input->get('f'),$this->input->get('history')); + }else{ + $taux = $this->user_model->getTaux($network_id); + if ($taux != null) { + $taux = $taux->first_row(); + $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; + $data['transactions'] = $this->user_model->getTransactions(null,null,$network_id); + $totalCommissionBanque = 0; + if($data['transactions']){ + foreach ($data['transactions']->result() as $row) { + $totalCommissionBanque += $row->commission_banque; + } + } + $data['totalCommissionBanque'] = $totalCommissionBanque ; + } else { + + $data["taux_client_r"] = "N/A"; + $data["taux_client_d"] = "N/A"; + $data["taux_ag_r"] = "N/A"; + $data["taux_ag_d"] = "N/A"; + $data["taux_sup_r"] = "N/A"; + $data["taux_sup_d"] = "N/A"; + $data['taux_bq_d'] = "N/A"; + $data['taux_bq_r'] = "N/A"; + $data['frais_d'] = "N/A"; + $data['totalCommissionBanque'] = "N/A"; + $data["transactions"] = false; + } + + $hyper = $this->user_model->getNetworkHyper($network_id)->first_row(); + $data['walletHyper'] = $this->user_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; + } +// $data['agentWalletInfos'] = $this->user_model->getInfosWalletAgentForHyper($network_id); + $data['active'] = "wallet"; + $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_wallet'); + $this->load->view('footer'); + } + + + } else { + + $data['active'] = "wallet"; + $data['alert'] = ""; + $data['game_pays'] = $this->user_model->getGameCountry(); + $data['networks'] = $this->user_model->getAllActivatedNetworks(); + $this->load->view('header_gestion', $data); + $this->load->view('gestion_wallets'); + $this->load->view('footer'); + } + } + } + + public function config_wallet($method = 'create') + { + if($this->isLogged()){ + if (isset($_POST)) { + + $network_id = $_POST['network_id']; + if($method == 'create') + { + $res = $this->user_model->addConfigWallet($network_id , 0 , 0, 0 ,0 , 0, 0, 0 , 0 , 0); +// if($res) +// $this->generateAllWallets($network_id); + + } + else if($method = 'update'){ + + $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']; + + $res = $this->user_model->updateConfigWallet($network_id , $taux_client_r , $taux_client_d , $taux_ag_r ,$taux_ag_d , $taux_sup_r , $taux_sup_d, $taux_bq_r , $taux_bq_d , $frais_d); + + } + if ($res != false) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + + } + + public function delete_config_wallet() + { + if($this->isLogged()){ + if (isset($_POST)) { + $network_id = $_POST['network_id']; + $res = $this->user_model->deleteConfigWallet($network_id); + if ($res != false) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + + } + + + 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; + } + + public function generateAllWallets(){ + // Asynchrous method + + $network_id = $_POST['network_id']; + $pool = Pool::create(); + $pool->add(function () use ($network_id) { + // Fetch all agents , hyperviseur , superviseur + $f_agents = $this->user_model->getAllAgentsForNetwork($network_id) ; + if ($f_agents){ + foreach($f_agents->result() AS $row){ + //Create wallet if it not exist + $res = $this->user_model->getWallet($row->agent_id); + if($res){ + // Reinitialize the wallet +// $this->user_model->reinitializeWallet($res->first_row()->wallet_id); + }else{ + $this->user_model->addWallet($row->agent_id); + } + } + } + })->then(function () { + + }); + await($pool); + } + + private function historique($network_id ,$startDate ,$endDate, $type) + { + + +$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 == 'transaction') + $data['transactions'] = $this->user_model->getTransactions($startDate , $endDate ,$network_id); + else + $data['transactions'] = $this->user_model->getRecharges($startDate , $endDate ,$network_id); + + $data['active'] = "wallet"; + $data['alert'] = ""; + $data['networks'] = $this->user_model->getAllActivatedNetworks(); + $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; + } + $this->load->view('header_gestion', $data); + if($type == 'transaction') + $this->load->view('historique_transactions'); + else + $this->load->view('historique_recharges'); + $this->load->view('footer'); + } + + + +} + diff --git a/application/models/nano_credit_model.php b/application/models/nano_credit_model.php new file mode 100644 index 00000000..a025d559 --- /dev/null +++ b/application/models/nano_credit_model.php @@ -0,0 +1,99 @@ +db->query($sql, array($has_nano_credit, $limit_min, $limit_max, $id_network)); + } + + public function insertNanoCreditSharedRates($taux_ag, $taux_sup, $taux_hyp, $id_network) + { + $sql = "UPDATE `configWallet` SET `taux_com_ag_nano_credit` = ?, `taux_com_sup_nano_credit` = ? , `taux_com_hyp_nano_credit` = ? WHERE (`id_network` = ? );"; + return $this->db->query($sql, array($taux_ag, $taux_sup, $taux_hyp, $id_network)); + } + + public function getAllIlinkWorldNetworks() + { + $query = $this->db->query("SELECT networks.name AS network,networks.status AS status,networks.id,cc.name AS country,networks.country_id , configWallet.id_network , configWallet.type,cc.currency_code, + configWallet.limite_credit_min , configWallet.limite_credit_max , configWallet.has_nano_credit FROM `networks` + INNER JOIN countries_currencies cc ON networks.country_id=cc.id LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND configWallet.type = 'ilink'"); + if ($query->num_rows() > 0) { + return $query; + } else { + return false; + } + } + + public function getUsersGroups($id_network) + { + $query = $this->db->query("SELECT * FROM infos_users_groups WHERE id_network = '" . $id_network . "'"); + if ($query->num_rows() > 0) { + return $query; + } else { + return false; + } + } + + public function getNanoCreditRates($idConfig, $type = 'nano_credit') + { + $sql = "SELECT * FROM `paliersConfigNanoCredit` WHERE (`idConfig` = ? AND `type` = ? );"; + $query = $this->db->query($sql, array($idConfig, $type)); + if ($query->num_rows() > 0) { + return $query; + } else { + return false; + } + } + + public function deleteNanoCreditRates($idConfig, $type = 'nano_credit') + { + $sql = "DELETE FROM `paliersConfigNanoCredit` WHERE (`idConfig` = ? AND `type` = ? );"; + $query = $this->db->query($sql, array($idConfig, $type)); + return $query; + } + + public function addNanoCreditRates($idConfig, $duree, $valeur, $type = 'nano_credit') + { + $sql = "INSERT INTO `paliersConfigNanoCredit` (`duree_mois`, `taux`, `idConfig` ,`type`) VALUES (?,?,?,?);"; + $query = $this->db->query($sql, array($duree, $valeur, $idConfig, $type)); + return $query; + } + + public function getUserDemandesCredit($debut, $fin, $id_network) + { + $chain = $debut ? " AND date_creation BETWEEN '" . $debut . "' AND '" . $fin . "'" : ""; + $query = $this->db->query("SELECT * + FROM infos_users_demandes_credits + WHERE `id_network`='" . $id_network . "'" . $chain); + if ($query->num_rows() > 0) { + return $query; + } else { + return false; + } + } + + public function getUsersSavings($debut, $fin, $id_network) + { + $chain = $debut ? " AND date_creation BETWEEN '" . $debut . "' AND '" . $fin . "'" : ""; + $query = $this->db->query("SELECT * + FROM infos_users_epargnes + WHERE `id_network`='" . $id_network . "'" . $chain); + if ($query->num_rows() > 0) { + return $query; + } else { + return false; + } + } +} diff --git a/bower.json b/bower.json index c24bdaaa..9e519d17 100755 --- a/bower.json +++ b/bower.json @@ -60,7 +60,6 @@ "jquery-ui": "1.11.4", "toastr": "^2.1.3", "js-xlsx": "^0.16.8", - "file-saver": "^2.0.4", - "google-material-icons": "^2.2.1" + "file-saver": "^2.0.4" } }