Compare commits
4 commits
1c97e494b8
...
09d87dee72
Author | SHA1 | Date | |
---|---|---|---|
|
09d87dee72 | ||
|
d6c8fd2ba7 | ||
|
4a4306f1c8 | ||
|
00a4ad9784 |
5 changed files with 86 additions and 4 deletions
|
@ -1,13 +1,19 @@
|
||||||
<?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;
|
||||||
|
|
||||||
|
@ -71,10 +77,33 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
40
services/AbsenceManager.php
Normal file
40
services/AbsenceManager.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,9 +22,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label col-sm-2" for="commentaire">Justification:</label>
|
<label class="control-label col-sm-2" for="justification">Justification:</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input class="form-control" type="textarea" id="commentaire" name"commentaire"/>
|
<input class="form-control" type="text" name="justification"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-default">Envoyer</button>
|
<button type="submit" class="btn btn-default">Envoyer</button>
|
||||||
|
|
9
templates/eleve_creer_absence.twig
Normal file
9
templates/eleve_creer_absence.twig
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
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>
|
Loading…
Reference in a new issue