Add payment aggregators settings to admin panel
This commit is contained in:
parent
135443a7e2
commit
103ca3ec2e
|
@ -2479,5 +2479,20 @@ class Gestion extends CI_Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function aggregators()
|
||||
{
|
||||
if ($this->isLogged()) {
|
||||
$data['active'] = "aggregators";
|
||||
$data['alert'] = "";
|
||||
$data['aggregators'] = $this->db->get_where('payment_aggregators');
|
||||
// $data['pays'] = $this->user_model->getAllPays();
|
||||
$data['game_pays'] = $this->user_model->getGameCountry();
|
||||
$this->load->view('header_gestion', $data);
|
||||
$this->load->view('gestion_aggregators');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
class PaymentController extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function createPaymentAggregator()
|
||||
{
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$emailExist = $this->db->get_where('payment_aggregators', ['email' => $_POST['email']]);
|
||||
if ($emailExist->num_rows() == 0) {
|
||||
$_POST['created_at'] = (new DateTime())->format('Y-m-d H:i:s');
|
||||
$_POST['updated_at'] = (new DateTime())->format('Y-m-d H:i:s');
|
||||
$this->db->insert('payment_aggregators', $_POST);
|
||||
echo json_encode(['code' => 200]);
|
||||
} else {
|
||||
echo json_encode(['code'=> 419 , 'message' => $this->lang->line("L'email entré est déjà utilisé")]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePaymentAggregator()
|
||||
{
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$emailExist = $this->db->get_where('payment_aggregators', ['id !=' => $_POST['id'], 'email' => $_POST['email']]);
|
||||
if ($emailExist->num_rows() == 0) {
|
||||
$_POST['updated_at'] = (new DateTime())->format('Y-m-d H:i:s');
|
||||
$this->db->where('id',$_POST['id']);
|
||||
$this->db->update('payment_aggregators',$_POST);
|
||||
echo json_encode(['code' => 200]);
|
||||
}else{
|
||||
echo json_encode(['code'=> 419 , 'message' => $this->lang->line("L'email entré est déjà utilisé")]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deletePaymentAggregator(){
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$this->db->delete('payment_aggregators', ['id' => $_POST['id']]);
|
||||
echo json_encode(['code' => 200]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function enableAggregator()
|
||||
{
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$date = (new DateTime())->format('Y-m-d H:i:s');
|
||||
$this->db->update('payment_aggregators',['status' => 0 , 'updated_at' => $date]);
|
||||
$this->db->where('id',$_POST['id']);
|
||||
$this->db->update('payment_aggregators',['status' => 1 , 'updated_at' => $date]);
|
||||
echo json_encode(['code' => 200]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function isLogged()
|
||||
{
|
||||
if (!$this->session->userdata('email')) {
|
||||
$this->session->set_flashdata('error', 'log in first');
|
||||
|
||||
$data['alert'] = "ok";
|
||||
$data['message'] = "Login first!";
|
||||
$this->load->view('login', $data);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -947,4 +947,20 @@ $lang['STOPPED'] = "Stopped";
|
|||
$lang['profile_image'] = "Profile image";
|
||||
$lang['open_wallet_at_mobile_login'] = "Open wallet at mobile login";
|
||||
$lang['MODIFIED'] = "Modified";
|
||||
$lang['opening_amount'] = "Opening amount";
|
||||
$lang['name_already_used'] = "The name entered is already in use";
|
||||
$lang['add_customer_account_type'] = 'Add a customer account type';
|
||||
$lang['customer_account_type_created'] = "Customer account type created";
|
||||
$lang['customer_account_type_updated'] = "Customer account type modified";
|
||||
$lang['customer_account_type_deleted'] = "Customer account type deleted";
|
||||
$lang['customer_account_types'] = 'customer account types';
|
||||
$lang['customers_accounts_configuration'] = 'Configuration of opening customer accounts';
|
||||
$lang['aggregators'] = "Aggregators";
|
||||
$lang['payment_aggregators'] = "Payment aggregators";
|
||||
$lang['add_aggregator'] = "Add an aggregator";
|
||||
$lang['aggregator_updated'] = "Payment aggregator updated";
|
||||
$lang['aggregator_deleted'] = "Payment aggregator deleted";
|
||||
$lang['aggregator_created'] = "Payment aggregator created";
|
||||
$lang['aggregator_activated'] = "Agrégateur de paiement activated" ;
|
||||
|
||||
?>
|
||||
|
|
|
@ -956,4 +956,20 @@ $lang['STOPPED'] = "Arretée";
|
|||
$lang['profile_image'] = "Photo de profil";
|
||||
$lang['open_wallet_at_mobile_login'] = "Ouverture du wallet à la connexion mobile";
|
||||
$lang['MODIFIED'] = "Modifiée";
|
||||
$lang['opening_amount'] = "Montant à l'ouverture";
|
||||
$lang['name_already_used'] = "Le nom entré est déjà utilisé";
|
||||
$lang['add_customer_account_type'] = 'Ajouter un type de compte client';
|
||||
$lang['customer_account_type_created'] = "Type de compte client crée";
|
||||
$lang['customer_account_type_updated'] = "Type de compte client modifié";
|
||||
$lang['customer_account_type_deleted'] = "Type de compte client supprimé";
|
||||
$lang['customer_account_types'] = 'Types de comptes clients';
|
||||
$lang['customers_accounts_configuration'] = 'Configuration ouverture des comptes clients';
|
||||
$lang['aggregators'] = "Agrégateurs";
|
||||
$lang['payment_aggregators'] = "Agrégateurs de paiement";
|
||||
$lang['add_aggregator'] = "Ajouter un agrégateur";
|
||||
$lang['aggregator_updated'] = "Agrégateur de paiement mis à jour" ;
|
||||
$lang['aggregator_deleted'] = "Agrégateur de paiement supprimé" ;
|
||||
$lang['aggregator_created'] = "Agrégateur de paiement créé" ;
|
||||
$lang['aggregator_activated'] = "Agrégateur de paiement activé" ;
|
||||
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,343 @@
|
|||
<link rel="stylesheet"
|
||||
href="<?= base_url('bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css') ?>">
|
||||
<link rel="stylesheet" href="<?= base_url('bower_components/toastr/toastr.css') ?>">
|
||||
<div class="content-wrapper">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<?= $this->lang->line('payment_aggregators') ; ?>
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-xs-8">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?= $this->lang->line('payment_aggregators'); ?></h3>
|
||||
</div>
|
||||
<div class="box-body" style="overflow-x:auto;">
|
||||
<table id="aggregators" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align='center'>#</th>
|
||||
<th><?= $this->lang->line('Nom'); ?></th>
|
||||
<th align='center'><?= $this->lang->line('Email'); ?></th>
|
||||
<th align='center'><?= $this->lang->line('Adresse'); ?></th>
|
||||
<th align='center'><?= $this->lang->line('Contact'); ?></th>
|
||||
<th align='center'><?= $this->lang->line('Statut'); ?></th>
|
||||
<th align='center'><?php echo $this->lang->line('Activer'); ?></th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if(isset($aggregators)){
|
||||
foreach ($aggregators->result() as $i => $row) {
|
||||
?>
|
||||
<tr>
|
||||
<td align='center'><?= $i+1?></td>
|
||||
<td><?= $row->name ?></td>
|
||||
<td align='center'><?=$row->email?></td>
|
||||
<td align='center'><?=$row->address?></td>
|
||||
<td align='center'><?=$row->phone?></td>
|
||||
<td align='center'><?= $this->lang->line($row->status ? 'Active' : 'Inactive'); ?></td>
|
||||
<td align='center'>
|
||||
<input type='checkbox' value='<?=$row->id?>' <?= $row->status ? 'checked' : '' ?>>
|
||||
</td>
|
||||
<td>
|
||||
<button class='btn btn-success edit' data-id="<?=$row->id?>" data-address="<?=$row->address?>" data-name="<?=$row->name?>"
|
||||
data-email="<?=$row->email?>" data-phone="<?=$row->phone?>" >
|
||||
<i class='fa fa-edit'></i>
|
||||
</button>
|
||||
<button data-toggle='modal' class='btn btn-danger delete' data-id="<?=$row->id?>">
|
||||
<i class='fa fa-trash'></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" class="btn btn-success" id="enableAggregator"><?php echo $this->lang->line('Activer/Désactiver'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title"><?= $this->lang->line('add_aggregator'); ?></h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<form id="create-aggregator-form" class="bottom-75 center-block" method="post">
|
||||
<div class="form-group">
|
||||
<label for="name"><?= $this->lang->line('Nom'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email"><?= $this->lang->line('Email'); ?></label>
|
||||
<input type="email" class="form-control input-lg" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="address"><?= $this->lang->line('Adresse'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="address">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="contact"><?= $this->lang->line('Contact'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="phone">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit"
|
||||
value="<?= $this->lang->line('Ajouter'); ?>"
|
||||
class="btn btn-primary">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="editModal">
|
||||
<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('Mettre à jour des informations'); ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="update-form" method="post" class="bottom-75 center-block">
|
||||
|
||||
<div class="form-group">
|
||||
<label><?= $this->lang->line('Nom'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?= $this->lang->line('Email'); ?></label>
|
||||
<input type="email" class="form-control input-lg" name="email" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?= $this->lang->line('Adresse'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="address" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><?= $this->lang->line('Contact'); ?></label>
|
||||
<input type="text" class="form-control input-lg" name="phone">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input id="btn-update" type="submit"
|
||||
value="<?= $this->lang->line('save'); ?>" class="btn btn-primary">
|
||||
<button type="button" class="btn btn-default pull-right"
|
||||
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('include/delete_modal') ?>
|
||||
<?php $this->load->view('include/loader') ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- jQuery 3 -->
|
||||
<script src="<?= base_url('bower_components/jquery/dist/jquery.min.js') ?>"></script>
|
||||
<!-- Bootstrap 3.3.7 -->
|
||||
<script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
|
||||
<!-- DataTables -->
|
||||
<script src="<?= base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
|
||||
<script src="<?= base_url('bower_components/datatables.net-bs/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 -->
|
||||
<script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
|
||||
<script src="<?= base_url('bower_components/toastr/toastr.js') ?>"></script>
|
||||
<script src="<?= base_url('dist/js/sweetalert2.js') ?>"></script>
|
||||
|
||||
<script>
|
||||
|
||||
toastr.options.closeButton = true;
|
||||
toastr.options.closeMethod = 'fadeOut';
|
||||
toastr.options.closeDuration = 5000;
|
||||
toastr.options.closeEasing = 'swing';
|
||||
|
||||
var selectedId = null
|
||||
var checkedId = null
|
||||
|
||||
function showEnableButton() {
|
||||
if($("#aggregators input:checked").length){
|
||||
$('#enableAggregator').show();
|
||||
$("#aggregators input:checked").each(function() {
|
||||
checkedId = $(this).val()
|
||||
});
|
||||
}else{
|
||||
$('#enableAggregator').hide();
|
||||
checkedId = null
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#aggregators').DataTable();
|
||||
showEnableButton()
|
||||
})
|
||||
|
||||
$('#aggregators').on('change', 'input[type=checkbox]', function(e) {
|
||||
if(this.checked){
|
||||
$("#aggregators").find("input[type=checkbox]").not(this).prop('checked', false);
|
||||
}
|
||||
showEnableButton()
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on("click", ".edit", function () {
|
||||
selectedId = $(this).data('id');
|
||||
$("#update-form input[name='name']").val($(this).data('name'));
|
||||
$("#update-form input[name='address']").val($(this).data('address'));
|
||||
$("#update-form input[name='email']").val($(this).data('email'));
|
||||
$("#update-form input[name='phone']").val($(this).data('phone'));
|
||||
$('#editModal').modal('show');
|
||||
|
||||
});
|
||||
|
||||
$(document).on("click", ".delete", function () {
|
||||
selectedId = $(this).data('id');
|
||||
$('#delete-modal').modal('show');
|
||||
});
|
||||
|
||||
|
||||
$("#update-form").submit(function () {
|
||||
$.ajax({
|
||||
url: '<?= base_url('PaymentController/updatePaymentAggregator')?>',
|
||||
type: 'post',
|
||||
data: {
|
||||
id: selectedId,
|
||||
name: $("input[name=name]",this).val(),
|
||||
address: $("input[name=address]",this).val(),
|
||||
email: $("input[name=email]",this).val(),
|
||||
phone: $("input[name=phone]",this).val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if(data.code === 200){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?= $this->lang->line('aggregator_updated')?>",
|
||||
text:"<?= $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(()=>{
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
toastr.error(data.message , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$("#create-aggregator-form").submit(function (event) {
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url('PaymentController/createPaymentAggregator')?>',
|
||||
type: 'post',
|
||||
data: {
|
||||
name: $("input[name=name]",this).val(),
|
||||
address: $("input[name=address]",this).val(),
|
||||
email: $("input[name=email]",this).val(),
|
||||
phone: $("input[name=phone]",this).val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if(data.code === 200){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?= $this->lang->line('aggregator_created')?>",
|
||||
text:"<?= $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(()=>{
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
toastr.error(data.message , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$("#enableAggregator").click(function () {
|
||||
$.ajax({
|
||||
url: '<?= base_url('PaymentController/enableAggregator')?>',
|
||||
type: 'post',
|
||||
data: {id: checkedId},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if(data.code === 200){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?= $this->lang->line('aggregator_activated')?>",
|
||||
text:"<?= $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(()=>{
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
toastr.error(data.message , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#delete-btn").click(function () {
|
||||
$.ajax({
|
||||
url: '<?= base_url('PaymentController/deletePaymentAggregator')?>',
|
||||
type: 'post',
|
||||
data: {id: selectedId},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if(data.code === 200){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?= $this->lang->line('aggregator_deleted')?>",
|
||||
text:"<?= $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(()=>{
|
||||
location.reload();
|
||||
});
|
||||
}else{
|
||||
toastr.error(data.message , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
</script>
|
|
@ -190,6 +190,11 @@
|
|||
<i class="fa fa-building"></i> <span><?= $this->lang->line('operators'); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if($active=="aggregators"){echo "active";} ?>">
|
||||
<a href="<?php echo base_url('index.php/Gestion/aggregators') ?>">
|
||||
<i class="ion ion-cash"></i> <span><?php echo $this->lang->line('aggregators'); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="<?php if($active=="settings"){echo "active";} ?>">
|
||||
<a href="<?= base_url('Gestion/settings') ?>">
|
||||
<i class="ion ion-settings"></i> <span><?= $this->lang->line('settings'); ?></span>
|
||||
|
|
Loading…
Reference in New Issue