Created
November 4, 2019 17:57
-
-
Save Coop920/ff8e1bea3c3a32f35b99351583488b54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Delaware OPAL | |
*/ | |
$customer_id = isset($_POST["customer_id"]) ? $_POST["customer_id"] : ""; | |
$first_name = isset($_POST["first_name"]) ? $_POST["first_name"] : ""; | |
$last_name = isset($_POST["last_name"]) ? $_POST["last_name"] : ""; | |
$email = isset($_POST["email"]) ? $_POST["email"] : ""; | |
$street_address1 = isset($_POST["street_address1"]) ? $_POST["street_address1"] : ""; | |
$street_address2 = isset($_POST["street_address2"]) ? $_POST["street_address2"] : ""; | |
$city = isset($_POST["city"]) ? $_POST["city"] : ""; | |
$state = isset($_POST["state"]) ? $_POST["state"] : ""; | |
$zip = isset($_POST["zip"]) ? $_POST["zip"] : ""; | |
$phone = isset($_POST["phone"]) ? $_POST["phone"] : ""; | |
$location_id = isset($_POST["location_id"]) ? $_POST["location_id"] : ""; | |
$location_name = isset($_POST["location_name"]) ? $_POST["location_name"] : ""; | |
$email_permission = isset($_POST["email_permission"]) ? $_POST["email_permission"] : ""; | |
$start_datetime = isset($_POST["start_datetime"]) ? $_POST["start_datetime"] : ""; | |
$end_datetime = isset($_POST["end_datetime"]) ? $_POST["end_datetime"] : ""; | |
$act = isset($_POST["act"]) ? strtolower($_POST["act"]) : ""; | |
$technician_name = isset($_POST["technician_name"]) ? $_POST["technician_name"] : ""; | |
$job_category = isset($_POST["job_category"]) ? $_POST["job_category"] : ""; | |
$workorder_token = isset($_POST["workorder_token"]) ? $_POST["workorder_token"] : ""; | |
/*$fields_values = 'customer_id=' . $customer_id . | |
'&first_name=' . $first_name . | |
'&last_name=' . $last_name . | |
'&email=' . $email . | |
'&street_address1=' . $street_address1 . | |
'&street_address2=' . $street_address2 . | |
'&city=' . $city . | |
'&state=' . $state . | |
'&zip=' . $zip . | |
'&phone=' . $phone . | |
'&location_id=' . $location_id . | |
'&location_name=' . $location_name . | |
'&start_datetime=' . $start_datetime . | |
'&end_datetime=' . $end_datetime . | |
'&act=' . $act . | |
'&technician_name=' . $technician_name . | |
'&job_category=' . $job_category; | |
//echo $fields_values; | |
error_log($fields_values);*/ | |
$entry["date_created"] = date("Y-m-d H:i:s"); | |
$entry["is_read"] = 0; | |
$entry["source_url"] = "text.com"; | |
$entry["status"] = "Active"; | |
$entry["1"] = $customer_id; | |
$entry["2"] = $first_name; | |
$entry["3"] = $last_name; | |
$entry["4"] = $email; | |
$entry["6.1"] = $street_address1; | |
$entry["6.2"] = $street_address2; | |
$entry["6.3"] = $city; | |
$entry["6.4"] = $state; | |
$entry["6.5"] = $zip; | |
$entry["6.6"] = "United States"; | |
$entry["15"] = $phone; | |
$entry["7"] = $location_id; | |
$entry["8"] = $location_name; | |
$entry["9"] = $email_permission; | |
$entry["10"] = $start_datetime; | |
$entry["11"] = $end_datetime; | |
$entry["12"] = $act; | |
$entry["13"] = $technician_name; | |
$entry["14"] = $job_category; | |
$entry["16"] = $workorder_token; | |
//error_log(print_r($_POST)); | |
//This is for sending that data to the first contact form | |
if($act == "open"){ | |
$entry["form_id"] = 1; | |
$subject = "Your Appointment Confirmation from Precision Garage Door"; | |
$message = "Dear {$first_name}, | |
Thank you for scheduling an appointment with Precision Garage Door. | |
Your appointment has been confirmed for " . date('g:i A l, F d, Y', strtotime($start_datetime)) . " | |
The address we have on file is {$street_address1}, {$city}, {$state} {$zip}. | |
Our records show that your contact phone number is {$phone}. Please contact our office immediately if any of this information is not correct. | |
Your technician is tentatively scheduled to be {$technician_name}. He will contact you when he is approximately 30-60 minutes from your home. (Note, your technician may be changed last minute due to schedule shifts.) | |
Thank you for choosing Precision Garage Door. Do not hesitate to call us with any questions or concerns. | |
Sincerely, | |
Adam Schultz\n | |
General Manager\n | |
(888) 506-9763"; | |
} | |
//This is for sending the data to the second contact form | |
else if($act == "close"){ | |
$entry["form_id"] = 2; | |
$subject = "Thank you for your business"; | |
$message = "Dear {$first_name}, | |
Thank you for choosing Precision Garage Door. I hope your recent experience with our company was a great one. | |
As a highly valued customer, your feedback is immensely important to us. Please take a moment to rate your experience: http://MyNewDoor.com/Reviews | |
If for any reason you are not satisfied, I would consider it a favor if you call and give me the opportunity to make it right. | |
Thank you for choosing Precision Garage Door! | |
Adam Schultz\n | |
General Manager\n | |
(888) 506-9763"; | |
} | |
//If you aren't supposed to be here, you will get redirected to the homepage. | |
else { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
/*Add entry to Gravity Forms*/ | |
$add_my_entry = GFAPI::add_entry($entry); | |
/* Now lets send some emails */ | |
$from_name = "Precision Garage Door"; | |
$from = "[email protected]"; | |
$headers = array(); | |
$headers["From"] = "From: \"{$from_name}\" <{$from}>"; | |
$headers["Reply-To"] = "Reply-To: {$from}"; | |
$headers["Content-type"] = "Content-type: text/plain; charset=" . get_option('blog_charset'); | |
$email_out = wp_mail( $email, $subject, $message, $headers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment