Compare commits

..

No commits in common. "09d87dee723e3763c5db206331b1a6ae652414fd" and "1c97e494b8ffce593ba507e3a82b44943952be9c" have entirely different histories.

5 changed files with 4 additions and 86 deletions

View file

@ -1,19 +1,13 @@
<?php <?php
namespace YesWiki\Meeo\Controller; namespace YesWiki\Meeo\Controller;
include_once "includes/email.inc.php";
include_once "includes/email.inc.php";
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use YesWiki\Core\ApiResponse; use YesWiki\Core\ApiResponse;
use YesWiki\Core\Controller\AuthController;
use YesWiki\Core\YesWikiController; use YesWiki\Core\YesWikiController;
use YesWiki\Meeo\Controle\Controle; use YesWiki\Meeo\Controle\Controle;
use YesWiki\Meeo\Service\AbsenceManager;
use YesWiki\Meeo\Service\EleveManager; use YesWiki\Meeo\Service\EleveManager;
use YesWiki\Meeo\Service\NoteManager; use YesWiki\Meeo\Service\NoteManager;
@ -77,33 +71,10 @@ class ApiController extends YesWikiController
* @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}}) * @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}})
*/ */
public function absence(Request $request) { public function absence(Request $request) {
// $noteManager = $this->getService(NoteManager::class);
$content = $request->getContent(); $content = $request->getContent();
parse_str($content, $parameters); parse_str($content, $parameters);
// Créer l'absence dans bazar
$eleve = $this->getService(EleveManager::class)->getEleve($parameters['eleve']);
$absenceManager = $this->getService(AbsenceManager::class);
$absence = $absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']);
// Récupération de l'expéditeur
$expediteur = $this->getService(AuthController::class)->getLoggedUser();
// echo "Expediteur : ".var_dump($expediteur)."\n";
// Récupération du destinataire
$destinataire = $eleve->getEmail();
// echo "Envoyer à : ".$destinataire."\n";
// Génération du rendu du mail
$body = $this->render("@meeo/eleve_creer_absence.twig", [
'eleve' => $eleve,
'absence' => $parameters
]);
// echo $body;
// Envoi de mail à la personne qui a été absente
if (!send_mail($expediteur['email'], $expediteur['name'], $destinataire, "Absence", $body, $body))
echo "Erreur d'envoie de mail";
return new ApiResponse($parameters); return new ApiResponse($parameters);
// return $this->wiki->redirect($this->redirectParams['absence'], 200); // return $this->wiki->redirect($this->redirectParams['absence'], 200);
} }

View file

@ -45,10 +45,6 @@ class Eleve {
$this->data['listeListeClassesbf_classe'] = $classe; $this->data['listeListeClassesbf_classe'] = $classe;
} }
public function getEmail() {
return $this->user['bf_mail'];
}
public function getData() { public function getData() {
return $this->data; return $this->data;
} }

View file

@ -1,40 +0,0 @@
<?php
namespace YesWiki\Meeo\Service;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use YesWiki\Bazar\Service\EntryManager;
use YesWiki\Wiki;
use YesWiki\Meeo\Eleve\Eleve;
class AbsenceManager {
private $wiki;
private $params;
private $entryManager;
private $formId;
private $eleveFormId;
public function __construct( Wiki $wiki, ParameterBagInterface $params, EntryManager $entryManager) {
$this->wiki = $wiki;
$this->params = $params;
$this->entryManager = $entryManager;
$this->formId = $params->get('meeo')['absencesFormId'];
$this->eleveFormId = $params->get('meeo')['elevesFormId'];
}
public function create(Eleve $eleve, $debut, $fin, $justification) {
$data = [
'bf_titre' => 'Absence : '.$eleve->getId().' - '.$debut,
'listefiche'.$this->eleveFormId.'bf_eleve' => $eleve->getId(),
'bf_date_debut' => $debut,
'bf_date_fin' => $fin,
'bf_commentaire' => $justification,
'antispam' => true
];
// echo var_dump($data);
return $this->entryManager->create($this->formId, $data);
}
}

View file

@ -21,10 +21,10 @@
<input class="form-control" type="datetime-local" id="date_fin_absence" name="date_fin_absence"/> <input class="form-control" type="datetime-local" id="date_fin_absence" name="date_fin_absence"/>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="justification">Justification:</label> <label class="control-label col-sm-2" for="commentaire">Justification:</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input class="form-control" type="text" name="justification"/> <input class="form-control" type="textarea" id="commentaire" name"commentaire"/>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-default">Envoyer</button> <button type="submit" class="btn btn-default">Envoyer</button>

View file

@ -1,9 +0,0 @@
Le message sera à voir avec l'équipe educative.
<div>
<p>Bonjour {{ eleve.getNom() }},</p>
<p>Nous vous signalons que votre enfant a été absent {{ absence['date_debut_absence']}}.</p>
<p>Merci d'en prendre note.</p>
</div>