/
archives.php
111 lines (108 loc) · 5.47 KB
/
archives.php
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
108
109
110
111
<?php
$msg_id = (empty($_GET['msg_id']) ? "" : $_GET['msg_id']);
$msg_id = (empty($_POST['msg_id']) ? $msg_id : $_POST['msg_id']);
$token=(empty($_POST['token'])?"":$_POST['token']);
if(!isset($token) || $token=="")$token=(empty($_GET['token'])?"":$_GET['token']);
if(!tok_val($token)){
header("Location:login.php?error=2");
exit;
}
echo '<article class="module width_full">';
echo "<script>function deleteArchive(){document.archive_form.elements['action'].value = 'delete';document.archive_form.submit();}</script>";
echo "<header><h3>".translate("ARCHIVE_TITLE") . "</h3></header>
<div class='module_content'>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post' name='archive_form'>";
$newsletter=getConfig($cnx,$list_id,$row_config_globale['table_listsconfig']);
if (!empty($msg_id) && $action == "delete"){
$deleted = deleteArchive($cnx, $row_config_globale['table_archives'], $msg_id);
}
if ($archives = getArchivesselectList($cnx, $row_config_globale['table_archives'], $msg_id,'archive_form',$list_id) != -1) {
echo "<input type='submit' value='" . translate("ARCHIVE_DISPLAY") . "' class='button' />
<input type='button' value='" . translate("ARCHIVE_DELETE") . "' onclick='deleteArchive();' />
<input type='hidden' name='page' value='archives' />
<input type='hidden' name='action' value='' />
<input type='hidden' name='list_id' value='$list_id' />
<input type='hidden' name='token' value='$token' />";
} else {
echo (translate("NO_ARCHIVE"));
}
echo "</form>";
if (!empty($msg_id) && empty($action)) {
$diff_send = $cnx->SqlRow("SELECT s.cpt AS cpt_send, COUNT(e.email) AS cpt_rec FROM
".$row_config_globale['table_email']." e, ".$row_config_globale['table_send']." s
WHERE e.list_id=s.id_list
AND s.id_mail = '".$msg_id."'
AND s.id_list = '".$list_id."'
AND e.error = 'N';");
$to_send = $diff_send['cpt_rec']-$diff_send['cpt_send'];
$js = false;
if($to_send==1){
echo '<br><div id="messInfo"><h4 class="alert_warning" id="SendIt">Attention : '.$to_send.' inscrit n\'a pas reçu cette information ! Cliquez ici pour la renvoyer à cet inscrit<h4></div><br>';
$js = true;
}elseif($to_send>1){
echo '<br><div id="messInfo"><h4 class="alert_warning" id="SendIt">Attention : '.$to_send.' inscrits n\'ont pas reçu cette information ! Cliquez ici pour la renvoyer à ces inscrits</h4></div><br>';
$js = true;
}
if($js){ ?>
<script type="text/javascript">
$("#SendIt").click(function(){
$('#msg').show();
$(function(){
var begin = <?php echo $diff_send['cpt_send']?>;
var sn = <?php echo $diff_send['cpt_rec'];?>;
var step = 'send';
var pct = 0;
var list_id = <?=intval($list_id);?>;
var token = '<?=$token;?>';
var msg_id = <?=$msg_id;?>;
var tts = 0;
function progresspump(){
$.ajax({
url:"send.php",
type: "GET",
dataType:"json",
data:'list_id=' + list_id +'&token=' + token + '&begin='+ begin + '&sn=' + sn + '&step=' + step +'&msg_id=' + msg_id,
success:function(rj){
begin = rj.begin;
sn = rj.sn;
step = rj.step;
pct = (rj.pct!=''?rj.pct:0);
msg_id= rj.msg_id;
tts = (rj.TTS!=''?rj.TTS:0);
$("#pct").css('width',pct+'%');
$("#done").html(pct+'%'+'(Execution time : '+tts+' ms)');
if(pct > 99.999) {
clearInterval(progresspump);
$('.record').hide('slow');
$("#send_title").text("Envoi terminé...");
setTimeout(function() {
$("#send_title").text("Redirection en cours...");
},3000);
setTimeout(function() {
window.location.href='?page=tracking&list_id=<?=$list_id;?>&token=<?=$token;?>&date=ch';
},3000);
}
}
});
setTimeout(progresspump,5000); // 10000
}progresspump();});
});
</script>
<div id='msg' style='display:none'>
<h2 id='send_title'>Progression de l'envoi en cours :</h2>
<div class="8u"><div class="record"><div id="pct" class="bar" style="width:0%"><span id="done">0,00%</span></div></div></div>
<br><br>
</div>
<?php
}
getArchiveMsg($cnx, $row_config_globale['table_archives'], $msg_id, $token, $list);
}
if (!empty($msg_id) && $action == "delete") {
if ($deleted){
echo "<h4 class='alert_success'>" . translate("ARCHIVE_DELETED") . "</h4>";
}else{
echo "<h4 class='alert_error'>" . translate("ERROR_DELETING_ARCHIVE") . "</h4>";
}
}
echo "</div></article>";
?>