- Ajoute Dompdf via composer
- Ajoute un lien télecharger en PDF
- Refactorisation du render message et response
- Echappement html, et normalisation des retours chariots
105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
let $j = jQuery.noConflict();
|
|
|
|
$j(function(){
|
|
|
|
let currentMsg;
|
|
let currentMsgRef;
|
|
|
|
$j('body').on('click', '.answer-msg', function(e){
|
|
e.preventDefault();
|
|
|
|
currentMsg = $j(this).data('id');
|
|
currentMsgRef = $j(this).data('ref');
|
|
|
|
$j.post(
|
|
ajaxurl,
|
|
{
|
|
'action': 'getReponseForMsg',
|
|
'id' : currentMsg,
|
|
},
|
|
function(response){
|
|
$j('#reponse-msg').empty().html(response);
|
|
$j.fancybox.open({
|
|
src : '#reponse-msg',
|
|
type : 'inline',
|
|
afterClose: function (){
|
|
window.location.reload();
|
|
},
|
|
closeBtn: true
|
|
});
|
|
}
|
|
);
|
|
|
|
});
|
|
|
|
$j('body').on('click', '.show-msg', function(e){
|
|
e.preventDefault();
|
|
|
|
currentMsg = $j(this).data('id');
|
|
|
|
$j.post(
|
|
ajaxurl,
|
|
{
|
|
'action': 'getMsg',
|
|
'id' : currentMsg,
|
|
},
|
|
function(response){
|
|
$j('#reponse-msg').empty().html(response);
|
|
$j.fancybox.open({
|
|
src : '#reponse-msg',
|
|
type : 'inline',
|
|
afterClose: function (){
|
|
window.location.reload();
|
|
},
|
|
closeBtn: true
|
|
});
|
|
}
|
|
);
|
|
|
|
});
|
|
|
|
$j('body').on('click', '.send-answer', function(e){
|
|
e.preventDefault();
|
|
let email = $j('#emailTosend').val();
|
|
let message = $j('#msgTosend').val();
|
|
$j.post(
|
|
ajaxurl,
|
|
{
|
|
'action': 'sendReponse',
|
|
'email' : email,
|
|
'message' : message,
|
|
'id' : currentMsg,
|
|
'ref': currentMsgRef
|
|
},
|
|
function(response){
|
|
$j('#reponse-msg').empty().html(response);
|
|
}
|
|
);
|
|
});
|
|
|
|
$j('body').on('click', '.mark-msg', function (e) {
|
|
e.preventDefault();
|
|
|
|
let test = confirm("Êtes-vous sûr(e) ?");
|
|
if (!test)
|
|
return;
|
|
|
|
let self = this,
|
|
currentMsg = $j(self).data('id'),
|
|
$tdStatus = $j(self).parents('tr').eq(0).children('td').eq(2),
|
|
$tdDate = $j(self).parents('tr').eq(0).children('td').eq(7);
|
|
|
|
$j.post(
|
|
ajaxurl,
|
|
{
|
|
'action': 'markMsg',
|
|
'id': currentMsg,
|
|
},
|
|
function (date) {
|
|
$tdStatus.html("<p class='ldc_messages_green'>Traité</p>");
|
|
$j(self).parent().html("<a href='#' class='show-msg' data-id='" + currentMsg + "'>Afficher</a>");
|
|
$tdDate.text('Marqué comme traité');
|
|
}
|
|
);
|
|
});
|
|
});
|