2 |
//$Id$ |
//$Id$ |
3 |
//gen openMairie le 10/02/2011 20:32 |
//gen openMairie le 10/02/2011 20:32 |
4 |
require_once ("../gen/obj/consultation.class.php"); |
require_once ("../gen/obj/consultation.class.php"); |
5 |
|
require_once("../services/outgoing/messageenqueuer.php"); |
6 |
|
|
7 |
class consultation extends consultation_gen { |
class consultation extends consultation_gen { |
8 |
|
|
42 |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
$this->val[array_search("avis_consultation",$this->champs)] != $val["avis_consultation"] OR |
43 |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
$this->val[array_search("date_retour",$this->champs)] != $val["date_retour"] OR |
44 |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
$this->val[array_search("motivation",$this->champs)] != $val["motivation"] OR |
45 |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"] ) |
$this->val[array_search("fichier",$this->champs)] != $val["fichier"]) |
46 |
) { |
) { |
47 |
$this->valF["lu"]=false; |
$this->valF["lu"]=false; |
48 |
} |
} |
49 |
|
} |
50 |
|
|
51 |
|
function verifier($val, &$db, $DEBUG) { |
52 |
|
parent::verifier($val, $db, $DEBUG); |
53 |
// Si le fichier envoye est different de l'existant |
// Si le fichier envoye est different de l'existant |
54 |
if (isset($this->val[array_search("fichier",$this->champs)]) |
if (isset($this->val[array_search("fichier",$this->champs)]) |
55 |
&& $this->val[array_search("fichier",$this->champs)] != $val["fichier"] |
&& $this->val[array_search("fichier",$this->champs)] != $val["fichier"] |
71 |
// Sinon on supprime le fichier dans tmp |
// Sinon on supprime le fichier dans tmp |
72 |
// on reinitialise le nom du fichier a l'ancienne valeur |
// on reinitialise le nom du fichier a l'ancienne valeur |
73 |
} else { |
} else { |
74 |
|
$this->correct = false; |
75 |
$this->addToMessage($res); |
$this->addToMessage($res); |
76 |
unlink("../tmp/".$this->valF['fichier']); |
unlink("../tmp/".$this->valF['fichier']); |
77 |
$this->valF['fichier']=$this->val[array_search("fichier",$this->champs)]; |
$this->valF['fichier']=$this->val[array_search("fichier",$this->champs)]; |
81 |
} |
} |
82 |
|
|
83 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
84 |
|
// Appel du parent |
85 |
parent::setType($form,$maj); |
parent::setType($form,$maj); |
86 |
if ($maj < 2) { //ajouter et modifier [add and modify] |
// MODE - AJOUTER |
87 |
if($maj==0){ // add |
if ($maj == 0) { |
88 |
$form->setType('dossier', 'hiddenstatic'); |
// On cache alors tous les champs que nous ne voulons pas voir |
89 |
$form->setType('date_envoi', 'date2'); |
// apparaître dans le formulaire d'ajout (principalement les |
90 |
$form->setType('service', 'select'); |
// informations sur le retour d'avis) |
91 |
$form->setType('date_limite', 'hidden'); |
$form->setType('date_retour', 'hidden'); |
92 |
$form->setType('date_retour', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
93 |
$form->setType('avis_consultation', 'hidden'); |
$form->setType('date_limite', 'hidden'); |
94 |
$form->setType('motivation', 'hidden'); |
$form->setType('avis_consultation', 'hidden'); |
95 |
$form->setType('fichier', 'hidden'); |
$form->setType('motivation', 'hidden'); |
96 |
|
$form->setType('fichier', 'hidden'); |
97 |
|
$form->setType('lu', 'hidden'); |
98 |
|
// On permet la modification de certains champs |
99 |
|
$form->setType('dossier', 'hiddenstatic'); |
100 |
|
$form->setType('service', 'select'); |
101 |
|
$form->setType('date_envoi', 'date2'); |
102 |
|
} |
103 |
|
// MODE - MODIFIER |
104 |
|
if ($maj == 1) { |
105 |
|
|
106 |
|
// On affiche en statique les informations qui ne sont plus |
107 |
|
// modifiables |
108 |
|
$form->setType('dossier', 'hiddenstatic'); |
109 |
|
$form->setType('date_envoi', 'hiddenstaticdate'); |
110 |
|
$form->setType('date_limite', 'hiddenstaticdate'); |
111 |
|
$form->setType('service', 'selecthiddenstatic'); |
112 |
|
|
113 |
|
// La date de réception ne peut être modifiée que par un |
114 |
|
// utilisateur en ayant spécifiquement la permission |
115 |
|
if($this->f->isAccredited('consultation_modifier_date_reception')) { |
116 |
|
$form->setType('date_reception', 'date2'); |
117 |
|
} else { |
118 |
|
$form->setType('date_reception', 'hiddenstaticdate'); |
119 |
|
} |
120 |
|
|
121 |
|
// Le marqueur lu/non lu ne peut être modifié que par un |
122 |
|
// utilisateur en ayant spécifiquement la permission |
123 |
|
if ($this->f->isAccredited('consultation_modifier_lu')) { |
124 |
|
$form->setType('lu', 'checkbox'); |
125 |
|
} else { |
126 |
$form->setType('lu', 'hidden'); |
$form->setType('lu', 'hidden'); |
127 |
|
} |
128 |
|
|
129 |
|
// Gestion du type du widget sur le champ fichier |
130 |
|
if($this->val[array_search("fichier",$this->champs)]=="" OR |
131 |
|
$this->f->isAccredited('consultation_modifier_fichier')) { |
132 |
|
// Si il n'y a jamais eu de fichier enregistré ou que |
133 |
|
// l'utilisateur a spécifiquement les droits pour modifier |
134 |
|
// un fichier déjà enregistré alors on positionne un type |
135 |
|
// de widget modifiable |
136 |
|
$form->setType('fichier', 'tmpUpload'); |
137 |
|
} else { |
138 |
|
// Si non on affiche uniquement le nom du fichier |
139 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
140 |
|
} |
141 |
|
|
142 |
|
// Modification layout : écran de retour d'avis permettant |
143 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
144 |
|
if (!$this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
145 |
|
|
146 |
|
// On cache alors tous les champs que nous ne voulons pas voir |
147 |
|
$form->setType('dossier', 'hidden'); |
148 |
|
$form->setType('service', 'hidden'); |
149 |
|
$form->setType('date_envoi', 'hidden'); |
150 |
|
$form->setType('date_retour', 'hidden'); |
151 |
$form->setType('date_reception', 'hidden'); |
$form->setType('date_reception', 'hidden'); |
152 |
}else{ // modify |
$form->setType('date_limite', 'hidden'); |
153 |
if($this->f->isAccredited('consultation_retour_avis_service')) { |
$form->setType('lu', 'hidden'); |
154 |
$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'); |
|
|
// Si il n'y a pas de fichier ou que l'utilisateur a les droits |
|
|
if($this->val[array_search("fichier",$this->champs)]=="" OR |
|
|
$this->f->isAccredited('consultation_modifier_fichier')) { |
|
|
$form->setType('fichier', 'tmpUpload'); |
|
|
} else { |
|
|
$form->setType('fichier', 'hiddenstatic'); |
|
|
} |
|
|
} 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'); |
|
|
// Si il n'y a pas de fichier ou que l'utilisateur a les droits |
|
|
if($this->val[array_search("fichier",$this->champs)]=="" OR |
|
|
$this->f->isAccredited('consultation_modifier_fichier')) { |
|
|
$form->setType('fichier', 'tmpUpload'); |
|
|
} else { |
|
|
$form->setType('fichier', 'hiddenstatic'); |
|
|
} |
|
|
//Affichage du champ en modification pour le prifil instructeur |
|
|
if(!$this->f->isAccredited('consultation_modifier_lu')) { |
|
|
$form->setType('lu', 'hidden'); |
|
|
} |
|
|
} |
|
155 |
} |
} |
|
} |
|
|
$form->setType('consultation', 'hidden'); |
|
|
//setType pour profil service |
|
156 |
|
|
157 |
|
} |
158 |
|
// MODE - CONSULTER |
159 |
|
if ( $maj == 3 ) { |
160 |
|
$form->setType('fichier', 'tmpUploadStatic'); |
161 |
|
} |
162 |
|
//// On cache la clé primaire |
163 |
|
//$form->setType('consultation', 'hidden'); |
164 |
} |
} |
165 |
|
|
166 |
// TRIGGER AVANT MODIFICATION DE DONNEES |
// TRIGGER AVANT MODIFICATION DE DONNEES |
213 |
} |
} |
214 |
} |
} |
215 |
|
|
216 |
|
// s'il s'agit de la consultation ERP Secu, ERP Accessibilite, ou |
217 |
|
// deenvoie un |
218 |
|
// message a ERP |
219 |
|
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE. |
220 |
|
"dossier WHERE dossier = '" .$this->valF['dossier'] . "'"); |
221 |
|
$dossier_nature = $this->getFromDB("SELECT nature FROM ".DB_PREFIXE. |
222 |
|
"dossier WHERE dossier = '" . $this->valF['dossier'] . "'"); |
223 |
|
if ($dossier_erp == 't' |
224 |
|
&& substr($dossier_nature, 0, 2) == $this->f->getParameter('erp_dossier_nature_pc')) { |
225 |
|
// envoi du message "Demande d'instruction d'un dossier PC pour un ERP" |
226 |
|
if (($this->valF['service'] == $this->f->getParameter('erp_service_accessibilite') |
227 |
|
|| $this->valF['service'] == $this->f->getParameter('erp_service_securite'))) { |
228 |
|
$msgenque = new MessageEnqueuer(); |
229 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
230 |
|
$msgenque->setConsultationIdentifier($this->valF['consultation']); |
231 |
|
$msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_INSTRUCTION_PC); |
232 |
|
} |
233 |
|
|
234 |
|
// envoi du message "Consultation ERP pour conformite" en cas de creation de la |
235 |
|
// consultation du service ERP Conformite |
236 |
|
if ($this->valF['service'] == $this->f->getParameter('erp_service_conformite')) { |
237 |
|
$msgenque = new MessageEnqueuer(); |
238 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
239 |
|
$msgenque->setConsultationIdentifier($this->valF['consultation']); |
240 |
|
$msgenque->enqueueMessage($msgenque::$ERP_CONSULTATION_CONFORMITE); |
241 |
|
} |
242 |
|
} |
243 |
|
|
244 |
|
} |
245 |
|
|
246 |
|
/** |
247 |
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
248 |
|
* cette valeur |
249 |
|
* @param string $sql La requete sql a executer |
250 |
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
251 |
|
* l'execution s'arrete. |
252 |
|
*/ |
253 |
|
function getFromDB($sql) { |
254 |
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
255 |
|
$res = $this->db->limitquery($sql, 0, 1); |
256 |
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
257 |
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
258 |
|
// Si une erreur survient on die |
259 |
|
if (database::isError($res, true)) { |
260 |
|
// Appel de la methode de recuperation des erreurs |
261 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
262 |
|
} |
263 |
|
// retourne la nature du dossier |
264 |
|
while ($row =& $res->fetchRow()) { |
265 |
|
return $row[0]; |
266 |
|
} |
267 |
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
268 |
|
return NULL; |
269 |
|
|
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
|
/** |
274 |
|
* Returne la nature du dossier auquel la consultation appartient. |
275 |
|
* @param string $dossier L'identifiant du dossier |
276 |
|
* @return La nature du dossier si elle existe, sinon NULL. En cas |
277 |
|
* d'erreur de la BD, l'execution se termine. |
278 |
|
*/ |
279 |
|
function getDossierNature($dossier) { |
280 |
|
$sql = "SELECT nature FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
281 |
|
$res = $this->db->limitquery($sql, 0, 1); |
282 |
|
$this->addToLog("getDossierNature(): db->limitquery(\"".str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
283 |
|
// Si une erreur survient on die |
284 |
|
if (database::isError($res, true)) { |
285 |
|
// Appel de la methode de recuperation des erreurs |
286 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'dossier'); |
287 |
|
} |
288 |
|
// retourne la nature du dossier |
289 |
|
while ($row =& $res->fetchRow()) { |
290 |
|
return $row[0]; |
291 |
|
} |
292 |
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
293 |
|
return NULL; |
294 |
} |
} |
295 |
|
|
296 |
// ============================================= |
// ============================================= |
337 |
// Add fieldset |
// Add fieldset |
338 |
// ============================================= |
// ============================================= |
339 |
function setLayout(&$form, $maj){ |
function setLayout(&$form, $maj){ |
340 |
if ( $maj < 2 OR $maj == 3 ) { |
|
341 |
if(!$this->f->isAccredited('consultation_retour_avis_service')) { |
// Modification layout : écran de retour d'avis permettant |
342 |
|
// uniquement la saisie des trois champs : avis, motivation et fichier |
343 |
|
if ($this->f->isAccredited('consultation_consulter_autre_que_retour_avis')) { |
344 |
|
|
345 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
346 |
$form->setBloc('dossier','D',""); |
$form->setBloc('dossier','D',""); |
347 |
$form->setFieldset('dossier','D',_('Consultation')); |
$form->setFieldset('dossier','D',_('Consultation')); |
349 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
350 |
$form->setFieldset('date_envoi','F',''); |
$form->setFieldset('date_envoi','F',''); |
351 |
$form->setBloc('date_envoi','F'); |
$form->setBloc('date_envoi','F'); |
352 |
|
|
353 |
} |
} |
354 |
if ( $maj == 1 OR $maj == 3 ){ |
|
355 |
|
// MODE - autre que AJOUTER alors on affiche un fieldset retour |
356 |
|
// d'avis |
357 |
|
if ($maj != 0) { |
358 |
|
|
359 |
//Champs sur lequel s'ouvre le fieldset |
//Champs sur lequel s'ouvre le fieldset |
360 |
$form->setBloc('date_reception','D',""); |
$form->setBloc('date_reception','D',""); |
361 |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
$form->setFieldset('date_reception','D',_('Retour d\'avis')); |
362 |
|
|
363 |
//Champs sur lequel se ferme le fieldset |
//Champs sur lequel se ferme le fieldset |
364 |
$form->setFieldset('lu','F',''); |
$form->setFieldset('lu','F',''); |
365 |
$form->setBloc('lu','F'); |
$form->setBloc('lu','F'); |
366 |
|
|
367 |
} |
} |
|
} |
|
368 |
} |
} |
369 |
|
|
370 |
/** 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 |
400 |
echo _("Retour"); |
echo _("Retour"); |
401 |
// |
// |
402 |
echo "</a>\n"; |
echo "</a>\n"; |
|
|
|
403 |
} |
} |
404 |
|
|
405 |
|
/** |
406 |
|
* Surcharge pour gérer les actions disponibles dans le portlet |
407 |
|
*/ |
408 |
|
function checkAccessibility() { |
409 |
|
// |
410 |
|
if (isset($this->actions_sup["lu"]) && $this->val[10] == "t") { |
411 |
|
unset($this->actions_sup["lu"]); |
412 |
|
} |
413 |
|
// |
414 |
|
parent::checkAccessibility(); |
415 |
|
} |
416 |
|
|
417 |
|
/** |
418 |
|
* Méthode de verification d'accèssibilité de la consultation |
419 |
|
* à l'utilisateur connecté |
420 |
|
*/ |
421 |
|
function canAccess() { |
422 |
|
parent::canAccess(); |
423 |
|
if($this->f->isUserServiceExt()) { |
424 |
|
// On compare l'id du service de la consultation |
425 |
|
// aux id des services de utilisateur connecté |
426 |
|
foreach($this->f->om_utilisateur['service'] as $service) { |
427 |
|
if($this->val[array_search("service",$this->champs)]===$service['service']) { |
428 |
|
return true; |
429 |
|
} |
430 |
|
} |
431 |
|
return false; |
432 |
|
} else{ |
433 |
|
return true; |
434 |
|
} |
435 |
|
} |
436 |
|
|
437 |
|
/** |
438 |
|
* Surcharge du bouton retour pour popup |
439 |
|
*/ |
440 |
|
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
441 |
|
$objsf, $premiersf, $tricolsf, $validation, |
442 |
|
$idx, $maj, $retour) { |
443 |
|
if($retourformulaire === "demande_avis_encours") { |
444 |
|
echo "\n<a class=\"retour\" "; |
445 |
|
echo "href=\""; |
446 |
|
echo "#"; |
447 |
|
echo "\" "; |
448 |
|
echo ">"; |
449 |
|
// |
450 |
|
echo _("Retour"); |
451 |
|
// |
452 |
|
echo "</a>\n"; |
453 |
|
} else { |
454 |
|
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
455 |
|
$objsf, $premiersf, $tricolsf, $validation, |
456 |
|
$idx, $maj, $retour); |
457 |
|
} |
458 |
|
} |
459 |
}// fin classe |
}// fin classe |
460 |
?> |
?> |