/[openfoncier]/trunk/obj/consultation.class.php
ViewVC logotype

Diff of /trunk/obj/consultation.class.php

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

revision 41 by fraynaud, Fri Jul 22 16:30:22 2011 UTC revision 671 by fmichon, Mon Nov 12 17:18:43 2012 UTC
# Line 9  class consultation extends consultation_ Line 9  class consultation extends consultation_
9          $this->constructeur($id,$db,$debug);          $this->constructeur($id,$db,$debug);
10      }// fin constructeur      }// fin constructeur
11            
     function setValFAjout($val){  
         $this->valF['service'] = $val['service'];  
     }  
   
     function setvalF($val){  
         parent::setvalF($val);        
         // cles secondaires numerique (contrainte integrite  pgsql)  
         if(!is_numeric($val['avis'])) $this->valF['avis']= null;  
     }  
   
     function verifier(){  
         $this->correct=True;  
         $imgv="";  
         $f="&nbsp!    ";  
         $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";  
         if ($this->valF['service']==""){  
            $this->correct=false;  
            $this->msg= $this->msg.$imgv." "._("service")." ".  
            _("obligatoire").$f;  
         }  
         if ($this->valF['dossier']==""){  
            $this->correct=false;  
            $this->msg= $this->msg.$imgv." "._("dossier")." ".  
            _("obligatoire").$f;  
         }  
         if ($this->valF['date_envoi']==""){  
            $this->correct=false;  
            $this->msg= $this->msg.$imgv." "._("date_envoi")." ".  
            _("obligatoire").$f;  
         }  
     }  
   
