<?php
//$Id: servitude_surfacique.class.php 5616 2015-12-15 10:53:32Z nmeucci $ 
//gen openMairie le 15/12/2015 11:49

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

class servitude_surfacique_gen extends om_dbform {

    var $table = "servitude_surfacique";
    var $clePrimaire = "servitude_surfacique";
    var $typeCle = "N";
    var $required_field = array(
        "libelle",
        "servitude_surfacique"
    );
    
    var $foreign_keys_extended = array(
    );



    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['servitude_surfacique'])) {
            $this->valF['servitude_surfacique'] = ""; // -> requis
        } else {
            $this->valF['servitude_surfacique'] = $val['servitude_surfacique'];
        }
        $this->valF['libelle'] = $val['libelle'];
        if ($val['observation'] == "") {
            $this->valF['observation'] = NULL;
        } else {
            $this->valF['observation'] = $val['observation'];
        }
        if (!is_numeric($val['perimetre'])) {
            $this->valF['perimetre'] = NULL;
        } else {
            $this->valF['perimetre'] = $val['perimetre'];
        }
            $this->valF['description'] = $val['description'];
        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) {
        // Récupération du mode de l'action
        $crud = $this->get_action_crud($maj);

        // MODE AJOUTER
        if ($maj == 0 || $crud == 'create') {
            $form->setType("servitude_surfacique", "hidden");
            $form->setType("libelle", "text");
            $form->setType("observation", "text");
            $form->setType("perimetre", "text");
            $form->setType("description", "textarea");
            $form->setType("geom", "geom");
        }

        // MDOE MODIFIER
        if ($maj == 1 || $crud == 'update') {
            $form->setType("servitude_surfacique", "hiddenstatic");
            $form->setType("libelle", "text");
            $form->setType("observation", "text");
            $form->setType("perimetre", "text");
            $form->setType("description", "textarea");
            $form->setType("geom", "geom");
        }

        // MODE SUPPRIMER
        if ($maj == 2 || $crud == 'delete') {
            $form->setType("servitude_surfacique", "hiddenstatic");
            $form->setType("libelle", "hiddenstatic");
            $form->setType("observation", "hiddenstatic");
            $form->setType("perimetre", "hiddenstatic");
            $form->setType("description", "hiddenstatic");
            $form->setType("geom", "geom");
        }

        // MODE CONSULTER
        if ($maj == 3 || $crud == 'read') {
            $form->setType("servitude_surfacique", "static");
            $form->setType("libelle", "static");
            $form->setType("observation", "static");
            $form->setType("perimetre", "static");
            $form->setType("description", "textareastatic");
            $form->setType("geom", "geom");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('servitude_surfacique','VerifNum(this)');
        $form->setOnchange('perimetre','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("servitude_surfacique", 11);
        $form->setTaille("libelle", 20);
        $form->setTaille("observation", 30);
        $form->setTaille("perimetre", 11);
        $form->setTaille("description", 80);
        $form->setTaille("geom", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("servitude_surfacique", 11);
        $form->setMax("libelle", 20);
        $form->setMax("observation", 80);
        $form->setMax("perimetre", 11);
        $form->setMax("description", 6);
        $form->setMax("geom", 551432);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('servitude_surfacique',_('servitude_surfacique'));
        $form->setLib('libelle',_('libelle'));
        $form->setLib('observation',_('observation'));
        $form->setLib('perimetre',_('perimetre'));
        $form->setLib('description',_('description'));
        $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("servitude_surfacique", $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 
    //==================================
    

}

?>
