<?php
//$Id$ 
//gen openMairie le 14/05/2012 13:43 
require_once ("../obj/om_dbform.class.php");

class om_sig_point_comp_gen extends om_dbform {
    var $table="om_sig_point_comp";
    var $clePrimaire="om_sig_point_comp";
    var $typeCle="N";
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if(!is_numeric($val['om_sig_point_comp']))
            unset($this->valF['om_sig_point_comp']);
        else
            $this->valF['om_sig_point_comp'] = $val['om_sig_point_comp'];
        if(!is_numeric($val['om_sig_point']))
            unset($this->valF['om_sig_point']);
        else
            $this->valF['om_sig_point'] = $val['om_sig_point'];
        $this->valF['libelle'] = $val['libelle'];
        if(!is_numeric($val['ordre']))
            unset($this->valF['ordre']);
        else
            $this->valF['ordre'] = $val['ordre'];
        $this->valF['actif'] = $val['actif'];
        $this->valF['comp_maj'] = $val['comp_maj'];
        $this->valF['type_geometrie'] = $val['type_geometrie'];
        $this->valF['comp_table_update'] = $val['comp_table_update'];
        $this->valF['comp_champ'] = $val['comp_champ'];
    }

    //=================================================
    //cle primaire automatique [automatic primary key]
    //==================================================

    function setId(&$db) {
    //numero automatique
        $this->valF[$this->table] = $db->nextId(DB_PREFIXE.$this->table);
    }

    function setValFAjout($val) {
    //numero automatique -> pas de controle ajout cle primaire
    }

    function verifierAjout() {
    //numero automatique -> pas de verfication de cle primaire
    }

    //====================================
    // verifier avant validation [verify]
    //=====================================
    /**
     * Methode verifier
     */
    function verifier($val = array(), &$db = NULL, $DEBUG = false) {
        // On appelle la methode de la classe parent
        parent::verifier($val, $db, $DEBUG);
        // On verifie si le champ n'est pas vide
        if ($this->valF['om_sig_point'] == "") {
            $this->correct = false;
            $this->addToMessage(_("Le champ")." "._("om_sig_point")." "._("est obligatoire"));
        }
    }


    //==========================
    // Formulaire  [form]
    //==========================

    function setType(&$form,$maj) {
        //type
        if ($maj==0){ //ajout
            $form->setType('om_sig_point_comp','hidden');// cle automatique
            if($this->retourformulaire=='om_sig_point')
                $form->setType('om_sig_point','hiddenstatic');
            else
                $form->setType('om_sig_point','select');
            $form->setType('libelle','text');
            $form->setType('ordre','text');
            $form->setType('actif','text');
            $form->setType('comp_maj','text');
            $form->setType('type_geometrie','text');
            $form->setType('comp_table_update','text');
            $form->setType('comp_champ','text');
        }// fin ajout
        if ($maj==1){ //modifier
            $form->setType('om_sig_point_comp','hiddenstatic');
            if($this->retourformulaire=='om_sig_point')
                $form->setType('om_sig_point','hiddenstatic');
            else
                $form->setType('om_sig_point','select');
            $form->setType('libelle','text');
            $form->setType('ordre','text');
            $form->setType('actif','text');
            $form->setType('comp_maj','text');
            $form->setType('type_geometrie','text');
            $form->setType('comp_table_update','text');
            $form->setType('comp_champ','text');
        }// fin modifier
        if ($maj==2){ //supprimer
            $form->setType('om_sig_point_comp','hiddenstatic');
            $form->setType('om_sig_point','hiddenstatic');
            $form->setType('libelle','hiddenstatic');
            $form->setType('ordre','hiddenstatic');
            $form->setType('actif','hiddenstatic');
            $form->setType('comp_maj','hiddenstatic');
            $form->setType('type_geometrie','hiddenstatic');
            $form->setType('comp_table_update','hiddenstatic');
            $form->setType('comp_champ','hiddenstatic');
        }//fin supprimer
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('om_sig_point_comp','VerifNum(this)');
        $form->setOnchange('om_sig_point','VerifNum(this)');
        $form->setOnchange('ordre','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("om_sig_point_comp", 11);
        $form->setTaille("om_sig_point", 11);
        $form->setTaille("libelle", 30);
        $form->setTaille("ordre", 11);
        $form->setTaille("actif", 10);
        $form->setTaille("comp_maj", 10);
        $form->setTaille("type_geometrie", 30);
        $form->setTaille("comp_table_update", 30);
        $form->setTaille("comp_champ", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("om_sig_point_comp", 11);
        $form->setMax("om_sig_point", 11);
        $form->setMax("libelle", 50);
        $form->setMax("ordre", 11);
        $form->setMax("actif", 3);
        $form->setMax("comp_maj", 3);
        $form->setMax("type_geometrie", 30);
        $form->setMax("comp_table_update", 30);
        $form->setMax("comp_champ", 30);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('om_sig_point_comp',_('om_sig_point_comp'));
        $form->setLib('om_sig_point',_('om_sig_point'));
        $form->setLib('libelle',_('libelle'));
        $form->setLib('ordre',_('ordre'));
        $form->setLib('actif',_('actif'));
        $form->setLib('comp_maj',_('comp_maj'));
        $form->setLib('type_geometrie',_('type_geometrie'));
        $form->setLib('comp_table_update',_('comp_table_update'));
        $form->setLib('comp_champ',_('comp_champ'));
    }

    function setSelect(&$form, $maj,&$db,$debug) {
        if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
            include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
        elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))
            include ("../sql/".$db->phptype."/".$this->table.".form.inc");
        if($maj<2){
            // om_sig_point
            $contenu=array();
            $res = $db->query($sql_om_sig_point);
            // Logger
            $this->addToLog("setSelect()[gen/obj]: db->query(\"".$sql_om_sig_point."\");", VERBOSE_MODE);
            if (database::isError($res))
                die($res->getMessage().$sql_om_sig_point);
            else{
                if ($debug == 1)
                    echo " la requete ".$sql_om_sig_point." est executee<br>";
                $contenu[0][0]='';
                $contenu[1][0]=_('choisir')."&nbsp;"._('om_sig_point');
                $k=1;
                    while ($row=& $res->fetchRow()){
                        $contenu[0][$k]=$row[0];
                        $contenu[1][$k]=$row[1];
                        $k++;
                }
                $form->setSelect('om_sig_point',$contenu);
            }// fin error db
        }// fin maj
    }// fin select

    //==================================
    // sous Formulaire  [subform]
    //==================================

    function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
        $this->retourformulaire = $retourformulaire;
        if($validation==0) {
            if($retourformulaire =='om_sig_point')
                $form->setVal('om_sig_point', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

    //==================================
    // cle secondaire  [secondary key]
    //==================================

}// fin classe
?>