function laromeemailinvoice_clearmsg() {
if (document.getElementById("notifications")!=null) {
document.getElementById("notifications").innerHTML="";
}
}
function laromeemailinvoice_showinfomsg(msg) {
if (document.getElementById("notifications")!=null) {
document.getElementById("notifications").innerHTML='
' + msg + '
';
}
}
function laromeemailinvoice_showsuccessmsg(msg) {
if (document.getElementById("notifications")!=null) {
document.getElementById("notifications").innerHTML='' + msg + '
';
}
else {
alert(msg);
}
}
function laromeemailinvoice_showerrormsg(msg) {
if (document.getElementById("notifications")!=null) {
document.getElementById("notifications").innerHTML='' + msg + '
';
}
else {
alert(msg);
}
}
function laromeemailinvoice_sendemailinvoice(id_order) {
var ajaxobj;
var json;
laromeemailinvoice_clearmsg();
laromeemailinvoice_showinfomsg("sending invoice");
ajaxobj=new XMLHttpRequest();
ajaxobj.open("GET","https://perfumeslarome.com/fr/module/laromeemailinvoice/ajax?action=invoice&orderid="+id_order,true);
ajaxobj.onreadystatechange=function() {
if (ajaxobj.readyState==4) {
if (ajaxobj.status==200) {
try {
json=JSON.parse(ajaxobj.responseText);
if (json.error!='') {
laromeemailinvoice_showerrormsg(json.error);
}
else {
laromeemailinvoice_showsuccessmsg(json.response);
}
}
catch(e) {
laromeemailinvoice_showerrormsg("response error");
}
}
else {
laromeemailinvoice_showerrormsg("connection error");
}
}
}
ajaxobj.send(null);
}