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 |
41 |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
$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 |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
43 |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
44 |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"] |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"] ) |
|
) |
|
45 |
) { |
) { |
46 |
$this->valF["lu"]=false; |
$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) |
85 |
$form->setType('date_retour', 'hidden'); |
$form->setType('date_retour', 'hidden'); |
86 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
87 |
$form->setType('motivation', 'hidden'); |
$form->setType('date_limite', 'hidden'); |
88 |
$form->setType('fichier', 'hidden'); |
$form->setType('avis_consultation', 'hidden'); |
89 |
|
$form->setType('motivation', 'hidden'); |
90 |
|
$form->setType('fichier', 'hidden'); |
91 |
|
$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'); |
$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', 'hiddenstatic'); |
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'); |
$form->setType('date_reception', 'hidden'); |
146 |
}else{ // modify |
$form->setType('date_limite', 'hidden'); |
147 |
if($this->f->isAccredited('consultation_retour_avis_service')) { |
$form->setType('lu', 'hidden'); |
148 |
$form->setType('dossier', 'hidden'); |
|
|
$form->setType('service', 'hidden'); |
|
|
$form->setType('date_envoi', 'hidden'); |
|
|
$form->setType('date_retour', 'hidden'); |
|
|
$form->setType('date_reception', 'hidden'); |
|
|
$form->setType('date_limite', 'hidden'); |
|
|
$form->setType('lu', 'hidden'); |
|
|
$form->setType('fichier', 'upload2'); |
|
|
} else { |
|
|
$form->setType('dossier', 'hiddenstatic'); |
|
|
$form->setType('date_envoi', 'hiddenstaticdate'); |
|
|
$form->setType('date_limite', 'hiddenstaticdate'); |
|
|
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
|
|
$form->setType('date_reception', 'hiddenstaticdate'); |
|
|
} else { |
|
|
$form->setType('date_reception', 'date2'); |
|
|
} |
|
|
$form->setType('service', 'selecthiddenstatic'); |
|
|
$form->setType('date_retour', 'date2'); |
|
|
$form->setType('avis_consultation', 'select'); |
|
|
$form->setType('motivation', 'textarea'); |
|
|
if(!isset($this->parameters['retourformulaire'])) { |
|
|
$form->setType('fichier', 'upload'); |
|
|
} else { |
|
|
$form->setType('fichier', 'upload2'); |
|
|
} |
|
|
//Affichage du champ en modification pour le prifil instructeur |
|
|
if(!$this->f->isAccredited('consultation_modifier_lu')) { |
|
|
$form->setType('lu', 'hidden'); |
|
|
} |
|
|
} |
|
149 |
} |
} |
|
} |
|
|
$form->setType('consultation', 'hidden'); |
|
|
//setType pour profil service |
|
150 |
|
|
151 |
|
} |
152 |
|
//// On cache la clé primaire |
153 |
|
//$form->setType('consultation', 'hidden'); |
154 |
} |
} |
155 |
|
|
156 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
190 |
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
$corps=_("Votre service est consulte concernant le dossier no")." ".$dossier['dossier']."<br/>". |
191 |
_("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']). |
192 |
" ".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/>". |
193 |
_("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'). |
194 |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
195 |
_("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'). |
196 |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
"scr/form.php?obj=consultation&action=3&idx=".$this->valF['consultation']."' >". |
197 |
_("Lien externe (hors VDM)")."</a>"; |
_("Lien externe (hors VDM)")."</a>"; |
198 |
// Envoi du mail avec message de retour |
// Envoi du mail avec message de retour |
249 |
// Add fieldset |
// Add fieldset |
250 |
// ============================================= |
// ============================================= |
251 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
252 |
if ( $maj < 2 OR $maj == 3 ) { |
|
253 |
if(!$this->f->isAccredited('consultation_retour_avis_service')) { |
// Modification layout : écran de retour d'avis permettant |
254 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
255 |
|
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
256 |
|
|
257 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
258 |
$form->setBloc('dossier','D',""); |
$form->setBloc('dossier','D',""); |
259 |
$form->setFieldset('dossier','D',_('Consultation')); |
$form->setFieldset('dossier','D',_('Consultation')); |
261 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
262 |
$form->setFieldset('date_envoi','F',''); |
$form->setFieldset('date_envoi','F',''); |
263 |
$form->setBloc('date_envoi','F'); |
$form->setBloc('date_envoi','F'); |
264 |
|
|
265 |
} |
} |
266 |
if ( $maj == 1 OR $maj == 3 ){ |
|
267 |
|
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
268 |
|
// d'avis |
269 |
|
if ($maj != 0) { |
270 |
|
|
271 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
272 |
$form->setBloc('date_reception','D',""); |
$form->setBloc('date_reception','D',""); |
273 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
274 |
|
|
275 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
276 |
$form->setFieldset('lu','F',''); |
$form->setFieldset('lu','F',''); |
277 |
$form->setBloc('lu','F'); |
$form->setBloc('lu','F'); |
278 |
|
|
279 |
} |
} |
|
} |
|
280 |
} |
} |
281 |
|
|
282 |
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |
/** Surcharge de la methode retour afin de retourner sur la page de saisie de |