<?php
//$Id$ 
//gen openMairie le 25/04/2024 17:58

require_once PATH_OPENMAIRIE."om_dbform.class.php";

class om_vues_gen extends dbform {

    protected $_absolute_class_name = "om_vues";

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

    /**
     *
     * @return array
     */
    function get_var_sql_forminc__champs() {
        return array(
            "table_name",
            "table_schema",
            "view_definition",
        );
    }




    function setvalF($val = array()) {
        //affectation valeur formulaire
        $this->valF['table_name'] = $val['table_name'];
        if ($val['table_schema'] == "") {
            $this->valF['table_schema'] = NULL;
        } else {
            $this->valF['table_schema'] = $val['table_schema'];
        }
            $this->valF['view_definition'] = $val['view_definition'];
    }

    //==========================
    // 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("table_name", "text");
            $form->setType("table_schema", "text");
            $form->setType("view_definition", "textarea");
        }

        // MDOE MODIFIER
        if ($maj == 1 || $crud == 'update') {
            $form->setType("table_name", "hiddenstatic");
            $form->setType("table_schema", "text");
            $form->setType("view_definition", "textarea");
        }

        // MODE SUPPRIMER
        if ($maj == 2 || $crud == 'delete') {
            $form->setType("table_name", "hiddenstatic");
            $form->setType("table_schema", "hiddenstatic");
            $form->setType("view_definition", "hiddenstatic");
        }

        // MODE CONSULTER
        if ($maj == 3 || $crud == 'read') {
            $form->setType("table_name", "static");
            $form->setType("table_schema", "static");
            $form->setType("view_definition", "textareastatic");
        }

    }

    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("table_name", 30);
        $form->setTaille("table_schema", 30);
        $form->setTaille("view_definition", 80);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("table_name", 80);
        $form->setMax("table_schema", 80);
        $form->setMax("view_definition", 6);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('table_name', __('table_name'));
        $form->setLib('table_schema', __('table_schema'));
        $form->setLib('view_definition', __('view_definition'));
    }
    /**
     *
     */
    function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {

    }


    //==================================
    // 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
    //==================================
    

}
