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

Annotation of /trunk/obj/om_collectivite.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 386 - (hide annotations)
Wed Sep 19 12:59:37 2012 UTC (12 years, 4 months ago) by nhaye
File size: 2321 byte(s)
Correction afin que la contenu se raproche au maximum de celui d'openmairie exemple

1 fraynaud 3 <?php
2     //$Id$
3     //gen openMairie le 15/10/2010 15:56
4     require_once ("../gen/obj/om_collectivite.class.php");
5    
6     class om_collectivite extends om_collectivite_gen {
7 nhaye 386
8 fraynaud 3 var $maj;
9 nhaye 386
10 fraynaud 3 function om_collectivite($id,&$db,$debug) {
11     $this->constructeur($id,$db,$debug);
12     }// fin constructeur
13 nhaye 386
14 fraynaud 3 function setType(&$form,$maj) {
15 nhaye 386 parent::setType($form,$maj);
16 fraynaud 3
17 nhaye 386 if ($maj < 2) {
18     $form->setType('niveau', 'select');
19     }
20    
21     if ($maj == 2 or $maj == 3) {
22     $form->setType('niveau', 'selectstatic');
23     }
24 fraynaud 3 }
25    
26 nhaye 386 /**
27     * Methode verifier
28     */
29     function verifier($val = array(), &$db = NULL, $DEBUG = false) {
30     // On appelle la methode de la classe parent
31 fraynaud 3 parent::verifier($val, $db, $DEBUG);
32 nhaye 386 // On verifie si il y a une autre collectivite multi
33     if ($this->valF['niveau'] == 2) {
34     if ($this->maj == 0) {
35     $this->verifierniveau($db, $DEBUG, ']');
36     } else {
37     $this->verifierniveau($db, $DEBUG, $val['om_collectivite']);
38 nhaye 382 }
39     }
40 fraynaud 3 }
41    
42 nhaye 386 function setSelect(&$form, $maj, $db, $debug) {
43     $contenu = array();
44     $contenu[0] = array(1, 2);
45     $contenu[1] = array(_('mono'), _('multi'));
46     $form->setSelect('niveau', $contenu);
47 fraynaud 3 }
48    
49     /**
50     * verification sur existence d une collectivite de niveau 2
51     */
52     function verifierniveau(&$db, $DEBUG,$id){
53     $sql = "select * from ".DB_PREFIXE."om_collectivite where niveau = '2'";
54     if($id!=']')
55     $sql.=" and om_collectivite !='".$id."'";
56     $res = $db->query($sql);
57     if($DEBUG==1) echo $sql;
58     if (database::isError($res))
59     die($res->getMessage(). " => Echec ".$sql);
60     else{
61     $nbligne=$res->numrows();
62     if ($nbligne>0){
63     $this->msg= $this->msg." ".$nbligne." "._("collectivite")." "._("existant").
64     " "._("niveau")." 2 ! "._("vous ne pouvez avoir qu une collectivite")." ".
65     _("de")." "._("niveau")." multi ";
66     $this->correct=False;
67     }
68     }
69     }
70    
71     function setVal(&$form, $maj, $validation, &$db, $DEBUG=null) {
72     parent::setVal($form, $maj, $validation, $db, $DEBUG=null);
73     $this->maj=$maj;
74     }
75     }// fin classe
76 nhaye 386 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26