Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
51783b50
Commit
51783b50
authored
May 30, 2024
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '6342-territory-filter-in-flux-menus' into ssa-gironde
parents
87c7feeb
0793b760
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
FluxAdmin.php
src/Admin/FluxAdmin.php
+31
-0
FluxRepository.php
src/Repository/FluxRepository.php
+22
-0
No files found.
src/Admin/FluxAdmin.php
View file @
51783b50
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Admin
;
namespace
App\Admin
;
use
App\Entity\Flux
;
use
App\Entity\Flux
;
use
App\Entity\Subterritory
;
use
Sonata\AdminBundle\Admin\AbstractAdmin
;
use
Sonata\AdminBundle\Admin\AbstractAdmin
;
use
Sonata\AdminBundle\Datagrid\DatagridMapper
;
use
Sonata\AdminBundle\Datagrid\DatagridMapper
;
use
Sonata\AdminBundle\Datagrid\ListMapper
;
use
Sonata\AdminBundle\Datagrid\ListMapper
;
...
@@ -11,6 +12,7 @@ use Sonata\Form\Type\DateTimeRangePickerType;
...
@@ -11,6 +12,7 @@ use Sonata\Form\Type\DateTimeRangePickerType;
use
Symfony\Component\Form\Extension\Core\Type\ChoiceType
as
SChoiceType
;
use
Symfony\Component\Form\Extension\Core\Type\ChoiceType
as
SChoiceType
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Translation\TranslatorInterface
;
use
Symfony\Component\Translation\TranslatorInterface
;
use
Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter
;
/**
/**
* Administration des Flux.
* Administration des Flux.
...
@@ -172,6 +174,35 @@ class FluxAdmin extends AbstractAdmin
...
@@ -172,6 +174,35 @@ class FluxAdmin extends AbstractAdmin
'label'
=>
'Date'
,
'label'
=>
'Date'
,
])
])
;
;
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'household_based_allowance'
))
{
$datagridMapper
->
add
(
'territory'
,
CallbackFilter
::
class
,
[
'callback'
=>
[
$this
,
'getTerritoryFilter'
],
'field_type'
=>
SChoiceType
::
class
,
'label'
=>
'Territoire de l\'adhérent'
,
'show_filter'
=>
true
,
'advanced_filter'
=>
false
,
'field_options'
=>
[
'choice_label'
=>
'name'
,
'choices'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getRepository
(
Subterritory
::
class
)
->
findAll
()
],
]);
}
}
public
function
getTerritoryFilter
(
$queryBuilder
,
$alias
,
$field
,
$value
)
{
if
(
!
$value
[
'value'
])
{
return
;
}
$flux_ids
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getRepository
(
Flux
::
class
)
->
getQuerybyAdherentSubterritory
(
$value
[
'value'
]);
$queryBuilder
->
andWhere
(
$queryBuilder
->
expr
()
->
in
(
$alias
.
'.id'
,
':ids'
))
->
setParameter
(
'ids'
,
$flux_ids
);
return
true
;
}
}
public
function
getTemplate
(
$name
)
public
function
getTemplate
(
$name
)
...
...
src/Repository/FluxRepository.php
View file @
51783b50
...
@@ -422,4 +422,26 @@ class FluxRepository extends ServiceEntityRepository
...
@@ -422,4 +422,26 @@ class FluxRepository extends ServiceEntityRepository
return
$results
;
return
$results
;
}
}
/**
* @param String $subterritory_name the subterritory name to look for
*
* @return
*/
public
function
getQuerybyAdherentSubterritory
(
$subterritory_name
)
{
$sqlQuery
=
"SELECT f.id
FROM
{
$this
->
tableName
}
f
LEFT JOIN adherent a ON (a.id = f.adherent_id OR a.id = f.adherent_dest_id)
LEFT JOIN geoloc g ON a.geoloc_id = g.id
LEFT JOIN subterritory st ON g.subterritory_id = st.id
WHERE st.name = :subterritory_name"
;
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
->
bindValue
(
':subterritory_name'
,
$subterritory_name
);
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
return
$results
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment