1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
//function sendMessage(){}
// modif des paramètre d'envoi d'e-mail depuis l'espace admin
function changeRecipient(id){
const email = document.getElementById('recipient').value;
const hidden = document.getElementById('recipient_hidden').value;
fetch('index.php?action=recipient_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: id, email: email, hidden: hidden })
})
.then(response => response.json())
.then(data => {
if(data.success){
toastNotify('Adresse e-mail de destination modifiée');
}
else{
toastNotify('E-mail non valide');
}
})
.catch(error => {
console.error('Erreur:', error);
});
}
function sendTestEmail(id){
const admin_form = document.querySelector('.admin_form');
const test_email_success = document.querySelector('.test_email_success');
test_email_success.innerHTML = 'Envoi en cours, veuillez patienter';
test_email_success.style.backgroundColor = 'yellow';
fetch('index.php?action=test_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ id: id})
})
.then(response => response.json())
.then(data => {
let message;
let color;
if(data.success){
message = 'E-mail de test envoyé avec succès';
color = 'chartreuse';
}
else{
message = "Erreur à l'envoi de l'e-mail, vérifiez la configuration du serveur";
color = "orangered"
}
test_email_success.innerHTML = message;
toastNotify(message);
test_email_success.style.backgroundColor = color;
})
.catch(error => {
console.error('Erreur:', error);
});
}
function sendVisitorEmail(id){
const send_email_success = document.querySelector('.send_email_success');
send_email_success.innerHTML = 'Envoi en cours, veuillez patienter';
send_email_success.style.backgroundColor = 'yellow';
const email_name = document.getElementById('email_name').value;
const email_address = document.getElementById('email_address').value;
const email_message = document.getElementById('email_message').value;
const email_captcha = document.getElementById('email_captcha').value;
const email_hidden = document.getElementById('email_hidden').value;
fetch('index.php?action=send_email', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: email_name,
email: email_address,
message: email_message,
captcha: email_captcha,
hidden: email_hidden,
id: id
})
})
.then(response => response.json())
.then(data => {
let message;
let color;
if(data.success){
message = 'Votre E-mail a été envoyé!';
color = 'lawngreen';
}
else{
message = "Votre message n'a pas pu être envoyé, votre e-mail ou le captcha ne sont peut-être pas corrects";
color = "orangered"
}
send_email_success.innerHTML = message;
toastNotify(message);
send_email_success.style.backgroundColor = color;
})
.catch(error => {
console.error('Erreur:', error);
});
}
|