Commit cceb3801 authored by tguillon's avatar tguillon
Browse files

Factorisation : de la génération des champs pour la configuration des champs dans le formulaire.

Modification : pour supprimer un traitement on doit obligatoirement désactiver celui-ci afin de le supprimer.
Modification : il n'est plus possible de changer le nom de variable d'un champ déjà existant dans un formulaire.
Modification : remise en forme des champs entre le formulaire et la déclaration d'un traitement afin qu'il soit identique
Modification : lors de la connexion et/ou changement d'entité de l'utilisateur ou récupèrent les services auxquels il appartient afin de les écrire en session
parent e14b1e54
......@@ -390,20 +390,6 @@ class FichesController extends AppController
$this->request->data['Fiche']['declarantpersonneemail'] = $userLog['User']['email'];
$this->request->data['Fiche']['declarantpersonnefix'] = $userLog['User']['telephonefixe'];
$this->request->data['Fiche']['declarantpersonneportable'] = $userLog['User']['telephoneportable'];
// $service = $this->OrganisationUser->find('all', [
// 'conditions' => [
// 'user_id' => $this->Auth->user('id'),
// 'organisation_id' => $this->Session->read('Organisation.id')
// ],
// 'contain' => [
// 'OrganisationUserService' => [
// 'Service'
// ]
// ]
// ]);
// $serviceUser = Hash::extract($service, '{n}.OrganisationUserService.Service');
// $listeUserService = Hash::combine($serviceUser, '{n}.libelle', '{n}.libelle');
}
$this->set(compact('champs', 'options_normes', 'descriptions_normes', 'soustraitance', 'soustraitants', 'responsables'));
......
......@@ -597,6 +597,25 @@ class OrganisationsController extends AppController
]);
$this->Session->write('Organisation', $change['Organisation']);
$service = $this->OrganisationUser->find('all', [
'conditions' => [
'user_id' => $userId,
'organisation_id' => $id
],
'contain' => [
'OrganisationUserService' => [
'Service'
]
]
]);
$serviceUser = Hash::extract($service, '{n}.OrganisationUserService.Service');
$serviceUser = Hash::combine($serviceUser, '{n}.id', '{n}.libelle');
$this->Session->write('User.service', $serviceUser);
if(!empty($this->Session->read('Auth.User.uuid'))){
$this->Session->delete('Auth.User.uuid');
}
$droits = $this->Droit->find('all', [
'conditions' => [
'OrganisationUser.user_id' => $userId,
......
......@@ -834,20 +834,19 @@ class UsersController extends AppController {
$this->Session->write('Su', false);
}
$service = $this->OrganisationUser->find('all', [
'conditions' => [
'user_id' => $this->Auth->user('id')
],
'contain' => [
'OrganisationUserService' => [
'Service'
]
]
]);
$serviceUser = Hash::extract($service, '{n}.OrganisationUserService.Service');
$serviceUser = Hash::combine($serviceUser, '{n}.id', '{n}.libelle');
$this->Session->write('User.service', $serviceUser);
// $service = $this->OrganisationUser->find('all', [
// 'conditions' => [
// 'user_id' => $this->Auth->user('id')
// ],
// 'contain' => [
// 'OrganisationUserService' => [
// 'Service'
// ]
// ]
// ]);
// $serviceUser = Hash::extract($service, '{n}.OrganisationUserService.Service');
// $serviceUser = Hash::combine($serviceUser, '{n}.id', '{n}.libelle');
// $this->Session->write('User.service', $serviceUser);
if(!empty($this->Session->read('Auth.User.uuid'))){
$this->Session->delete('Auth.User.uuid');
......
......@@ -320,3 +320,6 @@ msgstr "Veuillez entrer une norme non existante"
msgid "Validate::checkNotBlankIf"
msgstr "Champ obligatoire"
msgid "Validate::multiple"
msgstr "Champ obligatoire"
......@@ -11,9 +11,7 @@ $line = 1;
<div class="col-md-6">
<?php
$incrementation_id = 0;
foreach ($champs
as $value) {
foreach ($champs as $value) {
if ($value['Champ']['colonne'] > $col) {
?>
</div>
......@@ -35,7 +33,9 @@ $line = 1;
$options = json_decode($value['Champ']['details'], true);
?>
<div class="row row35">
<!-- <div class="row row35">-->
<!-- <div class="col-md-12">-->
<div class="users form">
<div class="col-md-12">
<?php
switch ($value['Champ']['type']) {
......@@ -147,9 +147,9 @@ $line = 1;
// Menu multi-select
case 'multi-select':
echo $this->WebcilForm->input($options['name'], [
'id' => $options['name'],
'options' => $options['options'],
'class' => 'form-group multiSelect',
'id' => $options['name'],
'label' => [
'text' => $options['label'],
'class' => 'col-md-4'
......@@ -181,12 +181,12 @@ $line = 1;
</label>
</div>
<div class="col-md-8" <?php if ($options['obligatoire']): echo 'required="required"'; endif;?>>
<input type="hidden" name="data[<?php echo $modelName;?>][<?php echo $fieldName;?>]" value="" />
<input type="hidden" id="<?php echo $options['name']; ?>" name="data[<?php echo $modelName;?>][<?php echo $fieldName;?>]" value="" />
<?php
foreach ($options['options'] as $key => $val) {
$checked = $val === $this->request->data("{$modelName}.{$fieldName}") ? ' checked="checked"' : '';
$checked = $val == $this->request->data("{$modelName}.{$fieldName}") ? ' checked="checked"' : '';
echo '<div class="radio">
<input type="radio" name="data['.$modelName.']['.$fieldName.']" value="'.$val.'" '.$checked.'>
<input type="radio" id="'.$options['name'].$key.'" name="data['.$modelName.']['.$fieldName.']" value="'.$val.'" '.$checked.'>
'.$val.'
</div>';
}
......@@ -207,4 +207,27 @@ $line = 1;
</div>
</div>
</div>
<!-- Fin onglet Formulaire -->
\ No newline at end of file
<!-- Fin onglet Formulaire -->
<script type="text/javascript">
$(document).ready(function () {
$('.multiSelect').select2({
placeholder: "Sélectionnez une ou plusieurs options",
allowClear: true
});
var incrementationId = <?php echo json_encode($incrementation_id)?>;
for (var i = 0; i < incrementationId; i++) {
$('#datetimepicker' + i).datetimepicker({
viewMode: 'year',
startView: 'decade',
format: 'dd/mm/yyyy',
minView: 2,
language: 'fr'
});
}
});
</script>
\ No newline at end of file
......@@ -31,7 +31,7 @@ foreach ($champs as $key => $value) {
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<input type="text" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '" class="form-control"/>'
. '<input type="text" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '" class="form-control champNomVariableReadonly"/>'
. '</div>'
. '</div>';
break;
......@@ -46,7 +46,7 @@ foreach ($champs as $key => $value) {
. '</label>'
. '</div>'
. '<div class="col-md-8">'
. '<textarea type="textarea" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '"class="form-control" cols="30" rows="6"></textarea>'
. '<textarea type="textarea" name="' . $details['name'] . '" checked="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '"class="form-control champNomVariableReadonly" cols="30" rows="6"></textarea>'
. '</div>'
. '</div>';
break;
......@@ -60,12 +60,8 @@ foreach ($champs as $key => $value) {
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
. '</label>'
. '</div>'
. '<div class="container">'
. '<div class="row">'
. '<div class="col-sm-5">'
. '<input type="date" class="form-control" id="' . $details['name'] . '" name="' . $details['name'] . '" required="' . $details['obligatoire'] . '" placeholder="' . $details['placeholder'] . '"></input>'
. '</div>'
. '</div>'
. '<div class="col-md-8">'
. '<input class="form-control champNomVariableReadonly" id="'.$details['name'].'" name="'.$details['name'].'" required="'.$details['obligatoire'].'" placeholder="'.$details['placeholder'].'"/>'
. '</div>'
. '</div>';
......@@ -101,7 +97,7 @@ foreach ($champs as $key => $value) {
echo '<div class="col-md-8 contentCheckbox">';
foreach ($details['options'] as $key => $val) {
echo '<div class="checkbox">'
. '<input type="checkbox" name="'.$details['name'].'" value="'.$val.'" id="x'.$key.'"><label for="x'.$key.'">'.$val.'</label></div>';
. '<input class="champNomVariableReadonly" type="checkbox" name="'.$details['name'].'" value="'.$val.'" id="x'.$key.'"><label for="x'.$key.'">'.$val.'</label></div>';
}
echo '</div>
</div>
......@@ -120,7 +116,7 @@ foreach ($champs as $key => $value) {
. '</div>'
. '<div class="col-md-8 contentRadio">';
foreach ($details['options'] as $val) {
echo '<div class="radio"><input type="radio" name="'.$details['name'].'" value="'.$val.'">'.$val.'</div>';
echo '<div class="radio"><input class="champNomVariableReadonly" type="radio" name="'.$details['name'].'" value="'.$val.'">'.$val.'</div>';
}
echo '</div></div>';
break;
......@@ -137,7 +133,7 @@ foreach ($champs as $key => $value) {
. '<div class="col-md-8">'
. '<select class="form-control contentDeroulant" name ="' . $details['name'] . '">';
foreach ($details['options'] as $val) {
echo '<option type="deroulant" name ="' . $details['name'] . '" value="' . $val . '"> ' . $val . '</option></div>';
echo '<option class="champNomVariableReadonly" type="deroulant" name ="' . $details['name'] . '" value="' . $val . '"> ' . $val . '</option></div>';
}
echo '</select>'
. '</div>'
......@@ -145,22 +141,22 @@ foreach ($champs as $key => $value) {
break;
case 'multi-select' :
echo '<div class="draggable col-md-6 form-group multi-select" style="top:' . $line . 'px; ' . $colonne . '" data="' . $champObligatoire . '">'
echo '<div class="draggable col-md-6 form-group multi-select" style="top:'.$line.'px; '.$colonne.'" data="'.$champObligatoire.'">'
.'<div class="col-md-4">'
.'<label>'
.'<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
.'</label>'
.'<label>'
.'<span class="labeler">' . $details['label'] . '</span>'
. ($details['obligatoire'] ? '<span class="obligatoire"> *</span>' : '')
.'</label>'
.'</div>'
.'<div class="col-md-8">'
.'<input type="hidden" name="multi-select" value="" id="multi-select_"/>'
.'<select id="' . $details['name'] . '" name="multi-select" class="form-control multiSelect contentMultiSelect" multiple="multiple">';
foreach ($details['options'] as $val) {
echo '<option name="' . $details['name'] . '" value="' . $val . '"> ' . $val . '</option>';
}
echo '</select>'
.'<input type="hidden" name="multi-select" value="" id="multi-select_"/>'
.'<select id="'.$details['name'].'" name="multi-select" class="form-control multiSelect contentMultiSelect" multiple="multiple">';
foreach ($details['options'] as $val) {
echo '<option class="champNomVariableReadonly" name="'.$details['name'].'" value="'.$val.'"> '.$val.'</option>';
}
echo '</select>'
.'</div>'
.'</div>';
.'</div>';
break;
// Label
......@@ -174,4 +170,28 @@ foreach ($champs as $key => $value) {
break;
}
}
?>
\ No newline at end of file
?>
<script type="text/javascript">
$(document).ready(function () {
var champsDate = <?php echo json_encode($calendrier)?>;
jQuery.each(champsDate, function(key, val){
$('#' + val).datetimepicker({
viewMode: 'year',
startView: 'decade',
format: 'dd/mm/yyyy',
format: 'dd/mm/yyyy',
minView: 2,
language: 'fr'
});
});
$('.multiSelect').select2({
placeholder: "Sélectionnez une option",
allowClear: true
});
});
</script>
......@@ -421,11 +421,6 @@ require_once dirname(__FILE__).DS.'model_extention.ctp';
$(a).append("<span class='fa fa-exclamation-circle fa-danger' aria-hidden='true'><!----><\/span>");
});
$('.multiSelect').select2({
placeholder: "Sélectionnez une ou plusieurs options",
allowClear: true
});
// Mask champs
// Information sur le rédacteur
$('#declarantpersonneportable').mask("00 00 00 00 00", {placeholder: "__ __ __ __ __"});
......
......@@ -394,11 +394,6 @@ require_once dirname(__FILE__).DS.'model_extention.ctp';
$( "a[href='#"+$(pane).attr('id')+"']" ).append("<span class='fa fa-exclamation-circle fa-danger' aria-hidden='true'><!----></span>");
});
$('.multiSelect').select2({
placeholder: "Sélectionnez une ou plusieurs options",
allowClear: true
});
// Mask champs
// Information sur le rédacteur
$('#declarantpersonneportable').mask("00 00 00 00 00", {placeholder: "__ __ __ __ __"});
......
This diff is collapsed.
......@@ -131,13 +131,4 @@ echo $this->Html->css([
// Fin onglet Information sur l'entité
?>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('.multiSelect').select2({
placeholder: "Sélectionnez une option",
allowClear: true
});
});
</script>
\ No newline at end of file
</div>
\ No newline at end of file
......@@ -154,7 +154,7 @@
</button>
<?php
if ($valid[$data['Formulaire']['id']] == true) {
if ($valid[$data['Formulaire']['id']] == true && $data['Formulaire']['active'] == false) {
//Bouton supprimé le formulaire
echo $this->Html->link('<span class="fa fa-trash fa-lg"><!----></span>', [
'controller' => 'formulaires',
......
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