<?php
//$Id$ 
//gen openMairie le 31/10/2025 17:23

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

class habillage_gen extends om_dbform {

    protected $_absolute_class_name = "habillage";

    var $table = "habillage";
    var $clePrimaire = "habillage";
    var $typeCle = "N";
    var $required_field = array(
        "habillage"
    );
    
    var $foreign_keys_extended = array(
    );
    
    /**
     *
     * @return string
     */
    function get_default_libelle() {
        return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("habillagelib");
    }

    /**
     *
     * @return array
     */
    function get_var_sql_forminc__champs() {
        return array(
            "habillage",
            "habillagelib",
            "geom",
            "pgeom",
            "type_obj",
        );
    }




    function setvalF($val = array()) {
        //affectation valeur formulaire
        if (!is_numeric($val['habillage'])) {
            $this->valF['habillage'] = ""; // -> requis
        } else {
            $this->valF['habillage'] = $val['habillage'];
        }
        if ($val['habillagelib'] == "") {
            $this->valF['habillagelib'] = NULL;
        } else {
            $this->valF['habillagelib'] = $val['habillagelib'];
        }
        if ($val['geom'] == "") {
            unset($this->valF['geom']);
        } else {
            $this->valF['geom'] = $val['geom'];
        }
        if ($val['pgeom'] == "") {
            unset($this->valF['pgeom']);
        } else {
            $this->valF['pgeom'] = $val['pgeom'];
        }
        if ($val['type_obj'] == "") {
            $this->valF['type_obj'] = NULL;
        } else {
            $this->valF['type_obj'] = $val['type_obj'];
        }
    }

    //=================================================
    //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 = array()) {
    //numero automatique -> pas de controle ajout cle primaire
    }

    function verifierAjout($val = array(), &$dnu1 = null) {
    //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("habillage", "hidden");
            $form->setType("habillagelib", "text");
            $form->setType("geom", "geom");
            $form->setType("pgeom", "geom");
            $form->setType("type_obj", "text");
        }

        // MDOE MODIFIER
        if ($maj == 1 || $crud == 'update') {
            $form->setType("habillage", "hiddenstatic");
            $form->setType("habillagelib", "text");
            $form->setType("geom", "geom");
            $form->setType("pgeom", "geom");
            $form->setType("type_obj", "text");
        }

        // MODE SUPPRIMER
        if ($maj == 2 || $crud == 'delete') {
            $form->setType("habillage", "hiddenstatic");
            $form->setType("habillagelib", "hiddenstatic");
            $form->setType("geom", "geom");
            $form->setType("pgeom", "geom");
            $form->setType("type_obj", "hiddenstatic");
        }

        // MODE CONSULTER
        if ($maj == 3 || $crud == 'read') {
            $form->setType("habillage", "static");
            $form->setType("habillagelib", "static");
            $form->setType("geom", "geom");
            $form->setType("pgeom", "geom");
            $form->setType("type_obj", "static");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('habillage','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("habillage", 11);
        $form->setTaille("habillagelib", 30);
        $form->setTaille("geom", 30);
        $form->setTaille("pgeom", 30);
        $form->setTaille("type_obj", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("habillage", 11);
        $form->setMax("habillagelib", 255);
        $form->setMax("geom", 551428);
        $form->setMax("pgeom", 551444);
        $form->setMax("type_obj", 255);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('habillage', __('habillage'));
        $form->setLib('habillagelib', __('habillagelib'));
        $form->setLib('geom', __('geom'));
        $form->setLib('pgeom', __('pgeom'));
        $form->setLib('type_obj', __('type_obj'));
    }
    /**
     *
     */
    function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {

        // geom
        if ($maj == 1 || $maj == 3) {
            $contenu = array();
            $contenu[0] = array("habillage", $this->getParameter("idx"), "0");
            $form->setSelect("geom", $contenu);
        }
        // pgeom
        if ($maj == 1 || $maj == 3) {
            $contenu = array();
            $contenu[0] = array("habillage", $this->getParameter("idx"), "1");
            $form->setSelect("pgeom", $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
    //==================================
    

}
