Add settings menu in admin panel
This commit is contained in:
parent
0d35ecb601
commit
655c9c5603
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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";
|
||||
|
||||
?>
|
||||
|
|
|
@ -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é";
|
||||
?>
|
||||
|
|
|
@ -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'");
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
<link rel="stylesheet" href="<?php echo base_url('bower_components/jvectormap/jquery-jvectormap.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
|
||||
<!-- Date Picker -->
|
||||
<link rel="stylesheet" href="<?php echo base_url('bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.css') ?>">
|
||||
<link rel="stylesheet" href="<?php echo base_url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css') ?>">
|
||||
|
||||
<style type="text/css">
|
||||
/*@import url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css');*/
|
||||
/*@import url('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.css');*/
|
||||
.datepicker table tr td.disabled,
|
||||
.datepicker table tr td.disabled:hover {
|
||||
color: #b90000;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
?>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
|
||||
<h1>
|
||||
<?php echo $this->lang->line('settings'); ?>
|
||||
</h1>
|
||||
<?php
|
||||
$site_url = base_url();
|
||||
|
||||
if ($alert == "ok") {
|
||||
|
||||
if (!$success == "ok") {
|
||||
?>
|
||||
<div class='alert alert-danger alert-dismissible col-xs-6'>
|
||||
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
|
||||
<h4><i class='icon fa fa-ban'></i> Erreur!</h4>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<div class="alert alert-success alert-dismissible col-xs-6">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<h4><i class="icon fa fa-check"></i> Success!</h4>
|
||||
<?php echo $message; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="margin">
|
||||
<button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#modal-update"
|
||||
style="width: 100%"><?php echo $this->lang->line('Modifier la configuration') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-xs-6">
|
||||
<!-- small box -->
|
||||
<div class="small-box bg-aqua">
|
||||
<div class="inner">
|
||||
<h3><?= $pas_chargement ?></h3>
|
||||
|
||||
<p><?php echo $this->lang->line('steps_map_loading'); ?></p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-map"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="col-lg-3 col-xs-6">-->
|
||||
<!-- <div class="small-box bg-blue">-->
|
||||
<!-- <div class="inner">-->
|
||||
<!-- <h3>--><?php //= $this->lang->line($active_pub ? 'Oui' : 'Non')?><!--</h3>-->
|
||||
<!-- <p>--><?php //echo $this->lang->line('sms_notifications'); ?><!--</p>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="icon">-->
|
||||
<!-- <i class="fa fa-send-o"></i>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
<div class="modal fade" id="modal-update">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h3 class="modal-title"><?php echo $this->lang->line('settings'); ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="settingsForm">
|
||||
<div class="form-group">
|
||||
<label
|
||||
class="col-form-label"><?php echo $this->lang->line('steps_map_loading'); ?></label>
|
||||
<input type="number" min="0" required class="form-control"
|
||||
id="pas" name="pas" value="<?= $pas_chargement ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="form-group" style="margin-bottom: 40px">-->
|
||||
<!-- <input type="checkbox" name="sms_notifications" id="sms_notifications">-->
|
||||
<!-- <label for="sms_notifications">--><?php //echo $this->lang->line('sms_notifications'); ?><!--</label>-->
|
||||
<!-- </div>-->
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default pull-left"
|
||||
data-dismiss="modal"><?php echo $this->lang->line('Fermer'); ?></button>
|
||||
<button type="button" id="updateSettings"
|
||||
class="btn btn-primary"><?php echo $this->lang->line('Continuer'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
<!-- jQuery 3 -->
|
||||
<script src="<?php echo base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<script src="<?php echo base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
|
||||
<!-- DataTables -->
|
||||
<script src="<?php echo base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
|
||||
<script src="<?php echo base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
|
||||
<!-- Slimscroll -->
|
||||
<script src="<?php echo base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
|
||||
<!-- FastClick -->
|
||||
<script src="<?php echo base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="<?php echo base_url('dist/js/adminlte.min.js') ?>"></script>
|
||||
<!-- AdminLTE for demo purposes -->
|
||||
<script src="<?php echo base_url('dist/js/demo.js') ?>"></script>
|
||||
|
||||
<script src="<?php echo base_url('bower_components/moment/min/moment.min.js') ?>"></script>
|
||||
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
|
||||
<script src="<?php echo base_url('dist/js/sweetalert2.js') ?>"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment-with-locales.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"> </script>
|
||||
|
||||
<script>
|
||||
toastr.options.closeButton = true;
|
||||
toastr.options.closeMethod = 'fadeOut';
|
||||
toastr.options.closeDuration = 5000;
|
||||
toastr.options.closeEasing = 'swing';
|
||||
|
||||
//const format = "<?//=$this->session->userdata('site_lang')?>//" === 'french' ? 'fr' : 'en';
|
||||
//moment.updateLocale(moment.locale(format), {invalidDate: ""}); // Blank text when is invalid date
|
||||
|
||||
//$(document).on("click", ".open-modal", function () {
|
||||
// const default_locality = $(this).data('default_locality');
|
||||
//
|
||||
// $(".modal-body #default_locality").val(default_locality);
|
||||
// $(".modal-body #sms_notifications").prop('checked', <?//=$active_pub?>//);
|
||||
//});
|
||||
|
||||
$('#updateSettings').click(function () {
|
||||
if ($('#settingsForm')[0].checkValidity()) {
|
||||
var pas = parseInt($('#pas').val());
|
||||
// var active_pub = $("#sms_notifications").is(':checked') ? 1 : 0;
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('index.php/Gestion/update_settings')?>',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {pas: pas},
|
||||
success: function (data) {
|
||||
if (data == '200') {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?php echo $this->lang->line('settings_updated')?>",
|
||||
text: "<?php echo $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$('#settingsForm')[0].reportValidity();
|
||||
}
|
||||
});
|
||||
|
||||
//$.fn.datepicker.dates.en.titleFormat="MM";
|
||||
//$(document).ready(function(){
|
||||
// $('#payment_deadline').text(moment("<?//=$payment_deadline_date?>//", 'DD/MM').format('D MMMM'));
|
||||
// $('#payment_deadline_date').datepicker({
|
||||
// format: 'dd/mm',
|
||||
// autoclose: true,
|
||||
// startView: 1,
|
||||
// maxViewMode: "months",
|
||||
// orientation: "bottom left",
|
||||
// });
|
||||
//});
|
||||
</script>
|
|
@ -190,6 +190,11 @@
|
|||
<i class="fa fa-building"></i> <span><?php echo $this->lang->line('operators'); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if($active=="settings"){echo "active";} ?>">
|
||||
<a href="<?php echo base_url('index.php/Gestion/settings') ?>">
|
||||
<i class="ion ion-settings"></i> <span><?php echo $this->lang->line('settings'); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue