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
b4bbd62d
Commit
b4bbd62d
authored
May 07, 2024
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into ssa-gironde
parents
fdd31ac6
b96970ea
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
14 deletions
+107
-14
UserAdmin.php
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
+17
-0
CRUDController.php
src/Controller/CRUD/CRUDController.php
+41
-0
UserController.php
src/Controller/UserController.php
+18
-0
Adherent.php
src/Entity/Adherent.php
+1
-1
ListOperationFormType.php
src/Form/Type/ListOperationFormType.php
+3
-3
FluxRepository.php
src/Repository/FluxRepository.php
+23
-0
OperationUtils.php
src/Utils/OperationUtils.php
+2
-2
menu.html.twig
templates/themes/kohinos/common/menu.html.twig
+2
-8
No files found.
src/Application/Sonata/UserBundle/Admin/UserAdmin.php
View file @
b4bbd62d
...
@@ -48,6 +48,8 @@ class UserAdmin extends BaseUserAdmin
...
@@ -48,6 +48,8 @@ class UserAdmin extends BaseUserAdmin
protected
function
configureRoutes
(
RouteCollection
$collection
)
protected
function
configureRoutes
(
RouteCollection
$collection
)
{
{
// Remove 'delete' action for non tav envs
if
(
!
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
if
(
$this
->
isChild
())
{
if
(
$this
->
isChild
())
{
$collection
->
remove
(
'delete'
);
$collection
->
remove
(
'delete'
);
...
@@ -57,6 +59,7 @@ class UserAdmin extends BaseUserAdmin
...
@@ -57,6 +59,7 @@ class UserAdmin extends BaseUserAdmin
// This is the route configuration as a parent
// This is the route configuration as a parent
$collection
->
remove
(
'delete'
);
$collection
->
remove
(
'delete'
);
}
}
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
...
@@ -83,6 +86,20 @@ class UserAdmin extends BaseUserAdmin
...
@@ -83,6 +86,20 @@ class UserAdmin extends BaseUserAdmin
])
])
;
;
// Add delete action on users in TAV envs for super admin
if
(
$this
->
isGranted
(
'ROLE_SUPER_ADMIN'
)
&&
$this
->
getConfigurationPool
()
->
getContainer
()
->
getParameter
(
'tav_env'
))
{
$listMapper
->
remove
(
'_action'
)
->
add
(
'_action'
,
null
,
[
'label'
=>
'Actions'
,
'actions'
=>
[
'edit'
=>
[],
'delete'
=>
[]
],
])
;
}
// TODO: SECURITY BREACH, RESET ASAP!!!
// TODO: SECURITY BREACH, RESET ASAP!!!
// if ('dev' == $_ENV['APP_ENV'] && $this->isGranted('ROLE_ALLOWED_TO_SWITCH')) {
// if ('dev' == $_ENV['APP_ENV'] && $this->isGranted('ROLE_ALLOWED_TO_SWITCH')) {
if
(
$this
->
isGranted
(
'ROLE_ALLOWED_TO_SWITCH'
))
{
if
(
$this
->
isGranted
(
'ROLE_ALLOWED_TO_SWITCH'
))
{
...
...
src/Controller/CRUD/CRUDController.php
View file @
b4bbd62d
...
@@ -9,9 +9,20 @@ use Symfony\Component\Form\FormView;
...
@@ -9,9 +9,20 @@ use Symfony\Component\Form\FormView;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Security\Core\Exception\AccessDeniedException
;
use
Symfony\Component\Security\Core\Exception\AccessDeniedException
;
use
App\Utils\CustomEntityManager
;
use
App\Entity\User
;
use
App\Entity\Flux
;
class
CRUDController
extends
Controller
class
CRUDController
extends
Controller
{
{
protected
$em
;
public
function
__construct
(
CustomEntityManager
$em
)
{
$this
->
em
=
$em
;
}
/**
/**
* Create action.
* Create action.
*
*
...
@@ -211,6 +222,36 @@ class CRUDController extends Controller
...
@@ -211,6 +222,36 @@ class CRUDController extends Controller
return
$this
->
redirectTo
(
$object
);
return
$this
->
redirectTo
(
$object
);
}
}
if
(
$object
->
hasRole
(
'ROLE_API'
))
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer le compte API !'
);
return
$this
->
redirectTo
(
$object
);
}
// Prevent deleting user if flux related to its Adherent account exist
if
(
$object
instanceof
User
)
{
$query
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByUser
(
$object
);
$hasFluxAdherent
=
false
;
if
(
$object
->
getAdherent
())
{
$queryAdherent
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByAdherent
(
$object
->
getAdherent
());
if
(
null
!=
$queryAdherent
&&
count
(
$queryAdherent
->
getResult
())
>
0
)
{
$hasFluxAdherent
=
true
;
}
}
if
(
null
!=
$query
&&
count
(
$query
->
getResult
())
>
0
||
$hasFluxAdherent
)
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer ce compte utilisateur : des flux en relation à son compte sont enregistrés.'
);
return
$this
->
redirectTo
(
$object
);
}
}
return
parent
::
deleteAction
(
$id
);
return
parent
::
deleteAction
(
$id
);
}
}
...
...
src/Controller/UserController.php
View file @
b4bbd62d
...
@@ -8,6 +8,7 @@ use App\Entity\CotisationPrestataire;
...
@@ -8,6 +8,7 @@ use App\Entity\CotisationPrestataire;
use
App\Entity\GlobalParameter
;
use
App\Entity\GlobalParameter
;
use
App\Entity\Payment
;
use
App\Entity\Payment
;
use
App\Entity\Prestataire
;
use
App\Entity\Prestataire
;
use
App\Entity\Reconversion
;
use
App\Entity\TransactionPrestataireAdherent
;
use
App\Entity\TransactionPrestataireAdherent
;
use
App\Entity\User
;
use
App\Entity\User
;
use
App\Entity\TransactionAdherentPrestataire
;
use
App\Entity\TransactionAdherentPrestataire
;
...
@@ -31,6 +32,7 @@ use Symfony\Component\Routing\Annotation\Route;
...
@@ -31,6 +32,7 @@ use Symfony\Component\Routing\Annotation\Route;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Translation\TranslatorInterface
;
use
Symfony\Component\Translation\TranslatorInterface
;
use
Twig\Environment
;
use
Twig\Environment
;
use
App\Entity\Flux
;
class
UserController
extends
AbstractController
class
UserController
extends
AbstractController
{
{
...
@@ -285,6 +287,22 @@ class UserController extends AbstractController
...
@@ -285,6 +287,22 @@ class UserController extends AbstractController
return
$this
->
redirectToRoute
(
'index'
);
return
$this
->
redirectToRoute
(
'index'
);
}
}
//Prevent cancelling transactions which happened before a reconversion (to avoid refunding money that's been reconverted)
if
(
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByPrestataire
(
$presta
,
null
,
Reconversion
::
TYPE_RECONVERSION_PRESTATAIRE
,
$transactionAdherentPrestataire
->
getCreatedAt
()
->
format
(
"Y-m-d H:i:s"
)
)
->
getResult
()
)
{
$this
->
addFlash
(
'error'
,
'Cette transaction ne plus être annulée car une reconversion a été demandée depuis.'
);
return
$this
->
redirectToRoute
(
'index'
);
}
//Create new transaction in opposite direction
//Create new transaction in opposite direction
$flux
=
new
TransactionPrestataireAdherent
();
$flux
=
new
TransactionPrestataireAdherent
();
$flux
->
setExpediteur
(
$presta
);
$flux
->
setExpediteur
(
$presta
);
...
...
src/Entity/Adherent.php
View file @
b4bbd62d
...
@@ -77,7 +77,7 @@ class Adherent extends AccountableObject implements AccountableInterface
...
@@ -77,7 +77,7 @@ class Adherent extends AccountableObject implements AccountableInterface
/**
/**
* @var ArrayCollection|AccountAdherent[]
* @var ArrayCollection|AccountAdherent[]
* @ORM\OneToMany(targetEntity="AccountAdherent", mappedBy="adherent")
* @ORM\OneToMany(targetEntity="AccountAdherent", mappedBy="adherent"
, cascade={"remove"}
)
*/
*/
private
$accounts
;
private
$accounts
;
...
...
src/Form/Type/ListOperationFormType.php
View file @
b4bbd62d
...
@@ -6,7 +6,7 @@ use App\Enum\MoyenEnum;
...
@@ -6,7 +6,7 @@ use App\Enum\MoyenEnum;
use
Doctrine\ORM\EntityManagerInterface
;
use
Doctrine\ORM\EntityManagerInterface
;
use
Symfony\Component\Form\AbstractType
;
use
Symfony\Component\Form\AbstractType
;
use
Symfony\Component\Form\Extension\Core\Type\ChoiceType
;
use
Symfony\Component\Form\Extension\Core\Type\ChoiceType
;
use
Symfony\Component\Form\Extension\Core\Type\DateT
imeT
ype
;
use
Symfony\Component\Form\Extension\Core\Type\DateType
;
use
Symfony\Component\Form\Extension\Core\Type\SubmitType
;
use
Symfony\Component\Form\Extension\Core\Type\SubmitType
;
use
Symfony\Component\Form\FormBuilderInterface
;
use
Symfony\Component\Form\FormBuilderInterface
;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
use
Symfony\Component\HttpFoundation\Session\SessionInterface
;
...
@@ -40,13 +40,13 @@ class ListOperationFormType extends AbstractType
...
@@ -40,13 +40,13 @@ class ListOperationFormType extends AbstractType
return
MoyenEnum
::
getTypeName
(
$choice
);
return
MoyenEnum
::
getTypeName
(
$choice
);
},
},
])
])
->
add
(
'datemin'
,
DateT
imeT
ype
::
class
,
[
->
add
(
'datemin'
,
DateType
::
class
,
[
'label'
=>
'Date min'
,
'label'
=>
'Date min'
,
'required'
=>
false
,
'required'
=>
false
,
'widget'
=>
'single_text'
,
'widget'
=>
'single_text'
,
// 'data' => new \DateTime('first day of this month')
// 'data' => new \DateTime('first day of this month')
])
])
->
add
(
'datemax'
,
DateT
imeT
ype
::
class
,
[
->
add
(
'datemax'
,
DateType
::
class
,
[
'label'
=>
'Date max'
,
'label'
=>
'Date max'
,
'required'
=>
false
,
'required'
=>
false
,
'widget'
=>
'single_text'
,
'widget'
=>
'single_text'
,
...
...
src/Repository/FluxRepository.php
View file @
b4bbd62d
...
@@ -7,6 +7,7 @@ use App\Entity\Comptoir;
...
@@ -7,6 +7,7 @@ use App\Entity\Comptoir;
use
App\Entity\Flux
;
use
App\Entity\Flux
;
use
App\Entity\Groupe
;
use
App\Entity\Groupe
;
use
App\Entity\Prestataire
;
use
App\Entity\Prestataire
;
use
App\Entity\User
;
use
Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
;
use
Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository
;
use
Doctrine\Persistence\ManagerRegistry
;
use
Doctrine\Persistence\ManagerRegistry
;
...
@@ -237,6 +238,28 @@ class FluxRepository extends ServiceEntityRepository
...
@@ -237,6 +238,28 @@ class FluxRepository extends ServiceEntityRepository
;
;
}
}
/**
* @param User $user
*
* @return Query Returns a query fo finding an array of Flux
*/
public
function
getQueryByUser
(
User
$user
)
{
$sqlQuery
=
"SELECT f.id FROM
{
$this
->
tableName
}
f WHERE f.user_id = :id"
;
$statement
=
$this
->
connection
->
prepare
(
$sqlQuery
);
$statement
->
bindValue
(
':id'
,
$user
->
getId
());
$statement
->
execute
();
$results
=
$statement
->
fetchAll
();
$qb
=
$this
->
createQueryBuilder
(
'f'
);
return
$qb
->
where
(
$qb
->
expr
()
->
in
(
'f.id'
,
':ids'
))
->
setParameter
(
'ids'
,
$results
)
->
orderBy
(
'f.createdAt'
,
'DESC'
)
->
getQuery
()
;
}
public
function
getTotalVenteAchat
()
public
function
getTotalVenteAchat
()
{
{
$qb
=
$this
->
createQueryBuilder
(
'f'
);
$qb
=
$this
->
createQueryBuilder
(
'f'
);
...
...
src/Utils/OperationUtils.php
View file @
b4bbd62d
...
@@ -61,13 +61,13 @@ class OperationUtils
...
@@ -61,13 +61,13 @@ class OperationUtils
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'datemin'
]))
{
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'datemin'
]))
{
$qb
$qb
->
andWhere
(
'a.createdAt >= :datemin'
)
->
andWhere
(
'a.createdAt >= :datemin'
)
->
setParameter
(
'datemin'
,
$request
->
get
(
'formListOperations'
)[
'datemin'
]
.
' 00:00:00'
)
->
setParameter
(
'datemin'
,
$request
->
get
(
'formListOperations'
)[
'datemin'
]
)
// Date only comparison: error in queries comparing datetimes with some MYSQL versions
;
;
}
}
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'datemax'
]))
{
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'datemax'
]))
{
$qb
$qb
->
andWhere
(
'a.createdAt <= :datemax'
)
->
andWhere
(
'a.createdAt <= :datemax'
)
->
setParameter
(
'datemax'
,
$request
->
get
(
'formListOperations'
)[
'datemax'
]
.
' 23:59:59'
)
->
setParameter
(
'datemax'
,
$request
->
get
(
'formListOperations'
)[
'datemax'
])
;
;
}
}
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'moyen'
]))
{
if
(
!
empty
(
$request
->
get
(
'formListOperations'
)[
'moyen'
]))
{
...
...
templates/themes/kohinos/common/menu.html.twig
View file @
b4bbd62d
...
@@ -80,14 +80,8 @@
...
@@ -80,14 +80,8 @@
</a>
</a>
<div
class=
"dropdown-menu dropdown-menu-right"
aria-labelledby=
"navbarDropdownUC"
>
<div
class=
"dropdown-menu dropdown-menu-right"
aria-labelledby=
"navbarDropdownUC"
>
{# COMPTE ou ECOMPTE : @TODO : mettre plutôt dans le header en visible tout le temps ? #}
{# COMPTE ou ECOMPTE : @TODO : mettre plutôt dans le header en visible tout le temps ? #}
{%
if
app.user
and
is_granted
(
'ROLE_ADHERENT'
)
%}
{%
if
app.user
and
app.user.adherent
and
is_granted
(
'ROLE_ADHERENT'
)
%}
<b
class=
"dropdown-item bg-primary text-white"
>
<b
class=
"dropdown-item bg-primary text-white"
>
Ecompte :
{{
app.user.adherent.emlcAccount.balance
}}
</b>
{%
if
app.user.adherent
%}
Ecompte :
{{
app.user.adherent.emlcAccount.balance
}}
{%
else
%}
Adhérent introuvable.
{%
endif
%}
</b>
{%
elseif
app.user
and
is_granted
(
'ROLE_PRESTATAIRE'
)
and
getCurrentPrestataire
()
!=
null
%}
{%
elseif
app.user
and
is_granted
(
'ROLE_PRESTATAIRE'
)
and
getCurrentPrestataire
()
!=
null
%}
<b
class=
"dropdown-item bg-primary text-white"
>
Ecompte :
{{
getCurrentPrestataire
()
.
emlcAccount.balance
}}
</b>
<b
class=
"dropdown-item bg-primary text-white"
>
Ecompte :
{{
getCurrentPrestataire
()
.
emlcAccount.balance
}}
</b>
{%
elseif
getCurrentGroupe
()
!=
null
%}
{%
elseif
getCurrentGroupe
()
!=
null
%}
...
...
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