/[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 665 by fmichon, Mon Nov 12 12:34:56 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 setvalF($val) {
34            parent::setValF($val);
35            if($this->getParameter('maj')==0) {
36                $this->valF["date_reception"]=$this->valF["date_envoi"];
37            }
38    
39            // Si un retour d'avis est modifie on passe "lu" a false
40            if($this->getParameter('maj')==1 AND (
41                $this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR
42                $this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR
43                $this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR
44                $this->val[array_search("fichier",$this->champs)] != $val["fichier"]       )
45            ) {
46                $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                }
74            }
75        }
76        
77      function setType(&$form,$maj) {      function setType(&$form,$maj) {
78            parent::setType($form,$maj);
79          if ($maj < 2) { //ajouter et modifier [add and modify]          if ($maj < 2) { //ajouter et modifier [add and modify]
80              if($maj==0){ // add              if($maj==0){ // add
81                    $form->setType('dossier', 'hiddenstatic');
82                  $form->setType('date_envoi', 'date2');                  $form->setType('date_envoi', 'date2');
83                  $form->setType('service', 'select');                  $form->setType('service', 'select');
84                  $form->setType('date_limite', 'hidden');                  $form->setType('date_limite', 'hidden');
85                  $form->setType('date_retour', 'hidden');                  $form->setType('date_retour', 'hidden');
86                  $form->setType('avis', 'hidden');                  $form->setType('avis_consultation', 'hidden');
87                    $form->setType('motivation', 'hidden');
88                    $form->setType('fichier', 'hidden');
89                    $form->setType('lu', 'hidden');
90                    $form->setType('date_reception', 'hidden');
91              }else{   // modify              }else{   // modify
92                  $form->setType('date_envoi', 'hiddenstaticdate');                  if($this->f->isAccredited('consultation_retour_avis_service')) {
93                  $form->setType('service', 'selectdisabled');                      $form->setType('dossier', 'hidden');
94                  $form->setType('date_limite', 'date2');                      $form->setType('service', 'hidden');
95                  $form->setType('date_retour', 'date2');                      $form->setType('date_envoi', 'hidden');
96                  $form->setType('avis', 'select');                      $form->setType('date_retour', 'hidden');
97              }                      $form->setType('date_reception', 'hidden');
98              $form->setType('consultation', 'hiddenstatic');                      $form->setType('date_limite', 'hidden');
99              $form->setType('dossier', 'hiddenstatic');                      $form->setType('lu', 'hidden');
100          }else{ // supprimer                      // Si il n'y a pas de fichier ou que l'utilisateur a les droits
101              $form->setType('consultation', 'hiddenstatic');                      if($this->val[array_search("fichier",$this->champs)]=="" OR
102              $form->setType('dossier', 'hiddenstatic');                         $this->f->isAccredited('consultation_modifier_fichier')) {
103                            $form->setType('fichier', 'tmpUpload');
104                        } else {
105                            $form->setType('fichier', 'hiddenstatic');
106                        }
107                    } else {
108                        $form->setType('dossier', 'hiddenstatic');
109                        $form->setType('date_envoi', 'hiddenstaticdate');
110                        $form->setType('date_limite', 'hiddenstaticdate');
111                        if(!$this->f->isAccredited('consultation_modifier_date_reception')) {
112                            $form->setType('date_reception', 'hiddenstaticdate');
113                        } else {
114                            $form->setType('date_reception', 'date2');
115                        }
116                        $form->setType('service', 'selecthiddenstatic');
117                        $form->setType('date_retour', 'date2');
118                        $form->setType('avis_consultation', 'select');
119                        $form->setType('motivation', 'textarea');
120                        // Si il n'y a pas de fichier ou que l'utilisateur a les droits
121                        if($this->val[array_search("fichier",$this->champs)]=="" OR
122                           $this->f->isAccredited('consultation_modifier_fichier')) {
123                            $form->setType('fichier', 'tmpUpload');
124                        } else {
125                            $form->setType('fichier', 'hiddenstatic');
126                        }
127                        //Affichage du champ en modification pour le prifil instructeur
128                        if(!$this->f->isAccredited('consultation_modifier_lu')) {
129                            $form->setType('lu', 'hidden');
130                        }
131                    }
132                }
133          }          }
134      }          $form->setType('consultation', 'hidden');
135            //setType pour  profil service
136    
     function setTaille(&$form,$maj){  
         $form->setTaille('consultation', 8);  
         $form->setTaille('dossier', 12);  
         $form->setTaille('service', 5);  
         $form->setTaille('date_envoi', 12);  
         $form->setTaille('date_retour', 12);  
         $form->setTaille('avis', 2);  
         $form->setTaille('date_limite', 12);  
     }  
   
     function setMax(&$form,$maj){  
         $form->setMax('consultation', 8);  
         $form->setMax('dossier', 12);  
         $form->setMax('service', 5);  
         $form->setMax('date_envoi', 12);  
         $form->setMax('date_retour', 12);  
         $form->setMax('avis', 2);  
         $form->setMax('date_limite', 12);  
137      }      }
138    
   