12      function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){      function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
13          if ($validation==0) {          if ($validation==0) {
14              if ($maj == 0){              if ($maj == 0){
15                $form->setVal("dossier", $idxformulaire);                  $form->setVal("dossier", $idxformulaire);
16                    $form->setVal("date_envoi",date('d/m/Y'));
17                }
18                if($maj == 1) {
19                    if($this->f->isAccredited('consultation_retour_avis_suivi') OR
20                        $this->f->isAccredited('consultation_retour_avis_service')) {
21                        $form->setVal("date_retour",date('d/m/Y'));
22                    }
23              }              }
24          }          }
25      }      }
26        
27        function setVal(&$form, $maj, $validation, &$db) {
28            if($maj == 1) {
29                 $form->setVal("date_retour",date('d/m/Y'));
30            }
31        }
32    
33      function setType(&$form,$maj) {      function setvalF($val) {
34          if ($maj < 2) { //ajouter et modifier [add and modify]          parent::setValF($val);
35              if($maj==0){ // add          if($this->getParameter('maj')==0) {
36                  $form->setType('date_envoi', 'date2');              $this->valF["date_reception"]=$this->valF["date_envoi"];
37                  $form->setType('service', 'select');          }
38                  $form->setType('date_limite', 'hidden');  
39                  $form->setType('date_retour', 'hidden');          // Si un retour d'avis est modifie on passe "lu" a false
40                  $form->setType('avis', 'hidden');          if($this->getParameter('maj')==1 AND (
41              }else{   // modify              $this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR
42                  $form->setType('date_envoi', 'hiddenstaticdate');              $this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR
43                  $form->setType('service', 'selectdisabled');              $this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR
44                  $form->setType('date_limite', 'date2');              $this->val[array_search("fichier",$this->champs)] != $val["fichier"]       )
45                  $form->setType('date_retour', 'date2');          ) {
46                  $form->setType('avis', 'select');              $this->valF["lu"]=false;
47            }
48            // Si le fichier envoye est different de l'existant
49            if (isset($this->val[array_search("fichier",$this->champs)])
50                && $this->val[array_search("fichier",$this->champs)] != $val["fichier"]
51                && $this->valF['fichier']!="") {
52                // Si le fichier existe dans tmp
53                if(file_exists("../tmp/".$this->valF['fichier'])) {
54                    $contents=file_get_contents("../tmp/".$this->valF['fichier']);
55                    // On essaye de l'enregistrer
56                    $res = $this->f->storeDecisionFile($contents, $this->valF['fichier'],
57                                                   $this->valF['dossier'],
58                                                   'consultation_'.$this->valF['consultation']."_");
59                    // Si l'enregistrement s'est bien deroule
60                    // on supprime le fichier dans tmp
61                    // on met a jour valF avec le nouveau nom du fichier
62                    if($res===true){
63                        $this->addToMessage(_("Sauvegarde du fichier reussi"));
64                        unlink("../tmp/".$this->valF['fichier']);
65                        $this->valF['fichier']='consultation_'.$this->valF['consultation']."_".$this->valF['fichier'];
66                    // Sinon on supprime le fichier dans tmp
67                    // on reinitialise le nom du fichier a l'ancienne valeur
68                    } else {
69                        $this->addToMessage($res);
70                        unlink("../tmp/".$this->valF['fichier']);
71                        $this->valF['fichier']=$this->val[array_search("fichier",$this->champs)];
72                    }
73              }              }
             $form->setType('consultation', 'hiddenstatic');  
             $form->setType('dossier', 'hiddenstatic');  
         }else{ // supprimer  
             $form->setType('consultation', 'hiddenstatic');  
             $form->setType('dossier', 'hiddenstatic');  
74          }          }
75      }      }
76        
77        function setType(&$form,$maj) {
78            // Appel du parent
79            parent::setType($form,$maj);
80            // MODE - AJOUTER
81            if ($maj == 0) {
82                // On cache alors tous les champs que nous ne voulons pas voir
83                // apparaître dans le formulaire d'ajout (principalement les
84                // informations sur le retour d'avis)
85                $form->setType('date_retour', 'hidden');
86                $form->setType('date_reception', 'hidden');
87                $form->setType('date_limite', 'hidden');
88                $form->setType('avis_consultation', 'hidden');
89                $form->setType('motivation', 'hidden');
90                $form->setType('fichier', 'hidden');
91                $form->setType('lu', 'hidden');
92                // On permet la modification de certains champs
93                $form->setType('dossier', 'hiddenstatic');
94                $form->setType('service', 'select');
95                $form->setType('date_envoi', 'date2');
96            }
97            // MODE - MODIFIER
98            if ($maj == 1) {
99    
100      function setTaille(&$form,$maj){              // On affiche en statique les informations qui ne sont plus
101          $form->setTaille('consultation', 8);              // modifiables
102          $form->setTaille('dossier', 12);              $form->setType('dossier', 'hiddenstatic');
103          $form->setTaille('service', 5);              $form->setType('date_envoi', 'hiddenstaticdate');
104          $form->setTaille('date_envoi', 12);              $form->setType('date_limite', 'hiddenstaticdate');
105          $form->setTaille('date_retour', 12);              $form->setType('service', 'selecthiddenstatic');
106          $form->setTaille('avis', 2);              
107          $form->setTaille('date_limite', 12);              // La date de réception ne peut être modifiée que par un
108      }              // utilisateur en ayant spécifiquement la permission
109                if($this->f->isAccredited('consultation_modifier_date_reception')) {
110      function setMax(&$form,$maj){                  $form->setType('date_reception', 'date2');
111          $form->setMax('consultation', 8);              } else {
112          $form->setMax('dossier', 12);                  $form->setType('date_reception', 'hiddenstaticdate');
113          $form->setMax('service', 5);              }
114          $form->setMax('date_envoi', 12);  
115          $form->setMax('date_retour', 12);              // Le marqueur lu/non lu ne peut être modifié que par un
116          $form->setMax('avis', 2);              // utilisateur en ayant spécifiquement la permission
117          $form->setMax('date_limite', 12);              if ($this->f->isAccredited('consultation_modifier_lu')) {
118      }                  $form->setType('lu', 'checkbox');
119                } else {
120                    $form->setType('lu', 'hidden');
121                }
122    
123                // Gestion du type du widget sur le champ fichier
124                if($this->val[array_search("fichier",$this->champs)]=="" OR
125                   $this->f->isAccredited('consultation_modifier_fichier')) {
126                    // Si il n'y a jamais eu de fichier enregistré ou que
127                    // l'utilisateur a spécifiquement les droits pour modifier
128                    // un fichier déjà enregistré alors on positionne un type
129                    // de widget modifiable
130                    $form->setType('fichier', 'tmpUpload');
131                } else {
132                    // Si non on affiche uniquement le nom du fichier
133                    $form->setType('fichier', 'hiddenstatic');
134                }
135    
136                // Modification layout : écran de retour d'avis permettant
137                // uniquement la saisie des trois champs : avis, motivation et fichier
138                if (!$this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) {
139    
140                    // On cache alors tous les champs que nous ne voulons pas voir
141                    $form->setType('dossier', 'hidden');
142                    $form->setType('service', 'hidden');
143                    $form->setType('date_envoi', 'hidden');
144                    $form->setType('date_retour', 'hidden');
145                    $form->setType('date_reception', 'hidden');
146                    $form->setType('date_limite', 'hidden');
147                    $form->setType('lu', 'hidden');
148    
149                }
150    
151            }
152            //// On cache la clé primaire
153            //$form->setType('consultation', 'hidden');
154        }
155    
156      // TRIGGER AVANT MODIFICATION DE DONNEES      // TRIGGER AVANT MODIFICATION DE DONNEES
157      // trigger before modification data      // trigger before modification data
158      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
159          // mise a jour instruction avec evenement [return delay]          // mise a jour instruction avec evenement [return delay]
160          if (!$this->valF['date_envoi']==""){          if ($this->valF['date_envoi']!=""){
161              $sql= "select delai from service where service ='".$this->valF['service']."'";              $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
162              $delai = $db->getOne($sql);              $delai = $db->getOne($sql);
163              $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);              $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);
164              $this->msg=$this->msg."<br>"._("delai")." ".              $this->addToMessage(_("delai")." ".
165                 _("retour")." ".$delai." "._("mois")." -> ".                 _("retour")." ".$delai." "._("mois")." -> ".
166                 _("retour")." ".$this->valF['date_limite']."<br>";                 _("retour")." ".$this->valF['date_limite']."<br>");
167                $this->valF['lu'] = true;
168          }          }
169            
170        }
171        
172        function triggerajouterapres($id,&$db,$val,$DEBUG) {
173            
174            // Verification de la demande de notif par mail
175            $sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE.
176                    "service WHERE service ='".$this->valF['service']."'";
177            $res=$db->query($sql);
178            $notif = $res->fetchrow(DB_FETCHMODE_ASSOC);
179            if (database :: isError($sql))die($res->getMessage()."erreur ".$sql);
180            if ($notif['notification_email']=='t') {
181                
182                // Recuperation des infos du dossier
183                $sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville
184                        FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'";
185                $res=$db->query($sql);
186                $dossier = $res->fetchrow(DB_FETCHMODE_ASSOC);
187                
188                // Definition des parametres d'envoi du mail
189                $title=_("Consultation de services : dossier no")." ".$dossier['dossier'];
190                $corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>".
191                _("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']).
192                " ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>".
193                _("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('services_consultes_lien_interne').
194                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
195                _("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('services_consultes_lien_externe').
196                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
197                _("Lien externe (hors VDM)")."</a>";
198                // Envoi du mail avec message de retour
199                if($this->f->sendMail($title, $corps, $notif['email'])) {
200                    $this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']);
201                } else {
202                    $this->addToMessage(_("L'envoi du mail de notification a echoue"));
203                }
204            }
205            
206      }      }
207    
208      // =============================================      // =============================================
# Line 146  class consultation extends consultation_ Line 244  class consultation extends consultation_
244          return $annee."-".$mois."-".$jour ;          return $annee."-".$mois."-".$jour ;
245      }      }
246    
247        // =============================================
248        // Ajout du fielset
249        // Add fieldset
250        // =============================================
251        function setLayout(&$form, $maj){
252    
253                // Modification layout : écran de retour d'avis permettant
254                // uniquement la saisie des trois champs : avis, motivation et fichier
255                if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) {
256                    
257                    //Champs sur lequel s'ouvre le fieldset
258                    $form->setBloc('dossier','D',"");
259                    $form->setFieldset('dossier','D',_('Consultation'));
260        
261                    //Champs sur lequel se ferme le fieldset
262                    $form->setFieldset('date_envoi','F','');
263                    $form->setBloc('date_envoi','F');
264    
265                }
266                
267                // MODE - autre que AJOUTER alors on affiche un fieldset retour
268                // d'avis
269                if ($maj != 0) {
270                    
271                    //Champs sur lequel s'ouvre le fieldset
272                    $form->setBloc('date_reception','D',"");
273                    $form->setFieldset('date_reception','D',_('Retour d\'avis'));
274        
275                    //Champs sur lequel se ferme le fieldset
276                    $form->setFieldset('lu','F','');
277                    $form->setBloc('lu','F');
278                    
279                }
280        }
281    
282        /** Surcharge de la methode retour afin de retourner sur la page de saisie de
283        * code barre si besoin
284        **/
285        function retour($premier = 0, $recherche = "", $tricol = "") {
286            $params ="obj=".get_class($this);
287            if($this->getParameter("retour")=="form") {
288                $params .= "&amp;idx=".$this->getParameter("idx");
289                $params .= "&amp;action=3";
290            }
291            $params .= "&amp;premier=".$this->getParameter("premier");
292            $params .= "&amp;tricol=".$this->getParameter("tricol");
293            $params .= "&amp;recherche=".$this->getParameter("recherche");
294            $params .= "&amp;selectioncol=".$this->getParameter("selectioncol");
295            $params .= "&amp;advs_id=".$this->getParameter("advs_id");
296            $params .= "&amp;valide=".$this->getParameter("valide");
297            echo "\n<a class=\"retour\" ";
298            echo "href=\"";
299            //
300    
301            if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
302                echo "form.php?".$params;
303            } elseif($this->getParameter("retour")=="avis_code_barre") {
304                echo "../app/avis_code_barre.php";
305            } else {
306                echo "tab.php?".$params;
307            }
308            //
309            echo "\"";
310            echo ">";
311            //
312            echo _("Retour");
313            //
314            echo "</a>\n";
315    
316        }
317        
318  }// fin classe  }// fin classe
 ?>  
319    ?>

Legend:
Removed from v.41  
changed lines
  Added in v.671

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26