feat : mail for demande de trajets
This commit is contained in:
parent
07d24e4e2c
commit
d033e2d58b
1 changed files with 86 additions and 0 deletions
86
fields/DemandeField.php
Normal file
86
fields/DemandeField.php
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace YesWiki\Custom\Field;
|
||||||
|
|
||||||
|
include_once 'custom/templates/bazar/circuitscourt.php';
|
||||||
|
|
||||||
|
use YesWiki\Bazar\Field\BazarField;
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Field({"demande"})
|
||||||
|
*/
|
||||||
|
class ReservationField extends BazarField
|
||||||
|
{
|
||||||
|
public function __construct(array $values, ContainerInterface $services)
|
||||||
|
{
|
||||||
|
parent::__construct($values, $services);
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue