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 |
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 |
|
} |
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) { |
function setvalF($val) { |
34 |
parent::setValF($val); |
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 |
// Si un retour d'avis est modifie on passe "lu" a false |
40 |
if($this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
if($this->getParameter('maj')==1 AND ( |
41 |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
42 |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
43 |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) { |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
44 |
$this->valF["lu"]=FALSE; |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) |
45 |
$this->valF["date_retour"]=$this->dateDB(date('d/m/Y')); |
) { |
46 |
|
$this->valF["lu"]=false; |
47 |
|
} |
48 |
|
// Si le fichier envoye est different de l'existant |
49 |
|
if (isset($this->val[array_search("fichier",$this->champs)]) |
50 |
|
&& $this->val[array_search("fichier",$this->champs)] != $val["fichier"] |
51 |
|
&& $this->valF['fichier']!="") { |
52 |
|
// Si le fichier existe dans tmp |
53 |
|
if(file_exists("../tmp/".$this->valF['fichier'])) { |
54 |
|
$contents=file_get_contents("../tmp/".$this->valF['fichier']); |
55 |
|
// On essaye de l'enregistrer |
56 |
|
$res = $this->f->storeDecisionFile($contents, $this->valF['fichier'], |
57 |
|
$this->valF['dossier'], |
58 |
|
'consultation_'.$this->valF['consultation']."_"); |
59 |
|
// Si l'enregistrement s'est bien deroule |
60 |
|
// on supprime le fichier dans tmp |
61 |
|
// on met a jour valF avec le nouveau nom du fichier |
62 |
|
if($res===true){ |
63 |
|
$this->addToMessage(_("Sauvegarde du fichier reussi")); |
64 |
|
unlink("../tmp/".$this->valF['fichier']); |
65 |
|
$this->valF['fichier']='consultation_'.$this->valF['consultation']."_".$this->valF['fichier']; |
66 |
|
// Sinon on supprime le fichier dans tmp |
67 |
|
// on reinitialise le nom du fichier a l'ancienne valeur |
68 |
|
} else { |
69 |
|
$this->addToMessage($res); |
70 |
|
unlink("../tmp/".$this->valF['fichier']); |
71 |
|
$this->valF['fichier']=$this->val[array_search("fichier",$this->champs)]; |
72 |
|
} |
73 |
|
} |
74 |
} |
} |
|
|
|
75 |
} |
} |
76 |
|
|
77 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
78 |
|
// Appel du parent |
79 |
parent::setType($form,$maj); |
parent::setType($form,$maj); |
80 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
// MODE - AJOUTER |
81 |
if($maj==0){ // add |
if ($maj == 0) { |
82 |
$form->setType('date_envoi', 'date2'); |
// On cache alors tous les champs que nous ne voulons pas voir |
83 |
$form->setType('service', 'select'); |
// apparaître dans le formulaire d'ajout (principalement les |
84 |
$form->setType('date_limite', 'hidden'); |
// informations sur le retour d'avis) |
|
$form->setType('date_retour', 'hidden'); |
|
|
$form->setType('avis_consultation', 'hidden'); |
|
|
$form->setType('motivation', 'hidden'); |
|
|
$form->setType('fichier', 'hidden'); |
|
|
$form->setType('lu', 'hidden'); |
|
|
$form->setType('date_reception', 'hidden'); |
|
|
}else{ // modify |
|
|
$form->setType('date_envoi', 'hiddenstaticdate'); |
|
|
$form->setType('date_limite', 'hiddenstaticdate'); |
|
|
$form->setType('service', 'selecthiddenstatic'); |
|
|
$form->setType('date_retour', 'date2'); |
|
|
$form->setType('avis_consultation', 'select'); |
|
|
$form->setType('motivation', 'textarea'); |
|
|
$form->setType('fichier', 'upload2'); |
|
|
|
|
|
//Affichage du champ en modification pour le prifil instructeur |
|
|
if(!$this->f->isAccredited('consultation_modifier_lu')) { |
|
|
$form->setType('lu', 'hidden'); |
|
|
} |
|
|
} |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
|
} |
|
|
$form->setType('consultation', 'hidden'); |
|
|
//setType pour profil service |
|
|
if($this->f->isAccredited('consultation_retour_avis_service')) { |
|
|
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('service', 'hidden'); |
|
|
$form->setType('date_envoi', 'hidden'); |
|
85 |
$form->setType('date_retour', 'hidden'); |
$form->setType('date_retour', 'hidden'); |
86 |
$form->setType('date_reception', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
87 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_limite', 'hidden'); |
88 |
|
$form->setType('avis_consultation', 'hidden'); |
89 |
|
$form->setType('motivation', 'hidden'); |
90 |
|
$form->setType('fichier', 'hidden'); |
91 |
$form->setType('lu', 'hidden'); |
$form->setType('lu', 'hidden'); |
92 |
|
// On permet la modification de certains champs |
93 |
|
$form->setType('dossier', 'hiddenstatic'); |
94 |
|
$form->setType('service', 'select'); |
95 |
|
$form->setType('date_envoi', 'date2'); |
96 |
} |
} |
97 |
|
// MODE - MODIFIER |
98 |
|
if ($maj == 1) { |
99 |
|
|
100 |
|
// On affiche en statique les informations qui ne sont plus |
101 |
|
// modifiables |
102 |
|
$form->setType('dossier', 'hiddenstatic'); |
103 |
|
$form->setType('date_envoi', 'hiddenstaticdate'); |
104 |
|
$form->setType('date_limite', 'hiddenstaticdate'); |
105 |
|
$form->setType('service', 'selecthiddenstatic'); |
106 |
|
|
107 |
|
// La date de réception ne peut être modifiée que par un |
108 |
|
// utilisateur en ayant spécifiquement la permission |
109 |
|
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
110 |
|
$form->setType('date_reception', 'date2'); |
111 |
|
} else { |
112 |
|
$form->setType('date_reception', 'hiddenstaticdate'); |
113 |
|
} |
114 |
|
|
115 |
|
// Le marqueur lu/non lu ne peut être modifié que par un |
116 |
|
// utilisateur en ayant spécifiquement la permission |
117 |
|
if ($this->f->isAccredited('consultation_modifier_lu')) { |
118 |
|
$form->setType('lu', 'checkbox'); |
119 |
|
} else { |
120 |
|
$form->setType('lu', 'hidden'); |
121 |
|
} |
122 |
|
|
123 |
|
// Gestion du type du widget sur le champ fichier |
124 |
|
if($this->val[array_search("fichier",$this->champs)]=="" OR |
125 |
|
$this->f->isAccredited('consultation_modifier_fichier')) { |
126 |
|
// Si il n'y a jamais eu de fichier enregistré ou que |
127 |
|
// l'utilisateur a spécifiquement les droits pour modifier |
128 |
|
// un fichier déjà enregistré alors on positionne un type |
129 |
|
// de widget modifiable |
130 |
|
$form->setType('fichier', 'tmpUpload'); |
131 |
|
} else { |
132 |
|
// Si non on affiche uniquement le nom du fichier |
133 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
134 |
|
} |
135 |
|
|
136 |
|
// Modification layout : écran de retour d'avis permettant |
137 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
138 |
|
if (!$this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
139 |
|
|
140 |
|
// On cache alors tous les champs que nous ne voulons pas voir |
141 |
|
$form->setType('dossier', 'hidden'); |
142 |
|
$form->setType('service', 'hidden'); |
143 |
|
$form->setType('date_envoi', 'hidden'); |
144 |
|
$form->setType('date_retour', 'hidden'); |
145 |
|
$form->setType('date_reception', 'hidden'); |
146 |
|
$form->setType('date_limite', 'hidden'); |
147 |
|
$form->setType('lu', 'hidden'); |
148 |
|
|
149 |
|
} |
150 |
|
|
151 |
|
} |
152 |
|
// MODE - CONSULTER |
153 |
|
if ( $maj == 3 ) { |
154 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
155 |
|
} |
156 |
|
//// On cache la clé primaire |
157 |
|
//$form->setType('consultation', 'hidden'); |
158 |
} |
} |
159 |
|
|
160 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
194 |
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
195 |
_("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']). |
_("Il concerne le terrain situe a l'adresse :")." ".utf8_decode($dossier['terrain_adresse']). |
196 |
" ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>". |
" ".utf8_decode($dossier['terrain_adresse_complement'])." ".utf8_decode($dossier['terrain_cp'])." ".$dossier['terrain_ville']."<br/>". |
197 |
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('lien_interne_vdm'). |
_("Vous pouvez y acceder et rendre votre avis a l'adresse")." <a href='".$this->f->getParameter('services_consultes_lien_interne'). |
198 |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
199 |
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('lien_externe'). |
_("Lien interne (services VDM)")."</a> "._("ou")." <a href='".$this->f->getParameter('services_consultes_lien_externe'). |
200 |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
201 |
_("Lien externe (hors VDM)")."</a>"; |
_("Lien externe (hors VDM)")."</a>"; |
202 |
// Envoi du mail avec message de retour |
// Envoi du mail avec message de retour |
253 |
// Add fieldset |
// Add fieldset |
254 |
// ============================================= |
// ============================================= |
255 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
256 |
if ( $maj < 2 OR $maj == 3 ) { |
|
257 |
if(!$this->f->isAccredited('consultation_retour_avis_service')) { |
// Modification layout : écran de retour d'avis permettant |
258 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
259 |
|
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
260 |
|
|
261 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
262 |
$form->setBloc('dossier','D',""); |
$form->setBloc('dossier','D',""); |
263 |
$form->setFieldset('dossier','D',_('Consultation')); |
$form->setFieldset('dossier','D',_('Consultation')); |
265 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
266 |
$form->setFieldset('date_envoi','F',''); |
$form->setFieldset('date_envoi','F',''); |
267 |
$form->setBloc('date_envoi','F'); |
$form->setBloc('date_envoi','F'); |
268 |
|
|
269 |
} |
} |
270 |
if ( $maj == 1 OR $maj == 3 ){ |
|
271 |
|
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
272 |
|
// d'avis |
273 |
|
if ($maj != 0) { |
274 |
|
|
275 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
276 |
$form->setBloc('date_reception','D',""); |
$form->setBloc('date_reception','D',""); |
277 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
278 |
|
|
279 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
280 |
$form->setFieldset('lu','F',''); |
$form->setFieldset('lu','F',''); |
281 |
$form->setBloc('lu','F'); |
$form->setBloc('lu','F'); |
282 |
|
|
283 |
} |
} |
284 |
|
} |
285 |
|
|
286 |
|
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
287 |
|
* code barre si besoin |
288 |
|
**/ |
289 |
|
function retour($premier = 0, $recherche = "", $tricol = "") { |
290 |
|
$params ="obj=".get_class($this); |
291 |
|
if($this->getParameter("retour")=="form") { |
292 |
|
$params .= "&idx=".$this->getParameter("idx"); |
293 |
|
$params .= "&action=3"; |
294 |
} |
} |
295 |
|
$params .= "&premier=".$this->getParameter("premier"); |
296 |
|
$params .= "&tricol=".$this->getParameter("tricol"); |
297 |
|
$params .= "&recherche=".$this->getParameter("recherche"); |
298 |
|
$params .= "&selectioncol=".$this->getParameter("selectioncol"); |
299 |
|
$params .= "&advs_id=".$this->getParameter("advs_id"); |
300 |
|
$params .= "&valide=".$this->getParameter("valide"); |
301 |
|
echo "\n<a class=\"retour\" "; |
302 |
|
echo "href=\""; |
303 |
|
// |
304 |
|
|
305 |
|
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
306 |
|
echo "form.php?".$params; |
307 |
|
} elseif($this->getParameter("retour")=="avis_code_barre") { |
308 |
|
echo "../app/avis_code_barre.php"; |
309 |
|
} else { |
310 |
|
echo "tab.php?".$params; |
311 |
|
} |
312 |
|
// |
313 |
|
echo "\""; |
314 |
|
echo ">"; |
315 |
|
// |
316 |
|
echo _("Retour"); |
317 |
|
// |
318 |
|
echo "</a>\n"; |
319 |
|
|
320 |
} |
} |
321 |
|
|
322 |
}// fin classe |
}// fin classe |