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
0
Merge Requests
0
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
fd30b467
Commit
fd30b467
authored
Dec 20, 2022
by
Yvon Kerdoncuff
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '4125-cotisation-hidden' into 'develop'
4125-cotisation-hidden See merge request cooperatic/kohinos-tav!19
parents
928a32a7
45fe5e42
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
229 additions
and
75 deletions
+229
-75
services.yaml
config/services.yaml
+8
-2
AdherentAdmin.php
src/Admin/AdherentAdmin.php
+37
-14
CotisationAdmin.php
src/Admin/CotisationAdmin.php
+9
-0
PrestataireAdmin.php
src/Admin/PrestataireAdmin.php
+65
-53
FluxRepository.php
src/Repository/FluxRepository.php
+21
-0
AppExtension.php
src/Twig/AppExtension.php
+27
-3
CotisationUtils.php
src/Utils/CotisationUtils.php
+26
-3
TAVCotisationUtils.php
src/Utils/TAVCotisationUtils.php
+22
-0
list_user_tav_cotisation.html.twig
...tes/themes/kohinos/tav/list_user_tav_cotisation.html.twig
+14
-0
No files found.
config/services.yaml
View file @
fd30b467
...
...
@@ -111,17 +111,23 @@ services:
class
:
App\Utils\CotisationUtils
autowire
:
false
public
:
true
arguments
:
[
'
@app.utils.custom_entity_manager'
,
'
@session'
,
'
@security.helper'
,
'
@event_dispatcher'
]
arguments
:
[
'
@app.utils.custom_entity_manager'
,
'
@session'
,
'
@security.helper'
,
'
@event_dispatcher'
,
'
@service_container'
]
app.utils.account
:
class
:
App\Utils\AccountUtils
autowire
:
false
arguments
:
[
'
@doctrine.orm.entity_manager'
]
app.utils.tav_cotisations
:
class
:
App\Utils\TAVCotisationUtils
autowire
:
false
public
:
true
arguments
:
[
'
@app.utils.custom_entity_manager'
,
'
@security.helper'
,
'
@app.utils.operations'
]
app.twig.main.extension
:
class
:
App\Twig\AppExtension
autowire
:
false
arguments
:
[
"
@service_container"
,
"
@security.helper"
,
"
@doctrine.orm.entity_manager"
,
"
@knp_paginator"
,
"
@session"
,
"
@app.utils.operations"
,
"
@app.utils.cotisations"
]
arguments
:
[
"
@service_container"
,
"
@security.helper"
,
"
@doctrine.orm.entity_manager"
,
"
@knp_paginator"
,
"
@session"
,
"
@app.utils.operations"
,
"
@app.utils.cotisations"
,
"
@app.utils.tav_cotisations"
]
app.twig.logentry.extension
:
class
:
App\Twig\LogEntryExtension
...
...
src/Admin/AdherentAdmin.php
View file @
fd30b467
...
...
@@ -110,12 +110,14 @@ class AdherentAdmin extends AbstractAdmin
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'admin_app_user_edit'
,
[
'id'
=>
$user
->
getId
()],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
}
$menu
->
addChild
(
'Ajouter une cotisation'
,
[
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'cotisation_adherent_create'
,
[
'expediteur'
=>
$id
],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
$menu
->
addChild
(
'Voir les cotisations'
,
[
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'cotisation_adherent_list'
,
[
'filter'
=>
[
'expediteur'
=>
[
'value'
=>
$id
]]],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
if
(
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$menu
->
addChild
(
'Ajouter une cotisation'
,
[
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'cotisation_adherent_create'
,
[
'expediteur'
=>
$id
],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
$menu
->
addChild
(
'Voir les cotisations'
,
[
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'cotisation_adherent_list'
,
[
'filter'
=>
[
'expediteur'
=>
[
'value'
=>
$id
]]],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
}
}
/**
...
...
@@ -288,6 +290,10 @@ class AdherentAdmin extends AbstractAdmin
'label'
=>
'Date de mise à jour'
,
])
;
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$datagridMapper
->
remove
(
'cotisationajour'
);
}
}
public
function
getCotisationFilter
(
$queryBuilder
,
$alias
,
$field
,
$value
)
...
...
@@ -385,14 +391,31 @@ class AdherentAdmin extends AbstractAdmin
->
addIdentifier
(
'user.lastname'
,
null
,
[
'label'
=>
'Nom'
])
->
addIdentifier
(
'user.firstname'
,
null
,
[
'label'
=>
'Prénom'
])
->
addIdentifier
(
'user.email'
,
null
,
[
'label'
=>
'Email'
])
->
add
(
'cotisation'
,
null
,
[
'label'
=>
'Cotisation à jour'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_user_cotisation.html.twig'
,
]
)
;
if
(
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$listMapper
->
add
(
'cotisation'
,
null
,
[
'label'
=>
'Cotisation à jour'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_user_cotisation.html.twig'
,
]
);
}
else
{
$listMapper
->
add
(
'cotisation'
,
null
,
[
'label'
=>
'Dernière cotisation'
,
'template'
=>
'@kohinos/tav/list_user_tav_cotisation.html.twig'
,
]
);
}
$listMapper
->
addIdentifier
(
'groupe'
,
null
,
[
'label'
=>
'Groupe'
,
'sortable'
=>
true
,
...
...
src/Admin/CotisationAdmin.php
View file @
fd30b467
...
...
@@ -21,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use
Symfony\Component\Form\Extension\Core\Type\MoneyType
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Validator\Constraints\Regex
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
/**
* Administration des cotisations.
...
...
@@ -189,6 +190,14 @@ class CotisationAdmin extends AbstractAdmin
*/
protected
function
configureListFields
(
ListMapper
$listMapper
)
{
// In TAV env, block access to standard cotisations admin.
// TODO: find a better way (eg. block access with App\EventListener\MenuBuilderListener?)
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$url
=
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'sonata_admin_dashboard'
);
$redirection
=
new
RedirectResponse
(
$url
);
$redirection
->
send
();
}
unset
(
$this
->
listModes
[
'mosaic'
]);
$listMapper
->
add
(
'id'
,
'text'
,
[
...
...
src/Admin/PrestataireAdmin.php
View file @
fd30b467
...
...
@@ -144,7 +144,7 @@ class PrestataireAdmin extends AbstractAdmin
// ]);
}
// Le prestataire "Monnaie Locale" représentant l'asso recevant les cotisations n'a pas de cotisations lui même !
if
(
!
$presta
->
isMlc
())
{
if
(
!
$presta
->
isMlc
()
&&
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
)
)
{
$menu
->
addChild
(
'Ajouter une cotisation'
,
[
'uri'
=>
$this
->
getConfigurationPool
()
->
getContainer
()
->
get
(
'router'
)
->
generate
(
'cotisation_prestataire_create'
,
[
'expediteur'
=>
$id
],
UrlGeneratorInterface
::
ABSOLUTE_URL
),
]);
...
...
@@ -519,6 +519,11 @@ class PrestataireAdmin extends AbstractAdmin
'advanced_filter'
=>
false
,
])
;
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$datagridMapper
->
remove
(
'cotisationajour'
);
$datagridMapper
->
remove
(
'gestionnaireajour'
);
}
}
public
function
getGestionnaireFilter
(
$queryBuilder
,
$alias
,
$field
,
$value
)
...
...
@@ -691,60 +696,67 @@ class PrestataireAdmin extends AbstractAdmin
];
}
}
// listmappers for each environment (pro & tav_env)
$listMapper
->
addIdentifier
(
'raisonAndIdmlc'
,
'html'
,
[
'label'
=>
'Raison'
,
])
->
add
(
'groupe'
,
null
,
[
'label'
=>
'Groupe'
,
'sortable'
=>
true
,
'sort_field_mapping'
=>
[
'fieldName'
=>
'name'
],
'sort_parent_association_mappings'
=>
[[
'fieldName'
=>
'groupe'
]],
])
// ->addIdentifier('users', null, array('label' => 'Gestionnaires'))
->
add
(
'rubriques'
,
null
)
->
add
(
'etats'
,
null
,
[
'label'
=>
'Tags'
,
// 'editable' => true,
// 'class' => EtatPrestataire::class,
// 'multiple' => true,
// // 'required' => false,
// // 'by_reference' => false,
// 'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(EtatPrestataire::class)->findBy(array('enabled' => true))
])
->
add
(
'cotisation'
,
null
,
[
'label'
=>
'Cotisation à jour'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_cotisation.html.twig'
,
]
)
->
add
(
'users'
,
null
,
[
'label'
=>
'Gestionnaires [Cotisation à jour]'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_gestionnaires.html.twig'
,
])
->
add
(
'enabled'
,
null
,
[
'label'
=>
'Activé'
,
'editable'
=>
true
,
])
->
add
(
'acceptemlc'
,
null
,
[
'label'
=>
'Accepte e-mlc'
,
'editable'
=>
true
,
])
->
add
(
'createdAt'
,
'date'
,
[
'pattern'
=>
'dd/MM/YYYY HH:mm'
,
'label'
=>
'Crée le'
,
])
->
add
(
'updatedAt'
,
'date'
,
[
'pattern'
=>
'dd/MM/YYYY HH:mm'
,
'label'
=>
'Mis à jour le'
,
])
// You may also specify the actions you want to be displayed in the list
->
add
(
'_action'
,
null
,
[
'actions'
=>
$actions
,
])
->
addIdentifier
(
'raisonAndIdmlc'
,
'html'
,
[
'label'
=>
'Raison'
,
])
->
add
(
'groupe'
,
null
,
[
'label'
=>
'Groupe'
,
'sortable'
=>
true
,
'sort_field_mapping'
=>
[
'fieldName'
=>
'name'
],
'sort_parent_association_mappings'
=>
[[
'fieldName'
=>
'groupe'
]],
])
// ->addIdentifier('users', null, array('label' => 'Gestionnaires'))
->
add
(
'rubriques'
,
null
)
->
add
(
'etats'
,
null
,
[
'label'
=>
'Tags'
,
// 'editable' => true,
// 'class' => EtatPrestataire::class,
// 'multiple' => true,
// // 'required' => false,
// // 'by_reference' => false,
// 'choices' => $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository(EtatPrestataire::class)->findBy(array('enabled' => true))
])
->
add
(
'cotisation'
,
null
,
[
'label'
=>
'Cotisation à jour'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_cotisation.html.twig'
,
]
)
->
add
(
'users'
,
null
,
[
'label'
=>
'Gestionnaires [Cotisation à jour]'
,
'template'
=>
'@kohinos/bundles/SonataAdminBundle/CRUD/list_presta_gestionnaires.html.twig'
,
])
->
add
(
'enabled'
,
null
,
[
'label'
=>
'Activé'
,
'editable'
=>
true
,
])
->
add
(
'acceptemlc'
,
null
,
[
'label'
=>
'Accepte e-mlc'
,
'editable'
=>
true
,
])
->
add
(
'createdAt'
,
'date'
,
[
'pattern'
=>
'dd/MM/YYYY HH:mm'
,
'label'
=>
'Crée le'
,
])
->
add
(
'updatedAt'
,
'date'
,
[
'pattern'
=>
'dd/MM/YYYY HH:mm'
,
'label'
=>
'Mis à jour le'
,
])
// You may also specify the actions you want to be displayed in the list
->
add
(
'_action'
,
null
,
[
'actions'
=>
$actions
,
])
;
if
(
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$listMapper
->
remove
(
'cotisation'
);
$listMapper
->
remove
(
'users'
);
}
}
protected
function
configureRoutes
(
RouteCollection
$collection
)
...
...
src/Repository/FluxRepository.php
View file @
fd30b467
...
...
@@ -264,4 +264,25 @@ class FluxRepository extends ServiceEntityRepository
return
$results
;
}
/**
* @param Adherent $adherent the user to look the cotisation for
*
* @return
*/
public
function
getLastTavCotisation
(
$adherent
)
{
$sqlQuery
=
"SELECT f.created_at
FROM
{
$this
->
tableName
}
f
WHERE f.type IN ('achat_monnaie_adherent', 'vente_emlc_adherent')
AND (f.adherent_id = :adh_id OR f.adherent_dest_id = :adh_id)
ORDER BY created_at DESC"
;
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
->
bindValue
(
':adh_id'
,
$adherent
->
getId
());
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
return
$results
;
}
}
src/Twig/AppExtension.php
View file @
fd30b467
...
...
@@ -27,6 +27,7 @@ use App\Enum\CurrencyEnum;
use
App\Flux\AccountableInterface
;
use
App\Utils\CotisationUtils
;
use
App\Utils\OperationUtils
;
use
App\Utils\TAVCotisationUtils
;
use
Doctrine\ORM\EntityManagerInterface
;
use
FOS\UserBundle\Model\UserInterface
;
use
Knp\Component\Pager\PaginatorInterface
;
...
...
@@ -46,9 +47,18 @@ class AppExtension extends AbstractExtension
public
$session
;
public
$operationUtils
;
public
$cotisationUtils
;
public
function
__construct
(
ContainerInterface
$container
,
Security
$security
,
EntityManagerInterface
$em
,
PaginatorInterface
$paginator
,
SessionInterface
$session
,
OperationUtils
$operationUtils
,
CotisationUtils
$cotisationUtils
)
{
public
$tavCotisationUtils
;
public
function
__construct
(
ContainerInterface
$container
,
Security
$security
,
EntityManagerInterface
$em
,
PaginatorInterface
$paginator
,
SessionInterface
$session
,
OperationUtils
$operationUtils
,
CotisationUtils
$cotisationUtils
,
TAVCotisationUtils
$tavCotisationUtils
)
{
$this
->
em
=
$em
;
$this
->
security
=
$security
;
$this
->
container
=
$container
;
...
...
@@ -56,6 +66,7 @@ class AppExtension extends AbstractExtension
$this
->
session
=
$session
;
$this
->
operationUtils
=
$operationUtils
;
$this
->
cotisationUtils
=
$cotisationUtils
;
$this
->
tavCotisationUtils
=
$tavCotisationUtils
;
}
public
function
getFunctions
()
...
...
@@ -92,6 +103,7 @@ class AppExtension extends AbstractExtension
new
\Twig_SimpleFunction
(
'getCurrencyName'
,
[
$this
,
'getCurrencyName'
]),
new
\Twig_SimpleFunction
(
'getPaymentReceiptUrlFromFlux'
,
[
$this
,
'getPaymentReceiptUrlFromFlux'
]),
new
\Twig_SimpleFunction
(
'getDonType'
,
[
$this
,
'getDonType'
]),
new
\Twig_SimpleFunction
(
'getLastTavCotisationForAdherent'
,
[
$this
,
'getLastTavCotisationForAdherent'
]),
new
\Twig_SimpleFunction
(
'parameter'
,
function
(
$name
)
{
return
$this
->
container
->
getParameter
(
$name
);
}),
...
...
@@ -287,6 +299,18 @@ class AppExtension extends AbstractExtension
return
$this
->
cotisationUtils
->
isCotisationValidForAdherent
(
$adherent
);
}
/**
* [getLastTavCotisationForAdherent.
*
* @param Adherent|null $adherent
*
* @return bool|date
*/
public
function
getLastTavCotisationForAdherent
(
?
Adherent
$adherent
=
null
)
{
return
$this
->
tavCotisationUtils
->
getLastTavCotisationForAdherent
(
$adherent
);
}
public
function
isDevFixture
(
?
string
$username
=
null
)
{
if
(
null
==
$username
)
{
...
...
src/Utils/CotisationUtils.php
View file @
fd30b467
...
...
@@ -9,6 +9,7 @@ use FOS\UserBundle\Model\UserInterface;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
class
CotisationUtils
{
...
...
@@ -16,13 +17,20 @@ class CotisationUtils
private
$session
;
private
$security
;
private
$eventDispatcher
;
public
function
__construct
(
CustomEntityManager
$em
,
SessionInterface
$session
,
Security
$security
,
EventDispatcherInterface
$eventDispatcher
)
{
private
$container
;
public
function
__construct
(
CustomEntityManager
$em
,
SessionInterface
$session
,
Security
$security
,
EventDispatcherInterface
$eventDispatcher
,
ContainerInterface
$container
)
{
$this
->
em
=
$em
;
$this
->
session
=
$session
;
$this
->
security
=
$security
;
$this
->
eventDispatcher
=
$eventDispatcher
;
$this
->
container
=
$container
;
}
public
function
isUserCotisationExpired
(
UserInterface
$user
,
int
$nbDay
=
30
)
:
bool
...
...
@@ -97,6 +105,11 @@ class CotisationUtils
*/
public
function
isCotisationValidForPresta
(
?
Prestataire
$presta
)
{
// In TAV mode, no standard cotisation required. Return next year date to make all accounts valid.
if
(
$this
->
container
->
getParameter
(
'tav_env'
))
{
return
date
(
'Y-m-d'
,
strtotime
(
'+1 year'
));
}
$query
=
null
;
if
(
null
!==
$presta
)
{
$query
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByPrestataire
(
$presta
,
'cotisation'
);
...
...
@@ -147,6 +160,11 @@ class CotisationUtils
*/
public
function
isCotisationValidForAdherent
(
?
Adherent
$adherent
)
{
// In TAV mode, no standard cotisation required. Return next year date to make all accounts valid.
if
(
$this
->
container
->
getParameter
(
'tav_env'
))
{
return
date
(
'Y-m-d'
,
strtotime
(
'+1 year'
));
}
$query
=
null
;
if
(
null
!==
$adherent
)
{
$query
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByAdherent
(
$adherent
,
'cotisation'
);
...
...
@@ -172,6 +190,11 @@ class CotisationUtils
*/
public
function
isCotisationValid
(
?
UserInterface
$user
)
{
// In TAV mode, no standard cotisation required. Return next year date to make all accounts valid.
if
(
$this
->
container
->
getParameter
(
'tav_env'
))
{
return
date
(
'Y-m-d'
,
strtotime
(
'+1 year'
));
}
$query
=
null
;
if
(
null
===
$user
&&
null
!=
$this
->
security
->
getUser
())
{
if
(
$this
->
security
->
isGranted
(
'ROLE_ADHERENT'
)
&&
null
!=
$this
->
security
->
getUser
()
->
getAdherent
())
{
...
...
src/Utils/TAVCotisationUtils.php
View file @
fd30b467
...
...
@@ -2,6 +2,7 @@
namespace
App\Utils
;
use
App\Entity\Adherent
;
use
App\Entity\Siege
;
use
App\Entity\Flux
;
use
App\Entity\TauxCotisationReversement
;
...
...
@@ -88,4 +89,25 @@ class TAVCotisationUtils
$this
->
em
->
persist
(
$fluxCotis
);
$this
->
operationUtils
->
executeOperations
(
$fluxCotis
);
}
/**
* Get the last cotisation of an adhérent
*
* @param Adherent $adherent
*
* @return bool|date
*/
public
function
getLastTavCotisationForAdherent
(
?
Adherent
$adherent
)
{
$cotisations
=
[];
if
(
null
!==
$adherent
)
{
$cotisations
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getLastTavCotisation
(
$adherent
);
}
if
(
count
(
$cotisations
)
>
0
)
{
return
$cotisations
[
0
][
"created_at"
];
}
return
false
;
}
}
templates/themes/kohinos/tav/list_user_tav_cotisation.html.twig
0 → 100644
View file @
fd30b467
{%
extends
admin.getTemplate
(
'base_list_field'
)
%}
{%
block
field
%}
{%
-
spaceless
%}
{%
set
cotisEnd
=
getLastTavCotisationForAdherent
(
object.user.adherent
)
%}
{%
if
false
!=
cotisEnd
%}
{%
set
text
=
cotisEnd
|
date
(
'd/m/Y'
)
%}
{%
set
class
=
'label-success'
%}
{%
else
%}
{%
set
text
=
'aucune'
|
trans
%}
{%
set
class
=
'label-danger'
%}
{%
endif
%}
<span
class=
"label
{{
class
}}
"
>
{{
text
}}
</span>
{%
endspaceless
-
%}
{%
endblock
%}
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