From 655c9c560342ddb3d6ea010d4df3086e2d6d2869 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 24 May 2021 08:40:09 +0100 Subject: [PATCH] Add settings menu in admin panel --- application/controllers/Gestion.php | 84 ++++++- application/controllers/Users.php | 2 +- application/language/english/message_lang.php | 7 + application/language/french/message_lang.php | 6 + application/models/User_model.php | 13 ++ application/views/gestion_settings.php | 214 ++++++++++++++++++ application/views/header_gestion.php | 5 + application/views/login.php | 13 ++ 8 files changed, 335 insertions(+), 9 deletions(-) create mode 100755 application/views/gestion_settings.php diff --git a/application/controllers/Gestion.php b/application/controllers/Gestion.php index 7c78bb46..df5b23cb 100755 --- a/application/controllers/Gestion.php +++ b/application/controllers/Gestion.php @@ -673,15 +673,18 @@ class Gestion extends CI_Controller 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; + do{ + $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]; + } + $q = $this->db->get_where('codeGenerer',['code_membre' => $str]); + }while($q->num_rows() != 0); + return $str; } public function geolocalisation() @@ -2530,5 +2533,70 @@ class Gestion extends CI_Controller } } + public function settings(){ + if ($this->isLogged()) { + $data['active'] = "settings"; + $data['alert'] = ""; + $data['game_pays'] = $this->user_model->getGameCountry(); + $data['pas_chargement'] = $this->user_model->getAdminConfig('pas_chargement'); + $data['active_pub'] = $this->user_model->getAdminConfig('active_pub', 'bool'); +// $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'); + } + } + + public function update_settings(){ + 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'); + if(isset($pas)){ + $result = $this->user_model->insertAdminConfig('pas_chargement', $pas); + } + + if(isset($jours)){ + $result = $this->user_model->insertAdminConfig('jours_calendaires', $jours); + } + + if(isset($default_locality)){ + $result = $this->user_model->insertAdminConfig('default_locality', $default_locality,''); + } + + + if(isset($enable_sms_notifications)){ + $result = $this->user_model->insertAdminConfig('enable_sms_notifications', $enable_sms_notifications, 'bool'); + + } + + if(isset($office_penalty_percent)){ + $result = $this->user_model->insertAdminConfig('office_penalty_percent', $office_penalty_percent); + } + + if(isset($month_delay_penalty_percent)){ + $result = $this->user_model->insertAdminConfig('month_delay_penalty_percent', $month_delay_penalty_percent); + } + + if(isset($payment_deadline_date)){ + $result = $this->user_model->insertAdminConfig('payment_deadline_date', $payment_deadline_date, 'date'); + } + + if ($result) { + echo json_encode("200"); + } else { + echo json_encode("500"); + } + } + } + } diff --git a/application/controllers/Users.php b/application/controllers/Users.php index 5db48b31..26d9feef 100755 --- a/application/controllers/Users.php +++ b/application/controllers/Users.php @@ -242,7 +242,7 @@ $token_query = $this->db->query("SELECT token FROM admin WHERE email='".$email."'"); $token = $token_query->first_row()->token; - $link = "https://ilink-app.com/backofficebeta/index.php/Admin_password/?token=".$token; + $link = base_url("index.php/Admin_password/?token=".$token); $this->load->library('email'); $this->email->from('noreply@ilink-app.com', 'iLink World'); diff --git a/application/language/english/message_lang.php b/application/language/english/message_lang.php index eeca86b2..fdbccddc 100755 --- a/application/language/english/message_lang.php +++ b/application/language/english/message_lang.php @@ -617,4 +617,11 @@ $lang['payment_done'] = "Payment made"; $lang['commission_payments_history'] = "Commission payment history"; $lang['initial_commission'] = "Initial commission"; $lang['final_commission'] = "Final commission"; +//Settings +$lang['settings'] = "Settings"; +$lang['settings_updated'] = "Update settings"; +$lang['steps_map_loading'] = "Number of agents geolocated by steps on the map"; +$lang['sms_notifications'] = "SMS notifications"; +$lang['advertising'] = "Advertising"; + ?> diff --git a/application/language/french/message_lang.php b/application/language/french/message_lang.php index 662927c0..527b4269 100755 --- a/application/language/french/message_lang.php +++ b/application/language/french/message_lang.php @@ -629,4 +629,10 @@ $lang['payment_done'] = "Paiement effectué"; $lang['commission_payments_history'] = "Historique des paiements de commission"; $lang['initial_commission'] = "Commission initiale"; $lang['final_commission'] = "Commission finale"; +//Settings +$lang['settings'] = "Paramètres"; +$lang['settings_updated'] = "Mise à jour des paramètres"; +$lang['steps_map_loading'] = "Nombre d'agents géolocalisés par pas sur la carte"; +$lang['sms_notifications'] = "Notifications par SMS"; +$lang['advertising'] = "Publicité"; ?> diff --git a/application/models/User_model.php b/application/models/User_model.php index a4bba4ce..06aa6852 100755 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -2595,6 +2595,19 @@ class User_model extends CI_Model return ($query->num_rows() > 0) ? $query : false; } + public function getAdminConfig($config_name ,$valueType = 'int'){ + $query = $this->db->query("SELECT * FROM `adminConfig` WHERE `cle`='".$config_name."' "); + $chain = empty($valueType) ? '' : '_'.$valueType; + return$query->num_rows()>0 ? $query->first_row()->{'valeur'.$chain} : false; + } + + public function insertAdminConfig($config_name, $value , $valueType = 'int'){ + $chain = empty($valueType) ? '' : '_' . $valueType; + $data = array('valeur' . $chain => $value); + $this->db->where('cle', $config_name); + return $this->db->update('adminConfig', $data); + } + // Obtenir l'heure en fonction de l'id du reseau public function getCurrentTimeByNetworkID($id_network){ $query = $this->db->query("SELECT code_country FROM countries c INNER JOIN networks n on n.country_id = c.id WHERE n.id = '$id_network'"); diff --git a/application/views/gestion_settings.php b/application/views/gestion_settings.php new file mode 100755 index 00000000..ece813b8 --- /dev/null +++ b/application/views/gestion_settings.php @@ -0,0 +1,214 @@ + + + + + + + + + + + +
+ +
+ +

+ lang->line('settings'); ?> +

+ +
+ +

Erreur!

+ +
+ + +
+ +

Success!

+ +
+ + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

+ +

lang->line('steps_map_loading'); ?>

+
+
+ +
+
+
+ + + +lang->line($active_pub ? 'Oui' : 'Non')?> +lang->line('sms_notifications'); ?> + + + + + + +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/header_gestion.php b/application/views/header_gestion.php index 8212a12f..be7e8b5f 100755 --- a/application/views/header_gestion.php +++ b/application/views/header_gestion.php @@ -190,6 +190,11 @@ lang->line('operators'); ?> +
  • "> + + lang->line('settings'); ?> + +
  • diff --git a/application/views/login.php b/application/views/login.php index 61357549..7e8bbe99 100755 --- a/application/views/login.php +++ b/application/views/login.php @@ -173,6 +173,19 @@ increaseArea: '20%' // optional }); }); + + $("#eyes").on('click', function(event) { + if ($("#user_password").attr("type") == "text") { + $("#user_password").attr('type', 'password'); + $("#eyes").addClass("glyphicon-eye-close"); + $("#eyes").removeClass("glyphicon-eye-open"); + } else if ($('#user_password').attr("type") == "password") { + $('#user_password').attr('type', 'text'); + $('#eyes').removeClass("glyphicon-eye-close"); + $('#eyes').addClass("glyphicon-eye-open"); + } + }); +