mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
[export] add an export 'count activity' and first filters
- reason aggregator - reason filter - count activity export
This commit is contained in:
77
Export/Export/CountActivity.php
Normal file
77
Export/Export/CountActivity.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 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\ActivityBundle\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Export\ExportInterface;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CountActivity implements ExportInterface
|
||||
{
|
||||
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
throw new \LogicException('This export does not requires a form.');
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Count activities";
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Count activities";
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'activity';
|
||||
}
|
||||
|
||||
public function initiateQuery(QueryBuilder $qb, array $requiredModifiers)
|
||||
{
|
||||
$qb->select('COUNT(activity.id) as export_count_activity')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
;
|
||||
|
||||
if (in_array('person', $requiredModifiers)) {
|
||||
$qb->join('activity.person', 'person');
|
||||
}
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function hasForm()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function supportsModifiers()
|
||||
{
|
||||
return array('person', 'activity');
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user