case 'submitLogEmailAddress': //if logEmailAddressID is sent then this is an update if (isset($_GET['logEmailAddressID']) && $_GET['logEmailAddressID'] != '') { $logEmailAddress = new LogEmailAddress(new NamedArguments(array('primaryKey' => $_GET['logEmailAddressID']))); } else { $logEmailAddress = new LogEmailAddress(); } $logEmailAddress->emailAddress = $_GET['emailAddress']; try { $logEmailAddress->save(); } catch (Exception $e) { echo $e->getMessage(); } break; case 'deleteLogEmailAddress': $logEmailAddress = new LogEmailAddress(new NamedArguments(array('primaryKey' => $_GET['logEmailAddressID']))); try { $logEmailAddress->delete(); } catch (Exception $e) { echo $e->getMessage(); } break; case 'updateOutlier': $overageCount = $_GET['overageCount']; $overagePercent = $_GET['overagePercent']; $outlier = new Outlier(new NamedArguments(array('primaryKey' => $_GET['outlierID']))); $outlier->overageCount = $_GET['overageCount']; $outlier->overagePercent = $_GET['overagePercent']; try { $outlier->save(); } catch (Exception $e) {
$emailLog = "<h2>" . count($sushiServicesArray) . " SUSHI runs found for day: " . $day . "</h2>"; foreach ($sushiServicesArray as $sushiService) { $sushiService->setImportDates(); $emailLog .= "<h3>" . $sushiService->getServiceProvider() . "</h3>"; //try to run! try { $emailLog .= nl2br($sushiService->runAll($_POST['overwritePlatform'])); } catch (Exception $e) { $emailLog .= nl2br($e->getMessage()); } } //if more than one run, send email if (count($sushiServicesArray) > 0) { $emailLog .= "<br /><br />Log in to <a href='" . $util->getPageURL() . "sushi.php'>Sushi Administration</a> for more information."; //send email to email addresses listed in DB $logEmailAddress = new LogEmailAddress(); $emailAddresses = array(); foreach ($logEmailAddress->allAsArray() as $emailAddress) { $emailAddresses[] = $emailAddress['emailAddress']; } if (count($emailAddresses) > 0) { $email = new Email(); $email->to = implode(", ", $emailAddresses); $email->subject = "SUSHI Scheduled run log for " . format_date(date) . " - " . count($sushiServicesArray) . " runs"; $email->message = $emailLog; if ($email->send()) { echo "Run complete. Log has been emailed to " . implode(", ", $emailAddresses); } else { echo "Email to " . implode(", ", $emailAddresses) . " Failed!"; } }