/[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 20 by fraynaud, Mon Jul 18 15:27:17 2011 UTC revision 587 by nhaye, Fri Nov 2 17:44:04 2012 UTC
# Line 4  Line 4 
4  require_once ("../gen/obj/consultation.class.php");  require_once ("../gen/obj/consultation.class.php");
5    
6  class consultation extends consultation_gen {  class consultation extends consultation_gen {
7        var $maj;
8      function consultation($id,&$db,$debug) {      function consultation($id,&$db,$debug) {
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 verifierAjout(){  
         $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;  
         }  
     }  
   
     function verifier(){  
         $this->correct=True;  
         $imgv="";  
         $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";  
         $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";  
         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                     $form->setVal("date_retour",date('d/m/Y'));
20              }              }
21          }          }
22      }      }
23        
24        function setVal(&$form, $maj, $validation, &$db) {
25            if($maj == 1) {
26                 $form->setVal("date_retour",date('d/m/Y'));
27            }
28        }
29    
30        function setvalF($val) {
31            parent::setValF($val);
32            if($maj==0) {
33                $this->valF["date_reception"]=$this->valF["date_envoi"];
34            }
35            // Si un retour d'avis est modifie on passe "lu" a false
36            if($this->maj==1 AND ($this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR
37               $this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR
38               $this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR
39               $this->val[array_search("fichier",$this->champs)] != $val["fichier"])) {
40                $this->valF["lu"]=FALSE;
41                $this->valF["date_retour"]=$this->dateDB(date('d/m/Y'));
42            }
43            
44        }
45        
46      function setType(&$form,$maj) {      function setType(&$form,$maj) {
47            parent::setType($form,$maj);
48          if ($maj < 2) { //ajouter et modifier [add and modify]          if ($maj < 2) { //ajouter et modifier [add and modify]
49              if($maj==0){ // add              if($maj==0){ // add
50                  $form->setType('date_envoi', 'date2');                  $form->setType('date_envoi', 'date2');
51                  $form->setType('service', 'select');                  $form->setType('service', 'select');
52                  $form->setType('date_limite', 'hidden');                  $form->setType('date_limite', 'hidden');
53                  $form->setType('date_retour', 'hidden');                  $form->setType('date_retour', 'hidden');
54                  $form->setType('avis', 'hidden');                  $form->setType('avis_consultation', 'hidden');
55                    $form->setType('motivation', 'hidden');
56                    $form->setType('fichier', 'hidden');
57                    $form->setType('lu', 'hidden');
58                    $form->setType('date_reception', 'hidden');
59              }else{   // modify              }else{   // modify
60                  $form->setType('date_envoi', 'hiddenstaticdate');                  if($this->f->isAccredited('consultation_retour_avis_service')) {
61                  $form->setType('service', 'selectdisabled');                      $form->setType('dossier', 'hidden');
62                  $form->setType('date_limite', 'date2');                      $form->setType('service', 'hidden');
63                  $form->setType('date_retour', 'date2');                      $form->setType('date_envoi', 'hidden');
64                  $form->setType('avis', 'select');                      $form->setType('date_retour', 'hidden');
65                        $form->setType('date_reception', 'hidden');
66                        $form->setType('date_limite', 'hidden');
67                        $form->setType('lu', 'hidden');
68                    } else {
69                        $form->setType('date_envoi', 'hiddenstaticdate');
70                        $form->setType('date_limite', 'hiddenstaticdate');
71                        $form->setType('date_reception', 'hiddenstaticdate');
72                        $form->setType('service', 'selecthiddenstatic');
73                        $form->setType('date_retour', 'date2');
74                        $form->setType('avis_consultation', 'select');
75                        $form->setType('motivation', 'textarea');
76                        $form->setType('fichier', 'upload2');
77                        //Affichage du champ en modification pour le prifil instructeur
78                        if(!$this->f->isAccredited('consultation_modifier_lu')) {
79                            $form->setType('lu', 'hidden');
80                        }
81                    }
82              }              }
             $form->setType('consultation', 'hiddenstatic');  
             $form->setType('dossier', 'hiddenstatic');  
         }else{ // supprimer  
             $form->setType('consultation', 'hiddenstatic');  
83              $form->setType('dossier', 'hiddenstatic');              $form->setType('dossier', 'hiddenstatic');
84          }          }
85      }          $form->setType('consultation', 'hidden');
86            //setType pour  profil service
87    
     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);  
