Merge branch 'master' into 110_extend_thirdparty

This commit is contained in:
Mathieu Jaumotte 2021-07-30 22:56:41 +02:00
commit 4eef8492b1
111 changed files with 3019 additions and 1974 deletions

View File

@ -52,7 +52,7 @@
"knplabs/knp-time-bundle": "^1.12",
"symfony/intl": "4.*",
"symfony/swiftmailer-bundle": "^3.5",
"league/csv": "^9.6",
"league/csv": "^9.7.1",
"phpoffice/phpspreadsheet": "^1.16",
"symfony/browser-kit": "^5.2",
"symfony/css-selector": "^5.2",

View File

@ -22,6 +22,7 @@ class LoadActivityNotifications extends AbstractFixture implements DependentFixt
'entityRef' => 'activity_gerard depardieu',
'sender' => 'center a_social',
'addressees' => [
'center a_social',
'center a_administrative',
'center a_direction',
'multi_center'

View File

@ -0,0 +1,24 @@
<?php
namespace Chill\ActivityBundle\Notification;
use Chill\MainBundle\Entity\Notification;
use Chill\ActivityBundle\Entity\Activity;
final class ActivityNotificationRenderer
{
public function supports(Notification $notification, array $options = []): bool
{
return $notification->getRelatedEntityClass() == Activity::class;
}
public function getTemplate()
{
return '@ChillActivity/Activity/showInNotification.html.twig';
}
public function getTemplateData(Notification $notification)
{
return ['notification' => $notification];
}
}

View File

@ -1,4 +1,6 @@
@import '~ChillMainAssets/module/bootstrap/bootstrap';
// Access to Bootstrap variables and mixins
@import '~ChillMainAssets/module/bootstrap/shared';
//@import '~ChillMainSass/custom/mixins/entity';
//.chill-entity.chill-entity__activity-reason {
@ -6,7 +8,7 @@
//}
.activity {
color: $chill-green;
//color: $chill-green;
}
// exceptions for flex-bloc in concerned-groups

View File

@ -60,7 +60,7 @@
<li>
<a href="{{ _self.href(bloc.path, bloc.key, item.id) }}">
<span class="badge bg-primary">
{{ item|chill_entity_render_box({'only_denomination': true}) }}
{{ item|chill_entity_render_box({'render': 'raw'}) }}
</span>
</a>
</li>

View File

@ -18,57 +18,44 @@
{% else %}
<div class="flex-table list-records context-{{ context }}">
<!--
<thead>
<tr>
<th class="chill-red">{{'Date' | trans }}</th>
<th class="chill-green">{{'Duration Time' | trans }}</th>
<th class="chill-orange">{{'Reasons' | trans}}</th>
<th>{{'Type' | trans}}</th>
<th>&nbsp;</th>
</tr>
</thead>
-->
{% for activity in activities %}
{% set t = activity.type %}
<div class="item-bloc">
<div class="item-row main">
<div class="item-col">
{% if activity.date %}
<h3>{{ activity.date|format_date('long') }}</h3>
{% endif %}
<div class="duration">
{% if t.durationTimeVisible > 0 %}
<p>
<i class="fa fa-fw fa-hourglass-end"></i>
{{ activity.durationTime|date('H:i') }}
</p>
{% endif %}
{% if t.durationTimeVisible > 0 %}
<p>
<i class="fa fa-fw fa-hourglass-end"></i>
{{ activity.durationTime|date('H:i') }}
</p>
{% endif %}
{% if activity.travelTime and t.travelTimeVisible %}
<p>
<i class="fa fa-fw fa-car"></i>
{{ activity.travelTime|date('H:i') }}
</p>
<p>
<i class="fa fa-fw fa-car"></i>
{{ activity.travelTime|date('H:i') }}
</p>
{% endif %}
</div>
{% if context == 'person' and activity.accompanyingPeriod is not empty %}
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
<a
href="{{ chill_path_add_return_path(
"chill_person_accompanying_course_index",
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
) }}"
>
<i class="fa fa-random"></i>
{{ activity.accompanyingPeriod.id }}
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
<a href="{{ chill_path_add_return_path(
"chill_person_accompanying_course_index",
{ 'accompanying_period_id': activity.accompanyingPeriod.id }
) }}">
<i class="fa fa-random"></i>
{{ activity.accompanyingPeriod.id }}
</a>
</div>
</div>
{% endif %}
</div>
<div class="item-col">
<ul class="list-content">
@ -77,19 +64,19 @@
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
</li>
{% endif %}
<li>
<b>{{ activity.type.name | localize_translatable_string }}</b>
{% if activity.attendee is not null and t.attendeeVisible %}
{% if activity.attendee %}
{{ '→ ' ~ 'present'|trans|capitalize }}
{% else %}
{{ '→ ' ~ 'present'|trans|capitalize }}
{% else %}
{{ '→ ' ~ 'not present'|trans|capitalize }}
{% endif %}
{% endif %}
</li>
<li>
<b>{{ 'location'|trans ~ ': ' }}</b>
Domicile de l'usager
@ -97,7 +84,7 @@
{% if activity.location %}{{ activity.location }}{% endif %}
#}
</li>
{%- if t.reasonsVisible -%}
<li>
{%- if activity.reasons is empty -%}
@ -121,7 +108,7 @@
{%- endif -%}
</li>
{% endif %}
{%- if t.socialActionsVisible -%}
<li class="social-actions">
{%- if activity.socialActions is empty -%}
@ -134,7 +121,7 @@
</li>
{% endif %}
</ul>
<ul class="record_actions">
<li>
@ -159,19 +146,19 @@
</ul>
</div>
</div>
{%
{%
if activity.comment.comment is not empty
or activity.persons|length > 0
or activity.thirdParties|length > 0
or activity.users|length > 0
or activity.users|length > 0
%}
<div class="item-row details">
<div class="item-col">
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': activity } %}
</div>
{% if activity.comment.comment is not empty %}
<div class="item-col comment">
{{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
@ -179,7 +166,7 @@
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
</div>

View File

@ -0,0 +1,4 @@
{{ dump(notification) }}
<a href="{{ path('chill_activity_activity_show', {'id': notification.relatedEntityId }) }}">Go to Activity</a>

View File

@ -1,4 +1,4 @@
services:
services:
chill.activity.security.authorization.activity_voter:
class: Chill\ActivityBundle\Security\Authorization\ActivityVoter
arguments:
@ -6,7 +6,7 @@ services:
tags:
- { name: security.voter }
- { name: chill.role }
chill.activity.security.authorization.activity_stats_voter:
class: Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter
arguments:
@ -14,8 +14,8 @@ services:
tags:
- { name: security.voter }
- { name: chill.role }
chill.activity.timeline:
class: Chill\ActivityBundle\Timeline\TimelineActivityProvider
arguments:
@ -33,3 +33,8 @@ services:
autoconfigure: true
resource: '../Menu/'
tags: ['chill.menu_builder']
Chill\ActivityBundle\Notification\:
autowire: true
autoconfigure: true
resource: '../Notification'

View File

@ -108,8 +108,6 @@
{{ chill_pagination(paginator) }}
{% endif %}
{% form_theme form_add_event_participation_by_person 'bootstrap_4_layout.html.twig' %}
<div class="input-group mb-3">
{{ form_start(form_add_event_participation_by_person) }}
{#
@ -137,4 +135,4 @@
</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -3,9 +3,7 @@
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block title 'Participation creation'|trans %}
{% form_theme form _self %}
{% block _collection_row %}
<tr>
<td>
@ -28,10 +26,10 @@
</tr>
</tbody>
</table>
{% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %}
{{ form_start(form) }}
{{ form_start(form) }}
<table>
<thead>
<tr>
@ -47,10 +45,10 @@
<td>{{ form_widget(participationField.role) }}</td>
<td>{{ form_widget(participationField.status) }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
<ul class="record_actions">
<li class="cancel">
<a href="{{ path('chill_event__event_show', { 'event_id' : participations[0].event.id } ) }}" class="btn btn-cancel">
@ -61,7 +59,7 @@
{{ form_widget(form.submit, { 'attr' : { 'class' : 'btn btn-create' } } ) }}
</li>
</ul>
{{ form_end(form) }}
{% endblock %}

View File

@ -1141,7 +1141,7 @@ class CRUDController extends AbstractController
*/
protected function getPaginatorFactory(): PaginatorFactory
{
return $this->container->get('chill_main.paginator_factory');
return $this->container->get(PaginatorFactory::class);
}
/**

View File

@ -0,0 +1,59 @@
<?php
namespace Chill\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Chill\MainBundle\Repository\NotificationRepository;
use Chill\MainBundle\Notification\NotificationRenderer;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Routing\Annotation\Route;
use Chill\MainBundle\Pagination\PaginatorFactory;
/**
* @Route("/{_locale}/notification")
*/
class NotificationController extends AbstractController
{
private $security;
public function __construct(Security $security)
{
$this->security = $security;
}
/**
* @Route("/show", name="chill_main_notification_show")
*/
public function showAction(
NotificationRepository $notificationRepository, NotificationRenderer $notificationRenderer,
PaginatorFactory $paginatorFactory)
{
$currentUser = $this->security->getUser();
$notificationsNbr = $notificationRepository->countAllForAttendee(($currentUser));
$paginator = $paginatorFactory->create($notificationsNbr);
$notifications = $notificationRepository->findAllForAttendee(
$currentUser,
$limit=$paginator->getItemsPerPage(),
$offset= $paginator->getCurrentPage()->getFirstItemNumber());
$templateData = array();
foreach ($notifications as $notification) {
$data = [
'template' => $notificationRenderer->getTemplate($notification),
'template_data' => $notificationRenderer->getTemplateData($notification),
'notification' => $notification
];
$templateData[] = $data;
}
return $this->render('@ChillMain/Notification/show.html.twig', [
'datas' => $templateData,
'notifications' => $notifications,
'paginator' => $paginator,
]);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Chill\MainBundle\Notification;
use Chill\MainBundle\Entity\Notification;
use Chill\PersonBundle\Notification\AccompanyingPeriodNotificationRenderer;
use Chill\ActivityBundle\Notification\ActivityNotificationRenderer;
final class NotificationRenderer
{
private array $renderers;
public function __construct(
AccompanyingPeriodNotificationRenderer $accompanyingPeriodNotificationRenderer,
ActivityNotificationRenderer $activityNotificationRenderer)
{
// TODO configure automatically
// TODO CREER UNE INTERFACE POUR ETRE SUR QUE LES RENDERERS SONT OK
$this->renderers[] = $accompanyingPeriodNotificationRenderer;
$this->renderers[] = $activityNotificationRenderer;
}
private function getRenderer(Notification $notification)
{
foreach ($this->renderers as $renderer) {
if($renderer->supports($notification)) {
return $renderer;
}
}
throw new \Exception('No renderer for '. $notification);
}
public function getTemplate(Notification $notification)
{
return $this->getRenderer($notification)->getTemplate();
}
public function getTemplateData(Notification $notification)
{
return $this->getRenderer($notification)->getTemplateData($notification);
}
}

View File

@ -23,6 +23,8 @@ use Chill\MainBundle\Entity\Notification;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
use Chill\MainBundle\Entity\User;
use Doctrine\ORM\Query;
final class NotificationRepository implements ObjectRepository
{
@ -59,8 +61,54 @@ final class NotificationRepository implements ObjectRepository
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
private function queryAllForAttendee(User $addressee, bool $countQuery=False): Query
{
$qb = $this->repository->createQueryBuilder('n');
$select = 'n';
if($countQuery) {
$select = 'count(n)';
}
$qb
->select($select)
->join('n.addressees', 'a')
->where('a = :addressee')
->setParameter('addressee', $addressee);
return $qb->getQuery();
}
/**
* @return int
*/
public function countAllForAttendee(User $addressee): int // TODO passer à attendees avec S
{
$query = $this->queryAllForAttendee($addressee, $countQuery=True);
return $query->getSingleScalarResult();
}
/**
* @return Notification[]
*/
public function findAllForAttendee(User $addressee, $limit = null, $offset = null): array // TODO passer à attendees avec S
{
$query = $this->queryAllForAttendee($addressee);
if($limit) {
$query = $query->setMaxResults($limit);
}
if($offset) {
$query = $query->setFirstResult($offset);
}
return $query->getResult();
}
public function getClassName() {
return Notification::class;
}
}

View File

@ -1,12 +1,14 @@
/*
* NOTE 2021.04
* scss/chillmain.scss is the main sass file for the new chill.2
* scratch will be replaced by bootstrap, please avoid to edit in modules/scratch/_custom.scss
*
* when possible, try to use bootstrap html class
*/
// Access to Bootstrap variables and mixins
@import '~ChillMainAssets/module/bootstrap/shared';
@import '~ChillMainAssets/module/bootstrap/bootstrap';
// Chill mixins
@import './scss/mixins';
// Chill entity render box system
@import './scss/render_box';
// Chill flex responsive table/block presentation
@import './scss/flex_table';
/*
* Specific rules
@ -22,6 +24,7 @@ div.banner {
.id-number {
font-weight: lighter;
font-size: 50%;
margin-left: 0.5em;
&:before { content: '(n°'; }
&:after { content: ')'; }
}
@ -37,165 +40,5 @@ div.banner {
&:before { content: '('; }
&:after { content: ')'; }
}
div.members {
display: flex;
flex-direction: row;
span.badge-member {
border: 1px solid #ffffff3b;
color: #ffffff;
padding: 0.4em 0.8em;
margin-right: 0.3em;
border-radius: 8px;
&.holder {
order: -1;
}
&.child {
order: 2;
}
}
}
}
/*
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
*/
div.flex-bloc,
div.flex-table {
h2, h3, h4, dl, p {
margin: 0;
}
h2, h3, h4 {
color: var(--bs-chill-blue);
}
div.item-bloc {
// We use box-shadow instead of border
// to avoid to manage border double-width
// when blocs are resized for small screen !
// Then we can simulate border-collapse: collapse (table)
box-shadow:
1px 0 0 0 var(--bs-dark),
0 1px 0 0 var(--bs-dark),
1px 1px 0 0 var(--bs-dark), /* fix the corner */
1px 0 0 0 var(--bs-dark) inset,
0 1px 0 0 var(--bs-dark) inset;
}
}
/*
* Bloc appearance
*/
div.flex-bloc {
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
align-content: stretch;
div.item-bloc {
flex-grow: 0; flex-shrink: 1; flex-basis: 33%;
margin: 0;
padding: 1em;
display: flex;
flex-direction: column;
div.item-row {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
flex-direction: column;
div.item-col {
&:first-child {
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
.list-content { // ul, dl, or div
}
ul.record_actions {
margin: 0;
align-self: flex-end;
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
li {
margin-right: 5px;
}
}
}
}
}
}
@media only screen and (max-width: 945px) { margin: auto -0.2em; }
@media only screen and (max-width: 935px) { margin: auto -0.5em; }
@media only screen and (max-width: 920px) { margin: auto -0.9em; }
@media only screen and (max-width: 900px) {
flex-direction: column;
margin: auto 0;
}
}
/*
* Table appearance
*/
div.flex-table {
display: flex;
flex-direction: column;
align-items: stretch;
align-content: stretch;
div.item-bloc {
display: flex;
flex-direction: column;
padding: 1em;
&:nth-child(even) {
background-color: #e6e6e6;
}
div.item-row {
display: flex;
flex-direction: row;
&:not(:first-child) {
margin-top: 0.5em;
border-top: 1px dotted #0000004f;
padding-top: 0.5em;
flex-direction: column;
}
div.item-col {
&:first-child {
flex-grow: 0; flex-shrink: 0; flex-basis: 33%;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
justify-content: flex-end;
.list-content { // ul, dl, or div
}
ul.record_actions {
margin: 0;
align-self: flex-start;
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
li {
margin-right: 5px;
}
}
}
}
@media only screen and (max-width: 900px) {
flex-direction: column;
div.item-col {
&:last-child {
ul.record_actions {
align-self: flex-end;
}
}
}
}
// neutralize
div.chill_address div.chill_address_address p { text-indent: 0; }
}
}
}

View File

@ -0,0 +1,130 @@
/*
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
*/
div.flex-bloc,
div.flex-table {
h2, h3, h4, dl, p {
margin: 0;
}
h2, h3, h4 {
color: var(--bs-chill-blue);
}
div.item-bloc {
@include border-collapse;
}
}
/*
* Bloc appearance
*/
div.flex-bloc {
box-sizing: border-box;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
align-content: stretch;
div.item-bloc {
flex-grow: 0; flex-shrink: 1; flex-basis: auto;
margin: 0;
padding: 1em;
display: flex;
flex-direction: column;
div.item-row {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
flex-direction: column;
div.item-col {
&:first-child {
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
padding-bottom: 0.5em;
border-bottom: 1px dotted #0000004f;
margin-bottom: 0.5em;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
.list-content { // ul, dl, or div
}
ul.record_actions {
margin: 0;
align-self: flex-end;
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
li {
margin-right: 5px;
}
}
}
}
}
}
}
/*
* Table appearance
*/
div.flex-table {
display: flex;
flex-direction: column;
align-items: stretch;
align-content: stretch;
div.item-bloc {
display: flex;
flex-direction: column;
padding: 1em;
&:nth-child(even) {
background-color: $gray-200;
}
div.item-row {
display: flex;
flex-direction: row;
&:not(:first-child) {
margin-top: 0.5em;
border-top: 1px dotted #0000004f;
padding-top: 0.5em;
flex-direction: column;
}
div.item-col {
&:first-child {
flex-grow: 0; flex-shrink: 0; flex-basis: 33%;
}
&:last-child {
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
display: flex;
justify-content: flex-end;
.list-content { // ul, dl, or div
}
ul.record_actions {
margin: 0;
align-self: flex-start;
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
li {
margin-right: 5px;
}
}
}
}
@media only screen and (max-width: 900px) {
flex-direction: column;
div.item-col {
&:last-child {
ul.record_actions {
align-self: flex-end;
}
}
}
}
// neutralize
div.chill_address div.chill_address_address p { text-indent: 0; }
}
}
}

View File

@ -0,0 +1,14 @@
// We use box-shadow instead of border
// to avoid to manage border double-width
// Then we can simulate border-collapse: collapse (table)
@mixin border-collapse {
box-shadow:
1px 0 0 0 var(--bs-dark),
0 1px 0 0 var(--bs-dark),
1px 1px 0 0 var(--bs-dark), /* fix the corner */
1px 0 0 0 var(--bs-dark) inset,
0 1px 0 0 var(--bs-dark) inset;
}

View File

@ -0,0 +1,95 @@
// generic rules
section.chill-entity {
// display inline for render raw
// have no effect for render label, bloc !
display: inline;
// don't break flex cascade with section tag
div.flex-bloc & {
display: flex;
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
}
}
// specific rules
.chill-entity {
// used for: entity-person, entity-thirdparty
&.entity-person,
&.entity-thirdparty {
div.entity-label {
div.denomination {
&.h3 {
font-size: 1.3em;
font-weight: 700;
}
a {
text-decoration: none;
}
span.badge {
margin-left: 0.3em;
}
span.altnames,
span.id-number {
font-weight: lighter;
font-size: 50%;
margin-left: 0.5em;
}
span.id-number {
&:before { content: '(n°'; }
&:after { content: ')'; }
}
}
p.moreinfo {}
}
div.entity-bloc {}
}
// used for addresses
&.entity-address {
.address {
font-size: 98%;
font-variant: small-caps;
&.multiline {
margin: 0.7em 0;
p {
display: block;
}
}
&.delimiter {
p:not(:first-child):before {
content: '';
}
}
p {
display: inline-block;
margin: 0 0 0 1.5em;
text-indent: -1.5em;
&.street {
span.streetnumber {
&::before { content: ", "; }
}
}
&.postcode {
span.code {}
span.name {}
}
&.country {}
}
}
.noaddress {
font-style: italic;
}
span.address-valid {
&.address-since {}
&.address-until {}
}
}
}

View File

@ -7,17 +7,10 @@
* Enable / disable bootstrap assets
*/
// Bootstrap configuration files are shared with chill entrypoint
@import "shared";
// scss-docs-start import-stack
// Configuration
@import "bootstrap/scss/functions";
/* replace by CHILL variables */
//@import "bootstrap/scss/variables";
@import "custom/_variables";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
// Layout & components
@import "bootstrap/scss/root";
@import "bootstrap/scss/reboot";
@ -59,3 +52,4 @@
// CHILL custom
@import "custom";
@import "custom/_debug";

View File

@ -0,0 +1,19 @@
body {
position: relative;
div.responsive {
position: fixed;
top: 0;
left: 50%;
background-color: #4a4d50;
color: white;
padding: 0.5em;
z-index: 10000;
@media (max-width: 576px) { &::after { content: 'XS'; }}
@media (min-width: 576px) { &::after { content: 'SM'; }}
@media (min-width: 768px) { &::after { content: 'MD'; }}
@media (min-width: 992px) { &::after { content: 'LG'; }}
@media (min-width: 1200px) { &::after { content: 'XL'; }}
@media (min-width: 1400px) { &::after { content: 'XXL'; }}
}
}

View File

@ -0,0 +1,14 @@
// Configuration
@import "bootstrap/scss/functions";
/*
* Replaced by CHILL variables
* it is necessary to keep the possibility of making a diff with original !
* original: "bootstrap/scss/variables";
*/
@import "custom/_variables";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";

View File

@ -1,23 +1,22 @@
<template>
<div class='person-address__create'>
<div>
<h2 v-if="!edit">{{ $t('create_a_new_address') }}</h2>
<h2 v-else>{{ $t('edit_a_new_address') }}</h2>
<add-address
@addNewAddress="addNewAddress">
</add-address>
</div>
<div>
<show-address
v-if="address"
v-bind:address="address">
</show-address>
</div>
<div class="chill-entity entity-address">
<h2 v-if="!edit">{{ $t('create_a_new_address') }}</h2>
<h2 v-else>{{ $t('edit_address') }}</h2>
<show-address
v-if="address"
v-bind:address="address">
</show-address>
<add-address
@addNewAddress="addNewAddress">
</add-address>
</div>
<div v-if="!edit" class='person-address__valid'>
<h2>{{ $t('date') }}</h2>
<div class="input-group mb-3">
<span class="input-group-text" id="validFrom"><i class="fa fa-fw fa-calendar"></i></span>
<input type="date" class="form-control form-control-lg" name="validFrom"
@ -25,7 +24,7 @@
v-model="validFrom"
aria-describedby="validFrom" />
</div>
<div v-if="errors.length > 0">
{{ errors }}
</div>

View File

@ -3,7 +3,7 @@
{{ $t('add_an_address_title') }}
</button>
<button v-else class="btn btn-create mt-4" @click="openModal">
{{ $t('edit_an_address_title') }}
{{ $t('edit_address') }}
</button>
<teleport to="body">
@ -18,19 +18,19 @@
<template v-slot:body>
<div class="address-form">
<h4 class="h3">{{ $t('select_an_address_title') }}
<span v-if="loading">
<i class="fa fa-circle-o-notch fa-spin fa-lg"></i>
</span>
</h4>
<div class="row my-3">
<div class="col-lg-6">
<div class="col-lg-6">
<div class="form-check">
<input type="checkbox"
class="form-check-input"
class="form-check-input"
id="isNoAddress"
v-model="isNoAddress"
v-bind:value="value" />
@ -38,18 +38,18 @@
{{ $t('isNoAddress') }}
</label>
</div>
<country-selection
v-bind:address="address"
v-bind:getCities="getCities">
</country-selection>
<city-selection
v-bind:address="address"
v-bind:focusOnAddress="focusOnAddress"
v-bind:getReferenceAddresses="getReferenceAddresses">
</city-selection>
<address-selection
v-if="!isNoAddress"
v-bind:address="address"
@ -58,15 +58,15 @@
</div>
<div class="col-lg-6 mt-3 mt-lg-0">
<address-map
v-bind:address="address"
ref="addressMap">
</address-map>
</div>
</div>
<address-more
v-if="!isNoAddress"
v-bind:address="address">

View File

@ -1,36 +1,54 @@
<template>
<div class="chill_address_address chill_address_address--multiline">
<div v-if="address.text">
{{ address.text }}
<div class="address multiline">
<p v-if="address.text"
class="street">
{{ address.text }}
</p>
<p v-if="address.postcode"
class="postcode">
{{ address.postcode.name }}
</p>
<p v-if="address.country"
class="country">
{{ address.country.name.fr }}
</p>
<div v-if="address.floor">
<span class="floor">
<b>{{ $t('floor') }}</b>: {{ address.floor }}
</span>
</div>
<div v-if="address.corridor">
<span class="corridor">
<b>{{ $t('corridor') }}</b>: {{ address.corridor }}
</span>
</div>
<div v-if="address.steps">
<span class="steps">
<b>{{ $t('steps') }}</b>: {{ address.steps }}
</span>
</div>
<div v-if="address.flat">
<span class="flat">
<b>{{ $t('flat') }}</b>: {{ address.flat }}
</span>
</div>
<div v-if="address.buildingName">
<span class="buildingName">
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }}
</span>
</div>
<div v-if="address.extra">
<span class="extra">
<b>{{ $t('extra') }}</b>: {{ address.extra }}
</span>
</div>
<div v-if="address.distribution">
<span class="distribution">
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
</span>
</div>
</div>
<div v-if="address.postcode">
{{ address.postcode.name }}
</div>
<div v-if="address.country">
{{ address.country.name.fr }}
</div>
<div v-if="address.floor">
<span>{{ $t('floor') }}</span>: {{ address.floor }}
</div>
<div v-if="address.corridor">
<span>{{ $t('corridor') }}</span>: {{ address.corridor }}
</div>
<div v-if="address.steps">
<span>{{ $t('steps') }}</span>: {{ address.steps }}
</div>
<div v-if="address.flat">
<span>{{ $t('flat') }}</span>: {{ address.flat }}
</div>
<div v-if="address.buildingName">
<span>{{ $t('buildingName') }}</span>: {{ address.buildingName }}
</div>
<div v-if="address.extra">
<span>{{ $t('extra') }}</span>: {{ address.extra }}
</div>
<div v-if="address.distribution">
<span>{{ $t('distribution') }}</span>: {{ address.distribution }}
</div>
</div>
</template>
<script>

View File

@ -3,7 +3,7 @@ const addressMessages = {
add_an_address_title: 'Créer une adresse',
edit_an_address_title: 'Modifier une adresse',
create_a_new_address: 'Créer une nouvelle adresse',
edit_a_new_address: 'Modifier l\'adresse',
edit_address: 'Modifier l\'adresse',
select_an_address_title: 'Sélectionner une adresse',
fill_an_address: 'Compléter l\'adresse',
select_country: 'Choisir le pays',

View File

@ -1,16 +0,0 @@
<div class="chill_address">
{% if options['has_no_address'] == true and address.isNoAddress == true %}
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
{% endif %}
<div class="chill_address_address {% if options['multiline'] %}chill_address_address--multiline{% endif %}">
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
{% if address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</div>
{%- if options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}</span>
{%- endif -%}
</div>

View File

@ -1,21 +0,0 @@
{%- macro _render(address, options) -%}
{%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%}
{%- set options = { 'has_no_address' : false }|merge(options|default({})) -%}
{%- set options = { 'with_icon' : false }|merge(options|default({})) -%}
<div class="chill_address">
{% if options['has_no_address'] == true and address.isNoAddress == true %}
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
{% endif %}
<div class="chill_address_address">{% if options['with_icon'] == true %}<i class="fa fa-fw fa-map-marker"></i>{% endif %}
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
{% if address.postCode is not empty %}
<p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
</div>
{%- if options['with_valid_from'] == true -%}
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}</span>
{%- endif -%}
</div>
{%- endmacro -%}

View File

@ -0,0 +1,121 @@
{#
Template to render an address
OPTIONS
* render string ['list'|'bloc'|'inline']
* with_valid_from bool start date
* with_valid_to bool end date
* with_picto bool add a forkawesome pictogram
* with_delimiter bool add a delimiter between fragments
* has_no_address bool
* multiline bool multiline display
* extended_infos bool add extra informations (step, floor, etc.)
#}
{% macro raw(address, options) %}
{% if address.street is not empty %}
<p class="street">{{ address.street }}
{% if address.streetNumber is not empty %}
<span class="streetnumber">{{ address.streetNumber }}</span>
{% endif %}
</p>
{% endif %}
{% if options['extended_infos'] %}
{{ _self.extended(address, options) }}
{% endif %}
{% if address.postCode is not empty %}
<p class="postcode">
<span class="code">{{ address.postCode.code }}</span>
<span class="name">{{ address.postCode.name }}</span>
</p>
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
{% endif %}
{% endmacro %}
{% macro extended(address, options) %}
{% if address.floor is not empty %}
<span class="floor">{{ address.floor }}</span>
{% endif %}
{% if address.corridor is not empty %}
<span class="corridor">{{ address.corridor }}</span>
{% endif %}
{% if address.steps is not empty %}
<span class="steps">{{ address.steps }}</span>
{% endif %}
{% if address.buildingName is not empty %}
<span class="buildingName">{{ address.buildingName }}</span>
{% endif %}
{% if address.flat is not empty %}
<span class="flat">{{ address.flat }}</span>
{% endif %}
{% if address.distribution is not empty %}
<span class="distribution">{{ address.distribution }}</span>
{% endif %}
{% if address.extra is not empty %}
<span class="extra">{{ address.extra }}</span>
{% endif %}
{% endmacro %}
{% macro inline(address, options) %}
{% if options['has_no_address'] == true and address.isNoAddress == true %}
<span class="noaddress">
{{ 'address.consider homeless'|trans }}
</span>
{% else %}
<span class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{{ _self.raw(address, options) }}
</span>
{% endif %}
{{ _self.validity(address, options) }}
{% endmacro %}
{% macro validity(address, options) %}
{%- if options['with_valid_from'] == true -%}
<span class="address-valid address-since">
{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}
</span>
{%- endif -%}
{%- if options['with_valid_to'] == true -%}
<span class="address-valid address-until">
{{ 'Until %date%'|trans( { '%date%' : address.validTo|format_date('long') } ) }}
</span>
{%- endif -%}
{% endmacro %}
{%- if render == 'list' -%}
<li class="chill-entity entity-address">
{% if options['with_picto'] %}
<i class="fa fa-li fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options) }}
</li>
{%- endif -%}
{%- if render == 'inline' -%}
<span class="chill-entity entity-address">
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.inline(address, options) }}
</span>
{%- endif -%}
{%- if render == 'bloc' -%}
<div class="chill-entity entity-address">
{% if options['has_no_address'] == true and address.isNoAddress == true %}
<div class="noaddress">
{{ 'address.consider homeless'|trans }}
</div>
{% else %}
<div class="address{% if options['multiline'] %} multiline{% endif %}{% if options['with_delimiter'] %} delimiter{% endif %}">
{% if options['with_picto'] %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
{{ _self.raw(address, options) }}
</div>
{% endif %}
{{ _self.validity(address, options) }}
</div>
{%- endif -%}

View File

@ -60,14 +60,22 @@
{{- form_errors(form) -}}
</div>
{%- else -%}
{{- form_label(form) -}}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form, widget_attr) -}}
{{- form_help(form) -}}
{{- form_errors(form) -}}
</div>
{% if form.vars.hideLabel is not defined or form.vars.hideLabel == false %}
{{- form_label(form) -}}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form, widget_attr) -}}
{{- form_help(form) -}}
{{- form_errors(form) -}}
</div>
{% else %}
<div class="col-sm">
{{- form_widget(form, widget_attr) -}}
{{- form_help(form) -}}
{{- form_errors(form) -}}
</div>
{% endif %}
{%- endif -%}
{##}</div>
</div>
{%- endif -%}
{%- endblock form_row %}

View File

@ -1,5 +1,5 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@ -19,15 +19,15 @@
{% block form_row %}
{% apply spaceless %}
{% if form.vars.hideLabel is not defined or form.vars.hideLabel == false %}
<div class="container-fluid mb-2">
<div class="mb-2">
<div class="row">
<div class="{% apply spaceless %}
{% if attr.class is defined and ('cf-title' in attr.class or 'cf-fields' in attr.class ) %}
col-12
col-sm-12
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
col-2 col-md-4 clear
col-sm-2 col-md-4 clear
{% else %}
col-4 clear
col-sm-4 clear
{% endif %}
{% endapply %}">
{% if attr.class is not defined or ('cf-title' not in attr.class and 'cf-fields' not in attr.class ) %}
@ -36,13 +36,13 @@
</div>
<div class="{% apply spaceless %}
{% if attr.class is defined and 'cf-title' in attr.class %}
col-12
col-sm-12
{% elseif attr.class is defined and 'cf-fields' in attr.class %}
col-12 parent
col-sm-12 parent
{% elseif attr.class is defined and 'multiple-cf-inline' in attr.class %}
col-2 col-md-8 multiple-cf-inline
col-sm-2 col-md-8 multiple-cf-inline
{% else %}
col-8
col-sm-8
{% endif %}
{% endapply %}">
{{ form_widget(form) }}
@ -55,7 +55,7 @@
{% endif %}
{% endapply %}
{% endblock form_row %}
{% block choice_widget_expanded %}
{% apply spaceless %}
<div {{ block('widget_container_attributes') }} class="choice-widget-expanded">
@ -125,7 +125,7 @@
</div>
{%- endif -%}
{%- endblock time_widget -%}
{% block form_errors %}
{% apply spaceless %}
{% if errors|length > 0 %}
@ -140,27 +140,27 @@
{% block _formatter__aggregator_placement_csv_formatter_row %}
<h3>{{ form_label(form) }}</h3>
{{ form_row(form.order) }}
{{ form_row(form.position) }}
{% endblock %}
{% block _formatter__aggregator_placement_spreadsheet_formatter_row %}
<h3>{{ form_label(form) }}</h3>
{{ form_row(form.order) }}
{% endblock %}
{% block chill_collection_widget %}
<div class="chill-collection">
<ul class="list-entry"
data-collection-name="{{ form.vars.name|escape('html_attr') }}"
data-collection-identifier="{{ form.vars.identifier|escape('html_attr') }}"
data-collection-button-remove-label="{{ form.vars.button_remove_label|trans|e }}"
data-collection-allow-add="{{ form.vars.allow_add|escape('html_attr') }}"
<ul class="list-entry"
data-collection-name="{{ form.vars.name|escape('html_attr') }}"
data-collection-identifier="{{ form.vars.identifier|escape('html_attr') }}"
data-collection-button-remove-label="{{ form.vars.button_remove_label|trans|e }}"
data-collection-allow-add="{{ form.vars.allow_add|escape('html_attr') }}"
data-collection-allow-delete="{{ form.vars.allow_delete|escape('html_attr') }}">
{% for entry in form %}
<li class="entry" data-collection-is-persisted="1">
@ -172,14 +172,14 @@
</ul>
{% if form.vars.allow_add == 1 %}
<button class="add-entry btn btn-misc"
data-collection-add-target="{{ form.vars.name|escape('html_attr') }}"
<button class="add-entry btn btn-misc"
data-collection-add-target="{{ form.vars.name|escape('html_attr') }}"
data-form-prototype="{{ ('<div>' ~ form_widget(form.vars.prototype) ~ '</div>')|escape('html_attr') }}" >
<i class="fa fa-plus fa-fw"></i>
{{ form.vars.button_add_label|trans }}
</button>
{% endif %}
</div>
{% endblock %}

View File

@ -0,0 +1 @@
<div class="responsive"></div>

View File

@ -0,0 +1,42 @@
{% extends "@ChillMain/layout.html.twig" %}
{% block content %}
<div id="container content">
<div class="grid-8 centered">
<h1>{{ "Notifications list" | trans }}</h1>
<!-- TODO : UNREAD & READ -->
{%for data in datas %}
{% set notification = data.notification %}
<dl class="chill_view_data">
<dt class="inline">{{ 'Message'|trans }}</dt>
<dd>{{ notification.message }}</dd>
</dl>
<dl class="chill_view_data">
<dt class="inline">{{ 'Date'|trans }}</dt>
<dd>{{ notification.date | date('long') }}</dd>
</dl>
<dl class="chill_view_data">
<dt class="inline">{{ 'Sender'|trans }}</dt>
<dd>{{ notification.sender }}</dd>
</dl>
<dl class="chill_view_data">
<dt class="inline">{{ 'Addressees'|trans }}</dt>
<dd>{{ notification.addressees |join(', ') }}</dd>
</dl>
<dl class="chill_view_data">
<dt class="inline">{{ 'Entity'|trans }}</dt>
<dd>
{% include data.template with data.template_data %}
</dd>
</dl>
{% endfor %}
</div>
</div>
{% endblock content %}

View File

@ -1 +1 @@
{% if nb > 0 %}<span class="notification-counter">{{ nb }}</span>{% endif %}
{% if nb > 0 %}<span class="badge rounded-pill bg-danger notification-counter">{{ nb }}</span>{% endif %}

View File

@ -38,6 +38,9 @@
</head>
<body>
{#
{{ include('@ChillMain/Layout/_debug.html.twig') }}
#}
{{ include('@ChillMain/Layout/_header.html.twig') }}
{% block top_banner %}{#
@ -50,30 +53,23 @@
{% block sublayout_content %}
<div class="row justify-content-center my-5">
{# Flash messages ! #}
{% if app.session.flashbag.all()|length > 0 %}
<div class="col-8 mb-5 flash_message">
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="col-8 mb-5 alert alert-success flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="col-8 alert alert-success flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('error') %}
<div class="col-8 mb-5 alert alert-danger flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('error') %}
<div class="col-8 alert alert-danger flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="col-8 alert alert-warning flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
</div>
{% endif %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="col-8 mb-5 alert alert-warning flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% block content %}
<div class="col-8 main_search">

View File

@ -1,5 +1,5 @@
{#
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
* Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@ -27,30 +27,23 @@
<div class="row">
<div class="col-md-9 my-5">
{# Flash messages ! #}
{% if app.session.flashbag.all()|length > 0 %}
<div class="row justify-content-center mb-5">
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="col-8 mb-5 alert alert-success flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="col-8 alert alert-success flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('error') %}
<div class="col-8 mb-5 alert alert-danger flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('error') %}
<div class="col-8 alert alert-danger flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="col-8 alert alert-warning flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
</div>
{% endif %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="col-8 mb-5 alert alert-warning flash_message">
<span>{{ flashMessage|raw }}</span>
</div>
{% endfor %}
{% block layout_wvm_content %}<!-- content of the layoutWithVerticalMenu is empty -->
{% endblock %}

View File

@ -28,11 +28,11 @@ abstract class AbstractChillEntityRender implements ChillEntityRenderInterface
{
protected function getDefaultOpeningBox($classSuffix): string
{
return '<span class="chill-entity chill-entity__'.$classSuffix.'">';
return '<section class="chill-entity entity-'.$classSuffix.'">';
}
protected function getDefaultClosingBox(): string
{
return '</span>';
return '</section>';
}
}

View File

@ -10,16 +10,20 @@ class AddressRender implements ChillEntityRenderInterface
private EngineInterface $templating;
public const DEFAULT_OPTIONS = [
'with_valid_from' => true,
'with_valid_from' => false,
'with_valid_to' => false,
'with_picto' => false,
'with_delimiter' => false,
'has_no_address' => false,
'multiline' => true,
'extended_infos' => false
];
public function __construct(EngineInterface $templating)
{
$this->templating = $templating;
}
/**
* {@inheritDoc}
*/
@ -56,11 +60,12 @@ class AddressRender implements ChillEntityRenderInterface
*/
public function renderBox($addr, array $options): string
{
$options = \array_merge(self::DEFAULT_OPTIONS, $options);
$options = \array_merge(self::DEFAULT_OPTIONS, $options);
return $this->templating
->render('@ChillMain/Address/entity_render.html.twig', [
->render('@ChillMain/Entity/address.html.twig', [
'address' => $addr,
'render' => $options['render'] ?? 'bloc',
'options' => $options
]);
}

View File

@ -26,7 +26,7 @@ use Symfony\Component\HttpFoundation\Request;
/**
* This class provide a set of tests for exports.
*
*
* The tests provided by this class will check basic things, like
* the type of value are conform to the expected, etc.
*
@ -34,45 +34,45 @@ use Symfony\Component\HttpFoundation\Request;
*/
abstract class AbstractExportTest extends WebTestCase
{
use PrepareClientTrait;
/**
* Create an instance of the report to test
*
*
* @return \Chill\MainBundle\Export\ExportInterface an instance of the export to test
*/
public abstract function getExport();
/**
* Create possible combinaison of data (produced by the form).
*
*
* This data will be used to generate data providers using this data.
*
*
* @return array an array of data. Example : `array( array(), array('fields' => array(1,2,3), ...)` where an empty array and `array(1,2,3)` are possible values
*/
public abstract function getFormData();
/**
* get the possible modifiers which could apply in combination to this
* get the possible modifiers which could apply in combination to this
* export.
* .
*
* @return array of string[] an array which contains an array of possible modifiers. Example : `array( array('modifier_1', 'modifier_2'), array('modifier_1'), ...)`
* .
*
* @return array of string[] an array which contains an array of possible modifiers. Example : `array( array('modifier_1', 'modifier_2'), array('modifier_1'), ...)`
*/
abstract public function getModifiersCombination();
/**
* Return an array usable as ACL
*
*
* If this method is overridden, the returned result must be an array
* with this form :
*
*
* ```
* array(
* array(
* 'center' => //center instance
* array(
* 'center' => //center instance
* 'circles' => array(// array of circles instances )
* )
* );
@ -84,15 +84,15 @@ abstract class AbstractExportTest extends WebTestCase
if (static::$kernel === null) {
static::bootKernel();
}
$em = static::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$centers = $em->getRepository('ChillMainBundle:Center')
->findAll();
$circles = $em->getRepository('ChillMainBundle:Scope')
->findAll();
if (count($centers) === 0) {
throw new \RuntimeException("No center found. Did you forget to "
. "run `doctrine:fixtures:load` command before ?");
@ -101,7 +101,7 @@ abstract class AbstractExportTest extends WebTestCase
throw new \RuntimeException("No circle found. Did you forget to "
. "run `doctrine:fixtures:load` command before ?");
}
return array([
'center' => $centers[0],
'circles' => [
@ -115,204 +115,203 @@ abstract class AbstractExportTest extends WebTestCase
public function testGetType()
{
$export = $this->getExport();
$this->assertInternalType('string', $export->getType(),
$this->assertInternalType('string', $export->getType(),
"Assert that the `getType` method return a string");
$this->assertNotEmpty($export->getType(), "Assert that the `getType` method"
. " does not return an empty string.");
}
/**
* Test that the description is not empty
*/
public function testGetDescription()
{
$export = $this->getExport();
$this->assertInternalType('string', $export->getDescription(),
$this->assertInternalType('string', $export->getDescription(),
"Assert that the `getDescription` method return a string");
$this->assertNotEmpty($export->getDescription(),
$this->assertNotEmpty($export->getDescription(),
"Assert that the `getDescription` method does not return an empty "
. "string.");
}
/**
* create data for `ìnitiateQuery` method
*/
public function dataProviderInitiateQuery()
{
$acl = $this->getAcl();
foreach($this->getModifiersCombination() as $modifiers) {
foreach($this->getFormData() as $data) {
yield array($modifiers, $acl, $data);
}
}
}
public function dataProviderGetQueryKeys()
{
foreach($this->getFormData() as $data) {
yield array($data);
}
}
/**
*
*
* test that the query returned is a QueryBuilder or a NativeQuery.
*
*
* If the query is a QueryBuilder, test that select and from is not empty.
*
* If the query is a native sql, test the query is not empty (length is
*
* If the query is a native sql, test the query is not empty (length is
* > 0).
*
*
* @dataProvider dataProviderInitiateQuery
*/
public function testInitiateQuery($modifiers, $acl, $data)
{
var_dump($data);
$query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
$this->assertTrue($query instanceof QueryBuilder || $query instanceof NativeQuery,
sprintf("Assert that the returned query is an instance of %s or %s",
sprintf("Assert that the returned query is an instance of %s or %s",
QueryBuilder::class, Query::class));
if ($query instanceof QueryBuilder) {
$this->assertGreaterThanOrEqual(1, count($query->getDQLPart('select')),
"assert there is at least one 'select' part");
$this->assertGreaterThanOrEqual(1, count($query->getDQLPart('from')),
"assert there is at least one 'from' part");
} elseif ($query instanceof NativeQuery) {
$this->assertNotEmpty($query->getSQL(),
$this->assertNotEmpty($query->getSQL(),
"check that the SQL query is not empty");
}
}
/**
* Test that supportsModifier return :
*
*
* - an array of string, if the query is a QueryBuilder ;
* - nothing, if the query is a native SQL
*
*
* @dataProvider dataProviderInitiateQuery
*/
public function testSupportsModifier($modifiers, $acl, $data)
{
$export = $this->getExport();
$query = $export->initiateQuery($modifiers, $acl, $data);
if ($query instanceof QueryBuilder) {
$this->assertContainsOnly('string', $export->supportsModifiers(),
"Test that the `supportsModifiers` method returns only strings");
} elseif ($query instanceof NativeQuery) {
$this->assertTrue($export->supportsModifiers() === null ||
$this->assertTrue($export->supportsModifiers() === null ||
count($export->supportsModifiers()) === 0,
"Test that the `supportsModifier` methods returns null or an empty array");
}
}
/**
* Test required role is an instance of Role
*/
public function testRequiredRole()
{
$role = $this->getExport()->requiredRole();
$this->assertInstanceOf(Role::class, $role,
$this->assertInstanceOf(Role::class, $role,
sprintf("test that the returned value of `requiredRole` is an instance "
. "of %s", Role::class));
}
/**
* Test the formatters type are string
*/
public function testGetAllowedFormattersType()
{
$formattersTypes = $this->getExport()->getAllowedFormattersTypes();
$this->assertContainsOnly("string", $formattersTypes,
"Test that the method `getAllowedFormattersTypes` returns an array of string");
}
/**
* Test that the query keys are strings
*
*
* @param array $data
* @dataProvider dataProviderGetQueryKeys
*/
public function testGetQueryKeys(array $data)
{
$queryKeys = $this->getExport()->getQueryKeys($data);
$this->assertContainsOnly("string", $queryKeys,
"test that the query keys returned by `getQueryKeys` are only strings");
$this->assertGreaterThanOrEqual(1, count($queryKeys),
"test that there are at least one query key returned");
}
/**
*
* Test that
*
*
* Test that
*
* - the results have a correct form (are arrays or traversable)
* - each key in a row are present in getQueryKeys ;
* - each returned object of the `getLabels` method is callable
* - each result can be converted to string using this callable
* - each of this callable can provide a string for '_header'
*
*
* @param string[] $modifiers
* @param array $acl
* @param array $data
*
*
* @dataProvider dataProviderInitiateQuery
*/
public function testGetResultsAndLabels($modifiers, $acl, array $data)
{
// it is more convenient to group the `getResult` and `getLabels` test
// due to the fact that testing both methods use the same tools.
$queryKeys = $this->getExport()->getQueryKeys($data);
$query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
// limit the result for the query for performance reason (only for QueryBuilder,
// not possible in NativeQuery)
if ($query instanceof QueryBuilder) {
$query->setMaxResults(1);
}
}
$results = $this->getExport()->getResult($query, $data);
$this->assertInternalType('array', $results,
$this->assertInternalType('array', $results,
"assert that the returned result is an array");
if (count($results) === 0) {
$this->markTestIncomplete("The result is empty. We cannot process tests "
. "on results");
}
// testing the result
$result = $results[0];
$this->assertTrue( $result instanceof \Traversable || is_array($result),
"test that each row in the result is traversable or an array");
foreach ($result as $key => $value) {
$this->assertContains($key, $queryKeys,
"test that each key is present in `getQueryKeys`");
$closure = $this->getExport()->getLabels($key, array($value), $data);
$this->assertTrue(is_callable($closure, false),
"test that the `getLabels` for key is a callable");
$this->assertTrue(is_string((string) call_user_func($closure, $value)),
sprintf("test that the callable return by `getLabels` for key %s "
. "is a string or an be converted to a string", $key));
$this->assertTrue(
// conditions
is_string((string) call_user_func($closure, '_header'))
@ -322,13 +321,13 @@ abstract class AbstractExportTest extends WebTestCase
sprintf("Test that the callable return by `getLabels` for key %s "
. "can provide an header", $key)
);
}
}
}
/**
* Test that the translated title of the export is present the list,
* Test that the translated title of the export is present the list,
* and that the list of exports (under `/fr/exports/`) is still successfull
*/
public function testListExportPage()
@ -338,17 +337,17 @@ abstract class AbstractExportTest extends WebTestCase
$export = $this->getExport();
$prophet= new \Prophecy\Prophet;
$container = static::$kernel->getContainer();
// store the locale in a request
$request = new Request();
$request->setLocale('fr');
$container->get('request_stack')->push($request);
// translate the title
$title = $container->get('translator')->trans($export->getTitle());
// performs the request to /fr/exports
$crawler = $client->request('GET', '/fr/exports/');
// and finally make tests
$this->assertTrue($client->getResponse()->isSuccessful(),
"test that the response of /fr/exports/ is successful");

View File

@ -34,6 +34,10 @@ chill_password_recover:
resource: "@ChillMainBundle/config/routes/password_recover.yaml"
prefix: "public/{_locale}/password"
chill_main_notification:
resource: "@ChillMainBundle/config/routes/notification.yaml"
prefix: "{_locale}/notification"
chill_crud:
resource: "@ChillMainBundle"
type: CRUD

View File

@ -33,3 +33,8 @@ services:
$logger: '@Psr\Log\LoggerInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\MainBundle\Controller\NotificationController:
arguments:
$security: '@Symfony\Component\Security\Core\Security'
tags: ['controller.service_arguments']

View File

@ -4,7 +4,11 @@ services:
$logger: '@Psr\Log\LoggerInterface'
$twig: '@Twig\Environment'
$mailer: '@swiftmailer.mailer.default'
# $mailerTransporter: '@swiftmailer.transport'
# $mailerTransporter: '@swiftmailer.transport'
$router: '@Symfony\Component\Routing\RouterInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$routeParameters: '%chill_main.notifications%'
Chill\MainBundle\Notification\NotificationRenderer:
autoconfigure: true
autowire: true

View File

@ -2,6 +2,8 @@ services:
chill_main.paginator_factory:
class: Chill\MainBundle\Pagination\PaginatorFactory
public: true
autowire: true
autoconfigure: true
arguments:
- "@request_stack"
- "@router"

View File

@ -0,0 +1,6 @@
years_old: >-
{age, plural,
one {# an}
many {# ans}
other {# ans}
}

View File

@ -1,25 +1,7 @@
<?php
/*
* Copyright (C) 2016-2019 Champs-Libres <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\PersonBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@ -28,39 +10,28 @@ use Doctrine\ORM\EntityManagerInterface;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Console\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
class ChillPersonMoveCommand extends ContainerAwareCommand
final class ChillPersonMoveCommand extends Command
{
/**
*
* @var PersonMove
*/
protected $mover;
/**
*
* @var EntityManagerInterface
*/
protected $em;
/**
*
* @var LoggerInterface
*/
protected $chillLogger;
private PersonMove $mover;
private EntityManagerInterface $em;
private LoggerInterface $chillLogger;
public function __construct(
PersonMove $mover,
PersonMove $mover,
EntityManagerInterface $em,
LoggerInterface $chillLogger
) {
parent::__construct('chill:person:move');
$this->mover = $mover;
$this->em = $em;
$this->chillLogger = $chillLogger;
}
protected function configure()
{
$this
@ -73,14 +44,14 @@ class ChillPersonMoveCommand extends ContainerAwareCommand
->addOption('delete-entity', null, InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, "entity to delete", [])
;
}
protected function interact(InputInterface $input, OutputInterface $output)
{
if (FALSE === $input->hasOption('dump-sql') && FALSE === $input->hasOption('force')) {
$msg = "You must use \"--dump-sql\" or \"--force\"";
throw new RuntimeException($msg);
}
foreach (["from", "to"] as $name) {
if (empty($input->getOption($name))) {
throw new RuntimeException("You must set a \"$name\" option");
@ -90,7 +61,7 @@ class ChillPersonMoveCommand extends ContainerAwareCommand
throw new RuntimeException("The id in \"$name\" field does not contains "
. "only digits: $id");
}
}
}
}
protected function execute(InputInterface $input, OutputInterface $output)
@ -99,16 +70,16 @@ class ChillPersonMoveCommand extends ContainerAwareCommand
$from = $repository->find($input->getOption('from'));
$to = $repository->find($input->getOption('to'));
$deleteEntities = $input->getOption('delete-entity');
if ($from === NULL) {
throw new RuntimeException(sprintf("Person \"from\" with id %d not found", $input->getOption('from')));
}
if ($to === NULL) {
throw new RuntimeException(sprintf("Person \"to\" with id %d not found", $input->getOption('to')));
}
$sqls = $this->mover->getSQL($from, $to, $deleteEntities);
if ($input->getOption('dump-sql')) {
foreach($sqls as $sql) {
$output->writeln($sql);
@ -125,25 +96,25 @@ class ChillPersonMoveCommand extends ContainerAwareCommand
$connection->executeQuery($sql);
}
$connection->commit();
$this->chillLogger->notice("Move a person from command line succeeded", $ctxt);
}
}
protected function buildLoggingContext(Person $from, Person $to, $deleteEntities, $sqls)
{
$ctxt = [
'from' => $from->getId(),
'to' => $to->getId()
];
foreach ($deleteEntities as $key => $de) {
$ctxt['delete_entity_'.$key] = $de;
}
foreach ($sqls as $key => $sql) {
$ctxt['sql_'.$key] = $sql;
}
return $ctxt;
}

View File

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Command;
use Chill\PersonBundle\Service\Import\ChillImporter;
use Chill\PersonBundle\Service\Import\SocialWorkMetadataInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use League\Csv\Reader;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Throwable;
final class ImportSocialWorkMetadata extends Command
{
/**
* @var EntityManagerInterface
*/
protected EntityManagerInterface $em;
/**
* @var LoggerInterface
*/
protected ChillImporter $importer;
public function __construct(
SocialWorkMetadataInterface $socialWorkMetadata
) {
parent::__construct('chill:person:import-socialwork');
$this->importer = $socialWorkMetadata;
}
protected function configure()
{
$this
->setName('chill:person:import-socialwork')
->addOption('filepath', 'f', InputOption::VALUE_REQUIRED, 'The file to import.')
->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'The default language');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$filepath = $input->getOption('filepath');
try {
$csv = Reader::createFromPath($filepath);
} catch (Throwable $e) {
throw new Exception('Error while loading CSV.',0, $e);
}
$csv->setDelimiter(';');
return true === $this->importer->import($csv) ?
0:
1;
}
}

View File

@ -252,18 +252,6 @@ final class PersonController extends AbstractController
*/
$person = $form->getData();
$periods = $person->getAccompanyingPeriodsOrdered();
$period = $periods[0];
$period->setOpeningDate($form['creation_date']->getData());
// $person = new Person($form['creation_date']->getData());
//
// $person->setFirstName($form['firstName']->getData())
// ->setLastName($form['lastName']->getData())
// ->setGender($form['gender']->getData())
// ->setBirthdate($form['birthdate']->getData())
// ->setCenter($form['center']->getData())
// ;
return $person;
}
@ -364,7 +352,6 @@ final class PersonController extends AbstractController
'lastName' => $form['lastName']->getData(),
'birthdate' => $form['birthdate']->getData(),
'gender' => $form['gender']->getData(),
'creation_date' => $form['creation_date']->getData(),
'form' => $form->createView()));
}

View File

@ -0,0 +1,39 @@
<?php
namespace Chill\PersonBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait;
use Chill\PersonBundle\DataFixtures\ORM\LoadAccompanyingPeriod;
/**
* Load notififications into database
*/
class LoadAccompanyingPeriodNotifications extends AbstractFixture implements DependentFixtureInterface
{
use LoadAbstractNotificationsTrait;
public $notifs = [
[
'message' => 'Hello !',
'entityClass' => AccompanyingPeriod::class,
'entityRef' => LoadAccompanyingPeriod::ACCOMPANYING_PERIOD,
'sender' => 'center a_social',
'addressees' => [
'center a_social',
'center a_administrative',
'center a_direction',
'multi_center'
],
]
];
public function getDependencies()
{
return [
LoadAccompanyingPeriod::class,
];
}
}

View File

@ -183,6 +183,14 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
private function addAPerson(array $person, ObjectManager $manager)
{
$p = new Person();
$p->addAccompanyingPeriod(
new AccompanyingPeriod(
(new \DateTime())
->sub(
new \DateInterval('P'.\random_int(0, 180).'D')
)
)
);
foreach ($person as $key => $value) {
switch ($key) {

View File

@ -69,11 +69,11 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$loader->load('services/search.yaml');
$loader->load('services/menu.yaml');
$loader->load('services/privacyEvent.yaml');
$loader->load('services/command.yaml');
$loader->load('services/actions.yaml');
$loader->load('services/form.yaml');
$loader->load('services/alt_names.yaml');
$loader->load('services/household.yaml');
$loader->load('services/notification.yaml');
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
// We should use the PersonRepository service instead of a custom service name.
$loader->load('services/repository.yaml');

View File

@ -379,12 +379,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
private Collection $householdAddresses;
/**
* Person constructor.
*
* @param \DateTime|null $opening
*/
public function __construct(\DateTime $opening = null)
public function __construct()
{
$this->accompanyingPeriodParticipations = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection();
@ -393,12 +388,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
$this->otherPhoneNumbers = new ArrayCollection();
$this->householdParticipations = new ArrayCollection();
$this->householdAddresses = new ArrayCollection();
if ($opening === null) {
$opening = new \DateTime();
}
$this->open(new AccompanyingPeriod($opening));
$this->genderComment = new CommentEmbeddable();
$this->maritalStatusComment = new CommentEmbeddable();
}
@ -734,9 +723,13 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->birthdate;
}
public function getAge(): int
public function getAge(): ?int
{
return date_diff($this->birthdate, date_create('now'))->format("%y");
if ($this->birthdate instanceof \DateTimeInterface) {
return date_diff($this->birthdate, date_create('now'))->format("%y");
}
return null;
}
/**

View File

@ -23,7 +23,7 @@ class Evaluation
private $title = [];
/**
* @ORM\Column(type="dateinterval")
* @ORM\Column(type="dateinterval", nullable=true)
*/
private $delay;

View File

@ -47,7 +47,7 @@ class SocialAction
private $children;
/**
* @ORM\Column(type="dateinterval")
* @ORM\Column(type="dateinterval", nullable=true)
*/
private $defaultNotificationDelay;

View File

@ -26,7 +26,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\CenterType;
use Chill\PersonBundle\Form\Type\GenderType;
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
@ -80,9 +80,6 @@ final class CreationPersonType extends AbstractType
'property_path' => 'birthdate'
))
->add('gender', HiddenType::class)
->add('creation_date', HiddenType::class, array(
'mapped' => false
))
->add('form_status', HiddenType::class, array(
'mapped' => false,
'data' => $options['form_status']
@ -99,25 +96,18 @@ final class CreationPersonType extends AbstractType
$builder->get('birthdate')
->addModelTransformer($dateToStringTransformer);
$builder->get('creation_date')
->addModelTransformer($dateToStringTransformer);
$builder->get('center')
->addModelTransformer($this->centerTransformer);
} else {
$builder
->add('firstName')
->add('lastName')
->add('birthdate', DateType::class, array('required' => false,
'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('birthdate', ChillDateType::class, [
'required' => false,
])
->add('gender', GenderType::class, array(
'required' => true, 'placeholder' => null
))
->add('creation_date', DateType::class, array(
'required' => true,
'widget' => 'single_text',
'format' => 'dd-MM-yyyy',
'mapped' => false,
'data' => new \DateTime()))
->add('form_status', HiddenType::class, array(
'data' => $options['form_status'],
'mapped' => false

View File

@ -0,0 +1,24 @@
<?php
namespace Chill\PersonBundle\Notification;
use Chill\MainBundle\Entity\Notification;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
final class AccompanyingPeriodNotificationRenderer
{
public function supports(Notification $notification)
{
return $notification->getRelatedEntityClass() == AccompanyingPeriod::class;
}
public function getTemplate()
{
return 'ChillPersonBundle:AccompanyingPeriod:showInNotification.html.twig';
}
public function getTemplateData(Notification $notification)
{
return ['notification' => $notification];
}
}

View File

@ -5,8 +5,9 @@ namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class EvaluationRepository
final class EvaluationRepository implements ObjectRepository
{
private EntityRepository $repository;
@ -14,4 +15,40 @@ final class EvaluationRepository
{
$this->repository = $entityManager->getRepository(Evaluation::class);
}
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Evaluation
{
return $this->repository->find($id, $lockMode, $lockVersion);
}
/**
* @return array<int, Evaluation>
*/
public function findAll(): array
{
return $this->repository->findAll();
}
/**
* @return array<int, Evaluation>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria, ?array $orderBy = null): ?Evaluation
{
return $this->repository->findOneBy($criteria, $orderBy);
}
/**
* @return class-string
*/
public function getClassName(): string
{
return Evaluation::class;
}
}

View File

@ -18,31 +18,27 @@ final class GoalRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(Goal::class);
}
public function find($id)
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Goal
{
return $this->repository->find($id);
return $this->repository->find($id, $lockMode, $lockVersion);
}
public function findAll()
/**
* @return array<int, Goal>
*/
public function findAll(): array
{
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
/**
* @return array<int, Goal>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria)
{
return $this->findOneBy($criteria);
}
public function getClassName()
{
return Goal::class;
}
/**
*
* @return Goal[]
@ -91,4 +87,16 @@ final class GoalRepository implements ObjectRepository
return $qb;
}
public function findOneBy(array $criteria, ?array $orderBy = null): ?Goal
{
return $this->repository->findOneBy($criteria, $orderBy);
}
/**
* @return class-string
*/
public function getClassName(): string
{
return Goal::class;
}
}

View File

@ -19,31 +19,19 @@ final class ResultRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(Result::class);
}
public function find($id)
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?Result
{
return $this->repository->find($id);
return $this->repository->find($id, $lockMode, $lockVersion);
}
public function findAll()
/**
* @return array<int, Result>
*/
public function findAll(): array
{
return $this->repository->findAll();
}
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria)
{
return $this->findOneBy($criteria);
}
public function getClassName()
{
return Result::class;
}
/**
*
* @return Result[]
@ -133,5 +121,25 @@ final class ResultRepository implements ObjectRepository
->getSingleScalarResult()
;
}
}
/**
* @return array<int, Result>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria, ?array $orderBy = null): ?Result
{
return $this->repository->findOneBy($criteria, $orderBy);
}
/**
* @return class-string
*/
public function getClassName(): string
{
return Result::class;
}
}

View File

@ -5,8 +5,9 @@ namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
final class SocialActionRepository
final class SocialActionRepository implements ObjectRepository
{
private EntityRepository $repository;
@ -14,4 +15,38 @@ final class SocialActionRepository
{
$this->repository = $entityManager->getRepository(SocialAction::class);
}
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?SocialAction
{
return $this->repository->find($id, $lockMode, $lockVersion);
}
/**
* @return array<int, SocialAction>
*/
public function findAll(): array
{
return $this->repository->findAll();
}
/**
* @return array<int, SocialAction>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria, ?array $orderBy = null): ?SocialAction
{
return $this->repository->findOneBy($criteria, $orderBy);
}
/**
* @return class-string
*/
public function getClassName(): string
{
return SocialAction::class;
}
}

View File

@ -1,9 +1,10 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\Persistence\ObjectRepository;
@ -17,42 +18,36 @@ final class SocialIssueRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(SocialIssue::class);
}
/**
* {@inheritDoc}
*/
public function find($id)
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?SocialIssue
{
return $this->repository->find($id);
return $this->repository->find($id, $lockMode, $lockVersion);
}
/**
* {@inheritDoc}
* @return array<int, SocialIssue>
*/
public function findAll()
public function findAll(): array
{
return $this->repository->findAll();
}
/**
* {@inheritDoc}
* @return array<int, SocialIssue>
*/
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null)
public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
/**
* {@inheritDoc}
*/
public function findOneBy(array $criteria)
public function findOneBy(array $criteria, ?array $orderBy = null): ?SocialIssue
{
return $this->findOneBy($criteria);
return $this->repository->findOneBy($criteria, $orderBy);
}
/**
* {@inheritDoc}
* @return class-string
*/
public function getClassName()
public function getClassName(): string
{
return SocialIssue::class;
}

View File

@ -1,4 +1,5 @@
@import '~ChillMainAssets/module/bootstrap/bootstrap';
// Access to Bootstrap variables and mixins
@import '~ChillMainAssets/module/bootstrap/shared';
/*
* PERSON CONTEXT
@ -16,6 +17,11 @@ div#header-person-details {
color: #FFF;
padding-top: 1em;
padding-bottom: 1em;
div.contact {
& > * {
margin-right: 1em;
}
}
}
div#person_details_container {
@ -108,6 +114,7 @@ div#header-accompanying_course-details {
div#header-household-name {
background: none repeat scroll 0 0 #929d69; //#b97a7a;
color: #FFF;
h1 {
margin: 0.4em 0;
}
@ -130,85 +137,26 @@ div#header-household-details {
}
}
/*
* ADDRESS HISTORY
* context person / household
*/
div.address-timeline.grid {
display: grid;
grid-template-rows: auto auto auto;
grid-template-columns: auto 120px auto;
@media only screen and (max-width: 750px) {
grid-template-columns: auto 1em auto;
}
div.top {
grid-column: 2;
text-align: center;
color: lightgrey;
margin-bottom: -20px;
}
div.col-a {
grid-column: 1;
text-align: right;
}
div.col-b,
div.date {
grid-column: 2;
position: relative;
&:after {
position: absolute;
content: '';
top: 0; bottom: 0;
left: 50%;
margin: auto -5px;
width: 10px;
height: 100%;
background-color: lightgrey;
z-index: -5;
div.household-members {
display: flex;
flex-direction: row;
flex-wrap: wrap;
//justify-content: flex-end;
span.badge-member {
flex-shrink: 0; flex-grow: 0; flex-basis: auto;
border: 1px solid #ffffff3b;
color: #ffffff;
padding: 0.4em 0.8em;
margin-bottom: 0.2em;
margin-right: 0.3em;
border-radius: 8px;
&.holder {
order: -1;
}
}
div.col-c {
grid-column: 3;
}
div.col-b,
div.action,
div.content {
min-height: 30px;
padding: 1em;
}
div.content {
margin: 0.3em;
border: 1px dashed #00000045;
&.row1 { // current address
border: 1px solid #000;
}
div.address {
font-variant: small-caps;
}
}
div.date {
text-align: center;
background-color: lightgrey;
padding: 0.5em;
border-radius: 0.3em;
}
div.span2 { grid-row: span 3; }
div.span3 { grid-row: span 5; }
div.span4 { grid-row: span 7; }
div.span5 { grid-row: span 9; }
ul.record_actions {
margin: 0;
}
.fake {
&:after {
content: 'fake, just to test.. ';
color: lightgrey;
font-style: italic;
&.child {
order: 2;
}
}
}

View File

@ -7,6 +7,8 @@ require('./scss/person_with_period.scss');
require('./scss/household_banner.scss');
require('./scss/accompanying_period_work.scss');
require('./scss/person_by_phonenumber.scss');
require('./scss/render_box.scss');
require('./scss/address_history.scss');
require('./svg/phone-alt-solid.svg');
require('./svg/mobile-alt-solid.svg');

View File

@ -0,0 +1,88 @@
/*
* ADDRESS HISTORY
* context person / household
*/
div.address-timeline.grid {
display: grid;
grid-template-rows: auto auto auto;
grid-template-columns: auto 120px auto;
div.household-address & {
// no col-a in this context !
grid-template-columns: 0 120px auto;
}
@media only screen and (max-width: 750px) {
grid-template-columns: auto 1em auto;
}
div.top {
grid-column: 2;
text-align: center;
color: lightgrey;
margin-bottom: -20px;
}
div.col-a {
grid-column: 1;
text-align: right;
}
div.col-b,
div.date {
grid-column: 2;
position: relative;
&:after {
position: absolute;
content: '';
top: 0; bottom: 0;
left: 50%;
margin: auto -5px;
width: 10px;
height: 100%;
background-color: lightgrey;
z-index: -5;
}
}
div.col-c {
grid-column: 3;
}
div.col-b,
div.action,
div.content {
min-height: 30px;
padding: 1em;
}
div.content {
margin: 0.3em;
border: 1px dashed #00000045;
&.row1 { // current address
border: 1px solid #000;
}
div.address {
font-variant: small-caps;
}
}
div.date {
text-align: center;
background-color: lightgrey;
padding: 0.5em;
border-radius: 0.3em;
}
div.span2 { grid-row: span 3; }
div.span3 { grid-row: span 5; }
div.span4 { grid-row: span 7; }
div.span5 { grid-row: span 9; }
ul.record_actions {
margin: 0;
}
.fake {
&:after {
content: 'fake, just to test.. ';
color: lightgrey;
font-style: italic;
}
}
}

View File

@ -2,24 +2,11 @@
div.list-with-period,
div.list-household-members {
.chill-entity__person {
.chill-entity__person__first-name,
.chill-entity__person__last-name {
font-size: 1.3em;
font-weight: 700;
}
}
.chill_denomination {
font-size: 1.3em;
font-weight: 700;
}
div.comment {
// for the comment for household-members
}
div.periods {
div.header,
div.header,
div.list-content {
width: calc(100% - 40px);
margin-left: 40px;
@ -28,17 +15,17 @@ div.list-household-members {
position: relative;
a.sc-button {
position: absolute;
width: 30px;
width: 30px;
height: 30px;
top: 10px;
top: 10px;
left: -40px;
padding: 0;
i {
padding: 5px;
}
}
abbr.referrer {
font-size: 70%;
abbr.referrer {
font-size: 70%;
}
span.user {
margin-left: 1em;
@ -51,3 +38,6 @@ div.list-household-members {
}
}
}

View File

@ -0,0 +1,8 @@
section.chill-entity {
&.entity-person {
span.firstname,
span.lastname,
span.altname {}
}
}

View File

@ -2,23 +2,18 @@
<banner></banner>
<sticky-nav></sticky-nav>
<div class="row justify-content-end">
<div class="col-md-11 col-xxl">
<h1 v-if="accompanyingCourse.step === 'DRAFT'">{{ $t('course.title.draft') }}</h1>
<h1 v-else>{{ $t('course.title.active') }}</h1>
<h1 v-if="accompanyingCourse.step === 'DRAFT'">{{ $t('course.title.draft') }}</h1>
<h1 v-else>{{ $t('course.title.active') }}</h1>
<persons-associated></persons-associated>
<origin-demand></origin-demand>
<requestor></requestor>
<social-issue></social-issue>
<referrer></referrer>
<resources></resources>
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
<persons-associated></persons-associated>
<origin-demand></origin-demand>
<requestor></requestor>
<social-issue></social-issue>
<referrer></referrer>
<resources></resources>
<comment v-if="accompanyingCourse.step === 'DRAFT'"></comment>
<confirm v-if="accompanyingCourse.step === 'DRAFT'"></confirm>
</div>
</div>
</template>
<script>

View File

@ -1,33 +1,32 @@
<template>
<teleport to="#header-accompanying_course-name #banner-flags">
<toggle-flags></toggle-flags>
</teleport>
<teleport to="#header-accompanying_course-name #banner-status">
<div v-if="accompanyingCourse.step === 'DRAFT'">
<span v-if="accompanyingCourse.step === 'DRAFT'" class="d-md-block">
<span class="badge bg-secondary">
{{ $t('course.step.draft') }}
</span>
</div>
<div v-else>
<div>
</span>
<span v-else class="text-md-end">
<span class="d-md-block mb-md-3">
<span class="badge bg-primary">
{{ $t('course.step.active') }}
</span>
</div>
<div>
<span>
</span>
<span class="d-md-block">
<span class="d-md-block ms-3 ms-md-0">
<i>{{ $t('course.open_at') }}{{ $d(accompanyingCourse.openingDate.datetime, 'text') }}</i>
</span>
<br>
<span v-if="accompanyingCourse.user">
<span v-if="accompanyingCourse.user" class="d-md-block ms-3 ms-md-0">
{{ $t('course.by') }}<b>{{ accompanyingCourse.user.username }}</b>
</span>
</div>
</div>
</span>
</span>
</teleport>
<teleport to="#header-accompanying_course-details #banner-social-issues">
<div class="col-12">
<social-issue
@ -61,11 +60,6 @@ export default {
<style lang="scss">
div#banner-flags,
div#banner-status {
margin: 1.5em 0;
div {
text-align: right;
margin-bottom: 0.8em;
}
.badge {
text-transform: uppercase;
}

View File

@ -1,19 +1,21 @@
<template>
<div>
<a @click="toggleIntensity" class="flag-toggle">
<span :class="{ 'on': !isRegular }">{{ $t('course.occasional') }}</span>
<i class="fa" :class="{ 'fa-toggle-on': isRegular, 'fa-toggle-on fa-flip-horizontal': !isRegular }"></i>
<span :class="{ 'on': isRegular }">{{ $t('course.regular') }}</span>
</a>
</div>
<div>
<button class="badge rounded-pill" :class="{ 'bg-primary': isEmergency, 'bg-secondary': !isEmergency }" @click="toggleEmergency">
{{ $t('course.emergency') }}
</button>
<button class="badge rounded-pill" :class="{ 'bg-primary': isConfidential, 'bg-secondary': !isConfidential }" @click="toggleConfidential">
{{ $t('course.confidential') }}
</button>
<div class="text-md-end">
<span class="d-block d-sm-inline-block mb-md-2">
<a @click="toggleIntensity" class="flag-toggle">
<span :class="{ 'on': !isRegular }">{{ $t('course.occasional') }}</span>
<i class="fa" :class="{ 'fa-toggle-on': isRegular, 'fa-toggle-on fa-flip-horizontal': !isRegular }"></i>
<span :class="{ 'on': isRegular }">{{ $t('course.regular') }}</span>
</a>
</span>
<span class="d-block d-sm-inline-block ms-sm-3 ms-md-0">
<button class="badge rounded-pill me-1" :class="{ 'bg-primary': isEmergency, 'bg-secondary': !isEmergency }" @click="toggleEmergency">
{{ $t('course.emergency') }}
</button>
<button class="badge rounded-pill" :class="{ 'bg-primary': isConfidential, 'bg-secondary': !isConfidential }" @click="toggleConfidential">
{{ $t('course.confidential') }}
</button>
</span>
</div>
</template>
@ -66,7 +68,6 @@ export default {
<style lang="scss" scoped>
a.flag-toggle {
color: white;
padding: 0 10px;
cursor: pointer;
&:hover {
color: white;
@ -81,7 +82,6 @@ export default {
}
}
button.badge {
margin-left: 0.8em;
&.bg-secondary {
opacity: 0.5;
&:hover {

View File

@ -0,0 +1,40 @@
<div class="border border-danger">
<div class="alert alert-danger alert-with-actions mb-0">
<div class="message">
{{ 'Some peoples does not belong to any household currently. Add them to an household soon'|trans }}
</div>
<ul class="record_actions">
<li>
<button class="btn btn-chill-pink" data-bs-toggle="collapse" href="#withoutHouseholdList">
<i class="fa fa-fw fa-caret-down"></i><span class="text-light">{{ 'Add to household now'|trans }}</span>
</button>
</li>
</ul>
</div>
<div id="withoutHouseholdList" class="collapse p-3">
<form method="GET"
action="{{ chill_path_add_return_path('chill_person_household_members_editor') }}">
<h3>{{ 'household.Select people to move'|trans }}</h3>
<ul>
{% for p in withoutHousehold %}
<li>
<input type="checkbox" name="persons[]" value="{{ p.id }}" checked />
{{ p|chill_entity_render_box }}
</li>
{% endfor %}
</ul>
<input type="hidden" name="expand_suggestions" value="true" />
<input type="hidden" name="accompanying_period_id" value="{{ accompanyingCourse.id }}" />
<ul class="record_actions mb-0">
<li>
<button type="submit" class="btn btn-edit">
{{ 'household.Household editor'|trans }}
</button>
</li>
</ul>
</form>
</div>
</div>

View File

@ -3,7 +3,7 @@
<div class="container-xxl">
<div class="row">
<div class="col-sm-5">
<div class="col-md-6 ps-md-5 ps-xxl-0">
<h1>
<i class="fa fa-random fa-fw"></i>
{{ 'Accompanying Course'|trans }}
@ -12,21 +12,21 @@
</div>
{# vue teleport fragment here #}
<div class="col-sm-3" id="banner-flags"></div>
<div class="col-md-3 mt-3 mb-1 my-md-3" id="banner-flags"></div>
{# vue teleport fragment here #}
<div class="col-sm-3" id="banner-status"></div>
<div class="col-md-3 mt-1 mb-3 my-md-3 pe-md-5 pe-xxl-0" id="banner-status"></div>
</div>
</div>
</div>
<div id="header-accompanying_course-details" class="header-details">
<div class="container-xxl">
<div class="row justify-content-md-right">
{# vue teleport fragment here #}
<div class="col-sm-10" id="banner-social-issues"></div>
<div class="col-md-10 ps-md-5 ps-xxl-0" id="banner-social-issues"></div>
</div>
</div>

View File

@ -1,16 +1,25 @@
{% extends '@ChillPerson/AccompanyingCourse/layout.html.twig' %}
{% import '@ChillMain/Address/macro.html.twig' as address %}
{% block title %}
{{ 'Resume Accompanying Course'|trans }}
{% endblock %}
{% macro button_person(person) %}
{% if person.isSharingHousehold %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': person.getCurrentHousehold.id }) }}"
class="btn btn-chill-pink" title="{{ 'Show household'|trans ~ ' n° ' ~ person.getCurrentHousehold.id }}">
<i class="fa fa-home"></i>
</a>
</li>
{% endif %}
{% endmacro %}
{% block content %}
<div class="accompanying_course-index">
<div class="accompanyingcourse-resume">
{% if 'DRAFT' == accompanyingCourse.step %}
<div class="col-8 centered error flash_message">
<div class="col-8 alert alert-danger flash_message mb-5">
<span>
{{ 'This accompanying course is still a draft'|trans }}
<a href="{{ path('chill_person_accompanying_course_edit', { 'accompanying_period_id': accompanyingCourse.id } ) }}">
@ -20,347 +29,101 @@
</div>
{% endif %}
{% if withoutHousehold|length > 0 %}
<div class="alert alert-danger alert-with-actions">
<div class="message">
{{ 'Some peoples does not belong to any household currently. Add them to an household soon'|trans }}
</div>
<ul class="record_actions">
<li>
<button class="btn btn-create" data-bs-toggle="collapse" href="#withoutHouseholdList">
{{ 'Add to household now'|trans }}
</button>
</li>
</ul>
</div>
<div id="withoutHouseholdList" class="collapse">
<form method="GET" action="{{ chill_path_add_return_path('chill_person_household_members_editor') }}">
<h3>{{ 'household.Select people to move'|trans }}</h3>
<ul>
{% for p in withoutHousehold %}
<li>
<input type="checkbox" name="persons[]" value="{{ p.id }}" checked />
{{ p|chill_entity_render_box }}
</li>
{% endfor %}
</ul>
<input type="hidden" name="expand_suggestions" value="true" />
<input type="hidden" name="accompanying_period_id" value="{{ accompanyingCourse.id }}" />
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-edit">
{{ 'household.Household editor'|trans }}
</button>
</li>
</ul>
</form>
<div class="associated-persons mb-5">
<h2 class="mb-3">{{ 'Associated peoples'|trans }}</h2>
<div class="flex-table mb-3">
{% for participation in accompanyingCourse.participations %}
{% if participation.enddate is null %}
<div class="item-bloc">
{{ participation.person|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addInfo': true,
'customButtons': { 'before': _self.button_person(participation.person) }
}) }}
</div>
{% endif %}
{% endfor %}
</div>
{% if withoutHousehold|length > 0 %}
{% include '@ChillPerson/AccompanyingCourse/_join_household.html.twig' with {} %}
{% endif %}
</div>
{% endif %}
<h2>{{ 'Associated peoples'|trans }}</h2>
<div class="flex-table">
{% for p in accompanyingCourse.participations %}
{% if p.enddate is null %}
<div class="item-bloc">
<div class="item-row">
<div class="item-col">
<h3>{{ p.person.firstname ~ ' ' ~ p.person.lastname }}</h3>
<p>
{% set born = (p.person.gender == 'woman') ? 'née': 'né' %}
{% set gender = (p.person.gender == 'woman') ? 'fa-venus' :
(p.person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (p.person.gender == 'woman') ? 'femme' :
(p.person.gender == 'man') ? 'homme' : 'neutre' %}
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle }}"></i>{{ born ~ ' le ' ~ p.person.birthdate|format_date('short') }}
</p>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if p.person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ p.person.mobilenumber }}">
{{ p.person.mobilenumber|chill_format_phonenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if p.person.phonenumber %}
<a href="{{ 'tel:' ~ p.person.phonenumber }}">{{ p.person.phonenumber|chill_format_phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{%- if p.person.lastAddress is not empty -%}
{{ p.person.currentHouseholdAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_view', { person_id: p.person.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
{% if p.person.isSharingHousehold %}
<li>
<a href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': p.person.getCurrentHousehold.id }) }}"
class="btn btn-misc">
<i class="fa fa-home"></i>
n°&nbsp;
{{ p.person.getCurrentHousehold.id }}
</a>
</li>
{% endif %}
</ul>
</div>
<div class="requestor mb-5">
<h2 class="mb-3">{{ 'Requestor'|trans }}</h2>
{% if accompanyingCourse.requestorPerson is not empty %}
{% set requestor = accompanyingCourse.requestorPerson %}
{% set info = true %}
{% elseif accompanyingCourse.requestor is not empty %}
{% set requestor = accompanyingCourse.requestorThirdParty %}
{% set info = false %}
{% endif %}
{% if accompanyingCourse.requestor == null %}
<p class="chill-no-data-statement">{{ 'Any requestor to this accompanying course'|trans }}</p>
{% else %}
<div class="flex-bloc row row-cols-1 g-0">
<div class="item-bloc col">
{{ requestor|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addEntity': true, 'addInfo': info
}) }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
<h2>{{ 'Requestor'|trans }}</h2>
<div class="resources mb-5">
<h2 class="mb-3">{{ 'Resources'|trans }}</h2>
{% if accompanyingCourse.resources|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p>
{% else %}
<div class="flex-bloc row row-cols-1 row-cols-sm-2 row-cols-xl-3 row-cols-xxl-4 g-0">
{% for r in accompanyingCourse.resources %}
<div class="item-bloc col">
{% if r.person %}
{{ r.person|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addEntity': true, 'addInfo': true
}) }}
{% endif %}
{% if r.thirdParty %}
{{ r.thirdParty|chill_entity_render_box({
'render': 'bloc', 'addLink': false, 'addEntity': true, 'addInfo': false
}) }}
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% if accompanyingCourse.requestor == null %}
<p>{{ 'Any requestor to this accompanying course'|trans }}</p>
{% elseif accompanyingCourse.requestorPerson is not empty %}
{% set r = accompanyingCourse.requestorPerson %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.firstname ~ ' ' ~ r.lastname }}
<span class="badge rounded-pill bg-secondary">{{ 'Usager' }}</span>
</h3>
<p>
{% set born = (r.gender == 'woman') ? 'née': 'né' %}
{% set gender = (r.gender == 'woman') ? 'fa-venus' :
(r.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (r.gender == 'woman') ? 'femme' :
(r.gender == 'homme') ? 'fa-mars' : 'neutre' %}
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle }}"></i>{{ born ~ ' le ' ~ r.birthdate|format_date('short') }}
</p>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if r.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ r.mobilenumber }}">
{{ r.mobilenumber|chill_format_phonenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if r.phonenumber %}
<a href="{{ 'tel:' ~ r.phonenumber }}">{{ r.phonenumber|chill_format_phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{%- if r.lastAddress is not empty -%}
{{ r.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_view', { person_id: r.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% elseif accompanyingCourse.requestorThirdParty is not empty %}
{% set r = accompanyingCourse.requestorThirdParty %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.name }}
<span class="badge rounded-pill bg-secondary">{{ 'Tiers' }}</span>
</h3>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ r.email }}">
{{ r.email|chill_print_or_message("thirdparty.No_email") }}
</a>
</li>
<li><i class="fa fa-li fa-phone"></i>
{% if r.telephone %}
<a href="{{ 'tel:' ~ r.telephone }}">{{ r.telephone|chill_format_phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'thirdparty.No_phonenumber'|trans }}</span>
{% endif %}
</li>
<li><i class="fa fa-li fa-map-marker"></i>
{%- if r.address is not empty -%}
{{ r.getAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: r.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% endif %}
<h2>{{ 'Resources'|trans }}</h2>
{% if accompanyingCourse.resources|length == 0 %}
<p class="chill-no-data-statement">{{ 'Any resource for this accompanying course'|trans }}</p>
{% else %}
<div class="flex-bloc">
{% for r in accompanyingCourse.resources %}
<div class="item-bloc">
{% if r.person %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.person.firstname ~ ' ' ~ r.person.lastname }}
<span class="badge rounded-pill bg-secondary">{{ 'Usager' }}</span>
</h3>
<p>
{% set born = (r.person.gender == 'woman') ? 'née': 'né' %}
{% set gender = (r.person.gender == 'woman') ? 'fa-venus' :
(r.person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (r.person.gender == 'woman') ? 'femme' :
(r.person.gender == 'homme') ? 'fa-mars' : 'neutre' %}
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle }}"></i>{{ born ~ ' le ' ~ r.person.birthdate|format_date('short') }}
</p>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li>
{% if r.person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ r.person.mobilenumber }}">{{ r.person.mobilenumber }}</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if r.person.phonenumber %}
<a href="{{ 'tel:' ~ r.person.phonenumber }}">{{ r.person.phonenumber }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{%- if r.person.lastAddress is not empty -%}
{{ r.person.getLastAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_view', { person_id: r.person.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% endif %}
{% if r.thirdParty %}
<div class="item-row">
<div class="item-col">
<h3>
{{ r.thirdParty.name }}
<span class="badge rounded-pill bg-secondary">{{ 'Tiers' }}</span>
</h3>
</div>
<div class="item-col">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ r.thirdParty.email }}">
{{ r.thirdParty.email|chill_print_or_message("thirdparty.No_email") }}
</a>
</li>
<li><i class="fa fa-li fa-phone"></i>
{% if r.thirdParty.telephone %}
<a href="{{ 'tel:' ~ r.thirdParty.telephone }}">{{ r.thirdParty.telephone }}</a>
{% else %}
<span class="chill-no-data-statement">{{ 'thirdparty.No_phonenumber'|trans }}</span>
{% endif %}
</li>
<li><i class="fa fa-li fa-map-marker"></i>
{%- if r.thirdParty.address is not empty -%}
{{ r.thirdParty.getAddress|chill_entity_render_box({'with_valid_from': false}) }}
{%- else -%}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{%- endif -%}
</li>
</ul>
<ul class="record_actions">
<li>
<a href="{{ path('chill_3party_3party_show', { thirdparty_id: r.thirdParty.id }) }}" class="btn btn-show" target="_blank" title="Voir"></a>
</li>
</ul>
</div>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
<h2>{{ 'Social actions'|trans }}</h2>
<div id="accompanying_course_work_list" class="short">
{% for w in works %}
<div class="item">
<div class="title">
<p class="title_label">{{ 'accompanying_course_work.action'|trans }}</p >
<h2 class="action_title">
{{ w.socialAction|chill_entity_render_box({ 'no-badge': false }) }}
</h2>
</div>
<div class="actions">
<ul class="record_actions">
<li>
<a
class="btn btn-edit"
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}">{{ 'Edit'|trans }}</a>
</li>
</ul>
<div class="social-actions mb-5">
<h2 class="mb-3">{{ 'Social actions'|trans }}</h2>
{% for w in works %}
<div class="item">
<div class="title">
<p class="title_label">{{ 'accompanying_course_work.action'|trans }}</p >
<h2 class="action_title">
{{ w.socialAction|chill_entity_render_box({ 'no-badge': false }) }}
</h2>
</div>
<div class="actions">
<ul class="record_actions">
<li>
<a class="btn btn-edit"
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}">{{ 'Edit'|trans }}</a>
</li>
</ul>
</div>
</div>
</div>
{% else %}
<p class="chill-no-data-statement">{{ 'accompanying_course_work.Any work'|trans }}</p>
{% endfor %}
{% else %}
<p class="chill-no-data-statement">{{ 'accompanying_course_work.Any work'|trans }}</p>
{% endfor %}
</div>
{% block contentActivity %}
<div class="activity mb-5">
{% set person = null %}
{% include 'ChillActivityBundle:Activity:list.html.twig' with {'context': 'accompanyingCourse', 'context': 'accompanyingCourse'} %}
{% include 'ChillActivityBundle:Activity:list.html.twig' with { 'context': 'accompanyingCourse' } %}
</div>
{% endblock %}
{# ==> insert accompanyingCourse vue component #}
<div id="accompanying-course"></div>
</div>
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('vue_accourse_work_list') }}
{% endblock %}

View File

@ -96,7 +96,7 @@
<div class="actions">
<ul class="record_actions">
<li>
<a
<a
class="btn btn-edit"
href="{{ chill_path_add_return_path('chill_person_accompanying_period_work_edit', { 'id': w.id }) }}">{{ 'Edit'|trans }}</a>
</li>
@ -120,8 +120,3 @@
</div>
{% endblock %}
{% block css %}
{{ parent() }}
{{ encore_entry_link_tags('vue_accourse_work_list') }}
{% endblock %}

View File

@ -0,0 +1,3 @@
<a href="{{ path('chill_person_accompanying_course_index', {'accompanying_period_id': notification.relatedEntityId }) }}">
Go to Acc. period.
</a>

View File

@ -16,110 +16,125 @@
#}
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% import '@ChillMain/Address/macro.html.twig' as address_macros %}
{% set activeRouteKey = '' %}
{% block title %}{{ 'Addresses history for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) }}{% endblock %}
{% block personcontent %}
<div class="person-addresses">
<h1>{{ 'Addresses history'|trans }}</h1>
<div class="address-timeline grid">
{% if person.addresses|length == 0 %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
<div class="top"><i class="fa fa-caret-up fa-3x"></i></div>
{% endif %}
{% for address in person.addresses %}
{# if person address #}
<div class="col-a content{{ ' row' ~ loop.index }}">
<div class="address">
{% if address.isNoAddress == true %}
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
{% else %}
{% if address.street is not empty %}
<div class="street">
<span class="streetNumber">{{ address.street }}</span>
{% if address.streetNumber is not empty %}
<span class="streetNumber">, {{ address.streetNumber }}</span>
{% endif %}
</div>
{% endif %}
{% if address.postCode is not empty %}
<div class="postCode">
<span>{{ address.postCode.code }}</span> <span>{{ address.postCode.name }}</span>
<span class="country">({{ address.postCode.country.name|localize_translatable_string }})</span>
</div>
{% endif %}
{% endif %}
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : address.id } ) }}" class="btn btn-edit"></a>
</li>
</ul>
</div>
</div>
{# endif #}
<div class="col-b"></div>
{# if household address #}{#
<div class="col-c content rowXX">
<div class="address">...</div>
</div>
#}{# endif #}
<div class="date">
{% if address.validFrom is not empty %}
{{ address.validFrom|format_date('long') }}
{% endif %}
</div>
{% endfor %}
{# TEST HOUSEHOLD POSITION
#}
<div class="col-b"></div>
<div class="col-c content fake">
<div class="address">
<div class="street">
<span class="streetNumber">549, chemin De Sousa</span>
<span class="streetNumber">, 45, boulevard Aurore Roux</span>
</div>
<div class="postCode">
<span>10850</span> <span>Nanterre</span> <span class="country">(France)</span>
</div>
<ul class="record_actions"><li><a href="" class="btn btn-edit"></a></li></ul>
</div>
<div class="person-address">
<h1>{{ 'Addresses history'|trans }}</h1>
<ul class="record_actions my-3">
<li style="margin: auto;">
<a class="btn btn-lg btn-create"
href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}">
{{ 'Add an address'|trans }}
</a>
</li>
</ul>
<div class="address-timeline grid">
{% if person.addresses|length == 0 %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
<div class="top"><i class="fa fa-caret-up fa-3x"></i></div>
{% endif %}
<div class="col-a">
<h3 class="mb-5">{{ 'Person addresses'|trans }}</h3>
</div>
<div class="col-b"></div>
<div class="col-c">
<h3 class="mb-5">{{ 'Household addresses'|trans }}</h3>
</div>
{% set row = 0 %}
{% set previousRowFrom = null %}
{% for address in person.addresses %}
{% set row = row + 1 %}
{% if address.validTo is not empty and address.validTo < previousRowFrom %}
<div class="{{ 'row' ~ row ~ ' ' }}col-a action">
<a href="" class="btn btn-sm btn-create">{{ 'Insert an address'|trans }}</a></div>
<div class="{{ 'row' ~ row ~ ' ' }}col-b"></div>
<div class="{{ 'row' ~ row ~ ' ' }}col-c action">
<a href="" class="btn btn-sm btn-create">{{ 'Insert an address'|trans }}</a></div>
<div class="date">
{% if address.validTo is not empty %}
{{ address.validTo|format_date('short') }}
{% endif %}
</div>
<div class="date">01 janvier 1970</div>
{# END TEST #}
{% set row = row + 1 %}
{% endif %}
{# if person address #}
<div class="{{ 'row' ~ row ~ ' ' }}col-a content">
{{ address|chill_entity_render_box({
'render': 'bloc',
'multiline': true,
'extended_infos': true,
'has_no_address': true
}) }}
<ul class="record_actions">
<li><a href="{{ path('chill_person_address_edit', { 'person_id': person.id, 'address_id' : address.id } ) }}" class="btn btn-edit"></a></li>
</ul>
</div>
{# endif #}
<div class="{{ 'row' ~ row ~ ' ' }}col-b"></div>
{# if household address #}{#
<div class="col-c content rowXX">
<div class="address">...</div>
</div>
#}{# endif #}
<div class="date">
{% if address.validFrom is not empty %}
{{ address.validFrom|format_date('short') }}
{% endif %}
</div>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path('chill_person_view', { 'person_id' : person.id } ) }}" class="btn btn-cancel">
{{ 'Back to the person details'|trans }}
</a>
</li>
<li>
<a class="btn btn-create"
href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}">
{{ 'Add an address'|trans }}
</a>
</li>
</ul>
{% set previousRowFrom = address.validFrom %}
{% endfor %}
{# TEST HOUSEHOLD POSITION
#}
<div class="col-b"></div>
<div class="col-c content fake">
<div class="address">
<div class="street">
<span class="streetNumber">549, chemin De Sousa</span>
<span class="streetNumber">, 45, boulevard Aurore Roux</span>
</div>
<div class="postCode">
<span>10850</span> <span>Nanterre</span> <span class="country">(France)</span>
</div>
<ul class="record_actions"><li><a href="" class="btn btn-edit"></a></li></ul>
</div>
</div>
<div class="date">01/01/1970</div>
{# END TEST #}
</div>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path('chill_person_view', { 'person_id' : person.id } ) }}" class="btn btn-cancel">
{{ 'Back to the person details'|trans }}
</a>
</li>
<li>
<a class="btn btn-create"
href="{{ path('chill_person_address_new', { 'person_id' : person.id } ) }}">
{{ 'Add an address'|trans }}
</a>
</li>
</ul>
</div>
{% endblock %}

View File

@ -1,17 +1,135 @@
<span class="chill-entity chill-entity__person">
{%- if addLink and is_granted('CHILL_PERSON_SEE', person) -%}
{%- set showLink = true -%}<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">{%- endif -%}
<span class="chill_denomination">{{ person.firstName }}</span>
<span class="chill_denomination">{{ person.lastName }}</span>
{%- if addAltNames -%}
{%- for n in person.altNames -%}
{%- if loop.first -%}({% else %} {%- endif -%}
<span class="chill-entity__person__alt-name chill-entity__person__altname--{{ n.key }}">
{{- n.label -}}
</span>
{%- if loop.last -%}) {%- endif -%}
{%- endfor -%}
{#
Template to render a person
OPTIONS
* render string ['raw'|'label'|'bloc']
* addAltNames bool
* addLink bool
* addEntity bool
* addId bool
* addInfo bool
* addAge bool
* hLevel integer
* customButtons [
'before' Twig\Markup, (injected with macro)
'replace' Twig\Markup,
'after' Twig\Markup
]
#}
{% macro raw(person, options) %}
<span class="firstname">{{ person.firstName }}</span>
<span class="lastname">{{ person.lastName }}</span>
{%- if options['addAltNames'] -%}
<span class="altnames">
{%- for n in person.altNames -%}
<span class="altname altname-{{ n.key }}">
{{- n.label -}}
</span>
{%- endfor -%}
</span>
{%- endif -%}
{%- if showLink is defined -%}</a>{%- endif -%}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</span>{%- endif -%}
{% endmacro raw %}
{% macro label(person, options) %}
<div class="entity-label">
<div class="denomination {{ 'h' ~ options['hLevel'] }}">
{%- if options['addLink'] and is_granted('CHILL_PERSON_SEE', person) -%}
<a href="{{ chill_path_add_return_path('chill_person_view', { 'person_id': person.id }) }}">
{{ _self.raw(person, options) }}
</a>
{%- else -%}
{{ _self.raw(person, options) }}
{%- endif -%}
{%- if options['addEntity'] -%}
<span class="badge rounded-pill bg-secondary">{{ 'Person'|trans }}</span>
{%- endif -%}
{%- if options['addId'] -%}
<span class="id-number" title="{{ 'Person'|trans ~ ' n° ' ~ person.id }}">
{{ person.id|upper }}
</span>
{%- endif -%}
</div>
{%- if options['addInfo'] -%}
{% set gender = (person.gender == 'woman') ? 'fa-venus' :
(person.gender == 'man') ? 'fa-mars' : 'fa-neuter' %}
{% set genderTitle = (person.gender == 'woman') ? 'woman' :
(person.gender == 'man') ? 'man' : 'neuter' %}
<p class="moreinfo">
<i class="fa fa-fw {{ gender }}" title="{{ genderTitle|trans }}"></i>
<time datetime="{{ person.birthdate|date('Y-m-d') }}" title="{{ 'Birthdate'|trans }}">
{{ 'Born the date'|trans({'gender': person.gender,
'birthdate': person.birthdate|format_date("medium") }) }}
</time>
{%- if options['addAge'] -%}
<span class="age">
{{ 'years_old'|trans({ 'age': person.age }) }}
</span>
{%- endif -%}
</p>
{%- endif -%}
{#- tricks to remove easily whitespace after template -#}
{%- if true -%}</div>{%- endif -%}
{% endmacro label %}
{%- if render == 'raw' -%}
{{ _self.raw(person, options) }}
{%- endif -%}
{%- if render == 'label' -%}
{{ _self.label(person, options) }}
{%- endif -%}
{%- if render == 'bloc' -%}
<div class="item-row entity-bloc">
<div class="item-col">
{{ _self.label(person, options) }}
</div>
<div class="item-col">
<ul class="list-content fa-ul">
{{ person.getLastAddress|chill_entity_render_box({
'render': 'list',
'with_picto': true,
'multiline': false,
'with_valid_from': false
}) }}
<li>
{% if person.mobilenumber %}
<i class="fa fa-li fa-mobile"></i><a href="{{ 'tel:' ~ person.mobilenumber }}">
{{ person.mobilenumber|chill_format_phonenumber }}
</a>
{% else %}
<i class="fa fa-li fa-phone"></i>
{% if person.phonenumber %}
<a href="{{ 'tel:' ~ person.phonenumber }}">
{{ person.phonenumber|chill_format_phonenumber }}
</a>
{% else %}
<span class="chill-no-data-statement">{{ 'No data given'|trans }}</span>
{% endif %}
{% endif %}
</li>
</ul>
<ul class="record_actions">
{% if options['customButtons']['before'] is defined %}
{{ options['customButtons']['before'] }}
{% endif %}
{%- if options['customButtons']['replace'] is not defined and is_granted('CHILL_PERSON_SEE', person) -%}
<li>
<a class="btn btn-show" target="_blank" title="{{ 'Show person'|trans }}"
href="{{ path('chill_person_view', { person_id: person.id }) }}"></a>
</li>
{%- else -%}
{{ options['customButtons']['replace'] }}
{%- endif -%}
{% if options['customButtons']['after'] is defined %}
{{ options['customButtons']['after'] }}
{% endif %}
</ul>
</div>
</div>
{%- endif -%}

View File

@ -5,68 +5,83 @@
{% block content %}
<div class="household-address">
<h1>{{ block('title') }}</h1>
<h1>{{ block('title') }}</h1>
<div class="address-timeline grid">
<ul class="record_actions my-3">
<li style="margin: auto;">
<a class="btn btn-lg btn-create"
href="{{ chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }) }}">
{{ 'Move household'|trans }}
</a>
</li>
</ul>
{% if household.addresses|length == 0 %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
<div class="top"><i class="fa fa-caret-up fa-3x"></i></div>
{% endif %}
<div class="address-timeline grid">
{% for address in household.addresses %}
{% if household.addresses|length == 0 %}
<span class="chill-no-data-statement">{{ 'No address given'|trans }}</span>
{% else %}
<div class="top"><i class="fa fa-caret-up fa-3x"></i></div>
{% endif %}
<div class="col-b"></div>
{% set row = 0 %}
{% set previousRowFrom = null %}
<div class="col-c content{{ ' row' ~ loop.index }}">
<div class="address">
{% if address.isNoAddress == true %}
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
{% else %}
{% if address.street is not empty %}
<div class="street">
<span class="streetNumber">{{ address.street }}</span>
{% if address.streetNumber is not empty %}
<span class="streetNumber">, {{ address.streetNumber }}</span>
{% endif %}
</div>
{% endif %}
{% if address.postCode is not empty %}
<div class="postCode">
<span>{{ address.postCode.code }}</span> <span>{{ address.postCode.name }}</span>
<span class="country">({{ address.postCode.country.name|localize_translatable_string }})</span>
</div>
{% for address in household.addresses %}
{% set row = row + 1 %}
{% if address.validTo is not empty and address.validTo < previousRowFrom %}
<div class="{{ 'row' ~ row ~ ' ' }}col-b"></div>
<div class="{{ 'row' ~ row ~ ' ' }}col-c action">
<a href="" class="btn btn-sm btn-create">{{ 'Insert an address'|trans }}</a></div>
<div class="date">
{% if address.validTo is not empty %}
{{ address.validTo|format_date('short') }}
{% endif %}
</div>
{% set row = row + 1 %}
{% endif %}
<div class="{{ 'row' ~ row ~ ' ' }}col-b"></div>
<div class="{{ 'row' ~ row ~ ' ' }}col-c content">
{{ address|chill_entity_render_box({
'render': 'bloc',
'multiline': true,
'extended_infos': true,
'has_no_address': true
}) }}
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_household_address_edit', { 'household_id': household.id, 'address_id' : address.id } ) }}" class="btn btn-edit"></a>
</li>
</ul>
</div>
<div class="date">
{% if address.validFrom is not empty %}
{{ address.validFrom|format_date('short') }}
{% endif %}
</div>
<ul class="record_actions">
<li>
<a href="{{ path('chill_person_household_address_edit', { 'household_id': household.id, 'address_id' : address.id } ) }}" class="btn btn-edit"></a>
</li>
</ul>
</div>
{% set previousRowFrom = address.validFrom %}
{% endfor %}
</div>
<div class="date">
{% if address.validFrom is not empty %}
{{ address.validFrom|format_date('long') }}
{% endif %}
</div>
{% endfor %}
</div>
<ul class="record_actions">
<li>
<a class="btn btn-create"
href="{{ chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }) }}">
{{ 'Move household'|trans }}
</a>
</li>
</ul>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">
<a href="{{ path('chill_person_household_summary', { 'household_id' : household.id } ) }}" class="btn btn-cancel">
{{ 'Back to household'|trans }}
</a>
</li>
<li>
<a class="btn btn-create"
href="{{ chill_path_add_return_path('chill_person_household_address_move', { 'household_id': household.id }) }}">
{{ 'Move household'|trans }}
</a>
</li>
</ul>
</div>
{% endblock %}

View File

@ -2,8 +2,8 @@
<div id="header-household-name" class="header-name">
<div class="container-xxl">
<div class="row">
<div class="col-sm-5">
<div class="col-md-4 col-lg-3 ps-md-5 ps-xxl-0">
<h1>
<i class="fa fa-home"></i>
{{ 'household.Household'|trans }}
@ -11,56 +11,60 @@
</h1>
</div>
<div class="col-sm">
<ul class="list-content fa-ul">
<li>
{% set address = household.currentAddress %}
<i class="fa fa-li fa-map-marker"></i>
{% if address is empty %}
<p class="chill-no-data-statement">{{ 'household.Household does not have any address currently'|trans }}</p>
{% else %}
{{ address|chill_entity_render_box({'multiline': false, 'with_valid_from': false}) }}
<div class="col-md-8 col-lg-9">
<div class="household-members my-3 pe-md-5 pe-xxl-0 justify-content-md-end">
{%- set members = household.getCurrentMembersOrdered() -%}
{%- if members|length > 0 -%}
<span class="current-members-explain" style="display: none;">
{{- 'household.Current household members'|trans }}
<i class="fa fa-fw fa-users" title="{{- 'household.Current household members'|trans }}"></i>
</span>
{%- for m in members|slice(0, 5) -%}
<span
class="badge-member{%- if m.holder %} holder{% endif -%}{%- if m.position.ordering >= 2 %} child{% endif -%}"
title="{{ m.position.label.fr }}">
{%- if m.holder %}
<span class="badge bg-chill-light-gray text-chill-gray">
{{ 'household.holder'|trans }}
</span>
{% endif -%}
{{- m.person|chill_entity_render_box({'addLink': false}) -}}
</span>
{%- endfor -%}
{% if members|length > 5 %}
<span class="current-members-more">
{{ 'household.and x other persons'|trans({'x': members|length-5}) }}
</span>
{% endif %}
</li>
</ul>
{%- endif -%}
</div>
</div>
</div>
</div>
</div>
<div id="header-household-details" class="header-details">
<div class="container-xxl">
<div class="row justify-content-md-right">
<div class="col-sm-10 members" id="banner-misc">
{%- set members = household.getCurrentMembersOrdered() -%}
{%- if members|length > 0 -%}
<span class="current-members-explain" style="display: none;">
{{- 'household.Current household members'|trans }}
<i class="fa fa-fw fa-users" title="{{- 'household.Current household members'|trans }}"></i>
<div class="contact col-md-12 ps-md-5 ps-xxl-0">
{% set address = household.currentAddress %}
{% if address is empty %}
<span class="chill-no-data-statement">
{{ 'household.Household does not have any address currently'|trans }}
</span>
{%- for m in members|slice(0, 5) -%}
<span
class="badge-member{%- if m.holder %} holder{% endif -%}{%- if m.position.ordering >= 2 %} child{% endif -%}"
title="{{ m.position.label.fr }}">
{%- if m.holder %}
<span class="badge bg-chill-light-gray text-chill-gray">
{{ 'household.holder'|trans }}
</span>
{% endif -%}
{{- m.person|chill_entity_render_box({'addLink': false}) -}}
</span>
{%- endfor -%}
{% if members|length > 5 %}
<span class="current-members-more">
{{ 'household.and x other persons'|trans({'x': members|length-5}) }}
</span>
{% endif %}
{%- endif -%}
{% else %}
<span class=" d-block d-sm-inline-block">
{{ address|chill_entity_render_box({
'render': 'inline', 'multiline': false, 'with_picto': true, 'with_delimiter': true
}) }}
</span>
{% endif %}
</div>
</div>
</div>
</div>

View File

@ -2,108 +2,65 @@
<div id="header-person-name" class="header-name">
<div class="container-xxl">
<div class="row">
<div class="col-md-6 ps-md-5 ps-xxl-0">
{{ person|chill_entity_render_box({
'render': 'label', 'addInfo': true, 'addAge': true, 'addId': true, 'hLevel': 1
}) }}
</div>
<div class="col-md-6">
<h1>
{% set gender =
(person.gender == "woman") ? 'female' :
(person.gender == "both") ? 'neuter' : 'male'
%}
<i class="fa fa-fw fa-{{ gender }}" title="{{ gender|capitalize|trans }}"></i>
{{ person|chill_entity_render_string }}
<span class="id-number" title="{{ 'Person'|trans ~ ' ' ~ person.id }}">
{{ person.id|upper }}
</span>
</h1>
{{ include('@ChillPerson/Person/banner_custom.html.twig') }}
</div>
<div class="col-md-auto ps-4 ps-md-2">
<ul class="list-content fa-ul my-2">
{% if person.email %}
<li>
<i class="fa fa-li fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ person.email }}" class="email" title="{{ 'Email'|trans }}">
{{ person.email }}
</a>
</li>
{% endif %}
{% if person.mobilenumber %}
<li>
<i class="fa fa-li fa-mobile"></i>
<a href="{{ 'tel:' ~ person.mobilenumber }}" class="phone mr-3" title="{{ 'Mobilenumber'|trans }}">
{{ person.mobilenumber|chill_format_phonenumber }}</a>
</li>
{% elseif person.phonenumber %}
<li>
<i class="fa fa-li fa-phone"></i>
<a href="{{ 'tel:' ~ person.phonenumber }}" class="phone mr-3" title="{{ 'Phonenumber'|trans }}">
{{ person.phonenumber|chill_format_phonenumber }}</a>
</li>
{% endif %}
</ul>
</div>
<div class="col-md ps-4 ps-md-2">
<ul class="list-content fa-ul">
{%- if person.currentHouseholdAddress is not empty -%}
<li>
<i class="fa fa-li fa-map-marker"></i>
{{ person.currentHouseholdAddress|chill_entity_render_box({'multiline': false, 'with_valid_from': false}) }}
</li>
{%- elseif person.lastAddress is not empty -%}
<li>
<i class="fa fa-li fa-map-marker"></i>
{{ person.lastAddress|chill_entity_render_box({'multiline': false, 'with_valid_from': false}) }}
</li>
{%- endif -%}
</ul>
</div>
</div>
</div>
</div>
<div id="header-person-details" class="header-details">
<div class="container-xxl">
<div class="row justify-content-between">
<div class="col-md-6 ps-4">
<span class="open_sansbold">
{{ 'Birthdate'|trans|upper }} &nbsp; :
</span>
{% if person.birthdate == null %}
{{ 'Unknown date of birth'|trans }}
{% else %}
{{ person.birthdate|format_date('short') }}
{% endif %}
<span class="age">
{{ person.age ~ ((person.age > 1) ? ' ans' : ' an') }}
</span>
<div class="col-md-12 ps-md-5 ps-xxl-0">
<div class="contact">
{% if person.phonenumber %}
<span class="phonenumber d-block d-sm-inline-block">
<i class="fa fa-fw fa-phone"></i>
<a href="{{ 'tel:' ~ person.phonenumber }}" class="phone mr-3" title="{{ 'Phonenumber'|trans }}">
{{ person.phonenumber|chill_format_phonenumber }}</a>
</span>
{% endif %}
{% if person.mobilenumber %}
<span class="mobilenumber d-block d-sm-inline-block">
<i class="fa fa-fw fa-mobile"></i>
<a href="{{ 'tel:' ~ person.mobilenumber }}" class="phone mr-3" title="{{ 'Mobilenumber'|trans }}">
{{ person.mobilenumber|chill_format_phonenumber }}</a>
</span>
{% endif %}
{% if person.email %}
<span class="email d-block d-sm-inline-block">
<i class="fa fa-fw fa-envelope-o"></i>
<a href="{{ 'mailto:' ~ person.email }}" class="email" title="{{ 'Email'|trans }}">
{{ person.email }}
</a>
</span>
{% endif %}
{% set address = null %}
{%- if person.currentHouseholdAddress is not empty -%}
{% set address = person.currentHouseholdAddress %}
{%- elseif person.lastAddress is not empty -%}
{% set address = person.lastAddress %}
{%- endif -%}
{%- if address is not null -%}
<span class=" d-block d-sm-inline-block">
{{ address|chill_entity_render_box({
'render': 'inline', 'multiline': false, 'with_picto': true, 'with_delimiter': true
}) }}
</span>
{%- endif -%}
</div>
</div>
{%- if chill_person.fields.nationality == 'visible' -%}
<div class="col-md-auto ps-4 ps-md-2">
<span class="open_sansbold">
{{ 'Nationality'|trans|upper}} &nbsp; :
</span>
{% if person.nationality is not null %}
{{ person.nationality.name|localize_translatable_string }}
{% else %}
{% trans %}Without nationality{% endtrans %}
{% endif %}
</div>
{%- endif -%}
{%- if chill_person.fields.spoken_languages == 'visible' -%}
<div class="col-md ps-4 ps-md-2 text-md-end text-start pe-4">
<span class="open_sansbold">
{{ 'Center'|trans|upper}} &nbsp; :
</span>
{{ person.center.name|upper }}
</div>
{%- endif -%}
</div>
</div>
</div>

View File

@ -0,0 +1,27 @@
{#
Overwrite this file to display client specific datas in custom area
#}
<div id="banner-person-custom" class="my-3 pe-md-5 pe-xxl-0 justify-content-end">
<div class="text-md-end mb-1">
{%- if chill_person.fields.nationality == 'visible' -%}
<span class="open_sansbold">
{{ 'Nationality'|trans|upper}} :
</span>
{% if person.nationality is not null %}
{{ person.nationality.name|localize_translatable_string }}
{% else %}
<span class="chill-no-data-statement">
{% trans %}Without nationality{% endtrans %}
</span>
{% endif %}
{%- endif -%}
</div>
<div class="text-md-end">
{%- if chill_person.fields.spoken_languages == 'visible' -%}
<span class="open_sansbold">
{{ 'Center'|trans|upper}} :
</span>
{{ person.center.name|upper }}
{%- endif -%}
</div>
</div>

View File

@ -1,7 +1,6 @@
{#
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
@ -37,8 +36,6 @@
{{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
{{ form_row(form.creation_date, { 'label' : 'Creation date'|trans }) }}
{{ form_rest(form) }}
<button class="btn btn-create" type="submit" alt="add a person">

View File

@ -68,14 +68,15 @@
<dd>{{ person|chill_entity_render_string }}</dd>
<dt>{{ 'Date of birth'|trans }}</dt>
<dd>{{ birthdate|format_date('long')|default( 'Unknown date of birth'|trans ) }}</dd>
{% if birthdate is empty %}
<dd>{{ 'Unknown date of birth'|trans }}</dd>
{% else %}
<dd>{{ birthdate|format_date('long') }}</dd>
{% endif %}
<dt>{{ 'Gender'|trans }}</dt>
<dd>{{ gender|trans }}</dd>
<dt>{{ 'Creation date'|trans }}</dt>
<dd>{{ creation_date|format_date('long') }}</dd>
{% if form.altNames is defined %}
{# mark as rendered #}
{{ form_widget(form.altNames) }}
@ -83,8 +84,13 @@
</dl>
{{ form_rest(form) }}
<button class="btn btn-submit" type="submit"><i class="fa fa-check"></i> {{ 'Confirm the creation'|trans }}</button>
<ul class="record_actions">
<li>
<button class="sc-button bt-create change-icon" type="submit"><i class="fa fa-check"></i> {{ 'Confirm the creation'|trans }}</button>
</li>
</ul>
{{ form_end(form) }}
</div>
</div>

View File

@ -39,21 +39,24 @@
<div class="flex-table list-with-period">
{% for person in persons %}
<div class="item-bloc">
<div class="item-row person">
<div class="item-col box-person">
<div>{{ person|chill_entity_render_box({'addLink': true}) }}</div>
<div>{{ 'Born the %date%'|transchoice(person.genderNumeric, { '%date%': person.birthdate|format_date("medium") }) }}</div>
<div>
{{ person|chill_entity_render_box({
'render': 'label', 'addLink': true, 'addInfo': true
}) }}
</div>
</div>
<div class="item-col box-where">
<ul class="list-content fa-ul">
<li><i class="fa fa-li fa-long-arrow-right"></i>
{{ person.center }}
</li>
<li>
{% if person.mobilenumber is not empty %}
<i class="fa fa-li fa-mobile"></i> <a href="{{ 'tel:' ~ person.mobilenumber }}">{{ person.mobilenumber|chill_format_phonenumber }}</a>
@ -66,7 +69,7 @@
{% endif %}
{% endif %}
</li>
<li>
<i class="fa fa-li fa-map-marker"></i>
{% if person.getLastAddress is not null %}
@ -75,7 +78,7 @@
<span class="chill-no-data-statement">{{ 'No address'|trans }}</span>
{% endif %}
</li>
</ul>
<ul class="record_actions">
<li>
@ -89,7 +92,7 @@
</li>
</ul>
</div>
</div>
{#- 'apps' is for AccompanyingPeriodParticipationS #}
@ -100,40 +103,40 @@
{%- set apps = apps|merge([app]) %}
{%- endif %}
{%- endfor %}
{% if apps|length > 0 %}
{% for app in apps %}
<div class="item-row periods">
<div class="header">
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}"
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': app.accompanyingPeriod.id }) }}"
class="btn btn-chill-green" title="{{ 'See accompanying period'|trans }}">
<i class="fa fa-random"></i>
</a>
<span>{{ 'Since %date%'|trans({'%date%': app.startDate|format_date('medium') }) }}</span>
{% if app.accompanyingPeriod.user is not null %}
<span class="user">
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
{{ app.accompanyingPeriod.user|chill_entity_render_box }}
</span>
{% endif %}
</div>
<div class="list-content">
{% for issue in app.accompanyingPeriod.socialIssues|slice(0,2) %}
<span>{{ issue|chill_entity_render_box }}</span>
{% endfor %}
{% if app.accompanyingPeriod.socialIssues|length > 2 %}
<span class="more">{{ 'and %number% other'|transchoice(app.accompanyingPeriod.socialIssues|length-2) }}</span>
{% endif %}
</div>
</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
@ -162,7 +165,7 @@
</li>
{% endif %}
</ul>
{% else %}
<ul class="record_actions">
<li>

View File

@ -16,8 +16,6 @@
#}
{% extends "@ChillPerson/Person/layout.html.twig" %}
{% import '@ChillMain/Address/macro.html.twig' as address %}
{% set activeRouteKey = 'chill_person_view' %}
{#
@ -171,7 +169,12 @@ This view should receive those arguments:
<dt>{{ 'Address'|trans }}</dt>
<dd>
{%- if person.lastAddress is not empty -%}
{{ address._render(person.lastAddress, {'has_no_address': true}) }}
{{ person.lastAddress|chill_entity_render_box({
'render': 'bloc',
'multiline': true,
'extended_infos': true,
'has_no_address': true
}) }}
<ul class="list-inline text-right mt-2">
<li class="list-inline-item">

View File

@ -1,7 +1,5 @@
{%- macro details(person, options) -%}
{% import '@ChillMain/Address/macro.html.twig' as address %}
<ul>
<li><b>{{ 'gender'|trans }}</b>:
{{ person.gender|trans }}</li>
@ -24,7 +22,9 @@
<li><b>{{ 'memo'|trans }}</b>:
{{ person.memo }}</li>
<li><b>{{ 'address'|trans }}</b>:
{%- if person.lastAddress is not empty -%}{{ address._render(person.lastAddress, {'with_valid_from': false}) }}{% endif %}</li>
{%- if person.lastAddress is not empty -%}
{{ person.lastAddress|chill_entity_render_box({'with_valid_from': false}) }}
{% endif %}</li>
<li><b>{{ 'spokenLanguages'|trans }}</b>:
{% for lang in person.spokenLanguages %}{{ lang.name|localize_translatable_string }}{% if not loop.last %},{% endif %}{% endfor %}</li>
<li><b>{{ 'contactInfo'|trans }}</b>:
@ -43,4 +43,4 @@
<li><b>{{ person.counters.nb_addresses }}</b> {{ (person.counters.nb_addresses > 1)? 'adresses' : 'adresse' }}</li>
</ul>
{% endmacro %}
{% endmacro %}

View File

@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Service\Import;
interface ChillImporter
{
public function import(iterable $dataset): bool;
}

View File

@ -0,0 +1,298 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Service\Import;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\SocialWork\Goal;
use Chill\PersonBundle\Entity\SocialWork\Result;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\PersonBundle\Repository\SocialWork\EvaluationRepository;
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Comparison;
use Doctrine\Persistence\ObjectRepository;
use Exception;
final class SocialWorkMetadata implements SocialWorkMetadataInterface
{
private SocialIssueRepository $socialIssueRepository;
private SocialActionRepository $socialActionRepository;
private GoalRepository $goalRepository;
private ResultRepository $resultRepository;
private EvaluationRepository $evaluationRepository;
private EntityManagerInterface $entityManager;
public function __construct(
SocialIssueRepository $socialIssueRepository,
SocialActionRepository $socialActionRepository,
GoalRepository $goalRepository,
ResultRepository $resultRepository,
EvaluationRepository $evaluationRepository,
EntityManagerInterface $entityManager
) {
$this->socialIssueRepository = $socialIssueRepository;
$this->socialActionRepository = $socialActionRepository;
$this->goalRepository = $goalRepository;
$this->resultRepository = $resultRepository;
$this->evaluationRepository = $evaluationRepository;
$this->entityManager = $entityManager;
}
public function import(iterable $dataset): bool
{
foreach ($dataset as $row) {
$this->import1(
array_map(
static fn (string $column): ?string => '' === $column ? null : $column,
array_map('trim', $row)
)
);
}
return true;
}
private function import1(array $row): void
{
// Structure:
// Index 0: SocialIssue.parent
// Index 1: SocialIssue
// Index 2: SocialAction.parent
// Index 3: SocialAction
// Index 4: Goal
// Index 5: Result
// Index 6: Evaluation
$socialIssue = $this->handleSocialIssue($row[0], $row[1]);
$socialAction = $this->handleSocialAction($row[2], $row[3], $socialIssue);
$goal = $this->handleGoal($row[4], $socialAction);
$result = $this->handleResult($row[5], $socialAction, $goal);
$eval = $this->handleEvaluation($row[6], $socialAction);
$this->entityManager->flush();
}
private function handleSocialIssue(?string $socialIssueTitle = null, ?string $socialIssueChildrenTitle = null): SocialIssue
{
if (null !== $socialIssueChildrenTitle) {
/** @var SocialIssue $socialIssueChildren */
$socialIssueChildren = $this->getOrCreateEntity($this->socialIssueRepository, 'title', ['fr' => $socialIssueChildrenTitle]);
$socialIssueChildren->setTitle(['fr' => $socialIssueChildrenTitle]);
$this->entityManager->persist($socialIssueChildren);
}
/** @var SocialIssue $socialIssue */
$socialIssue = $this->getOrCreateEntity($this->socialIssueRepository, 'title', ['fr' => $socialIssueTitle]);
$socialIssue->setTitle(['fr' => $socialIssueTitle]);
if (null !== $socialIssueChildrenTitle) {
$socialIssue->addChild($socialIssueChildren);
}
$this->entityManager->persist($socialIssue);
return null === $socialIssueChildrenTitle ? $socialIssue : $socialIssueChildren;
}
private function handleSocialAction(?string $socialActionTitle, ?string $socialActionChildrenTitle, SocialIssue $socialIssue): SocialAction
{
if (null !== $socialActionChildrenTitle) {
/** @var SocialAction $socialActionChildren */
$socialActionChildren = $this->getOrCreateEntity($this->socialActionRepository, 'title', ['fr' => $socialActionChildrenTitle]);
$socialActionChildren->setTitle(['fr' => $socialActionChildrenTitle]);
$this->entityManager->persist($socialActionChildren);
}
/** @var SocialIssue $socialIssue */
$socialAction = $this->getOrCreateEntity($this->socialActionRepository, 'title', ['fr' => $socialActionTitle]);
$socialAction->setTitle(['fr' => $socialActionTitle]);
if (null !== $socialActionChildrenTitle) {
$socialActionChildren->setIssue($socialIssue);
$this->entityManager->persist($socialActionChildren);
$socialAction->addChild($socialActionChildren);
} else {
$socialAction->setIssue($socialIssue);
}
$this->entityManager->persist($socialAction);
return null === $socialActionChildrenTitle ? $socialAction : $socialActionChildren;
}
private function handleGoal(?string $goalTitle = null, ?SocialAction $socialAction = null): ?Goal
{
if (null === $goalTitle) {
return null;
}
/** @var Goal $goal */
$goal = $this->getOrCreateEntity($this->goalRepository, 'title', ['fr' => $goalTitle]);
$goal->setTitle(['fr' => $goalTitle]);
if (null !== $socialAction) {
$socialAction->addGoal($goal);
$goal->addSocialAction($socialAction);
$this->entityManager->persist($socialAction);
}
$this->entityManager->persist($goal);
return $goal;
}
private function handleResult(?string $resultTitle = null, ?SocialAction $socialAction = null, ?Goal $goal = null): ?Result
{
if (null === $resultTitle) {
return null;
}
/** @var Result $result */
$result = $this->getOrCreateEntity($this->resultRepository, 'title', ['fr' => $resultTitle]);
$result->setTitle(['fr' => $resultTitle]);
if (null !== $goal) {
$result->addGoal($goal);
$goal->addResult($result);
$this->entityManager->persist($goal);
} else {
$result->addSocialAction($socialAction);
}
$result->addSocialAction($socialAction);
$socialAction->addResult($result);
$this->entityManager->persist($result);
$this->entityManager->persist($socialAction);
return $result;
}
private function handleEvaluation(?string $evaluationTitle, SocialAction $socialAction): ?Evaluation
{
if (null === $evaluationTitle) {
return null;
}
/** @var Evaluation $eval */
$eval = $this->getOrCreateEntity($this->evaluationRepository, 'title', ['fr' => $evaluationTitle]);
$eval->setTitle(['fr' => $evaluationTitle]);
$eval->setSocialAction($socialAction);
$this->entityManager->persist($eval);
return $eval;
}
private function findByJson(ObjectRepository $repository, string $field, array $jsonCriterias): array
{
$qb = $this
->entityManager
->createQueryBuilder()
->select('s')
->from($repository->getClassName(), 's');
$expr = $qb->expr();
$temporaryJsonCriterias = $jsonParameters = [];
foreach ($jsonCriterias as $key => $value) {
$temporaryJsonCriterias[] = [$field, $key, $value, sprintf(':placeholder_%s_%s', $field, $key)];
}
$jsonParameters = array_reduce(
$temporaryJsonCriterias,
static function (array $carry, array $row): array
{
[,, $value, $placeholder] = $row;
return array_merge(
$carry,
[
$placeholder => sprintf('"%s"', $value),
]
);
},
[]
);
$jsonPredicates = array_map(
static function (array $row) use ($expr): Comparison
{
[$field, $key,, $placeholder] = $row;
$left = sprintf(
"GET_JSON_FIELD_BY_KEY(s.%s, '%s')",
$field,
$key
);
return $expr
->eq(
$left,
$placeholder
);
},
$temporaryJsonCriterias
);
$query = $qb
->select('s')
->where(...$jsonPredicates)
->setParameters($jsonParameters)
->getQuery();
return $query->getResult();
}
private function getOrCreateEntity(ObjectRepository $repository, string $field, array $jsonCriterias = [])
{
$results = $this
->findByJson(
$repository,
$field,
$jsonCriterias
);
switch (true) {
case count($results) === 0:
$entity = $repository->getClassName();
$entity = new $entity();
break;
case count($results) === 1;
$entity = current($results);
break;
case count($results) > 1;
throw new Exception(
sprintf(
'More than one entity(%s) found.',
$repository->getClassName()
)
);
}
return $entity;
}
}

View File

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace Chill\PersonBundle\Service\Import;
interface SocialWorkMetadataInterface extends ChillImporter
{
}

View File

@ -2,7 +2,7 @@
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS,
* Copyright (C) 2014-2019, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@ -25,7 +25,6 @@ use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Symfony\Component\Templating\EngineInterface;
/**
* Render a Person
*
@ -35,7 +34,7 @@ class PersonRender extends AbstractChillEntityRender
private ConfigPersonAltNamesHelper $configAltNamesHelper;
private EngineInterface $engine;
public function __construct(
ConfigPersonAltNamesHelper $configAltNamesHelper,
EngineInterface $engine
@ -43,26 +42,38 @@ class PersonRender extends AbstractChillEntityRender
$this->configAltNamesHelper = $configAltNamesHelper;
$this->engine = $engine;
}
/**
*
*
* @param Person $person
* @param array $options
* @return string
*/
public function renderBox($person, array $options): string
{
return $this->engine->render('@ChillPerson/Entity/person.html.twig',
[
$params = [
'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
'addLink' => $options['addLink'] ?? false,
'addEntity' => $options['addEntity'] ?? false,
'addId' => $options['addId'] ?? false,
'addInfo' => $options['addInfo'] ?? false,
'addAge' => $options['addAge'] ?? false,
'hLevel' => $options['hLevel'] ?? 3,
'customButtons' => $options['customButtons'] ?? [],
];
return
$this->getDefaultOpeningBox('person') .
$this->engine->render('@ChillPerson/Entity/person.html.twig', [
'person' => $person,
'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
'addLink' => $options['addLink'] ?? false
]
);
'render' => $options['render'] ?? 'raw',
'options' => $params
]) .
$this->getDefaultClosingBox();
}
/**
*
*
* @param Person $person
* @param array $options
* @return string
@ -73,10 +84,10 @@ class PersonRender extends AbstractChillEntityRender
.$this->addAltNames($person, false);
}
protected function addAltNames(Person $person, bool $addSpan)
protected function addAltNames(Person $person, bool $addSpan): string
{
$str = '';
if ($this->configAltNamesHelper->hasAltNames()) {
$altNames = $this->configAltNamesHelper->getChoices();
$isFirst = true;
@ -91,21 +102,21 @@ class PersonRender extends AbstractChillEntityRender
$str.= " ";
}
if ($addSpan) {
$str .= '<span class="chill-entity__person__alt-name chill-entity__person__altname--'.$altName->getKey().'">';
$str .= '<span class="altname altname-'.$altName->getKey().'">';
}
$str .= $altName->getLabel();
if ($addSpan) {
$str .= "</span>";
}
}
}
if (!$isFirst) {
$str .= ")";
}
}
return $str;
}

View File

@ -152,7 +152,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
* with : dateClosing: 2015-02-01
* with : the last closing motive in list
* Then the response should redirect to period view
* And the next page should have a `.error` element present in page
* And the next page should have a `.alert-danger` element present in page
*
* @todo
*/
@ -174,7 +174,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
'/fr/person/'.$this->person->getId().'/accompanying-period'),
'the server redirects to /accompanying-period page');
$this->assertGreaterThan(0, $this->client->followRedirect()
->filter('.success')->count(),
->filter('.alert-success')->count(),
"a 'success' element is shown");
}
@ -186,7 +186,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
* with : dateClosing: 2014-01-01
* with : the last closing motive in list
* Then the response should redirect to period view
* And the next page should have a `.error` element present in page
* And the next page should have a `.alert-danger` element present in page
*
* @todo
*/
@ -207,8 +207,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stays on the /close page');
$this->assertGreaterThan(0, $crawlerResponse
->filter('.error')->count(),
"an '.error' element is shown");
->filter('.alert-danger')->count(),
"an '.alert-danger' element is shown");
}
/**
@ -240,7 +240,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
'/fr/person/'.$this->person->getId().'/accompanying-period'),
'the server redirects to /accompanying-period page');
$this->assertGreaterThan(0, $this->client->followRedirect()
->filter('.success')->count(),
->filter('.alert-success')->count(),
"a 'success' element is shown");
}
@ -275,7 +275,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawler->filter('.error')->count(),
$this->assertGreaterThan(0, $crawler->filter('.alert-danger')->count(),
"an 'error' element is shown");
}
@ -310,7 +310,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawler->filter('.error')->count(),
$this->assertGreaterThan(0, $crawler->filter('.alert-danger')->count(),
"an 'error' element is shown");
}
@ -351,7 +351,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawlerResponse->filter('.error')->count(),
$this->assertGreaterThan(0, $crawlerResponse->filter('.alert-danger')->count(),
"an 'error' element is shown");
}
@ -382,7 +382,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawler->filter('.error')->count(),
$this->assertGreaterThan(0, $crawler->filter('.alert-danger')->count(),
"an 'error' element is shown");
}
@ -424,7 +424,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawlerResponse->filter('.error')->count(),
$this->assertGreaterThan(0, $crawlerResponse->filter('.alert-danger')->count(),
"an 'error' element is shown");
}
@ -465,7 +465,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the server stay on form page');
$this->assertGreaterThan(0, $crawlerResponse->filter('.error')->count(),
$this->assertGreaterThan(0, $crawlerResponse->filter('.alert-danger')->count(),
"an 'error' element is shown");
}

View File

@ -93,8 +93,6 @@ class PersonControllerCreateTest extends WebTestCase
'The page contains a "gender" input');
$this->assertTrue($form->has(self::BIRTHDATE_INPUT),
'The page has a "date of birth" input');
$this->assertTrue($form->has(self::CREATEDATE_INPUT),
'The page contains a "creation date" input');
$genderType = $form->get(self::GENDER_INPUT);
$this->assertEquals('radio', $genderType->getType(),
@ -107,10 +105,6 @@ class PersonControllerCreateTest extends WebTestCase
'gender has "femme" option');
$this->assertFalse($genderType->hasValue(), 'The gender input is not checked');
$today = new \DateTime();
$this->assertEquals($today->format('d-m-Y'), $form->get(self::CREATEDATE_INPUT)
->getValue(), 'The creation date input has the current date by default');
return $form;
}

View File

@ -102,7 +102,6 @@ class PersonControllerUpdateTest extends WebTestCase
public function testHiddenFielsArePresent()
{
$crawler = $this->client->request('GET', $this->editUrl);
$configurables = array('placeOfBirth', 'phonenumber', 'email',
'countryOfBirth', 'nationality', 'spokenLanguages', 'maritalStatus');
$form = $crawler->selectButton('Enregistrer')->form(); //;
@ -190,7 +189,7 @@ class PersonControllerUpdateTest extends WebTestCase
'the value '.$field.' is updated in db');
$crawler = $this->client->followRedirect();
$this->assertGreaterThan(0, $crawler->filter('.success')->count(),
$this->assertGreaterThan(0, $crawler->filter('.alert-success')->count(),
'a element .success is shown');
if($field == 'birthdate' or $field == 'memo' or $field == 'countryOfBirth' or $field == 'nationality'
@ -245,7 +244,7 @@ class PersonControllerUpdateTest extends WebTestCase
$this->assertFalse($this->client->getResponse()->isRedirect(),
'the page is not redirected to /general');
$this->assertGreaterThan(0, $crawler->filter('.error')->count(),
$this->assertGreaterThan(0, $crawler->filter('.alert-danger')->count(),
'a element .error is shown');
}

View File

@ -45,11 +45,12 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testGetCurrentAccompanyingPeriod()
{
$d = new \DateTime('yesterday');
$p = new Person($d);
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$period = $p->getCurrentAccompanyingPeriod();
$this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
$this->assertInstanceOf(AccompanyingPeriod::class, $period);
$this->assertTrue($period->isOpen());
$this->assertEquals($d, $period->getOpeningDate());
@ -67,7 +68,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
{
$d = new \DateTime("2013/2/1");
$p = new Person($d);
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
@ -93,7 +95,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testAccompanyingPeriodOrderSameDateOpening() {
$d = new \DateTime("2013/2/1");
$p = new Person($d);
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$g = new \DateTime("2013/4/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
@ -120,7 +123,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testDateCoveringWithCoveringAccompanyingPeriod() {
$d = new \DateTime("2013/2/1");
$p = new Person($d);
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
@ -145,7 +149,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testNotOpenAFileReOpenedLater() {
$d = new \DateTime("2013/2/1");
$p = new Person($d);
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new \DateTime("2013/3/1");
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);

View File

@ -20,9 +20,11 @@
namespace Chill\PersonBundle\Tests\Timeline;
use Symfony\Bundle\SecurityBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\EntityManagerInterface;
use Chill\MainBundle\Test\PrepareClientTrait;
/**
* This class tests entries are shown for closing and opening
@ -31,22 +33,20 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
* @author Julien Fastré <julien.fastre@champs-libres.coop>
* @author Champs Libres <info@champs-libres.coop>
*/
class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controller\AccompanyingPeriodControllerTest
class TimelineAccompanyingPeriodTest extends WebTestCase
{
public function testEntriesAreShown()
use PrepareClientTrait;
/**
* @dataProvider provideDataPersonWithAccompanyingPeriod
*/
public function testEntriesAreShown($personId)
{
$this->generatePeriods(array(
[
'openingDate' => '2014-01-01',
'closingDate' => '2014-12-31',
'closingMotive' => $this->getRandomClosingMotive()
]
));
$client = $this->getClientAuthenticated();
$crawler = $client->request('GET', "/en/person/{$personId}/timeline");
$crawler = $this->client->request('GET', '/en/person/'
.$this->person->getId().'/timeline');
$this->assertTrue($this->client->getResponse()->isSuccessful(),
$this->assertTrue($client->getResponse()->isSuccessful(),
"the timeline page loads sucessfully");
$this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
"the timeline page contains multiple div inside a .timeline element");
@ -57,5 +57,34 @@ class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controlle
$crawler->Filter('.timeline')->text(),
"the text 'Une période d'accompagnement a été fermée' is present");
}
public function provideDataPersonWithAccompanyingPeriod()
{
self::bootKernel();
$qb = self::$container->get(EntityManagerInterface::class)
->createQueryBuilder()
;
$personIds = $qb
->from(Person::class, 'p')
->join('p.accompanyingPeriodParticipations', 'part')
->join('part.accompanyingPeriod', 'period')
->join('p.center', 'center')
->select('p.id')
->where($qb->expr()->isNotNull('period.closingDate'))
->andWhere($qb->expr()->eq('center.name', ':center'))
->setParameter('center', 'Center A')
->setMaxResults(1000)
->getQuery()
->getResult()
;
\shuffle($personIds);
yield [ \array_pop($personIds)['id'] ];
yield [ \array_pop($personIds)['id'] ];
yield [ \array_pop($personIds)['id'] ];
}
}

View File

@ -6,12 +6,24 @@ services:
autowire: true
autoconfigure: true
Chill\PersonBundle\Service\:
resource: '../Service/'
autowire: true
autoconfigure: true
Chill\PersonBundle\Serializer\Normalizer\:
resource: '../Serializer/Normalizer/'
autowire: true
tags:
- { name: 'serializer.normalizer', priority: 64 }
Chill\PersonBundle\Command\:
resource: '../Command/'
autowire: true
autoconfigure: true
tags:
- { name: console.command }
chill.person.form.type.select2maritalstatus:
class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType
arguments:
@ -49,7 +61,7 @@ services:
tags:
- { name: security.voter }
- { name: chill.role }
chill.person.birthdate_validation:
class: Chill\PersonBundle\Validator\Constraints\BirthdateValidator
arguments:

View File

@ -1,19 +0,0 @@
services:
Chill\PersonBundle\Command\ChillPersonMoveCommand:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$mover: '@Chill\PersonBundle\Actions\Remove\PersonMove'
$chillLogger: '@chill.main.logger'
tags:
- { name: console.command }
Chill\PersonBundle\Command\ImportPeopleFromCSVCommand:
arguments:
$logger: '@logger'
$helper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$em: '@Doctrine\ORM\EntityManagerInterface'
$customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$formFactory: '@form.factory'
tags:
- { name: console.command }

View File

@ -0,0 +1,3 @@
services:
Chill\PersonBundle\Notification\AccompanyingPeriodNotificationRenderer:
autowire: true

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210623142046 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_action ALTER defaultnotificationdelay DROP NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_action ALTER defaultNotificationDelay SET NOT NULL');
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210624131722 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ALTER delay DROP NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ALTER delay SET NOT NULL');
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210624131723 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ALTER notificationdelay DROP NOT NULL');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_person_social_work_evaluation ALTER notificationdelay SET NOT NULL');
}
}

Some files were not shown because too many files have changed in this diff Show More