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_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 |
|
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 |
} |
} |
|
else |
|
|
if ( $maj == 1 ) |
|
|
$form->setVal("date_retour",date('d/m/Y')); |
|
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 |
|
) { |
47 |
|
$this->valF["lu"]=false; |
48 |
|
} |
49 |
|
if($this->val[array_search("fichier",$this->champs)] != $val["fichier"] AND $this->valF['fichier']!="") { |
50 |
|
$file_id = array_search($this->valF['fichier'],$_SESSION['file_upload']); |
51 |
|
if($file_id!==false) { |
52 |
|
if(file_exists("../tmp/".$this->valF['fichier'])) { |
53 |
|
$contents=file_get_contents("../tmp/".$this->valF['fichier']); |
54 |
|
$this->f->storeDecisionFile($contents, $this->valF['fichier'], $this->valF['dossier'], 'consultation_'.$this->valF['consultation']."_"); |
55 |
|
$this->f->displayMessages(); |
56 |
|
unlink("../tmp/".$this->valF['fichier']); |
57 |
|
} |
58 |
|
} |
59 |
|
} |
60 |
|
} |
61 |
|
|
62 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
63 |
parent::setType($form,$maj); |
parent::setType($form,$maj); |
64 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
if ($maj < 2) { //ajouter et modifier [add and modify] |
65 |
if($maj==0){ // add |
if($maj==0){ // add |
66 |
|
$form->setType('dossier', 'hiddenstatic'); |
67 |
$form->setType('date_envoi', 'date2'); |
$form->setType('date_envoi', 'date2'); |
68 |
$form->setType('service', 'select'); |
$form->setType('service', 'select'); |
69 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_limite', 'hidden'); |
70 |
$form->setType('date_retour', 'hidden'); |
$form->setType('date_retour', 'hidden'); |
71 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('avis_consultation', 'hidden'); |
72 |
$form->setType('motivation', 'hidden'); |
$form->setType('motivation', 'hidden'); |
73 |
$form->setType('fichier', 'hidden'); |
$form->setType('fichier', 'hidden'); |
74 |
$form->setType('lu', 'hidden'); |
$form->setType('lu', 'hidden'); |
75 |
$form->setType('date_reception', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
76 |
}else{ // modify |
}else{ // modify |
77 |
$form->setType('date_envoi', 'hiddenstaticdate'); |
if($this->f->isAccredited('consultation_retour_avis_service')) { |
78 |
$form->setType('date_limite', 'hiddenstaticdate'); |
$form->setType('dossier', 'hidden'); |
79 |
$form->setType('service', 'selectdisabled'); |
$form->setType('service', 'hidden'); |
80 |
$form->setType('date_retour', 'date2'); |
$form->setType('date_envoi', 'hidden'); |
81 |
$form->setType('avis_consultation', 'select'); |
$form->setType('date_retour', 'hidden'); |
82 |
$form->setType('motivation', 'textarea'); |
$form->setType('date_reception', 'hidden'); |
83 |
$form->setType('fichier', 'upload'); |
$form->setType('date_limite', 'hidden'); |
84 |
} |
$form->setType('lu', 'hidden'); |
85 |
$form->setType('consultation', 'hiddenstatic'); |
$form->setType('fichier', 'tmpUpload'); |
86 |
$form->setType('dossier', 'hiddenstatic'); |
} else { |
87 |
} |
$form->setType('dossier', 'hiddenstatic'); |
88 |
else { |
$form->setType('date_envoi', 'hiddenstaticdate'); |
89 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_limite', 'hiddenstaticdate'); |
90 |
$form->setType('date_retour', 'hidden'); |
if(!$this->f->isAccredited('consultation_modifier_date_reception')) { |
91 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('date_reception', 'hiddenstaticdate'); |
92 |
$form->setType('motivation', 'hidden'); |
} else { |
93 |
$form->setType('fichier', 'hidden'); |
$form->setType('date_reception', 'date2'); |
94 |
$form->setType('lu', 'hidden'); |
} |
95 |
$form->setType('date_reception', 'hidden'); |
$form->setType('service', 'selecthiddenstatic'); |
96 |
} |
$form->setType('date_retour', 'date2'); |
97 |
|
$form->setType('avis_consultation', 'select'); |
98 |
|
$form->setType('motivation', 'textarea'); |
99 |
|
$form->setType('fichier', 'tmpUpload'); |
100 |
|
//Affichage du champ en modification pour le prifil instructeur |
101 |
|
if(!$this->f->isAccredited('consultation_modifier_lu')) { |
102 |
|
$form->setType('lu', 'hidden'); |
103 |
|
} |
104 |
|
} |
105 |
|
} |
106 |
|
} |
107 |
|
$form->setType('consultation', 'hidden'); |
108 |
|
//setType pour profil service |
109 |
|
|
110 |
} |
} |
111 |
|
|
112 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
113 |
// trigger before modification data |
// trigger before modification data |
114 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
115 |
// mise a jour instruction avec evenement [return delay] |
// mise a jour instruction avec evenement [return delay] |
116 |
if (!$this->valF['date_envoi']==""){ |
if ($this->valF['date_envoi']!=""){ |
117 |
$sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'"; |
$sql= "select delai from ".DB_PREFIXE."service where service ='".$this->valF['service']."'"; |
118 |
$delai = $db->getOne($sql); |
$delai = $db->getOne($sql); |
119 |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
$this->valF['date_limite'] = $this->moisdate($this->valF['date_envoi'],$delai); |
120 |
$this->msg=$this->msg."<br>"._("delai")." ". |
$this->addToMessage(_("delai")." ". |
121 |
_("retour")." ".$delai." "._("mois")." -> ". |
_("retour")." ".$delai." "._("mois")." -> ". |
122 |
_("retour")." ".$this->valF['date_limite']."<br>"; |
_("retour")." ".$this->valF['date_limite']."<br>"); |
123 |
$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";*/ |
|
124 |
} |
} |
125 |
|
|
126 |
|
} |
127 |
|
|
128 |
|
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
129 |
|
|
130 |
|
// Verification de la demande de notif par mail |
131 |
|
$sql= "SELECT abrege, notification_email, email FROM ".DB_PREFIXE. |
132 |
|
"service WHERE service ='".$this->valF['service']."'"; |
133 |
|
$res=$db->query($sql); |
134 |
|
$notif = $res->fetchrow(DB_FETCHMODE_ASSOC); |
135 |
|
if (database :: isError($sql))die($res->getMessage()."erreur ".$sql); |
136 |
|
if ($notif['notification_email']=='t') { |
137 |
|
|
138 |
|
// Recuperation des infos du dossier |
139 |
|
$sql= "SELECT dossier, terrain_adresse, terrain_adresse_complement, terrain_cp, terrain_ville |
140 |
|
FROM ".DB_PREFIXE."dossier WHERE dossier ='".$this->valF['dossier']."'"; |
141 |
|
$res=$db->query($sql); |
142 |
|
$dossier = $res->fetchrow(DB_FETCHMODE_ASSOC); |
143 |
|
|
144 |
|
// Definition des parametres d'envoi du mail |
145 |
|
$title=_("Consultation de services : dossier no")." ".$dossier['dossier']; |
146 |
|
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
147 |
|
_("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']). |
148 |
|
" ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>". |
149 |
|
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm'). |
150 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
151 |
|
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe'). |
152 |
|
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
153 |
|
_("Lien externe (hors VDM)")."</a>"; |
154 |
|
// Envoi du mail avec message de retour |
155 |
|
if($this->f->sendMail($title, $corps, $notif['email'])) { |
156 |
|
$this->addToMessage(_("Envoi d'un mail de notification au service")." ".$notif['abrege']); |
157 |
|
} else { |
158 |
|
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
159 |
|
} |
160 |
|
} |
161 |
|
|
162 |
} |
} |
163 |
|
|
164 |
// ============================================= |
// ============================================= |
200 |
return $annee."-".$mois."-".$jour ; |
return $annee."-".$mois."-".$jour ; |
201 |
} |
} |
202 |
|
|
203 |
// ============================================= |
// ============================================= |
204 |
// Ajout du fielset |
// Ajout du fielset |
205 |
// Add fieldset |
// Add fieldset |
206 |
// ============================================= |
// ============================================= |
207 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
208 |
if ( $maj < 2 ) { |
if ( $maj < 2 OR $maj == 3 ) { |
209 |
//Champs sur lequel s'ouvre le fieldset |
if(!$this->f->isAccredited('consultation_retour_avis_service')) { |
210 |
$form->setBloc('dossier','D',""); |
//Champs sur lequel s'ouvre le fieldset |
211 |
$form->setFieldset('dossier','D',_('Consultation')); |
$form->setBloc('dossier','D',""); |
212 |
|
$form->setFieldset('dossier','D',_('Consultation')); |
213 |
//Champs sur lequel se ferme le fieldset |
|
214 |
$form->setFieldset('date_envoi','F',''); |
//Champs sur lequel se ferme le fieldset |
215 |
$form->setBloc('date_envoi','F'); |
$form->setFieldset('date_envoi','F',''); |
216 |
if ( $maj == 1 ){ |
$form->setBloc('date_envoi','F'); |
217 |
//Champs sur lequel s'ouvre le fieldset |
} |
218 |
$form->setBloc('date_reception','D',""); |
if ( $maj == 1 OR $maj == 3 ){ |
219 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
//Champs sur lequel s'ouvre le fieldset |
220 |
|
$form->setBloc('date_reception','D',""); |
221 |
//Champs sur lequel se ferme le fieldset |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
222 |
$form->setFieldset('lu','F',''); |
|
223 |
$form->setBloc('lu','F'); |
//Champs sur lequel se ferme le fieldset |
224 |
} |
$form->setFieldset('lu','F',''); |
225 |
} |
$form->setBloc('lu','F'); |
226 |
|
} |
227 |
} |
} |
228 |
|
} |
229 |
function setSelect(&$form, $maj,&$db,$debug) { |
|
230 |
parent::setSelect($form, $maj,$db,$debug); |
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
231 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
* code barre si besoin |
232 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
**/ |
233 |
if($maj<2){ |
function retour($premier = 0, $recherche = "", $tricol = "") { |
234 |
$contenu=array(); |
$params ="obj=".get_class($this); |
235 |
$sql = " SELECT service, abrege, libelle FROM ".DB_PREFIXE."service"; |
if($this->getParameter("retour")=="form") { |
236 |
$res = $db->query($sql); |
$params .= "&idx=".$this->getParameter("idx"); |
237 |
if (database::isError($res)) |
$params .= "&action=3"; |
238 |
die($res->getMessage()); |
} |
239 |
$contenu[0][0]=""; |
$params .= "&premier=".$this->getParameter("premier"); |
240 |
$contenu[1][0]=_('choisir')." "._('service'); |
$params .= "&tricol=".$this->getParameter("tricol"); |
241 |
$k=1; |
$params .= "&recherche=".$this->getParameter("recherche"); |
242 |
while ($row=& $res->fetchRow()){ |
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
243 |
if($maj==0){ // ajouter |
$params .= "&advs_id=".$this->getParameter("advs_id"); |
244 |
$contenu[0][$k]=$row[0]; |
$params .= "&valide=".$this->getParameter("valide"); |
245 |
$contenu[1][$k]=$row[1]." ".$row[2]; |
echo "\n<a class=\"retour\" "; |
246 |
$k++; |
echo "href=\""; |
247 |
}else{ |
// |
248 |
// select hiddenstatic |
|
249 |
$contenu[0][$k]=$row[0]; |
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
250 |
$contenu[1][$k]=$row[1]." ".$row[2]; |
echo "form.php?".$params; |
251 |
$k++; |
} elseif($this->getParameter("retour")=="avis_code_barre") { |
252 |
} |
echo "../app/avis_code_barre.php"; |
253 |
} |
} else { |
254 |
$form->setSelect("service",$contenu); |
echo "tab.php?".$params; |
255 |
} |
} |
256 |
} |
// |
257 |
|
echo "\""; |
258 |
//Formatage des intitulés des champs. |
echo ">"; |
259 |
function setLib(&$form,$maj) { |
// |
260 |
parent::setLib($form,$maj); |
echo _("Retour"); |
261 |
$form->setLib('date_reception','date de reception'); |
// |
262 |
$form->setLib('avis_consultation','avis'); |
echo "</a>\n"; |
263 |
$form->setLib('fichier','retour d\'avis'); |
|
264 |
} |
} |
265 |
|
|
266 |
}// fin classe |
}// fin classe |
|
?> |
|
267 |
|
?> |