38 |
// Tableau contenant une partie des métadonnées arrêtés |
// Tableau contenant une partie des métadonnées arrêtés |
39 |
var $metadonneesArrete; |
var $metadonneesArrete; |
40 |
|
|
41 |
|
/** |
42 |
|
* Instance de la classe dossier |
43 |
|
* |
44 |
|
* @var mixed |
45 |
|
*/ |
46 |
|
var $inst_dossier = null; |
47 |
|
|
48 |
var $metadata = array( |
var $metadata = array( |
49 |
"om_fichier_instruction" => array( |
"om_fichier_instruction" => array( |
50 |
"dossier" => "getDossier", |
"dossier" => "getDossier", |
447 |
$form->setType('date_finalisation_courrier', 'date'); |
$form->setType('date_finalisation_courrier', 'date'); |
448 |
// suivi des dates |
// suivi des dates |
449 |
if ($maj == 125) { |
if ($maj == 125) { |
450 |
|
$form->setType('date_evenement', 'hiddenstaticdate'); |
451 |
$form->setType('complement_om_html', 'hiddenstatic'); |
$form->setType('complement_om_html', 'hiddenstatic'); |
452 |
$form->setType('complement2_om_html', 'hiddenstatic'); |
$form->setType('complement2_om_html', 'hiddenstatic'); |
453 |
$form->setType('complement3_om_html', 'hiddenstatic'); |
$form->setType('complement3_om_html', 'hiddenstatic'); |
1575 |
$this->correct = false; |
$this->correct = false; |
1576 |
return false; |
return false; |
1577 |
} |
} |
1578 |
return $this->add_log_to_dossier('ajouter', $id, $val); |
return $this->add_log_to_dossier($id, array_merge($val, $this->valF)); |
1579 |
} |
} |
1580 |
|
|
1581 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
1663 |
if (database::isError($res)) { |
if (database::isError($res)) { |
1664 |
die($res->getMessage()); |
die($res->getMessage()); |
1665 |
} |
} |
1666 |
|
$current_id = $this->getVal($this->clePrimaire); |
1667 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)) { |
1668 |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
// Si la date de retour signature est éditée on vérifie si il existe un événement automatique |
1669 |
if ($this->getVal('date_retour_signature') == "" AND |
if ($this->getVal('date_retour_signature') == "" AND |
1685 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1686 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1687 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1688 |
|
$new_instruction->setParameter("maj", 0); |
1689 |
|
$new_instruction->class_actions[0]["identifier"] = |
1690 |
|
"retour signature de l'instruction $current_id"; |
1691 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1692 |
|
|
1693 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
1727 |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
$valNewInstr["date_retour_rar"] = $this->f->formatDate($this->valF['date_retour_rar']); |
1728 |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
$valNewInstr["date_envoi_controle_legalite"] = $this->f->formatDate($this->valF['date_envoi_controle_legalite']); |
1729 |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
$valNewInstr["date_retour_controle_legalite"] = $this->f->formatDate($this->valF['date_retour_controle_legalite']); |
1730 |
$new_instruction->setParameter("maj", $this->getParameter("maj")); |
$new_instruction->setParameter("maj", 0); |
1731 |
|
$new_instruction->class_actions[0]["identifier"] = |
1732 |
|
"retour RAR de l'instruction $current_id"; |
1733 |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
$retour = $new_instruction->ajouter($valNewInstr,$db, $DEBUG); |
1734 |
|
|
1735 |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
//Si une erreur s'est produite et qu'il s'agit d'un problème |
1877 |
$this->correct = false; |
$this->correct = false; |
1878 |
return false; |
return false; |
1879 |
} |
} |
1880 |
return $this->add_log_to_dossier('modifier', $id, $val); |
return $this->add_log_to_dossier($id, $val); |
1881 |
} |
} |
1882 |
|
|
1883 |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
function triggersupprimer($id,&$db,$val,$DEBUG) { |
2013 |
$this->correct = false; |
$this->correct = false; |
2014 |
return false; |
return false; |
2015 |
} |
} |
2016 |
return $this->add_log_to_dossier('supprimer', $id, $val); |
$val['evenement'] = $this->getVal('evenement'); |
2017 |
|
return $this->add_log_to_dossier($id, $val); |
2018 |
} |
} |
2019 |
|
|
2020 |
/** |
/** |
2385 |
$this->msg = ""; |
$this->msg = ""; |
2386 |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
$this->addToMessage(sprintf(_("La %s du document s'est effectuee avec succes."), $etat)); |
2387 |
|
|
2388 |
return true; |
return $this->add_log_to_dossier($id, $val); |
2389 |
} |
} |
2390 |
} else { |
} else { |
2391 |
// Message d'echec (saut d'une ligne supplementaire avant le |
// Message d'echec (saut d'une ligne supplementaire avant le |
2555 |
|
|
2556 |
//Si il y a un résultat |
//Si il y a un résultat |
2557 |
if ($row !== null) { |
if ($row !== null) { |
2558 |
|
|
2559 |
//Génération du numéro de version |
// Instrance de la classe dossier |
2560 |
$sql = "SELECT |
$inst_dossier = $this->get_inst_dossier($dossier); |
2561 |
count(*) |
|
2562 |
FROM |
// Insère l'attribut version à l'objet |
2563 |
".DB_PREFIXE."dossier |
$row->version = $inst_dossier->get_dossier_instruction_version(); |
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_autorisation |
|
|
ON |
|
|
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
|
|
LEFT JOIN |
|
|
".DB_PREFIXE."dossier_instruction_type |
|
|
ON |
|
|
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
|
|
WHERE |
|
|
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
|
|
AND |
|
|
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
|
|
$row->version = $this->db->getOne($sql); |
|
|
$this->f->addToLog("getSpecificMetadata(): db->getOne(\"".$sql."\")", VERBOSE_MODE); |
|
|
if ( database::isError($row->version)){ |
|
|
$this->f->addToError("", $row->version, $row->version); |
|
|
return false; |
|
|
} |
|
|
|
|
|
//Formatage du numéro de version |
|
|
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
|
2564 |
|
|
2565 |
//Alors on créé l'objet dossier_instruction |
//Alors on créé l'objet dossier_instruction |
2566 |
$this->specificMetadata = $row; |
$this->specificMetadata = $row; |
4086 |
|
|
4087 |
//On modifie les valeurs de l'instruction |
//On modifie les valeurs de l'instruction |
4088 |
$instr->setParameter('maj', 170); |
$instr->setParameter('maj', 170); |
4089 |
|
$instr->class_actions[170]["identifier"] = |
4090 |
|
"modifier (via le menu suivi des pièces)"; |
4091 |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
$retour = $instr->modifier($valF, $f->db, DEBUG); |
4092 |
|
|
4093 |
//Si une erreur s'est produite, on défait les modifications |
//Si une erreur s'est produite, on défait les modifications |
4726 |
} |
} |
4727 |
|
|
4728 |
/** |
/** |
4729 |
* Logue l'action de l'instruction dans son DI |
* Récupère l'instance du dossier d'instruction |
4730 |
* @param string $action ajouter/modifer/supprimer |
* |
4731 |
* @param string $id clé primaire de l'instruction |
* @param mixed Identifiant du dossier d'instruction |
4732 |
* @param array $val valeurs de l'instruction |
* |
4733 |
* @return bool vrai si traitement effectué avec succès |
* @return object |
4734 |
*/ |
*/ |
4735 |
private function add_log_to_dossier($action, $id, $val) { |
function get_inst_dossier($dossier = null) { |
4736 |
|
// |
4737 |
|
return $this->get_inst_common("dossier", $dossier); |
4738 |
|
} |
4739 |
|
|
4740 |
|
/** |
4741 |
|
* Logue l'action de l'instruction dans son DI |
4742 |
|
* |
4743 |
|
* @param string $id clé primaire de l'instruction |
4744 |
|
* @param array $val valeurs de l'instruction |
4745 |
|
* @return bool vrai si traitement effectué avec succès |
4746 |
|
*/ |
4747 |
|
private function add_log_to_dossier($id, $val) { |
4748 |
|
$maj = $this->getParameter("maj"); |
4749 |
|
// Action = Trace par défaut |
4750 |
|
$action = $this->get_backtrace(); |
4751 |
|
// Action = Identifant de l'action si contexte connu |
4752 |
|
if (empty($maj) === false |
4753 |
|
|| (empty($maj) === true && $maj === 0)) { |
4754 |
|
$action = $this->get_action_param($maj, 'identifier'); |
4755 |
|
if ($action === 'modifier_suivi') { |
4756 |
|
$action = "modifier (via l'action suivi des dates)"; |
4757 |
|
} |
4758 |
|
} |
4759 |
// Création du log |
// Création du log |
4760 |
$log = array( |
$log = array( |
4761 |
'date' => date('Y-m-d H:i:s'), |
'date' => date('Y-m-d H:i:s'), |
4767 |
'date_retour_signature' => $this->dateDB($val['date_retour_signature']), |
'date_retour_signature' => $this->dateDB($val['date_retour_signature']), |
4768 |
'evenement' => $val['evenement'], |
'evenement' => $val['evenement'], |
4769 |
'action' => $val['action'], |
'action' => $val['action'], |
4770 |
'instruction' => $id , |
'instruction' => $id, |
4771 |
'etat' => $val['etat'], |
'etat' => $val['etat'], |
4772 |
), |
), |
4773 |
); |
); |
4774 |
// Ajout du log |
// Ajout du log |
4775 |
require_once "../obj/dossier_instruction.class.php"; |
$di = $this->get_inst_common("dossier", $val['dossier']); |
|
$di = new dossier_instruction($val['dossier'], $this->db, DEBUG); |
|
4776 |
$ret = $di->add_log_instructions($log); |
$ret = $di->add_log_instructions($log); |
4777 |
if ($ret === false) { |
if ($ret === false) { |
4778 |
$this->correct = false; |
$this->correct = false; |
4781 |
} |
} |
4782 |
return $ret; |
return $ret; |
4783 |
} |
} |
4784 |
|
|
4785 |
|
/** |
4786 |
|
* Retourne le contexte de déboguage formaté en HTML |
4787 |
|
* |
4788 |
|
* @return string une ligne par trace |
4789 |
|
*/ |
4790 |
|
private function get_backtrace() { |
4791 |
|
$trace = debug_backtrace(); |
4792 |
|
$backtrace = ''; |
4793 |
|
$i = 1; |
4794 |
|
foreach ($trace as $key => $value) { |
4795 |
|
$func = $trace[$key]['function']; |
4796 |
|
// On ne s'autolog pas |
4797 |
|
if ($func === 'get_backtrace' |
4798 |
|
|| $func === 'add_log_to_dossier') { |
4799 |
|
continue; |
4800 |
|
} |
4801 |
|
$backtrace .= $i.') '; |
4802 |
|
// Si dans une classe |
4803 |
|
if (isset($trace[$key]['class']) === true |
4804 |
|
&& empty($trace[$key]['class']) === false) { |
4805 |
|
$backtrace .= $trace[$key]['class'].'->'.$func; |
4806 |
|
} |
4807 |
|
// Si procédural |
4808 |
|
else { |
4809 |
|
$file = $trace[$key]['file']; |
4810 |
|
$line = $trace[$key]['line']; |
4811 |
|
$truncated_file = $this->get_relative_path($file); |
4812 |
|
if ($truncated_file !== false) { |
4813 |
|
$file = $truncated_file; |
4814 |
|
} |
4815 |
|
$backtrace .= $func.' IN<br/> '.$file.':'.$line; |
4816 |
|
} |
4817 |
|
$backtrace .= '<br/>'; |
4818 |
|
$i++; |
4819 |
|
} |
4820 |
|
return $backtrace; |
4821 |
|
} |
4822 |
|
|
4823 |
|
/** |
4824 |
|
* Pour un path absolu donné, retourne le relatif à la racine de l'application |
4825 |
|
* |
4826 |
|
* @param string $path chemin absolu |
4827 |
|
* @return mixed false si échec sinon chemin relatif |
4828 |
|
*/ |
4829 |
|
private function get_relative_path($absolute) { |
4830 |
|
if ($this->get_path_app() === false) { |
4831 |
|
return false; |
4832 |
|
} |
4833 |
|
$path_app = $this->get_path_app(); |
4834 |
|
return str_replace($path_app, '', $absolute); |
4835 |
|
} |
4836 |
|
|
4837 |
|
/** |
4838 |
|
* Retourne le path absolu de la racine de l'application |
4839 |
|
* |
4840 |
|
* @return mixed false si échec sinon chemin absolu |
4841 |
|
*/ |
4842 |
|
private function get_path_app() { |
4843 |
|
$match = array(); |
4844 |
|
preg_match( '/(.*)\/[a-zA-Z0-9]+\/\.\.\/core\/$/', PATH_OPENMAIRIE, $match); |
4845 |
|
// On vérifie qu'il n'y a pas d'erreur |
4846 |
|
if (isset($match[1]) === false) { |
4847 |
|
return false; |
4848 |
|
} |
4849 |
|
return $match[1]; |
4850 |
|
} |
4851 |
}// fin classe |
}// fin classe |
4852 |
|
|
4853 |
?> |
?> |