33 |
var $retourformulaire; // specific |
var $retourformulaire; // specific |
34 |
var $idxformulaire; // specific |
var $idxformulaire; // specific |
35 |
var $valEvenement; |
var $valEvenement; |
36 |
|
// Tableau contenant une partie des métadonnées arrêtés |
37 |
|
var $metadonneesArrete; |
38 |
|
|
39 |
|
var $metadata = array( |
40 |
|
"om_fichier_instruction" => array( |
41 |
|
"dossier" => "getDossier", |
42 |
|
"dossier_autorisation" => "getDossierAutorisation", |
43 |
|
"date_demande_initiale" => "getDateDemandeInitiale", |
44 |
|
"dossier_instruction_type" => "getDossierInstructionType", |
45 |
|
"statut" => "getStatut", |
46 |
|
"dossier_autorisation_type" => "getDossierAutorisationType", |
47 |
|
"date_creation" => "getDateEvenement", |
48 |
|
"groupe_instruction" => 'getGroupeInstruction', |
49 |
|
), |
50 |
|
"document_arrete" => array( |
51 |
|
"numArrete" => "getNumArrete", |
52 |
|
"specialiteArrete" => "getSpecialiteArrete", |
53 |
|
"decisionArrete" => "getDecisionArrete", |
54 |
|
"chketatReglementaire" => "getChketatReglementaire", |
55 |
|
"chkNotification" => "getChkNotification", |
56 |
|
"dateNotification" => "getDateNotification", |
57 |
|
"chkCreationdroit" => "getChkCreationdroit", |
58 |
|
"chkPublication" => "getChkPublication", |
59 |
|
"datePublication" => "getDatePublication", |
60 |
|
"chkControleLegalite" => "getChkControleLegalite", |
61 |
|
"dateSignatureArrete" => "getDateSignatureArrete", |
62 |
|
"nomSignataire" => "getNomSignataire", |
63 |
|
"qualiteSignataire" => "getQualiteSignataire", |
64 |
|
"chkDelegation" => "getChkDelegation", |
65 |
|
"ap_numRue" => "getAp_numRue", |
66 |
|
"ap_nomDeLaVoie" => "getAp_nomDeLaVoie", |
67 |
|
"ap_codePostal" => "getAp_codePostal", |
68 |
|
"ap_ville" => "getAp_ville", |
69 |
|
), |
70 |
|
); |
71 |
|
|
72 |
|
|
73 |
function instruction($id, &$db, $debug) { |
function instruction($id, &$db, $debug) { |
74 |
$this->constructeur($id, $db, $debug); |
$this->constructeur($id, $db, $debug); |
101 |
|
|
102 |
//Si le document est déjà finalisé, on affiche uniquement le lien de |
//Si le document est déjà finalisé, on affiche uniquement le lien de |
103 |
//dé-finalisation |
//dé-finalisation |
104 |
|
$om_final_instruction = $this->getVal("om_final_instruction"); |
105 |
if ( isset($this->actions_sup["finalisation"]) && |
if ( isset($this->actions_sup["finalisation"]) && |
106 |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
$om_final_instruction== "t" ){ |
|
&& $this->val[array_search("om_final_instruction", $this->champs)]== "t" ){ |
|
107 |
|
|
108 |
|
//On cache les liens d'action |
109 |
|
$this->parameters["actions"]["modifier"] = NULL; |
110 |
|
$this->parameters["actions"]["supprimer"] = NULL; |
111 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
112 |
unset($this->actions_sup["finalisation"]); |
$this->actions_sup["finalisation"] = NULL; |
113 |
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
114 |
$this->actions_sup["pdfetat"]["id"] = |
$this->actions_sup["pdfetat"]["id"] = |
115 |
"&obj=instruction&champ=om_fichier_instruction"; |
"&obj=instruction&champ=om_fichier_instruction"; |
117 |
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
118 |
//finalisation |
//finalisation |
119 |
if ( isset($this->actions_sup["definalisation"]) && |
if ( isset($this->actions_sup["definalisation"]) && |
120 |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
$om_final_instruction!= "t" ){ |
|
&& $this->val[array_search("om_final_instruction", $this->champs)]!= "t" ){ |
|
121 |
|
|
122 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
123 |
unset($this->actions_sup["definalisation"]); |
$this->actions_sup["definalisation"] = NULL; |
124 |
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
125 |
$this->actions_sup["pdfetat"]["id"] = ""; |
$this->actions_sup["pdfetat"]["id"] = ""; |
126 |
} |
} |
127 |
|
|
128 |
|
$idxformulaire = $this->getParameter("idxformulaire"); |
129 |
|
$retourformulaire = $this->getParameter("retourformulaire"); |
130 |
|
//Si le dossier d'instruction auquel est rattachée l'instruction est cloturé, |
131 |
|
//on affiche pas les liens du portlet |
132 |
|
if ( $idxformulaire != '' && |
133 |
|
( |
134 |
|
$retourformulaire == 'dossier' || |
135 |
|
$retourformulaire == 'dossier_instruction' || |
136 |
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
137 |
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
138 |
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
139 |
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
140 |
|
)){ |
141 |
|
|
142 |
|
//On récuppère le statut du dossier d'instruction |
143 |
|
$statut = $this->getStatutDossier($idxformulaire); |
144 |
|
if ( $this->f->isUserInstructeur() && $statut == "cloture" ){ |
145 |
|
|
146 |
|
//On cache le lien de modification |
147 |
|
$this->parameters["actions"]["modifier"] = NULL; |
148 |
|
$this->actions_sup["finalisation"] = NULL; |
149 |
|
$this->actions_sup["definalisation"] = NULL; |
150 |
|
} |
151 |
|
} |
152 |
} |
} |
153 |
|
|
154 |
/** |
/** |
165 |
$this->addToLog("canAccess(): utilisateur instructeur sur un dossier d'une autre division", EXTRA_VERBOSE_MODE); |
$this->addToLog("canAccess(): utilisateur instructeur sur un dossier d'une autre division", EXTRA_VERBOSE_MODE); |
166 |
return false; |
return false; |
167 |
} |
} |
168 |
|
|
169 |
|
$retourformulaire = $this->getParameter("retourformulaire"); |
170 |
|
// Si l'utilisateur est un instructeur et que le dossier est cloturé |
171 |
|
if ( $this->f->isUserInstructeur() && |
172 |
|
$this->getStatutDossier($this->getParameter("idxformulaire")) == "cloture" && |
173 |
|
( |
174 |
|
$retourformulaire == 'dossier' || |
175 |
|
$retourformulaire == 'dossier_instruction' || |
176 |
|
$retourformulaire == 'dossier_instruction_mes_encours' || |
177 |
|
$retourformulaire == 'dossier_instruction_tous_encours' || |
178 |
|
$retourformulaire == 'dossier_instruction_mes_clotures' || |
179 |
|
$retourformulaire == 'dossier_instruction_tous_clotures' |
180 |
|
) |
181 |
|
&& $this->getParameter("maj") != 3 && $this->getParameter("maj") != 0 ) { |
182 |
|
|
183 |
|
return false; |
184 |
|
} |
185 |
// |
// |
186 |
return true; |
return true; |
187 |
} |
} |
347 |
$form->setType('date_retour_rar','datedisabled'); |
$form->setType('date_retour_rar','datedisabled'); |
348 |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
$form->setType('date_envoi_controle_legalite','datedisabled'); |
349 |
$form->setType('date_retour_controle_legalite','datedisabled'); |
$form->setType('date_retour_controle_legalite','datedisabled'); |
350 |
|
$form->setType('date_finalisation_courrier','datedisabled'); |
351 |
if($maj==0){ // add |
if($maj==0){ // add |
352 |
$form->setType('instruction', 'hiddenstatic'); |
$form->setType('instruction', 'hiddenstatic'); |
353 |
$form->setType('evenement', 'select'); |
$form->setType('evenement', 'select'); |
376 |
//Cache les champs pour la finalisation |
//Cache les champs pour la finalisation |
377 |
$form->setType('om_fichier_instruction', 'hidden'); |
$form->setType('om_fichier_instruction', 'hidden'); |
378 |
$form->setType('om_final_instruction', 'hidden'); |
$form->setType('om_final_instruction', 'hidden'); |
379 |
|
// Cache le document arrêté |
380 |
|
$form->setType('document_arrete', 'hidden'); |
381 |
} |
} |
382 |
|
|
383 |
function setSelect(&$form, $maj,&$db,$debug) { |
function setSelect(&$form, $maj,&$db,$debug) { |
491 |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
function cleSecondaire($id, &$db, $val, $DEBUG) { |
492 |
// |
// |
493 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
494 |
|
|
495 |
/** |
// Aucune clé secondaire n'a été trouvée, l'instruction peut être supprimée |
496 |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
if ( $this->correct !== false ){ |
497 |
* remodifier les données de manière itérative. |
|
498 |
*/ |
/** |
499 |
// Initialisation |
* Vérification que l'élément supprimé est le dernier pour pouvoir |
500 |
$dernierevenement = ""; |
* remodifier les données de manière itérative. |
501 |
// Récupération du dernier élément de la table d'instruction qui |
*/ |
502 |
// concerne le dossier en cours |
// Initialisation |
503 |
$sql = "SELECT max(instruction) |
$dernierevenement = ""; |
504 |
FROM ".DB_PREFIXE."instruction |
// Récupération du dernier élément de la table d'instruction qui |
505 |
WHERE dossier ='".$this->idxformulaire."'"; |
// concerne le dossier en cours |
506 |
$dernierevenement = $db->getOne($sql); |
$sql = "SELECT max(instruction) |
507 |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
FROM ".DB_PREFIXE."instruction |
508 |
if (database::isError($dernierevenement)) { |
WHERE dossier ='".$this->idxformulaire."'"; |
509 |
die($dernierevenement->getMessage()); |
$dernierevenement = $db->getOne($sql); |
510 |
} |
$this->addToLog("setSelect(): db->getone(\"".$sql."\");", VERBOSE_MODE); |
511 |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
if (database::isError($dernierevenement)) { |
512 |
if ($dernierevenement == $id) { |
die($dernierevenement->getMessage()); |
513 |
// Alors on valide la suppression |
} |
514 |
$this->correct = true; |
// Si on se trouve effectivement sur le dernier evenement d'instruction |
515 |
$this->addToMessage(_('Destruction_chronologique')); |
if ($dernierevenement == $id) { |
516 |
} else { |
// Alors on valide la suppression |
517 |
// Alors on annule la suppression |
$this->correct = true; |
518 |
$this->correct = false; |
$this->addToMessage(_('Destruction_chronologique')); |
519 |
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
} else { |
520 |
|
// Alors on annule la suppression |
521 |
|
$this->correct = false; |
522 |
|
$this->addToMessage(_("Seul le dernier evenement d'instruction peut etre supprime.")); |
523 |
|
} |
524 |
} |
} |
525 |
} |
} |
526 |
|
|
1064 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
1065 |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1066 |
$da->majDossierAutorisation(); |
$da->majDossierAutorisation(); |
|
|
|
|
// Finalisation du document |
|
|
$this->finaliserAjouter(); |
|
1067 |
} |
} |
1068 |
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
1069 |
|
// Ajout de l'arrêté dans la GED |
1070 |
|
if ($this->valF['numero_arrete'] != $this->getVal('numero_arrete') |
1071 |
|
AND $this->valF["om_fichier_instruction"] != "") { |
1072 |
|
$file = $this->f->storage->get($this->valF["om_fichier_instruction"]); |
1073 |
|
if(isset($file) and $file != null) { |
1074 |
|
// Récupération des métadonnées calculées après validation |
1075 |
|
$spe_metadata = $this->getMetadata("document_arrete"); |
1076 |
|
$pdf_output = $file["file_content"]; |
1077 |
|
//Métadonnées du document |
1078 |
|
$metadata = array( |
1079 |
|
'filename' => 'instruction_'.$this->valF[$this->clePrimaire].'.pdf', |
1080 |
|
'mimetype' => 'application/pdf', |
1081 |
|
'size' => strlen($pdf_output) |
1082 |
|
); |
1083 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1084 |
|
|
1085 |
|
//Si le document a déjà été finalisé |
1086 |
|
//on met à jour le document mais pas son uid |
1087 |
|
if ( $this->getVal("document_arrete") != '' ){ |
1088 |
|
$uid = $this->f->storage->update( |
1089 |
|
$this->getVal("document_arrete"), $pdf_output, $metadata); |
1090 |
|
} |
1091 |
|
//Sinon, on joute le document et on récupère son uid |
1092 |
|
else { |
1093 |
|
//Stockage du PDF |
1094 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1095 |
|
} |
1096 |
|
if($uid != OP_FAILURE) { |
1097 |
|
$this->valF["document_arrete"] = $uid; |
1098 |
|
} |
1099 |
|
} |
1100 |
|
|
1101 |
|
} |
1102 |
|
} |
1103 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1104 |
/** |
/** |
1105 |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
* L'objectif ici est d'effectuer les recalculs de date dans le dossier |
1280 |
$da->majDossierAutorisation(); |
$da->majDossierAutorisation(); |
1281 |
} |
} |
1282 |
|
|
1283 |
|
/** |
1284 |
|
* Méthode de récupération des métadonnées arrêtés dans la base de données, |
1285 |
|
* les données sont stockés dans l'attribut $this->metadonneesArrete |
1286 |
|
*/ |
1287 |
|
function getArreteMetadata() { |
1288 |
|
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
1289 |
|
signataire_arrete.qualite as \"qualitesignataire\", |
1290 |
|
instruction.date_evenement as \"datesignaturearrete\", |
1291 |
|
instruction.etat as \"decisionarrete\", |
1292 |
|
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
1293 |
|
dossier.complement as \"ap_nomdelavoie\", |
1294 |
|
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
1295 |
|
dossier.terrain_adresse_localite as \"ap_ville\" |
1296 |
|
FROM ".DB_PREFIXE."instruction |
1297 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
1298 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
1299 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
1300 |
|
instruction.dossier = dossier.dossier |
1301 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
1302 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
1303 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
1304 |
|
$resArrete = $this->db->query($sqlArrete); |
1305 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
1306 |
|
if ( database::isError($resArrete)){ |
1307 |
|
die(); |
1308 |
|
} |
1309 |
|
|
1310 |
|
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
1311 |
|
} |
1312 |
|
|
1313 |
|
// {{{ |
1314 |
|
// Méthodes de récupération des métadonnées arrêté |
1315 |
|
/** |
1316 |
|
* @return string Retourne le numéro d'arrêté |
1317 |
|
*/ |
1318 |
|
function getNumArrete() { |
1319 |
|
return $this->valF['numero_arrete']; |
1320 |
|
} |
1321 |
|
/** |
1322 |
|
* @return string ads |
1323 |
|
*/ |
1324 |
|
function getSpecialiteArrete() { |
1325 |
|
return "ADS"; |
1326 |
|
} |
1327 |
|
/** |
1328 |
|
* @return string decision |
1329 |
|
*/ |
1330 |
|
function getDecisionArrete() { |
1331 |
|
if (empty($this->metadonneesArrete)) { |
1332 |
|
$this->getArreteMetadata(); |
1333 |
|
} |
1334 |
|
return $this->metadonneesArrete["decisionarrete"]; |
1335 |
|
} |
1336 |
|
/** |
1337 |
|
* @return chaîne vide |
1338 |
|
*/ |
1339 |
|
function getChketatReglementaire() { |
1340 |
|
return ""; |
1341 |
|
} |
1342 |
|
/** |
1343 |
|
* @return boolean de notification au pétitionnaire |
1344 |
|
*/ |
1345 |
|
function getChkNotification() { |
1346 |
|
if( isset($this->valF["date_retour_rar"]) ) { |
1347 |
|
return true; |
1348 |
|
} else { |
1349 |
|
return false; |
1350 |
|
} |
1351 |
|
} |
1352 |
|
/** |
1353 |
|
* @return date de notification au pétitionnaire |
1354 |
|
*/ |
1355 |
|
function getDateNotification() { |
1356 |
|
return date("d/m/Y", strtotime($this->valF["date_retour_rar"])); |
1357 |
|
} |
1358 |
|
/** |
1359 |
|
* @return chaîne vide |
1360 |
|
*/ |
1361 |
|
function getChkCreationdroit() { |
1362 |
|
return ""; |
1363 |
|
} |
1364 |
|
/** |
1365 |
|
* @return chaîne vide |
1366 |
|
*/ |
1367 |
|
function getChkPublication() { |
1368 |
|
return ""; |
1369 |
|
} |
1370 |
|
/** |
1371 |
|
* @return chaîne vide |
1372 |
|
*/ |
1373 |
|
function getDatePublication() { |
1374 |
|
return ""; |
1375 |
|
} |
1376 |
|
/** |
1377 |
|
* @return boolean check si le document est passé au contrôle de légalité |
1378 |
|
*/ |
1379 |
|
function getChkControleLegalite() { |
1380 |
|
if( isset($this->valF["date_retour_controle_legalite"]) ) { |
1381 |
|
return true; |
1382 |
|
} else { |
1383 |
|
return false; |
1384 |
|
} |
1385 |
|
} |
1386 |
|
/** |
1387 |
|
* @return date de signature de l'arrêté |
1388 |
|
*/ |
1389 |
|
function getDateSignatureArrete() { |
1390 |
|
return date("d/m/Y", strtotime($this->valF['date_retour_signature'])); |
1391 |
|
} |
1392 |
|
/** |
1393 |
|
* @return string nom du signataire |
1394 |
|
*/ |
1395 |
|
function getNomSignataire() { |
1396 |
|
if (empty($this->metadonneesArrete)) { |
1397 |
|
$this->getArreteMetadata(); |
1398 |
|
} |
1399 |
|
return $this->metadonneesArrete["nomsignataire"]; |
1400 |
|
} |
1401 |
|
/** |
1402 |
|
* @return string qualité du signataire |
1403 |
|
*/ |
1404 |
|
function getQualiteSignataire() { |
1405 |
|
if (empty($this->metadonneesArrete)) { |
1406 |
|
$this->getArreteMetadata(); |
1407 |
|
} |
1408 |
|
return $this->metadonneesArrete["qualitesignataire"]; |
1409 |
|
} |
1410 |
|
/** |
1411 |
|
* @return string chaîne vide |
1412 |
|
*/ |
1413 |
|
function getChkDelegation() { |
1414 |
|
return ""; |
1415 |
|
} |
1416 |
|
/** |
1417 |
|
* @return string numéro du terrain |
1418 |
|
*/ |
1419 |
|
function getAp_numRue() { |
1420 |
|
if (empty($this->metadonneesArrete)) { |
1421 |
|
$this->getArreteMetadata(); |
1422 |
|
} |
1423 |
|
return $this->metadonneesArrete["ap_numrue"]; |
1424 |
|
} |
1425 |
|
/** |
1426 |
|
* @return string nom de la rue du terrain |
1427 |
|
*/ |
1428 |
|
function getAp_nomDeLaVoie() { |
1429 |
|
if (empty($this->metadonneesArrete)) { |
1430 |
|
$this->getArreteMetadata(); |
1431 |
|
} |
1432 |
|
return $this->metadonneesArrete["ap_nomdelavoie"]; |
1433 |
|
} |
1434 |
|
/** |
1435 |
|
* @return string code postal du terrain |
1436 |
|
*/ |
1437 |
|
function getAp_codePostal() { |
1438 |
|
if (empty($this->metadonneesArrete)) { |
1439 |
|
$this->getArreteMetadata(); |
1440 |
|
} |
1441 |
|
return $this->metadonneesArrete["ap_codepostal"]; |
1442 |
|
} |
1443 |
|
/** |
1444 |
|
* @return string ville du terrain |
1445 |
|
*/ |
1446 |
|
function getAp_ville() { |
1447 |
|
if (empty($this->metadonneesArrete)) { |
1448 |
|
$this->getArreteMetadata(); |
1449 |
|
} |
1450 |
|
return $this->metadonneesArrete["ap_ville"]; |
1451 |
|
} |
1452 |
|
|
1453 |
|
// Fin des méthodes de récupération des métadonnées |
1454 |
|
// }}} |
1455 |
|
|
1456 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
1457 |
/** |
/** |
1458 |
* L'objectif ici est de repositionner les valeurs récupérées en |
* L'objectif ici est de repositionner les valeurs récupérées en |
1562 |
// Affichage d'informations à l'utilisateur |
// Affichage d'informations à l'utilisateur |
1563 |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
$this->addToMessage(_("Suppression de l'instruction")." [".$db->affectedRows()." "._('enregistrement')." "._('mis_a_jour')."]"); |
1564 |
|
|
1565 |
|
// Mise à jour de la demande si un récépissé d'instruction correspond à l'instruction à supprimer |
1566 |
} |
} |
1567 |
|
|
1568 |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
function triggersupprimerapres($id,&$db,$val,$DEBUG) { |
1713 |
} |
} |
1714 |
|
|
1715 |
/** |
/** |
1716 |
* Finalisation des documents. |
* Finalisation des documents. |
1717 |
|
* @param string $champ champ du fichier à finaliser |
1718 |
|
* @param booleen $status permet de définir si on finalise ou définalise |
1719 |
|
* @param string $sousform permet de savoir si se trouve dans un sousformulaire (passé au javascript) |
1720 |
*/ |
*/ |
1721 |
function finaliser( $champ = '', $status, $sousform){ |
function finaliser( $champ = '', $status, $sousform, $retourformulaire){ |
1722 |
|
|
1723 |
//Si on finalise le document |
//Si on finalise le document |
1724 |
if ( $status == 1 ){ |
if ( $status == 1 ){ |
1735 |
'size' => strlen($pdf_output) |
'size' => strlen($pdf_output) |
1736 |
); |
); |
1737 |
|
|
1738 |
|
// Récupération des métadonnées calculées après validation |
1739 |
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
1740 |
|
|
1741 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1742 |
//Si le document a déjà été finalisé |
//Si le document a déjà été finalisé |
1743 |
//on met à jour le document mais pas son uid |
//on met à jour le document mais pas son uid |
1744 |
if ( $this->getVal("om_fichier_instruction") != '' ){ |
if ( $this->getVal("om_fichier_instruction") != '' ){ |
1770 |
$id = $this->getVal($this->clePrimaire); |
$id = $this->getVal($this->clePrimaire); |
1771 |
else |
else |
1772 |
$id=$this->id; |
$id=$this->id; |
1773 |
|
|
1774 |
|
$actions = array(); |
1775 |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
1776 |
//à jour de l'interface |
//à jour de l'interface |
1777 |
if ( $status == 0 ){ |
if ( $status == 0 ){ |
1778 |
$lien = '../app/pdf_instruction.php?idx='.$id; |
$lien = '../app/pdf_instruction.php?idx='.$id; |
1779 |
|
|
1780 |
|
//Ajout des actions |
1781 |
|
//Si l'utilisateur a le droit de modifier l'objet |
1782 |
|
if ( $this->f->isAccredited('instruction') || |
1783 |
|
$this->f->isAccredited('instruction_modifier') ){ |
1784 |
|
|
1785 |
|
$actions["modifier"] = ($sousform!='')? |
1786 |
|
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
1787 |
|
\'../scr/sousform.php?obj=instruction&action=1&idx='. |
1788 |
|
$this->getVal($this->clePrimaire). |
1789 |
|
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
1790 |
|
$this->getVal("dossier"). |
1791 |
|
'&retour=form\');"> |
1792 |
|
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
1793 |
|
_('Modifier').'">'. |
1794 |
|
_('Modifier'). |
1795 |
|
'</span></a></li>': |
1796 |
|
'<li> |
1797 |
|
<a href="form.php?obj=instruction&action=1'.'&idx='. |
1798 |
|
$this->getVal($this->clePrimaire). |
1799 |
|
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
1800 |
|
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
1801 |
|
_('Modifier').'">'. |
1802 |
|
_('Modifier'). |
1803 |
|
'</span></a></li>'; |
1804 |
|
} |
1805 |
|
//Si l'utilisateur a le droit de supprimer l'objet |
1806 |
|
if ( $this->f->isAccredited('instruction') || |
1807 |
|
$this->f->isAccredited('instruction_supprimer') ){ |
1808 |
|
|
1809 |
|
$actions["supprimer"] = ($sousform!='')? |
1810 |
|
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
1811 |
|
\'../scr/sousform.php?obj=instruction&action=2&idx='. |
1812 |
|
$this->getVal($this->clePrimaire). |
1813 |
|
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
1814 |
|
$this->getVal("dossier"). |
1815 |
|
'&retour=form\');"> |
1816 |
|
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
1817 |
|
_('Supprimer').'">'. |
1818 |
|
_('Supprimer'). |
1819 |
|
'</span></a></li>': |
1820 |
|
'<li> |
1821 |
|
<a href="form.php?obj=instruction&action=1'.'&idx='. |
1822 |
|
$this->getVal($this->clePrimaire). |
1823 |
|
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
1824 |
|
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
1825 |
|
_('Supprimer').'">'. |
1826 |
|
_('Supprimer'). |
1827 |
|
'</span></a></li>'; |
1828 |
|
} |
1829 |
} |
} |
1830 |
else { |
else { |
1831 |
$lien = '../spg/file.php?obj=instruction&'. |
$lien = '../spg/file.php?obj=instruction&'. |
1835 |
$retour = array( |
$retour = array( |
1836 |
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
1837 |
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
1838 |
<span class=\"om-prev-icon om-icon-16 om-icon-fix delete-16 " |
<span class=\"om-prev-icon om-icon-16 om-icon-fix " |
1839 |
.(($status==1)?"de":"")."finalise\" title=\"". |
.(($status==1)?"de":"")."finalise\" title=\"". |
1840 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
1841 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
1842 |
</a>", |
</a>", |
1843 |
"pdf" => $lien |
"pdf" => $lien, |
1844 |
|
"actions" => $actions |
1845 |
); |
); |
1846 |
|
|
1847 |
foreach ( $this->champs as $key=>$value ) |
foreach ( $this->champs as $key=>$value ) |
1879 |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1880 |
$valF = array( |
$valF = array( |
1881 |
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
1882 |
"om_fichier_instruction"=>$uid); |
"om_fichier_instruction"=>$uid, |
1883 |
|
"date_finalisation_courrier"=>date('Y-m-d')); |
1884 |
// Execution de la requête de modification des donnees de l'attribut |
// Execution de la requête de modification des donnees de l'attribut |
1885 |
// valF de l'objet dans l'attribut table de l'objet |
// valF de l'objet dans l'attribut table de l'objet |
1886 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1921 |
} |
} |
1922 |
|
|
1923 |
/** |
/** |
1924 |
* Finalisation du document lors de l'ajout d'une instruction |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
1925 |
* |
* @return string numéro de dossier d'instruction |
1926 |
|
*/ |
1927 |
|
protected function getDossier() { |
1928 |
|
if(empty($this->specificMetadata)) { |
1929 |
|
$this->getSpecificMetadata(); |
1930 |
|
} |
1931 |
|
return $this->specificMetadata->dossier; |
1932 |
|
} |
1933 |
|
/** |
1934 |
|
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
1935 |
|
* @return string numéro de dossier d'autorisation |
1936 |
|
*/ |
1937 |
|
protected function getDossierAutorisation() { |
1938 |
|
if(empty($this->specificMetadata)) { |
1939 |
|
$this->getSpecificMetadata(); |
1940 |
|
} |
1941 |
|
return $this->specificMetadata->dossier_autorisation; |
1942 |
|
} |
1943 |
|
/** |
1944 |
|
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
1945 |
|
* @return date de la demande initiale |
1946 |
|
*/ |
1947 |
|
protected function getDateDemandeInitiale() { |
1948 |
|
if(empty($this->specificMetadata)) { |
1949 |
|
$this->getSpecificMetadata(); |
1950 |
|
} |
1951 |
|
return $this->specificMetadata->date_demande_initiale; |
1952 |
|
} |
1953 |
|
/** |
1954 |
|
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
1955 |
|
* @return string type du dossier d'instruction |
1956 |
|
*/ |
1957 |
|
protected function getDossierInstructionType() { |
1958 |
|
if(empty($this->specificMetadata)) { |
1959 |
|
$this->getSpecificMetadata(); |
1960 |
|
} |
1961 |
|
return $this->specificMetadata->dossier_instruction_type; |
1962 |
|
} |
1963 |
|
/** |
1964 |
|
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
1965 |
|
* @return string avis |
1966 |
|
*/ |
1967 |
|
protected function getStatut() { |
1968 |
|
if(empty($this->specificMetadata)) { |
1969 |
|
$this->getSpecificMetadata(); |
1970 |
|
} |
1971 |
|
return $this->specificMetadata->statut; |
1972 |
|
} |
1973 |
|
/** |
1974 |
|
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
1975 |
|
* @return string type du dossier d'autorisation |
1976 |
|
*/ |
1977 |
|
protected function getDossierAutorisationType() { |
1978 |
|
if(empty($this->specificMetadata)) { |
1979 |
|
$this->getSpecificMetadata(); |
1980 |
|
} |
1981 |
|
return $this->specificMetadata->dossier_autorisation_type; |
1982 |
|
} |
1983 |
|
/** |
1984 |
|
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
1985 |
|
* @return date de l'évènement |
1986 |
*/ |
*/ |
1987 |
function finaliserAjouter(){ |
protected function getDateEvenement() { |
1988 |
|
return date("d/m/Y"); |
1989 |
|
} |
1990 |
|
/** |
1991 |
|
* Récupération du groupe d'instruction à ajouter aux métadonnées |
1992 |
|
* @return string Groupe d'instruction |
1993 |
|
*/ |
1994 |
|
protected function getGroupeInstruction() { |
1995 |
|
if(empty($this->specificMetadata)) { |
1996 |
|
$this->getSpecificMetadata(); |
1997 |
|
} |
1998 |
|
return $this->specificMetadata->groupe_instruction; |
1999 |
|
} |
2000 |
|
|
2001 |
//Génération du PDF |
/** |
2002 |
$_GET['output'] = "string"; |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
2003 |
$_GET['obj'] = "instruction"; |
* nécessaire à l'ajout d'un document. |
2004 |
$_GET['idx'] = $this->valF[$this->clePrimaire]; |
*/ |
2005 |
$f = $this->f; |
public function getSpecificMetadata() { |
2006 |
include '../app/pdf_instruction.php'; |
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
2007 |
|
$dossier = $this->valF["dossier"]; |
2008 |
|
} else { |
2009 |
|
$dossier = $this->getVal("dossier"); |
2010 |
|
} |
2011 |
|
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
2012 |
|
$sql = "SELECT dossier.dossier as dossier, |
2013 |
|
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
2014 |
|
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
2015 |
|
dossier_instruction_type.code as dossier_instruction_type, |
2016 |
|
etat_dossier_autorisation.libelle as statut, |
2017 |
|
dossier_autorisation_type.code as dossier_autorisation_type, |
2018 |
|
groupe.code as groupe_instruction |
2019 |
|
FROM ".DB_PREFIXE."dossier |
2020 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
2021 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
2022 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
2023 |
|
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
2024 |
|
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
2025 |
|
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
2026 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
2027 |
|
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
2028 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
2029 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
2030 |
|
LEFT JOIN ".DB_PREFIXE."groupe |
2031 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
2032 |
|
WHERE dossier.dossier = '".$dossier."'"; |
2033 |
|
$res = $this->db->query($sql); |
2034 |
|
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
2035 |
|
if ( database::isError($res)){ |
2036 |
|
die(); |
2037 |
|
} |
2038 |
|
|
2039 |
//Métadonnées du document |
//Le résultat est récupéré dans un objet |
2040 |
$metadata = array( |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
|
'filename' => 'instruction_'.$idx.'.pdf', |
|
|
'mimetype' => 'application/pdf', |
|
|
'size' => strlen($pdf_output) |
|
|
); |
|
2041 |
|
|
2042 |
//On ajoute le document et on récupère son uid |
//Si il y a un résultat |
2043 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
if ($row !== null) { |
2044 |
|
|
2045 |
//Mise à jour des données |
//Alors on créé l'objet dossier_instruction |
2046 |
if ( $uid != '' ){ |
$this->specificMetadata = $row; |
|
// Logger |
|
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
|
2047 |
|
|
|
$valF = array( |
|
|
"om_final_instruction"=> TRUE, |
|
|
"om_fichier_instruction"=>$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($idx)); |
|
|
$this->addToLog("finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($idx)."\")", VERBOSE_MODE); |
|
|
// Si une erreur survient |
|
|
if (database::isError($res)) { |
|
|
// Appel de la methode de recuperation des erreurs |
|
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
|
|
} else { |
|
|
// Log |
|
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
|
|
// Log |
|
|
$message = _("Enregistrement")." ".$idx." "; |
|
|
$message .= _("de la table")." \"".$this->table."\" "; |
|
|
$message .= "[ ".$this->db->affectedRows()." "; |
|
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
|
|
$this->addToLog($message, VERBOSE_MODE); |
|
|
} |
|
2048 |
} |
} |
2049 |
} |
} |
2050 |
|
|
2051 |
|
/** |
2052 |
|
* Retourne le statut du dossier d'instruction |
2053 |
|
* @param string $idx Identifiant du dossier d'instruction |
2054 |
|
* @return string Le statut du dossier d'instruction |
2055 |
|
*/ |
2056 |
|
function getStatutDossier($idx){ |
2057 |
|
|
2058 |
|
$statut = ''; |
2059 |
|
|
2060 |
|
//Si l'identifiant du dossier d'instruction fourni est correct |
2061 |
|
if ( $idx != '' ){ |
2062 |
|
|
2063 |
|
//On récupère le statut de l'état du dossier à partir de l'identifiant du |
2064 |
|
//dossier |
2065 |
|
$sql = "SELECT etat.statut |
2066 |
|
FROM ".DB_PREFIXE."dossier |
2067 |
|
LEFT JOIN |
2068 |
|
".DB_PREFIXE."etat |
2069 |
|
ON |
2070 |
|
dossier.etat = etat.etat |
2071 |
|
WHERE dossier ='".$idx."'"; |
2072 |
|
$statut = $this->db->getOne($sql); |
2073 |
|
$this->f->addToLog("getStatutDossier() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
2074 |
|
if ( database::isError($statut)){ |
2075 |
|
die(); |
2076 |
|
} |
2077 |
|
} |
2078 |
|
return $statut; |
2079 |
|
} |
2080 |
}// fin classe |
}// fin classe |
2081 |
?> |
?> |