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; |
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_consultation']=='') $this->valF['avis_consultation']= null; |
|
|
} |
|
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')); |
$form->setVal("date_envoi",date('d/m/Y')); |
17 |
} |
} |
18 |
else |
if($maj == 1) { |
19 |
if ( $maj == 1 ) |
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
20 |
$form->setVal("date_retour",date('d/m/Y')); |
$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->maj==0) { |
36 |
|
$this->valF["date_reception"]=$this->valF["date_envoi"]; |
37 |
|
} |
38 |
|
// Si un retour d'avis est modifie on passe "lu" a false |
39 |
|
if($this->maj==1 AND ($this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
40 |
|
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
41 |
|
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
42 |
|
$this->val[array_search("fichier",$this->champs)] != $val["fichier"])) { |
43 |
|
$this->valF["lu"]=FALSE; |
44 |
|
$this->valF["date_retour"]=$this->dateDB(date('d/m/Y')); |
45 |
|
} |
46 |
|
|
47 |
|
} |
48 |
|
|
49 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
50 |
parent::setType($form,$maj); |
parent::setType($form,$maj); |
51 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
if ($maj < 2) { //ajouter et modifier [add and modify] |
55 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_limite', 'hidden'); |
56 |
$form->setType('date_retour', 'hidden'); |
$form->setType('date_retour', 'hidden'); |
57 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('avis_consultation', 'hidden'); |
58 |
$form->setType('motivation', 'hidden'); |
$form->setType('motivation', 'hidden'); |
59 |
$form->setType('fichier', 'hidden'); |
$form->setType('fichier', 'hidden'); |
60 |
$form->setType('lu', 'hidden'); |
$form->setType('lu', 'hidden'); |
61 |
$form->setType('date_reception', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
62 |
}else{ // modify |
}else{ // modify |
63 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
if($this->f->isAccredited('consultation_retour_avis_service')) { |
64 |
$form->setType('date_limite', 'hiddenstaticdate'); |
$form->setType('dossier', 'hidden'); |
65 |
$form->setType('service', 'selectdisabled'); |
$form->setType('service', 'hidden'); |
66 |
$form->setType('date_retour', 'date2'); |
$form->setType('date_envoi', 'hidden'); |
67 |
$form->setType('avis_consultation', 'select'); |
$form->setType('date_retour', 'hidden'); |
68 |
$form->setType('motivation', 'textarea'); |
$form->setType('date_reception', 'hidden'); |
69 |
$form->setType('fichier', 'upload'); |
$form->setType('date_limite', 'hidden'); |
70 |
} |
$form->setType('lu', 'hidden'); |
71 |
$form->setType('consultation', 'hiddenstatic'); |
$form->setType('fichier', 'upload2'); |
72 |
$form->setType('dossier', 'hiddenstatic'); |
} else { |
73 |
} |
$form->setType('dossier', 'hiddenstatic'); |
74 |
else { |
$form->setType('date_envoi', 'hiddenstaticdate'); |
75 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_limite', 'hiddenstaticdate'); |
76 |
$form->setType('date_retour', 'hidden'); |
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
77 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('date_reception', 'hiddenstaticdate'); |
78 |
$form->setType('motivation', 'hidden'); |
} else { |
79 |
$form->setType('fichier', 'hidden'); |
$form->setType('date_reception', 'date2'); |
80 |
$form->setType('lu', 'hidden'); |
} |
81 |
$form->setType('date_reception', 'hidden'); |
$form->setType('service', 'selecthiddenstatic'); |
82 |
} |
$form->setType('date_retour', 'date2'); |
83 |
|
$form->setType('avis_consultation', 'select'); |
84 |
|
$form->setType('motivation', 'textarea'); |
85 |
|
if(!isset($this->parameters['retourformulaire'])) { |
86 |
|
$form->setType('fichier', 'upload'); |
87 |
|
} else { |
88 |
|
$form->setType('fichier', 'upload2'); |
89 |
|
} |
90 |
|
//Affichage du champ en modification pour le prifil instructeur |
91 |
|
if(!$this->f->isAccredited('consultation_modifier_lu')) { |
92 |
|
$form->setType('lu', 'hidden'); |
93 |
|
} |
94 |
|
} |
95 |
|
} |
96 |
|
} |
97 |
|
$form->setType('consultation', 'hidden'); |
98 |
|
//setType pour profil service |
99 |
|
|
100 |
} |
} |
101 |
|
|
102 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
103 |
// trigger before modification data |
// trigger before modification data |
104 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
105 |
// mise a jour instruction avec evenement [return delay] |
// mise a jour instruction avec evenement [return delay] |
106 |
if (!$this->valF['date_envoi']==""){ |
if ($this->valF['date_envoi']!=""){ |
107 |
$sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'"; |
$sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'"; |
108 |
$delai = $db->getOne($sql); |
$delai = $db->getOne($sql); |
109 |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
110 |
$this->msg=$this->msg."<br>"._("delai")." ". |
$this->addToMessage(_("delai")." ". |
111 |
_("retour")." ".$delai." "._("mois")." -> ". |
_("retour")." ".$delai." "._("mois")." -> ". |
112 |
_("retour")." ".$this->valF['date_limite']."<br>"; |
_("retour")." ".$this->valF['date_limite']."<br>"); |
113 |
$this->valF['lu'] = true; |
$this->valF['lu'] = true; |
|
|
|
|
/*require("../php/phpmailer/class.phpmailer.php"); |
|
|
|
|
|
$mail = new PHPMailer(); |
|
|
|
|
|
$mail->IsSMTP(); // set mailer to use SMTP |
|
|
$mail->Host = "smtp.gmail.com"; // specify main and backup server |
|
|
$mail->SMTPAuth = true; // turn on SMTP authentication |
|
|
$mail->Username = ""; // SMTP username |
|
|
$mail->Password = ""; // SMTP password |
|
|
|
|
|
$mail->From = "[email protected]"; |
|
|
$mail->FromName = "Mailer"; |
|
|
$mail->AddAddress("[email protected]", "Vi"); |
|
|
$mail->AddReplyTo("[email protected]", "Information"); |
|
|
|
|
|
$mail->WordWrap = 50; // set word wrap to 50 characters |
|
|
$mail->IsHTML(true); // set email format to HTML |
|
|
|
|
|
$mail->Subject = "Here is the subject"; |
|
|
$mail->Body = "This is the HTML message body <b>in bold!</b>"; |
|
|
$mail->AltBody = "This is the body in plain text for non-HTML mail clients"; |
|
|
|
|
|
if(!$mail->Send()) |
|
|
{ |
|
|
echo "Message could not be sent. <p>"; |
|
|
echo "Mailer Error: " . $mail->ErrorInfo; |
|
|
exit; |
|
|
} |
|
|
|
|
|
echo "Message has been sent";*/ |
|
114 |
} |
} |
115 |
|
|
116 |
|
} |
117 |
|
|
118 |
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
119 |
|
|
120 |
|
// Verification de la demande de notif par mail |
121 |
|
$sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE. |
122 |
|
"service WHERE service ='".$this->valF['service']."'"; |
123 |
|
$res=$db->query($sql); |
124 |
|
$notif = $res->fetchrow(DB_FETCHMODE_ASSOC); |
125 |
|
if (database :: isError($sql))die($res->getMessage()."erreur ".$sql); |
126 |
|
if ($notif['notification_email']=='t') { |
127 |
|
|
128 |
|
// Recuperation des infos du dossier |
129 |
|
$sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville |
130 |
|
FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'"; |
131 |
|
$res=$db->query($sql); |
132 |
|
$dossier = $res->fetchrow(DB_FETCHMODE_ASSOC); |
133 |
|
|
134 |
|
// Definition des parametres d'envoi du mail |
135 |
|
$title=_("Consultation de services : dossier no")." ".$dossier['dossier']; |
136 |
|
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
137 |
|
_("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']). |
138 |
|
" ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>". |
139 |
|
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm'). |
140 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
141 |
|
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe'). |
142 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
143 |
|
_("Lien externe (hors VDM)")."</a>"; |
144 |
|
// Envoi du mail avec message de retour |
145 |
|
if($this->f->sendMail($title, $corps, $notif['email'])) { |
146 |
|
$this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']); |
147 |
|
} else { |
148 |
|
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
149 |
|
} |
150 |
|
} |
151 |
|
|
152 |
} |
} |
153 |
|
|
154 |
// ============================================= |
// ============================================= |
190 |
return $annee."-".$mois."-".$jour ; |
return $annee."-".$mois."-".$jour ; |
191 |
} |
} |
192 |
|
|
193 |
// ============================================= |
// ============================================= |
194 |
// Ajout du fielset |
// Ajout du fielset |
195 |
// Add fieldset |
// Add fieldset |
196 |
// ============================================= |
// ============================================= |
197 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
198 |
if ( $maj < 2 ) { |
if ( $maj < 2 OR $maj == 3 ) { |
199 |
//Champs sur lequel s'ouvre le fieldset |
if(!$this->f->isAccredited('consultation_retour_avis_service')) { |
200 |
$form->setBloc('dossier','D',""); |
//Champs sur lequel s'ouvre le fieldset |
201 |
$form->setFieldset('dossier','D',_('Consultation')); |
$form->setBloc('dossier','D',""); |
202 |
|
$form->setFieldset('dossier','D',_('Consultation')); |
203 |
//Champs sur lequel se ferme le fieldset |
|
204 |
$form->setFieldset('date_envoi','F',''); |
//Champs sur lequel se ferme le fieldset |
205 |
$form->setBloc('date_envoi','F'); |
$form->setFieldset('date_envoi','F',''); |
206 |
if ( $maj == 1 ){ |
$form->setBloc('date_envoi','F'); |
207 |
//Champs sur lequel s'ouvre le fieldset |
} |
208 |
$form->setBloc('date_reception','D',""); |
if ( $maj == 1 OR $maj == 3 ){ |
209 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
//Champs sur lequel s'ouvre le fieldset |
210 |
|
$form->setBloc('date_reception','D',""); |
211 |
//Champs sur lequel se ferme le fieldset |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
212 |
$form->setFieldset('lu','F',''); |
|
213 |
$form->setBloc('lu','F'); |
//Champs sur lequel se ferme le fieldset |
214 |
} |
$form->setFieldset('lu','F',''); |
215 |
} |
$form->setBloc('lu','F'); |
216 |
|
} |
217 |
} |
} |
218 |
|
} |
219 |
function setSelect(&$form, $maj,&$db,$debug) { |
|
220 |
parent::setSelect($form, $maj,$db,$debug); |
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
221 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
* code barre si besoin |
222 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
**/ |
223 |
if($maj<2){ |
function retour($premier = 0, $recherche = "", $tricol = "") { |
224 |
$contenu=array(); |
$params ="obj=".get_class($this); |
225 |
$sql = " SELECT service, abrege, libelle FROM ".DB_PREFIXE."service"; |
if($this->getParameter("retour")=="form") { |
226 |
$res = $db->query($sql); |
$params .= "&idx=".$this->getParameter("idx"); |
227 |
if (database::isError($res)) |
$params .= "&action=3"; |
228 |
die($res->getMessage()); |
} |
229 |
$contenu[0][0]=""; |
$params .= "&premier=".$this->getParameter("premier"); |
230 |
$contenu[1][0]=_('choisir')." "._('service'); |
$params .= "&tricol=".$this->getParameter("tricol"); |
231 |
$k=1; |
$params .= "&recherche=".$this->getParameter("recherche"); |
232 |
while ($row=& $res->fetchRow()){ |
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
233 |
if($maj==0){ // ajouter |
$params .= "&advs_id=".$this->getParameter("advs_id"); |
234 |
$contenu[0][$k]=$row[0]; |
$params .= "&valide=".$this->getParameter("valide"); |
235 |
$contenu[1][$k]=$row[1]." ".$row[2]; |
echo "\n<a class=\"retour\" "; |
236 |
$k++; |
echo "href=\""; |
237 |
}else{ |
// |
238 |
// select hiddenstatic |
|
239 |
$contenu[0][$k]=$row[0]; |
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
240 |
$contenu[1][$k]=$row[1]." ".$row[2]; |
echo "form.php?".$params; |
241 |
$k++; |
} elseif($this->getParameter("retour")=="avis_code_barre") { |
242 |
} |
echo "../app/avis_code_barre.php"; |
243 |
} |
} else { |
244 |
$form->setSelect("service",$contenu); |
echo "tab.php?".$params; |
245 |
} |
} |
246 |
} |
// |
247 |
|
echo "\""; |
248 |
//Formatage des intitulés des champs. |
echo ">"; |
249 |
function setLib(&$form,$maj) { |
// |
250 |
parent::setLib($form,$maj); |
echo _("Retour"); |
251 |
$form->setLib('date_reception','date de reception'); |
// |
252 |
$form->setLib('avis_consultation','avis'); |
echo "</a>\n"; |
253 |
$form->setLib('fichier','retour d\'avis'); |
|
254 |
} |
} |
255 |
|
|
256 |
}// fin classe |
}// fin classe |
|
?> |
|
257 |
|
?> |