Skip to content
Snippets Groups Projects
Commit 56c5b32d authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

Change isset to !empty; More formatting and work on the csv file

parent 9a0de4e8
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ if (!empty($_POST)) {
if (in_array($_POST['location'], array("lied","union","sheldon","wick"))) {
$error_msg .= 'This location\'s outdoor events are not arranged through Landscape Services. Please contact them directly. <a href="http://www.unl.edu/unlspecialevents">Contact info available here</a>';
}
/* if (($_POST['location'] == 'other' && empty($_POST['location_other'])) ||
if (($_POST['location'] == 'other' && empty($_POST['location_other'])) ||
empty($_POST['location']) || empty($_POST['begindate_month']) || empty($_POST['begindate_day']) ||
empty($_POST['enddate_month']) || empty($_POST['enddate_day']) ||
empty($_POST['title']) || empty($_POST['starttime_hour']) || empty($_POST['endtime_hour']) || empty($_POST['attendance']) ||
......@@ -28,13 +28,13 @@ if (!empty($_POST)) {
empty($_POST['business']) || empty($_POST['weather']) || empty($_POST['agree'])
) {
$error_msg .= 'Please fill out all required fields';
}*/
}
if (empty($error_msg)) {
$mailer = new UNL_WDN_Emailer_Main();
$body = "<h3>Event Information</h3>";
if (isset($_POST['location_other'])) {
if (!empty($_POST['location_other'])) {
$body .= "<strong>Location:</strong> " . $_POST['location_other'] . "<br/>";
} else {
$body .= "<strong>Location:</strong> " . $_POST['location'] . "<br/>";
......@@ -72,6 +72,7 @@ if (!empty($_POST)) {
// Create the csv attachment
foreach(array_keys($_POST) as $key) {
if ($key != 'attendance')
$_POST[$key] = escape_csv_value($_POST[$key]);
}
$csv = ','
......@@ -79,11 +80,11 @@ if (!empty($_POST)) {
. $_POST['begindate_month'] . '/' . $_POST['begindate_day'] . '/' . $_POST['begindate_year'] . ','
. $_POST['enddate_month'] . '/' . $_POST['enddate_day'] . '/' . $_POST['enddate_year'] . ','
. ','
. (isset($_POST['location_other'])?$_POST['location_other']:$_POST['location']) . ','
. (!empty($_POST['location_other'])?$_POST['location_other']:$_POST['location']) . ','
. ($_POST['starttime_ampm']=='am'?$_POST['starttime_hour']:(int)$_POST['starttime_hour']+12) . ':' . ((int)$_POST['starttime_minute']==0?'00':$_POST['starttime_minute']) . ','
. ($_POST['endtime_ampm']=='am'?$_POST['endtime_hour']:(int)$_POST['endtime_hour']+12) . ':' . ((int)$_POST['endtime_minute']==0?'00':$_POST['endtime_minute']) . ','
. (isset($_POST['sponsor'])?$_POST['sponsor']:'') . ','
. $_POST['attendance'] . ','
. (!empty($_POST['sponsor'])?$_POST['sponsor']:'') . ','
. str_replace(",", "",$_POST['attendance']) . ','
. ','
. $_POST['name'] . ','
. ','
......@@ -93,39 +94,34 @@ if (!empty($_POST)) {
. $_POST['state'] . ','
. $_POST['zip'] . ','
. $_POST['business'] . ','
. (isset($_POST['home'])?$_POST['home']:'') . ','
. (isset($_POST['fax'])?$_POST['fax']:'') . ','
. (!empty($_POST['home'])?$_POST['home']:'') . ','
. (!empty($_POST['fax'])?$_POST['fax']:'') . ','
. $_POST['email'] . ','
. (isset($_POST['litter'])?true:false) . ','
. (isset($_POST['picnic'])?true:false) . ','
. (isset($_POST['litter_number'])?$_POST['litter_number']:'') . ','
. (isset($_POST['picnic_number'])?$_POST['picnic_number']:'') . ','
. ','
. (isset($_POST['electricity'])?true:false) . ','
. ','
. ','
. (!empty($_POST['litter'])?'true':'false') . ','
. (!empty($_POST['picnic'])?'true':'false') . ','
. (!empty($_POST['litter_number'])?$_POST['litter_number']:'') . ','
. (!empty($_POST['picnic_number'])?$_POST['picnic_number']:'') . ','
. 'true,'
. (!empty($_POST['electricity'])?'true':'false') . ','
. (!empty($_POST['litter_number'])? 12+((int)$_POST['litter_number']-1)*4 :'') . ','
. (!empty($_POST['picnic_number'])? 25+((int)$_POST['picnic_number']-1)*10 :'') . ','
. $_POST['weather'] . ','
. 'TBD,'
. 'TBD,'
. 'TBD,'
. 'T. Moore,'
. ','
. (!empty($_POST['description'])?$_POST['description']:'') . ' --- ' . (!empty($_POST['comments'])?$_POST['comments']:'') . ','
. ','
. ','
. ','
. ','
. (isset($_POST['description'])?$_POST['description']:'') . (isset($_POST['comments'])?$_POST['comments']:'') . ','
. ','
. ','
. ','
. ','
. ','
. ','
. ','
. ','
. ','
. 'false,'
. 'false,'
. 'false,'
. 'false,'
. 'false,'
. 'false,'
. ','
;
$mailer->attachment['file'] = $csv;
$mailer->attachment['c_type'] = 'text/csv';
$mailer->attachment['name'] = trim($_POST['title']) . '.csv';
$mailer->attachment['isfile'] = false;
// Setup and send email to requestor
$note = "<p>Note: This request does not confirm/reserve access to the space. We will contact you as to availability.</p>";
......@@ -135,6 +131,11 @@ if (!empty($_POST)) {
$mailer->subject = $emailSubject;
$mailer->send();
// Add the attachment for internal emails
$mailer->attachment['file'] = $csv;
$mailer->attachment['c_type'] = 'text/csv';
$mailer->attachment['name'] = 'newevent.csv';
$mailer->attachment['isfile'] = false;
// Setup email for UNL staff recipients
$mailer->html_body = $body;
$mailer->from_address = $_POST['email'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment