<?php
//$Id: om_dashboard.class.php 2497 2013-09-20 14:23:32Z fmichon $ 
//gen openMairie le 20/08/2013 16:00

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

class om_dashboard_gen extends om_dbform {
    var $table="om_dashboard";
    var $clePrimaire="om_dashboard";
    var $typeCle="N";
    var $required_field=array(
        "bloc",
        "om_dashboard",
        "om_profil",
        "om_widget"
    );
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['om_dashboard'])) {
            $this->valF['om_dashboard'] = ""; // -> requis
        } else {
            $this->valF['om_dashboard'] = $val['om_dashboard'];
        }
        if (!is_numeric($val['om_profil'])) {
            $this->valF['om_profil'] = ""; // -> requis
        } else {
            $this->valF['om_profil'] = $val['om_profil'];
        }
        $this->valF['bloc'] = $val['bloc'];
        if (!is_numeric($val['position'])) {
            $this->valF['position'] = NULL;
        } else {
            $this->valF['position'] = $val['position'];
        }
        if (!is_numeric($val['om_widget'])) {
            $this->valF['om_widget'] = ""; // -> requis
        } else {
            $this->valF['om_widget'] = $val['om_widget'];
        }
    }

    //=================================================
    //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('om_dashboard','hidden');// cle automatique

            if($this->retourformulaire=='om_profil'
               and $form->val['om_profil'] == $this->getParameter('idxformulaire')) {
                $form->setType('om_profil','selecthiddenstatic');
            } else {
                $form->setType('om_profil','select');
            }
            $form->setType('bloc','text');
            $form->setType('position','text');

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

            if($this->retourformulaire=='om_profil'
               and $form->val['om_profil'] == $this->getParameter('idxformulaire')) {
                $form->setType('om_profil','selecthiddenstatic');
            } else {
                $form->setType('om_profil','select');
            }
            $form->setType('bloc','text');
            $form->setType('position','text');

            if($this->retourformulaire=='om_widget'
               and $form->val['om_widget'] == $this->getParameter('idxformulaire')) {
                $form->setType('om_widget','selecthiddenstatic');
            } else {
                $form->setType('om_widget','select');
            }
        }// fin modifier
        if ($maj==2){ //supprimer
            $form->setType('om_dashboard','hiddenstatic');
            $form->setType('om_profil','selectstatic');
            $form->setType('bloc','hiddenstatic');
            $form->setType('position','hiddenstatic');
            $form->setType('om_widget','selectstatic');
        }//fin supprimer
        if ($maj==3){ //consulter
            $form->setType('om_dashboard','static');
            $form->setType('om_profil','selectstatic');
            $form->setType('bloc','static');
            $form->setType('position','static');
            $form->setType('om_widget','selectstatic');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('om_dashboard','VerifNum(this)');
        $form->setOnchange('om_profil','VerifNum(this)');
        $form->setOnchange('position','VerifNum(this)');
        $form->setOnchange('om_widget','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("om_dashboard", 11);
        $form->setTaille("om_profil", 11);
        $form->setTaille("bloc", 10);
        $form->setTaille("position", 11);
        $form->setTaille("om_widget", 11);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("om_dashboard", 11);
        $form->setMax("om_profil", 11);
        $form->setMax("bloc", 10);
        $form->setMax("position", 11);
        $form->setMax("om_widget", 11);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('om_dashboard',_('om_dashboard'));
        $form->setLib('om_profil',_('om_profil'));
        $form->setLib('bloc',_('bloc'));
        $form->setLib('position',_('position'));
        $form->setLib('om_widget',_('om_widget'));
    }

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

        // om_profil
        $this->init_select($form, $db, $maj, $debug, "om_profil",
                           $sql_om_profil, $sql_om_profil_by_id, false);

        // om_widget
        $this->init_select($form, $db, $maj, $debug, "om_widget",
                           $sql_om_widget, $sql_om_widget_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 =='om_profil')
                $form->setVal('om_profil', $idxformulaire);
            if($retourformulaire =='om_widget')
                $form->setVal('om_widget', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>