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

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

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

revision 2267 by softime, Tue Sep 10 08:16:35 2013 UTC revision 2605 by softime, Thu Dec 12 18:00:35 2013 UTC
# Line 96  class utils extends application { Line 96  class utils extends application {
96              $this->om_utilisateur["libelle_profil"] = $resProfil;              $this->om_utilisateur["libelle_profil"] = $resProfil;
97    
98              // si c'est un administrateur technique              // si c'est un administrateur technique
99              if ($resProfil == "ADMINISTRATEUR TECHNIQUE") {              // XXX Mauvaise méthode, il faut utiliser isAccredited
100                if ($resProfil == "ADMINISTRATEUR TECHNIQUE"
101                    || $resProfil == "ADMINISTRATEUR FONCTIONNEL") {
102                  $this->user_is_admin = true;                  $this->user_is_admin = true;
103              } else {              } else {
104                  $this->user_is_admin = false;                  $this->user_is_admin = false;
# Line 589  class utils extends application { Line 591  class utils extends application {
591          (isset($this->config['path_scan']) ? "" : $this->config['path_scan'] = '../trs/numerisation/');          (isset($this->config['path_scan']) ? "" : $this->config['path_scan'] = '../trs/numerisation/');
592                    
593          $default_sig_elyx = array(          $default_sig_elyx = array(
             'url' => 'http://localhost/openads/tests/sig_elyx_test.php',  
594              'wsdl' => '../tests/wsurbanisme.wsdl',              'wsdl' => '../tests/wsurbanisme.wsdl',
595              'login' => 'sig',              'login' => 'sig',
596              'password' => 'sig',              'password' => 'sig',
# Line 616  class utils extends application { Line 617  class utils extends application {
617          }          }
618      }      }
619    
620        /**
621         * Permet de vérifier que des champs existe dans une table
622         * @param  array  $list_fields Liste des champs à tester
623         * @param  string $table       Table où les champs doivent exister
624         * @return mixed               Retourne les champs qui n'existent pas
625         *                             ou true
626         */
627        public function check_field_exist($list_fields, $table) {
628    
629            // Requête SQL pour récupérer le nom des colonnes
630            $sql = "SELECT column_name
631                    FROM information_schema.columns
632                    WHERE table_schema = '".substr(DB_PREFIXE, 0, -1)."'
633                    AND table_name = '".$table."'
634                    ORDER BY ordinal_position";
635            $this->addToLog("check_field_exist() : db->query(\"".$sql."\")", VERBOSE_MODE);
636            $res = $this->db->query($sql);
637            $this->isDatabaseError($res);
638    
639            // Tant qu'il y a un résultat
640            while ($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
641                
642                // Le nom de la colonne est mise dans un tableau
643                $list_column[] = $row['column_name'];
644            }
645    
646            // Tableau des champs en erreur
647            $error_fields = array();
648    
649            // Pour chaque champ à tester
650            foreach ($list_fields as $value) {
651                
652                // S'il n'apparaît pas dans la liste des champs possible
653                if (!in_array($value, $list_column)) {
654    
655                    // Alors le champ est ajouté au tableau des erreurs
656                    $error_fields[] = $value;
657                }
658            }
659    
660            // Si le tableau des erreurs n'est pas vide on le retourne
661            if (count($error_fields) > 0) {
662                return $error_fields;
663            }
664    
665            // Sinon on retourne le booléen true
666            return true;
667    
668        }
669    
670        /*
671         *
672         */
673        /**
674         * Récupère la lettre type lié à un événement
675         * @param  integer  $evenement L'identifiant de l'événement
676         * @return integer             Retourne l'idenfiant de la lettre-type                             ou true
677         */
678        function getLettreType($evenement){
679            
680             $lettretype = NULL;
681            
682             $sql =
683                "SELECT
684                    lettretype
685                FROM
686                    ".DB_PREFIXE."evenement
687                WHERE
688                    evenement = $evenement";
689                
690            $this->addToLog("getLettreType() : db->query(\"".$sql."\")", VERBOSE_MODE);
691            $res = $this->db->query($sql);
692            if ( database::isError($res)){
693                die();
694            }
695            
696            if ( $res->numrows() > 0 ){
697                    
698                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
699                $lettretype = $row['lettretype'];
700            }
701          
702            return $lettretype;
703        }
704        
705        /**
706         * Retourne le type de dossier d'autorisation du dossier courant :
707         * @param $idxDossier Le numéro du dossier d'instruction
708         * @return le code du type détaillée de dossier d'autorisation
709         **/
710        function getDATDCode($idxDossier) {
711            $sql = "SELECT dossier_autorisation_type_detaille.code
712                    FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
713                    INNER JOIN ".DB_PREFIXE."dossier_autorisation
714                        ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
715                           dossier_autorisation.dossier_autorisation_type_detaille
716                    INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
717                    WHERE dossier.dossier = '".$idxDossier."'";
718            $res = $this->db->getOne($sql);
719            $this->addToLog("getDATDCode() : db->getOne(\"".$sql."\")", VERBOSE_MODE);
720            if ( database::isError($res)){
721                die();
722            }
723            return $res;
724        }
725  }  }
726    
727  ?>  ?>

Legend:
Removed from v.2267  
changed lines
  Added in v.2605

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26