[Eleves] Rajout d'une APi pour update les élèves.

Il faut que je fasse le code dedans.
This commit is contained in:
mckmonster 2024-07-17 19:15:22 +02:00
parent 621da28094
commit 1ace33f690
3 changed files with 43 additions and 5 deletions

View file

@ -14,5 +14,5 @@ services:
# resource: 'services/*'
# Allows to use controllers as services
# YesWiki\MeeO\Controller\:
# resource: 'controllers/*'
YesWiki\MeeO\Controller\:
resource: 'controllers/*'

View file

@ -0,0 +1,38 @@
<?php
namespace YesWiki\Meeo\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use YesWiki\Core\ApiResponse;
use YesWiki\Core\YesWikiController;
class ApiController extends YesWikiController
{
/**
* @Route("/api/meeo/eleves",methods={"POST"},options={"acl":{"public"}})
*/
public function eleveUpdate(Request $request) {
$content = $request->getContent();
parse_str($content, $parameters);
$result = [];
foreach ($parameters as $cle => $valeur) {
$clef_action = explode('_', $cle);
if ($clef_action[1] == 'classe' && $valeur != 'aucune') {
$result[] = 'Change la classe de '.$clef_action[0].' pour '.$valeur;
}
if ($clef_action[1] == 'del') {
$result[] = 'Suppression de '.$clef_action[0];
}
}
return new ApiResponse(
['result'=> $result],
Response::HTTP_CREATED
);
}
}

View file

@ -4,9 +4,9 @@
<div class="col-sm-3"><h2>Classe</h2></div>
<div class="col-sm-1 text-center"><h2><span class="glyphicon glyphicon-trash"></span></h2></div>
</div>
<form>
<form action="?api/meeo/eleves" method="post" enctype="application/json">
{% for eleve in eleves|sort %}
<div class="row">
<div class="row form-group" id="{{eleve['id_fiche']}}" name="{{eleve['id_fiche']}}">
<div class="col-sm-8">{{ eleve['bf_nom'] }}</div>
<div class="col-sm-3">
<select id="{{eleve['id_fiche']}}_classe" name="{{eleve['id_fiche']}}_classe" class="form-control">
@ -16,7 +16,7 @@
</select>
</div>
<div class="col-sm-1 text-center">
<input class="form-check-iput" type="checkbox" value=""/>
<input id="{{eleve['id_fiche']}}_del" name="{{eleve['id_fiche']}}_del" class="form-check-input" type="checkbox" value=""/>
</div>
</div>
{% endfor %}