diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index dee5dce8d..f052c5885 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -210,10 +210,20 @@ class ListActivity implements ListInterface, GroupedExportInterface $qb ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'person') - ->join('actperson.center', 'actcenter') - ->andWhere('actcenter IN (:authorized_centers)') - ->setParameter('authorized_centers', $centers); + ->join('activity.person', 'actperson') + ->join('actperson.centerHistory', 'centerHistory'); + + $qb->where( + $qb->expr()->andX( + $qb->expr()->lte('centerHistory.startDate', 'activity.date'), + $qb->expr()->orX( + $qb->expr()->isNull('centerHistory.endDate'), + $qb->expr()->gt('centerHistory.endDate', 'activity.date') + ) + ) + ) + ->andWhere($qb->expr()->in('centerHistory.center', ':centers')) + ->setParameter('centers', $centers); foreach ($this->fields as $f) { if (in_array($f, $data['fields'], true)) { @@ -224,17 +234,17 @@ class ListActivity implements ListInterface, GroupedExportInterface break; case 'person_firstname': - $qb->addSelect('person.firstName AS person_firstname'); + $qb->addSelect('actperson.firstName AS person_firstname'); break; case 'person_lastname': - $qb->addSelect('person.lastName AS person_lastname'); + $qb->addSelect('actperson.lastName AS person_lastname'); break; case 'person_id': - $qb->addSelect('person.id AS person_id'); + $qb->addSelect('actperson.id AS person_id'); break; @@ -251,7 +261,7 @@ class ListActivity implements ListInterface, GroupedExportInterface break; case 'type_name': - $qb->join('activity.type', 'type'); + $qb->join('activity.activityType', 'type'); $qb->addSelect('type.name AS type_name'); break; @@ -263,6 +273,11 @@ class ListActivity implements ListInterface, GroupedExportInterface break; + case 'attendee': + $qb->addSelect('IDENTITY(activity.attendee) AS attendee'); + + break; + default: $qb->addSelect(sprintf('activity.%s as %s', $f, $f)); diff --git a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php index 4084bfb4f..6b77e5b2b 100644 --- a/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php +++ b/src/Bundle/ChillMainBundle/Export/Formatter/SpreadSheetFormatter.php @@ -445,6 +445,8 @@ class SpreadSheetFormatter implements FormatterInterface $this->initializeCache($key); } + $value = null === $value ? '' : $value; + return call_user_func($this->cacheDisplayableResult[$key], $value); }