/[openfoncier]/trunk/obj/instruction.class.php
ViewVC logotype

Diff of /trunk/obj/instruction.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3904 by jymadier, Mon Apr 11 08:09:07 2016 UTC revision 3965 by nmeucci, Thu Apr 14 14:19:24 2016 UTC
# Line 1575  class instruction extends instruction_ge Line 1575  class instruction extends instruction_ge
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) {
# Line 1663  class instruction extends instruction_ge Line 1663  class instruction extends instruction_ge
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
# Line 1684  class instruction extends instruction_ge Line 1685  class instruction extends instruction_ge
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
# Line 1723  class instruction extends instruction_ge Line 1727  class instruction extends instruction_ge
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
# Line 1871  class instruction extends instruction_ge Line 1877  class instruction extends instruction_ge
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) {
# Line 2007  class instruction extends instruction_ge Line 2013  class instruction extends instruction_ge
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      /**      /**
# Line 2378  class instruction extends instruction_ge Line 2385  class instruction extends instruction_ge
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
# Line 4079  class instruction extends instruction_ge Line 4086  class instruction extends instruction_ge
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
# Line 4730  class instruction extends instruction_ge Line 4739  class instruction extends instruction_ge
4739    
4740      /**      /**
4741       * Logue l'action de l'instruction dans son DI       * Logue l'action de l'instruction dans son DI
4742       * @param  string $action ajouter/modifer/supprimer       *
4743       * @param  string $id     clé primaire de l'instruction       * @param   string  $id   clé primaire de l'instruction
4744       * @param  array  $val    valeurs de l'instruction       * @param   array   $val  valeurs de l'instruction
4745       * @return bool           vrai si traitement effectué avec succès       * @return  bool          vrai si traitement effectué avec succès
4746       */       */
4747      private function add_log_to_dossier($action, $id, $val) {      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'),
# Line 4747  class instruction extends instruction_ge Line 4767  class instruction extends instruction_ge
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;
# Line 4762  class instruction extends instruction_ge Line 4781  class instruction extends instruction_ge
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/>&nbsp;&nbsp;&nbsp;&nbsp; '.$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  ?>  ?>

Legend:
Removed from v.3904  
changed lines
  Added in v.3965

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26