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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 386 - (show 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 <?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 function setType(&$form,$maj) {
15 parent::setType($form,$maj);
16
17 if ($maj < 2) {
18 $form->setType('niveau', 'select');
19 }
20
21 if ($maj == 2 or $maj == 3) {
22 $form->setType('niveau', 'selectstatic');
23 }
24 }
25
26 /**
27 * Methode verifier
28 */
29 function verifier($val = array(), &$db = NULL, $DEBUG = false) {
30 // On appelle la methode de la classe parent
31 parent::verifier($val, $db, $DEBUG);
32 // 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 }
39 }
40 }
41
42 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 }
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 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26