From d033e2d58b0c41f57ec724277a3c869083836609 Mon Sep 17 00:00:00 2001 From: Florian Schmitt Date: Thu, 21 Dec 2023 13:57:27 +0300 Subject: [PATCH] feat : mail for demande de trajets --- fields/DemandeField.php | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 fields/DemandeField.php diff --git a/fields/DemandeField.php b/fields/DemandeField.php new file mode 100644 index 0000000..bc45649 --- /dev/null +++ b/fields/DemandeField.php @@ -0,0 +1,86 @@ +size = null; + $this->maxChars = null; + $this->default = ""; + } + + protected function renderInput($entry) + { + return; + } + + protected function renderStatic($entry) + { + return; + } + + public function formatValuesBeforeSave($entry) + { + $producteur = baz_valeurs_fiche($entry['listefiche8producteur']); + setlocale(LC_ALL, 'fr_FR.UTF8', 'fr_FR', 'fr', 'fr', 'fra', 'fr_FR@euro'); + setlocale(LC_TIME, "fr_FR"); + $dateTimeObj = new \DateTime($entry['date_souhaitee'], new \DateTimeZone('Europe/Paris')); + $date = + str_replace(' à 0:00', '', \IntlDateFormatter::formatObject( + $dateTimeObj, + 'eeee d MMMM y', + 'fr' + )); + $dateTimeObj = new \DateTime($entry['date_souhaitee_fin'], new \DateTimeZone('Europe/Paris')); + $datefin = + str_replace(' à 0:00', '', \IntlDateFormatter::formatObject( + $dateTimeObj, + 'eeee d MMMM y', + 'fr' + )); + $users = $GLOBALS['wiki']->LoadAll("select email from " . $GLOBALS['wiki']->config["table_prefix"] . "users"); + $url = $GLOBALS['wiki']->href('', 'PagePrincipale'); + $message = 'Une personne de votre commune a besoin de vous pour s’approvisionner chez le producteur ' . $producteur['bf_titre'] . ' entre le ' . $date . ' et le ' . $date . '. + +Si vous en avez la possibilité, soyez solidaire et créez une proposition de trajet dans la période correspondante. +Pour cela, rendez-vous sur le site de mutualisation de trajet de votre commune ou cliquez directement sur le lien : ' . $url . ' puis sur « Je propose un trajet". + +Nature des productions du producteur concerné : ' . $producteur['nature_des_productions'] . ' + +Par avance merci ! +La solidarité est une clé du bien vivre ensemble. + +En cas de souci avec l’outil numérique, vous pouvez contacter Cyrille Bombard au 06 63 28 13 11 ou par mail à cyrille.bombard@wision.info'; + + $message_html = nl2br($message); + if ($GLOBALS['wiki']->getPageTag() == $entry['id_fiche']) { + // modification : on ne fait pas de mail + } else { + // creation : on envoie un mail a tous + foreach ($users as $user) { + if (!empty($user["email"])) { + include_once 'tools/contact/libs/contact.functions.php'; + send_mail('noreply@yeswiki.pro', 'Outil Circuit Court', $user["email"], '[Outil CC] un habitant a BESOIN de vous pour un trajet à ' . $producteur['bf_titre'] . ' entre le ' . $date . ' et le ' . $datefin, $message, $message_html); + } + } + } + } + + // change return of this method to keep compatible with php 7.3 (mixed is not managed) + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return; + } +}