GA4
[clinton/MarylandElectronicPetitionSignature.git] / admin / follow_up_emails.php
CommitLineData
c4f9ed02
PM
1<?PHP
2include_once('../email.php');
337f2b8e 3include_once('../slack.php');
431f376b 4$base_message = "I just wanted to take a second and follow up with your visit to md-petition.com and
1e7a4bde
PM
5see if you needed anything or had any questions? You should have received an
6alert 'Petition Signed' when you finished signing the petition and had the option to print a signed copy.
7If you did not receive the alert and would like help, let me know. The invite link is below to try again.";
c4f9ed02
PM
8
9// USAGE meps_mail('Patrick <baltimorehacker@gmail.com>','','Petition Follow-Up');
10
64feb164 11$q="SELECT * FROM follow_up where status = 'NEW'";
c4f9ed02
PM
12$r = $petition->query($q);
13while($d = mysqli_fetch_array($r)){
64feb164 14 $name = $d['name'];
91445973 15 $email = $d['email'];
64feb164
PM
16 $q2 = "SELECT * FROM presign where php_session_id = '$d[php_session]'";
17 $r2 = $petition->query($q2);
91445973 18 $presign = mysqli_fetch_array($r2);
64feb164 19 $visit = $presign['action_on'];
91445973
PM
20 $invite='';
21 $petition_name='Maryland';
22 if($d['petition_id'] != '0'){
23 $q2 = "SELECT * FROM petitions where petition_id = '$d[petition_id]'";
24 $r2 = $petition->query($q2);
25 $petitions = mysqli_fetch_array($r2);
26 $petition_name = $petitions['petition_name'];
27 $landing_page = $petitions['landing_page'];
28 $web_short_name = $petitions['web_short_name'];
29 $link = 'https://www.md-petition.com/?invite='.$web_short_name;
30 if ($landing_page != ''){
31 $link = 'https://www.md-petition.com/'.$landing_page;
32 }
33 $invite = "<br><br>Petition: $petition_name at <a href='$link'>$link</a>";
64feb164 34 }
0491415e
PM
35 $last = "<br><br>Follow up was requested at $visit";
36 $body = $base_message.$invite.$last;
37 $subject = "$petition_name Petition Follow-Up";
38 $to = "$name <$email>";
64feb164 39 $feedback_message = "TO: $to SUB: $subject MSG: $body sent on ".date('r')." by ".$_COOKIE['name'];
0491415e 40 $response = meps_mail($to,$body,$subject);
64feb164 41 $feedback_message = $petition->real_escape_string($feedback_message);
0491415e
PM
42 $response = $petition->real_escape_string($response);
43 $petition->query("update follow_up set status = 'sent', feedback_message = '$feedback_message', system_response='$response' where id = '$d[id]' ");
337f2b8e 44 slack_general('Sending Follow Up Email to '.$to,'automation');
c4f9ed02 45}
0491415e 46header('Location: /admin/follow_up_success.php');
c4f9ed02 47?>