<?php
//$Id: om_logo.class.php 2381 2013-06-11 10:37:35Z fmichon $ 
//gen openMairie le 08/03/2013 20:41

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

class om_logo_gen extends om_dbform {
    var $table="om_logo";
    var $clePrimaire="om_logo";
    var $typeCle="N";
    var $required_field=array(
        "fichier",
        "id",
        "libelle",
        "om_collectivite",
        "om_logo"
    );
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['om_logo'])) {
            $this->valF['om_logo'] = ""; // -> requis
        } else {
            $this->valF['om_logo'] = $val['om_logo'];
        }
        $this->valF['id'] = $val['id'];
        $this->valF['libelle'] = $val['libelle'];
        if ($val['description'] == "") {
            $this->valF['description'] = NULL;
        } else {
            $this->valF['description'] = $val['description'];
        }
        $this->valF['fichier'] = $val['fichier'];
        if (!is_numeric($val['resolution'])) {
            $this->valF['resolution'] = NULL;
        } else {
            $this->valF['resolution'] = $val['resolution'];
        }
        if ($val['actif'] == 1 || $val['actif'] == "t" || $val['actif'] == "Oui") {
            $this->valF['actif'] = true;
        } else {
            $this->valF['actif'] = false;
        }
        if (!is_numeric($val['om_collectivite'])) {
            $this->valF['om_collectivite'] = ""; // -> requis
        } else {
            if($_SESSION['niveau']==1) {
                $this->valF['om_collectivite'] = $_SESSION['collectivite'];
            } else {
                $this->valF['om_collectivite'] = $val['om_collectivite'];
            }
        }
    }

    //=================================================
    //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_logo','hidden');// cle automatique
            $form->setType('id','text');
            $form->setType('libelle','text');
            $form->setType('description','text');
            $form->setType('fichier','text');
            $form->setType('resolution','text');
            $form->setType('actif','checkbox');
            if($this->retourformulaire=='om_collectivite')
                if($_SESSION['niveau']==2) {
                    $form->setType('om_collectivite','selecthiddenstatic');
                } else {
                    $form->setType('om_collectivite','hidden');
                }
            else
                if($_SESSION['niveau']==2)
                    $form->setType('om_collectivite','select');
                else
                    $form->setType('om_collectivite','hidden');
        }// fin ajout
        if ($maj==1){ //modifier
            $form->setType('om_logo','hiddenstatic');
            $form->setType('id','text');
            $form->setType('libelle','text');
            $form->setType('description','text');
            $form->setType('fichier','text');
            $form->setType('resolution','text');
            $form->setType('actif','checkbox');
            if($this->retourformulaire=='om_collectivite')
                if($_SESSION['niveau']==2) {
                    $form->setType('om_collectivite','selecthiddenstatic');
                } else {
                    $form->setType('om_collectivite','hidden');
                }
            else
                if($_SESSION['niveau']==2)
                    $form->setType('om_collectivite','select');
                else
                    $form->setType('om_collectivite','hidden');
        }// fin modifier
        if ($maj==2){ //supprimer
            $form->setType('om_logo','hiddenstatic');
            $form->setType('id','hiddenstatic');
            $form->setType('libelle','hiddenstatic');
            $form->setType('description','hiddenstatic');
            $form->setType('fichier','hiddenstatic');
            $form->setType('resolution','hiddenstatic');
            $form->setType('actif','hiddenstatic');
            if($_SESSION['niveau']==2) {
                $form->setType('om_collectivite','selectstatic');
            } else {
                $form->setType('om_collectivite','hidden');
            }
        }//fin supprimer
        if ($maj==3){ //consulter
            $form->setType('om_logo','static');
            $form->setType('id','static');
            $form->setType('libelle','static');
            $form->setType('description','static');
            $form->setType('fichier','static');
            $form->setType('resolution','static');
            $form->setType('actif','checkboxstatic');
            if($this->retourformulaire=='om_collectivite')
                if($_SESSION['niveau']==2) {
                    $form->setType('om_collectivite','selectstatic');
                } else {
                    $form->setType('om_collectivite','hidden');
                }
            else
                if($_SESSION['niveau']==2)
                    $form->setType('om_collectivite','selectstatic');
                else
                    $form->setType('om_collectivite','hidden');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('om_logo','VerifNum(this)');
        $form->setOnchange('resolution','VerifNum(this)');
        $form->setOnchange('om_collectivite','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("om_logo", 11);
        $form->setTaille("id", 30);
        $form->setTaille("libelle", 30);
        $form->setTaille("description", 30);
        $form->setTaille("fichier", 30);
        $form->setTaille("resolution", 11);
        $form->setTaille("actif", 1);
        $form->setTaille("om_collectivite", 11);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("om_logo", 11);
        $form->setMax("id", 50);
        $form->setMax("libelle", 100);
        $form->setMax("description", 200);
        $form->setMax("fichier", 100);
        $form->setMax("resolution", 11);
        $form->setMax("actif", 1);
        $form->setMax("om_collectivite", 11);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('om_logo',_('om_logo'));
        $form->setLib('id',_('id'));
        $form->setLib('libelle',_('libelle'));
        $form->setLib('description',_('description'));
        $form->setLib('fichier',_('fichier'));
        $form->setLib('resolution',_('resolution'));
        $form->setLib('actif',_('actif'));
        $form->setLib('om_collectivite',_('om_collectivite'));
    }

    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_collectivite
        $this->init_select($form, $db, $maj, $debug, "om_collectivite",
                           $sql_om_collectivite, $sql_om_collectivite_by_id, false);
    }// fin select

    function setVal(&$form,$maj,$validation,&$db,$DEBUG=null){
        if($validation==0 and $maj==0 and $_SESSION['niveau']==1) {
            $form->setVal('om_collectivite', $_SESSION['collectivite']);
        }// fin validation
    }// fin setVal

    //==================================
    // sous Formulaire  [subform]
    //==================================

    function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
        $this->retourformulaire = $retourformulaire;
        if($validation==0 and $maj==0 and $_SESSION['niveau']==1) {
            $form->setVal('om_collectivite', $_SESSION['collectivite']);
        }// fin validation
        if($validation == 0) {
            if($retourformulaire =='om_collectivite')
                $form->setVal('om_collectivite', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>