139      // TRIGGER AVANT MODIFICATION DE DONNEES      // TRIGGER AVANT MODIFICATION DE DONNEES
140      // trigger before modification data      // trigger before modification data
141      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
142          // mise a jour instruction avec evenement [return delay]          // mise a jour instruction avec evenement [return delay]
143          if (!$this->valF['date_envoi']==""){          if ($this->valF['date_envoi']!=""){
144              $sql= "select delai from service where service ='".$this->valF['service']."'";              $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
145              $delai = $db->getOne($sql);              $delai = $db->getOne($sql);
146              $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);              $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);
147              $this->msg=$this->msg."<br>"._("delai")." ".              $this->addToMessage(_("delai")." ".
148                 _("retour")." ".$delai." "._("mois")." -> ".                 _("retour")." ".$delai." "._("mois")." -> ".
149                 _("retour")." ".$this->valF['date_limite']."<br>";                 _("retour")." ".$this->valF['date_limite']."<br>");
150                $this->valF['lu'] = true;
151          }          }
152            
153        }
154        
155        function triggerajouterapres($id,&$db,$val,$DEBUG) {
156            
157            // Verification de la demande de notif par mail
158            $sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE.
159                    "service WHERE service ='".$this->valF['service']."'";
160            $res=$db->query($sql);
161            $notif = $res->fetchrow(DB_FETCHMODE_ASSOC);
162            if (database :: isError($sql))die($res->getMessage()."erreur ".$sql);
163            if ($notif['notification_email']=='t') {
164                
165                // Recuperation des infos du dossier
166                $sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville
167                        FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'";
168                $res=$db->query($sql);
169                $dossier = $res->fetchrow(DB_FETCHMODE_ASSOC);
170                
171                // Definition des parametres d'envoi du mail
172                $title=_("Consultation de services : dossier no")." ".$dossier['dossier'];
173                $corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>".
174                _("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']).
175                " ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>".
176                _("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm').
177                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
178                _("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe').
179                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
180                _("Lien externe (hors VDM)")."</a>";
181                // Envoi du mail avec message de retour
182                if($this->f->sendMail($title, $corps, $notif['email'])) {
183                    $this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']);
184                } else {
185                    $this->addToMessage(_("L'envoi du mail de notification a echoue"));
186                }
187            }
188            
189      }      }
190    
191      // =============================================      // =============================================
# Line 146  class consultation extends consultation_ Line 227  class consultation extends consultation_
227          return $annee."-".$mois."-".$jour ;          return $annee."-".$mois."-".$jour ;
228      }      }
229    
230        // =============================================
231        // Ajout du fielset
232        // Add fieldset
233        // =============================================
234        function setLayout(&$form, $maj){
235            if ( $maj < 2 OR $maj == 3 ) {
236                if(!$this->f->isAccredited('consultation_retour_avis_service')) {
237                    //Champs sur lequel s'ouvre le fieldset
238                    $form->setBloc('dossier','D',"");
239                    $form->setFieldset('dossier','D',_('Consultation'));
240        
241                    //Champs sur lequel se ferme le fieldset
242                    $form->setFieldset('date_envoi','F','');
243                    $form->setBloc('date_envoi','F');
244                }
245                if ( $maj == 1 OR $maj == 3 ){
246                    //Champs sur lequel s'ouvre le fieldset
247                    $form->setBloc('date_reception','D',"");
248                    $form->setFieldset('date_reception','D',_('Retour d\'avis'));
249    
250                    //Champs sur lequel se ferme le fieldset
251                    $form->setFieldset('lu','F','');
252                    $form->setBloc('lu','F');
253                }
254            }
255        }
256    
257        /** Surcharge de la methode retour afin de retourner sur la page de saisie de
258        * code barre si besoin
259        **/
260        function retour($premier = 0, $recherche = "", $tricol = "") {
261            $params ="obj=".get_class($this);
262            if($this->getParameter("retour")=="form") {
263                $params .= "&amp;idx=".$this->getParameter("idx");
264                $params .= "&amp;action=3";
265            }
266            $params .= "&amp;premier=".$this->getParameter("premier");
267            $params .= "&amp;tricol=".$this->getParameter("tricol");
268            $params .= "&amp;recherche=".$this->getParameter("recherche");
269            $params .= "&amp;selectioncol=".$this->getParameter("selectioncol");
270            $params .= "&amp;advs_id=".$this->getParameter("advs_id");
271            $params .= "&amp;valide=".$this->getParameter("valide");
272            echo "\n<a class=\"retour\" ";
273            echo "href=\"";
274            //
275    
276            if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
277                echo "form.php?".$params;
278            } elseif($this->getParameter("retour")=="avis_code_barre") {
279                echo "../app/avis_code_barre.php";
280            } else {
281                echo "tab.php?".$params;
282            }
283            //
284            echo "\"";
285            echo ">";
286            //
287            echo _("Retour");
288            //
289            echo "</a>\n";
290    
291        }
292        
293  }// fin classe  }// fin classe
 ?>  
294    ?>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26