[Absence] Creation entrée bazar
This commit is contained in:
parent
1c97e494b8
commit
00a4ad9784
3 changed files with 57 additions and 4 deletions
|
@ -8,6 +8,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
use YesWiki\Core\ApiResponse;
|
||||
use YesWiki\Core\YesWikiController;
|
||||
use YesWiki\Meeo\Controle\Controle;
|
||||
use YesWiki\Meeo\Service\AbsenceManager;
|
||||
use YesWiki\Meeo\Service\EleveManager;
|
||||
use YesWiki\Meeo\Service\NoteManager;
|
||||
|
||||
|
@ -71,10 +72,22 @@ class ApiController extends YesWikiController
|
|||
* @Route("/api/meeo/absence",methods={"POST"},options={"acl":{"public"}})
|
||||
*/
|
||||
public function absence(Request $request) {
|
||||
// $noteManager = $this->getService(NoteManager::class);
|
||||
$content = $request->getContent();
|
||||
parse_str($content, $parameters);
|
||||
|
||||
// Créer l'absence dans bazar
|
||||
$eleve = $this->getService(EleveManager::class)->getEleve($parameters['eleve']);
|
||||
$absenceManager = $this->getService(AbsenceManager::class);
|
||||
$absenceManager->create($eleve, $parameters['date_debut_absence'], $parameters['date_fin_absence'], $parameters['justification']);
|
||||
|
||||
// Récupération de l'expéditeur
|
||||
|
||||
// Récupération du destinataire
|
||||
|
||||
// Génération du rendu du mail
|
||||
|
||||
// Envoi de mail à la personne qui a été absente
|
||||
|
||||
return new ApiResponse($parameters);
|
||||
// return $this->wiki->redirect($this->redirectParams['absence'], 200);
|
||||
}
|
||||
|
|
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);
|
||||
$this->entryManager->create($this->formId, $data);
|
||||
}
|
||||
}
|
|
@ -21,10 +21,10 @@
|
|||
<input class="form-control" type="datetime-local" id="date_fin_absence" name="date_fin_absence"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="commentaire">Justification:</label>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="justification">Justification:</label>
|
||||
<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>
|
||||
<button type="submit" class="btn btn-default">Envoyer</button>
|
||||
|
|
Loading…
Reference in a new issue