summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus_arch2017-03-07 11:53:37 +0100
committerhorus_arch2017-03-07 11:53:37 +0100
commitd4f8e252f43b2de2e52b4a883174516ebae9ad0e (patch)
treeaa1d9caf1c77cf8af6bcc05149467fef3dfbc035
parenta30b3234fe9bf5afbe5a22a2e26a031495d2c470 (diff)
downloadgospeladlershof.de-d4f8e252f43b2de2e52b4a883174516ebae9ad0e.tar.gz
Erster Versuch einer Erinnerungsmail, wenn wenige Proben eingetragen sind.
-rw-r--r--intern.gospeladlershof.de/code/erinnerung.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/code/erinnerung.php b/intern.gospeladlershof.de/code/erinnerung.php
new file mode 100644
index 0000000..89b2dce
--- /dev/null
+++ b/intern.gospeladlershof.de/code/erinnerung.php
@@ -0,0 +1,59 @@
+<?php
+
+require_once __DIR__ . '/db.php';
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use Pheanstalk\Pheanstalk;
+
+$db = get_db();
+$error_msg = "";
+
+if ( false === $db ) {
+ $error_msg = "Kann keine Verbindung zur Datenbank herstellen.";
+} else {
+ try {
+ $res = $db->query('SELECT count(*) FROM proben WHERE date(STR_TO_DATE(termin, "%d.%m.%Y")) > (SELECT CURDATE() ) ORDER BY date(STR_TO_DATE(termin, "%d.%m.%Y"));');
+ $count_proben = $res->fetch(PDO::FETCH_NUM)[0];
+ } catch(Exception $e) {
+ $error_msg = $e->getMessage();
+ }
+}
+
+if ( $error_msg != "" ) {
+ // Fehlerbehandlung
+ // schickt mir ne E-Mail mit der Fehlermeldung
+ $pheanstalk = new Pheanstalk('192.168.122.1');
+
+ $data = array(
+ 'To' => array('status@iamfabulous.de'),
+ 'Name' => 'Fehler | Gospelchor Adlershof',
+ 'From' => 'noreply@gospeladlershof.de',
+ 'ReplyTo' => 'status@iamfabulous.de',
+ 'Subject' => 'Gospelchor Adlershof | Error',
+ 'HTMLMessage' => null,
+ 'TextMessage' => $error_msg,
+ );
+
+ $pheanstalk
+ ->useTube('contactme_mail')
+ ->put(json_encode($data));
+} else {
+ if ( $count_proben <= 3 ) {
+ // email schicken, da wenige proben in der datenbank vorhanden sind
+ $pheanstalk = new Pheanstalk('192.168.122.1');
+
+ $data = array(
+ 'To' => array('status@iamfabulous.de'),
+ 'Name' => 'Gospelchor Adlershof',
+ 'From' => 'noreply@gospeladlershof.de',
+ 'ReplyTo' => 'status@iamfabulous.de',
+ 'Subject' => '[Chor-Admin] Wenige Proben',
+ 'HTMLMessage' => null,
+ 'TextMessage' => 'Hi Lotte\r\nes sind nur noch ' . $count_proben . ' eingetragen.\r\n\r\nViele Grüße\r\nMax',
+ );
+
+ $pheanstalk
+ ->useTube('contactme_mail')
+ ->put(json_encode($data));
+ }
+}