Implements Validation and Reject of insurance subscriptions
This commit is contained in:
parent
8008eed20f
commit
436cc49583
|
@ -1851,7 +1851,8 @@ if($this->isLogged()) {
|
|||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.WALLET_SERVICE_TOKEN
|
||||
'Authorization:'.WALLET_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
|
||||
/* set return type json */
|
||||
|
@ -1889,7 +1890,8 @@ if($this->isLogged()) {
|
|||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.WALLET_SERVICE_TOKEN
|
||||
'Authorization:'.WALLET_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
|
||||
/* set return type json */
|
||||
|
|
|
@ -257,7 +257,8 @@ class Hyperviseur_dash extends CI_Controller
|
|||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.NOTIFICATION_SERVICE_TOKEN
|
||||
'Authorization:'.NOTIFICATION_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
|
||||
$data = new \stdClass();
|
||||
|
@ -681,7 +682,8 @@ class Hyperviseur_dash extends CI_Controller
|
|||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.NOTIFICATION_SERVICE_TOKEN
|
||||
'Authorization:'.NOTIFICATION_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
|
||||
$data = new \stdClass();
|
||||
|
|
|
@ -161,6 +161,75 @@ class NanoHealthController extends CI_Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function validateSubscription()
|
||||
{
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$subscription_id = $_POST['subscription_id'];
|
||||
$url = NANO_SANTE_SERVICE_URL.'/insurances/subscriptions/'.$subscription_id.'/validate';
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.NANO_SANTE_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
/* set return type json */
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$body = new \stdClass();
|
||||
$body->agent_id = $this->input->post('agent_id');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
|
||||
|
||||
/* execute request */
|
||||
$result = curl_exec($ch);
|
||||
/* close cURL resource */
|
||||
curl_close($ch);
|
||||
|
||||
if ($result) {
|
||||
echo $result;
|
||||
} else {
|
||||
echo json_encode(['status' => 500]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function rejectSubscription()
|
||||
{
|
||||
if($this->isLogged()) {
|
||||
if (isset($_POST)) {
|
||||
$subscription_id = $_POST['subscription_id'];
|
||||
$url = NANO_SANTE_SERVICE_URL.'/insurances/subscriptions/'.$subscription_id.'/reject';
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
/* set the content type json */
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type:application/json',
|
||||
'Authorization:'.NANO_SANTE_SERVICE_TOKEN,
|
||||
'X-localization:'. $this->session->userdata('site_lang') == 'french' ? 'fr' : 'en'
|
||||
));
|
||||
/* set return type json */
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$body = new \stdClass();
|
||||
$body->agent_id = $this->input->post('agent_id');
|
||||
$body->reason = $this->input->post('reason');
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
|
||||
|
||||
/* execute request */
|
||||
$result = curl_exec($ch);
|
||||
/* close cURL resource */
|
||||
curl_close($ch);
|
||||
|
||||
if ($result) {
|
||||
echo $result;
|
||||
} else {
|
||||
echo json_encode(['status' => 500]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function isLogged()
|
||||
{
|
||||
if (!$this->session->userdata('email')) {
|
||||
|
|
|
@ -714,4 +714,14 @@ $lang['SPOUSE'] = "SPOUSE";
|
|||
$lang['care_requests'] = "Care requests";
|
||||
$lang['birthdate_proof_doc'] = "Birth certificate";
|
||||
$lang['justice_doc'] = "Justice document";
|
||||
$lang['marriage_certificate_doc'] = "Marriage certificate";
|
||||
$lang['subscription_accepted'] = "The subscription has been accepted";
|
||||
$lang['ACCEPTED'] = "Accepted";
|
||||
$lang['REJECTED'] = "Rejected";
|
||||
$lang['id_document_image_front'] = "Front of the identity document";
|
||||
$lang['id_document_image_back'] = "Back side of the identity document";
|
||||
$lang['reject_subscription'] = "Reject the subscription";
|
||||
$lang['reject_reason'] = "Reason for rejection";
|
||||
$lang['subscription_rejected'] = "Rejected subscription";
|
||||
$lang['reason_rule'] = "Reason must not exceed 500 characters";
|
||||
?>
|
||||
|
|
|
@ -726,4 +726,14 @@ $lang['SPOUSE'] = "CONJOINT";
|
|||
$lang['care_requests'] = "Demandes de soins";
|
||||
$lang['birthdate_proof_doc'] = "Acte de naissance";
|
||||
$lang['justice_doc'] = "Document de justice";
|
||||
$lang['marriage_certificate_doc'] = "Acte de mariage";
|
||||
$lang['subscription_accepted'] = "La souscription a été acceptée";
|
||||
$lang['ACCEPTED'] = "Acceptée";
|
||||
$lang['REJECTED'] = "Rejetée";
|
||||
$lang['id_document_image_front'] = "Face avant du document d'identité";
|
||||
$lang['id_document_image_back'] = "Face arrière du document d'identité";
|
||||
$lang['reject_subscription'] = "Rejecter la subscription";
|
||||
$lang['reject_reason'] = "Motif du rejet";
|
||||
$lang['subscription_rejected'] = "Souscription rejetée";
|
||||
$lang['reason_rule'] = "Le motif ne doit pas dépasser 500 caractères";
|
||||
?>
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
<?= $this->lang->line('subscriptions') . ' :: ' . $this->lang->line('subscription_detail') . ' - ' . $insurance_subscription_id; ?>
|
||||
|
||||
<div class="pull-right">
|
||||
<button id="download-notice" class="btn btn-success" >
|
||||
<?php if($subscription->state == 'UNDER_VALIDATION') { ?>
|
||||
<button id="accept-subscription" class="btn btn-success" >
|
||||
<?= $this->lang->line('accept') ?>
|
||||
</button>
|
||||
<button id="download-notice" class="btn btn-danger" >
|
||||
<button class="btn btn-danger" data-toggle="modal" data-target="#reject-modal">
|
||||
<?= $this->lang->line('reject') ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
|
@ -227,41 +229,81 @@
|
|||
?>
|
||||
|
||||
<td>
|
||||
<button class="btn btn-primary" data-target="#images-modal" data-toggle="modal">
|
||||
<button class="btn btn-primary" data-target="<?= '#images-modal'.$i ?>" data-toggle="modal">
|
||||
<?= $this->lang->line('show'); ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<div class="modal fade" id="images-modal">
|
||||
<div class="modal fade" id="<?= 'images-modal'.$i ?>">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Images des documents</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<?php
|
||||
<?php if($row->affiliation == 'CHILD') {
|
||||
|
||||
$birthdate_proof_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->birthdate_proof_doc;
|
||||
$birthdate_proof_doc_file = @fopen($birthdate_proof_doc ,'r');
|
||||
|
||||
$justice_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->justice_doc;
|
||||
$justice_doc_file = @fopen($justice_doc ,'r');
|
||||
?>
|
||||
|
||||
?>
|
||||
<div class="row" style="margin-top: 10px">
|
||||
<div class="col-sm-6 text-center">
|
||||
<label><?= $this->lang->line('birthdate_proof_doc') ?></label>
|
||||
<img src="<?= $birthdate_proof_doc_file ? $birthdate_proof_doc : base_url('images/broken.png') ?>"
|
||||
alt="document_front"/>
|
||||
alt="document_front" style="width: 100%;"/>
|
||||
|
||||
</div>
|
||||
<div class="col-sm-6 text-center">
|
||||
<label><?= $this->lang->line('justice_doc') ?></label>
|
||||
<img src="<?= $justice_doc_file ? $justice_doc : base_url('images/broken.png')?>"
|
||||
alt="document_back"/>
|
||||
alt="document_back" style="width: 100%;"/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php } else {
|
||||
|
||||
$marriage_certificate_doc = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->marriage_certificate_doc;
|
||||
$marriage_certificate_doc_file = @fopen($marriage_certificate_doc,'r');
|
||||
|
||||
$id_document_front = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->id_document_front;
|
||||
$id_document_front_file = @fopen($id_document_front ,'r');
|
||||
|
||||
$id_document_back = NANO_SANTE_SERVICE_URL . '/insurances-subscriptions-docs/'.$row->id_document_back;
|
||||
$id_document_back_file = @fopen($id_document_front ,'r');
|
||||
|
||||
?>
|
||||
|
||||
<div class="row text-center">
|
||||
<div class="col-12">
|
||||
<label><?= $this->lang->line('marriage_certificate_doc') ?></label>
|
||||
<div>
|
||||
<img src="<?= $marriage_certificate_doc_file ? $marriage_certificate_doc : base_url('images/broken.png') ?>"
|
||||
alt="user_image"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-top: 10px">
|
||||
<div class="col-sm-6 text-center">
|
||||
<label><?= $this->lang->line('id_document_image_front') ?></label>
|
||||
<img src="<?= $id_document_front_file ? $id_document_front : base_url('images/broken.png') ?>"
|
||||
alt="document_front" style="width: 100%;"/>
|
||||
|
||||
</div>
|
||||
<div class="col-sm-6 text-center">
|
||||
<label><?= $this->lang->line('id_document_image_back') ?></label>
|
||||
<img src="<?= $id_document_back_file ? $id_document_back : base_url('images/broken.png')?>"
|
||||
alt="document_back" style="width: 100%;"/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
@ -278,6 +320,37 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="reject-modal">
|
||||
<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('reject_subscription') ?></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="reject-form">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="col-form-label"><?= $this->lang->line('reject_reason'); ?></label>
|
||||
<textarea required class="form-control" rows="5" name="reason"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-danger pull-left"
|
||||
id="reject-subscription"><?= $this->lang->line('Confirmer'); ?></button>
|
||||
<button type="button" class="btn btn-default pull-right"
|
||||
data-dismiss="modal"><?= $this->lang->line('Fermer'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
@ -369,7 +442,77 @@
|
|||
}
|
||||
);
|
||||
|
||||
$('#accept-subscription').click(function() {
|
||||
$.ajax({
|
||||
url: '<?= base_url('NanoHealthController/validateSubscription')?>',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
"subscription_id": "<?=$subscription->id ?>",
|
||||
"agent_id": "<?= $this->session->userdata('agent_id') ?>",
|
||||
},
|
||||
success: function (data) {
|
||||
// console.log('data',data);
|
||||
if(data.status === 200){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?= $this->lang->line('subscription_accepted')?>",
|
||||
text:"<?= $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(()=>{
|
||||
location.reload();
|
||||
});
|
||||
// alert("Les informations ont été mises à jour.") ? "" :
|
||||
}else{
|
||||
toastr.error(data.error , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
|
||||
$('#penalties').DataTable();
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?= $this->lang->line('error_message')?>" , "<?= $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#reject-subscription').click(function () {
|
||||
if ($('#reject-form')[0].checkValidity()) {
|
||||
let reason = $("textarea[name=reason]").val();
|
||||
if(reason.length > 500 ){
|
||||
toastr.warning( "<?= $this->lang->line('reason_rule')?>", "<?= $this->lang->line('management_rule')?>");
|
||||
}else{
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('NanoHealthController/rejectSubscription')?>',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
"subscription_id": "<?=$subscription->id ?>",
|
||||
"agent_id": "<?= $this->session->userdata('agent_id') ?>",
|
||||
"reason": reason
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.status === 200) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: "<?php echo $this->lang->line('subscription_rejected')?>",
|
||||
text: "<?php echo $this->lang->line('informations_updated')?>",
|
||||
timer: 3000
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
toastr.error(data.error, "<?php echo $this->lang->line('request_error')?>");
|
||||
}
|
||||
},
|
||||
error: function (resultat, statut, error) {
|
||||
console.log(resultat + " " + error);
|
||||
toastr.error("<?php echo $this->lang->line('error_message')?>", "<?php echo $this->lang->line('request_error')?>");
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
$('#reject-form')[0].reportValidity();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue