| 1 | <?PHP |
| 2 | include_once('../email.php'); |
| 3 | include_once('../slack.php'); |
| 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 should have received an |
| 6 | alert 'Petition Signed' when you finished signing the petition and had the option to print a signed copy. |
| 7 | If you did not receive the alert and would like help, let me know. The invite link is below to try again."; |
| 8 | |
| 9 | // USAGE meps_mail('Patrick <baltimorehacker@gmail.com>','','Petition Follow-Up'); |
| 10 | |
| 11 | $q="SELECT * FROM follow_up where status = 'NEW'"; |
| 12 | $r = $petition->query($q); |
| 13 | while($d = mysqli_fetch_array($r)){ |
| 14 | $name = $d['name']; |
| 15 | $email = $d['email']; |
| 16 | $q2 = "SELECT * FROM presign where php_session_id = '$d[php_session]'"; |
| 17 | $r2 = $petition->query($q2); |
| 18 | $presign = mysqli_fetch_array($r2); |
| 19 | $visit = $presign['action_on']; |
| 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>"; |
| 34 | } |
| 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>"; |
| 39 | $feedback_message = "TO: $to SUB: $subject MSG: $body sent on ".date('r')." by ".$_COOKIE['name']; |
| 40 | $response = meps_mail($to,$body,$subject); |
| 41 | $feedback_message = $petition->real_escape_string($feedback_message); |
| 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]' "); |
| 44 | slack_general('Sending Follow Up Email to '.$to,'automation'); |
| 45 | } |
| 46 | header('Location: /admin/follow_up_success.php'); |
| 47 | ?> |