mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add creation of new history line
This commit is contained in:
parent
9c249160cc
commit
c9204e32d8
@ -22,6 +22,64 @@ class HistoryController extends Controller
|
|||||||
'person' => $person));
|
'person' => $person));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createAction($personId) {
|
||||||
|
$person = $this->_getPerson($personId);
|
||||||
|
|
||||||
|
if ($person === null) {
|
||||||
|
return $this->createNotFoundException('Person not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$history = new PersonHistoryFile(new \DateTime());
|
||||||
|
$history->setPerson($person);
|
||||||
|
|
||||||
|
$motivesArray = $this->get('service_container')
|
||||||
|
->getParameter('person.history.close.motives');
|
||||||
|
|
||||||
|
$form = $this->createForm(new PersonHistoryFileType($motivesArray),
|
||||||
|
$history);
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
|
||||||
|
if ($request->getMethod() === 'POST') {
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
$errors = $this->_validatePerson($person);
|
||||||
|
|
||||||
|
$flashBag = $this->get('session')->getFlashBag();
|
||||||
|
|
||||||
|
if ($form->isValid(array('Default', 'closed'))
|
||||||
|
&& count($errors) === 0) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$em->persist($history);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$flashBag->add('success',
|
||||||
|
$this->get('translator')->trans(
|
||||||
|
'controller.Person.history.create.done'));
|
||||||
|
|
||||||
|
return $this->redirect($this->generateUrl('chill_person_history_list',
|
||||||
|
array('id' => $person->getId())));
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$flashBag->add('danger', $this->get('translator')
|
||||||
|
->trans('controller.Person.history.create.error'));
|
||||||
|
|
||||||
|
foreach($errors as $error) {
|
||||||
|
$flashBag->add('info', $error->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render('CLChillPersonBundle:History:update.html.twig',
|
||||||
|
array('form' => $form->createView(),
|
||||||
|
'person' => $person ) );
|
||||||
|
}
|
||||||
|
|
||||||
public function updateAction($id, $historyId){
|
public function updateAction($id, $historyId){
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
@ -32,7 +32,9 @@ class PersonHistoryFileType extends AbstractType
|
|||||||
'choices' => $this->motives,
|
'choices' => $this->motives,
|
||||||
'required' => true
|
'required' => true
|
||||||
))
|
))
|
||||||
->add('memo', 'textarea')
|
->add('memo', 'textarea', array(
|
||||||
|
'required' => false
|
||||||
|
))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@ chill_person_history_list:
|
|||||||
menu: person
|
menu: person
|
||||||
order: 100
|
order: 100
|
||||||
label: menu.person.history
|
label: menu.person.history
|
||||||
|
|
||||||
|
chill_person_history_create:
|
||||||
|
pattern: /{personId}/history/create
|
||||||
|
defaults: { _controller: CLChillPersonBundle:History:create }
|
||||||
|
|
||||||
|
|
||||||
chill_person_history_update:
|
chill_person_history_update:
|
||||||
pattern: /{id}/history/{historyId}/update
|
pattern: /{id}/history/{historyId}/update
|
||||||
|
@ -42,11 +42,14 @@ controller:
|
|||||||
open:
|
open:
|
||||||
done: Bravo ! Le dossier de <em>%name%</em> est maintenant ouvert.
|
done: Bravo ! Le dossier de <em>%name%</em> est maintenant ouvert.
|
||||||
error: Les informations introduites ne sont pas valides. Le dossier n'a pu être ouvert.
|
error: Les informations introduites ne sont pas valides. Le dossier n'a pu être ouvert.
|
||||||
error_in_fom: Le formulaire n'est pas valide.
|
error_in_form: Le formulaire n'est pas valide.
|
||||||
is_not_closed: Le dossier de <em>%name%</em> n'est pas fermé. Il ne peut donc être ouvert.
|
is_not_closed: Le dossier de <em>%name%</em> n'est pas fermé. Il ne peut donc être ouvert.
|
||||||
update:
|
update:
|
||||||
done: Bravo ! La mise à jour de l'historique a réussi !
|
done: Bravo ! La mise à jour de l'historique a réussi !
|
||||||
error: Les données introduites ne sont pas valides. Veuillez vérifier les informations ci-dessous.
|
error: Les données introduites ne sont pas valides. Veuillez vérifier les informations ci-dessous.
|
||||||
|
create:
|
||||||
|
done: Bravo ! L'historique a été modifié.
|
||||||
|
error: Les données introduites ne sont pas valides. Veuillez vérifier les informations ci-dessous.
|
||||||
|
|
||||||
views:
|
views:
|
||||||
layout:
|
layout:
|
||||||
@ -92,6 +95,7 @@ views:
|
|||||||
edit: Modifier
|
edit: Modifier
|
||||||
close: Clôre le dossier
|
close: Clôre le dossier
|
||||||
open: Ouvrir le dossier
|
open: Ouvrir le dossier
|
||||||
|
create: Nouvel ouverture-fermeture à une autre date
|
||||||
close:
|
close:
|
||||||
last_opening_since: Dernière ouverture le %last_opening%.
|
last_opening_since: Dernière ouverture le %last_opening%.
|
||||||
action: Clotûrer
|
action: Clotûrer
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
|
|
||||||
<table class="striped rounded">
|
<table class="rounded">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ 'views.Person.hlist.dateOpening_title'|trans }}</th>
|
<th>{{ 'views.Person.hlist.dateOpening_title'|trans }}</th>
|
||||||
@ -17,8 +17,9 @@
|
|||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
{% set i = 0 %}
|
||||||
{% for history in histories %}
|
{% for history in histories %}
|
||||||
<tr>
|
<tr class="{% if i is not even %}striped{% endif %}">
|
||||||
<td>{{ history.dateOpening|date(date_format) }}</td>
|
<td>{{ history.dateOpening|date(date_format) }}</td>
|
||||||
<td>{% spaceless %}
|
<td>{% spaceless %}
|
||||||
{% if history.isOpen %}
|
{% if history.isOpen %}
|
||||||
@ -39,7 +40,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if history.memo is not empty %}
|
||||||
|
<tr class="{% if i is not even %}striped{% endif %}">
|
||||||
|
<td colspan="3">
|
||||||
|
<pre>{{ history.memo }}</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endif %}
|
||||||
|
{% set i = i+1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -49,6 +57,12 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="form_control">
|
<div class="form_control">
|
||||||
|
<div class="btn small warning icon-right entypo icon-plus">
|
||||||
|
<a href="{{ path ('chill_person_history_create', {'personId' : person.id } ) }}">
|
||||||
|
{{ 'views.Person.hlist.create'|trans }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="btn medium danger icon-right entypo {% spaceless %}
|
<div class="btn medium danger icon-right entypo {% spaceless %}
|
||||||
{% if person.isOpen == true %}
|
{% if person.isOpen == true %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user