88      }      }
89    
   
90      // TRIGGER AVANT MODIFICATION DE DONNEES      // TRIGGER AVANT MODIFICATION DE DONNEES
91      // trigger before modification data      // trigger before modification data
92      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
93          // mise a jour instruction avec evenement [return delay]          // mise a jour instruction avec evenement [return delay]
94          $sql= "select delai from service where service ='".$this->valF['service']."'";          if ($this->valF['date_envoi']!=""){
95          $delai = $db->getOne($sql);              $sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'";
96          $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);              $delai = $db->getOne($sql);
97          $this->msg=$this->msg."<br>"._("delai")." ".              $this->valF['date_limite'] =  $this->moisdate($this->valF['date_envoi'],$delai);
98             _("retour")." ".$delai." "._("mois")." -> ".              $this->addToMessage(_("delai")." ".
99             _("retour")." ".$this->valF['date_limite']."<br>";                 _("retour")." ".$delai." "._("mois")." -> ".
100                   _("retour")." ".$this->valF['date_limite']."<br>");
101                $this->valF['lu'] = true;
102            }
103            
104        }
105        
106        function triggerajouterapres($id,&$db,$val,$DEBUG) {
107            
108            // Verification de la demande de notif par mail
109            $sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE.
110                    "service WHERE service ='".$this->valF['service']."'";
111            $res=$db->query($sql);
112            $notif = $res->fetchrow(DB_FETCHMODE_ASSOC);
113            if (database :: isError($sql))die($res->getMessage()."erreur ".$sql);
114            if ($notif['notification_email']=='t') {
115                
116                // Recuperation des infos du dossier
117                $sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville
118                        FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'";
119                $res=$db->query($sql);
120                $dossier = $res->fetchrow(DB_FETCHMODE_ASSOC);
121                
122                // Definition des parametres d'envoi du mail
123                $title=_("Consultation de services : dossier no")." ".$dossier['dossier'];
124                $corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>".
125                _("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']).
126                " ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>".
127                _("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm').
128                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
129                _("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe').
130                "scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >".
131                _("Lien externe (hors VDM)")."</a>";
132                // Envoi du mail avec message de retour
133                if($this->f->sendMail($title, $corps, $notif['email'])) {
134                    $this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']);
135                } else {
136                    $this->addToMessage(_("L'envoi du mail de notification a echoue"));
137                }
138            }
139            
140      }      }
141    
142      // =============================================      // =============================================
# Line 146  class consultation extends consultation_ Line 178  class consultation extends consultation_
178          return $annee."-".$mois."-".$jour ;          return $annee."-".$mois."-".$jour ;
179      }      }
180    
181        // =============================================
182        // Ajout du fielset
183        // Add fieldset
184        // =============================================
185        function setLayout(&$form, $maj){
186            if ( $maj < 2 OR $maj == 3 ) {
187                if(!$this->f->isAccredited('consultation_retour_avis_service')) {
188                    //Champs sur lequel s'ouvre le fieldset
189                    $form->setBloc('dossier','D',"");
190                    $form->setFieldset('dossier','D',_('Consultation'));
191        
192                    //Champs sur lequel se ferme le fieldset
193                    $form->setFieldset('date_envoi','F','');
194                    $form->setBloc('date_envoi','F');
195                }
196                if ( $maj == 1 OR $maj == 3 ){
197                    //Champs sur lequel s'ouvre le fieldset
198                    $form->setBloc('date_reception','D',"");
199                    $form->setFieldset('date_reception','D',_('Retour d\'avis'));
200    
201                    //Champs sur lequel se ferme le fieldset
202                    $form->setFieldset('lu','F','');
203                    $form->setBloc('lu','F');
204                }
205            }
206        }
207        
208  }// fin classe  }// fin classe
 ?>  
209    ?>

Legend:
Removed from v.20  
changed lines
  Added in v.587

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26