correct status on link bank to account
This commit is contained in:
parent
7b9933b0eb
commit
a80b7264d5
|
|
@ -200,7 +200,7 @@
|
|||
<?php
|
||||
$statusStr = 'pending';
|
||||
if($l->is_verified == 1) $statusStr = 'actived';
|
||||
if($l->is_verified == 2) $statusStr = 'rejected';
|
||||
elseif($l->is_verified == 2) $statusStr = 'rejected';
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $i++; ?></td>
|
||||
|
|
|
|||
|
|
@ -1,402 +1,342 @@
|
|||
<link rel="stylesheet" href="<?= base_url('<link rel="stylesheet"
|
||||
href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap.min.css">') ?>">
|
||||
<!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 (Page header) -->
|
||||
|
||||
<!-- Content Header -->
|
||||
<section class="content-header">
|
||||
|
||||
<?php
|
||||
$site_url = base_url();
|
||||
|
||||
if($alert=="ok") {
|
||||
|
||||
if(!$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 {
|
||||
?>
|
||||
<?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; ?>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h1>
|
||||
<?= $this->lang->line("Demandes d'adhésions et codes valides"); ?>
|
||||
</h1>
|
||||
|
||||
<h1><?= $this->lang->line("Demandes d'adhésions et codes valides"); ?></h1>
|
||||
</section>
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
|
||||
<!-- 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>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
<?php
|
||||
|
||||
$sql2 = $list_dem;
|
||||
if($sql2!=false){
|
||||
$numrows=$sql2->num_rows();
|
||||
$num = 3000;
|
||||
if ($numrows > 0) {
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<table id="validated" class="table table-bordered table-striped">
|
||||
<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("Supprimer"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// output data of each row
|
||||
foreach($sql2->result() as $row) {
|
||||
$etat = $this->lang->line("Non traitée");
|
||||
if($row->etat==1){
|
||||
$etat = $this->lang->line("traitée");
|
||||
}
|
||||
$num ++;
|
||||
//$member_code = randomString1(10);
|
||||
echo "<tr>
|
||||
<td> $row->phone</td>
|
||||
<td >$row->code_membre </td>
|
||||
<td>$row->network</td>
|
||||
<td>$etat</td>
|
||||
<td >".$row->date_creation."</td>";
|
||||
if($row->etat==0){
|
||||
echo "
|
||||
<td>
|
||||
<a href='#myModal-1".$num."' role='button' class='btn btn-block btn-danger' data-toggle='modal'><i class='fa fa-remove'></i></a>
|
||||
<div class='modal fade' id='myModal-1".$num."' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
|
||||
<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>
|
||||
<h4 class='modal-title'>".$this->lang->line('Confirmer la suppression')."</h4>
|
||||
</div>
|
||||
<div class='modal-body'>
|
||||
<p class='error-text'><i class='icon-warning-sign modal-icon'></i>".$this->lang->line('Message suppression')." ". $row->phone."?</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='".$site_url."Member_code_admin/delete/?recordId=".$row->phone."' role='button' class='btn btn-danger'>
|
||||
".$this->lang->line('Supprimer')."</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
echo $this->lang->line('Aucune demande');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
|
||||
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<!-- 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>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
<?php
|
||||
|
||||
$sql1 = $list_codes;
|
||||
if($sql1!=false){
|
||||
$numrows=$sql1->num_rows();
|
||||
$num = 0;
|
||||
|
||||
if ($numrows > 0) {
|
||||
?>
|
||||
|
||||
<table id="unvalidated" class="table table-bordered table-striped">
|
||||
<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("Supprimer"); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
|
||||
// output data of each row
|
||||
foreach($sql1->result() as $row) {
|
||||
$etat = $this->lang->line("Non assigné");
|
||||
if($row->etat==1){
|
||||
$etat = $this->lang->line("assigné");
|
||||
}
|
||||
|
||||
$num ++;
|
||||
echo "<tr>
|
||||
<td> $row->code_membre</td>
|
||||
<td>$row->category </td>
|
||||
<td>$etat</td>
|
||||
<td >".$row->date_creation."</td>
|
||||
<td>$row->code_parrain</td>
|
||||
<td>";
|
||||
if($row->etat==0){
|
||||
echo "
|
||||
<a href='#myModal-2".$num."' role='button' class='btn btn-block btn-danger' data-toggle='modal'><i class='fa fa-remove'></i></a>
|
||||
<div class='modal smallfade' id='myModal-2".$num."' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
|
||||
<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>
|
||||
<h4 class='modal-title'>".$this->lang->line('Confirmer la suppression')."</h4>
|
||||
</div>
|
||||
<div class='modal-body'>
|
||||
<p class='error-text'><i class='icon-warning-sign modal-icon'></i>".$this->lang->line('Message suppression code')." ".$row->code_membre."?</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='".$site_url."Member_code_admin/suppress/?recordId=".$row->code_membre."' role='button' class='btn btn-danger' id='delete'>
|
||||
".$this->lang->line('Supprimer')."</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
</div>
|
||||
</td>";
|
||||
|
||||
}
|
||||
|
||||
echo "</tr> ";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
echo $this->lang->line("Aucun membre validé");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->close();
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
|
||||
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- jQuery 2.2.4 -->
|
||||
<!-- =======================================================
|
||||
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>
|
||||
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
|
||||
<!-- DataTables -->
|
||||
<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>
|
||||
<!-- Slimscroll -->
|
||||
<script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
|
||||
<!-- FastClick -->
|
||||
<script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<!-- 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>
|
||||
<!-- AdminLTE for demo purposes -->
|
||||
<script src="<?= base_url('dist/js/demo.js') ?>"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#unvalidated').DataTable()
|
||||
$('#validated').DataTable()
|
||||
$(document).ready(function() {
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#pays').change(function(){
|
||||
var pays = $(this).val();
|
||||
$.ajax({
|
||||
url:'<?= base_url('Admin/getHypByPays')?>',
|
||||
type: 'post',
|
||||
data: {pays: pays},
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
var len = data.length;
|
||||
|
||||
|
||||
if(len > 0){
|
||||
|
||||
var select = document.getElementById('hyper');
|
||||
if(select===null){
|
||||
var grpPays = document.getElementById('grp-pays');
|
||||
$(grpPays).empty();
|
||||
$(grpPays).append("<select class='form-control input-lg' name='hyper' required id='hyper'></select>");
|
||||
select = document.getElementById('hyper');
|
||||
}
|
||||
$(select).empty();
|
||||
|
||||
for (var i in data) {
|
||||
$(select).append('<option value=' + data[i].code_membre + '>' + data[i].lastname +'-' + data[i].network + ' ('+ data[i].code_membre +')</option>');
|
||||
}
|
||||
|
||||
var code = data[0].code_membre;
|
||||
|
||||
$.ajax({
|
||||
url:'<?= base_url('Admin/getVilleByHyp')?>',
|
||||
type: 'post',
|
||||
data: {code: code,pays:pays},
|
||||
dataType: 'json',
|
||||
success: function(list){
|
||||
var len = list.length;
|
||||
|
||||
if(len > 0){
|
||||
|
||||
var select = document.getElementById('ville');
|
||||
if(select===null){
|
||||
var grpVille = document.getElementById('grp-ville');
|
||||
$(grpVille).empty();
|
||||
$(grpVille).append("<select class='form-control input-lg' name='ville' required id='ville'></select>");
|
||||
select = document.getElementById('ville');
|
||||
}
|
||||
$(select).empty();
|
||||
|
||||
for (var i in list) {
|
||||
$(select).append('<option value=' + list[i].town_id + '>' + list[i].town +'</option>');
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
var select = document.getElementById('ville');
|
||||
$(select).empty();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
var select = document.getElementById('hyper');
|
||||
$(select).empty();
|
||||
|
||||
var select2 = document.getElementById('ville');
|
||||
$(select2).empty();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#hyper').change(function(){
|
||||
var code = $(this).val();
|
||||
$.ajax({
|
||||
url:'<?= base_url('Admin/getVilleByHyp')?>',
|
||||
type: 'post',
|
||||
data: {code: code},
|
||||
dataType: 'json',
|
||||
success: function(list){
|
||||
var len = list.length;
|
||||
|
||||
if(len > 0){
|
||||
|
||||
var select = document.getElementById('ville');
|
||||
$(select).empty();
|
||||
|
||||
for (var i in list) {
|
||||
$(select).append('<option value=' + list[i].town_id + '>' + list[i].town +'</option>');
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
var select = document.getElementById('ville');
|
||||
$(select).empty();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
// 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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue