<?php
//$Id$ 
//gen openMairie le 05/10/2012 13:55

require_once ("../obj/om_dbform.class.php");

class om_sig_map_comp_gen extends om_dbform {
    var $table="om_sig_map_comp";
    var $clePrimaire="om_sig_map_comp";
    var $typeCle="N";
    var $required_field=array(
        "libelle",
        "om_sig_map",
        "om_sig_map_comp",
        "ordre"
    );
    var $retourformulaire;

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

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

    function setId(&$db) {
    //numero automatique
        $this->valF[$this->clePrimaire] = $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
    }

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

    function setType(&$form,$maj) {
        //type
        if ($maj==0){ //ajout
            $form->setType('om_sig_map_comp','hidden');// cle automatique

            if($this->retourformulaire=='om_sig_map'
               and $form->val['om_sig_map'] == $this->getParameter('idxformulaire')) {
                $form->setType('om_sig_map','selecthiddenstatic');
            } else {
                $form->setType('om_sig_map','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_map_comp','hiddenstatic');

            if($this->retourformulaire=='om_sig_map'
               and $form->val['om_sig_map'] == $this->getParameter('idxformulaire')) {
                $form->setType('om_sig_map','selecthiddenstatic');
            } else {
                $form->setType('om_sig_map','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_map_comp','hiddenstatic');
            $form->setType('om_sig_map','selectstatic');
            $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
        if ($maj==3){ //consulter
            $form->setType('om_sig_map_comp','static');
            $form->setType('om_sig_map','selectstatic');
            $form->setType('libelle','static');
            $form->setType('ordre','static');
            $form->setType('actif','static');
            $form->setType('comp_maj','static');
            $form->setType('type_geometrie','static');
            $form->setType('comp_table_update','static');
            $form->setType('comp_champ','static');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('om_sig_map_comp','VerifNum(this)');
        $form->setOnchange('om_sig_map','VerifNum(this)');
        $form->setOnchange('ordre','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("om_sig_map_comp", 11);
        $form->setTaille("om_sig_map", 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_map_comp", 11);
        $form->setMax("om_sig_map", 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_map_comp',_('om_sig_map_comp'));
        $form->setLib('om_sig_map',_('om_sig_map'));
        $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");

        // om_sig_map
        $this->init_select($form, $db, $maj, $debug, "om_sig_map",
                           $sql_om_sig_map, $sql_om_sig_map_by_id, false);
    }// 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_map')
                $form->setVal('om_sig_map', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>