1 |
<?php |
<?php |
2 |
|
/** |
3 |
|
* Script personnalisé pour les consultations multiples. |
4 |
|
* |
5 |
|
* @package openfoncier |
6 |
|
* @version SVN : $Id$ |
7 |
|
*/ |
8 |
|
|
9 |
require_once "../obj/utils.class.php"; |
require_once "../obj/utils.class.php"; |
10 |
|
|
11 |
// Identifiant de l'objet metier a copier |
// Identifiant de l'objet metier a copier |
12 |
(isset($_GET['idx']) ? $idx = $_GET['idx'] : $idx = ""); |
(isset($_GET['idx']) ? $idx = $_GET['idx'] : $idx = ""); |
13 |
// Nom de l'objet metier |
// Nom de l'objet metier |
14 |
(isset($_GET['obj']) ? $obj = $_GET['obj'] : $obj = ""); |
(isset($_GET['obj']) ? $obj = $_GET['obj'] : $obj = ""); |
15 |
|
//formulaire retour |
16 |
|
(isset($_GET['ret']) ? $retourformulaire = $_GET['ret'] : $retourformulaire = ""); |
17 |
|
(isset($_GET['date_envoi']) ? $date_envoi = $_GET['date_envoi'] : $date_envoi = ""); |
18 |
|
|
19 |
$f = new utils("nohtml"); |
$f = new utils("nohtml"); |
20 |
|
|
21 |
$liste_gauche = ""; |
$liste_gauche = ""; |
22 |
|
|
23 |
/*Requête qui récupère les services qui sont dans des thématiques*/ |
if ( isset($_GET) && isset($_GET['data']) && !empty($_GET['data']) ){ |
24 |
$sql = |
$f->disableLog(); |
25 |
"SELECT |
/*Récupération des données et formatage.*/ |
26 |
ser_cat.service_categorie, ser_cat.libelle AS them_lib, |
$donnees_temp = explode(';', $_GET['data']); |
27 |
ser.service, ser.libelle AS ser_lib, ser.consultation_papier |
for ( $i = 1 ; $i < count($donnees_temp) ; $i++ ) |
28 |
FROM |
$donnees[] = explode('_', $donnees_temp[$i]); |
|
public.lien_service_service_categorie lie, |
|
|
public.service_categorie ser_cat, |
|
|
public.service ser |
|
|
WHERE |
|
|
ser_cat.service_categorie = lie.service_categorie AND |
|
|
ser.service = lie.service AND |
|
|
( |
|
|
ser.om_validite_fin <= CURRENT_DATE OR |
|
|
ser.om_validite_fin IS NULL |
|
|
) |
|
|
"; |
|
|
|
|
|
$res = $f->db->query($sql); |
|
|
$f->isDatabaseError($res); |
|
|
|
|
|
$temp_ser_cat = 0; |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
29 |
|
|
30 |
/*On change de thématique, donc rajoute le nom de la thématique*/ |
/* Nombre de consultations papier à générer */ |
31 |
if ( $temp_ser_cat != $row['service_categorie'] ){ |
$nbConsPap = 0; |
32 |
|
|
33 |
|
/* Ajout des données en base de données |
34 |
|
* 0 : l'ID du service |
35 |
|
* 1 : consultation papier {0,1} |
36 |
|
* */ |
37 |
|
if ( isset($donnees) && count($donnees) > 0 ){ |
38 |
|
|
39 |
|
require_once "../core/om_dbform.class.php"; |
40 |
|
$om_dbform = new dbForm(); |
41 |
|
require_once "../obj/consultation.class.php"; |
42 |
|
$consultation = new consultation("]",$f->db,DEBUG); |
43 |
|
|
44 |
|
foreach ($donnees as $value) { |
45 |
|
|
46 |
|
$sql = "SELECT delai FROM ".DB_PREFIXE."service WHERE service = $value[0]"; |
47 |
|
$res = $f->db->query($sql); |
48 |
|
$f->isDatabaseError($res); |
49 |
|
$row=& $res->fetchRow(); |
50 |
|
$delai = $row[0]; |
51 |
|
|
52 |
|
/*Calcul du delai de retour*/ |
53 |
|
$date_envoi_temp = $om_dbform->datePHP($date_envoi); |
54 |
|
$delai = $om_dbform->dateDB($consultation->moisdate($date_envoi_temp, $delai)); |
55 |
|
|
56 |
|
/*Les données à ajouter*/ |
57 |
|
$arrayVal = array( |
58 |
|
'consultation' => "]", |
59 |
|
'dossier' => $idx, |
60 |
|
'date_envoi' => $date_envoi, |
61 |
|
'date_retour' => NULL, |
62 |
|
'date_limite' => $delai, |
63 |
|
'service' => $value[0], |
64 |
|
'avis_consultation' => NULL, |
65 |
|
'date_reception' => NULL, |
66 |
|
'motivation' => "", |
67 |
|
'fichier' => NULL, |
68 |
|
'lu' => TRUE |
69 |
|
); |
70 |
|
|
71 |
|
$consultation->ajouter($arrayVal, $f->db, DEBUG); |
72 |
|
|
73 |
|
/*Comptage du nombre de consultations papier demandées et récupération des ids des PDFs à éditer*/ |
74 |
|
if ($value[1]==1){ |
75 |
|
$idxConsultations[] = $consultation->valF['consultation']; |
76 |
|
$nbConsPap++; |
77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
|
/*Génération du PDF*/ |
81 |
|
if ( isset($idxConsultations) && count($idxConsultations) > 0 ){ |
82 |
|
|
83 |
|
$textIdsConsultations = ""; |
84 |
|
foreach ($idxConsultations as $value) |
85 |
|
$textIdsConsultations .= "&idxConsultations[]=$value"; |
86 |
|
|
87 |
|
echo " |
88 |
|
<script language='javascript' type='text/javascript'> |
89 |
|
$.download('../app/pdfetat.php','obj=consultation_avec_avis_attendu$textIdsConsultations', 'POST', 'consultation_avec_avis_attendu'); |
90 |
|
</script> |
91 |
|
"; |
92 |
|
} |
93 |
|
/*Affichage du message d'information*/ |
94 |
|
$f->displayMessage("valid", count($donnees)._(' service(s) selectionne(s) dont ').$nbConsPap._(' consultation(s) papier.')); |
95 |
|
} |
96 |
|
|
97 |
|
} |
98 |
|
else { |
99 |
|
/*Requête qui récupère les services qui sont dans des thématiques*/ |
100 |
|
$sql = |
101 |
|
"SELECT |
102 |
|
ser_cat.service_categorie, ser_cat.libelle AS them_lib, |
103 |
|
ser.service, ser.libelle AS ser_lib, ser.consultation_papier |
104 |
|
FROM |
105 |
|
".DB_PREFIXE."lien_service_service_categorie lie, |
106 |
|
".DB_PREFIXE."service_categorie ser_cat, |
107 |
|
".DB_PREFIXE."service ser |
108 |
|
WHERE |
109 |
|
ser_cat.service_categorie = lie.service_categorie AND |
110 |
|
ser.service = lie.service AND |
111 |
|
( |
112 |
|
(ser.om_validite_debut IS NULL |
113 |
|
AND (ser.om_validite_fin IS NULL |
114 |
|
OR ser.om_validite_fin > CURRENT_DATE)) |
115 |
|
OR |
116 |
|
(ser.om_validite_debut <= CURRENT_DATE |
117 |
|
AND (ser.om_validite_fin IS NULL |
118 |
|
OR ser.om_validite_fin > CURRENT_DATE)) |
119 |
|
) |
120 |
|
ORDER BY them_lib, ser_lib |
121 |
|
"; |
122 |
|
|
123 |
|
$res = $f->db->query($sql); |
124 |
|
$f->addToLog("app/consultation_multiple.php: db->query(\"".$sql."\")", VERBOSE_MODE); |
125 |
|
$f->isDatabaseError($res); |
126 |
|
|
127 |
|
$temp_ser_cat = 0; |
128 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
129 |
|
$name = $row['service_categorie'].'_'. |
130 |
|
$row['service'].'_'. |
131 |
|
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
132 |
|
/*On change de thématique, donc rajoute le nom de la thématique*/ |
133 |
|
if ( $temp_ser_cat != $row['service_categorie'] ){ |
134 |
|
|
135 |
|
$temp_ser_cat = $row['service_categorie']; |
136 |
|
$liste_gauche .= ' |
137 |
|
<div id="them_'.$row['service_categorie'].'" class="liste_gauche_them" >'. |
138 |
|
$row['them_lib']. |
139 |
|
'</div> |
140 |
|
<div |
141 |
|
class="liste_gauche_service t'.$name.'" |
142 |
|
id="t'.$name.'" > |
143 |
|
'.$row['ser_lib'].' |
144 |
|
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
145 |
|
</div> |
146 |
|
'; |
147 |
|
} |
148 |
|
|
149 |
|
/*On est dans la même thématique*/ |
150 |
|
else { |
151 |
|
|
152 |
|
$liste_gauche .= ' |
153 |
|
<div |
154 |
|
class="liste_gauche_service t'.$name.'" |
155 |
|
id="t'.$name.'" > |
156 |
|
'.$row['ser_lib'].' |
157 |
|
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
158 |
|
</div> |
159 |
|
'; |
160 |
|
} |
161 |
|
|
|
$temp_ser_cat = $row['service_categorie']; |
|
|
$liste_gauche .= ' |
|
|
<div id="them_'.$row['service_categorie'].'" class="liste_gauche_them" >'. |
|
|
$row['them_lib']. |
|
|
'</div> |
|
|
<div |
|
|
class="liste_gauche_service" |
|
|
id="'.$row['service_categorie'].'_'.$row['service'].'_" > |
|
|
'.$row['ser_lib'].' |
|
|
<input type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/> |
|
|
</div> |
|
|
'; |
|
162 |
} |
} |
163 |
|
|
164 |
/*On est dans la même thématique*/ |
/*Requête qui récupère les services qui ne sont pas dans une thématique*/ |
165 |
else { |
$sql = |
166 |
|
"SELECT service, libelle, consultation_papier |
167 |
|
FROM ".DB_PREFIXE."service |
168 |
|
WHERE service NOT IN |
169 |
|
( |
170 |
|
SELECT service |
171 |
|
FROM ".DB_PREFIXE."lien_service_service_categorie |
172 |
|
) |
173 |
|
AND |
174 |
|
( |
175 |
|
om_validite_fin <= CURRENT_DATE OR |
176 |
|
om_validite_fin IS NULL |
177 |
|
) |
178 |
|
"; |
179 |
|
|
180 |
|
$res = $f->db->query($sql); |
181 |
|
$f->isDatabaseError($res); |
182 |
|
|
183 |
|
if ( $res->numrows() > 0 ) |
184 |
|
$liste_gauche .= ' |
185 |
|
<div id="them_0" class="liste_gauche_them">Autres</div>'; |
186 |
|
|
187 |
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
188 |
|
|
189 |
|
/*Ajout de tous les services qui n'ont pas de thématique*/ |
190 |
|
$name = '0_'. |
191 |
|
$row['service'].'_'. |
192 |
|
(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '0' : '1' ).'_'; |
193 |
$liste_gauche .= ' |
$liste_gauche .= ' |
194 |
<div |
<div |
195 |
class="liste_gauche_service" |
class="liste_gauche_service t'.$name.'" |
196 |
id="'.$row['service_categorie'].'_'.$row['service'].'_" > |
id="t'.$name.'" > |
197 |
'.$row['ser_lib'].' |
'.$row['libelle'].' |
198 |
<input type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/> |
<input class="t'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == 'f' ) ? '' : 'checked="checked"' ).'/> |
199 |
</div> |
</div> |
200 |
'; |
'; |
201 |
} |
} |
202 |
|
|
203 |
} |
/*Affichage du formulaire*/ |
204 |
|
echo '<div class="subtitle">'; |
205 |
/*Requête qui récupère les services qui ne sont pas dans une thématique*/ |
echo '<h3>'; |
206 |
$sql = |
echo _("Application"); |
207 |
"SELECT service, libelle, consultation_papier |
echo '<span class="om-icon om-icon-16 om-icon-fix arrow-right-16"></span>'; |
208 |
FROM public.service |
echo _("consultation"); |
209 |
WHERE service NOT IN |
echo '</h3>'; |
210 |
( |
echo '</div>'; |
211 |
SELECT service |
echo '<div class="sformulaire">'; |
212 |
FROM lien_service_service_categorie |
echo '<form onsubmit="ajaxIt(\'consultation\', \'../app/consultation_multiple.php\');return false;" |
213 |
) |
method="get" action="" name="f2" id="form_val">'; |
214 |
AND |
echo '<div class="formEntete ui-corner-all">'; |
215 |
( |
echo "<div>"; |
216 |
om_validite_fin <= CURRENT_DATE OR |
echo '<div class="bloc">'; |
217 |
om_validite_fin IS NULL |
echo "<fieldset class='cadre ui-corner-all ui-widget-content'>\n"; |
218 |
) |
echo "\t<legend class='ui-corner-all ui-widget-content ui-state-active'>". |
219 |
"; |
_("Consultation par thematique ")."</legend>"; |
220 |
|
echo "<div class='fieldsetContent' style='width:100%'>"; |
221 |
$res = $f->db->query($sql); |
echo '<div class="field-ser-them field-type-hiddenstatic">'; |
222 |
$f->isDatabaseError($res); |
echo '<div class="form-libelle">'; |
223 |
|
echo '<label class="libelle-dossier" for="dossier">'; |
224 |
if ( $res->numrows() > 0 ) |
echo _('dossier'); |
|
$liste_gauche .= ' |
|
|
<div id="them_0" class="liste_gauche_them">Autres</div>'; |
|
|
|
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
|
|
/*Ajout de tous les services qui n'ont pas de thématique*/ |
|
|
$liste_gauche .= ' |
|
|
<div |
|
|
class="liste_gauche_service" |
|
|
id="0_'.$row['service'].'_" > |
|
|
'.$row['libelle'].' |
|
|
<input type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/> |
|
|
</div> |
|
|
'; |
|
|
} |
|
|
|
|
|
/*Affichage du formulaire*/ |
|
|
echo '<div class="subtitle">'; |
|
|
echo '<h3>'; |
|
|
echo _("Application"); |
|
|
echo '<span class="om-icon om-icon-16 om-icon-fix arrow-right-16"></span>'; |
|
|
echo _("consultation"); |
|
|
echo '</h3>'; |
|
|
echo '</div>'; |
|
|
echo '<div class="sformulaire">'; |
|
|
echo '<form onsubmit="affichersform(\'consultation\', |
|
|
\'../scr/sousform.php?obj=consultation&premiersf=0&retourformulaire=PC& |
|
|
idxformulaire=PC12R0001&trisf=&validation=1&retour=tab\', this);return false;" |
|
|
method="post" action="" name="f2">'; |
|
|
echo '<div class="formEntete ui-corner-all">'; |
|
|
echo "<div id='form-content'>"; |
|
|
echo '<div class="bloc">'; |
|
|
echo "<fieldset class='cadre ui-corner-all ui-widget-content'>\n"; |
|
|
echo "\t<legend class='ui-corner-all ui-widget-content ui-state-active'>". |
|
|
_("Consultation par thématique ")."</legend>"; |
|
|
echo "<div class='fieldsetContent' style='width:100%'>"; |
|
|
echo '<div class="field-ser-them field-type-hiddenstatic">'; |
|
|
echo '<div class="form-libelle">'; |
|
|
echo '<label class="libelle-dossier" for="dossier">'; |
|
|
echo _('dossier'); |
|
|
echo '<span class="not-null-tag">*</span>'; |
|
|
echo '</label>'; |
|
|
echo '</div>'; |
|
|
echo '<div class="form-content">'; |
|
|
echo '<input id="dossier" class="champFormulaire" type="hidden" value="'.$idx.'" name="dossier">'; |
|
|
echo $idx; |
|
|
echo '</div>'; |
|
|
echo '</div>'; |
|
|
/*Code du nouveau champ*/ |
|
|
echo '<div class="field-ser-them ser-them">'; |
|
|
echo '<div class="list-ser-them">'; |
|
|
echo $liste_gauche; |
|
|
echo '</div>'; |
|
|
echo '<div class="button-ser-them">'; |
|
|
echo '<ul>'; |
|
|
echo '<li>'; |
|
|
echo '<input type="button" value="'._("Ajouter").' >>" id="add-ser-them"/>'; |
|
|
echo '</li>'; |
|
|
echo '<li>'; |
|
|
echo '<input type="button" value="<< '._("Supprimer").'" id="del-ser-them"/>'; |
|
|
echo '</li>'; |
|
|
echo '</ul>'; |
|
|
echo '</div>'; |
|
|
echo '<div class="list-sel-ser-them">'; |
|
|
echo '</div>'; |
|
|
echo '</div>'; |
|
|
/* -- FIN --*/ |
|
|
echo '<div class="field-ser-them field-type-date2">'; |
|
|
echo '<div class="form-libelle">'; |
|
|
echo '<label class="libelle-date_envoi" for="date_envoi">'; |
|
|
echo _('date_envoi'); |
|
225 |
echo '<span class="not-null-tag">*</span>'; |
echo '<span class="not-null-tag">*</span>'; |
226 |
echo '</label>'; |
echo '</label>'; |
227 |
|
echo '</div>'; |
228 |
|
echo '<div class="form-content">'; |
229 |
|
echo '<input class="champFormulaire" type="hidden" value="'.$idx.'" name="dossier"/>'; |
230 |
|
echo $idx; |
231 |
|
echo '</div>'; |
232 |
echo '</div>'; |
echo '</div>'; |
233 |
echo '<div class="form-content">'; |
/*Code du nouveau champ*/ |
234 |
echo '<input id="date_envoi" class="champFormulaire datepicker" |
echo '<div class="field-ser-them ser-them">'; |
235 |
type="text" onkeyup="" onchange="fdate(this)" |
echo '<div class="list-ser-them">'; |
236 |
maxlength="10" size="12" value="'.date("d/m/Y").'" |
echo $liste_gauche; |
237 |
name="date_envoi">'; |
echo '</div>'; |
238 |
|
echo '<div class="button-ser-them">'; |
239 |
|
echo '<ul>'; |
240 |
|
echo '<li>'; |
241 |
|
echo '<input type="button" value="'._("Ajouter").' >>" id="add-ser-them"/>'; |
242 |
|
echo '</li>'; |
243 |
|
echo '<li>'; |
244 |
|
echo '<input type="button" value="<< '._("Supprimer").'" id="del-ser-them"/>'; |
245 |
|
echo '</li>'; |
246 |
|
echo '</ul>'; |
247 |
|
echo '</div>'; |
248 |
|
echo '<div class="list-sel-ser-them">'; |
249 |
|
echo '<div class=\'row\'>'; |
250 |
|
echo '<div class=\'cell1 liste_droite_title list-sel-ser-them-title\'>'._('Service a consulter').'</div>'; |
251 |
|
echo '<div class=\'cell2 liste_droite_title list-sel-ser-them-title\'>'._('Version papier').'</div>'; |
252 |
|
echo '</div>'; |
253 |
|
echo '</div>'; |
254 |
echo '</div>'; |
echo '</div>'; |
255 |
echo '</div>'; |
/* -- FIN --*/ |
256 |
echo "</div>"; |
echo '<div class="field-ser-them field-type-date2">'; |
257 |
echo "</fieldset>"; |
echo '<div class="form-libelle">'; |
258 |
|
echo '<label class="libelle-date_envoi" for="date_envoi">'; |
259 |
|
echo _('date_envoi'); |
260 |
|
echo '<span class="not-null-tag">*</span>'; |
261 |
|
echo '</label>'; |
262 |
|
echo '</div>'; |
263 |
|
echo '<div class="form-content">'; |
264 |
|
echo '<input id="date_envoi" class="champFormulaire datepicker" |
265 |
|
type="text" onkeyup="" onchange="fdate(this)" |
266 |
|
maxlength="10" size="12" value="'.date("d/m/Y").'" |
267 |
|
name="date_envoi">'; |
268 |
|
echo '</div>'; |
269 |
|
echo '</div>'; |
270 |
|
echo "</div>"; |
271 |
|
echo "</fieldset>"; |
272 |
|
echo '</div>'; |
273 |
echo '</div>'; |
echo '</div>'; |
274 |
echo '</div>'; |
echo '</div>'; |
275 |
echo '</div>'; |
echo '<div class="formControls">'; |
276 |
echo '<div class="formControls">'; |
echo '<input class="om-button ui-button ui-widget ui-state-default ui-corner-all" |
277 |
echo '<input class="om-button ui-button ui-widget ui-state-default ui-corner-all" |
type="button" onclick="if ( $(\'.liste_gauche_service_selected\').length > 0 && $(\'#date_envoi\').val() != \'\' ) { ajaxIt(\'consultation\', \'../app/consultation_multiple.php\'); } else alert(\'Veuillez choisir au moins un service et une date d envoi\');" |
278 |
type="button" onclick="affichersform(\'consultation\', |
value="Ajouter le(s) enregistrement(s) de la table : \'Consultation\'" |
279 |
\'../scr/sousform.php?obj=consultation&premiersf=0&retourformulaire=PC& |
id="button_val">'; |
280 |
idxformulaire=PC12R0001&trisf=&validation=1&retour=tab\', |
echo '<a class="retour" onclick="ajaxIt(\'consultation\', \'../scr/soustab.php?obj='.$obj.'&retourformulaire='.$retourformulaire.'&idxformulaire='.$idx.'&premier=0&tricol=\');" |
281 |
this.form);" |
href="#">'; |
282 |
value="Ajouter le(s) enregistrement(s) de la table : \'Consultation\'" |
echo 'Retour'; |
283 |
role="button" aria-disabled="false">'; |
echo '</a>'; |
284 |
echo '<a class="retour" onclick="ajaxIt(\'consultation\', |
echo '</div>'; |
285 |
\'../scr/soustab.php?obj=consultation&retourformulaire=PC& |
echo '</form>'; |
286 |
idxformulaire=PC12R0001&premier=0&tricol=\');" |
echo '</div>'; |
287 |
href="#">'; |
|
288 |
echo 'Retour'; |
echo " |
289 |
echo '</a>'; |
<script language='javascript' type='text/javascript'> |
290 |
echo '</div>'; |
$(function(){ |
291 |
echo '</form>'; |
|
292 |
echo '</div>'; |
/* |
293 |
|
Sélectionne tous les services d'un thème au clique sur celui ci. |
294 |
echo " |
*/ |
295 |
<script> |
$('.liste_gauche_them').click( |
296 |
$(function(){ |
function(){ |
297 |
$('.liste_gauche_them').click( |
|
298 |
function(){ |
var id = $(this).attr('id').split('_')[1]; |
299 |
|
var numSer = 0; |
300 |
var id = $(this).attr('id').split('_')[1]; |
var numSerWithClass = 0; |
301 |
$('.list-ser-them div').each( |
|
302 |
function() { |
$('.list-ser-them div').each( |
303 |
|
function() { |
304 |
if ( $(this).attr('id').indexOf('them') == -1 && |
|
305 |
$(this).attr('id').indexOf(id) == 0 ){ |
if ( $(this).attr('id').indexOf('them') == -1 && |
306 |
$(this).toggleClass('liste_gauche_service_selected'); |
$(this).attr('id').indexOf(id) == 1 && |
307 |
|
$(this).hasClass('liste_gauche_service_selected') ) |
308 |
|
|
309 |
|
numSerWithClass++; |
310 |
|
|
311 |
|
if ( $(this).attr('id').indexOf('them') == -1 && |
312 |
|
$(this).attr('id').indexOf(id) == 1 ) |
313 |
|
|
314 |
|
numSer++; |
315 |
} |
} |
316 |
} |
); |
317 |
); |
|
318 |
} |
if ( numSerWithClass < numSer && numSerWithClass >= 0 ){ |
319 |
); |
|
320 |
|
$('.list-ser-them div').each( |
|
$('.liste_gauche_service').click( |
|
|
function(){ |
|
|
$(this).toggleClass('liste_gauche_service_selected'); |
|
|
} |
|
|
); |
|
|
|
|
|
$('.liste_droite_service').live( |
|
|
'click', |
|
|
function(){ |
|
|
$(this).toggleClass('liste_droite_service_selected'); |
|
|
} |
|
|
); |
|
|
|
|
|
$('#add-ser-them').click( |
|
|
function() { |
|
|
|
|
|
$('.list-sel-ser-them').empty(); |
|
|
|
|
|
$('.liste_gauche_service_selected').each( |
|
|
function(i) { |
|
|
|
|
|
( i == 0 ) ? |
|
|
$('.list-sel-ser-them').append(''+ |
|
|
'<div class=\'row\'>'+ |
|
|
'<div class=\'cell1\' id=\'list-sel-ser-them-title\'>"._('Service à consulter')."</div>'+ |
|
|
'<div class=\'cell2\' id=\'list-sel-ser-them-title\'>"._('Version papier')."</div>'+ |
|
|
'</div>') |
|
|
: '' ; |
|
|
|
|
|
$('.list-sel-ser-them').append( |
|
|
'<div class=\'row liste_droite_service\' id=\'' + i + '\'>'+ |
|
|
'<div class=\'cell1\'>'+ |
|
|
'<div id=\'' + $(this).attr('id') + '\'>'+ |
|
|
$(this).html().split('<')[0]+ |
|
|
'</div>'+ |
|
|
'</div>' + |
|
|
'<div class=\'cell2\'>'+ |
|
|
'<div>'+ |
|
|
'<'+$(this).html().split('<')[1]+ |
|
|
'</div>'+ |
|
|
'</div>'+ |
|
|
'</div>' |
|
|
); |
|
|
|
|
|
$(this).hide(); |
|
|
var id = $(this).attr('id'); |
|
|
$('.list-ser-them div').each( |
|
321 |
function() { |
function() { |
322 |
|
|
323 |
if ( $(this).attr('id').indexOf('them') == -1 && |
if ( $(this).attr('id').indexOf('them') == -1 && |
324 |
$(this).attr('id').indexOf('_' + id.split('_')[1] + '_') != -1 ){ |
$(this).attr('id').indexOf(id) == 1 && |
325 |
|
!$(this).hasClass('liste_gauche_service_selected') ) |
326 |
$(this).hide(); |
|
327 |
} |
$(this).addClass('liste_gauche_service_selected'); |
328 |
} |
} |
329 |
); |
); |
330 |
} |
} |
331 |
); |
|
332 |
} |
else { |
|
); |
|
|
|
|
|
$('#del-ser-them').click( |
|
|
function() { |
|
|
$('.liste_droite_service_selected').each( |
|
|
function() { |
|
|
|
|
|
var id = $('#'+ $(this).attr('id') + ' .cell1 div').attr('id'); |
|
333 |
|
|
334 |
$('.list-ser-them div').each( |
$('.list-ser-them div').each( |
335 |
function() { |
function() { |
336 |
|
|
337 |
if ( $(this).attr('id').indexOf('them') == -1 && |
if ( $(this).attr('id').indexOf('them') == -1 && |
338 |
$(this).attr('id').indexOf('_' + id.split('_')[1] + '_') != -1 ){ |
$(this).attr('id').indexOf(id) == 1 && |
339 |
|
$(this).hasClass('liste_gauche_service_selected') ) |
340 |
$(this).show(); |
|
341 |
} |
$(this).removeClass('liste_gauche_service_selected'); |
342 |
} |
} |
343 |
); |
); |
344 |
|
} |
345 |
|
} |
346 |
|
); |
347 |
|
|
348 |
|
/* |
349 |
|
Change la class CSS d'un service sur lequel on clique dans la liste de gauche. |
350 |
|
*/ |
351 |
|
$('.liste_gauche_service').click( |
352 |
|
function(){ |
353 |
|
$(this).toggleClass('liste_gauche_service_selected'); |
354 |
|
} |
355 |
|
); |
356 |
|
|
357 |
|
/* |
358 |
|
Change la class CSS d'un service sur lequel on clique dans la liste de droite. |
359 |
|
*/ |
360 |
|
$('.field-ser-them').on( |
361 |
|
'click', |
362 |
|
'.cell1', |
363 |
|
function(){ |
364 |
|
if ( !$(this).hasClass('liste_droite_title') ) |
365 |
|
$(this).parent().toggleClass('liste_droite_service_selected'); |
366 |
|
} |
367 |
|
); |
368 |
|
|
369 |
|
$('.liste_droite_service input[type=checkbox]').live( |
370 |
|
'click', |
371 |
|
'input[type=checkbox]', |
372 |
|
function(){ |
373 |
|
|
374 |
|
old_id = $(this).attr('class'); |
375 |
|
|
376 |
|
tab_don = old_id.split('_'); |
377 |
|
|
378 |
|
new_id = tab_don[0] + '_' + tab_don[1] + '_' + ((tab_don[2] == 0 ) ? 1 : 0 ) + '_'; |
379 |
|
|
380 |
|
changeOneData( ';' + tab_don[1] + '_' + tab_don[2], ';' + tab_don[1] + '_' + ((tab_don[2] == 0) ? 1 : 0) ); |
381 |
|
$('div[class=\"' + old_id + '\"]').attr('class', new_id); |
382 |
|
$(this).attr('class', new_id); |
383 |
|
|
384 |
|
} |
385 |
|
); |
386 |
|
|
387 |
|
$('#date_envoi').change( |
388 |
|
function (){ |
389 |
|
|
390 |
|
var listServ = new Array(); |
391 |
|
var data = ''; |
392 |
|
|
393 |
|
$('.liste_gauche_service_selected').each( |
394 |
|
function(i) { |
395 |
|
|
396 |
|
var name = $(this).attr('name'); |
397 |
|
|
398 |
|
if ( listServ.length > 0 && listServ.indexOf(name.split('_')[1]) != -1 ) |
399 |
|
return; |
400 |
|
listServ[i] = name.split('_')[1]; |
401 |
|
data += ';' + name.split('_')[1] + '_' + name.split('_')[2] ; |
402 |
|
|
403 |
|
} |
404 |
|
); |
405 |
|
|
406 |
|
changeActionVal(data); |
407 |
|
} |
408 |
|
); |
409 |
|
|
410 |
|
/* |
411 |
|
Passe les services sélectionnés dans la liste de gauche dans celle de droite. |
412 |
|
*/ |
413 |
|
$('#add-ser-them').click( |
414 |
|
function() { |
415 |
|
|
416 |
|
changeDataLeftColumn(); |
417 |
|
} |
418 |
|
); |
419 |
|
|
420 |
|
/* |
421 |
|
Passe les services sélectionnés dans la liste de droite dans celle de gauche. |
422 |
|
*/ |
423 |
|
$('#del-ser-them').click( |
424 |
|
function() { |
425 |
|
|
426 |
|
var data = ''; |
427 |
|
|
428 |
|
$('.liste_droite_service_selected').each( |
429 |
|
function() { |
430 |
|
|
431 |
|
var name = $('#'+ $(this).attr('id') + ' .cell1 div').attr('name'); |
432 |
|
|
433 |
|
manageListServ('.list-ser-them div', name, 1); |
434 |
|
data += ';' + name.split('_')[1] + '_' + name.split('_')[2] ; |
435 |
|
|
436 |
|
$(this).remove(); |
437 |
|
} |
438 |
|
); |
439 |
|
|
440 |
|
changeActionVal(data); |
441 |
|
} |
442 |
|
); |
443 |
|
}); |
444 |
|
|
445 |
|
/* |
446 |
|
Vérifie que l'objet n'est pas une thématique et que son identifiant correspond. |
447 |
|
*/ |
448 |
|
function isNotthemIsOneServ( objet, id ){ |
449 |
|
return ( $(objet).attr('id').indexOf('them') == -1 && |
450 |
|
$(objet).attr('id').indexOf('_' + id.split('_')[1] + '_') != -1 ); |
451 |
|
} |
452 |
|
|
453 |
|
/* |
454 |
|
Affiche ou cache un élément qui n'est pas une thématique et dont son identifiant correspond. |
455 |
|
*/ |
456 |
|
function manageListServ( objet , name, type){ |
457 |
|
|
458 |
|
$(objet).each( |
459 |
|
function() { |
460 |
|
|
461 |
|
if ( isNotthemIsOneServ(this, name) ){ |
462 |
|
if ( type == 0 ) |
463 |
|
|
464 |
|
$(this).hide() ; |
465 |
|
|
466 |
$(this).remove(); |
else { |
467 |
|
|
468 |
|
if ( $(this).hasClass('liste_gauche_service_selected') ) |
469 |
|
|
470 |
|
$(this).toggleClass('liste_gauche_service_selected'); |
471 |
|
|
472 |
|
$(this).show() ; |
473 |
|
|
474 |
|
} |
475 |
} |
} |
|
); |
|
|
} |
|
|
); |
|
|
}); |
|
|
</script>"; |
|
|
?> |
|
476 |
|
} |
477 |
|
); |
478 |
|
} |
479 |
|
|
480 |
|
/* |
481 |
|
Change les actions qui sont réalisées lors de la soumission du formulaire |
482 |
|
*/ |
483 |
|
function changeActionVal(data){ |
484 |
|
date = $('#date_envoi').val(); |
485 |
|
|
486 |
|
$('#form_val').attr( |
487 |
|
'onsubmit', |
488 |
|
'if ( $(\'.liste_gauche_service_selected\').length > 0 && $(\'#date_envoi\').val() != \'\' ) { messageIt(\'consultation\', \'../app/consultation_multiple.php?obj=$obj&data='+data+'&idx=$idx&date_envoi='+date+'\',true);return false;' + |
489 |
|
'messageIt(\'consultation\', \'../scr/soustab.php?obj=$obj&retourformulaire=$retourformulaire&idxformulaire=$idx&premier=0&tricol=\',false);} else alert(\'Veuillez choisir au moins un service et une date d envoi\');' |
490 |
|
|
491 |
|
); |
492 |
|
$('#button_val').attr( |
493 |
|
'onclick', |
494 |
|
'if ( $(\'.liste_gauche_service_selected\').length > 0 && $(\'#date_envoi\').val() != \'\' ) { messageIt(\'consultation\', \'../app/consultation_multiple.php?obj=$obj&data='+data+'&idx=$idx&date_envoi='+date+'\',true);' + |
495 |
|
'messageIt(\'consultation\', \'../scr/soustab.php?obj=$obj&retourformulaire=$retourformulaire&idxformulaire=$idx&premier=0&tricol=\',false);} else alert(\'Veuillez choisir au moins un service et une date d envoi\');' |
496 |
|
|
497 |
|
); |
498 |
|
} |
499 |
|
|
500 |
|
/* |
501 |
|
Change les actions qui sont réalisées lors de la soumission du formulaire |
502 |
|
*/ |
503 |
|
function changeOneData( oldData, newData) { |
504 |
|
|
505 |
|
date = $('#date_envoi').val(); |
506 |
|
|
507 |
|
$('#form_val').attr( |
508 |
|
'onsubmit', |
509 |
|
$('#form_val').attr('onsubmit').replace(oldData,newData) |
510 |
|
); |
511 |
|
$('#button_val').attr( |
512 |
|
'onclick', |
513 |
|
$('#button_val').attr('onclick').replace(oldData,newData) |
514 |
|
); |
515 |
|
} |
516 |
|
|
517 |
|
function changeDataLeftColumn(){ |
518 |
|
|
519 |
|
$('.list-sel-ser-them').empty(); |
520 |
|
$('.list-sel-ser-them').html( |
521 |
|
'<div class=\"row\">' + |
522 |
|
'<div class=\"cell1 liste_droite_title list-sel-ser-them-title\">Service a consulter</div>' + |
523 |
|
'<div class=\"cell2 liste_droite_title list-sel-ser-them-title\">Version papier</div>' + |
524 |
|
'</div>' |
525 |
|
); |
526 |
|
|
527 |
|
var listServ = new Array(); |
528 |
|
var data = ''; |
529 |
|
|
530 |
|
$('.liste_gauche_service_selected').each( |
531 |
|
function(i) { |
532 |
|
|
533 |
|
var id = $(this).attr('id'); |
534 |
|
|
535 |
|
if ( $.inArray(id.split('_')[1], listServ) != -1 ) |
536 |
|
return; |
537 |
|
|
538 |
|
data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ; |
539 |
|
listServ[i] = id.split('_')[1]; |
540 |
|
|
541 |
|
$('.list-sel-ser-them').append( |
542 |
|
'<div id=\'s' + i + '\' class=\'row liste_droite_service\'>'+ |
543 |
|
'<div class=\'cell1\'>'+ |
544 |
|
'<div class=\'' + $(this).attr('id') + '\' name=\'' + $(this).attr('id') + '\'>'+ |
545 |
|
$(this).html().split('<')[0]+ |
546 |
|
'</div>'+ |
547 |
|
'</div>' + |
548 |
|
'<div class=\'cell2\'>'+ |
549 |
|
'<div>'+ |
550 |
|
'<input class=\'' + $(this).attr('id') + '\''+$(this).html().split('<input')[1]+ |
551 |
|
'</div>'+ |
552 |
|
'</div>'+ |
553 |
|
'</div>' |
554 |
|
); |
555 |
|
|
556 |
|
$(this).hide(); |
557 |
|
|
558 |
|
manageListServ('.list-ser-them div', id, 0); |
559 |
|
|
560 |
|
} |
561 |
|
); |
562 |
|
changeActionVal(data); |
563 |
|
} |
564 |
|
</script>"; |
565 |
|
} |
566 |
|
?> |