Update follow_up_emails.php
[clinton/MarylandElectronicPetitionSignature.git] / admin / follow_up_emails.php
1 <?PHP
2 include_once('../email.php');
3
4 $base_message = "I just wanted to take a second and follow up with your visit to md-petition.com and
5 see if you needed anything, or had any questions. You indicated a follow up if we did not receive your
6 completed petition. The software flagged your session, and we had a human review. You should receive an
7 alert 'Petition Signed' when complete. If you would like, please retry and if you continue to have trouble
8 I will work to fix it ASAP.";
9
10 // USAGE meps_mail('Patrick <baltimorehacker@gmail.com>','','Petition Follow-Up');
11
12 $q="SELECT * FROM follow_up where status = 'NEW'";
13 $r = $petition->query($q);
14 while($d = mysqli_fetch_array($r)){
15 $name = $d['name'];
16 $email = $d['email'];
17 $q2 = "SELECT * FROM presign where php_session_id = '$d[php_session]'";
18 $r2 = $petition->query($q2);
19 $presign = mysqli_fetch_array($r2);
20 $visit = $presign['action_on'];
21 $invite='';
22 $petition_name='Maryland';
23 if($d['petition_id'] != '0'){
24 $q2 = "SELECT * FROM petitions where petition_id = '$d[petition_id]'";
25 $r2 = $petition->query($q2);
26 $petitions = mysqli_fetch_array($r2);
27 $petition_name = $petitions['petition_name'];
28 $landing_page = $petitions['landing_page'];
29 $web_short_name = $petitions['web_short_name'];
30 $link = 'https://www.md-petition.com/?invite='.$web_short_name;
31 if ($landing_page != ''){
32 $link = 'https://www.md-petition.com/'.$landing_page;
33 }
34 $invite = "<br><br>Petition: $petition_name at <a href='$link'>$link</a>";
35 }
36 $last = "<br><br>Follow up was requested at $visit";
37 $body = $base_message.$invite.$last;
38 $subject = "$petition_name Petition Follow-Up";
39 $to = "$name <$email>";
40 $feedback_message = "TO: $to SUB: $subject MSG: $body sent on ".date('r')." by ".$_COOKIE['name'];
41 meps_mail($to,$body,$subject);
42 $feedback_message = $petition->real_escape_string($feedback_message);
43 $petition->query("update follow_up set status = 'sent', feedback_message = '$feedback_message' where id = '$d[id]' ");
44 }
45
46 ?>