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

Annotation of /trunk/app/consultation_multiple.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 572 - (hide annotations)
Wed Oct 31 15:34:17 2012 UTC (12 years, 3 months ago) by vpihour
File size: 23757 byte(s)
Correction des liens

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26