<?php
//$Id$ 
//gen openMairie le 26/09/2012 17:38

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

class blocnote_gen extends om_dbform {
    var $table="blocnote";
    var $clePrimaire="blocnote";
    var $typeCle="N";
    var $required_field=array(
        "blocnote",
        "categorie",
        "note"
    );
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['blocnote'])) {
            $this->valF['blocnote'] = ""; // -> requis
        } else {
            $this->valF['blocnote'] = $val['blocnote'];
        }
        $this->valF['categorie'] = $val['categorie'];
            $this->valF['note'] = $val['note'];
        if ($val['dossier'] == "") {
            $this->valF['dossier'] = NULL;
        } else {
            $this->valF['dossier'] = $val['dossier'];
        }
    }

    //=================================================
    //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('blocnote','hidden');// cle automatique
            $form->setType('categorie','text');
            $form->setType('note','textarea');

            if($this->retourformulaire=='dossier'
               and $form->val['dossier'] == $this->getParameter('idxformulaire')) {
                $form->setType('dossier','selecthiddenstatic');
            } else {
                $form->setType('dossier','select');
            }
        }// fin ajout
        if ($maj==1){ //modifier
            $form->setType('blocnote','hiddenstatic');
            $form->setType('categorie','text');
            $form->setType('note','textarea');

            if($this->retourformulaire=='dossier'
               and $form->val['dossier'] == $this->getParameter('idxformulaire')) {
                $form->setType('dossier','selecthiddenstatic');
            } else {
                $form->setType('dossier','select');
            }
        }// fin modifier
        if ($maj==2){ //supprimer
            $form->setType('blocnote','hiddenstatic');
            $form->setType('categorie','hiddenstatic');
            $form->setType('note','hiddenstatic');
            $form->setType('dossier','selectstatic');
        }//fin supprimer
        if ($maj==3){ //consulter
            $form->setType('blocnote','static');
            $form->setType('categorie','static');
            $form->setType('note','textareastatic');
            $form->setType('dossier','selectstatic');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('blocnote','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("blocnote", 11);
        $form->setTaille("categorie", 20);
        $form->setTaille("note", 80);
        $form->setTaille("dossier", 12);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("blocnote", 11);
        $form->setMax("categorie", 20);
        $form->setMax("note", 6);
        $form->setMax("dossier", 12);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('blocnote',_('blocnote'));
        $form->setLib('categorie',_('categorie'));
        $form->setLib('note',_('note'));
        $form->setLib('dossier',_('dossier'));
    }

    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");

        // dossier
        $this->init_select($form, $db, $maj, $debug, "dossier",
                           $sql_dossier, $sql_dossier_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 =='dossier')
                $form->setVal('dossier', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>