Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OSE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
OSE
Commits
c11c68ac
Commit
c11c68ac
authored
1 year ago
by
Antony Le Courtes
Browse files
Options
Downloads
Patches
Plain Diff
Amélioration bouton next etape feuille de route
parent
3c64691d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
module/Application/src/Service/WorkflowService.php
+218
-218
218 additions, 218 deletions
module/Application/src/Service/WorkflowService.php
with
218 additions
and
218 deletions
module/Application/src/Service/WorkflowService.php
+
218
−
218
View file @
c11c68ac
...
...
@@ -30,6 +30,33 @@ class WorkflowService extends AbstractService
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getPreviousAccessibleEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
&&
$etape
->
isAtteignable
()
&&
$etape
->
getUrl
()
&&
$this
->
isAllowed
(
$etape
))
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
return
null
;
}
protected
function
prepareEtapeParams
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
switch
(
true
)
{
...
...
@@ -74,128 +101,6 @@ class WorkflowService extends AbstractService
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
if
(
$fdr
)
{
foreach
(
$fdr
as
$etape
)
{
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
return
$etape
;
}
}
}
return
null
;
}
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getNextEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
)
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
return
null
;
}
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getPreviousAccessibleEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
&&
$etape
->
isAtteignable
()
&&
$etape
->
getUrl
()
&&
$this
->
isAllowed
(
$etape
))
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
return
null
;
}
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getNextAccessibleEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
&&
$etape
->
isAtteignable
()
&&
$etape
->
getUrl
()
&&
$this
->
isAllowed
(
$etape
))
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
return
$this
->
getEtapeCourante
(
$intervenant
,
$structure
);
}
public
function
isAllowed
(
$etape
)
{
if
(
$etape
instanceof
WorkflowEtape
)
{
$etape
=
$etape
->
getEtape
();
}
if
(
!
$etape
instanceof
WfEtape
)
{
throw
new
\Exception
(
'L\'étape fournie n\'est pas de classe WfEtape'
);
}
$resource
=
\Application\Util
::
routeToActionResource
(
$etape
->
getRoute
());
return
$this
->
getServiceAuthorize
()
->
isAllowed
(
$resource
);
}
/**
* @param Intervenant|null $intervenant
* @param Structure|null $structure
...
...
@@ -273,59 +178,51 @@ class WorkflowService extends AbstractService
/**
* @return $this
* @throws \Doctrine\DBAL\DBALException
* @param Intervenant|null $intervenant
*
* @return TblWorkflow[]
*/
p
ublic
function
calculerTout
(
)
p
rotected
function
getEtapes
(
Intervenant
$intervenant
,
?Structure
$structure
=
null
,
bool
$calcIfEmpty
=
true
)
{
$this
->
getServiceTableauBord
()
->
calculer
(
'workflow'
);
return
$this
;
}
$dql
=
"
SELECT
we, tw, str, dblo, dep
FROM
Application\Entity\Db\TblWorkflow tw
JOIN tw.etape we
LEFT JOIN tw.structure str
LEFT JOIN tw.etapeDeps dblo
LEFT JOIN dblo.wfEtapeDep dep
WHERE
tw.intervenant = :intervenant
"
.
(
$structure
?
"AND (tw.structure IS NULL OR tw.structure = :structure)"
:
''
)
.
"
ORDER BY
we.ordre, str.libelleCourt
"
;
$query
=
$this
->
getEntityManager
()
->
createQuery
(
$dql
);
$query
->
setParameter
(
'intervenant'
,
$intervenant
);
if
(
$structure
)
$query
->
setParameter
(
'structure'
,
$structure
);
$etapes
=
$query
->
getResult
();
if
(
empty
(
$etapes
)
&&
$calcIfEmpty
)
{
$this
->
calculerTableauxBord
([],
$intervenant
);
/**
* @return int
* @throws \Doctrine\DBAL\DBALException
*/
public
function
calculerTousTableauxBord
(
$beforeTrigger
=
null
,
$afterTrigger
=
null
)
{
$sql
=
"SELECT tbl_name FROM tbl WHERE tbl_name <> 'formule' ORDER BY ordre"
;
$tbls
=
$this
->
getEntityManager
()
->
getConnection
()
->
fetchAllAssociative
(
$sql
);
$result
=
true
;
foreach
(
$tbls
as
$tbl
)
{
$begin
=
microtime
(
true
);
$tbl
=
$tbl
[
'TBL_NAME'
];
$sql
=
'BEGIN UNICAEN_TBL.CALCULER(\''
.
$tbl
.
'\'); END;'
;
if
(
$beforeTrigger
instanceof
\Closure
)
{
$beforeTrigger
([
'tableau-bord'
=>
$tbl
,
]);
}
try
{
$this
->
getEntityManager
()
->
getConnection
()
->
executeStatement
(
$sql
);
if
(
$afterTrigger
instanceof
\Closure
)
{
$afterTrigger
([
'tableau-bord'
=>
$tbl
,
'result'
=>
true
,
'duree'
=>
microtime
(
true
)
-
$begin
,
]);
return
$this
->
getEtapes
(
$intervenant
,
$structure
,
false
);
}
}
catch
(
\Exception
$e
)
{
if
(
$afterTrigger
instanceof
\Closure
)
{
$afterTrigger
([
'tableau-bord'
=>
$tbl
,
'result'
=>
false
,
'exception'
=>
$e
,
'duree'
=>
microtime
(
true
)
-
$begin
,
]);
/* @var $etapes TblWorkflow[] */
if
(
$this
->
getServiceContext
()
->
getSelectedIdentityRole
()
->
getIntervenant
())
{
foreach
(
$etapes
as
$etape
)
{
$we
=
$etape
->
getEtape
();
if
(
$we
->
getRouteIntervenant
())
{
$we
->
setRoute
(
$we
->
getRouteIntervenant
());
}
$result
=
false
;
}
}
return
$
result
;
return
$
etapes
;
}
...
...
@@ -417,6 +314,53 @@ class WorkflowService extends AbstractService
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
if
(
$fdr
)
{
foreach
(
$fdr
as
$etape
)
{
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
return
$etape
;
}
}
}
return
null
;
}
/**
* Generates a url given the name of a route.
*
* @param string $name Name of the route
* @param array $params Parameters for the link
* @param array|Traversable $options Options for the route
* @param bool $reuseMatchedParams Whether to reuse matched parameters
*
* @return string Url For the link href attribute
* @see \Laminas\Mvc\Router\RouteInterface::assemble()
*
*/
protected
function
getUrl
(
$name
=
null
,
$params
=
[],
$options
=
[],
$reuseMatchedParams
=
false
)
{
$url
=
\Application
::
$container
->
get
(
'ViewHelperManager'
)
->
get
(
'url'
);
/* @var $url \Laminas\View\Helper\Url */
return
$url
->
__invoke
(
$name
,
$params
,
$options
,
$reuseMatchedParams
);
}
/**
* @param $data WorkflowEtape[]
*/
...
...
@@ -455,72 +399,128 @@ class WorkflowService extends AbstractService
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return
Tbl
Workflow
[]
* @return Workflow
Etape
*/
p
rotected
function
getEtape
s
(
Intervenant
$intervenant
,
?
Structure
$structure
=
null
,
bool
$calcIfEmpty
=
true
)
p
ublic
function
get
Next
Etape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$dql
=
"
SELECT
we, tw, str, dblo, dep
FROM
Application\Entity\Db\TblWorkflow tw
JOIN tw.etape we
LEFT JOIN tw.structure str
LEFT JOIN tw.etapeDeps dblo
LEFT JOIN dblo.wfEtapeDep dep
WHERE
tw.intervenant = :intervenant
"
.
(
$structure
?
"AND (tw.structure IS NULL OR tw.structure = :structure)"
:
''
)
.
"
ORDER BY
we.ordre, str.libelleCourt
"
;
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
)
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
$query
=
$this
->
getEntityManager
()
->
createQuery
(
$dql
);
$query
->
setParameter
(
'intervenant'
,
$intervenant
);
if
(
$structure
)
$query
->
setParameter
(
'structure'
,
$structure
);
$etapes
=
$query
->
getResult
();
return
null
;
}
if
(
empty
(
$etapes
)
&&
$calcIfEmpty
)
{
$this
->
calculerTableauxBord
([],
$intervenant
);
return
$this
->
getEtapes
(
$intervenant
,
$structure
,
false
);
public
function
isAllowed
(
$etape
)
{
if
(
$etape
instanceof
WorkflowEtape
)
{
$etape
=
$etape
->
getEtape
();
}
if
(
!
$etape
instanceof
WfEtape
)
{
throw
new
\Exception
(
'L\'étape fournie n\'est pas de classe WfEtape'
);
}
/* @var $etapes TblWorkflow[] */
if
(
$this
->
getServiceContext
()
->
getSelectedIdentityRole
()
->
getIntervenant
())
{
foreach
(
$etapes
as
$etape
)
{
$we
=
$etape
->
getEtape
();
if
(
$we
->
getRouteIntervenant
())
{
$we
->
setRoute
(
$we
->
getRouteIntervenant
());
$resource
=
\Application\Util
::
routeToActionResource
(
$etape
->
getRoute
());
return
$this
->
getServiceAuthorize
()
->
isAllowed
(
$resource
);
}
/**
* @param WfEtapeService|WorkflowEtape|TblWorkflow|string $etape
* @param Intervenant|null $intervenant
* @param Structure|null $structure
*
* @return WorkflowEtape
*/
public
function
getNextAccessibleEtape
(
$etape
,
Intervenant
$intervenant
=
null
,
Structure
$structure
=
null
)
{
[
$etapeCode
,
$intervenant
,
$structure
]
=
$this
->
prepareEtapeParams
(
$etape
,
$intervenant
,
$structure
);
$fdr
=
$this
->
getFeuilleDeRoute
(
$intervenant
,
$structure
);
$isCurrent
=
false
;
foreach
(
$fdr
as
$etape
)
{
if
(
$isCurrent
&&
$etape
->
isAtteignable
()
&&
$etape
->
getFranchie
()
<
1
&&
$etape
->
getUrl
()
&&
$this
->
isAllowed
(
$etape
))
{
return
$etape
;
}
if
(
$etape
->
getEtape
()
->
getCode
()
==
$etapeCode
)
{
$isCurrent
=
true
;
}
}
return
$
etapes
;
return
$
this
->
getEtapeCourante
(
$intervenant
,
$structure
)
;
}
/**
* Generates a url given the name of a route.
*
* @param string $name Name of the route
* @param array $params Parameters for the link
* @param array|Traversable $options Options for the route
* @param bool $reuseMatchedParams Whether to reuse matched parameters
*
* @return string Url For the link href attribute
* @see \Laminas\Mvc\Router\RouteInterface::assemble()
*
* @return $this
* @throws \Doctrine\DBAL\DBALException
*/
p
rotected
function
getUrl
(
$name
=
null
,
$params
=
[],
$options
=
[],
$reuseMatchedParams
=
false
)
p
ublic
function
calculerTout
(
)
{
$
url
=
\Application
::
$container
->
get
(
'ViewHelperManager'
)
->
get
(
'url
'
);
$
this
->
getServiceTableauBord
()
->
calculer
(
'workflow
'
);
/* @var $url \Laminas\View\Helper\Url */
return
$url
->
__invoke
(
$name
,
$params
,
$options
,
$reuseMatchedParams
);
return
$this
;
}
/**
* @return int
* @throws \Doctrine\DBAL\DBALException
*/
public
function
calculerTousTableauxBord
(
$beforeTrigger
=
null
,
$afterTrigger
=
null
)
{
$sql
=
"SELECT tbl_name FROM tbl WHERE tbl_name <> 'formule' ORDER BY ordre"
;
$tbls
=
$this
->
getEntityManager
()
->
getConnection
()
->
fetchAllAssociative
(
$sql
);
$result
=
true
;
foreach
(
$tbls
as
$tbl
)
{
$begin
=
microtime
(
true
);
$tbl
=
$tbl
[
'TBL_NAME'
];
$sql
=
'BEGIN UNICAEN_TBL.CALCULER(\''
.
$tbl
.
'\'); END;'
;
if
(
$beforeTrigger
instanceof
\Closure
)
{
$beforeTrigger
([
'tableau-bord'
=>
$tbl
,
]);
}
try
{
$this
->
getEntityManager
()
->
getConnection
()
->
executeStatement
(
$sql
);
if
(
$afterTrigger
instanceof
\Closure
)
{
$afterTrigger
([
'tableau-bord'
=>
$tbl
,
'result'
=>
true
,
'duree'
=>
microtime
(
true
)
-
$begin
,
]);
}
}
catch
(
\Exception
$e
)
{
if
(
$afterTrigger
instanceof
\Closure
)
{
$afterTrigger
([
'tableau-bord'
=>
$tbl
,
'result'
=>
false
,
'exception'
=>
$e
,
'duree'
=>
microtime
(
true
)
-
$begin
,
]);
}
$result
=
false
;
}
}
return
$result
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment