/[openfoncier]/trunk/app/consultation_multiple.php
ViewVC logotype

Annotation of /trunk/app/consultation_multiple.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 536 - (hide annotations)
Thu Oct 25 16:12:46 2012 UTC (12 years, 3 months ago) by vpihour
File size: 24039 byte(s)
Formulaire de création de multiple consultations

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26