Add phone number verification in gestion_recherche menu

This commit is contained in:
Djery-Tom 2021-03-01 17:53:59 +01:00
parent 9d8cf04e4a
commit a1cab68982
5 changed files with 26 additions and 103 deletions

View File

@ -1428,11 +1428,15 @@ class Gestion extends CI_Controller
$adresse = $_POST['adresse'];
$email = $_POST['email'];
$nom = $_POST['nom'];
$res = $this->user_model->update_geolocated_infos($nom, $adresse, $email, $id_agent, $transac, $phone, $id_netAg);
if ($res != false) {
echo json_encode("200");
} else {
echo json_encode("500");
if($this->user_model->isAgentPhoneExist($id_netAg,$phone,$transac)){
echo json_encode("400");
}else{
$res = $this->user_model->update_geolocated_infos($nom, $adresse, $email, $id_agent, $transac, $phone, $id_netAg);
if ($res != false) {
echo json_encode("200");
} else {
echo json_encode("500");
}
}
} else {

View File

@ -611,4 +611,5 @@ $lang['nano_health_management'] = 'Nano health management';
$lang['nano_health_removal'] = 'Removal of nano health';
$lang['activate_nano_health'] = 'Activate nano health';
$lang['nano_health_deleted'] = 'Nano health deleted';
$lang['phone_already_exists'] = "This phone number already exists";
?>

View File

@ -623,4 +623,5 @@ $lang['nano_health_management'] = 'Gestion du nano santé';
$lang['nano_health_removal'] = 'Suppression du nano santé';
$lang['activate_nano_health'] = 'Activation du nano santé';
$lang['nano_health_deleted'] = 'Nano santé supprimé';
$lang['phone_already_exists'] = "This phone number already exists";
?>

View File

@ -2608,4 +2608,9 @@ class User_model extends CI_Model
return date('Y-m-d H:i:s');
}
}
public function isAgentPhoneExist($id_network_agent , $phone, $phoneTransaction){
$query = $this->db->query("SELECT na.phone from networks_agents na WHERE na.id <> '$id_network_agent' AND (na.phone ='$phone' OR na.transactionNumber ='$phoneTransaction')");
return $query->num_rows() ;
}
}

View File

@ -6,6 +6,7 @@
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.15/css/bootstrap-multiselect.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="<?php echo base_url('bower_components/toastr/toastr.css') ?>">
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<style>
@ -755,7 +756,7 @@
<script src="<?php echo base_url('bower_components/bootstrap-daterangepicker/daterangepicker.js') ?>"></script>
<script src="<?php echo base_url('bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') ?>"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<script src="<?php echo base_url('bower_components/toastr/toastr.js') ?>"></script>
<script type="text/javascript">
//Date picker
@ -771,101 +772,10 @@
</script>
<script>
$('#pays').change(function () {
var pays = $(this).val();
$.ajax({
url: '<?php echo base_url('index.php/Gestion/getVilleByPays')?>',
type: 'post',
data: {pays: pays},
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].id + "'>" + list[i].name + "</option>");
}
var id_ville = list[0].id;
$.ajax({
url: '<?php echo base_url('index.php/Gestion/getAgentByVilles')?>',
type: 'post',
data: {id_ville: id_ville},
dataType: 'json',
success: function (list) {
var len = list.length;
if (len > 0) {
var select = document.getElementById('agent');
$(select).empty();
for (var i in list) {
$(select).append("<option value='" + list[i].lastname + "'>" + list[i].lastname + "</option>");
}
} else {
var select = document.getElementById('agent');
$(select).empty();
}
}
});
} else {
var select = document.getElementById('ville');
$(select).empty();
var select2 = document.getElementById('agent');
$(select2).empty();
}
}
});
});
$('#ville').change(function () {
var ville = $(this).val();
$.ajax({
url: '<?php echo base_url('index.php/Gestion/getAgentByVilles')?>',
type: 'post',
data: {id_ville: ville},
dataType: 'json',
success: function (list) {
var len = list.length;
if (len > 0) {
var select = document.getElementById('agent');
$(select).empty();
for (var i in list) {
$(select).append("<option value='" + list[i].lastname + "'>" + list[i].lastname + "</option>");
}
} else {
var select = document.getElementById('agent');
$(select).empty();
}
}
});
});
toastr.options.closeButton = true;
toastr.options.closeMethod = 'fadeOut';
toastr.options.closeDuration = 5000;
toastr.options.closeEasing = 'swing';
$('#phone').on('input', function () {
if ($(this).val() !== '') {
@ -958,14 +868,16 @@
success: function (data, statut) {
if (data == '200') {
alert("Les informations ont été mises à jour.") ? "" : location.reload(true);
} else {
} else if (data == '400') {
toastr.error("<?php echo $this->lang->line('phone_already_exists')?>", "<?php echo $this->lang->line('request_error')?>");
}else{
alert("Une erreur s'est produite.");
}
},
error: function (resultat, statut, erreur) {
alert("Une erreur s'est produite.");
console.log(resultat + " " + erreur);
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
}
});