<?php
//$Id$ 
//gen openMairie le 20/09/2013 15:51

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

class operation_defunt_gen extends om_dbform {
    var $table="operation_defunt";
    var $clePrimaire="operation_defunt";
    var $typeCle="N";
    var $required_field=array(
        "operation_defunt"
    );
    var $retourformulaire;

    function setvalF($val) {
        //affectation valeur formulaire
        if (!is_numeric($val['operation_defunt'])) {
            $this->valF['operation_defunt'] = ""; // -> requis
        } else {
            $this->valF['operation_defunt'] = $val['operation_defunt'];
        }
        if (!is_numeric($val['operation'])) {
            $this->valF['operation'] = NULL;
        } else {
            $this->valF['operation'] = $val['operation'];
        }
        if (!is_numeric($val['defunt'])) {
            $this->valF['defunt'] = NULL;
        } else {
            $this->valF['defunt'] = $val['defunt'];
        }
        if (!is_numeric($val['defunt_titre'])) {
            $this->valF['defunt_titre'] = NULL;
        } else {
            $this->valF['defunt_titre'] = $val['defunt_titre'];
        }
        if ($val['defunt_nom'] == "") {
            $this->valF['defunt_nom'] = NULL;
        } else {
            $this->valF['defunt_nom'] = $val['defunt_nom'];
        }
        if ($val['defunt_marital'] == "") {
            $this->valF['defunt_marital'] = NULL;
        } else {
            $this->valF['defunt_marital'] = $val['defunt_marital'];
        }
        if ($val['defunt_prenom'] == "") {
            $this->valF['defunt_prenom'] = NULL;
        } else {
            $this->valF['defunt_prenom'] = $val['defunt_prenom'];
        }
        if ($val['defunt_datenaissance'] != "") {
            $this->valF['defunt_datenaissance'] = $this->dateDB($val['defunt_datenaissance']);
        } else {
            $this->valF['defunt_datenaissance'] = NULL;
        }
        if ($val['defunt_datedeces'] != "") {
            $this->valF['defunt_datedeces'] = $this->dateDB($val['defunt_datedeces']);
        } else {
            $this->valF['defunt_datedeces'] = NULL;
        }
        if ($val['defunt_lieudeces'] == "") {
            $this->valF['defunt_lieudeces'] = NULL;
        } else {
            $this->valF['defunt_lieudeces'] = $val['defunt_lieudeces'];
        }
        if ($val['defunt_nature'] == "") {
            $this->valF['defunt_nature'] = NULL;
        } else {
            $this->valF['defunt_nature'] = $val['defunt_nature'];
        }
    }

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

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

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

