mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge remote-tracking branch 'origin/master' into integrate_wopi_bundle
This commit is contained in:
commit
80672a038c
@ -3,6 +3,7 @@
|
||||
namespace Chill\DocGeneratorBundle\Context;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||
|
||||
/**
|
||||
@ -21,11 +22,22 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
* Generate the form that display
|
||||
*/
|
||||
public function getForm($entity) {
|
||||
// TODO Get FormFactory and create a form
|
||||
throw new \Exception("No implemented yet", 1);
|
||||
|
||||
$choices = [];
|
||||
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
foreach ($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$choices[$person->getId()] = $person->getName();
|
||||
}
|
||||
}
|
||||
|
||||
// access to the house hold for the AccompanyingPeriod pr the SocialAction
|
||||
// and configure the form to select member of the family
|
||||
$builder->add('members', ChoiceType::class, [
|
||||
'choices' => $choices,
|
||||
'placeholder' => 'Choose a person',
|
||||
'label' => 'Person to add'
|
||||
]);
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,17 +53,26 @@ class HouseholdMemberSelectionContext implements DocGeneratorContextInterface
|
||||
* Get the data that will be injected to the generated document
|
||||
*/
|
||||
public function getData($entity): array {
|
||||
$ret = [];
|
||||
$datas = array(
|
||||
'setValue' => array(),
|
||||
'cloneRowAndSetValues' => array()
|
||||
); // TODO CREER UNE CLASSE POUR CA
|
||||
|
||||
if(get_class($entity) == AccompanyingPeriod::class) {
|
||||
// TODO mettre ça dans un service
|
||||
$ret = ['AccompanyingPeriod' => $entity];
|
||||
} elseif(get_class($entity) == SocialAction::class) {
|
||||
$ret = ['SocialAction' => $entity];
|
||||
if(get_class($entity) == AccompanyingPeriodWorkEvaluation::class) {
|
||||
$values = array();
|
||||
foreach($entity->getAccompanyingPeriodWork()->getPersons() as $person) {
|
||||
$i = 1;
|
||||
$values[] = array(
|
||||
'personRowId' => $i,
|
||||
'personFirstName' => $person->getFirstName(),
|
||||
'personLastName' => $person->getLastName(),
|
||||
);
|
||||
}
|
||||
|
||||
$datas['cloneRowAndSetValues'][] = array(
|
||||
'personRowId', $values);
|
||||
}
|
||||
|
||||
// TODO AJOUTER LES DONNES DU FORMULAIRE
|
||||
|
||||
return $ret;
|
||||
return $datas;
|
||||
}
|
||||
}
|
||||
|
@ -70,14 +70,17 @@ class DocGeneratorTemplateController extends AbstractController
|
||||
|
||||
if ($template->getContext() == HouseholdMemberSelectionContext::class) {
|
||||
$context = new HouseholdMemberSelectionContext();
|
||||
// $datas = $context->getData($entity);
|
||||
$datas = [];
|
||||
$datas = $context->getData($entity);
|
||||
} else {
|
||||
throw new \Exception("Not implemented", 1);
|
||||
}
|
||||
|
||||
$templateProcessor = new TemplateProcessor($tmpfname);
|
||||
$templateProcessor->setValues(array('firstname' => 'John', 'lastname' => 'Doe'));
|
||||
|
||||
// TODO foreach ($datas['setValue'] as $key => $value) {
|
||||
foreach ($datas['cloneRowAndSetValues'] as $cloneRowAndSetValues) {
|
||||
$templateProcessor->cloneRowAndSetValues($cloneRowAndSetValues[0], $cloneRowAndSetValues[1]);
|
||||
}
|
||||
|
||||
$tmpfname2 = tempnam(sys_get_temp_dir(), 'DOC_GENERATED');
|
||||
$templateProcessor->saveAs($tmpfname2);
|
||||
|
@ -24,9 +24,9 @@ class LoadDocGeneratorTemplate extends AbstractFixture
|
||||
[
|
||||
'name' => ['fr' => 'FORMULAIRE AEB'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
'file' => 'FORMULAIRE_AEB.docx',
|
||||
'file' => 'FORMULAIRE_AEB_WITH_DATA_INJ.docx',
|
||||
'context' => 'Chill\DocGeneratorBundle\Context\HouseholdMemberSelectionContext',
|
||||
'entities' => ['Chill\PersonBundle\Entity\AccompanyingPeriod', 'Chill\PersonBundle\Entity\SocialWork\SocialAction', AccompanyingPeriodWorkEvaluation::class],
|
||||
'entities' => [AccompanyingPeriodWorkEvaluation::class],
|
||||
], [
|
||||
'name' => ['fr' => 'AIDE ALIMENTAIRE'],
|
||||
'desc' => 'stocké sur openstack comedienbe',
|
||||
|
@ -3,6 +3,7 @@
|
||||
{% block layout_wvm_content %}
|
||||
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
||||
{% block table_entities_thead_tr %}
|
||||
<th></th>
|
||||
<th>{{ 'Title'|trans }}</th>
|
||||
<th>{{ 'File'|trans }}</th>
|
||||
{% endblock %}
|
||||
@ -10,6 +11,7 @@
|
||||
{% block table_entities_tbody %}
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.id }}</td>
|
||||
<td>{{ entity.name | localize_translatable_string }}</td>
|
||||
<td>{{ entity.file }}</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user