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

Diff of /trunk/app/consultation_multiple.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 534 by vpihour, Wed Oct 24 15:47:20 2012 UTC revision 575 by vpihour, Wed Oct 31 17:04:12 2012 UTC
# Line 1  Line 1 
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 = "");      (isset($_GET['date_envoi']) ? $date_envoi = $_GET['date_envoi'] : $date_envoi = "");
18            
19      $f = new utils("nohtml");      $f = new utils("nohtml");
# Line 15  Line 24 
24          $f->disableLog();          $f->disableLog();
25          /*Récupération des données et formatage.*/          /*Récupération des données et formatage.*/
26          $donnees_temp = explode(';', $_GET['data']);          $donnees_temp = explode(';', $_GET['data']);
27          for ( $i = 0 ; $i < count($donnees_temp) - 1 ; $i++ )          for ( $i = 1 ; $i < count($donnees_temp) ; $i++ )
28              $donnees[] = explode('_', $donnees_temp[$i]);              $donnees[] = explode('_', $donnees_temp[$i]);
29                    
30          /*Nombre de consultations papier à générer */          /* Nombre de consultations papier à générer */
31          $nbConsPap = 0;          $nbConsPap = 0;
32                    
33          /* Ajout des données en base de données          /* Ajout des données en base de données
# Line 26  Line 35 
35           * 1 : consultation papier {0,1}           * 1 : consultation papier {0,1}
36           * */           * */
37          if ( isset($donnees) && count($donnees) > 0 ){          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";              require_once "../obj/consultation.class.php";
42              $consultation = new consultation("]",$f->db,DEBUG);              $consultation = new consultation("]",$f->db,DEBUG);
43                            
# Line 39  Line 50 
50                  $delai = $row[0];                  $delai = $row[0];
51                                    
52                  /*Calcul du delai de retour*/                  /*Calcul du delai de retour*/
53                  $date_envoi_temp = explode("/", $date_envoi);                  $date_envoi_temp = $om_dbform->datePHP($date_envoi);
54                  $date_envoi_temp = $date_envoi_temp[2]."-".$date_envoi_temp[1]."-".$date_envoi_temp[0];                  $delai = $om_dbform->dateDB($consultation->moisdate($date_envoi_temp, $delai));
                 $delai_temp = explode('-',$consultation->moisdate($date_envoi_temp, $delai));  
                 $delai = $delai_temp[2]."/".$delai_temp[1]."/".$delai_temp[0];  
55    
56                  /*Les données à ajouter*/                    /*Les données à ajouter*/  
57                  $arrayVal = array(                  $arrayVal = array(
# Line 60  Line 69 
69                  );                  );
70                                                                
71                  $consultation->ajouter($arrayVal, $f->db, DEBUG);                  $consultation->ajouter($arrayVal, $f->db, DEBUG);
72                  
73                  /*Génération des PDF + comptage du nombre de consultations papier demandées*/                  /*Comptage du nombre de consultations papier demandées et récupération des ids des PDFs à éditer*/
74                  if ($value[1]==1){                  if ($value[1]==1){
75                                                $idxConsultations[] = $consultation->valF['consultation'];
76                      $nbConsPap++;                      $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>
89                            $.download('../app/pdfetat.php','obj=$obj$textIdsConsultations', 'POST', $obj);
90                        </script>
91                    ";
92                }
93              /*Affichage du message d'information*/              /*Affichage du message d'information*/
94              echo '<div class="subtitle">';              $f->displayMessage("valid", count($donnees)._(' service(s) s&eacute;lectionn&eacute;(s) dont ').$nbConsPap._(' consultation(s) papier.'));
                 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'<div class="message ui-widget ui-corner-all ui-state-highlight ui-state-valid">  
                         <p>  
                             <span class="ui-icon ui-icon-info"></span>  
                             <span class="text">  
                                 '.count($donnees).' service(s) s&eacute;lectionn&eacute;(s) dont '.$nbConsPap.' consultation(s) papier.  
                             </span>  
                         </p>  
                     </div>';    
             echo '</div>';  
95          }          }
96                    
97      }      }
# Line 125  Line 131 
131                      $row['them_lib'].                      $row['them_lib'].
132                  '</div>                  '</div>
133                      <div                      <div
134                          class="liste_gauche_service"                          class="liste_gauche_service '.$name.'"
135                          id="'.$name.'" >                          id="'.$name.'" >
136                          '.$row['ser_lib'].'                          '.$row['ser_lib'].'
137                          <input name="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>                          <input id="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>
138                      </div>                      </div>
139                  ';                  ';
140              }              }
# Line 138  Line 144 
144                                    
145                  $liste_gauche .= '                  $liste_gauche .= '
146                      <div                      <div
147                          class="liste_gauche_service"                          class="liste_gauche_service '.$name.'"
148                          id=id="'.$name.'" >                          id="'.$name.'" >
149                          '.$row['ser_lib'].'                          '.$row['ser_lib'].'
150                          <input name="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>                          <input id="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>
151                      </div>                      </div>
152                  ';                  ';
153              }              }
# Line 178  Line 184 
184                      (($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '0' : '1' ).'_';                      (($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '0' : '1' ).'_';
185              $liste_gauche .= '              $liste_gauche .= '
186                  <div                  <div
187                      class="liste_gauche_service"                      class="liste_gauche_service '.$name.'"
188                      id="'.$name.'" >                      id="'.$name.'" >
189                      '.$row['libelle'].'&nbsp;                      '.$row['libelle'].'&nbsp;
190                      <input name="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>                      <input id="'.$name.'" type="checkbox" '.(($row['consultation_papier'] == '' || $row['consultation_papier'] == FALSE ) ? '' : 'checked' ).'/>
191                  </div>                  </div>
192              ';              ';
193          }          }
# Line 232  Line 238 
238                                              echo '</ul>';                                              echo '</ul>';
239                                          echo '</div>';                                          echo '</div>';
240                                          echo '<div class="list-sel-ser-them">';                                          echo '<div class="list-sel-ser-them">';
241                                                echo '<div class=\'row\'>';
242                                                    echo '<div class=\'cell1 liste_gauche_them\' id=\'list-sel-ser-them-title\'>'._('Service à consulter').'</div>';
243                                                    echo '<div class=\'cell2 liste_gauche_them\' id=\'list-sel-ser-them-title\'>'._('Version papier').'</div>';
244                                                echo '</div>';
245                                          echo '</div>';                                          echo '</div>';
246                                      echo '</div>';                                      echo '</div>';
247                                      /* -- FIN --*/                                      /* -- FIN --*/
# Line 256  Line 266 
266                  echo '</div>';                  echo '</div>';
267                  echo '<div class="formControls">';                  echo '<div class="formControls">';
268                      echo '<input class="om-button ui-button ui-widget ui-state-default ui-corner-all"                      echo '<input class="om-button ui-button ui-widget ui-state-default ui-corner-all"
269                            type="button" onclick="ajaxIt(\'consultation\', \'../app/consultation_multiple.php\');"                            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\');"
270                            value="Ajouter le(s) enregistrement(s) de la table : \'Consultation\'"                            value="Ajouter le(s) enregistrement(s) de la table : \'Consultation\'"
271                            role="button" aria-disabled="false" id="button_val">';                            role="button" aria-disabled="false" id="button_val">';
272                      echo '<a class="retour" onclick="ajaxIt(\'consultation\', \'../scr/soustab.php?obj=consultation&retourformulaire=PC&idxformulaire=PC12R0001&premier=0&tricol=\');"                      echo '<a class="retour" onclick="ajaxIt(\'consultation\', \'../scr/soustab.php?obj='.$obj.'&retourformulaire='.$retourformulaire.'&idxformulaire='.$idx.'&premier=0&tricol=\');"
273                            href="#">';                            href="#">';
274                         echo 'Retour';                         echo 'Retour';
275                     echo '</a>';                     echo '</a>';
# Line 281  Line 291 
291                              function() {                              function() {
292                                                                    
293                                  if ( $(this).attr('id').indexOf('them') == -1 &&                                  if ( $(this).attr('id').indexOf('them') == -1 &&
294                                       $(this).attr('id').indexOf(id) == 0 ){                                       $(this).attr('id').indexOf(id) == 0  ){
295                                      $(this).toggleClass('liste_gauche_service_selected');                                      $(this).toggleClass('liste_gauche_service_selected');
296                                  }                                  }
297                              }                              }
# Line 301  Line 311 
311                  /*                  /*
312                      Change la class CSS d'un service sur lequel on clique dans la liste de droite.                      Change la class CSS d'un service sur lequel on clique dans la liste de droite.
313                  */                  */
314                  $('.liste_droite_service').live(                  $('.field-ser-them').on(
315                      'click',                      'click',
316                        '.liste_droite_service',
317                      function(){                      function(){
318                          $(this).toggleClass('liste_droite_service_selected');                          $(this).toggleClass('liste_droite_service_selected');
319                      }                      }
# Line 310  Line 321 
321                                    
322                  $('.liste_droite_service input[type=checkbox]').live(                  $('.liste_droite_service input[type=checkbox]').live(
323                      'click',                      'click',
324                        'input[type=checkbox]',
325                      function(){                      function(){
326                          old_id = $(this).attr('name');                          
327                          tab_don = $(this).attr('name').split('_');                          old_id = $(this).attr('id');
328                          new_id = tab_don[0] + '_' + tab_don[1] + '_' + ((tab_don[1] == 0 ) ? 1 : 0 ) + '_';                          
329                          //alert($('#' + old_id+'.cell1').attr('id'));                          tab_don = old_id.split('_');
330                          $(this).attr('name', new_id);                          
331                            new_id = tab_don[0] + '_' + tab_don[1] + '_' + ((tab_don[2] == 0 ) ? 1 : 0 ) + '_';
332    
333                            changeOneData( ';' + tab_don[1] + '_' + tab_don[2], ';' + tab_don[1] + '_' + ((tab_don[2] == 0) ? 1 : 0) );
334                            $('div[name=\"' + $(this).attr('class') + '\"]').attr('id', new_id);
335                            $(this).attr('id', new_id);
336    
337                      }                      }
338                  );                  );
339                                    
# Line 334  Line 352 
352                                  if ( listServ.length > 0 && listServ.indexOf(id.split('_')[1]) != -1 )                                  if ( listServ.length > 0 && listServ.indexOf(id.split('_')[1]) != -1 )
353                                      return;                                      return;
354                                  listServ[i] = id.split('_')[1];                                  listServ[i] = id.split('_')[1];
355                                  data += id.split('_')[1] + '_' + id.split('_')[2] + ';';                                  data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ;
356                                                                    
357                              }                              }
358                          );                          );
# Line 367  Line 385 
385                                  var id = $('#'+ $(this).attr('id') + ' .cell1 div').attr('id');                                  var id = $('#'+ $(this).attr('id') + ' .cell1 div').attr('id');
386                                                                    
387                                  manageListServ('.list-ser-them div', id, 1);                                  manageListServ('.list-ser-them div', id, 1);
388                                  data += id.split('_')[1] + '_' + id.split('_')[2] + ';';                                  data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ;
389                                                                    
390                                  $(this).remove();                                  $(this).remove();
391                              }                              }
# Line 418  Line 436 
436                                    
437                  $('#form_val').attr(                  $('#form_val').attr(
438                      'onsubmit',                      'onsubmit',
439                      'if ( $(\'.liste_gauche_service_selected\').length > 0 ) { messageIt(\'consultation\', \'../app/consultation_multiple.php?data='+data+'&idx=$idx&date_envoi='+date+'\',true);return false;' +                      '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;' +
440                      'messageIt(\'consultation\', \'../scr/soustab.php?obj=consultation&retourformulaire=PC&idxformulaire=PC12R0001&premier=0&tricol=\',false);}'                      '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\');'
441                                            
442                  );                  );
443                  $('#button_val').attr(                  $('#button_val').attr(
444                      'onclick',                      'onclick',
445                      'if ( $(\'.liste_gauche_service_selected\').length > 0 ) { messageIt(\'consultation\', \'../app/consultation_multiple.php?data='+data+'&idx=$idx&date_envoi='+date+'\',true);' +                      '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);' +
446                      'messageIt(\'consultation\', \'../scr/soustab.php?obj=consultation&retourformulaire=PC&idxformulaire=PC12R0001&premier=0&tricol=\',false);}'                      '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\');'
447                                            
448                  );                  );
449              }              }
450    
451                function changeOneData( oldData, newData) {
452                    
453                    date = $('#date_envoi').val();
454                    
455                    $('#form_val').attr(
456                        'onsubmit',
457                        $('#form_val').attr('onsubmit').replace(oldData,newData)                    
458                    );
459                    $('#button_val').attr(
460                        'onclick',
461                        $('#button_val').attr('onclick').replace(oldData,newData)
462                    );
463                }
464                            
465              function changeDataLeftColumn(){              function changeDataLeftColumn(){
466                  $('.list-sel-ser-them').empty();                  
467                  var listServ = new Array();                  var listServ = new Array();
468                  var data = '';                  var data = '';
469                                    
470                    if ( $('.liste_droite_service').length == 0 ){
471                        $('.list-sel-ser-them').empty();
472                        $('.list-sel-ser-them').append(''+
473                                    '<div class=\'row\'>'+
474                                        '<div class=\'cell1 liste_gauche_them\' id=\'list-sel-ser-them-title\'>"._('Service à consulter')."</div>'+
475                                        '<div class=\'cell2 liste_gauche_them\' id=\'list-sel-ser-them-title\'>"._('Version papier')."</div>'+
476                                    '</div>') ;
477                    }
478                    
479                  $('.liste_gauche_service_selected').each(                  $('.liste_gauche_service_selected').each(
480                      function(i) {                      function(i) {
481                                                    
482                            if ( !$(this).is(':visible') )
483                                return;
484                                
485                          var id = $(this).attr('id');                          var id = $(this).attr('id');
486                                                    
                         ( 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>')  
                             : '' ;  
                           
487                          if ( listServ.length > 0 && listServ.indexOf(id.split('_')[1]) != -1 )                          if ( listServ.length > 0 && listServ.indexOf(id.split('_')[1]) != -1 )
488                              return;                              return;
489                          listServ[i] = id.split('_')[1];                          listServ[i] = id.split('_')[1];
490                          data += id.split('_')[1] + '_' + id.split('_')[2] + ';';                          data += ';' + id.split('_')[1] + '_' + id.split('_')[2] ;
491                                                    
492                          $('.list-sel-ser-them').append(                          $('.list-sel-ser-them').append(
493                              '<div class=\'row liste_droite_service\' id=\'' + i + '\'>'+                              '<div class=\'row liste_droite_service\' id=\'' + i + '\'>'+
494                                  '<div class=\'cell1\'>'+                                  '<div class=\'cell1\'>'+
495                                      '<div id=\'' + $(this).attr('id') + '\'>'+                                      '<div name=\'' + $(this).attr('id') + '\' id=\'' + $(this).attr('id') + '\'>'+
496                                          $(this).html().split('<')[0]+                                          $(this).html().split('<')[0]+
497                                      '</div>'+                                      '</div>'+
498                                  '</div>' +                                  '</div>' +
499                                  '<div class=\'cell2\'>'+                                  '<div class=\'cell2\'>'+
500                                      '<div>'+                                      '<div>'+
501                                          '<'+$(this).html().split('<')[1]+                                          '<input class=\'' + $(this).attr('id') + '\''+$(this).html().split('<input')[1]+
502                                      '</div>'+                                      '</div>'+
503                                  '</div>'+                                  '</div>'+
504                              '</div>'                              '</div>'
# Line 479  Line 515 
515              }              }
516          </script>";          </script>";
517      }      }
     ?>  
518        ?>

Legend:
Removed from v.534  
changed lines
  Added in v.575

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26