            if($this->retourformulaire=='titre_de_civilite'
               and $form->val['defunt_titre'] == $this->getParameter('idxformulaire')) {
                $form->setType('defunt_titre','selecthiddenstatic');
            } else {
                $form->setType('defunt_titre','select');
            }
            $form->setType('defunt_nom','text');
            $form->setType('defunt_marital','text');
            $form->setType('defunt_prenom','text');
            if($this->retourformulaire=='')
                $form->setType('defunt_datenaissance','date');
            else
                $form->setType('defunt_datenaissance','date2');
            if($this->retourformulaire=='')
                $form->setType('defunt_datedeces','date');
            else
                $form->setType('defunt_datedeces','date2');
            $form->setType('defunt_lieudeces','text');
            $form->setType('defunt_nature','text');
        }// fin ajout
        if ($maj==1){ //modifier
            $form->setType('operation_defunt','hiddenstatic');

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

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

            if($this->retourformulaire=='titre_de_civilite'
               and $form->val['defunt_titre'] == $this->getParameter('idxformulaire')) {
                $form->setType('defunt_titre','selecthiddenstatic');
            } else {
                $form->setType('defunt_titre','select');
            }
            $form->setType('defunt_nom','text');
            $form->setType('defunt_marital','text');
            $form->setType('defunt_prenom','text');
            if($this->retourformulaire=='')
                $form->setType('defunt_datenaissance','date');
            else
                $form->setType('defunt_datenaissance','date2');
            if($this->retourformulaire=='')
                $form->setType('defunt_datedeces','date');
            else
                $form->setType('defunt_datedeces','date2');
            $form->setType('defunt_lieudeces','text');
            $form->setType('defunt_nature','text');
        }// fin modifier
        if ($maj==2){ //supprimer
            $form->setType('operation_defunt','hiddenstatic');
            $form->setType('operation','selectstatic');
            $form->setType('defunt','selectstatic');
            $form->setType('defunt_titre','selectstatic');
            $form->setType('defunt_nom','hiddenstatic');
            $form->setType('defunt_marital','hiddenstatic');
            $form->setType('defunt_prenom','hiddenstatic');
            $form->setType('defunt_datenaissance','hiddenstatic');
            $form->setType('defunt_datedeces','hiddenstatic');
            $form->setType('defunt_lieudeces','hiddenstatic');
            $form->setType('defunt_nature','hiddenstatic');
        }//fin supprimer
        if ($maj==3){ //consulter
            $form->setType('operation_defunt','static');
            $form->setType('operation','selectstatic');
            $form->setType('defunt','selectstatic');
            $form->setType('defunt_titre','selectstatic');
            $form->setType('defunt_nom','static');
            $form->setType('defunt_marital','static');
            $form->setType('defunt_prenom','static');
            $form->setType('defunt_datenaissance','datestatic');
            $form->setType('defunt_datedeces','datestatic');
            $form->setType('defunt_lieudeces','static');
            $form->setType('defunt_nature','static');
        }//fin consulter
    }

    function setOnchange(&$form,$maj) {
    //javascript controle client
        $form->setOnchange('operation_defunt','VerifNum(this)');
        $form->setOnchange('operation','VerifNum(this)');
        $form->setOnchange('defunt','VerifNum(this)');
        $form->setOnchange('defunt_titre','VerifNum(this)');
        $form->setOnchange('defunt_datenaissance','fdate(this)');
        $form->setOnchange('defunt_datedeces','fdate(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("operation_defunt", 11);
        $form->setTaille("operation", 11);
        $form->setTaille("defunt", 11);
        $form->setTaille("defunt_titre", 11);
        $form->setTaille("defunt_nom", 30);
        $form->setTaille("defunt_marital", 30);
        $form->setTaille("defunt_prenom", 30);
        $form->setTaille("defunt_datenaissance", 12);
        $form->setTaille("defunt_datedeces", 12);
        $form->setTaille("defunt_lieudeces", 30);
        $form->setTaille("defunt_nature", 15);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("operation_defunt", 11);
        $form->setMax("operation", 11);
        $form->setMax("defunt", 11);
        $form->setMax("defunt_titre", 11);
        $form->setMax("defunt_nom", 40);
        $form->setMax("defunt_marital", 40);
        $form->setMax("defunt_prenom", 40);
        $form->setMax("defunt_datenaissance", 12);
        $form->setMax("defunt_datedeces", 12);
        $form->setMax("defunt_lieudeces", 40);
        $form->setMax("defunt_nature", 15);
    }


    function setLib(&$form,$maj) {
    //libelle des champs
        $form->setLib('operation_defunt',_('operation_defunt'));
        $form->setLib('operation',_('operation'));
        $form->setLib('defunt',_('defunt'));
        $form->setLib('defunt_titre',_('defunt_titre'));
        $form->setLib('defunt_nom',_('defunt_nom'));
        $form->setLib('defunt_marital',_('defunt_marital'));
        $form->setLib('defunt_prenom',_('defunt_prenom'));
        $form->setLib('defunt_datenaissance',_('defunt_datenaissance'));
        $form->setLib('defunt_datedeces',_('defunt_datedeces'));
        $form->setLib('defunt_lieudeces',_('defunt_lieudeces'));
        $form->setLib('defunt_nature',_('defunt_nature'));
    }

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

        // defunt
        $this->init_select($form, $db, $maj, $debug, "defunt",
                           $sql_defunt, $sql_defunt_by_id, false);

        // defunt_titre
        $this->init_select($form, $db, $maj, $debug, "defunt_titre",
                           $sql_defunt_titre, $sql_defunt_titre_by_id, true);

        // operation
        $this->init_select($form, $db, $maj, $debug, "operation",
                           $sql_operation, $sql_operation_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 =='defunt')
                $form->setVal('defunt', $idxformulaire);
            if($retourformulaire =='titre_de_civilite')
                $form->setVal('defunt_titre', $idxformulaire);
            if($retourformulaire =='operation')
                $form->setVal('operation', $idxformulaire);
        }// fin validation
    }// fin setValsousformulaire

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

}// fin classe
?>