Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
open-source
OSE
Commits
afed0f43
Commit
afed0f43
authored
Jun 01, 2021
by
Laurent Lécluse
Browse files
Conservation des fractions pour les types d'intervention
parent
375f37aa
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
afed0f43
# OSE 16 (à venir)
Objectif : Connecteur Export OSE => Logiciel RH
Objectif : Connecteur Export OSE => Logiciel RH
+ import Actul+
# OSE 15.2 (à venir)
## Nouveautés
*
Au niveau des types d'intervention, il est désormais possible de saisir des fractions (2/3 TP par exemple)
## Corrections de bugs
*
Vérification que le champs 'numéro de rue' contient uniquement des chiffres lors de l'enregistrement des données personnelles (#37492)
...
...
module/Application/src/Application/Filter/FloatFromString.php
View file @
afed0f43
...
...
@@ -9,12 +9,26 @@ class FloatFromString extends AbstractFilter
private
static
$instance
;
public
function
filter
(
$value
)
{
if
(
$value
===
''
)
return
null
;
$value
=
preg_replace
(
"/[^0-9,\.-]/"
,
""
,
$value
);
$value
=
str_replace
(
','
,
'.'
,
$value
);
if
(
false
!==
strpos
(
$value
,
'/'
))
{
[
$f1
,
$f2
]
=
explode
(
'/'
,
$value
);
return
$this
->
convert
(
$f1
)
/
$this
->
convert
(
$f2
);
}
else
{
return
$this
->
convert
(
$value
);
}
}
protected
function
convert
(
$value
):
float
{
$value
=
preg_replace
(
"/[^0-9,\.-]/"
,
""
,
$value
);
$value
=
str_replace
(
','
,
'.'
,
$value
);
$value
=
floatval
(
$value
);
return
$value
;
...
...
@@ -22,12 +36,12 @@ class FloatFromString extends AbstractFilter
public
static
function
run
(
$value
)
public
static
function
run
(
$value
)
{
if
(
!
self
::
$instance
){
if
(
!
self
::
$instance
)
{
self
::
$instance
=
new
self
;
}
return
self
::
$instance
->
filter
(
$value
);
return
self
::
$instance
->
filter
(
$value
);
}
}
\ No newline at end of file
module/Application/src/Application/Filter/StringFromFloat.php
View file @
afed0f43
...
...
@@ -9,22 +9,56 @@ class StringFromFloat extends AbstractFilter
{
private
static
$instance
;
private
$fractions
=
[
[
'f'
=>
0.333333
,
's'
=>
'1/3'
],
[
'f'
=>
0.166667
,
's'
=>
'1/6'
],
[
'f'
=>
0.142857
,
's'
=>
'1/7'
],
[
'f'
=>
0.111111
,
's'
=>
'1/9'
],
[
'f'
=>
0.666667
,
's'
=>
'2/3'
],
[
'f'
=>
0.285714
,
's'
=>
'2/7'
],
[
'f'
=>
0.222222
,
's'
=>
'2/9'
],
[
'f'
=>
0.428571
,
's'
=>
'3/7'
],
[
'f'
=>
1.333333
,
's'
=>
'4/3'
],
[
'f'
=>
0.571429
,
's'
=>
'4/7'
],
[
'f'
=>
0.444444
,
's'
=>
'4/9'
],
[
'f'
=>
1.666667
,
's'
=>
'5/3'
],
[
'f'
=>
0.833333
,
's'
=>
'5/6'
],
[
'f'
=>
0.714286
,
's'
=>
'5/7'
],
[
'f'
=>
0.555556
,
's'
=>
'5/9'
],
[
'f'
=>
0.857143
,
's'
=>
'6/7'
],
[
'f'
=>
2.333333
,
's'
=>
'7/3'
],
[
'f'
=>
1.166667
,
's'
=>
'7/6'
],
[
'f'
=>
0.777778
,
's'
=>
'7/9'
],
[
'f'
=>
2.666667
,
's'
=>
'8/3'
],
[
'f'
=>
1.142857
,
's'
=>
'8/7'
],
[
'f'
=>
0.888889
,
's'
=>
'8/9'
],
[
'f'
=>
1.285714
,
's'
=>
'9/7'
],
];
public
function
filter
(
$value
,
$show0Digits
=
true
)
public
function
filter
(
$value
,
$show0Digits
=
true
)
{
$valfrac
=
round
(
$value
,
6
);
foreach
(
$this
->
fractions
as
$fs
)
{
if
(
$fs
[
'f'
]
===
$valfrac
)
{
return
$fs
[
's'
];
}
}
$res
=
Util
::
formattedFloat
(
$value
);
if
(
!
$show0Digits
){
$res
=
str_replace
(
',00'
,
''
,
$res
);
if
(
!
$show0Digits
)
{
$res
=
str_replace
(
',00'
,
''
,
$res
);
}
return
$res
;
}
public
static
function
run
(
$value
,
$show0Digits
=
true
)
public
static
function
run
(
$value
,
$show0Digits
=
true
)
{
if
(
!
self
::
$instance
){
if
(
!
self
::
$instance
)
{
self
::
$instance
=
new
self
;
}
...
...
module/Application/src/Application/View/Helper/TypeInterventionAdminViewHelper.php
View file @
afed0f43
...
...
@@ -2,10 +2,9 @@
namespace
Application\View\Helper
;
use
Application\Entity\Db\TypeInterventionStatut
;
use
Application\Entity\Db\TypeIntervention
;
use
Application\Filter\StringFromFloat
;
use
Application\Service\Traits\TypeInterventionServiceAwareTrait
;
use
UnicaenApp\Util
;
/**
* Aide de vue permettant d'afficher une liste de statuts
...
...
@@ -88,7 +87,7 @@ class TypeInterventionAdminViewHelper extends AbstractViewHelper
*/
public
function
render
(
$details
=
false
)
{
$ti
=
$this
->
getTypeIntervention
();
$ti
=
$this
->
getTypeIntervention
();
$title
=
''
;
$statuts
=
$ti
->
getTypeInterventionStatut
();
...
...
@@ -96,7 +95,7 @@ class TypeInterventionAdminViewHelper extends AbstractViewHelper
if
(
$title
)
$title
.
=
' - '
;
$title
.
=
$tis
->
getStatutIntervenant
()
->
getLibelle
();
}
$etoile
=
(
strlen
(
$title
)
?
'★'
:
''
);
$etoile
=
(
strlen
(
$title
)
?
'★'
:
''
);
$url
=
$this
->
getView
()
->
url
(
'type-intervention/statut'
,
[
'typeIntervention'
=>
$ti
->
getId
()]);
...
...
@@ -108,7 +107,7 @@ class TypeInterventionAdminViewHelper extends AbstractViewHelper
'title'
=>
$title
,
'href'
=>
$url
,
'data-submit-reload'
=>
'true'
,
])
->
text
(
Util
::
formattedNumber
(
$ti
->
getTauxHetdService
())
.
$etoile
);
])
->
text
(
StringFromFloat
::
run
(
$ti
->
getTauxHetdService
())
.
$etoile
);
$html
.
=
'</td><td>'
;
$html
.
=
$this
->
getView
()
->
tag
(
'a'
,
[
...
...
@@ -118,9 +117,9 @@ class TypeInterventionAdminViewHelper extends AbstractViewHelper
'title'
=>
$title
,
'href'
=>
$url
,
'data-submit-reload'
=>
'true'
,
])
->
text
(
Util
::
formattedNumber
(
$ti
->
getTauxHetdComplementaire
())
.
$etoile
);
])
->
text
(
StringFromFloat
::
run
(
$ti
->
getTauxHetdComplementaire
())
.
$etoile
);
$html
.
=
'</td>'
;
$html
.
=
'</td>'
;
return
$html
;
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment