mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: create a person with address (php form)
This commit is contained in:
parent
84038c0ff2
commit
4bc8da9655
@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Form\CreationPersonType;
|
||||
use Chill\PersonBundle\Form\PersonType;
|
||||
@ -260,6 +262,25 @@ final class PersonController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
$address = $form->get('address')->getData();
|
||||
$addressForm = $form->get('addressForm')->getData();
|
||||
|
||||
if(null !== $address and $addressForm){
|
||||
|
||||
$household = new Household();
|
||||
|
||||
$member = new HouseholdMember();
|
||||
$member->setPerson($person);
|
||||
$member->setStartDate(new \DateTimeImmutable());
|
||||
|
||||
$household->addMember($member);
|
||||
$household->setForceAddress($address);
|
||||
|
||||
$this->em->persist($member);
|
||||
$this->em->persist($household);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'chill_person_general_edit',
|
||||
['person_id' => $person->getId()]
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Form;
|
||||
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
use Chill\MainBundle\Form\Type\ChillPhoneNumberType;
|
||||
use Chill\MainBundle\Form\Type\PickAddressType;
|
||||
use Chill\MainBundle\Form\Type\PickCenterType;
|
||||
use Chill\MainBundle\Form\Type\PickCivilityType;
|
||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||
@ -25,7 +26,9 @@ use libphonenumber\PhoneNumberType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
@ -77,6 +80,15 @@ final class CreationPersonType extends AbstractType
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
->add('addressForm', CheckboxType::class, [
|
||||
'label' => 'Create a household and add an address',
|
||||
'required' => false,
|
||||
'mapped' => false
|
||||
])
|
||||
->add('address', PickAddressType::class, [
|
||||
'required' => false,
|
||||
'mapped' => false
|
||||
]);
|
||||
|
||||
if ($this->askCenters) {
|
||||
|
@ -0,0 +1,18 @@
|
||||
import { ShowHide } from 'ShowHide';
|
||||
|
||||
const addressForm = document.getElementById("addressForm");
|
||||
const address = document.getElementById("address");
|
||||
|
||||
new ShowHide({
|
||||
froms: [addressForm],
|
||||
container: [address],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
event_name: 'change'
|
||||
});
|
@ -107,6 +107,13 @@
|
||||
{{ form_row(form.center) }}
|
||||
{% endif %}
|
||||
|
||||
<div id=addressForm>
|
||||
{{ form_row(form.addressForm) }}
|
||||
</div>
|
||||
<div id=address>
|
||||
{{ form_row(form.address) }}
|
||||
</div>
|
||||
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
<li class="dropdown">
|
||||
<a class="btn btn-create dropdown-toggle"
|
||||
@ -134,4 +141,10 @@
|
||||
|
||||
{% block js %}
|
||||
{{ encore_entry_script_tags('page_suggest_names') }}
|
||||
{{ encore_entry_script_tags('page_create_person') }}
|
||||
{{ encore_entry_script_tags('mod_input_address') }}
|
||||
{% endblock js %}
|
||||
|
||||
{% block css %}
|
||||
{{ encore_entry_link_tags('mod_input_address') }}
|
||||
{% endblock %}
|
@ -22,4 +22,5 @@ module.exports = function(encore, entries)
|
||||
encore.addEntry('page_accompanying_course_index_masonry', __dirname + '/Resources/public/page/accompanying_course_index/masonry.js');
|
||||
encore.addEntry('page_person_resource_showhide_input', __dirname + '/Resources/public/page/person_resource/showhide-input.js');
|
||||
encore.addEntry('page_suggest_names', __dirname + '/Resources/public/page/person/suggest-names.js');
|
||||
encore.addEntry('page_create_person', __dirname + '/Resources/public/page/person/create-person.js');
|
||||
};
|
||||
|
@ -86,6 +86,7 @@ Civility: Civilité
|
||||
choose civility: --
|
||||
All genders: tous les genres
|
||||
Any person selected: Aucune personne sélectionnée
|
||||
Create a household and add an address: Créer un ménage et ajouter une adresse
|
||||
|
||||
# dédoublonnage
|
||||
Old person: Doublon
|
||||
|
Loading…
x
Reference in New Issue
Block a user