Commit e76b6bce authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Correction : modification des options des champs horsUE et donneeSensible dans...

Correction : modification des options des champs horsUE et donneeSensible dans le formulaire pour correspondre aux valeurs dans un traitement
Ajout : création des conditions en fonction du paramétrage dans le formulaire
parent b011d121
......@@ -7,6 +7,8 @@ echo $this->Html->script([
echo $this->Html->css('/js/smalot-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min');
$calendrier = [];
$conditions = [];
$col = 1;
$line = 1;
?>
......@@ -35,6 +37,9 @@ $line = 1;
}
$options = json_decode($value['Champ']['details'], true);
$fieldConditions = json_decode($options['conditions'], true);
$conditions = array_merge($conditions, $fieldConditions);
?>
<div class="row row35">
......@@ -209,6 +214,7 @@ $line = 1;
<!-- Fin onglet Formulaire -->
<script type="text/javascript">
$(document).ready(function () {
$('.multiSelect').select2({
......@@ -264,5 +270,37 @@ $line = 1;
});
});
// Mise en place des conditions
var conditions = <?php echo json_encode($conditions); ?>;
$.each(conditions, function (key, value) {
if (value['ifNot'] == 'shown') {
$('#' + value['thenTheField']).parent().parent().show();
} else {
$('#' + value['thenTheField']).parent().parent().hide();
}
$('#'+value['ifTheField']).change(function(){
var val = $(this).val();
if (val == value['hasValue']) {
if (value['mustBe'] == 'shown') {
$('#' + value['thenTheField']).parent().parent().show();
} else {
$('#' + value['thenTheField']).parent().parent().hide();
}
} else {
if (value['ifNot'] == 'shown') {
$('#' + value['thenTheField']).parent().parent().show();
} else {
$('#' + value['thenTheField']).parent().parent().hide();
}
}
});
});
function createConditions(value)
{
}
});
</script>
\ No newline at end of file
......@@ -84,8 +84,8 @@
'Fiche.transfertHorsUe' => [
'id' => 'transfertHorsUe',
'options' => [
true => 'Oui',
false => 'Non'
'Oui' => 'Oui',
'Non' => 'Non'
],
'class' => 'transformSelect form-control',
'placeholder' => false,
......@@ -97,8 +97,8 @@
'Fiche.donneesSensible' => [
'id' => 'donneesSensible',
'options' => [
true => 'Oui',
false => 'Non'
'Oui' => 'Oui',
'Non' => 'Non'
],
'class' => 'transformSelect form-control',
'placeholder' => false,
......
......@@ -884,6 +884,7 @@ var createForm = function(typeCreateForm) {
*/
function writeConditionsInOption(conditions) {
var writeConditions = '';
var success = true;
$.each(JSON.parse(conditions), function (key, value) {
var ifTheField = $('#'+value['ifTheField']).labels().text();
......@@ -892,6 +893,12 @@ var createForm = function(typeCreateForm) {
var mustBe = '';
var ifNot = '';
if (!ifTheField) {
alert("Une condition est en erreur !");
success = false;
return success;
}
if (!hasValue) {
var val_id = $('input[value="'+value['hasValue']+'"]').attr('id');
hasValue = $('label[for="'+val_id+'"]').text();
......@@ -936,9 +943,11 @@ var createForm = function(typeCreateForm) {
'</p>';
});
writeConditions = '<div class="col-md-12">' +
writeConditions+
'</div>';
if (success == true) {
writeConditions = '<div class="col-md-12">' +
writeConditions +
'</div>';
}
return writeConditions;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment