<?php
//$Id$ 
//gen openMairie le 10/04/2015 16:50

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

class rivoli_gen extends om_dbform {

    var $table = "rivoli";
    var $clePrimaire = "rivoli";
    var $typeCle = "A";
    var $required_field = array(
        "rivoli"
    );
    
    var $foreign_keys_extended = array(
    );



    function setvalF($val) {
        //affectation valeur formulaire
        $this->valF['rivoli'] = $val['rivoli'];
        if ($val['libelle'] == "") {
            $this->valF['libelle'] = NULL;
        } else {
            $this->valF['libelle'] = $val['libelle'];
        }
        if (!is_numeric($val['voie'])) {
            $this->valF['voie'] = NULL;
        } else {
            $this->valF['voie'] = $val['voie'];
        }
    }

    //==========================
    // Formulaire  [form]
    //==========================
    /**
     *
     */
    function setType(&$form, $maj) {

        // MODE AJOUTER
        if ($maj == 0) {
            $form->setType("rivoli", "text");
            $form->setType("libelle", "text");
            $form->setType("voie", "text");
        }

        // MDOE MODIFIER
        if ($maj == 1) {
            $form->setType("rivoli", "hiddenstatic");
            $form->setType("libelle", "text");
            $form->setType("voie", "text");
        }

        // MODE SUPPRIMER
        if ($maj == 2) {
            $form->setType("rivoli", "hiddenstatic");
            $form->setType("libelle", "hiddenstatic");
            $form->setType("voie", "hiddenstatic");
        }

        // MODE CONSULTER
        if ($maj == 3) {
            $form->setType("rivoli", "static");
            $form->setType("libelle", "static");
            $form->setType("voie", "static");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('voie','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("rivoli", 10);
        $form->setTaille("libelle", 10);
        $form->setTaille("voie", 11);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("rivoli", 4);
        $form->setMax("libelle", -5);
        $form->setMax("voie", 11);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('rivoli',_('rivoli'));
        $form->setLib('libelle',_('libelle'));
        $form->setLib('voie',_('voie'));
    }
    /**
     *
     */
    function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {

        // Inclusion du fichier de requêtes
        if (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) {
            include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php";
        } elseif (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) {
            include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc";
        }

    }


    //==================================
    // 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 
    //==================================
    
    /**
     * Methode clesecondaire
     */
    function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) {
        // On appelle la methode de la classe parent
        parent::cleSecondaire($id);
        // Verification de la cle secondaire : adresse_postale
        $this->rechercheTable($this->f->db, "adresse_postale", "rivoli", $id);
        // Verification de la cle secondaire : troncon
        $this->rechercheTable($this->f->db, "troncon", "rivoli", $id);
    }


}

?>
