Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
autoform
Commits
24e94e83
Commit
24e94e83
authored
4 months ago
by
Jean-Philippe Metivier
Browse files
Options
Downloads
Patches
Plain Diff
Récup des champs historisés pour la partie as Text ou Result (todo ? From)
parent
3e974f1a
No related branches found
No related tags found
No related merge requests found
Pipeline
#38411
passed
4 months ago
Stage: publish
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenAutoform/View/Helper/ChampAsResultHelper.php
+7
-11
7 additions, 11 deletions
src/UnicaenAutoform/View/Helper/ChampAsResultHelper.php
src/UnicaenAutoform/View/Helper/InstanceAsTextHelper.php
+13
-5
13 additions, 5 deletions
src/UnicaenAutoform/View/Helper/InstanceAsTextHelper.php
with
20 additions
and
16 deletions
src/UnicaenAutoform/View/Helper/ChampAsResultHelper.php
+
7
−
11
View file @
24e94e83
...
...
@@ -2,6 +2,7 @@
namespace
UnicaenAutoform\View\Helper
;
use
DateTime
;
use
UnicaenAutoform\Entity\Db\Champ
;
use
UnicaenAutoform\Service\Champ\ChampServiceAwareTrait
;
use
Laminas\Form\View\Helper\AbstractHelper
;
...
...
@@ -12,12 +13,8 @@ class ChampAsResultHelper extends AbstractHelper
{
use
ChampServiceAwareTrait
;
/**
* @param Champ $champ
* @param array $data
* @return string
*/
public
function
render
(
$champ
,
$data
=
null
)
{
public
function
render
(
Champ
$champ
,
$data
=
null
,
?DateTime
$date
=
null
)
:
string
{
$texte
=
""
;
/** @var PhpRenderer $view */
...
...
@@ -25,10 +22,9 @@ class ChampAsResultHelper extends AbstractHelper
$view
->
resolver
()
->
attach
(
new
TemplatePathStack
([
'script_paths'
=>
[
__DIR__
.
"/partial"
]]));
switch
(
$champ
->
getType
()
->
getCode
())
{
case
Champ
::
TYPE_LABEL
:
return
""
;
break
;
case
Champ
::
TYPE_SPACER
:
return
""
;
break
;
case
Champ
::
TYPE_LABEL
:
case
Champ
::
TYPE_SPACER
:
return
""
;
case
Champ
::
TYPE_CHECKBOX
:
$texte
.
=
$view
->
partial
(
'result/checkbox'
,
[
'champ'
=>
$champ
,
'data'
=>
$data
]);
break
;
...
...
@@ -97,7 +93,7 @@ class ChampAsResultHelper extends AbstractHelper
break
;
}
if
(
!
$champ
->
estNonHistorise
())
{
if
(
!
$champ
->
estNonHistorise
(
$date
))
{
$texte
=
"<span class='result-historiser'>"
.
$texte
.
"</span>"
;
}
if
(
$texte
!=
""
)
$texte
=
"<li>"
.
$texte
.
"</li>"
;
...
...
This diff is collapsed.
Click to expand it.
src/UnicaenAutoform/View/Helper/InstanceAsTextHelper.php
+
13
−
5
View file @
24e94e83
...
...
@@ -2,6 +2,7 @@
namespace
UnicaenAutoform\View\Helper
;
use
DateTime
;
use
UnicaenAutoform\Entity\Db\Categorie
;
use
UnicaenAutoform\Entity\Db\Champ
;
use
UnicaenAutoform\Entity\Db\FormulaireInstance
;
...
...
@@ -15,7 +16,8 @@ class InstanceAsTextHelper extends AbstractHelper
* @param string $categorie_code
* @return string
*/
public
function
render
(
$instance
,
$categorie_code
=
null
)
{
public
function
render
(
FormulaireInstance
$instance
,
?DateTime
$date
=
null
,
string
$categorie_code
=
null
)
{
$formulaire
=
$instance
->
getFormulaire
();
$reponsesTMP
=
$instance
->
getReponses
();
$reponsesTMP
=
array_filter
(
$reponsesTMP
,
function
(
FormulaireReponse
$r
)
{
return
$r
->
estNonHistorise
();
});
...
...
@@ -27,7 +29,11 @@ class InstanceAsTextHelper extends AbstractHelper
$text
=
""
;
$categories
=
$formulaire
->
getCategories
();
$categories
=
array_filter
(
$categories
,
function
(
Categorie
$categorie
)
{
return
$categorie
->
estNonHistorise
();});
$categories
=
array_filter
(
$categories
,
function
(
Categorie
$categorie
)
use
(
$date
)
{
$wasExisting
=
(
$categorie
->
getHistoCreation
()
===
null
or
$categorie
->
getHistoCreation
()
<=
$date
);
$wasntHistorise
=
(
$categorie
->
getHistoDestruction
()
===
null
or
$categorie
->
getHistoDestruction
()
>=
$date
);
return
(
$wasExisting
and
$wasntHistorise
);
});
usort
(
$categories
,
function
(
Categorie
$a
,
Categorie
$b
)
{
return
$a
->
getOrdre
()
-
$b
->
getOrdre
();});
...
...
@@ -35,8 +41,10 @@ class InstanceAsTextHelper extends AbstractHelper
if
(
$categorie_code
===
null
OR
$categorie_code
===
$categorie
->
getCode
())
{
$champs
=
$categorie
->
getChamps
();
$champs
=
array_filter
(
$champs
,
function
(
Champ
$champ
)
{
return
$champ
->
estNonHistorise
();
$champs
=
array_filter
(
$champs
,
function
(
Champ
$champ
)
use
(
$date
)
{
$wasExisting
=
(
$champ
->
getHistoCreation
()
===
null
or
$champ
->
getHistoCreation
()
<=
$date
);
$wasntHistorise
=
(
$champ
->
getHistoDestruction
()
===
null
or
$champ
->
getHistoDestruction
()
>=
$date
);
return
(
$wasExisting
and
$wasntHistorise
);
});
usort
(
$champs
,
function
(
Champ
$a
,
Champ
$b
)
{
return
$a
->
getOrdre
()
<=>
$b
->
getOrdre
();
...
...
@@ -55,7 +63,7 @@ class InstanceAsTextHelper extends AbstractHelper
foreach
(
$champs
as
$champ
)
{
if
(
isset
(
$reponses
[
$champ
->
getId
()]))
{
// var_dump($reponses[$champ->getId()]->getReponse());
$text
.
=
$this
->
getView
()
->
champAsResult
()
->
render
(
$champ
,
$reponses
[
$champ
->
getId
()]
->
getReponse
());
$text
.
=
$this
->
getView
()
->
champAsResult
()
->
render
(
$champ
,
$reponses
[
$champ
->
getId
()]
->
getReponse
()
,
$date
);
}
}
$text
.
=
'</ul>'
;
...
...
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
sign in
to comment