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

Legend:
Removed from v.116  
changed lines
  Added in v.638

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26