mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
count linked objects in merge person side panel
This commit is contained in:
parent
03ef68dc36
commit
d81fc881af
@ -16,6 +16,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||||
|
use Chill\EventBundle\Entity\Participation;
|
||||||
|
use Chill\TaskBundle\Entity\SingleTask;
|
||||||
|
|
||||||
class PersonDuplicateController extends Controller
|
class PersonDuplicateController extends Controller
|
||||||
{
|
{
|
||||||
@ -91,6 +95,9 @@ class PersonDuplicateController extends Controller
|
|||||||
$person1 = $this->_getPerson($person1_id);
|
$person1 = $this->_getPerson($person1_id);
|
||||||
$person2 = $this->_getPerson($person2_id);
|
$person2 = $this->_getPerson($person2_id);
|
||||||
|
|
||||||
|
$person1->counters = $this->_getCounters($person1_id);
|
||||||
|
$person2->counters = $this->_getCounters($person2_id);
|
||||||
|
|
||||||
if ($person1 === null) {
|
if ($person1 === null) {
|
||||||
throw $this->createNotFoundException("Person with id $person1_id not"
|
throw $this->createNotFoundException("Person with id $person1_id not"
|
||||||
. " found on this server");
|
. " found on this server");
|
||||||
@ -257,4 +264,23 @@ class PersonDuplicateController extends Controller
|
|||||||
|
|
||||||
return [$person1, $person2];
|
return [$person1, $person2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _getCounters($id): ?array
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$nb_activity = $em->getRepository(Activity::class)->findBy(['person'=>$id]);
|
||||||
|
$nb_document = $em->getRepository(PersonDocument::class)->findBy(['person'=>$id]);
|
||||||
|
$nb_event = $em->getRepository(Participation::class)->findBy(['person'=>$id]);
|
||||||
|
$nb_task = $em->getRepository(SingleTask::class)->countByParameters(['person'=>$id]);
|
||||||
|
$person = $em->getRepository(Person::class)->findOneBy(['id'=>$id]);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'nb_activity' => count($nb_activity),
|
||||||
|
'nb_document' => count($nb_document),
|
||||||
|
'nb_event' => count($nb_event),
|
||||||
|
'nb_task' => $nb_task,
|
||||||
|
'nb_addresses' => count($person->getAddresses())
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,12 @@
|
|||||||
|
|
||||||
{%- macro links(person, options) -%}
|
{%- macro links(person, options) -%}
|
||||||
<ul>
|
<ul>
|
||||||
{# TODO suivre toutes les jointures #}
|
|
||||||
<li><b>3</b> activités</li>
|
<li><b>{{ person.counters.nb_activity }}</b> {{ (person.counters.nb_activity > 1)? 'activités' : 'activité' }}</li>
|
||||||
<li><b>5</b> tâches</li>
|
<li><b>{{ person.counters.nb_task }}</b> {{ (person.counters.nb_task > 1)? 'tâches' : 'tâche' }}</li>
|
||||||
<li><b>2</b> rapports</li>
|
<li><b>{{ person.counters.nb_document }}</b> {{ (person.counters.nb_document > 1)? 'documents' : 'document' }}</li>
|
||||||
<li><b>3</b> événements</li>
|
<li><b>{{ person.counters.nb_event }}</b> {{ (person.counters.nb_event > 1)? 'événements' : 'événement' }}</li>
|
||||||
<li><b>6</b> documents</li>
|
<li><b>{{ person.counters.nb_addresses }}</b> {{ (person.counters.nb_addresses > 1)? 'documents' : 'document' }}</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
Loading…
x
Reference in New Issue
Block a user