PageRenderTime 57ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/booking/reservations/email/confirmation_email.php

https://bitbucket.org/anneivycat/california-tour
PHP | 242 lines | 214 code | 26 blank | 2 comment | 50 complexity | 042829759aeb000931d45d5d7ae3f75d MD5 | raw file
  1. <?php
  2. error_reporting(E_ALL);
  3. date_default_timezone_set('America/Los_Angeles');
  4. if(isset($itinerary))
  5. $attachment = str_replace("http://www.california-tour.com","",$itinerary);
  6. else
  7. $itinerary = '';
  8. if(isset($attachment)){
  9. $attachment = str_replace("http://california-tour.com","",$attachment);
  10. $attachment = $_SERVER["DOCUMENT_ROOT"] . $attachment;
  11. }else{
  12. $attachment = '';
  13. }
  14. $attach_size = '';
  15. $file_handle = '';
  16. $file_content = '';
  17. $file_content = '';
  18. $file_name = '';
  19. // process attachment
  20. if(file_exists($attachment)){
  21. $attach_size = filesize($attachment);
  22. $file_handle = fopen($attachment,"r");
  23. $file_content = fread($file_handle,$attach_size);
  24. fclose($file_handle);
  25. $file_content = chunk_split(base64_encode($file_content));
  26. $file_name = basename($attachment);
  27. $inc_file = true;
  28. $itin_note = 'Your itinerary is attached. You may also download your itinerary from:';
  29. }else{
  30. $inc_file = false;
  31. $itin_note = 'You may download your itinerary from:';
  32. }
  33. $mail_From = "tour@california-tour.com";
  34. $mail_FromName = "California Tour";
  35. $mail_Address = $_REQUEST['e_mail'];
  36. $mail_Subject = "Thank you for booking at California-Tour";
  37. // HTML body
  38. $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  39. ';
  40. $body .= '<html>
  41. <head>
  42. ';
  43. $body .= '<title>California Tours - Confirmation</title>
  44. ';
  45. $body .= '
  46. </head>
  47. ';
  48. $body .= '<body style="font-family: Verdana,helvetica,arial,sans-serif; background-color:#eee; font-size:11px; color:#222; line-height: 15px;padding:15px;">
  49. ';
  50. $body .= '<table width="600" cellpadding="10" cellspacing="10" align="center" style="background-color:#fff; border:1px solid #d4d4d4;">
  51. ';
  52. $body .= '<tr><td width="160"><p><a href="http://www.california-tour.com"><img src="http://www.california-tour.com/california/images/california_tours_logo/californiatours140.gif" width="140" height="61" alt="California Tours" border="0" /></a></p></td>
  53. ';
  54. $body .= '<td width="440" align="right"><p>Address: 2015 Center Street, 1st floor<br />Berkeley, CA 94704<br />Toll Free: (877) 338-3883<br />Phone: (510) 549-4211<br /> Fax: (510) 549-4210</p></td></tr>
  55. ';
  56. $body .= '<tr><td colspan="2"><h3>Your reservation is confirmed!</h3><p>Please print this page for your records. Be sure to note your pick up location and time. </p>
  57. ';
  58. $body .= '<p style="font-weight:bold;text-align:center;">Reservation Number: ' . $_REQUEST['reservation_num'] . '<br /> Customer Name: ' . ucfirst(strtolower($_REQUEST['first_name'])) . ' ' . ucfirst(strtolower($_REQUEST['last_name'])) . '</p>';
  59. if(isset($ScheduledTourBookId_2) && $ScheduledTourBookId_2 != 0 && is_numeric($ScheduledTourBookId_2)) {
  60. $body .= '<p style="font-weight:bold;text-align:center;">Reservation 2 Number: ' . $ReservationId_2 . '<br /> Customer 2 Name: ' . ucfirst(strtolower($FIRST_NAME_2)) . ' ' . ucfirst(strtolower($LAST_NAME_2)) . '</p>';
  61. }
  62. if(isset($ScheduledTourBookId_3) && $ScheduledTourBookId_3 != 0 && is_numeric($ScheduledTourBookId_3)) {
  63. $body .= '<p style="font-weight:bold;text-align:center;">Reservation 3 Number: ' . $ReservationId_3 . '<br /> Customer 3 Name: ' . ucfirst(strtolower($FIRST_NAME_3)) . ' ' . ucfirst(strtolower($LAST_NAME_3)) . '</p>';
  64. }
  65. if(isset($ScheduledTourBookId_4) && $ScheduledTourBookId_4 != 0 && is_numeric($ScheduledTourBookId_4)) {
  66. $body .= '<p style="font-weight:bold;text-align:center;">Reservation 4 Number: ' . $ReservationId_4 . '<br /> Customer 4 Name: ' . ucfirst(strtolower($FIRST_NAME_4)) . ' ' . ucfirst(strtolower($LAST_NAME_4)) . '</p>';
  67. }
  68. $body .= '
  69. <p>Please refer to your reservation number if you need to contact California Tours for any reason.</p>
  70. ';
  71. $body .= '<p>Thank you for choosing California Tours and have a nice trip!</p>
  72. ';
  73. $body .= '<h3>Your Receipt</h3>
  74. ';
  75. $body .= '<table cellpadding="0" cellspacing="0" border="0" style="width:500px;padding:15px;margin:15px;">
  76. ';
  77. $body .= '<tr><th colspan="2">' . $_REQUEST['tour_name'] . '</th></tr>
  78. ';
  79. $body .= '<tr><td>Total Charge:</td><td>' . $_REQUEST['total_charge'] . '</td></tr>
  80. ';
  81. $body .= '<tr><td>Price per person:</td><td>' . sprintf("%0.2f",$_REQUEST['total_charge']/$total_passenger_count) . '</td></tr>
  82. ';
  83. $body .= '<tr><td>Depart date:</td><td>' . date("F j, Y" , strtotime($_REQUEST['depart_date'])) . '</td></tr>
  84. ';
  85. $body .= '<tr><td>Return date:</td><td>' . date("F j, Y" , strtotime($_REQUEST['return_date'])) . '</td></tr>
  86. ';
  87. if($_REQUEST['depart_date'] != $_REQUEST['return_date']) {
  88. $body .='<tr><td>Occupancy:</td><td>' . @$occupancy_array[@$_REQUEST['occupancy']] . '</td></tr>';
  89. $body .= '<tr><td>Roommate:</td><td>';
  90. if(@$_REQUEST['occupancy'] > 1) {
  91. $body .= 'Yes';
  92. } else {
  93. $body .= 'No';
  94. }
  95. $body .= '</td></tr>
  96. ';
  97. }
  98. $body .= '<tr><th colspan="2"><hr /></th></tr>
  99. ';
  100. $body .= '<tr><td>Pick-up time:</td><td>' . $pu_time . '</td></tr>
  101. ';
  102. $body .= '<tr><td>Pick-up location:</td><td>' . $pu_location . '</td></tr>
  103. ';
  104. $body .= '<tr><td colspan="2">'.$itin_note.'<br />';
  105. $body .= $itinerary;
  106. $body .= '</td></tr>';
  107. $body .= '</table><br />
  108. ';
  109. if ($pu_imagelink != "") {
  110. $body .= '<p><img src="' . $pu_imagelink . '" alt="Pick up location map" /></p>';
  111. }
  112. $body .= '</td></tr></table>
  113. </body></html>
  114. ';
  115. $text_body .= 'California Tours
  116. Address: 2015 Center Street, 1st floor
  117. Berkeley, CA 94704
  118. Toll Free: (877) 338-3883
  119. Phone: (510) 549-4211
  120. Fax: (510) 549-4210
  121. Your reservation is confirmed!
  122. Please print this page for your records. Be sure to note your pick up location and time.
  123. Reservation Number: ' . $_REQUEST['reservation_num'] . '
  124. Customer Name: ' . ucfirst(strtolower($_REQUEST['first_name'])) . ' ' . ucfirst(strtolower($_REQUEST['last_name'])) . "
  125. ";
  126. if($ScheduledTourBookId_2 != 0 && is_numeric($ScheduledTourBookId_2)) {
  127. $text_body .= 'Reservation 2 Number: ' . $ReservationId_2 . "\n";
  128. $text_body .= 'Customer 2 Name: ' . ucfirst(strtolower($FIRST_NAME_2)) . ' ' . ucfirst(strtolower($LAST_NAME_2)) . '
  129. ';
  130. }
  131. if($ScheduledTourBookId_3 != 0 && is_numeric($ScheduledTourBookId_3)) {
  132. $text_body .= 'Reservation 3 Number: ' . $ReservationId_3 . "\n";
  133. $text_body .= 'Customer 3 Name: ' . ucfirst(strtolower($FIRST_NAME_3)) . ' ' . ucfirst(strtolower($LAST_NAME_3)) . '
  134. ';
  135. }
  136. if($ScheduledTourBookId_4 != 0 && is_numeric($ScheduledTourBookId_4)) {
  137. $text_body .= 'Reservation 4 Number: ' . $ReservationId_4 . "\n";
  138. $text_body .= 'Customer 4 Name: ' . ucfirst(strtolower($FIRST_NAME_4)) . ' ' . ucfirst(strtolower($LAST_NAME_4)) . '
  139. ';
  140. }
  141. $text_body .= 'Please refer to your reservation number if you need to contact California Tours for any reason.
  142. Thank you for choosing California Tours and have a nice trip!
  143. ------------------------------------------------------------
  144. Your Receipt
  145. Tour Name: ' . $_REQUEST['tour_name'] . '
  146. Total Charge: ' . $_REQUEST['total_charge'] . '
  147. Price per person: ' . sprintf('%0.2f', $_REQUEST['total_charge']/$total_passenger_count) . '
  148. Depart date: ' . date("F j, Y" , strtotime($_REQUEST['depart_date'])) . '
  149. Return date: ' . date("F j, Y" , strtotime($_REQUEST['return_date'])) . '
  150. ';
  151. if($_REQUEST['depart_date'] != $_REQUEST['return_date']) {
  152. $text_body .= 'Occupancy: ' . @$occupancy_array[@$_REQUEST['occupancy']] . '
  153. ';
  154. $text_body .= 'Roommate: ';
  155. if(@$_REQUEST['occupancy'] > 1) {
  156. $text_body .= 'Yes';
  157. } else {
  158. $text_body .= 'No';
  159. }
  160. }
  161. $text_body .= '
  162. ';
  163. if($pu_time != '')
  164. $text_body .= 'Pick-up time: ' . $pu_time . '
  165. ';
  166. if($pu_location != '')
  167. $text_body .= 'Pick-up location: ' . $pu_location . '
  168. ';
  169. if($pu_imagelink != '')
  170. $text_body .= 'Download pick-up location map: ' . $pu_imagelink . '
  171. ';
  172. if($itinerary != '')
  173. $text_body .= 'Download Itinerary: \n' . $itinerary . '
  174. ';
  175. $boundary = 'This_is_the_boundary-'.md5(date('r', time()));
  176. $mail_message = "
  177. --$boundary
  178. Content-Type: text/plain; charset=\"utf-8\"\r\nContent-Transfer-Encoding: 7bit
  179. $text_body
  180. --$boundary
  181. Content-Type: text/html; charset=\"utf-8\"\r\nContent-Transfer-Encoding: 7bit
  182. $body
  183. ";
  184. if($file_content != '' && $inc_file){
  185. $mail_message .= "--$boundary
  186. Content-Type: application/octet-stream; name=\"$file_name\"
  187. Content-Transfer-Encoding: base64
  188. Content-Disposition: attachment
  189. filename=\"$file_name\"
  190. $file_content
  191. ";
  192. }
  193. $mail_message .= "
  194. --$boundary--";
  195. $cont_type = 'multipart/alternative';
  196. if($file_content != '' && $inc_file)
  197. $cont_type = 'multipart/mixed';
  198. $mailYes = mail($mail_Address,$mail_Subject, $mail_message,
  199. "From: $mail_FromName <$mail_From>\r\nMIME-Version: 1.0\r\nContent-type: $cont_type;boundary=$boundary\r\nContent-Transfer-Encoding: 7bit\r\n\r\n");
  200. $mailYes3 = mail("tod@almost-everything.com","COPY - ".$_REQUEST['reservation_num'] . " - ".$mail_Subject, $mail_message,
  201. "From: $mail_FromName <$mail_From>\r\nMIME-Version: 1.0\r\nContent-type: $cont_type;boundary=$boundary\r\nContent-Transfer-Encoding: 7bit\r\n\r\n");
  202. if(!$mailYes)
  203. {
  204. echo "Message was not sent\n";
  205. echo "Mailer Error: " . $mail->ErrorInfo;
  206. echo "Please contact the webmaster: tour@california-tour.com";die();
  207. }
  208. ?>