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

Legend:
Removed from v.173  
changed lines
  Added in v.569

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26