+ Adding payment operators

This commit is contained in:
Djery-Tom 2020-11-06 18:47:42 +01:00
parent 468696abf0
commit 0968cb101b
9 changed files with 214 additions and 193 deletions

View File

@ -2286,33 +2286,35 @@ class Gestion extends CI_Controller
}
}
public function banks()
public function operators()
{
if ($this->isLogged()) {
$data['banks'] = $this->wallet_model->getAllBanksCountries();
$data['operators'] = $this->wallet_model->getAllOperatorsCountries();
$data['pays'] = $this->user_model->getAllPays();
$data['game_pays'] = $this->user_model->getGameCountry();
$data['alert'] = "";
$data['active'] = "banks";
$data['distinct_banks'] = $this->wallet_model->getAllBanks();
$data['active'] = "operators";
$data['distinct_operators'] = $this->wallet_model->getAllOperators();
$data['operators_types'] = $this->db->get('type_operators');
$this->load->view('header_gestion', $data);
$this->load->view('gestion_banques_admin');
$this->load->view('gestion_operateurs_admin');
$this->load->view('footer');
}
}
public function add_bank()
public function add_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$data = array(
'nom' => $this->input->post('name'),
'type' => $this->input->post('type')
);
$query = $this->db->insert('banks', $data);
$query = $this->db->insert('operators', $data);
if ($query) {
echo json_encode("completed");
} else {
@ -2322,14 +2324,14 @@ class Gestion extends CI_Controller
}
}
public function delete_bank()
public function delete_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$id_bank = $this->input->post('id_bank');
$id_operator = $this->input->post('id_operator');
$id_country = $this->input->post('id_country');
$query = $this->wallet_model->deleteBankCountry($id_bank, $id_country);
$query = $this->wallet_model->deleteOperatorCountry($id_operator, $id_country);
if ($query) {
echo json_encode("completed");
} else {
@ -2339,18 +2341,18 @@ class Gestion extends CI_Controller
}
}
public function assign_bank()
public function assign_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$id_bank = $this->input->post('id_bank');
$id_operator = $this->input->post('id_operator');
$existe = 0;
$this->db->trans_begin();
foreach ($_POST['id_country'] AS $country) {
$res = $this->wallet_model->checkIfBankAssignationExist($country, $id_bank);
$res = $this->wallet_model->checkIfOperatorAssignationExist($country, $id_operator);
if ($res == false) {
$data = array('id_country' => $country , 'id_bank' => $id_bank);
$this->db->insert('banks_countries', $data);
$data = array('id_country' => $country , 'id_operator' => $id_operator);
$this->db->insert('operators_countries', $data);
} else {
$existe = $existe + 1;
}
@ -2370,17 +2372,17 @@ class Gestion extends CI_Controller
}
}
public function update_bank()
public function update_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$id_bank = $this->input->post('id_bank');
$id_operator = $this->input->post('id_operator');
$id_country = $this->input->post('id_country');
$name = $this->input->post('name');
$address = $this->input->post('address');
$code = $this->input->post('code');
$res = $this->wallet_model->updateBank($id_bank, $id_country ,$name , $address , $code);
$res = $this->wallet_model->updateOperator($id_operator, $id_country ,$name , $address , $code);
if ($res == true) {
echo json_encode("completed");
@ -2391,7 +2393,7 @@ class Gestion extends CI_Controller
}
}
public function change_bank_status()
public function change_operator_status()
{
if ($this->isLogged()) {
if (isset($_POST)) {
@ -2403,9 +2405,9 @@ class Gestion extends CI_Controller
foreach ($_POST['activations'] AS $row) {
$data = array('status' => 1);
$this->db->where('id_bank', $row['id_bank']);
$this->db->where('id_operator', $row['id_operator']);
$this->db->where('id_country', $row['id_country']);
$this->db->update('banks_countries', $data);
$this->db->update('operators_countries', $data);
}
}
@ -2413,9 +2415,9 @@ class Gestion extends CI_Controller
foreach ($_POST['desactivations'] AS $row) {
$data = array('status' => 0);
$this->db->where('id_bank', $row['id_bank']);
$this->db->where('id_operator', $row['id_operator']);
$this->db->where('id_country', $row['id_country']);
$this->db->update('banks_countries', $data);
$this->db->update('operators_countries', $data);
}
}

View File

@ -1546,12 +1546,12 @@ class Hyperviseur_dash extends CI_Controller
}
}
public function banks()
public function operators()
{
if ($this->isLogged()) {
$data['active'] = "banks";
$data['active'] = "operators";
$data['alert'] = "";
$data['firstname'] = $this->session->userdata('firstname');
$data['lastname'] = $this->session->userdata('lastname');
@ -1563,25 +1563,25 @@ class Hyperviseur_dash extends CI_Controller
$data['category'] = $this->session->userdata('category');
$data['hasWallet'] = $this->wallet_model->getConfigWallet($this->session->userdata('network_id'));
$data['banks'] = $this->wallet_model->getBanksForNetwork($this->session->userdata('network_id'));
$data['operators'] = $this->wallet_model->getOperatorsForNetwork($this->session->userdata('network_id'));
$this->load->view('header_hyp', $data);
$this->load->view('gestion_banques_hyp');
$this->load->view('gestion_operateurs_hyp');
$this->load->view('footer');
}
}
public function active_bank()
public function active_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$data = array(
'id_bank_country' => $this->input->post('id_bank_country'),
'id_operator_country' => $this->input->post('id_operator_country'),
'id_network' => $this->input->post('id_network')
);
$query = $this->db->insert('networks_banks', $data);
$query = $this->db->insert('networks_operators', $data);
if ($query) {
echo json_encode("200");
@ -1592,16 +1592,16 @@ class Hyperviseur_dash extends CI_Controller
}
}
public function deactive_bank()
public function deactive_operator()
{
if ($this->isLogged()) {
if (isset($_POST)) {
$data = array(
'id_bank_country' => $this->input->post('id_bank_country'),
'id_operator_country' => $this->input->post('id_operator_country'),
'id_network' => $this->input->post('id_network')
);
$query = $this->db->delete('networks_banks', $data);
$query = $this->db->delete('networks_operators', $data);
if ($query) {
echo json_encode("200");

View File

@ -538,4 +538,19 @@ $lang['configure_transmitter_network'] = 'Configure the sending network';
$lang['paying_and_transmitting_networks_accounts'] = "Accounts of paying and issuing networks";
$lang['transmitting_networks_accounts'] = 'Accounts of transmitting networks';
$lang['bank_code'] = "Bank code";
$lang['operators'] = "Operators";
$lang['management_operators'] = "Management of operators";
$lang['add_operator'] = "Add an operator";
$lang['no_operator'] = "No operator";
$lang['operator_added'] = "The operator has been added";
$lang['operator_assigned'] = "The operator has been assigned";
$lang['operator_modified'] = "The operator has been modified";
$lang['operator_deleted'] = "The operator has been deleted";
$lang['operator_activated'] = "The operator has been activated";
$lang['operator_deactivated'] = "The operator has been deactivated";
$lang['operator_deactivation'] = "Operator deactivation";
$lang['modify_operator'] = "Modify operator";
$lang['assign_operator_to_country'] = "Assign an operator to a country";
$lang['operator_type'] = "Operator type";
$lang['no_type'] = "No type";
?>

View File

@ -550,5 +550,19 @@ $lang['configure_transmitter_network'] = 'Configurer le réseau émetteur';
$lang['paying_and_transmitting_networks_accounts'] = "Comptes des reseaux payeurs et émetteurs";
$lang['transmitting_networks_accounts'] = 'Comptes des reseaux émetteurs';
$lang['bank_code'] = "Code banque";
$lang['operators'] = "Opérateurs";
$lang['management_operators'] = "Gestion des opérateurs";
$lang['add_operator'] = "Ajouter un opérateur";
$lang['no_operator'] = "Aucun opérateur";
$lang['operator_added'] = "L'opérateur a été ajouté";
$lang['operator_assigned'] = "L'opérateur a été assigné";
$lang['operator_modified'] = "L'opérateur a été modifié";
$lang['operator_deleted'] = "L'opérateur a été supprimé";
$lang['operator_activated'] = "L'opérateur a été activé";
$lang['operator_deactivated'] = "L'opérateur a été désactivé";
$lang['operator_deactivation'] = "Désactivation de l'opérateur";
$lang['modify_operator'] = "Modifier l'opérateur";
$lang['assign_operator_to_country'] = "Assigner un opérateur à un pays";
$lang['operator_type'] = "Type d'opérateur";
$lang['no_type'] = "Aucun type";
?>

View File

@ -862,45 +862,46 @@ INNER JOIN countries_currencies cc ON n.country_id= cc.id INNER JOIN configWalle
return $query;
}
// Banques
public function getAllBanksCountries(){
$query = $this->db->query("SELECT b.id, b.nom as bank_name , bc.adresse as bank_address , bc.code_banque as bank_code , bc.status, c.name as country , c.id as country_id FROM banks_countries bc INNER JOIN banks b ON b.id = bc.id_bank INNER JOIN countries c ON c.id = bc.id_country");
// Operateurs
public function getAllOperatorsCountries(){
$query = $this->db->query("SELECT b.id, b.nom as operator_name , bc.adresse as operator_address , bc.code as operator_code , bc.status, c.name as country , c.id as country_id , top.description_fr as type_fr, top.description_en as type_en
FROM operators_countries bc INNER JOIN operators b ON b.id = bc.id_operator INNER JOIN type_operators top ON b.type = top.code INNER JOIN countries c ON c.id = bc.id_country ");
return $query->num_rows() > 0 ? $query : false ;
}
public function getAllBanks(){
$query = $this->db->query("SELECT * FROM banks");
public function getAllOperators(){
$query = $this->db->query("SELECT o.* , top.description_fr ,top.description_en FROM operators o INNER JOIN type_operators top ON o.type = top.code");
return $query->num_rows() > 0 ? $query : false ;
}
public function checkIfBankAssignationExist($id_country,$id_bank){
$query = $this->db->query("SELECT * FROM banks_countries WHERE id_country ='".$id_country."' AND id_bank='".$id_bank."'");
public function checkIfOperatorAssignationExist($id_country,$id_operator){
$query = $this->db->query("SELECT * FROM operators_countries WHERE id_country ='".$id_country."' AND id_operator='".$id_operator."'");
return $query->num_rows() > 0 ? $query : false ;
}
public function getBank($id_bank){
$query = $this->db->query("SELECT * FROM banks WHERE id='".$id_bank."'");
public function getOperator($id_operator){
$query = $this->db->query("SELECT * FROM operators WHERE id='".$id_operator."'");
return $query->num_rows() > 0 ? $query : false ;
}
public function updateBank($id_bank,$id_country, $name , $address , $code){
$sql = "UPDATE `banks` SET `nom` = ? WHERE (`id` = ?);";
$this->db->query($sql , array($name,$id_bank));
public function updateOperator($id_operator,$id_country, $name , $address , $code){
$sql = "UPDATE `operators` SET `nom` = ? WHERE (`id` = ?);";
$this->db->query($sql , array($name,$id_operator));
$sql = "UPDATE `banks_countries` SET `adresse` = ? , `code_banque` = ? WHERE (`id_bank` = ? AND `id_country` = ?);";
return $this->db->query($sql , array($address,$code,$id_bank,$id_country));
$sql = "UPDATE `operators_countries` SET `adresse` = ? , `code` = ? WHERE (`id_operator` = ? AND `id_country` = ?);";
return $this->db->query($sql , array($address,$code,$id_operator,$id_country));
}
public function deleteBankCountry($id_bank, $id_country){
$sql = "DELETE FROM `banks_countries` WHERE `id_bank` = ? AND `id_country` = ?";
$query = $this->db->query($sql, array($id_bank,$id_country));
public function deleteOperatorCountry($id_operator, $id_country){
$sql = "DELETE FROM `operators_countries` WHERE `id_operator` = ? AND `id_country` = ?";
$query = $this->db->query($sql, array($id_operator,$id_country));
return $query;
}
public function getBanksForNetwork($id_network){
$sql = "SELECT bc.id, b.nom as bank_name , bc.adresse as bank_address, bc.code_banque as bank_code , c.name as country , c.id as country_id , nb.id_network FROM networks n
CROSS JOIN banks_countries bc INNER JOIN banks b ON b.id = bc.id_bank INNER JOIN countries c ON c.id = bc.id_country
LEFT JOIn networks_banks nb ON nb.id_bank_country = bc.id AND nb.id_network = n.id WHERE bc.status = 1 AND n.id = ?";
public function getOperatorsForNetwork($id_network){
$sql = "SELECT bc.id, b.nom as operator_name , bc.adresse as operator_address, bc.code as operator_code , c.name as country , c.id as country_id , nb.id_network , top.description_fr as type_fr, top.description_en as type_en
FROM networks n CROSS JOIN operators_countries bc INNER JOIN operators b ON b.id = bc.id_operator INNER JOIN countries c ON c.id = bc.id_country INNER JOIN type_operators top ON b.type = top.code
LEFT JOIn networks_operators nb ON nb.id_operator_country = bc.id AND nb.id_network = n.id WHERE bc.status = 1 AND n.id = ?";
$query = $this->db->query($sql , array($id_network));
return $query->num_rows() > 0 ? $query : false ;
}

View File

@ -5,7 +5,7 @@
<section class="content-header">
<h1>
<?php echo $this->lang->line('management_banks'); ?>
<?php echo $this->lang->line('management_operators'); ?>
<input type="button" class="btn btn-primary pull-right" id="Bactiver" value="Activer/Désactiver le(s) banque(s)" style="display: none;" />
</h1>
<?php
@ -41,13 +41,13 @@
<div class="col-lg-8">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('banks'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('operators'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<?php
$sql2 = $banks;
$sql2 = $operators;
if($sql2!=false){
$numrows=$sql2->num_rows();
$num = 0;
@ -58,13 +58,13 @@
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Pays'); ?></th>
<th>Type</th>
<th><?php echo $this->lang->line('Nom'); ?></th>
<th><?php echo $this->lang->line('bank_code'); ?></th>
<th>Code</th>
<th><?php echo $this->lang->line('Adresse'); ?></th>
<th align='center'><?php echo $this->lang->line('Statut'); ?></th>
<th align='center'><?php echo $this->lang->line('Activer/Désactiver'); ?></th>
<th align='center'><?php echo $this->lang->line('Modifier'); ?></th>
<th align="center"><?php echo $this->lang->line('Supprimer'); ?></th>
<th align='center'>Action</th>
</tr>
</thead>
<tbody>
@ -75,38 +75,41 @@
if($row->status==0){
$libelle_status = $this->lang->line('Inactif');
}
echo "<tr>
<td align='center'>$num</td>
<td>$row->country</td>
<td >$row->bank_name</td>
<td >$row->bank_code</td>
<td >$row->bank_address</td>
<td align='center'>$libelle_status</td>";
$type = $this->session->userdata('site_lang') === 'french' ? $row->type_fr : $row->type_en;
?>
<tr>
<td align='center'><?= $num?></td>
<td><?= $row->country?></td>
<td><?=$type ?></td>
<td ><?=$row->operator_name ?></td>
<td ><?=$row->operator_code?></td>
<td ><?=$row->operator_address?></td>
<td align='center'><?=$libelle_status?></td>
<?php
if($row->status==0){
echo "<td align='center'><label>
<input type='checkbox' name='activer' class='minimal' data-id-bank='".$row->id."' data-id-country='".$row->country_id."' >
<input type='checkbox' name='activer' class='minimal' data-id-operator='".$row->id."' data-id-country='".$row->country_id."' >
</label>
<label>
<input type='checkbox' name='desactiver' class='minimal-red' disabled data-id-bank='".$row->id."' data-id-country='".$row->country_id."'>
<input type='checkbox' name='desactiver' class='minimal-red' disabled data-id-operator='".$row->id."' data-id-country='".$row->country_id."'>
</label></td>";
}else{
echo "<td align='center'><label>
<input type='checkbox' name='activer' class='minimal' disabled data-id-bank='".$row->id."' data-id-country='".$row->country_id."'>
<input type='checkbox' name='activer' class='minimal' disabled data-id-operator='".$row->id."' data-id-country='".$row->country_id."'>
</label>
<label>
<input type='checkbox' name='desactiver' class='minimal-red' data-id-bank='".$row->id."' data-id-country='".$row->country_id."'>
<input type='checkbox' name='desactiver' class='minimal-red' data-id-operator='".$row->id."' data-id-country='".$row->country_id."'>
</label></td>";
}
echo "<td id='edition' align='center'>
<button data-toggle='modal' data-id-bank='$row->id' data-name-bank='$row->bank_name' data-address-bank='$row->bank_address' data-code-bank='$row->bank_code'
data-country='$row->country' data-id-country='$row->country_id' class='open-modal btn btn-success' data-target='#editModal'><i class='fa fa-edit'></i></button>
</td>
<td id='suppression' align='center'>
<button data-toggle='modal' data-id-bank='$row->id' data-id-country='$row->country_id' class='delete-bank btn btn-danger' ><i class='fa fa-trash'></i></button>
</td>
</tr>";
}
?>
<td align='center'>
<button data-toggle='modal' data-id-operator='<?=$row->id?>' data-name-operator='<?=$row->operator_name?>' data-type-operator="<?=$type?>"
data-address-operator='<?=$row->operator_address?>' data-code-operator='<?=$row->operator_code?>' data-country='<?=$row->country?>' data-id-country='<?=$row->country_id?>' class='open-modal btn btn-success' data-target='#editModal'><i class='fa fa-edit'></i></button>
<button data-toggle='modal' data-id-operator='<?=$row->id?>' data-id-country='<?=$row->country_id?>' class='delete-operator btn btn-danger' ><i class='fa fa-trash'></i></button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
@ -115,10 +118,10 @@
}
else {
echo $this->lang->line('no_bank');
echo $this->lang->line('no_operator');
}
}else {
echo $this->lang->line('no_bank');
echo $this->lang->line('no_operator');
}
?>
</div>
@ -127,14 +130,30 @@
<div class="col-lg-4">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('add_bank'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('add_operator'); ?></h3>
</div>
<div class="box-body">
<form id="add-bank" method="post" class="bottom-75 center-block">
<form id="add-operator" method="post" class="bottom-75 center-block">
<div class="form-group">
<label for="name"><?php echo $this->lang->line('Nom'); ?></label>
<input type="text" class="form-control input-lg" name="name" required id="name">
</div>
<div class="form-group">
<label for="type"><?php echo $this->lang->line('operator_type'); ?></label>
<?php
$result=$operators_types;
$numrows=$result->num_rows();
if ($numrows > 0) { ?>
<select class="form-control input-lg" name="type" required id="type" >
<?php foreach($result->result() as $row) {
echo "<option value='".$row->code."' id='".$row->id."'>".($this->session->userdata('site_lang') === 'french' ? $row->description_fr : $row->description_en)."</option>";
} ?>
</select>
<?php }else{
echo $this->lang->line("no_type");
}
?>
</div>
<div class="form-group">
<input id="btn-add" type="submit" value="<?php echo $this->lang->line('Ajouter'); ?>" class="btn btn-primary">
</div>
@ -143,7 +162,7 @@
</div>
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('assign_bank_to_country'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('assign_operator_to_country'); ?></h3>
</div>
<div class="box-body">
<form id="assign-form" method="post" class="bottom-75 center-block">
@ -164,22 +183,22 @@
?>
</div>
<div class="form-group">
<label for="ville"><?php echo $this->lang->line('banks'); ?></label>
<label for="ville"><?php echo $this->lang->line('operators'); ?></label>
<?php
$result=$distinct_banks;
$result=$distinct_operators;
if($result!=false) {
$numrows = $result->num_rows();
if ($numrows > 0) { ?>
<select class="form-control input-lg" name="bank" required id="bank">
<select class="form-control input-lg" name="operator" required id="operator">
<?php foreach ($result->result() as $row) {
echo "<option value='" . $row->id. "'>" . $row->nom . "</option>";
echo "<option value='" . $row->id. "'>" . $row->nom." - ".($this->session->userdata('site_lang') === 'french' ? $row->description_fr : $row->description_en). "</option>";
} ?>
</select>
<?php } else {
echo $this->lang->line("no_bank");
echo $this->lang->line("no_operator");
}
}else{
echo $this->lang->line("no_bank");
echo $this->lang->line("no_operator");
}
?>
</div>
@ -199,7 +218,7 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"><?php echo $this->lang->line('modify_bank'); ?></h4>
<h4 class="modal-title"><?php echo $this->lang->line('modify_operator'); ?></h4>
</div>
<div class="modal-body">
<form id="update-form" method="post" class="bottom-75 center-block">
@ -207,12 +226,16 @@
<label for="modal-pays"><?php echo $this->lang->line('Pays'); ?></label>
<input type="text" class="form-control input-lg" name="pays" required id="modal-pays" readonly="readonly">
</div>
<div class="form-group">
<label for="type">Type</label>
<input type="text" class="form-control input-lg" name="pays" required id="type" readonly="readonly">
</div>
<div class="form-group">
<label for="name"><?php echo $this->lang->line('Nom'); ?></label>
<input type="text" class="form-control input-lg" name="name" required id="name">
</div>
<div class="form-group">
<label for=code"><?php echo $this->lang->line('bank_code'); ?></label>
<label for=code">Code</label>
<input type="text" pattern=".{4,}" class="form-control input-lg" name="code" required id="code">
</div>
<div class="form-group">
@ -270,17 +293,17 @@
var desactivation = [];
$.each($("input[name='activer']:checked"), function(){
activation.push({"id_bank" : $(this).data('id-bank'),"id_country": $(this).data('id-country')});
activation.push({"id_operator" : $(this).data('id-operator'),"id_country": $(this).data('id-country')});
});
$.each($("input[name='desactiver']:checked"), function(){
desactivation.push({"id_bank" : $(this).data('id-bank'),"id_country": $(this).data('id-country')});
desactivation.push({"id_operator" : $(this).data('id-operator'),"id_country": $(this).data('id-country')});
});
// console.log('act' , activation)
// console.log('desact' , desactivation)
$.ajax({
url:'<?php echo base_url('index.php/Gestion/change_bank_status')?>',
url:'<?php echo base_url('index.php/Gestion/change_operator_status')?>',
type: 'post',
data: {activations: activation,desactivations:desactivation},
dataType: 'json',
@ -317,38 +340,41 @@
<script>
var id_bank = null;
var id_operator = null;
var name_network = null;
var id_country = null;
var country = null;
$(document).on("click", ".open-modal", function () {
id_bank = $(this).data('id-bank');
const bank_name = $(this).data('name-bank');
const bank_address = $(this).data('address-bank');
const bank_code = $(this).data('code-bank');
id_operator = $(this).data('id-operator');
const operator_name = $(this).data('name-operator');
const operator_type = $(this).data('type-operator');
console.log('type',operator_type)
const operator_address = $(this).data('address-operator');
const operator_code = $(this).data('code-operator');
id_country = $(this).data('id-country');
country = $(this).data('country');
$(".modal-body #modal-pays").val(country);
$(".modal-body #name").val( bank_name );
$(".modal-body #address").val( bank_address );
$(".modal-body #code").val( bank_code );
$(".modal-body #type").val(operator_type);
$(".modal-body #name").val( operator_name );
$(".modal-body #address").val( operator_address );
$(".modal-body #code").val( operator_code );
});
$(document).on("click", ".delete-bank", function (event) {
id_bank = $(this).data('id-bank');
$(document).on("click", ".delete-operator", function (event) {
id_operator = $(this).data('id-operator');
id_country = $(this).data('id-country');
$.ajax({
url:'<?php echo base_url('index.php/Gestion/delete_bank')?>',
url:'<?php echo base_url('index.php/Gestion/delete_operator')?>',
type: 'post',
data: {id_bank: id_bank , id_country : id_country},
data: {id_operator: id_operator , id_country : id_country},
dataType: 'json',
success: function(data){
if(data==='completed'){
alert("<?= $this->lang->line('bank_deleted') ?>");
alert("<?= $this->lang->line('operator_deleted') ?>");
location.reload();
}else{
alert("<?= $this->lang->line('error_message') ?>");
@ -361,17 +387,17 @@
});
$("#assign-form").submit(function(event){
var id_bank = $("#assign-form #bank").val();
var id_operator = $("#assign-form #operator").val();
var selectedValues = $('#assign-form #pays').val();
$.ajax({
url:'<?php echo base_url('index.php/Gestion/assign_bank')?>',
url:'<?php echo base_url('index.php/Gestion/assign_operator')?>',
type: 'post',
data: {id_country: selectedValues,id_bank:id_bank},
data: {id_country: selectedValues,id_operator:id_operator},
dataType: 'json',
success: function(data){
if(data==='completed'){
alert("<?= $this->lang->line('bank_assigned') ?>");
alert("<?= $this->lang->line('operator_assigned') ?>");
location.reload();
}else if(data==='existe'){
alert('Ce réseau a déjà été assigné à certains des pays sélectionnés');
@ -387,16 +413,17 @@
event.preventDefault();
});
$("#add-bank").submit(function(event){
var name = $("#add-bank #name").val();
$("#add-operator").submit(function(event){
var name = $("#add-operator #name").val();
var type = $("#add-operator #type").val();
$.ajax({
url:'<?php echo base_url('index.php/Gestion/add_bank')?>',
url:'<?php echo base_url('index.php/Gestion/add_operator')?>',
type: 'post',
data: {name: name},
data: {name: name , type :type},
dataType: 'json',
success: function(data){
if(data==='completed'){
alert("<?= $this->lang->line('bank_added') ?>");
alert("<?= $this->lang->line('operator_added') ?>");
location.reload();
}else{
alert("<?= $this->lang->line('error_message') ?>");
@ -412,13 +439,13 @@
const address = $("#update-form #address").val();
const code = $("#update-form #code").val();
$.ajax({
url:'<?php echo base_url('index.php/Gestion/update_bank')?>',
url:'<?php echo base_url('index.php/Gestion/update_operator')?>',
type: 'post',
data: {id_bank: id_bank ,name:name , address :address , id_country : id_country , code : code},
data: {id_operator: id_operator ,name:name , address :address , id_country : id_country , code : code},
dataType: 'json',
success: function(data){
if(data==='completed'){
alert("<?= $this->lang->line('bank_modified') ?>");
alert("<?= $this->lang->line('operator_modified') ?>");
location.reload();
}else{
alert("<?= $this->lang->line('error_message') ?>");

View File

@ -6,7 +6,7 @@
<section class="content-header">
<h1>
<?php echo $this->lang->line('management_banks'); ?>
<?php echo $this->lang->line('management_operators'); ?>
</h1>
<?php
$site_url = base_url();
@ -41,13 +41,13 @@
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><?php echo $this->lang->line('banks'); ?></h3>
<h3 class="box-title"><?php echo $this->lang->line('operators'); ?></h3>
</div>
<div class="box-body" style="overflow-x:auto;">
<?php
$sql2 = $banks;
$sql2 = $operators;
if($sql2!=false){
$numrows=$sql2->num_rows();
$num = 0;
@ -58,8 +58,9 @@
<tr>
<th align='center'></th>
<th><?php echo $this->lang->line('Pays'); ?></th>
<th>Type</th>
<th><?php echo $this->lang->line('Nom'); ?></th>
<th><?php echo $this->lang->line('bank_code'); ?></th>
<th>Code</th>
<th align='center'><?php echo $this->lang->line('Adresse'); ?></th>
<th align='center'><?php echo $this->lang->line('Statut'); ?></th>
<th align='center'><?php echo $this->lang->line('Activer/Désactiver'); ?></th>
@ -70,24 +71,25 @@
<?php
foreach($sql2->result() as $row) {
$num ++;
//$member_code = randomString1(10);
$type = $this->session->userdata('site_lang') === 'french' ? $row->type_fr : $row->type_en;
echo "<tr>
<td align='center'>$num</td>
<td >$row->country</td>
<td >$row->bank_name</td>
<td >$row->bank_code</td>
<td>$row->bank_address</td>";
<td>$type</td>
<td >$row->operator_name</td>
<td >$row->operator_code</td>
<td>$row->operator_address</td>";
?>
<?php
if($row->id_network){
?>
<td><span class="label label-success"><?= $this->lang->line('Actif'); ?></span></td>
<td><button type="button" data-toggle="modal" data-target="#disableBank" data-id-bank-country="<?=$row->id ?>" data-id-network="<?= $row->id_network ?>" class="btn btn-danger openModal"><?= $this->lang->line('Désactiver'); ?></button></td>
<td><button type="button" data-toggle="modal" data-target="#disableOperator" data-id-operator-country="<?=$row->id ?>" data-id-network="<?= $row->id_network ?>" class="btn btn-danger openModal"><?= $this->lang->line('Désactiver'); ?></button></td>
<?php
}else{
?>
<td><span class="label label-danger"><?= $this->lang->line('Inactif'); ?></span></td>
<td><button type="button" data-id-bank-country="<?= $row->id ?>" data-id-network="<?= $this->session->userdata('network_id') ?>" class="btn btn-primary activeBank" ><?php echo $this->lang->line('Activer'); ?></button></td>
<td><button type="button" data-id-operator-country="<?= $row->id ?>" data-id-network="<?= $this->session->userdata('network_id') ?>" class="btn btn-primary activeOperator" ><?php echo $this->lang->line('Activer'); ?></button></td>
<?php
}
?>
@ -107,21 +109,21 @@
}
else {
echo $this->lang->line('no_bank');
echo $this->lang->line('no_operator');
}
}else {
echo $this->lang->line('no_bank');
echo $this->lang->line('no_operator');
}
?>
</div>
</div>
</div>
</div>
<div class="modal fade" id="disableBank" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="disableOperator" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?php echo $this->lang->line('bank_deactivation'); ?></h3>
<h3 class="modal-title"><?php echo $this->lang->line('operator_deactivation'); ?></h3>
</div>
<div class="modal-body">
<h4> Etes vous certain de vouloir ?</h4>
@ -166,27 +168,27 @@
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
var id_bank_country = null;
var id_operator_country = null;
$(document).on("click", ".openModal", function () {
id_bank_country = $(this).data('id-bank-country');
id_operator_country = $(this).data('id-operator-country');
id_network = $(this).data('id-network');
})
$(document).on("click", ".activeBank", function () {
const id_bank_country = $(this).data('id-bank-country');
$(document).on("click", ".activeOperator", function () {
const id_operator_country = $(this).data('id-operator-country');
const id_network = $(this).data('id-network');
$.ajax({
url : '<?php echo base_url('index.php/Hyperviseur_dash/active_bank')?>',
url : '<?php echo base_url('index.php/Hyperviseur_dash/active_operator')?>',
type : 'POST',
dataType : 'json',
data: {"id_bank_country": id_bank_country , "id_network" : id_network},
data: {"id_operator_country": id_operator_country , "id_network" : id_network},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('bank_activated')?>",
title: "<?php echo $this->lang->line('operator_activated')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{
@ -206,15 +208,15 @@
$('#deleteWallet').click(function(){
$.ajax({
url : '<?php echo base_url('index.php/Hyperviseur_dash/deactive_bank')?>',
url : '<?php echo base_url('index.php/Hyperviseur_dash/deactive_operator')?>',
type : 'POST',
dataType : 'json',
data: {"id_bank_country": id_bank_country , "id_network" : id_network},
data: {"id_operator_country": id_operator_country , "id_network" : id_network},
success : function(data){
if(data=='200'){
Swal.fire({
icon: 'success',
title: "<?php echo $this->lang->line('bank_deactivated')?>",
title: "<?php echo $this->lang->line('operator_deactivated')?>",
text: "<?php echo $this->lang->line('informations_updated')?>",
timer: 3000
}).then(()=>{

View File

@ -179,9 +179,9 @@
</a>
</li>
<li class="<?php if($active=="banks"){echo "active";} ?>">
<a href="<?php echo base_url('index.php/Gestion/banks') ?>">
<i class="fa fa-bank"></i> <span><?php echo $this->lang->line('banks'); ?></span>
<li class="<?php if($active=="operators"){echo "active";} ?>">
<a href="<?php echo base_url('index.php/Gestion/operators') ?>">
<i class="fa fa-building"></i> <span><?php echo $this->lang->line('operators'); ?></span>
</a>
</li>
</ul>

View File

@ -203,9 +203,9 @@
</li>
<?php }?>
<li class="<?php if($active=="banks"){echo "active";} ?>">
<a href="<?php echo base_url('index.php/Hyperviseur_dash/banks') ?>">
<i class="fa fa-bank"></i> <span><?php echo $this->lang->line('banks'); ?></span>
<li class="<?php if($active=="operators"){echo "active";} ?>">
<a href="<?php echo base_url('index.php/Hyperviseur_dash/operators') ?>">
<i class="fa fa-building"></i> <span><?php echo $this->lang->line('operators'); ?></span>
</a>
</li>
<?php } ?>
@ -268,43 +268,3 @@
<!-- /.modal -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<script type="text/javascript">
var startDate;
var endDate;
$(function() {
var start = moment().subtract(29, 'days');
var end = moment();
startDate = start;
endDate = end;
function cb(start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
startDate = start;
endDate = end;
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}, cb);
cb(start, end);
});
</script>