<?php
//$Id$ 
//gen openMairie le 05/10/2012 13:55

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

class destination_shon_gen extends om_dbform {
    var $table="destination_shon";
    var $clePrimaire="destination_shon";
    var $typeCle="N";
    var $required_field=array(
        "destination",
        "destination_shon"
    );
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['destination_shon'])) {
            $this->valF['destination_shon'] = ""; // -> requis
        } else {
            $this->valF['destination_shon'] = $val['destination_shon'];
        }
        $this->valF['destination'] = $val['destination'];
        if (!is_numeric($val['shon'])) {
            $this->valF['shon'] = NULL;
        } else {
            $this->valF['shon'] = $val['shon'];
        }
        if (!is_numeric($val['shon_anterieure'])) {
            $this->valF['shon_anterieure'] = NULL;
        } else {
            $this->valF['shon_anterieure'] = $val['shon_anterieure'];
        }
        if (!is_numeric($val['shon_demolie'])) {
            $this->valF['shon_demolie'] = NULL;
        } else {
            $this->valF['shon_demolie'] = $val['shon_demolie'];
        }
        if (!is_numeric($val['shon_anterieure_supprimee'])) {
            $this->valF['shon_anterieure_supprimee'] = NULL;
        } else {
            $this->valF['shon_anterieure_supprimee'] = $val['shon_anterieure_supprimee'];
        }
        if (!is_numeric($val['shon_nouvelle_transformee'])) {
            $this->valF['shon_nouvelle_transformee'] = NULL;
        } else {
            $this->valF['shon_nouvelle_transformee'] = $val['shon_nouvelle_transformee'];
        }
        if (!is_numeric($val['shon_nouvelle'])) {
            $this->valF['shon_nouvelle'] = NULL;
        } else {
            $this->valF['shon_nouvelle'] = $val['shon_nouvelle'];
        }
        if (!is_numeric($val['shon_shob_transformee'])) {
            $this->valF['shon_shob_transformee'] = NULL;
        } else {
            $this->valF['shon_shob_transformee'] = $val['shon_shob_transformee'];
        }
        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('destination_shon','hidden');// cle automatique

            if($this->retourformulaire=='destination'
               and $form->val['destination'] == $this->getParameter('idxformulaire')) {
                $form->setType('destination','selecthiddenstatic');
            } else {
                $form->setType('destination','select');
            }
            $form->setType('shon','text');
            $form->setType('shon_anterieure','text');
            $form->setType('shon_demolie','text');
            $form->setType('shon_anterieure_supprimee','text');
            $form->setType('shon_nouvelle_transformee','text');
            $form->setType('shon_nouvelle','text');
            $form->setType('shon_shob_transformee','text');

            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('destination_shon','hiddenstatic');

            if($this->retourformulaire=='destination'
               and $form->val['destination'] == $this->getParameter('idxformulaire')) {
                $form->setType('destination','selecthiddenstatic');
            } else {
                $form->setType('destination','select');
            }
            $form->setType('shon','text');
            $form->setType('shon_anterieure','text');
            $form->setType('shon_demolie','text');
            $form->setType('shon_anterieure_supprimee','text');
            $form->setType('shon_nouvelle_transformee','text');
            $form->setType('shon_nouvelle','text');
            $form->setType('shon_shob_transformee','text');

            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('destination_shon','hiddenstatic');
            $form->setType('destination','selectstatic');
            $form->setType('shon','hiddenstatic');
            $form->setType('shon_anterieure','hiddenstatic');
            $form->setType('shon_demolie','hiddenstatic');
            $form->setType('shon_anterieure_supprimee','hiddenstatic');
            $form->setType('shon_nouvelle_transformee','hiddenstatic');
            $form->setType('shon_nouvelle','hiddenstatic');
            $form->setType('shon_shob_transformee','hiddenstatic');
            $form->setType('dossier','selectstatic');
        }//fin supprimer
        if ($maj==3){ //consulter
            $form->setType('destination_shon','static');
            $form->setType('destination','selectstatic');
            $form->setType('shon','static');
            $form->setType('shon_anterieure','static');
            $form->setType('shon_demolie','static');
            $form->setType('shon_anterieure_supprimee','static');
            $form->setType('shon_nouvelle_transformee','static');
            $form->setType('shon_nouvelle','static');
            $form->setType('shon_shob_transformee','static');
            $form->setType('dossier','selectstatic');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('destination_shon','VerifNum(this)');
        $form->setOnchange('shon','VerifNum(this)');
        $form->setOnchange('shon_anterieure','VerifNum(this)');
        $form->setOnchange('shon_demolie','VerifNum(this)');
        $form->setOnchange('shon_anterieure_supprimee','VerifNum(this)');
        $form->setOnchange('shon_nouvelle_transformee','VerifNum(this)');
        $form->setOnchange('shon_nouvelle','VerifNum(this)');
        $form->setOnchange('shon_shob_transformee','VerifNum(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("destination_shon", 11);
        $form->setTaille("destination", 10);
        $form->setTaille("shon", 20);
        $form->setTaille("shon_anterieure", 20);
        $form->setTaille("shon_demolie", 20);
        $form->setTaille("shon_anterieure_supprimee", 20);
        $form->setTaille("shon_nouvelle_transformee", 20);
        $form->setTaille("shon_nouvelle", 20);
        $form->setTaille("shon_shob_transformee", 20);
        $form->setTaille("dossier", 12);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("destination_shon", 11);
        $form->setMax("destination", 2);
        $form->setMax("shon", 20);
        $form->setMax("shon_anterieure", 20);
        $form->setMax("shon_demolie", 20);
        $form->setMax("shon_anterieure_supprimee", 20);
        $form->setMax("shon_nouvelle_transformee", 20);
        $form->setMax("shon_nouvelle", 20);
        $form->setMax("shon_shob_transformee", 20);
        $form->setMax("dossier", 12);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('destination_shon',_('destination_shon'));
        $form->setLib('destination',_('destination'));
        $form->setLib('shon',_('shon'));
        $form->setLib('shon_anterieure',_('shon_anterieure'));
        $form->setLib('shon_demolie',_('shon_demolie'));
        $form->setLib('shon_anterieure_supprimee',_('shon_anterieure_supprimee'));
        $form->setLib('shon_nouvelle_transformee',_('shon_nouvelle_transformee'));
        $form->setLib('shon_nouvelle',_('shon_nouvelle'));
        $form->setLib('shon_shob_transformee',_('shon_shob_transformee'));
        $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");

        // destination
        $this->init_select($form, $db, $maj, $debug, "destination",
                           $sql_destination, $sql_destination_by_id, false);

        // 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 =='destination')
                $form->setVal('destination', $idxformulaire);
            if($retourformulaire =='dossier')
                $form->setVal('dossier', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>