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
9ccbc5eb
Commit
9ccbc5eb
authored
Sep 18, 2023
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add relevant tav data in admin adherents export
parent
2a3af91b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
14 deletions
+52
-14
AdherentAdmin.php
src/Admin/AdherentAdmin.php
+4
-3
PrestataireAdmin.php
src/Admin/PrestataireAdmin.php
+4
-3
CustomDoctrineORMQuerySourceIterator.php
src/Exporter/CustomDoctrineORMQuerySourceIterator.php
+44
-8
No files found.
src/Admin/AdherentAdmin.php
View file @
9ccbc5eb
...
...
@@ -585,10 +585,11 @@ class AdherentAdmin extends AbstractAdmin
}
}
$em
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$cotisationUtils
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'app.utils.cotisations'
);
$container
=
$this
->
getConfigurationPool
()
->
getContainer
();
$em
=
$container
->
get
(
'doctrine'
)
->
getManager
();
$cotisationUtils
=
$container
->
get
(
'app.utils.cotisations'
);
$iterator
=
new
CustomDoctrineORMQuerySourceIterator
(
$cotisationUtils
,
$em
,
$query
,
$fields
);
$iterator
=
new
CustomDoctrineORMQuerySourceIterator
(
$cotisationUtils
,
$em
,
$
container
,
$
query
,
$fields
);
$iterator
->
setDateTimeFormat
(
'd/m/Y H:i:s'
);
//change this to suit your needs
return
$iterator
;
...
...
src/Admin/PrestataireAdmin.php
View file @
9ccbc5eb
...
...
@@ -875,10 +875,11 @@ class PrestataireAdmin extends AbstractAdmin
}
}
$em
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$cotisationUtils
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'app.utils.cotisations'
);
$container
=
$this
->
getConfigurationPool
()
->
getContainer
();
$em
=
$container
->
get
(
'doctrine'
)
->
getManager
();
$cotisationUtils
=
$container
->
get
(
'app.utils.cotisations'
);
$iterator
=
new
CustomDoctrineORMQuerySourceIterator
(
$cotisationUtils
,
$em
,
$query
,
$fields
);
$iterator
=
new
CustomDoctrineORMQuerySourceIterator
(
$cotisationUtils
,
$em
,
$
container
,
$
query
,
$fields
);
$iterator
->
setDateTimeFormat
(
'd/m/Y H:i:s'
);
//change this to suit your needs
return
$iterator
;
...
...
src/Exporter/CustomDoctrineORMQuerySourceIterator.php
View file @
9ccbc5eb
...
...
@@ -15,11 +15,14 @@ namespace App\Exporter;
use
App\Entity\Adherent
;
use
App\Entity\Prestataire
;
use
App\Entity\Flux
;
use
App\Entity\GlobalParameter
;
use
App\Utils\CotisationUtils
;
use
Doctrine\ORM\EntityManagerInterface
;
use
Doctrine\ORM\Query
;
use
Sonata\Exporter\Source\AbstractPropertySourceIterator
;
use
Sonata\Exporter\Source\SourceIteratorInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* @final since sonata-project/exporter 2.4.
...
...
@@ -32,14 +35,22 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato
protected
$query
;
protected
$em
;
protected
$cotisationUtils
;
protected
$container
;
/**
* @param array<string> $fields Fields to export
*/
public
function
__construct
(
CotisationUtils
$cotisationUtils
,
EntityManagerInterface
$em
,
Query
$query
,
array
$fields
,
string
$dateTimeFormat
=
'r'
)
{
public
function
__construct
(
CotisationUtils
$cotisationUtils
,
EntityManagerInterface
$em
,
ContainerInterface
$container
,
Query
$query
,
array
$fields
,
string
$dateTimeFormat
=
'r'
)
{
$this
->
em
=
$em
;
$this
->
cotisationUtils
=
$cotisationUtils
;
$this
->
container
=
$container
;
$this
->
query
=
clone
$query
;
$this
->
query
->
setParameters
(
$query
->
getParameters
());
foreach
(
$query
->
getHints
()
as
$name
=>
$value
)
{
...
...
@@ -74,12 +85,37 @@ class CustomDoctrineORMQuerySourceIterator extends AbstractPropertySourceIterato
}
elseif
(
!
empty
(
$data
[
'Id'
])
&&
!
empty
(
$data
[
'Email'
]))
{
//adherent
$adherent
=
$this
->
em
->
getRepository
(
Adherent
::
class
)
->
findOneById
(
$data
[
'Id'
]);
$cotisEnd
=
$this
->
cotisationUtils
->
isCotisationValidForAdherent
(
$adherent
);
$cotisEnd
=
is_string
(
$cotisEnd
)
?
new
\DateTime
(
$cotisEnd
)
:
$cotisEnd
;
$data
[
'Cotisation à jour'
]
=
false
==
$cotisEnd
?
''
:
(
$cotisEnd
->
format
(
'd/m/Y'
));
$firstCotis
=
$this
->
cotisationUtils
->
getFirstCotisationForAdherent
(
$adherent
);
$firstCotis
=
is_string
(
$firstCotis
)
?
new
\DateTime
(
$firstCotis
)
:
$firstCotis
;
$data
[
'Première Cotisation'
]
=
false
==
$firstCotis
?
''
:
(
$firstCotis
->
format
(
'd/m/Y'
));
if
(
$this
->
container
->
getParameter
(
'tav_env'
))
{
// Last TAV cotisation
$cotisations
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getLastTavCotisation
(
$adherent
);
if
(
count
(
$cotisations
)
>
0
)
{
$cotisDate
=
date
(
"d/m/Y H:i:s"
,
strtotime
(
$cotisations
[
0
][
"created_at"
]));
$data
[
'Dernière Cotisation'
]
=
$cotisDate
;
}
else
{
$data
[
'Dernière Cotisation'
]
=
"Aucune"
;
}
// Current emlc balance
$balance
=
$adherent
->
getEmlcAccount
()
->
getBalance
();
$mlc
=
$this
->
em
->
getRepository
(
GlobalParameter
::
class
)
->
val
(
GlobalParameter
::
MLC_SYMBOL
);
$data
[
'Solde'
]
=
$balance
.
" "
.
$mlc
;
// Profil de cotisation
$cotisationProfile
=
$adherent
->
getProfilDeCotisation
();
if
(
!
is_null
(
$cotisationProfile
)
)
{
$data
[
'Profil de cotisation'
]
=
$cotisationProfile
;
}
else
{
$data
[
'Profil de cotisation'
]
=
"Aucun profil assigné"
;
}
}
else
{
$cotisEnd
=
$this
->
cotisationUtils
->
isCotisationValidForAdherent
(
$adherent
);
$cotisEnd
=
is_string
(
$cotisEnd
)
?
new
\DateTime
(
$cotisEnd
)
:
$cotisEnd
;
$data
[
'Cotisation à jour'
]
=
false
==
$cotisEnd
?
''
:
(
$cotisEnd
->
format
(
'd/m/Y'
));
$firstCotis
=
$this
->
cotisationUtils
->
getFirstCotisationForAdherent
(
$adherent
);
$firstCotis
=
is_string
(
$firstCotis
)
?
new
\DateTime
(
$firstCotis
)
:
$firstCotis
;
$data
[
'Première Cotisation'
]
=
false
==
$firstCotis
?
''
:
(
$firstCotis
->
format
(
'd/m/Y'
));
}
$adminRoles
=
''
;
if
(
!
empty
(
$adherent
->
getUser
()))
{
foreach
(
$adherent
->
getUser
()
->
getPossiblegroups
()
as
$group
)
{
...
...
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