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

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

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

revision 403 by nhaye, Thu Sep 20 15:25:57 2012 UTC revision 1173 by vpihour, Tue Jan 8 11:29:08 2013 UTC
# Line 17  class evenement extends evenement_gen { Line 17  class evenement extends evenement_gen {
17              $form->setType('delai_notification', 'select');              $form->setType('delai_notification', 'select');
18              $form->setType('delai', 'select');              $form->setType('delai', 'select');
19              $form->setType('lettretype', 'select');              $form->setType('lettretype', 'select');
20              $form->setType('pour_consultation', 'checkbox');              $form->setType('consultation', 'checkbox');
21                $form->setType('dossier_instruction_type','select_multiple');
22          }          }
23            
24            //Ajout du type select multiple sur dossier_instruction_type
25            if ($maj==2){ //supprimer
26            
27                $form->setType('dossier_instruction_type','select_multiple_static');
28            }//fin supprimer
29            if ($maj==3){ //consulter
30            
31                $form->setType('dossier_instruction_type','select_multiple_static');
32            }//fin consulter
33      }      }
34    
35      function setSelect(&$form, $maj,$db,$debug) {      function setSelect(&$form, $maj,$db,$debug) {
36            
37            if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
38                    include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
39            
40          parent::setSelect($form, $maj,$db,$debug);          parent::setSelect($form, $maj,$db,$debug);
41    
42          if($maj<2){          if($maj<2){
43              // lettretype              // lettretype
44              if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))              
                 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");  
45              $contenu=array();              $contenu=array();
46              $res = $db->query($sql_om_lettretype);              $res = $db->query($sql_om_lettretype);
47              if (database::isError($res))              if (database::isError($res))
# Line 76  class evenement extends evenement_gen { Line 90  class evenement extends evenement_gen {
90                            '24 '._("mois")                            '24 '._("mois")
91                            );                            );
92          $form->setSelect("delai",$contenu);          $form->setSelect("delai",$contenu);
93            
94            // dossier_instruction_type
95            $this->init_select($form, $db, $maj, $debug, "dossier_instruction_type",
96                               $sql_dossier_instruction_type, $sql_dossier_instruction_type_by_id, false);
97        }
98        
99        //Nombre de dossier_instruction_type affiché
100        function setTaille(&$form, $maj) {
101            
102            parent::setTaille($form, $maj);
103            $form->setTaille("dossier_instruction_type", 5);
104        }
105        
106        //Nombre de dossier_instruction_type maximum
107        function setMax(&$form, $maj) {
108            
109            parent::setMax($form, $maj);
110            $form->setMax("dossier_instruction_type", 5);
111      }      }
112    
113        //Ajoute autant de lien_dossier_instruction_type_evenement que de dossier_instruction_type
114        function triggerajouterapres($id,&$db,$val,$DEBUG) {
115            
116            parent::triggerajouterapres($id,$db,$val,$DEBUG);
117    
118            //Récupère les données du select multiple
119            $dossier_instruction_type = $this->getPostedValues('dossier_instruction_type');
120            
121            //Ne traite les données que s'il y en a et qu'elles sont correctes
122            if ( is_array($dossier_instruction_type) && count($dossier_instruction_type) > 0 ){
123                
124                $nb_tr = 0;    
125                /* Va créer autant de lien_dossier_instruction_type_evenement
126                 * que de dossier_instruction_type choisis */
127                foreach( $dossier_instruction_type as $value ){
128                
129                    //Test si la valeur par défaut est sélectionnée
130                    if ( $value != "" ) {
131                        
132                        //Données
133                        $donnees = array(
134                            'evenement' => $this->valF['evenement'],
135                            'dossier_instruction_type' => $value
136                        );
137                        
138                        //Ajoute un nouveau lien_dossier_instruction_type_evenement
139                        $this->addLienDossierInstructionType($donnees, $db, $DEBUG);
140    
141                        $nb_tr++;
142                    }
143                }
144                
145                //Message de confirmation de création de(s) lien_dossier_instruction_type_evenement(s).
146                if ( $nb_tr > 0 ){
147                    
148                    if ( $nb_tr == 1 ){
149                        
150                        $this->addToMessage(_("Creation de ").$nb_tr._(" nouvelle liaison
151                            realisee avec succes."));
152                    }
153                    else{
154                        
155                        $this->addToMessage(_("Creation de ").$nb_tr._(" nouvelles liaisions
156                            realisee avec succes."));
157                    }
158                }
159            }
160            
161        }
162        
163        //Fonction générique permettant de récupérer les données d'un champ postées
164        function getPostedValues($champ) {
165            
166            // Récupération des demandeurs dans POST
167            if (isset($_POST[$champ]) ) {
168                
169                return $_POST[$champ];
170            }
171        }
172        
173        //Modification des liens
174        function triggerModifierApres($id, &$db, $val, $DEBUG){
175            
176            parent::triggerModifierApres($id, $db, $val, $DEBUG);
177            
178            //Supprime toutes les liaisions liées à l'événement
179            $this->deleteAllLienDossierInstructionTypeEvenementEvenement($this->valF['evenement'], $db, $DEBUG);
180            
181            //Récupère les données du select multiple
182            $dossier_instruction_type = $this->getPostedValues('dossier_instruction_type');
183            
184            //Ne traite les données que s'il y en a et qu'elles sont correctes
185            if ( is_array($dossier_instruction_type) && count($dossier_instruction_type) > 0 ){
186                
187                $nb_tr = 0;    
188                //Va créer autant de lien_dossier_instruction_type_evenement que de dossier_instruction_type choisis
189                foreach( $dossier_instruction_type as $value ){
190                
191                    //Test si la valeur par défaut est sélectionnée
192                    if ( $value != "" ) {
193                        
194                        //Données
195                        $donnees = array(
196                            'evenement' => $this->valF['evenement'],
197                            'dossier_instruction_type' => $value
198                        );
199                        
200                        //Ajoute un nouveau lien_dossier_instruction_type_evenement
201                        $this->addLienDossierInstructionType($donnees, $db, $DEBUG);
202    
203                        $nb_tr++;
204                    }
205                }
206                
207                //Message de confirmation de création de(s) lien_dossier_instruction_type_evenement.
208                if ( $nb_tr > 0 ){
209                    
210                    $this->addToMessage(_("Mise a jour des liaisons realisee avec succes."));
211                }
212            }
213        }
214    
215        //Ajoute un nouveau lien_dossier_instruction_type_evenement
216        // $data array de données
217        function addLienDossierInstructionType($data, $db, $DEBUG){
218            
219            require_once '../obj/lien_dossier_instruction_type_evenement.class.php';
220            
221            $lien_dossier_instruction_type_evenement = new lien_dossier_instruction_type_evenement("]",$db,$DEBUG);
222            $lien_dossier_instruction_type_evenement->valF = "";
223        
224            //Données
225            $vallien_dossier_instruction_type_evenement['lien_dossier_instruction_type_evenement']=NULL;
226        
227            if ( is_array($data) ){
228                
229                foreach ($data as $key => $value) {
230                    
231                    $vallien_dossier_instruction_type_evenement[$key]=$value;
232                }            
233            }
234        
235            $lien_dossier_instruction_type_evenement->ajouter($vallien_dossier_instruction_type_evenement, $db, $DEBUG);
236        }
237    
238        //Supprime toutes les lien_dossier_instruction_type_evenement liées à un événement
239        function deleteAllLienDossierInstructionTypeEvenementEvenement($id, $db, $DEBUG){
240                
241            //Création de la requête
242            $sql = "DELETE FROM
243                    ".DB_PREFIXE."lien_dossier_instruction_type_evenement
244                WHERE
245                    evenement = $id";
246            
247            //Exécution de la requête
248            $res = $db->query($sql);
249            
250            //Ajout au log
251            $this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
252            $this->f->isDatabaseError();
253        }
254    
255        //Suppression de toutes les lien_dossier_instruction_type_evenement avec evenement
256        function triggersupprimer($id, &$db, $val, $DEBUG){
257                    
258            //Supprime toutes les lien_dossier_instruction_type_evenement liées à l'evenement
259            $this->deleteAllLienDossierInstructionTypeEvenementEvenement($id, $db, $DEBUG);
260        }
261        
262        /* Surcharge de la fonction cleSecondaire pour qu'elle ne vérifie pas le lien avec
263         * lien_dossier_instruction_type_evenement qui sera supprimé juste après*/
264        function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) {
265    
266            // Verification de la cle secondaire : bible
267            $this->rechercheTable($db, "bible", "evenement", $id);
268            // Verification de la cle secondaire : demande_type
269            $this->rechercheTable($db, "demande_type", "evenement", $id);
270            // Verification de la cle secondaire : evenement
271            $this->rechercheTable($db, "evenement", "evenement_retour_ar", $id);
272            // Verification de la cle secondaire : evenement
273            $this->rechercheTable($db, "evenement", "evenement_suivant_tacite", $id);
274            // Verification de la cle secondaire : instruction
275            $this->rechercheTable($db, "instruction", "evenement", $id);
276            // Verification de la cle secondaire : lien_evenement_dossier_autorisation_type
277            $this->rechercheTable($db, "lien_evenement_dossier_autorisation_type", "evenement", $id);
278            // Verification de la cle secondaire : transition
279            $this->rechercheTable($db, "transition", "evenement", $id);
280        }
281        
282        //Affichage des dossier_instruction_type anciennement liés
283        function setVal(&$form, $maj, $validation, &$db) {
284            
285            parent::setVal($form, $maj, $validation, $db);
286            
287            if($maj == 2 && $validation == 1 ) {
288                 $form->setVal("dossier_instruction_type",$this->val[count($this->val)-1]);
289            }
290        }
291    
292  }// fin classe  }// fin classe
293  ?>  ?>

Legend:
Removed from v.403  
changed lines
  Added in v.1173

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26