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" ){ |
107 |
&& $this->val[array_search("om_final_instruction", $this->champs)]== "t" ){ |
|
108 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
109 |
unset($this->actions_sup["finalisation"]); |
unset($this->actions_sup["finalisation"]); |
110 |
|
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
111 |
|
$this->actions_sup["pdfetat"]["id"] = |
112 |
|
"&obj=instruction&champ=om_fichier_instruction"; |
113 |
} |
} |
114 |
//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 |
115 |
//finalisation |
//finalisation |
116 |
if ( isset($this->actions_sup["definalisation"]) && |
if ( isset($this->actions_sup["definalisation"]) && |
117 |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
$om_final_instruction!= "t" ){ |
118 |
&& $this->val[array_search("om_final_instruction", $this->champs)]!= "t" ){ |
|
119 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
120 |
unset($this->actions_sup["definalisation"]); |
unset($this->actions_sup["definalisation"]); |
121 |
|
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
122 |
|
$this->actions_sup["pdfetat"]["id"] = ""; |
123 |
} |
} |
124 |
} |
} |
125 |
|
|
330 |
//Cache les champs pour la finalisation |
//Cache les champs pour la finalisation |
331 |
$form->setType('om_fichier_instruction', 'hidden'); |
$form->setType('om_fichier_instruction', 'hidden'); |
332 |
$form->setType('om_final_instruction', 'hidden'); |
$form->setType('om_final_instruction', 'hidden'); |
333 |
|
// Cache le document arrêté |
334 |
|
$form->setType('document_arrete', 'hidden'); |
335 |
} |
} |
336 |
|
|
337 |
function setSelect(&$form, $maj,&$db,$debug) { |
function setSelect(&$form, $maj,&$db,$debug) { |
1014 |
require_once "../obj/dossier_autorisation.class.php"; |
require_once "../obj/dossier_autorisation.class.php"; |
1015 |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
$da = new dossier_autorisation($this->getDossierAutorisationFromDossier($this->valF['dossier']), $this->db, DEBUG); |
1016 |
$da->majDossierAutorisation(); |
$da->majDossierAutorisation(); |
1017 |
|
|
1018 |
|
// Finalisation du document |
1019 |
|
$this->finaliserAjouter(); |
1020 |
} |
} |
1021 |
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
1022 |
|
// Ajout de l'arrêté dans la GED |
1023 |
|
if ($this->valF['numero_arrete'] != $this->getVal('numero_arrete') |
1024 |
|
AND $this->valF["om_fichier_instruction"] != "") { |
1025 |
|
$file = $this->f->storage->get($this->valF["om_fichier_instruction"]); |
1026 |
|
if(isset($file) and $file != null) { |
1027 |
|
// Récupération des métadonnées calculées après validation |
1028 |
|
$spe_metadata = $this->getMetadata("document_arrete"); |
1029 |
|
$pdf_output = $file["file_content"]; |
1030 |
|
//Métadonnées du document |
1031 |
|
$metadata = array( |
1032 |
|
'filename' => 'instruction_'.$this->valF[$this->clePrimaire].'.pdf', |
1033 |
|
'mimetype' => 'application/pdf', |
1034 |
|
'size' => strlen($pdf_output) |
1035 |
|
); |
1036 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1037 |
|
|
1038 |
|
//Si le document a déjà été finalisé |
1039 |
|
//on met à jour le document mais pas son uid |
1040 |
|
if ( $this->getVal("document_arrete") != '' ){ |
1041 |
|
$uid = $this->f->storage->update( |
1042 |
|
$this->getVal("document_arrete"), $pdf_output, $metadata); |
1043 |
|
} |
1044 |
|
//Sinon, on joute le document et on récupère son uid |
1045 |
|
else { |
1046 |
|
//Stockage du PDF |
1047 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1048 |
|
} |
1049 |
|
if($uid != OP_FAILURE) { |
1050 |
|
$this->valF["document_arrete"] = $uid; |
1051 |
|
} |
1052 |
|
} |
1053 |
|
|
1054 |
|
} |
1055 |
|
} |
1056 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1057 |
/** |
/** |
1058 |
* 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 |
1233 |
$da->majDossierAutorisation(); |
$da->majDossierAutorisation(); |
1234 |
} |
} |
1235 |
|
|
1236 |
|
/** |
1237 |
|
* Méthode de récupération des métadonnées arrêtés dans la base de données, |
1238 |
|
* les données sont stockés dans l'attribut $this->metadonneesArrete |
1239 |
|
*/ |
1240 |
|
function getArreteMetadata() { |
1241 |
|
$sqlArrete = "SELECT signataire_arrete.nom as \"nomsignataire\", |
1242 |
|
signataire_arrete.qualite as \"qualitesignataire\", |
1243 |
|
instruction.date_evenement as \"datesignaturearrete\", |
1244 |
|
instruction.etat as \"decisionarrete\", |
1245 |
|
dossier.terrain_adresse_voie_numero as \"ap_numrue\", |
1246 |
|
dossier.complement as \"ap_nomdelavoie\", |
1247 |
|
dossier.terrain_adresse_code_postal as \"ap_codepostal\", |
1248 |
|
dossier.terrain_adresse_localite as \"ap_ville\" |
1249 |
|
FROM ".DB_PREFIXE."instruction |
1250 |
|
LEFT JOIN ".DB_PREFIXE."signataire_arrete ON |
1251 |
|
instruction.signataire_arrete = signataire_arrete.signataire_arrete |
1252 |
|
LEFT JOIN ".DB_PREFIXE."dossier ON |
1253 |
|
instruction.dossier = dossier.dossier |
1254 |
|
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
1255 |
|
donnees_techniques.dossier_instruction = dossier.dossier |
1256 |
|
WHERE instruction.instruction = ".$this->valF['instruction']; |
1257 |
|
$resArrete = $this->db->query($sqlArrete); |
1258 |
|
$this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE); |
1259 |
|
if ( database::isError($resArrete)){ |
1260 |
|
die(); |
1261 |
|
} |
1262 |
|
|
1263 |
|
$this->metadonneesArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC); |
1264 |
|
} |
1265 |
|
|
1266 |
|
// Méthodes de récupération des métadonnées arrêté |
1267 |
|
function getNumArrete() { |
1268 |
|
return $this->valF['numero_arrete']; |
1269 |
|
} |
1270 |
|
function getSpecialiteArrete() { |
1271 |
|
return "ADS"; |
1272 |
|
} |
1273 |
|
function getDecisionArrete() { |
1274 |
|
if (empty($this->metadonneesArrete)) { |
1275 |
|
$this->getArreteMetadata(); |
1276 |
|
} |
1277 |
|
return $this->metadonneesArrete["decisionarrete"]; |
1278 |
|
} |
1279 |
|
function getChketatReglementaire() { |
1280 |
|
return ""; |
1281 |
|
} |
1282 |
|
function getChkNotification() { |
1283 |
|
if( isset($this->valF["date_retour_rar"]) ) { |
1284 |
|
return true; |
1285 |
|
} else { |
1286 |
|
return false; |
1287 |
|
} |
1288 |
|
} |
1289 |
|
function getDateNotification() { |
1290 |
|
return date("d/m/Y", strtotime($this->valF["date_retour_rar"])); |
1291 |
|
} |
1292 |
|
function getChkCreationdroit() { |
1293 |
|
return ""; |
1294 |
|
} |
1295 |
|
function getChkPublication() { |
1296 |
|
return ""; |
1297 |
|
} |
1298 |
|
function getDatePublication() { |
1299 |
|
return ""; |
1300 |
|
} |
1301 |
|
function getChkControleLegalite() { |
1302 |
|
if( isset($this->valF["date_retour_controle_legalite"]) ) { |
1303 |
|
return true; |
1304 |
|
} else { |
1305 |
|
return false; |
1306 |
|
} |
1307 |
|
} |
1308 |
|
function getDateSignatureArrete() { |
1309 |
|
return date("d/m/Y", strtotime($this->valF['date_retour_signature'])); |
1310 |
|
} |
1311 |
|
function getNomSignataire() { |
1312 |
|
if (empty($this->metadonneesArrete)) { |
1313 |
|
$this->getArreteMetadata(); |
1314 |
|
} |
1315 |
|
return $this->metadonneesArrete["nomsignataire"]; |
1316 |
|
} |
1317 |
|
function getQualiteSignataire() { |
1318 |
|
if (empty($this->metadonneesArrete)) { |
1319 |
|
$this->getArreteMetadata(); |
1320 |
|
} |
1321 |
|
return $this->metadonneesArrete["qualitesignataire"]; |
1322 |
|
} |
1323 |
|
function getChkDelegation() { |
1324 |
|
return ""; |
1325 |
|
} |
1326 |
|
function getAp_numRue() { |
1327 |
|
if (empty($this->metadonneesArrete)) { |
1328 |
|
$this->getArreteMetadata(); |
1329 |
|
} |
1330 |
|
return $this->metadonneesArrete["ap_numrue"]; |
1331 |
|
} |
1332 |
|
function getAp_nomDeLaVoie() { |
1333 |
|
if (empty($this->metadonneesArrete)) { |
1334 |
|
$this->getArreteMetadata(); |
1335 |
|
} |
1336 |
|
return $this->metadonneesArrete["ap_nomdelavoie"]; |
1337 |
|
} |
1338 |
|
function getAp_codePostal() { |
1339 |
|
if (empty($this->metadonneesArrete)) { |
1340 |
|
$this->getArreteMetadata(); |
1341 |
|
} |
1342 |
|
return $this->metadonneesArrete["ap_codepostal"]; |
1343 |
|
} |
1344 |
|
function getAp_ville() { |
1345 |
|
if (empty($this->metadonneesArrete)) { |
1346 |
|
$this->getArreteMetadata(); |
1347 |
|
} |
1348 |
|
return $this->metadonneesArrete["ap_ville"]; |
1349 |
|
} |
1350 |
|
|
1351 |
|
// Fin des méthodes de récupération des métadonnées |
1352 |
|
|
1353 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
1354 |
/** |
/** |
1355 |
* 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 |
1555 |
} |
} |
1556 |
} |
} |
1557 |
} |
} |
1558 |
|
|
1559 |
$this->updateDate("date_envoi_signature"); |
$this->updateDate("date_envoi_signature"); |
1560 |
$this->updateDate("date_retour_signature"); |
$this->updateDate("date_retour_signature"); |
1561 |
$this->updateDate("date_envoi_rar"); |
$this->updateDate("date_envoi_rar"); |
1607 |
return false; |
return false; |
1608 |
} |
} |
1609 |
} |
} |
1610 |
|
|
1611 |
|
/** |
1612 |
|
* Finalisation des documents. |
1613 |
|
*/ |
1614 |
|
function finaliser( $champ = '', $status, $sousform){ |
1615 |
|
|
1616 |
|
//Si on finalise le document |
1617 |
|
if ( $status == 1 ){ |
1618 |
|
|
1619 |
|
//Génération du PDF |
1620 |
|
$_GET['output'] = "string"; |
1621 |
|
$f = $this->f; |
1622 |
|
include '../app/pdf_instruction.php'; |
1623 |
|
|
1624 |
|
//Métadonnées du document |
1625 |
|
$metadata = array( |
1626 |
|
'filename' => 'instruction_'.$idx.'.pdf', |
1627 |
|
'mimetype' => 'application/pdf', |
1628 |
|
'size' => strlen($pdf_output) |
1629 |
|
); |
1630 |
|
|
1631 |
|
// Récupération des métadonnées calculées après validation |
1632 |
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
1633 |
|
|
1634 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1635 |
|
//Si le document a déjà été finalisé |
1636 |
|
//on met à jour le document mais pas son uid |
1637 |
|
if ( $this->getVal("om_fichier_instruction") != '' ){ |
1638 |
|
$uid = $this->f->storage->update( |
1639 |
|
$this->getVal("om_fichier_instruction"), $pdf_output, $metadata); |
1640 |
|
} |
1641 |
|
//Sinon, on joute le document et on récupère son uid |
1642 |
|
else { |
1643 |
|
//Stockage du PDF |
1644 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1645 |
|
} |
1646 |
|
} |
1647 |
|
else { |
1648 |
|
//Récupération de l'uid du document finalisé |
1649 |
|
$uid = $this->getVal("om_fichier_instruction"); |
1650 |
|
|
1651 |
|
//On dé-finalise avant de finaliser |
1652 |
|
if ( $uid == '' ){ |
1653 |
|
return -1; |
1654 |
|
} |
1655 |
|
} |
1656 |
|
|
1657 |
|
//Mise à jour des données |
1658 |
|
if ( $uid != '' ){ |
1659 |
|
// Logger |
1660 |
|
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
1661 |
|
// Recuperation de la valeur de la cle primaire de l'objet |
1662 |
|
if($this->getVal($this->clePrimaire) != '') |
1663 |
|
$id = $this->getVal($this->clePrimaire); |
1664 |
|
else |
1665 |
|
$id=$this->id; |
1666 |
|
|
1667 |
|
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
1668 |
|
//à jour de l'interface |
1669 |
|
if ( $status == 0 ){ |
1670 |
|
$lien = '../app/pdf_instruction.php?idx='.$id; |
1671 |
|
} |
1672 |
|
else { |
1673 |
|
$lien = '../spg/file.php?obj=instruction&'. |
1674 |
|
'champ=om_fichier_instruction&id='.$id; |
1675 |
|
} |
1676 |
|
|
1677 |
|
$retour = array( |
1678 |
|
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
1679 |
|
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
1680 |
|
<span class=\"om-prev-icon om-icon-16 om-icon-fix delete-16 " |
1681 |
|
.(($status==1)?"de":"")."finalise\" title=\"". |
1682 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
1683 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
1684 |
|
</a>", |
1685 |
|
"pdf" => $lien |
1686 |
|
); |
1687 |
|
|
1688 |
|
foreach ( $this->champs as $key=>$value ) |
1689 |
|
$val[$value] = $this->val[$key]; |
1690 |
|
$val['date_evenement']=$this->dateDBToForm($val['date_evenement']); |
1691 |
|
$val['archive_date_complet']=$this->dateDBToForm($val['archive_date_complet']); |
1692 |
|
$val['archive_date_rejet']=$this->dateDBToForm($val['archive_date_rejet']); |
1693 |
|
$val['archive_date_limite']=$this->dateDBToForm($val['archive_date_limite']); |
1694 |
|
$val['archive_date_notification_delai']=$this->dateDBToForm($val['archive_date_notification_delai']); |
1695 |
|
$val['archive_date_decision']=$this->dateDBToForm($val['archive_date_decision']); |
1696 |
|
$val['archive_date_validite']=$this->dateDBToForm($val['archive_date_validite']); |
1697 |
|
$val['archive_date_achevement']=$this->dateDBToForm($val['archive_date_achevement']); |
1698 |
|
$val['archive_date_chantier']=$this->dateDBToForm($val['archive_date_chantier']); |
1699 |
|
$val['archive_date_conformite']=$this->dateDBToForm($val['archive_date_conformite']); |
1700 |
|
$val['archive_date_dernier_depot']=$this->dateDBToForm($val['archive_date_dernier_depot']); |
1701 |
|
$val['archive_date_limite_incompletude']=$this->dateDBToForm($val['archive_date_limite_incompletude']); |
1702 |
|
$val['date_finalisation_courrier']=$this->dateDBToForm($val['date_finalisation_courrier']); |
1703 |
|
$val['date_envoi_signature']=$this->dateDBToForm($val['date_envoi_signature']); |
1704 |
|
$val['date_retour_signature']=$this->dateDBToForm($val['date_retour_signature']); |
1705 |
|
$val['date_envoi_rar']=$this->dateDBToForm($val['date_envoi_rar']); |
1706 |
|
$val['date_retour_rar']=$this->dateDBToForm($val['date_retour_rar']); |
1707 |
|
$val['date_envoi_controle_legalite']=$this->dateDBToForm($val['date_envoi_controle_legalite']); |
1708 |
|
$val['date_retour_controle_legalite']=$this->dateDBToForm($val['date_retour_controle_legalite']); |
1709 |
|
|
1710 |
|
$this->setvalF($val); |
1711 |
|
|
1712 |
|
// Verification de la validite des donnees |
1713 |
|
$this->verifier($this->val, $this->db, DEBUG); |
1714 |
|
// Verification du verrou |
1715 |
|
$this->testverrou(); |
1716 |
|
// Si les verifications precedentes sont correctes, on procede a |
1717 |
|
// la modification, sinon on ne fait rien et on retourne une erreur |
1718 |
|
if ($this->correct) { |
1719 |
|
// Execution du trigger 'before' specifique au MODE 'update' |
1720 |
|
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1721 |
|
$valF = array( |
1722 |
|
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
1723 |
|
"om_fichier_instruction"=>$uid); |
1724 |
|
// Execution de la requête de modification des donnees de l'attribut |
1725 |
|
// valF de l'objet dans l'attribut table de l'objet |
1726 |
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1727 |
|
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
1728 |
|
$this->addToLog("finaliser() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", VERBOSE_MODE); |
1729 |
|
// Si une erreur survient |
1730 |
|
if (database::isError($res)) { |
1731 |
|
// Appel de la methode de recuperation des erreurs |
1732 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1733 |
|
} else { |
1734 |
|
// Log |
1735 |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1736 |
|
// Log |
1737 |
|
$message = _("Enregistrement")." ".$id." "; |
1738 |
|
$message .= _("de la table")." \"".$this->table."\" "; |
1739 |
|
$message .= "[ ".$this->db->affectedRows()." "; |
1740 |
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1741 |
|
$this->addToLog($message, VERBOSE_MODE); |
1742 |
|
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
1743 |
|
// le meme document |
1744 |
|
$this->verrouille(); |
1745 |
|
// Execution du trigger 'after' specifique au MODE 'update' |
1746 |
|
//$this->triggermodifierapres($id, $this->db, $val, DEBUG); |
1747 |
|
|
1748 |
|
return $retour; |
1749 |
|
} |
1750 |
|
} else { |
1751 |
|
// Message d'echec (saut d'une ligne supplementaire avant le |
1752 |
|
// message pour qu'il soit mis en evidence) |
1753 |
|
$this->addToLog("Finalisation non enregistree"); |
1754 |
|
return -1; |
1755 |
|
} |
1756 |
|
} |
1757 |
|
// Si le document n'a pas été stocké |
1758 |
|
else{ |
1759 |
|
return -1; |
1760 |
|
} |
1761 |
|
} |
1762 |
|
|
1763 |
|
/** |
1764 |
|
* Finalisation du document lors de l'ajout d'une instruction |
1765 |
|
* |
1766 |
|
*/ |
1767 |
|
function finaliserAjouter(){ |
1768 |
|
|
1769 |
|
//Génération du PDF |
1770 |
|
$_GET['output'] = "string"; |
1771 |
|
$_GET['obj'] = "instruction"; |
1772 |
|
$_GET['idx'] = $this->valF[$this->clePrimaire]; |
1773 |
|
$f = $this->f; |
1774 |
|
include '../app/pdf_instruction.php'; |
1775 |
|
|
1776 |
|
//Métadonnées du document |
1777 |
|
$metadata = array( |
1778 |
|
'filename' => 'instruction_'.$idx.'.pdf', |
1779 |
|
'mimetype' => 'application/pdf', |
1780 |
|
'size' => strlen($pdf_output) |
1781 |
|
); |
1782 |
|
|
1783 |
|
// Récupération des métadonnées calculées après validation |
1784 |
|
$spe_metadata = $this->getMetadata("om_fichier_instruction"); |
1785 |
|
|
1786 |
|
$metadata = array_merge($metadata, $spe_metadata); |
1787 |
|
|
1788 |
|
//On ajoute le document et on récupère son uid |
1789 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1790 |
|
|
1791 |
|
//Mise à jour des données |
1792 |
|
if ( $uid != '' ){ |
1793 |
|
// Logger |
1794 |
|
$this->addToLog("finaliserAjouter() - begin", EXTRA_VERBOSE_MODE); |
1795 |
|
|
1796 |
|
$valF = array( |
1797 |
|
"om_final_instruction"=> TRUE, |
1798 |
|
"om_fichier_instruction"=>$uid); |
1799 |
|
|
1800 |
|
// Execution de la requête de modification des donnees de l'attribut |
1801 |
|
// valF de l'objet dans l'attribut table de l'objet |
1802 |
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1803 |
|
DB_AUTOQUERY_UPDATE, $this->getCle($idx)); |
1804 |
|
$this->addToLog("finaliserAjouter() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($idx)."\")", VERBOSE_MODE); |
1805 |
|
// Si une erreur survient |
1806 |
|
if (database::isError($res)) { |
1807 |
|
// Appel de la methode de recuperation des erreurs |
1808 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1809 |
|
} else { |
1810 |
|
// Log |
1811 |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1812 |
|
// Log |
1813 |
|
$message = _("Enregistrement")." ".$idx." "; |
1814 |
|
$message .= _("de la table")." \"".$this->table."\" "; |
1815 |
|
$message .= "[ ".$this->db->affectedRows()." "; |
1816 |
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1817 |
|
$this->addToLog($message, VERBOSE_MODE); |
1818 |
|
} |
1819 |
|
} |
1820 |
|
} |
1821 |
|
|
1822 |
|
/** |
1823 |
|
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
1824 |
|
* @return [type] [description] |
1825 |
|
*/ |
1826 |
|
protected function getDossier() { |
1827 |
|
if(empty($this->specificMetadata)) { |
1828 |
|
$this->getSpecificMetadata(); |
1829 |
|
} |
1830 |
|
return $this->specificMetadata->dossier; |
1831 |
|
} |
1832 |
|
/** |
1833 |
|
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
1834 |
|
* @return [type] [description] |
1835 |
|
*/ |
1836 |
|
protected function getDossierAutorisation() { |
1837 |
|
if(empty($this->specificMetadata)) { |
1838 |
|
$this->getSpecificMetadata(); |
1839 |
|
} |
1840 |
|
return $this->specificMetadata->dossier_autorisation; |
1841 |
|
} |
1842 |
|
/** |
1843 |
|
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
1844 |
|
* @return [type] [description] |
1845 |
|
*/ |
1846 |
|
protected function getDateDemandeInitiale() { |
1847 |
|
if(empty($this->specificMetadata)) { |
1848 |
|
$this->getSpecificMetadata(); |
1849 |
|
} |
1850 |
|
return $this->specificMetadata->date_demande_initiale; |
1851 |
|
} |
1852 |
|
/** |
1853 |
|
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
1854 |
|
* @return [type] [description] |
1855 |
|
*/ |
1856 |
|
protected function getDossierInstructionType() { |
1857 |
|
if(empty($this->specificMetadata)) { |
1858 |
|
$this->getSpecificMetadata(); |
1859 |
|
} |
1860 |
|
return $this->specificMetadata->dossier_instruction_type; |
1861 |
|
} |
1862 |
|
/** |
1863 |
|
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
1864 |
|
* @return [type] [description] |
1865 |
|
*/ |
1866 |
|
protected function getStatut() { |
1867 |
|
if(empty($this->specificMetadata)) { |
1868 |
|
$this->getSpecificMetadata(); |
1869 |
|
} |
1870 |
|
return $this->specificMetadata->statut; |
1871 |
|
} |
1872 |
|
/** |
1873 |
|
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
1874 |
|
* @return [type] [description] |
1875 |
|
*/ |
1876 |
|
protected function getDossierAutorisationType() { |
1877 |
|
if(empty($this->specificMetadata)) { |
1878 |
|
$this->getSpecificMetadata(); |
1879 |
|
} |
1880 |
|
return $this->specificMetadata->dossier_autorisation_type; |
1881 |
|
} |
1882 |
|
/** |
1883 |
|
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
1884 |
|
* @return [type] [description] |
1885 |
|
*/ |
1886 |
|
protected function getDateEvenement() { |
1887 |
|
return date("d/m/Y"); |
1888 |
|
} |
1889 |
|
/** |
1890 |
|
* Récupération du groupe d'instruction à ajouter aux métadonnées |
1891 |
|
* @return string Groupe d'instruction |
1892 |
|
*/ |
1893 |
|
protected function getGroupeInstruction() { |
1894 |
|
if(empty($this->specificMetadata)) { |
1895 |
|
$this->getSpecificMetadata(); |
1896 |
|
} |
1897 |
|
return $this->specificMetadata->groupe_instruction; |
1898 |
|
} |
1899 |
|
|
1900 |
|
/** |
1901 |
|
* Cette méthode permet de stocker en attribut toutes les métadonnées |
1902 |
|
* nécessaire à l'ajout d'un document. |
1903 |
|
*/ |
1904 |
|
public function getSpecificMetadata() { |
1905 |
|
if (isset($this->valF["dossier"]) AND $this->valF["dossier"] != "") { |
1906 |
|
$dossier = $this->valF["dossier"]; |
1907 |
|
} else { |
1908 |
|
$dossier = $this->getVal("dossier"); |
1909 |
|
} |
1910 |
|
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
1911 |
|
$sql = "SELECT dossier.dossier as dossier, |
1912 |
|
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
1913 |
|
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
1914 |
|
dossier_instruction_type.code as dossier_instruction_type, |
1915 |
|
etat_dossier_autorisation.libelle as statut, |
1916 |
|
dossier_autorisation_type.code as dossier_autorisation_type, |
1917 |
|
groupe.code as groupe_instruction |
1918 |
|
FROM ".DB_PREFIXE."dossier |
1919 |
|
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
1920 |
|
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
1921 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
1922 |
|
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
1923 |
|
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
1924 |
|
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
1925 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
1926 |
|
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
1927 |
|
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
1928 |
|
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
1929 |
|
LEFT JOIN ".DB_PREFIXE."groupe |
1930 |
|
ON dossier_autorisation_type.groupe = groupe.groupe |
1931 |
|
WHERE dossier.dossier = '".$dossier."'"; |
1932 |
|
$res = $this->db->query($sql); |
1933 |
|
$this->f->addToLog("obj/document_numerise.class.php : db->query(".$sql.")", VERBOSE_MODE); |
1934 |
|
if ( database::isError($res)){ |
1935 |
|
die(); |
1936 |
|
} |
1937 |
|
|
1938 |
|
//Le résultat est récupéré dans un objet |
1939 |
|
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
1940 |
|
|
1941 |
|
//Si il y a un résultat |
1942 |
|
if ($row !== null) { |
1943 |
|
|
1944 |
|
//Alors on créé l'objet dossier_instruction |
1945 |
|
$this->specificMetadata = $row; |
1946 |
|
|
1947 |
|
} |
1948 |
|
} |
1949 |
}// fin classe |
}// fin classe |
1950 |
?> |
?> |