/[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 3 - (hide annotations)
Thu Feb 10 20:46:18 2011 UTC (13 years, 11 months ago) by fraynaud
File size: 2426 byte(s)
version initiale


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    
8     var $maj;
9    
10     function om_collectivite($id,&$db,$debug) {
11     $this->constructeur($id,$db,$debug);
12     }// fin constructeur
13    
14    
15     function setType(&$form,$maj) {
16     parent::setType($form,$maj);
17    
18     if ($maj < 2) {
19     $form->setType('niveau', 'select');
20     }
21     }
22    
23     function verifier($val, &$db, $DEBUG) {
24     parent::verifier($val, $db, $DEBUG);
25     $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";
26     $imgv="<img src='../img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";
27     if ($this->valF['niveau']==""){
28     $this->msg= $this->msg.$imgv._('niveau')."&nbsp;"._('obligatoire').$f;
29     $this->correct=False;
30     }else
31     // verification si il y a une autre collectivite multi
32     if($this->valF['niveau']==2)
33     if($this->maj==0)
34     $this->verifierniveau($db, $DEBUG,']');
35     else
36     $this->verifierniveau($db, $DEBUG,$val['om_collectivite']);
37     }
38    
39     function setSelect(&$form, $maj,$db,$debug) {
40     if($maj<2){
41     $contenu=array();
42     $contenu[0]=array(1,2);
43     $contenu[1]=array(_("mono"),_("multi"));
44     $form->setSelect("niveau",$contenu);
45     }
46     }
47    
48     /**
49     * verification sur existence d une collectivite de niveau 2
50     */
51     function verifierniveau(&$db, $DEBUG,$id){
52     $sql = "select * from ".DB_PREFIXE."om_collectivite where niveau = '2'";
53     if($id!=']')
54     $sql.=" and om_collectivite !='".$id."'";
55     $res = $db->query($sql);
56     if($DEBUG==1) echo $sql;
57     if (database::isError($res))
58     die($res->getMessage(). " => Echec ".$sql);
59     else{
60     $nbligne=$res->numrows();
61     if ($nbligne>0){
62     $this->msg= $this->msg." ".$nbligne." "._("collectivite")." "._("existant").
63     " "._("niveau")." 2 ! "._("vous ne pouvez avoir qu une collectivite")." ".
64     _("de")." "._("niveau")." multi ";
65     $this->correct=False;
66     }
67     }
68     }
69    
70     function setVal(&$form, $maj, $validation, &$db, $DEBUG=null) {
71     parent::setVal($form, $maj, $validation, $db, $DEBUG=null);
72     $this->maj=$maj;
73     }
74     }// fin classe
75     ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26