Thanasoft-H2F/gestion/src/js/modules/ajaxRequest.mjs

819 lines
28 KiB
JavaScript

import { showMessage, showSuccess, showError } from "@nextcloud/dialogs";
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { baseUrl, cur, getGlobal, insertCell, insertRow, insertRowWeekendRow, modifyCell } from "./mainFunction.mjs";
/**
* Update data
* @param table
* @param column
* @param data
* @param id
*/
export function updateDB(table, column, data, id) {
var myData = {
table: table,
column: column,
data: data,
id: id,
};
$.ajax({
url: baseUrl + '/update',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
showSuccess(t('gestion', 'Modification saved'));
}).fail(function (response, code) {
showError(t('gestion', 'There is an error with the format, please check the documentation'));
});
}
/**
* Delete data
* @param table
* @param id
*/
export function deleteDB(table, id) {
var myData = {
table: table,
id: id,
};
if(window.confirm(t('gestion','Are you sure you want to delete?'))){
$.ajax({
url: baseUrl + '/delete',
type: 'DELETE',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
getStats();
showSuccess(t('gestion', 'Modification saved'));
}).fail(function (response, code) {
showError(response);
});
}else{
showMessage(t('gestion', 'Nothing changed'))
}
}
/**
*
*/
export function getStats() {
$.ajax({
url: baseUrl + '/getStats',
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
var res = JSON.parse(response);
$("#statsclient").text(res.client);
$("#statsthanato").text(res.thanato);
$("#statsdefunts").text(res.defunt);
$("#statsdevis").text(res.devis);
$("#statstrajet").text(res.trajet);
$("#statslieu").text(res.lieu);
$("#statsfacture").text(res.facture);
$("#statsproduit").text(res.produit);
$("#statsarticles").text(res.article);
$("#statsbibliotheque").text(res.bibliotheque);
}).fail(function (response, code) {
showError(response);
});
}
/**
*
* @param {*} f1
*/
export function configuration(f1) {
$.ajax({
url: baseUrl + '/getConfiguration',
type: 'PROPFIND',
contentType: 'application/json',
async: false,
}).done(function (response) {
f1(response);
}).fail(function (response, code) {
showError(response);
});
}
/**
*
* @param {*} callback
*/
export function getBibliotheques(callback) {
$.ajax({
url: baseUrl + '/getBibliotheques',
type: 'PROPFIND',
contentType: 'application/json',
async: false,
}).done(function (response) {
callback(response);
}).fail(function (response, code) {
showError(response);
});
}
/**
*
*/
export function isconfig() {
$.ajax({
url: baseUrl + '/isconfig',
type: 'GET',
contentType: 'application/json'
}).done(function (response) {
if (!response) {
var modal = document.getElementById("modalConfig");
modal.style.display = "block";
}
})
}
/**
*
* @param {*} cur
*/
export function getAnnualTurnoverPerMonthNoVat(cur) {
$.ajax({
url: baseUrl + '/getAnnualTurnoverPerMonthNoVat',
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
var res = JSON.parse(response);
var curY = "";
var curRow;
var total=0;
res.forEach(function(item){
if(curY !== item.y){
if(curY !== ""){
insertCell(curRow, -1, cur.format(total));
total=0;
}
curY = item.y;
curRow = insertRow("Statistical", -1, 0, item.y);
modifyCell(curRow, (item.m), cur.format(Math.round(item.total)));
total+= Math.round(item.total);
}else{
modifyCell(curRow, (item.m), cur.format(Math.round(item.total)));
total+= Math.round(item.total);
}
});
// At the end
insertCell(curRow, -1, cur.format(total));
}).fail(function (response, code) {
showError(response);
});
}
export function getStatArticleAnnuel(annee) {
$.ajax({
url: baseUrl + '/getStatArticleAnnuel/'+annee,
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
// refresh table rows
var table = document.getElementById("Articles");
// Start from the last row to avoid issues with dynamic indexing
for (var i = table.rows.length - 1; i > 0; i--) {
table.deleteRow(i);
}
var res = JSON.parse(response);
var curRow;
var total = 0;
res.forEach(function(item, index){
curRow = insertRow("Articles", -1, 0, item.reference);
modifyCell(curRow, 1, item.janvier);
modifyCell(curRow, 2, item.fevrier);
modifyCell(curRow, 3, item.mars);
modifyCell(curRow, 4, item.avril);
modifyCell(curRow, 5, item.mai);
modifyCell(curRow, 6, item.juin);
modifyCell(curRow, 7, item.juillet);
modifyCell(curRow, 8, item.aout);
modifyCell(curRow, 9, item.septembre);
modifyCell(curRow, 10, item.octobre);
modifyCell(curRow, 11, item.novembre);
modifyCell(curRow, 12, item.decembre);
total=item.janvier+item.fevrier+item.mars+item.avril+item.mai+item.juin+item.juillet+item.aout+item.septembre+item.octobre+item.novembre+item.decembre;
insertCell(curRow, -1, total);
})
}).fail(function (response, code) {
showError(response);
});
}
export function getStatSoinsThanatoAnnuel(annee) {
$.ajax({
url: baseUrl + '/getStatSoinsThanatoAnnuel/'+annee,
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
// refresh table rows
var table = document.getElementById("Soins");
// Start from the last row to avoid issues with dynamic indexing
for (var i = table.rows.length - 1; i > 0; i--) {
table.deleteRow(i);
}
var res = JSON.parse(response);
var curRow;
var total = 0;
res.forEach(function(item, index){
curRow = insertRow("Soins", -1, 0, `${item.nom_thanato} ${item.prenom_thanato}`);
modifyCell(curRow, 1, item.janvier);
modifyCell(curRow, 2, item.fevrier);
modifyCell(curRow, 3, item.mars);
modifyCell(curRow, 4, item.avril);
modifyCell(curRow, 5, item.mai);
modifyCell(curRow, 6, item.juin);
modifyCell(curRow, 7, item.juillet);
modifyCell(curRow, 8, item.aout);
modifyCell(curRow, 9, item.septembre);
modifyCell(curRow, 10, item.octobre);
modifyCell(curRow, 11, item.novembre);
modifyCell(curRow, 12, item.decembre);
total=Number(item.janvier)+Number(item.fevrier)+Number(item.mars)+Number(item.avril)+Number(item.mai)+Number(item.juin)+Number(item.juillet)+Number(item.aout)+Number(item.septembre)+Number(item.octobre)+Number(item.novembre)+Number(item.decembre);
insertCell(curRow, -1, total);
})
}).fail(function (response, code) {
showError(response);
});
}
export function getStatSoinsThanatoWeekend(annee, mois) {
$.ajax({
url: baseUrl + `/getStatSoinsThanatoWeekend/${annee}/${mois}`,
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
var table = document.getElementById("SoinsWeekend");
for (var i = table.rows.length - 1; i > 0; i--) {
table.deleteRow(i);
}
var res = JSON.parse(response);
var curRow;
res.forEach(function(item, index){
curRow = insertRowWeekendRow("SoinsWeekend", -1, 0, `${item.nom_thanato} ${item.prenom_thanato}`);
modifyCell(curRow, 1, item.weekends_travailles);
})
}).fail(function (response, code) {
showError(response);
});
}
/**
*
* @param {*} myCase
*/
export function updateEditable(myCase) {
updateDB(myCase.dataset.table, myCase.dataset.column, myCase.innerText, myCase.dataset.id);
if(myCase.dataset.table == "lieu" && (myCase.dataset.column == "depart" || myCase.dataset.column == "arrivee")) { location.reload(); }
if (myCase.dataset.modifier === "getProduitsById") {getProduitsById();}
if (myCase.dataset.modifier === "getArticlesById") {getArticlesById();}
myCase.removeAttribute('contenteditable');
}
/**
*
* @param {*} lp
* @param {*} id
* @param {*} produitid
*/
export function listProduit(lp, id, produitid) {
$.ajax({
url: baseUrl + '/getProduits',
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
lp.append('<option data-table="produit_devis" data-column="produit_id" data-val="' + produitid + '" data-id="' + id + '">'+t('gestion','Cancel')+'</option>');
$.each(JSON.parse(response), function (arrayID, myresp) {
var selected = "";
if (produitid == myresp.id) {
selected = "selected";
}
lp.append('<option ' + selected + ' data-table="produit_devis" data-column="produit_id" data-val="' + myresp.id + '" data-id="' + id + '">' + myresp.reference + ' ' + myresp.description + ' ' + cur.format(myresp.prix_unitaire) + '</option>');
});
}).fail(function (response, code) {
showError(response);
});
}
/**
*
* @param {*} la
* @param {*} id
* @param {*} articleid
*/
export function listArticle(la, id, articleid) {
$.ajax({
url: baseUrl + '/getArticles',
type: 'PROPFIND',
contentType: 'application/json'
}).done(function (response) {
la.append('<option data-table="article_devis" data-column="article_id" data-val="' + articleid + '" data-id="' + id + '">'+t('gestion','Cancel')+'</option>');
$.each(JSON.parse(response), function (arrayID, myresp) {
var selected = "";
if (articleid == myresp.id) {
selected = "selected";
}
la.append('<option ' + selected + ' data-table="article_devis" data-column="article_id" data-val="' + myresp.id + '" data-id="' + id + '">' + myresp.reference + ' ' + myresp.description + ' ' + cur.format(myresp.prix_unitaire) + '</option>');
});
}).fail(function (response, code) {
showError(response);
});
}
/**
* Get list of product by id_devis
*/
export function getProduitsByIdDevis(id_devis) {
var my_data = { numdevis: id_devis };
return $.ajax({
url: baseUrl + '/getProduitsById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(my_data)
})
}
/**
* Get a product in database using id
*/
export function getProduitsById() {
var devis_id = $('#devisid').data('id');
var myData = { numdevis: devis_id, };
$.ajax({
url: baseUrl + '/getProduitsById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
$('#produits tbody').empty();
var total = 0;
var deleteDisable = "";
if ($('#produits').data("type") === "facture") {
deleteDisable = "d-none";
}
$.each(JSON.parse(response), function (arrayID, myresp) {
$('#produits tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getProduitsById" data-id="' + myresp.pdid + '" data-table="produit_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.pid + '" data-id="' + myresp.pdid + '" class="selectable">' + myresp.reference + '</div></td>' +
'<td>' + myresp.description + '</td>' +
'<td><div class="editable" data-table="produit_devis" data-column="comment" data-id="' + myresp.pdid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div></td>' +
'<td><div class="editableNumber getProduitsById" style="display:inline;" data-modifier="getProduitsById" data-table="produit_devis" data-column="quantite" data-id=' + myresp.pdid + '>' + myresp.quantite + '</div> </td>' +
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
total += (myresp.quantite * myresp.prix_unitaire);
});
$("#totaldevis tbody").empty();
getGlobal(devis_id);
}).fail(function (response, code) {
showError(response);
});
}
/**
* Get an article in database using id
*/
export function getArticlesById() {
var devis_id = $('#devisid').data('id');
var myData = { numdevis: devis_id };
$.ajax({
url: baseUrl + '/getArticlesById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
$('#articles tbody').empty();
var total = 0;
var deleteDisable = "";
if ($('#articles').data("type") === "facture") {
deleteDisable = "d-none";
}
$.each(JSON.parse(response), function (arrayID, myresp) {
$('#articles tbody').append('<tr><td><div data-html2canvas-ignore data-modifier="getArticlesById" data-id="' + myresp.adid + '" data-table="article_devis" class="' + deleteDisable + ' deleteItem icon-delete"></div><div style="display:inline;" data-val="' + myresp.aid + '" data-id="' + myresp.adid + '" class="articleSelectable">' + myresp.reference + '</div></td>' +
'<td>' + myresp.description + '</td>' +
'<td><div class="editable" data-table="article_devis" data-column="comment" data-id="' + myresp.adid + '">' + ((myresp.comment.length === 0) ? '-' : myresp.comment) + '</div></td>' +
'<td><div class="editableNumber getArticlesById" style="display:inline;" data-modifier="getArticlesById" data-table="article_devis" data-column="quantite" data-id=' + myresp.adid + '>' + myresp.quantite + '</div> </td>' +
'<td>' + cur.format(myresp.prix_unitaire) + '</td>' +
'<td>' + cur.format((myresp.quantite * myresp.prix_unitaire)) + '</td></tr>');
total += (myresp.quantite * myresp.prix_unitaire);
});
$("#totaldevis tbody").empty();
getGlobal(devis_id);
}).fail(function (response, code) {
showError(response);
});
}
/**
* Get an observation in database using id
*/
export function getObservationsById() {
var defunt_id = $('#defuntid').data('id');
var myData = { numdefunt: defunt_id, };
$.ajax({
url: baseUrl + '/getObservationsById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
$('#observations tbody').empty();
$.each(JSON.parse(response), function (arrayID, myresp) {
$('#observations tbody').append('<tr>'+
'<td><div class="w-100">' +
'<input type="text" id="obs-'+myresp.odid+'" class="editable-obs w-100" data-table="obs_defunt" data-column="designation" data-id="' + myresp.odid + '" value="'+((myresp.designation.length === 0) ? '-' : myresp.designation)+'"/>' +
'<ul class="obs-list obs-'+myresp.odid+'-list"></ul>'+
'</div></td>' +
'<td><div class="editable" data-table="obs_defunt" data-column="commentaire" data-id="' + myresp.odid + '">' + ((myresp.commentaire.length === 0) ? '-' : myresp.commentaire) + '</div></td>' +
'<td><div data-html2canvas-ignore data-modifier="getObservationsById" data-id="' + myresp.odid + '" data-table="obs_defunt" class="deleteItem icon-delete"></div></td>'+
'</tr>'
);
});
}).fail(function (response, code) {
showError(response);
});
}
/**
* Get hypodermiques in database using id
*/
export function getHypodermiquesyId() {
var defunt_id = $('#defuntid').data('id');
var myData = { numdefunt: defunt_id, };
$.ajax({
url: baseUrl + '/getHypodermiquesById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
$('#hypodermiques tbody').empty();
$.each(JSON.parse(response), function (arrayID, myresp) {
$('#hypodermiques tbody').append('<tr>'+
'<td><div class="editable" data-table="hypo_defunt" data-column="qte" data-id="' + myresp.hdid + '">' + myresp.qte + '</div></td>' +
'<td><div class="w-100">' +
'<input type="text" id="hypo-'+myresp.hdid+'" class="editable-hypo w-100" data-table="hypo_defunt" data-column="designation" data-id="' + myresp.hdid + '" value="'+((myresp.designation.length === 0) ? '-' : myresp.designation)+'"/>' +
'<ul class="hypo-list hypo-'+myresp.hdid+'-list"></ul>'+
'</div></td>'+
'<td><div class="w-100">'+
'<input type="text" id="hyposur-'+myresp.hdid+'" class="editable-hsur w-100" data-table="hypo_defunt" data-column="endroit" data-id="'+myresp.hdid+'" value="'+((myresp.endroit.length == 0) ? '-' : myresp.endroit)+'">'+
'<ul class="hyposur-list hyposur-'+myresp.hdid+'-list"></ul>'+
'</div></td>'+
'<td><div data-html2canvas-ignore data-modifier="getHypodermiquesById" data-id="' + myresp.hdid + '" data-table="hypo_defunt" class="deleteItem icon-delete"></div></td>'+
'</tr>'
);
});
}).fail(function (response, code) {
showError(response);
});
}
/**
* Get a bijoux in database using id
*/
export function getBijouxById() {
var defunt_id = $('#defuntid').data('id');
var myData = { numdefunt: defunt_id, };
$.ajax({
url: baseUrl + '/getBijouxById',
type: 'POST',
async: false,
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response, code) {
$('#bijoux tbody').empty();
$.each(JSON.parse(response), function (arrayID, myresp) {
$('#bijoux tbody').append('<tr>'+
'<td><div class="editable" data-table="bijou_defunt" data-column="designation" data-id="' + myresp.bdid + '">' + ((myresp.designation.length === 0) ? '-' : myresp.designation) + '</div></td>' +
'<td><div class="editable" data-table="bijou_defunt" data-column="commentaire" data-id="' + myresp.bdid + '">' + ((myresp.commentaire.length === 0) ? '-' : myresp.commentaire) + '</div></td>' +
'<td><div data-html2canvas-ignore data-modifier="getBijouxById" data-id="' + myresp.bdid + '" data-table="bijou_defunt" class="deleteItem icon-delete"></div></td>'+
'</tr>'
);
});
}).fail(function (response, code) {
showError(response);
});
}
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveNextcloud(myData) {
$.ajax({
url: baseUrl + '/savePDF',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
showMessage(t('gestion', 'Save in') + " " + $("#theFolder").val() + "/" + $("#pdf").data("folder"));
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
* Save document recap in Nextcloud
* @param {*} myData
*/
export function saveDocumentRecap(myData) {
$.ajax({
url: baseUrl + '/saveDocumentRecap',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
showMessage('Sauvegarde reussie.');
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
}
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveOnePdfInNextcloud(myData) {
$.ajax({
url: baseUrl + '/savePDF',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
showMessage(t('gestion', 'Save in') + " " + $("#theFolder").val() + "/");
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function savePdfToNextcloud(myData) {
$.ajax({
url: baseUrl + '/saveNewPDF',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
showMessage(t('gestion', 'Save in') + " " + myData.folders[0]);
showMessage(t('gestion', 'Save in') + " " + myData.folders[1]);
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
export function refreshFEC() {
var oReq = new XMLHttpRequest();
oReq.open('GET', baseUrl + '/refreshFEC', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.setRequestHeader("requesttoken", oc_requesttoken);
oReq.onload = function(e){
if (this.status == 200) {
showSuccess(t('gestion', 'Save in')+' '+JSON.parse(this.response)['name']+'\n'+t('gestion','(do not forget to show hidden folders)'));
}else{
showError(this.response);
}
};
oReq.send();
}
export function getMailServerFrom(input) {
var oReq = new XMLHttpRequest();
oReq.open('PROPFIND', baseUrl + '/getServerFromMail', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.setRequestHeader("requesttoken", oc_requesttoken);
oReq.onload = function(e){
if (this.status == 200) {
input.value = JSON.parse(this.response)['mail'];
}else{
showError(this.response);
}
};
oReq.send();
}
export function backup(){
var oReq = new XMLHttpRequest();
oReq.open('GET', baseUrl + '/backup', true);
oReq.setRequestHeader("Content-Type", "application/json");
oReq.setRequestHeader("requesttoken", oc_requesttoken);
oReq.onload = function(e){
if (this.status == 200) {
showSuccess(t('gestion', 'Save in')+' '+JSON.parse(this.response)['name']+'\n'+t('gestion','(do not forget to show hidden folders)'));
}else{
showError(this.response);
}
};
oReq.send();
}
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveAttestationPacemaker(myData) {
$.ajax({
url: baseUrl + '/saveAttestationPacemaker',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
if(!response) {
showMessage('Ce defunt n\'appartient à aucun devis.');
} else {
showSuccess('Sauvegardé dans '+JSON.parse(response)['path']);
}
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveRapportSoin(myData) {
$.ajax({
url: baseUrl + '/saveRapportSoin',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
if(!response) {
showMessage('Ce defunt n\'appartient à aucun devis.');
} else {
showSuccess('Sauvegardé dans '+JSON.parse(response)['path']);
}
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveRapportBijoux(myData) {
$.ajax({
url: baseUrl + '/saveRapportBijoux',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
if(!response) {
showMessage('Ce defunt n\'appartient à aucun devis.');
} else {
showSuccess('Sauvegardé dans '+JSON.parse(response)['path']);
}
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
*
* @param {*} callback
*/
export function getproduits(callback) {
$.ajax({
url: baseUrl + '/getArticles',
type: 'PROPFIND',
contentType: 'application/json',
async: false,
}).done(function (response) {
callback(response);
}).fail(function (response, code) {
showError(response);
});
}
/**
* Generate defunts
*/
export function genererDefunts() {
$.ajax({
url: baseUrl + '/genererDefunt',
type: 'POST',
contentType: 'application/json'
}).done(function (response) {
showSuccess('Les défunts ont bien été générés');
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};
/**
* Export devis to pdf
* @param {*} devisId
*/
export function exportDevisToPdf(devisId) {
if(devisId == null){
showError('Devis non trouvé');
return;
}
let payload = {
devisId : devisId
}
$.ajax({
url: baseUrl + '/devis/exportDevisToPdf',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(payload)
}).done(function (response) {
if(response == null) {
showMessage('Le devis n\'existe pas');
return;
}
var fileNames = JSON.parse(response);
fileNames.forEach(fileName => {
showSuccess('Sauvegardé dans' + fileName);
});
}).fail(function (response, code) {
showMessage(t('gestion', 'Erreur dans l\'export du devis en PDF'));
error(response);
});
};
/**
* Export multiple devis to pdf
* @param {*} devisId
*/
export function exportClientDevisByMonthAndYearToPdf(clientId,year,month) {
let payload = {
clientId: clientId,
month : month,
year : year
};
$.ajax({
url: baseUrl + '/devis/exportDevisByClientAndMonthYearToPdf',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(payload)
}).done(function (response) {
if(response != null) {
showSuccess('Sauvegardé dans' + response);
return;
}
showError(t('gestion', "Les données pour sauvegarde sont vides"));
}).fail(function (response, code) {
showError(t('gestion', "Erreur dans la génération de devis multiple"));
});
};
/**
* Export care certificate
* @param {*} defuntIdPayload
*/
export function exportCareCertificate(defuntIdPayload) {
$.ajax({
url: baseUrl + '/defunt/exportCareCertificate',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(defuntIdPayload)
}).done(function (response) {
if(response == null) {
showMessage('Ce defunt n\'appartient à aucun devis.');
} else {
showSuccess('Sauvegardé dans '+ response );
}
}).fail(function (response, code) {
showMessage(t('gestion', 'There is an error'));
error(response);
});
};