<?php
//$Id$ 
//gen openMairie le 10/04/2015 16:50

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

class parcelle_gen extends om_dbform {

    var $table = "parcelle";
    var $clePrimaire = "parcelle";
    var $typeCle = "N";
    var $required_field = array(
        "parcelle"
    );
    
    var $foreign_keys_extended = array(
    );



    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['parcelle'])) {
            $this->valF['parcelle'] = ""; // -> requis
        } else {
            $this->valF['parcelle'] = $val['parcelle'];
        }
        if ($val['code'] == "") {
            $this->valF['code'] = NULL;
        } else {
            $this->valF['code'] = $val['code'];
        }
        if ($val['code_insee'] == "") {
            $this->valF['code_insee'] = NULL;
        } else {
            $this->valF['code_insee'] = $val['code_insee'];
        }
        if ($val['section'] == "") {
            $this->valF['section'] = NULL;
        } else {
            $this->valF['section'] = $val['section'];
        }
        if ($val['dnupla'] == "") {
            $this->valF['dnupla'] = NULL;
        } else {
            $this->valF['dnupla'] = $val['dnupla'];
        }
        if ($val['geom'] == "") {
            unset($this->valF['geom']);
        } else {
            $this->valF['geom'] = $val['geom'];
        }
    }

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

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

        // MODE AJOUTER
        if ($maj == 0) {
            $form->setType("parcelle", "hidden");
            $form->setType("code", "text");
            $form->setType("code_insee", "text");
            $form->setType("section", "text");
            $form->setType("dnupla", "text");
            $form->setType("geom", "geom");
        }

        // MDOE MODIFIER
        if ($maj == 1) {
            $form->setType("parcelle", "hiddenstatic");
            $form->setType("code", "text");
            $form->setType("code_insee", "text");
            $form->setType("section", "text");
            $form->setType("dnupla", "text");
            $form->setType("geom", "geom");
        }

        // MODE SUPPRIMER
        if ($maj == 2) {
            $form->setType("parcelle", "hiddenstatic");
            $form->setType("code", "hiddenstatic");
            $form->setType("code_insee", "hiddenstatic");
            $form->setType("section", "hiddenstatic");
            $form->setType("dnupla", "hiddenstatic");
            $form->setType("geom", "geom");
        }

        // MODE CONSULTER
        if ($maj == 3) {
            $form->setType("parcelle", "static");
            $form->setType("code", "static");
            $form->setType("code_insee", "static");
            $form->setType("section", "static");
            $form->setType("dnupla", "static");
            $form->setType("geom", "geom");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('parcelle','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("parcelle", 20);
        $form->setTaille("code", 10);
        $form->setTaille("code_insee", 10);
        $form->setTaille("section", 10);
        $form->setTaille("dnupla", 10);
        $form->setTaille("geom", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("parcelle", 20);
        $form->setMax("code", 6);
        $form->setMax("code_insee", 5);
        $form->setMax("section", 2);
        $form->setMax("dnupla", 4);
        $form->setMax("geom", 551444);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('parcelle',_('parcelle'));
        $form->setLib('code',_('code'));
        $form->setLib('code_insee',_('code_insee'));
        $form->setLib('section',_('section'));
        $form->setLib('dnupla',_('dnupla'));
        $form->setLib('geom',_('geom'));
    }
    /**
     *
     */
    function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {

        // Inclusion du fichier de requêtes
        if (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) {
            include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php";
        } elseif (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) {
            include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc";
        }

        // geom
        if ($maj == 1 || $maj == 3) {
            $contenu = array();
            $contenu[0] = array("parcelle", $this->getParameter("idx"), "0");
            $form->setSelect("geom", $contenu);
        }
    }


    //==================================
    // sous Formulaire 
    //==================================
    

    function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) {
        $this->retourformulaire = $retourformulaire;
        $this->set_form_default_values($form, $maj, $validation);
    }// fin setValsousformulaire

    //==================================
    // cle secondaire 
    //==================================
    

}

?>
