initial commit of code
This commit is contained in:
parent
9b00433142
commit
17d2c64f66
13 changed files with 1928 additions and 0 deletions
81
fields/ReservationField.php
Normal file
81
fields/ReservationField.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace YesWiki\Custom\Field;
|
||||
|
||||
include_once 'custom/templates/bazar/circuitscourt.php';
|
||||
|
||||
use YesWiki\Bazar\Field\BazarField;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @Field({"reservation"})
|
||||
*/
|
||||
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 displayReservation($entry);
|
||||
}
|
||||
|
||||
public function formatValuesBeforeSave($entry)
|
||||
{
|
||||
$mail_receiver = 'cyrille.bombard@lilo.org'; // todo prendre l'email du owner
|
||||
$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");
|
||||
$date = str_replace(' à 0:00', '', strftime("%A %d %B %Y à %k:%M", strtotime($entry['date_du_trajet'])));
|
||||
$users = $GLOBALS['wiki']->LoadAll("select email from ".$GLOBALS['wiki']->config["table_prefix"]."users");
|
||||
$u = [];
|
||||
//$url = $GLOBALS['wiki']->href('', 'saisie-participants-trajet', 'trajet='.$entry['id_fiche'].'&producteur='.urlencode($producteur['id_fiche']));
|
||||
$url = $GLOBALS['wiki']->href('', 'PagePrincipale');
|
||||
$message = 'Un nouveau trajet pour le producteur '.$producteur['bf_titre'].' le '.$date.' vient d’être proposé par '.$GLOBALS['wiki']->GetUsername().'.
|
||||
|
||||
Nature des productions de ce producteur : '.$producteur['nature_des_productions'].'
|
||||
|
||||
Si vous êtes intéressé par profiter de ce trajet pour vous approvisionner chez ce producteur et ainsi augmenter la résilience alimentaire de votre territoire, inscrivez-vous en cliquant sur '.$url.' , puis allez dans le menu "Je profite d\'un trajet".
|
||||
|
||||
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) {
|
||||
//$u[] = $user["email"];
|
||||
if (!empty($user["email"])) {
|
||||
send_mail('noreply@yeswiki.pro', 'Fors Circuit Court', $user["email"], '[Fors CC] un nouveau trajet pour '.$producteur['bf_titre'].' le '.$date, $message , $message_html);
|
||||
}
|
||||
}
|
||||
}
|
||||
//$message = 'Ce message sera envoyé à :'.implode(', ', $u)."\n\n";
|
||||
return array_merge(
|
||||
['trajet' => $entry['trajet']],
|
||||
);
|
||||
}
|
||||
|
||||
// change return of this method to keep compatible with php 7.3 (mixed is not managed)
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return array_merge(
|
||||
parent::jsonSerialize(),
|
||||
[
|
||||
'reservation_button' => '<a class="btn btn-primary" href="#"><i class="fa fa-plus"></i> Je profite de ce trajet</a>'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue