343 lines
16 KiB
PHP
Executable File
343 lines
16 KiB
PHP
Executable File
<!DOCTYPE html>
|
||
<html lang="<?= $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en' ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title><?= $this->lang->line("Demandes d'adhésions et codes valides"); ?> | Admin</title>
|
||
|
||
<!-- CSS -->
|
||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap.min.css">
|
||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.4.1/css/buttons.bootstrap.min.css">
|
||
<link rel="stylesheet" href="<?= base_url('bower_components/bootstrap/dist/css/bootstrap.min.css') ?>">
|
||
<link rel="stylesheet" href="<?= base_url('bower_components/font-awesome/css/font-awesome.min.css') ?>">
|
||
<link rel="stylesheet" href="<?= base_url('dist/css/AdminLTE.min.css') ?>">
|
||
<link rel="stylesheet" href="<?= base_url('dist/css/skins/_all-skins.min.css') ?>">
|
||
|
||
<style>
|
||
div.dataTables_wrapper { width: 100%; margin: 0 auto; }
|
||
.action-buttons { display: flex; gap: 6px; justify-content: center; }
|
||
</style>
|
||
</head>
|
||
<body class="hold-transition skin-blue sidebar-mini">
|
||
<div class="content-wrapper">
|
||
|
||
<!-- Content Header -->
|
||
<section class="content-header">
|
||
<?php if(isset($alert) && $alert == "ok"): ?>
|
||
<?php if(isset($success) && $success != "ok"): ?>
|
||
<div class='alert alert-danger alert-dismissible'>
|
||
<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
|
||
<h4><i class='icon fa fa-ban'></i> Error!</h4>
|
||
<?= $message; ?>
|
||
</div>
|
||
<?php else: ?>
|
||
<div class="alert alert-success alert-dismissible">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<h4><i class="icon fa fa-check"></i> Success!</h4>
|
||
<?= $message; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<h1><?= $this->lang->line("Demandes d'adhésions et codes valides"); ?></h1>
|
||
</section>
|
||
|
||
<!-- Main content -->
|
||
<section class="content">
|
||
<div class="row">
|
||
|
||
<!-- TABLEAU 1 : DEMANDES D'ADHÉSION -->
|
||
<div class="col-md-6">
|
||
<div class="box box-primary">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title"><?= $this->lang->line("Demandes adhésion"); ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<table id="validated" class="table table-bordered table-striped" style="width:100%">
|
||
<thead>
|
||
<tr>
|
||
<th><?= $this->lang->line("Téléphone"); ?></th>
|
||
<th><?= $this->lang->line("Parrain"); ?></th>
|
||
<th><?= $this->lang->line("Reseau"); ?></th>
|
||
<th><?= $this->lang->line("Statut"); ?></th>
|
||
<th><?= $this->lang->line("Date de la demande"); ?></th>
|
||
<th><?= $this->lang->line("Actions"); ?></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php if($list_dem && $list_dem->num_rows() > 0): ?>
|
||
<?php foreach($list_dem->result() as $row): ?>
|
||
<?php
|
||
// Logique d'affichage du statut
|
||
$isProcessed = ($row->etat == 1);
|
||
$statusLabel = $isProcessed ? $this->lang->line("traitée") : $this->lang->line("Non traitée");
|
||
$badgeClass = $isProcessed ? 'label-success' : 'label-warning';
|
||
?>
|
||
<tr>
|
||
<td><?= $row->phone ?></td>
|
||
<td><?= $row->code_membre ?></td>
|
||
<td><?= $row->network ?></td>
|
||
<td class="text-center">
|
||
<span class="label <?= $badgeClass ?>"><?= $statusLabel ?></span>
|
||
</td>
|
||
<td><?= $row->date_creation ?></td>
|
||
<td class="text-center">
|
||
<!-- Affichage conditionnel du bouton supprimer -->
|
||
<?php if(!$isProcessed): // Si non traitée (etat == 0) ?>
|
||
<button class="btn btn-danger btn-sm btn-delete-request"
|
||
data-id="<?= $row->phone ?>"
|
||
title="<?= $this->lang->line('Supprimer'); ?>">
|
||
<i class="fa fa-trash"></i>
|
||
</button>
|
||
<?php else: ?>
|
||
<span class="text-muted">-</span>
|
||
<?php endif; ?>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- TABLEAU 2 : CODES VALIDES -->
|
||
<div class="col-md-6">
|
||
<div class="box box-success">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title"><?= $this->lang->line("Codes valides"); ?></h3>
|
||
</div>
|
||
<div class="box-body">
|
||
<table id="unvalidated" class="table table-bordered table-striped" style="width:100%">
|
||
<thead>
|
||
<tr>
|
||
<th><?= $this->lang->line("Code"); ?></th>
|
||
<th><?= $this->lang->line("Catégorie"); ?></th>
|
||
<th><?= $this->lang->line("Statut"); ?></th>
|
||
<th><?= $this->lang->line("Créer le"); ?></th>
|
||
<th><?= $this->lang->line("Parrain"); ?></th>
|
||
<th><?= $this->lang->line("Actions"); ?></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php if($list_codes && $list_codes->num_rows() > 0): ?>
|
||
<?php foreach($list_codes->result() as $row): ?>
|
||
<?php
|
||
// Logique d'affichage du statut
|
||
$isAssigned = ($row->etat == 1);
|
||
$statusLabel = $isAssigned ? $this->lang->line("assigné") : $this->lang->line("Non assigné");
|
||
$badgeClass = $isAssigned ? 'label-success' : 'label-warning';
|
||
?>
|
||
<tr>
|
||
<td><?= $row->code_membre ?></td>
|
||
<td><?= $row->category ?></td>
|
||
<td class="text-center">
|
||
<span class="label <?= $badgeClass ?>"><?= $statusLabel ?></span>
|
||
</td>
|
||
<td><?= $row->date_creation ?></td>
|
||
<td><?= $row->code_parrain ?></td>
|
||
<td class="text-center">
|
||
<?php if(!$isAssigned): // Si non assigné (etat == 0) ?>
|
||
<button class="btn btn-danger btn-sm btn-delete-code"
|
||
data-id="<?= $row->code_membre ?>"
|
||
title="<?= $this->lang->line('Supprimer'); ?>">
|
||
<i class="fa fa-trash"></i>
|
||
</button>
|
||
<?php else: ?>
|
||
<span class="text-muted">-</span>
|
||
<?php endif; ?>
|
||
</td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</section>
|
||
</div>
|
||
|
||
<!-- =======================================================
|
||
MODALS (Sortis des boucles pour la performance)
|
||
======================================================= -->
|
||
|
||
<!-- Modal Suppression Demande -->
|
||
<div class="modal fade" id="deleteRequestModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||
<h4 class="modal-title"><?= $this->lang->line('Confirmer la suppression'); ?></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p class="error-text">
|
||
<i class="fa fa-warning modal-icon text-yellow"></i>
|
||
<?= $this->lang->line('Message suppression'); ?> <strong id="del_req_phone"></strong> ?
|
||
</p>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
|
||
<a href="#" id="btn_confirm_del_req" class="btn btn-danger"><?= $this->lang->line('Supprimer'); ?></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Modal Suppression Code -->
|
||
<div class="modal fade" id="deleteCodeModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||
<h4 class="modal-title"><?= $this->lang->line('Confirmer la suppression'); ?></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<p class="error-text">
|
||
<i class="fa fa-warning modal-icon text-yellow"></i>
|
||
<?= $this->lang->line('Message suppression code'); ?> <strong id="del_code_val"></strong> ?
|
||
</p>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
|
||
<a href="#" id="btn_confirm_del_code" class="btn btn-danger"><?= $this->lang->line('Supprimer'); ?></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- JS Dependencies -->
|
||
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
|
||
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
|
||
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
|
||
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap.min.js"></script>
|
||
<!-- Export Scripts -->
|
||
<script src="https://cdn.datatables.net/buttons/2.4.1/js/dataTables.buttons.min.js"></script>
|
||
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.bootstrap.min.js"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
|
||
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
|
||
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
// Config DataTables commune
|
||
const exportConfig = [
|
||
'pageLength',
|
||
{ extend: 'excelHtml5', className: 'btn-success btn-sm' },
|
||
{ extend: 'csvHtml5', className: 'btn-info btn-sm' }
|
||
];
|
||
|
||
const dtOptions = {
|
||
"pageLength": 10,
|
||
"ordering": true,
|
||
"scrollX": true,
|
||
dom: "<'row'<'col-sm-6'B><'col-sm-6'f>>t<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||
buttons: exportConfig,
|
||
language: {
|
||
url: "<?= base_url('assets/plugins/datatables/i18n/' . ($this->session->userdata('site_lang') == 'french' ? 'French' : 'English') . '.json') ?>"
|
||
}
|
||
};
|
||
|
||
// Init Tables
|
||
$('#validated').DataTable(dtOptions);
|
||
$('#unvalidated').DataTable(dtOptions);
|
||
|
||
// --- GESTION SUPPRESSION DEMANDE (TABLE 1) ---
|
||
$(document).on("click", ".btn-delete-request", function() {
|
||
let phone = $(this).data('id');
|
||
let baseUrl = "<?= base_url(); ?>";
|
||
|
||
// Mise à jour du modal
|
||
$("#del_req_phone").text(phone);
|
||
$("#btn_confirm_del_req").attr("href", baseUrl + "Member_code_admin/delete/?recordId=" + phone);
|
||
|
||
// Ouverture modal
|
||
$("#deleteRequestModal").modal("show");
|
||
});
|
||
|
||
// --- GESTION SUPPRESSION CODE (TABLE 2) ---
|
||
$(document).on("click", ".btn-delete-code", function() {
|
||
let code = $(this).data('id');
|
||
let baseUrl = "<?= base_url(); ?>";
|
||
|
||
// Mise à jour du modal
|
||
$("#del_code_val").text(code);
|
||
$("#btn_confirm_del_code").attr("href", baseUrl + "Member_code_admin/suppress/?recordId=" + code);
|
||
|
||
// Ouverture modal
|
||
$("#deleteCodeModal").modal("show");
|
||
});
|
||
|
||
|
||
// --- GESTION AJAX PAYS / VILLE (Code existant optimisé) ---
|
||
// Note: Assurez-vous que les éléments #pays, #hyper existent dans votre HTML (non présents dans votre snippet original)
|
||
$('#pays').change(function(){
|
||
var pays = $(this).val();
|
||
$.ajax({
|
||
url:'<?= base_url('Admin/getHypByPays')?>',
|
||
type: 'post',
|
||
data: {pays: pays},
|
||
dataType: 'json',
|
||
success: function(data){
|
||
|
||
// Gestion dynamique du select 'hyper'
|
||
var select = $('#hyper');
|
||
if(select.length === 0){
|
||
$('#grp-pays').empty().append("<select class='form-control input-lg' name='hyper' required id='hyper'></select>");
|
||
select = $('#hyper');
|
||
}
|
||
select.empty();
|
||
|
||
if(data.length > 0){
|
||
$.each(data, function(index, item) {
|
||
select.append('<option value=' + item.code_membre + '>' + item.lastname +'-' + item.network + ' ('+ item.code_membre +')</option>');
|
||
});
|
||
|
||
// Chargement automatique des villes pour le premier élément
|
||
loadVilles(data[0].code_membre, pays);
|
||
} else {
|
||
$('#ville').empty();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
$('#hyper').change(function(){
|
||
var code = $(this).val();
|
||
// Récupérer le pays si nécessaire, ici on passe undefined ou on stocke le pays globalement
|
||
loadVilles(code, $('#pays').val());
|
||
});
|
||
|
||
function loadVilles(code, pays) {
|
||
$.ajax({
|
||
url:'<?= base_url('Admin/getVilleByHyp')?>',
|
||
type: 'post',
|
||
data: {code: code, pays: pays}, // Ajout pays si l'API l'attend
|
||
dataType: 'json',
|
||
success: function(list){
|
||
|
||
var select = $('#ville');
|
||
if(select.length === 0){
|
||
$('#grp-ville').empty().append("<select class='form-control input-lg' name='ville' required id='ville'></select>");
|
||
select = $('#ville');
|
||
}
|
||
select.empty();
|
||
|
||
if(list.length > 0){
|
||
$.each(list, function(index, item) {
|
||
select.append('<option value=' + item.town_id + '>' + item.town +'</option>');
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|