85 |
|
|
86 |
// ACTION - 001 - modifier |
// ACTION - 001 - modifier |
87 |
// |
// |
88 |
$this->class_actions[1]["condition"] = array("show_consultation_finaliser_portlet_action", |
$this->class_actions[1]["condition"] = array("is_editable"); |
|
"is_editable"); |
|
89 |
|
|
90 |
// ACTION - 002 - supprimer |
// ACTION - 002 - supprimer |
91 |
// |
// |
92 |
$this->class_actions[2]["condition"] = array("show_consultation_finaliser_portlet_action", |
$this->class_actions[2]["condition"] = array("is_deletable"); |
|
"is_deletable"); |
|
93 |
|
|
94 |
// ACTION - 040 - ajout_multiple |
// ACTION - 040 - ajout_multiple |
95 |
// Ajout de consultattons multiples |
// Ajout de consultattons multiples |
1512 |
$form->setVal("dossier", $idxformulaire); |
$form->setVal("dossier", $idxformulaire); |
1513 |
$form->setVal("date_envoi",date('d/m/Y')); |
$form->setVal("date_envoi",date('d/m/Y')); |
1514 |
} |
} |
1515 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
if(($maj == 1 or $maj == 90 or $maj == 100) AND $this->getVal("date_retour") == "") { |
1516 |
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
if($this->f->isAccredited('consultation_retour_avis_suivi') OR |
1517 |
$this->f->isAccredited('consultation_retour_avis_service')) { |
$this->f->isAccredited('consultation_retour_avis_service')) { |
1518 |
$form->setVal("date_retour",date('d/m/Y')); |
$form->setVal("date_retour",date('d/m/Y')); |
1522 |
} |
} |
1523 |
|
|
1524 |
function setVal(&$form, $maj, $validation) { |
function setVal(&$form, $maj, $validation) { |
1525 |
if($maj == 1 or $maj == 90 or $maj == 100) { |
if(($maj == 1 or $maj == 90 or $maj == 100) AND $this->getVal("date_retour") == "") { |
1526 |
$form->setVal("date_retour",date('d/m/Y')); |
$form->setVal("date_retour",date('d/m/Y')); |
1527 |
} |
} |
1528 |
} |
} |
1683 |
$form->setType("avis_consultation", "select"); |
$form->setType("avis_consultation", "select"); |
1684 |
$form->setType("motivation", "textarea"); |
$form->setType("motivation", "textarea"); |
1685 |
$form->setType('fichier', 'upload'); |
$form->setType('fichier', 'upload'); |
1686 |
|
// Gestion du type du widget sur le champ fichier |
1687 |
|
if($this->getVal("fichier") == "" OR |
1688 |
|
$this->f->isAccredited(array('consultation', 'consultation_modifier_fichier'), 'OR')) { |
1689 |
|
// Si il n'y a jamais eu de fichier enregistré ou que |
1690 |
|
// l'utilisateur a spécifiquement les droits pour modifier |
1691 |
|
// un fichier déjà enregistré alors on positionne un type |
1692 |
|
// de widget modifiable |
1693 |
|
if ($this->retourformulaire == "demande_avis_encours" |
1694 |
|
|| $this->retourformulaire == "dossier_qualifier" |
1695 |
|
|| $this->retourformulaire == "dossier" |
1696 |
|
|| $this->retourformulaire == "dossier_instruction" |
1697 |
|
|| $this->retourformulaire == "dossier_instruction_mes_encours" |
1698 |
|
|| $this->retourformulaire == "dossier_instruction_tous_encours" |
1699 |
|
|| $this->retourformulaire == "dossier_instruction_mes_clotures" |
1700 |
|
|| $this->retourformulaire == "dossier_instruction_tous_clotures") { |
1701 |
|
$form->setType('fichier', 'upload2'); |
1702 |
|
} else { |
1703 |
|
$form->setType('fichier', 'upload'); |
1704 |
|
} |
1705 |
|
} else { |
1706 |
|
// Si non on affiche uniquement le nom du fichier |
1707 |
|
$form->setType('fichier', 'filestaticedit'); |
1708 |
|
} |
1709 |
} |
} |
1710 |
//// On cache la clé primaire |
//// On cache la clé primaire |
1711 |
//$form->setType('consultation', 'hidden'); |
//$form->setType('consultation', 'hidden'); |
1837 |
$corps = iconv("UTF-8", "CP1252", $corps); |
$corps = iconv("UTF-8", "CP1252", $corps); |
1838 |
// Envoi du mail avec message de retour |
// Envoi du mail avec message de retour |
1839 |
if ($this->f->sendMail($title, $corps, iconv("UTF-8", "CP1252", $inst_service->getVal('email')))) { |
if ($this->f->sendMail($title, $corps, iconv("UTF-8", "CP1252", $inst_service->getVal('email')))) { |
1840 |
$this->addToMessage(_("Envoi d'un mail de notification au service")." \"(".$inst_service->getVal('abrege').") ".$inst_service->getVal("libelle")."\""); |
$this->addToMessage(_("Envoi d'un mail de notification au service")." \"(".$inst_service->getVal('abrege').") ".$inst_service->getVal("libelle")."\"."); |
1841 |
} else { |
} else { |
1842 |
$this->addToMessage(_("L'envoi du mail de notification a echoue")); |
$this->addToMessage(_("L'envoi du mail de notification a échoué.") |
1843 |
|
.' '._("Veuillez contacter votre administrateur.")); |
1844 |
} |
} |
1845 |
} |
} |
1846 |
|
|
1914 |
* Finalisation du document PDF de consultation. |
* Finalisation du document PDF de consultation. |
1915 |
*/ |
*/ |
1916 |
// |
// |
1917 |
$this->finaliserAjouter($id); |
return $this->finaliserAjouter($id); |
1918 |
} |
} |
1919 |
|
|
1920 |
// ============================================= |
// ============================================= |
2060 |
/** |
/** |
2061 |
* Finalisation du document lors de l'ajout d'une consultation. |
* Finalisation du document lors de l'ajout d'une consultation. |
2062 |
* |
* |
2063 |
* @param integer $id indentifiant de l'objet |
* @param integer $id_consult indentifiant de l'objet |
2064 |
*/ |
*/ |
2065 |
function finaliserAjouter($id){ |
function finaliserAjouter($id_consult){ |
2066 |
|
// |
2067 |
$uid = $this->file_finalizing($id); |
$this->begin_treatment(__METHOD__); |
|
|
|
|
//Mise à jour des données |
|
|
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
|
|
// Logger |
|
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
|
2068 |
|
|
2069 |
$valF = array( |
// |
2070 |
"om_final_consultation"=> true, |
$admin_msg_error = _("Veuillez contacter votre administrateur."); |
2071 |
"om_fichier_consultation"=>$uid |
$file_msg_error = _("La finalisation du document a échoué.") |
2072 |
); |
." ".$admin_msg_error; |
2073 |
|
$bdd_msg_error = _("Erreur de base de données.") |
2074 |
|
." ".$admin_msg_error; |
2075 |
|
$log_msg_error = "Finalisation non enregistrée |
2076 |
|
- id consultation = %s |
2077 |
|
- uid fichier = %s"; |
2078 |
|
|
2079 |
|
$uid = $this->file_finalizing($id_consult); |
2080 |
|
// Comme pour le fonctionnement de l'envoi de mail, |
2081 |
|
// Si échec cela ne stoppe pas la création de la consultation. |
2082 |
|
// L'utilisateur en est tout de même informé dans l'IHM |
2083 |
|
// et l'erreur est loguée. |
2084 |
|
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
2085 |
|
$this->addToMessage($file_msg_error); |
2086 |
|
$this->addToLog(sprintf($log_msg_error, $id_consult, $uid)); |
2087 |
|
return $this->end_treatment(__METHOD__, true); |
2088 |
|
} |
2089 |
|
|
2090 |
// Execution de la requête de modification des donnees de l'attribut |
// Si succès mise à jour de la consultation |
2091 |
// valF de l'objet dans l'attribut table de l'objet |
$valF = array( |
2092 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
"om_final_consultation" => true, |
2093 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
"om_fichier_consultation" => $uid |
2094 |
$this->addToLog( |
); |
2095 |
"finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
// |
2096 |
VERBOSE_MODE |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
2097 |
); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_consult)); |
2098 |
// Si une erreur survient |
// |
2099 |
if (database::isError($res, true)) { |
$this->addToLog( |
2100 |
$this->correct = false; |
"finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_consult)."\")", |
2101 |
// Appel de la methode de recuperation des erreurs |
VERBOSE_MODE |
2102 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
); |
2103 |
return false; |
// |
2104 |
} else { |
if ($this->f->isDatabaseError($res, true) === true) { |
2105 |
// Log |
$this->correct = false; |
2106 |
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
// Remplacement du message de validation |
2107 |
// Log |
$this->msg = ''; |
2108 |
$message = _("Enregistrement")." ".$id." "; |
$this->addToMessage($bdd_msg_error); |
2109 |
$message .= _("de la table")." \"".$this->table."\" "; |
return $this->end_treatment(__METHOD__, false); |
|
$message .= "[ ".$this->db->affectedRows()." "; |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
|
|
$this->addToLog($message, VERBOSE_MODE); |
|
|
} |
|
2110 |
} |
} |
2111 |
|
// |
2112 |
|
return $this->end_treatment(__METHOD__, true); |
2113 |
} |
} |
2114 |
|
|
2115 |
/** |
/** |
2229 |
* @param array $val valeurs soumises par le formulaire |
* @param array $val valeurs soumises par le formulaire |
2230 |
*/ |
*/ |
2231 |
function manage_finalizing($mode = null, $val = array()) { |
function manage_finalizing($mode = null, $val = array()) { |
2232 |
|
// |
2233 |
|
$this->begin_treatment(__METHOD__); |
2234 |
|
|
2235 |
// Recuperation de la valeur de la cle primaire de l'objet |
// Recuperation de la valeur de la cle primaire de l'objet |
2236 |
$id = $this->getVal($this->clePrimaire); |
$id_consult = $this->getVal($this->clePrimaire); |
2237 |
|
|
2238 |
|
// |
2239 |
|
$admin_msg_error = _("Veuillez contacter votre administrateur."); |
2240 |
|
$file_msg_error = _("Erreur de traitement de fichier.") |
2241 |
|
." ".$admin_msg_error; |
2242 |
|
$bdd_msg_error = _("Erreur de base de données.") |
2243 |
|
." ".$admin_msg_error; |
2244 |
|
$log_msg_error = "Finalisation non enregistrée |
2245 |
|
- id consultation = %s |
2246 |
|
- uid fichier = %s"; |
2247 |
|
|
2248 |
// Si on finalise le document |
// Si on finalise le document |
2249 |
if ($mode == "finalize") { |
if ($mode == "finalize") { |
2250 |
|
// |
2251 |
|
$etat = _('finalisation'); |
2252 |
// Finalisation du fichier |
// Finalisation du fichier |
2253 |
$uid = $this->file_finalizing($id); |
$uid = $this->file_finalizing($id_consult); |
2254 |
} |
} |
2255 |
// |
// |
2256 |
else { |
else { |
2257 |
|
// |
2258 |
|
$etat = _('définalisation'); |
2259 |
//Récupération de l'uid du document finalisé |
//Récupération de l'uid du document finalisé |
2260 |
$uid = $this->getVal("om_fichier_consultation"); |
$uid = $this->getVal("om_fichier_consultation"); |
|
|
|
|
//On dé-finalise avant de finaliser |
|
|
if ( $uid == '' || $uid == 'OP_FAILURE' ){ |
|
|
$this->correct = false; |
|
|
$this->msg=""; |
|
|
$this->addToMessage(_("Finalisation non enregistree")); |
|
|
$this->addToLog( |
|
|
_("Finalisation non enregistree")." - ". |
|
|
_("id consultation")." = ".$id." - ". |
|
|
_("uid fichier")." = ".$uid |
|
|
); |
|
|
return false; |
|
|
} |
|
2261 |
} |
} |
2262 |
|
|
2263 |
//Mise à jour des données |
// Si on définalise l'UID doit être défini |
2264 |
if ($uid != '' && $uid != 'OP_FAILURE') { |
// Si on finalise la création/modification du fichier doit avoir réussi |
2265 |
|
if ($uid == '' || $uid == 'OP_FAILURE' ) { |
2266 |
// Logger |
$this->correct = false; |
2267 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
$this->addToMessage($file_msg_error); |
2268 |
|
$this->addToLog(sprintf($log_msg_error, $id_consult, $uid)); |
2269 |
foreach ($this->champs as $key => $value) { |
return $this->end_treatment(__METHOD__, false); |
2270 |
// |
} |
|
$val[$value] = $this->val[$key]; |
|
|
} |
|
|
|
|
|
$this->setvalF($val); |
|
|
|
|
|
// Verification de la validite des donnees |
|
|
$this->verifier($this->val, $this->db, DEBUG); |
|
|
// Si les verifications precedentes sont correctes, on procede a |
|
|
// la modification, sinon on ne fait rien et on retourne une erreur |
|
|
if ($this->correct) { |
|
|
|
|
|
// Execution du trigger 'before' specifique au MODE 'update' |
|
|
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
|
2271 |
|
|
2272 |
// |
foreach ($this->champs as $key => $value) { |
2273 |
$valF = ''; |
// |
2274 |
if($mode=="finalize") { |
$val[$value] = $this->val[$key]; |
2275 |
$valF["om_final_consultation"] = true; |
} |
2276 |
} else { |
$this->setvalF($val); |
|
$valF["om_final_consultation"] = false; |
|
|
} |
|
|
$valF["om_fichier_consultation"] = $uid; |
|
|
|
|
|
// Execution de la requête de modification des donnees de l'attribut |
|
|
// valF de l'objet dans l'attribut table de l'objet |
|
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
|
|
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
|
|
$this->addToLog( |
|
|
"finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", |
|
|
VERBOSE_MODE |
|
|
); |
|
2277 |
|
|
2278 |
// Si une erreur survient |
// Verification de la validite des donnees |
2279 |
if (database::isError($res, true)) { |
$this->verifier($this->val, $this->db, DEBUG); |
2280 |
|
// Si les verifications precedentes sont correctes, on procede a |
2281 |
|
// la modification, sinon on ne fait rien et on retourne une erreur |
2282 |
|
if ($this->correct === true) { |
2283 |
|
|
2284 |
// Appel de la methode de recuperation des erreurs |
// Execution du trigger 'before' specifique au MODE 'update' |
2285 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
$this->triggermodifier($id_consult, $this->db, $this->val, DEBUG); |
2286 |
$this->correct = false; |
// Suppression de son message de validation |
2287 |
return false; |
$this->msg = ''; |
|
} else { |
|
2288 |
|
|
|
// Log |
|
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
|
|
// Log |
|
|
$message = _("Enregistrement")." ".$id." "; |
|
|
$message .= _("de la table")." \"".$this->table."\" "; |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
|
|
$this->addToLog($message, VERBOSE_MODE); |
|
|
// Execution du trigger 'after' specifique au MODE 'update' |
|
|
$this->triggermodifierapres($id, $this->db, $this->val, DEBUG); |
|
|
|
|
|
if($mode == "finalize") { |
|
|
$etat = _('finalisation'); |
|
|
} else { |
|
|
$etat = _('definalisation'); |
|
|
} |
|
|
$this->msg=""; |
|
|
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
|
|
return true; |
|
|
} |
|
2289 |
// |
// |
2290 |
|
$valF = ''; |
2291 |
|
if ($mode == "finalize") { |
2292 |
|
$valF["om_final_consultation"] = true; |
2293 |
} else { |
} else { |
2294 |
$this->correct = false; |
$valF["om_final_consultation"] = false; |
|
$this->msg=""; |
|
|
// Message d'echec (saut d'une ligne supplementaire avant le |
|
|
// message pour qu'il soit mis en evidence) |
|
|
$this->addToMessage(_("Finalisation non enregistree")); |
|
|
$this->addToLog( |
|
|
_("Finalisation non enregistree")." - ". |
|
|
_("id consultation")." = ".$id." - ". |
|
|
_("uid fichier")." = ".$uid |
|
|
); |
|
|
return false; |
|
2295 |
} |
} |
2296 |
} |
$valF["om_fichier_consultation"] = $uid; |
2297 |
// Si le document n'a pas été stocké |
|
2298 |
else{ |
// Execution de la requête de modification des donnees de l'attribut |
2299 |
$this->correct = false; |
// valF de l'objet dans l'attribut table de l'objet |
2300 |
$this->msg=""; |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
2301 |
$this->addToMessage(_("Finalisation non enregistree")); |
DB_AUTOQUERY_UPDATE, $this->getCle($id_consult)); |
2302 |
$this->addToLog( |
$this->addToLog( |
2303 |
_("Finalisation non enregistree")." - ". |
"finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id_consult)."\")", |
2304 |
_("id consultation")." = ".$id." - ". |
VERBOSE_MODE |
|
_("uid fichier")." = ".$uid |
|
2305 |
); |
); |
2306 |
return false; |
// |
2307 |
|
if ($this->f->isDatabaseError($res, true) === true) { |
2308 |
|
$this->correct = false; |
2309 |
|
$this->addToMessage($bdd_msg_error); |
2310 |
|
return $this->end_treatment(__METHOD__, false); |
2311 |
|
} |
2312 |
|
// |
2313 |
|
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
2314 |
|
return $this->end_treatment(__METHOD__, true); |
2315 |
} |
} |
2316 |
|
// L'appel de verifier() a déjà positionné correct à false |
2317 |
|
// et défini un message d'erreur. |
2318 |
|
$this->addToLog(sprintf($log_msg_error, $id_consult, $uid)); |
2319 |
|
return $this->end_treatment(__METHOD__, false); |
2320 |
} |
} |
2321 |
|
|
2322 |
/** |
/** |
2570 |
} |
} |
2571 |
|
|
2572 |
function is_editable(){ |
function is_editable(){ |
2573 |
|
// Si bypass |
2574 |
if ($this->f->can_bypass("consultation", "modifier")){ |
if ($this->f->can_bypass("consultation", "modifier")){ |
2575 |
return true; |
return true; |
2576 |
} |
} |
2577 |
|
|
2578 |
if ($this->is_dossier_instruction_not_closed()&&$this->is_instructeur_from_division()){ |
// Si l'utilisateur n'est pas instructeur on vérifie que le dossier |
2579 |
return true; |
// n'est pas clôturé |
2580 |
|
// Sinon on verifie sa division |
2581 |
|
if ($this->f->isUserInstructeur() === false) { |
2582 |
|
if ($this->is_dossier_instruction_not_closed() === true) { |
2583 |
|
return true; |
2584 |
|
} |
2585 |
|
} else { |
2586 |
|
if ($this->is_dossier_instruction_not_closed() === true && |
2587 |
|
$this->is_instructeur_from_division() === true) { |
2588 |
|
return true; |
2589 |
|
} |
2590 |
} |
} |
2591 |
return false; |
return false; |
2592 |
} |
} |
2596 |
if ($this->f->can_bypass("consultation", "supprimer")){ |
if ($this->f->can_bypass("consultation", "supprimer")){ |
2597 |
return true; |
return true; |
2598 |
} |
} |
2599 |
|
|
2600 |
if ($this->is_dossier_instruction_not_closed()&&$this->is_instructeur_from_division()){ |
// Pas de suppression possible si un avis est rendu |
2601 |
|
// ou si un fichier est lié et que l'utilisateur n'a pas le droit de |
2602 |
|
// supprimer avec avis rendu |
2603 |
|
if ($this->is_dossier_instruction_not_closed() && |
2604 |
|
$this->is_instructeur_from_division() && |
2605 |
|
$this->getVal("avis_consultation") == "" && |
2606 |
|
$this->getVal('fichier') == "" && |
2607 |
|
$this->f->isAccredited("consultation_supprimer_avec_avis_rendu") == false |
2608 |
|
){ |
2609 |
return true; |
return true; |
2610 |
} |
} |
2611 |
return false; |
return false; |
2675 |
|
|
2676 |
|
|
2677 |
}// fin classe |
}// fin classe |
|
?> |
|
2678 |
|
?> |