|
|
@@ -0,0 +1,27 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+class CRM
|
|
|
+{
|
|
|
+ public static function sendInitEmail($dest, $name, $id)
|
|
|
+ {
|
|
|
+ $result = print_r(array("dest" => $dest, "name" => $name, "id" => $id), true);
|
|
|
+ mail($dest, "[Secret santa] - Création de votre campagne", $result, "Content-Type: text/HTML");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function sendMail($sender, $receiver, $campain)
|
|
|
+ {
|
|
|
+ $from = $to = null;
|
|
|
+ foreach ($campain->getUsers() as $i)
|
|
|
+ {
|
|
|
+ if ($i->getEmail() == $sender)
|
|
|
+ $from = $i;
|
|
|
+ if ($i->getEmail() == $receiver)
|
|
|
+ $to = $i;
|
|
|
+ }
|
|
|
+ if ($from == null || $to == null)
|
|
|
+ return;
|
|
|
+ $result = print_r(array("from" => $from->getName(), "receiver" => $to->getName(), "camp" => array("name" => $campain->getName(), "description" => $campain->getDescr())), true);
|
|
|
+ mail($sender, "[Secret santa] - Résultat du tirage au sort", $result, "Content-Type: text/HTML");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|