<?php
//$Id$ 
//gen openMairie le 21/04/2016 14:25

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

class dossier_gen extends om_dbform {

    var $table = "dossier";
    var $clePrimaire = "dossier";
    var $typeCle = "A";
    var $required_field = array(
        "date_depot",
        "date_dernier_depot",
        "dossier",
        "dossier_autorisation",
        "dossier_instruction_type",
        "om_collectivite"
    );
    
    var $foreign_keys_extended = array(
        "autorite_competente" => array("autorite_competente", ),
        "avis_decision" => array("avis_decision", ),
        "division" => array("division", ),
        "dossier_autorisation" => array("dossier_autorisation", ),
        "dossier_instruction_type" => array("dossier_instruction_type", ),
        "etat" => array("etat", ),
        "evenement" => array("evenement", ),
        "instructeur" => array("instructeur", ),
        "om_collectivite" => array("om_collectivite", ),
        "parcelle" => array("parcelle", ),
        "parcelle_lot" => array("parcelle_lot", ),
        "pos" => array("pos", ),
        "quartier" => array("quartier", ),
    );



    function setvalF($val) {
        //affectation valeur formulaire
        $this->valF['dossier'] = $val['dossier'];
        if ($val['annee'] == "") {
            $this->valF['annee'] = ""; // -> default
        } else {
            $this->valF['annee'] = $val['annee'];
        }
        if ($val['etat'] == "") {
            $this->valF['etat'] = NULL;
        } else {
            $this->valF['etat'] = $val['etat'];
        }
        if (!is_numeric($val['instructeur'])) {
            $this->valF['instructeur'] = NULL;
        } else {
            $this->valF['instructeur'] = $val['instructeur'];
        }
        if ($val['date_demande'] != "") {
            $this->valF['date_demande'] = $this->dateDB($val['date_demande']);
        } else {
            $this->valF['date_demande'] = NULL;
        }
        if ($val['date_depot'] != "") {
            $this->valF['date_depot'] = $this->dateDB($val['date_depot']);
        }
        if ($val['date_complet'] != "") {
            $this->valF['date_complet'] = $this->dateDB($val['date_complet']);
        } else {
            $this->valF['date_complet'] = NULL;
        }
        if ($val['date_rejet'] != "") {
            $this->valF['date_rejet'] = $this->dateDB($val['date_rejet']);
        } else {
            $this->valF['date_rejet'] = NULL;
        }
        if ($val['date_notification_delai'] != "") {
            $this->valF['date_notification_delai'] = $this->dateDB($val['date_notification_delai']);
        } else {
            $this->valF['date_notification_delai'] = NULL;
        }
        if (!is_numeric($val['delai'])) {
            $this->valF['delai'] = 0; // -> default
        } else {
            $this->valF['delai'] = $val['delai'];
        }
        if ($val['date_limite'] != "") {
            $this->valF['date_limite'] = $this->dateDB($val['date_limite']);
        } else {
            $this->valF['date_limite'] = NULL;
        }
        if ($val['accord_tacite'] == "") {
            $this->valF['accord_tacite'] = ""; // -> default
        } else {
            $this->valF['accord_tacite'] = $val['accord_tacite'];
        }
        if ($val['date_decision'] != "") {
            $this->valF['date_decision'] = $this->dateDB($val['date_decision']);
        } else {
            $this->valF['date_decision'] = NULL;
        }
        if ($val['date_validite'] != "") {
            $this->valF['date_validite'] = $this->dateDB($val['date_validite']);
        } else {
            $this->valF['date_validite'] = NULL;
        }
        if ($val['date_chantier'] != "") {
            $this->valF['date_chantier'] = $this->dateDB($val['date_chantier']);
        } else {
            $this->valF['date_chantier'] = NULL;
        }
        if ($val['date_achevement'] != "") {
            $this->valF['date_achevement'] = $this->dateDB($val['date_achevement']);
        } else {
            $this->valF['date_achevement'] = NULL;
        }
        if ($val['date_conformite'] != "") {
            $this->valF['date_conformite'] = $this->dateDB($val['date_conformite']);
        } else {
            $this->valF['date_conformite'] = NULL;
        }
        if ($val['parcelle'] == "") {
            $this->valF['parcelle'] = NULL;
        } else {
            $this->valF['parcelle'] = $val['parcelle'];
        }
        if ($val['pos'] == "") {
            $this->valF['pos'] = NULL;
        } else {
            $this->valF['pos'] = $val['pos'];
        }
        if ($val['sig'] == "") {
            $this->valF['sig'] = ""; // -> default
        } else {
            $this->valF['sig'] = $val['sig'];
        }
        if (!is_numeric($val['batiment_nombre'])) {
            $this->valF['batiment_nombre'] = NULL;
        } else {
            $this->valF['batiment_nombre'] = $val['batiment_nombre'];
        }
        if (!is_numeric($val['logement_nombre'])) {
            $this->valF['logement_nombre'] = NULL;
        } else {
            $this->valF['logement_nombre'] = $val['logement_nombre'];
        }
        if (!is_numeric($val['shon'])) {
            $this->valF['shon'] = NULL;
        } else {
            $this->valF['shon'] = $val['shon'];
        }
        if (!is_numeric($val['shon_calcul'])) {
            $this->valF['shon_calcul'] = NULL;
        } else {
            $this->valF['shon_calcul'] = $val['shon_calcul'];
        }
        if (!is_numeric($val['shob'])) {
            $this->valF['shob'] = NULL;
        } else {
            $this->valF['shob'] = $val['shob'];
        }
        if (!is_numeric($val['lot'])) {
            $this->valF['lot'] = NULL;
        } else {
            $this->valF['lot'] = $val['lot'];
        }
        if (!is_numeric($val['hauteur'])) {
            $this->valF['hauteur'] = NULL;
        } else {
            $this->valF['hauteur'] = $val['hauteur'];
        }
        if (!is_numeric($val['piece_nombre'])) {
            $this->valF['piece_nombre'] = NULL;
        } else {
            $this->valF['piece_nombre'] = $val['piece_nombre'];
        }
        if ($val['amenagement'] == "") {
            $this->valF['amenagement'] = ""; // -> default
        } else {
            $this->valF['amenagement'] = $val['amenagement'];
        }
        if (!is_numeric($val['parcelle_lot'])) {
            $this->valF['parcelle_lot'] = NULL;
        } else {
            $this->valF['parcelle_lot'] = $val['parcelle_lot'];
        }
        if ($val['parcelle_lot_lotissement'] == "") {
            $this->valF['parcelle_lot_lotissement'] = ""; // -> default
        } else {
            $this->valF['parcelle_lot_lotissement'] = $val['parcelle_lot_lotissement'];
        }
            $this->valF['description'] = $val['description'];
        if ($val['temp1'] == "") {
            $this->valF['temp1'] = ""; // -> default
        } else {
            $this->valF['temp1'] = $val['temp1'];
        }
        if ($val['temp2'] == "") {
            $this->valF['temp2'] = ""; // -> default
        } else {
            $this->valF['temp2'] = $val['temp2'];
        }
        if ($val['temp3'] == "") {
            $this->valF['temp3'] = ""; // -> default
        } else {
            $this->valF['temp3'] = $val['temp3'];
        }
        if ($val['temp4'] == "") {
            $this->valF['temp4'] = ""; // -> default
        } else {
            $this->valF['temp4'] = $val['temp4'];
        }
        if ($val['temp5'] == "") {
            $this->valF['temp5'] = ""; // -> default
        } else {
            $this->valF['temp5'] = $val['temp5'];
        }
            $this->valF['servitude'] = $val['servitude'];
        if ($val['erp'] == 1 || $val['erp'] == "t" || $val['erp'] == "Oui") {
            $this->valF['erp'] = true;
        } else {
            $this->valF['erp'] = false;
        }
        if (!is_numeric($val['avis_decision'])) {
            $this->valF['avis_decision'] = NULL;
        } else {
            $this->valF['avis_decision'] = $val['avis_decision'];
        }
        if ($val['enjeu_erp'] == 1 || $val['enjeu_erp'] == "t" || $val['enjeu_erp'] == "Oui") {
            $this->valF['enjeu_erp'] = true;
        } else {
            $this->valF['enjeu_erp'] = false;
        }
        if ($val['enjeu_urba'] == 1 || $val['enjeu_urba'] == "t" || $val['enjeu_urba'] == "Oui") {
            $this->valF['enjeu_urba'] = true;
        } else {
            $this->valF['enjeu_urba'] = false;
        }
        if (!is_numeric($val['division'])) {
            $this->valF['division'] = NULL;
        } else {
            $this->valF['division'] = $val['division'];
        }
        if (!is_numeric($val['autorite_competente'])) {
            $this->valF['autorite_competente'] = NULL;
        } else {
            $this->valF['autorite_competente'] = $val['autorite_competente'];
        }
        if ($val['a_qualifier'] == 1 || $val['a_qualifier'] == "t" || $val['a_qualifier'] == "Oui") {
            $this->valF['a_qualifier'] = true;
        } else {
            $this->valF['a_qualifier'] = false;
        }
            $this->valF['terrain_references_cadastrales'] = $val['terrain_references_cadastrales'];
        if ($val['terrain_adresse_voie_numero'] == "") {
            $this->valF['terrain_adresse_voie_numero'] = NULL;
        } else {
            $this->valF['terrain_adresse_voie_numero'] = $val['terrain_adresse_voie_numero'];
        }
        if ($val['terrain_adresse_voie'] == "") {
            $this->valF['terrain_adresse_voie'] = NULL;
        } else {
            $this->valF['terrain_adresse_voie'] = $val['terrain_adresse_voie'];
        }
        if ($val['terrain_adresse_lieu_dit'] == "") {
            $this->valF['terrain_adresse_lieu_dit'] = NULL;
        } else {
            $this->valF['terrain_adresse_lieu_dit'] = $val['terrain_adresse_lieu_dit'];
        }
        if ($val['terrain_adresse_localite'] == "") {
            $this->valF['terrain_adresse_localite'] = NULL;
        } else {
            $this->valF['terrain_adresse_localite'] = $val['terrain_adresse_localite'];
        }
        if ($val['terrain_adresse_code_postal'] == "") {
            $this->valF['terrain_adresse_code_postal'] = NULL;
        } else {
            $this->valF['terrain_adresse_code_postal'] = $val['terrain_adresse_code_postal'];
        }
        if ($val['terrain_adresse_bp'] == "") {
            $this->valF['terrain_adresse_bp'] = NULL;
        } else {
            $this->valF['terrain_adresse_bp'] = $val['terrain_adresse_bp'];
        }
        if ($val['terrain_adresse_cedex'] == "") {
            $this->valF['terrain_adresse_cedex'] = NULL;
        } else {
            $this->valF['terrain_adresse_cedex'] = $val['terrain_adresse_cedex'];
        }
        if (!is_numeric($val['terrain_superficie'])) {
            $this->valF['terrain_superficie'] = NULL;
        } else {
            $this->valF['terrain_superficie'] = $val['terrain_superficie'];
        }
        $this->valF['dossier_autorisation'] = $val['dossier_autorisation'];
        if (!is_numeric($val['dossier_instruction_type'])) {
            $this->valF['dossier_instruction_type'] = ""; // -> requis
        } else {
            $this->valF['dossier_instruction_type'] = $val['dossier_instruction_type'];
        }
        if ($val['date_dernier_depot'] != "") {
            $this->valF['date_dernier_depot'] = $this->dateDB($val['date_dernier_depot']);
        }
        if (!is_numeric($val['version'])) {
            $this->valF['version'] = NULL;
        } else {
            $this->valF['version'] = $val['version'];
        }
        if ($val['incompletude'] == 1 || $val['incompletude'] == "t" || $val['incompletude'] == "Oui") {
            $this->valF['incompletude'] = true;
        } else {
            $this->valF['incompletude'] = false;
        }
        if (!is_numeric($val['evenement_suivant_tacite'])) {
            $this->valF['evenement_suivant_tacite'] = NULL;
        } else {
            $this->valF['evenement_suivant_tacite'] = $val['evenement_suivant_tacite'];
        }
        if (!is_numeric($val['evenement_suivant_tacite_incompletude'])) {
            $this->valF['evenement_suivant_tacite_incompletude'] = NULL;
        } else {
            $this->valF['evenement_suivant_tacite_incompletude'] = $val['evenement_suivant_tacite_incompletude'];
        }
        if ($val['etat_pendant_incompletude'] == "") {
            $this->valF['etat_pendant_incompletude'] = NULL;
        } else {
            $this->valF['etat_pendant_incompletude'] = $val['etat_pendant_incompletude'];
        }
        if ($val['date_limite_incompletude'] != "") {
            $this->valF['date_limite_incompletude'] = $this->dateDB($val['date_limite_incompletude']);
        } else {
            $this->valF['date_limite_incompletude'] = NULL;
        }
        if (!is_numeric($val['delai_incompletude'])) {
            $this->valF['delai_incompletude'] = NULL;
        } else {
            $this->valF['delai_incompletude'] = $val['delai_incompletude'];
        }
        if ($val['dossier_libelle'] == "") {
            $this->valF['dossier_libelle'] = NULL;
        } else {
            $this->valF['dossier_libelle'] = $val['dossier_libelle'];
        }
        if ($val['numero_versement_archive'] == "") {
            $this->valF['numero_versement_archive'] = NULL;
        } else {
            $this->valF['numero_versement_archive'] = $val['numero_versement_archive'];
        }
        if (!is_numeric($val['duree_validite'])) {
            $this->valF['duree_validite'] = 0; // -> default
        } else {
            $this->valF['duree_validite'] = $val['duree_validite'];
        }
        if (!is_numeric($val['quartier'])) {
            $this->valF['quartier'] = NULL;
        } else {
            $this->valF['quartier'] = $val['quartier'];
        }
        if ($val['incomplet_notifie'] == 1 || $val['incomplet_notifie'] == "t" || $val['incomplet_notifie'] == "Oui") {
            $this->valF['incomplet_notifie'] = true;
        } else {
            $this->valF['incomplet_notifie'] = 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'];
            }
        }
        if (!is_numeric($val['tax_secteur'])) {
            $this->valF['tax_secteur'] = NULL;
        } else {
            $this->valF['tax_secteur'] = $val['tax_secteur'];
        }
        if (!is_numeric($val['tax_mtn_part_commu'])) {
            $this->valF['tax_mtn_part_commu'] = NULL;
        } else {
            $this->valF['tax_mtn_part_commu'] = $val['tax_mtn_part_commu'];
        }
        if (!is_numeric($val['tax_mtn_part_depart'])) {
            $this->valF['tax_mtn_part_depart'] = NULL;
        } else {
            $this->valF['tax_mtn_part_depart'] = $val['tax_mtn_part_depart'];
        }
        if (!is_numeric($val['tax_mtn_part_reg'])) {
            $this->valF['tax_mtn_part_reg'] = NULL;
        } else {
            $this->valF['tax_mtn_part_reg'] = $val['tax_mtn_part_reg'];
        }
        if (!is_numeric($val['tax_mtn_total'])) {
            $this->valF['tax_mtn_total'] = NULL;
        } else {
            $this->valF['tax_mtn_total'] = $val['tax_mtn_total'];
        }
            $this->valF['log_instructions'] = $val['log_instructions'];
        if ($val['geom'] == "") {
            unset($this->valF['geom']);
        } else {
            $this->valF['geom'] = $val['geom'];
        }
        if ($val['geom1'] == "") {
            unset($this->valF['geom1']);
        } else {
            $this->valF['geom1'] = $val['geom1'];
        }
    }

    //==========================
    // Formulaire  [form]
    //==========================
    /**
     *
     */
    function setType(&$form, $maj) {
        // Récupération du mode de l'action
        $crud = $this->get_action_crud($maj);

        // MODE AJOUTER
        if ($maj == 0 || $crud == 'create') {
            $form->setType("dossier", "text");
            $form->setType("annee", "text");
            if ($this->is_in_context_of_foreign_key("etat", $this->retourformulaire)) {
                $form->setType("etat", "selecthiddenstatic");
            } else {
                $form->setType("etat", "select");
            }
            if ($this->is_in_context_of_foreign_key("instructeur", $this->retourformulaire)) {
                $form->setType("instructeur", "selecthiddenstatic");
            } else {
                $form->setType("instructeur", "select");
            }
            $form->setType("date_demande", "date");
            $form->setType("date_depot", "date");
            $form->setType("date_complet", "date");
            $form->setType("date_rejet", "date");
            $form->setType("date_notification_delai", "date");
            $form->setType("delai", "text");
            $form->setType("date_limite", "date");
            $form->setType("accord_tacite", "text");
            $form->setType("date_decision", "date");
            $form->setType("date_validite", "date");
            $form->setType("date_chantier", "date");
            $form->setType("date_achevement", "date");
            $form->setType("date_conformite", "date");
            if ($this->is_in_context_of_foreign_key("parcelle", $this->retourformulaire)) {
                $form->setType("parcelle", "selecthiddenstatic");
            } else {
                $form->setType("parcelle", "select");
            }
            if ($this->is_in_context_of_foreign_key("pos", $this->retourformulaire)) {
                $form->setType("pos", "selecthiddenstatic");
            } else {
                $form->setType("pos", "select");
            }
            $form->setType("sig", "text");
            $form->setType("batiment_nombre", "text");
            $form->setType("logement_nombre", "text");
            $form->setType("shon", "text");
            $form->setType("shon_calcul", "text");
            $form->setType("shob", "text");
            $form->setType("lot", "text");
            $form->setType("hauteur", "text");
            $form->setType("piece_nombre", "text");
            $form->setType("amenagement", "text");
            if ($this->is_in_context_of_foreign_key("parcelle_lot", $this->retourformulaire)) {
                $form->setType("parcelle_lot", "selecthiddenstatic");
            } else {
                $form->setType("parcelle_lot", "select");
            }
            $form->setType("parcelle_lot_lotissement", "text");
            $form->setType("description", "textarea");
            $form->setType("temp1", "text");
            $form->setType("temp2", "text");
            $form->setType("temp3", "text");
            $form->setType("temp4", "text");
            $form->setType("temp5", "text");
            $form->setType("servitude", "textarea");
            $form->setType("erp", "checkbox");
            if ($this->is_in_context_of_foreign_key("avis_decision", $this->retourformulaire)) {
                $form->setType("avis_decision", "selecthiddenstatic");
            } else {
                $form->setType("avis_decision", "select");
            }
            $form->setType("enjeu_erp", "checkbox");
            $form->setType("enjeu_urba", "checkbox");
            if ($this->is_in_context_of_foreign_key("division", $this->retourformulaire)) {
                $form->setType("division", "selecthiddenstatic");
            } else {
                $form->setType("division", "select");
            }
            if ($this->is_in_context_of_foreign_key("autorite_competente", $this->retourformulaire)) {
                $form->setType("autorite_competente", "selecthiddenstatic");
            } else {
                $form->setType("autorite_competente", "select");
            }
            $form->setType("a_qualifier", "checkbox");
            $form->setType("terrain_references_cadastrales", "textarea");
            $form->setType("terrain_adresse_voie_numero", "text");
            $form->setType("terrain_adresse_voie", "text");
            $form->setType("terrain_adresse_lieu_dit", "text");
            $form->setType("terrain_adresse_localite", "text");
            $form->setType("terrain_adresse_code_postal", "text");
            $form->setType("terrain_adresse_bp", "text");
            $form->setType("terrain_adresse_cedex", "text");
            $form->setType("terrain_superficie", "text");
            if ($this->is_in_context_of_foreign_key("dossier_autorisation", $this->retourformulaire)) {
                $form->setType("dossier_autorisation", "selecthiddenstatic");
            } else {
                $form->setType("dossier_autorisation", "select");
            }
            if ($this->is_in_context_of_foreign_key("dossier_instruction_type", $this->retourformulaire)) {
                $form->setType("dossier_instruction_type", "selecthiddenstatic");
            } else {
                $form->setType("dossier_instruction_type", "select");
            }
            $form->setType("date_dernier_depot", "date");
            $form->setType("version", "text");
            $form->setType("incompletude", "checkbox");
            if ($this->is_in_context_of_foreign_key("evenement", $this->retourformulaire)) {
                $form->setType("evenement_suivant_tacite", "selecthiddenstatic");
            } else {
                $form->setType("evenement_suivant_tacite", "select");
            }
            if ($this->is_in_context_of_foreign_key("evenement", $this->retourformulaire)) {
                $form->setType("evenement_suivant_tacite_incompletude", "selecthiddenstatic");
            } else {
                $form->setType("evenement_suivant_tacite_incompletude", "select");
            }
            if ($this->is_in_context_of_foreign_key("etat", $this->retourformulaire)) {
                $form->setType("etat_pendant_incompletude", "selecthiddenstatic");
            } else {
                $form->setType("etat_pendant_incompletude", "select");
            }
            $form->setType("date_limite_incompletude", "date");
            $form->setType("delai_incompletude", "text");
            $form->setType("dossier_libelle", "text");
            $form->setType("numero_versement_archive", "text");
            $form->setType("duree_validite", "text");
            if ($this->is_in_context_of_foreign_key("quartier", $this->retourformulaire)) {
                $form->setType("quartier", "selecthiddenstatic");
            } else {
                $form->setType("quartier", "select");
            }
            $form->setType("incomplet_notifie", "checkbox");
            if ($this->is_in_context_of_foreign_key("om_collectivite", $this->retourformulaire)) {
                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");
                }
            }
            $form->setType("tax_secteur", "text");
            $form->setType("tax_mtn_part_commu", "text");
            $form->setType("tax_mtn_part_depart", "text");
            $form->setType("tax_mtn_part_reg", "text");
            $form->setType("tax_mtn_total", "text");
            $form->setType("log_instructions", "textarea");
            $form->setType("geom", "geom");
            $form->setType("geom1", "geom");
        }

        // MDOE MODIFIER
        if ($maj == 1 || $crud == 'update') {
            $form->setType("dossier", "hiddenstatic");
            $form->setType("annee", "text");
            if ($this->is_in_context_of_foreign_key("etat", $this->retourformulaire)) {
                $form->setType("etat", "selecthiddenstatic");
            } else {
                $form->setType("etat", "select");
            }
            if ($this->is_in_context_of_foreign_key("instructeur", $this->retourformulaire)) {
                $form->setType("instructeur", "selecthiddenstatic");
            } else {
                $form->setType("instructeur", "select");
            }
            $form->setType("date_demande", "date");
            $form->setType("date_depot", "date");
            $form->setType("date_complet", "date");
            $form->setType("date_rejet", "date");
            $form->setType("date_notification_delai", "date");
            $form->setType("delai", "text");
            $form->setType("date_limite", "date");
            $form->setType("accord_tacite", "text");
            $form->setType("date_decision", "date");
            $form->setType("date_validite", "date");
            $form->setType("date_chantier", "date");
            $form->setType("date_achevement", "date");
            $form->setType("date_conformite", "date");
            if ($this->is_in_context_of_foreign_key("parcelle", $this->retourformulaire)) {
                $form->setType("parcelle", "selecthiddenstatic");
            } else {
                $form->setType("parcelle", "select");
            }
            if ($this->is_in_context_of_foreign_key("pos", $this->retourformulaire)) {
                $form->setType("pos", "selecthiddenstatic");
            } else {
                $form->setType("pos", "select");
            }
            $form->setType("sig", "text");
            $form->setType("batiment_nombre", "text");
            $form->setType("logement_nombre", "text");
            $form->setType("shon", "text");
            $form->setType("shon_calcul", "text");
            $form->setType("shob", "text");
            $form->setType("lot", "text");
            $form->setType("hauteur", "text");
            $form->setType("piece_nombre", "text");
            $form->setType("amenagement", "text");
            if ($this->is_in_context_of_foreign_key("parcelle_lot", $this->retourformulaire)) {
                $form->setType("parcelle_lot", "selecthiddenstatic");
            } else {
                $form->setType("parcelle_lot", "select");
            }
            $form->setType("parcelle_lot_lotissement", "text");
            $form->setType("description", "textarea");
            $form->setType("temp1", "text");
            $form->setType("temp2", "text");
            $form->setType("temp3", "text");
            $form->setType("temp4", "text");
            $form->setType("temp5", "text");
            $form->setType("servitude", "textarea");
            $form->setType("erp", "checkbox");
            if ($this->is_in_context_of_foreign_key("avis_decision", $this->retourformulaire)) {
                $form->setType("avis_decision", "selecthiddenstatic");
            } else {
                $form->setType("avis_decision", "select");
            }
            $form->setType("enjeu_erp", "checkbox");
            $form->setType("enjeu_urba", "checkbox");
            if ($this->is_in_context_of_foreign_key("division", $this->retourformulaire)) {
                $form->setType("division", "selecthiddenstatic");
            } else {
                $form->setType("division", "select");
            }
            if ($this->is_in_context_of_foreign_key("autorite_competente", $this->retourformulaire)) {
                $form->setType("autorite_competente", "selecthiddenstatic");
            } else {
                $form->setType("autorite_competente", "select");
            }
            $form->setType("a_qualifier", "checkbox");
            $form->setType("terrain_references_cadastrales", "textarea");
            $form->setType("terrain_adresse_voie_numero", "text");
            $form->setType("terrain_adresse_voie", "text");
            $form->setType("terrain_adresse_lieu_dit", "text");
            $form->setType("terrain_adresse_localite", "text");
            $form->setType("terrain_adresse_code_postal", "text");
            $form->setType("terrain_adresse_bp", "text");
            $form->setType("terrain_adresse_cedex", "text");
            $form->setType("terrain_superficie", "text");
            if ($this->is_in_context_of_foreign_key("dossier_autorisation", $this->retourformulaire)) {
                $form->setType("dossier_autorisation", "selecthiddenstatic");
            } else {
                $form->setType("dossier_autorisation", "select");
            }
            if ($this->is_in_context_of_foreign_key("dossier_instruction_type", $this->retourformulaire)) {
                $form->setType("dossier_instruction_type", "selecthiddenstatic");
            } else {
                $form->setType("dossier_instruction_type", "select");
            }
            $form->setType("date_dernier_depot", "date");
            $form->setType("version", "text");
            $form->setType("incompletude", "checkbox");
            if ($this->is_in_context_of_foreign_key("evenement", $this->retourformulaire)) {
                $form->setType("evenement_suivant_tacite", "selecthiddenstatic");
            } else {
                $form->setType("evenement_suivant_tacite", "select");
            }
            if ($this->is_in_context_of_foreign_key("evenement", $this->retourformulaire)) {
                $form->setType("evenement_suivant_tacite_incompletude", "selecthiddenstatic");
            } else {
                $form->setType("evenement_suivant_tacite_incompletude", "select");
            }
            if ($this->is_in_context_of_foreign_key("etat", $this->retourformulaire)) {
                $form->setType("etat_pendant_incompletude", "selecthiddenstatic");
            } else {
                $form->setType("etat_pendant_incompletude", "select");
            }
            $form->setType("date_limite_incompletude", "date");
            $form->setType("delai_incompletude", "text");
            $form->setType("dossier_libelle", "text");
            $form->setType("numero_versement_archive", "text");
            $form->setType("duree_validite", "text");
            if ($this->is_in_context_of_foreign_key("quartier", $this->retourformulaire)) {
                $form->setType("quartier", "selecthiddenstatic");
            } else {
                $form->setType("quartier", "select");
            }
            $form->setType("incomplet_notifie", "checkbox");
            if ($this->is_in_context_of_foreign_key("om_collectivite", $this->retourformulaire)) {
                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");
                }
            }
            $form->setType("tax_secteur", "text");
            $form->setType("tax_mtn_part_commu", "text");
            $form->setType("tax_mtn_part_depart", "text");
            $form->setType("tax_mtn_part_reg", "text");
            $form->setType("tax_mtn_total", "text");
            $form->setType("log_instructions", "textarea");
            $form->setType("geom", "geom");
            $form->setType("geom1", "geom");
        }

        // MODE SUPPRIMER
        if ($maj == 2 || $crud == 'delete') {
            $form->setType("dossier", "hiddenstatic");
            $form->setType("annee", "hiddenstatic");
            $form->setType("etat", "selectstatic");
            $form->setType("instructeur", "selectstatic");
            $form->setType("date_demande", "hiddenstatic");
            $form->setType("date_depot", "hiddenstatic");
            $form->setType("date_complet", "hiddenstatic");
            $form->setType("date_rejet", "hiddenstatic");
            $form->setType("date_notification_delai", "hiddenstatic");
            $form->setType("delai", "hiddenstatic");
            $form->setType("date_limite", "hiddenstatic");
            $form->setType("accord_tacite", "hiddenstatic");
            $form->setType("date_decision", "hiddenstatic");
            $form->setType("date_validite", "hiddenstatic");
            $form->setType("date_chantier", "hiddenstatic");
            $form->setType("date_achevement", "hiddenstatic");
            $form->setType("date_conformite", "hiddenstatic");
            $form->setType("parcelle", "selectstatic");
            $form->setType("pos", "selectstatic");
            $form->setType("sig", "hiddenstatic");
            $form->setType("batiment_nombre", "hiddenstatic");
            $form->setType("logement_nombre", "hiddenstatic");
            $form->setType("shon", "hiddenstatic");
            $form->setType("shon_calcul", "hiddenstatic");
            $form->setType("shob", "hiddenstatic");
            $form->setType("lot", "hiddenstatic");
            $form->setType("hauteur", "hiddenstatic");
            $form->setType("piece_nombre", "hiddenstatic");
            $form->setType("amenagement", "hiddenstatic");
            $form->setType("parcelle_lot", "selectstatic");
            $form->setType("parcelle_lot_lotissement", "hiddenstatic");
            $form->setType("description", "hiddenstatic");
            $form->setType("temp1", "hiddenstatic");
            $form->setType("temp2", "hiddenstatic");
            $form->setType("temp3", "hiddenstatic");
            $form->setType("temp4", "hiddenstatic");
            $form->setType("temp5", "hiddenstatic");
            $form->setType("servitude", "hiddenstatic");
            $form->setType("erp", "hiddenstatic");
            $form->setType("avis_decision", "selectstatic");
            $form->setType("enjeu_erp", "hiddenstatic");
            $form->setType("enjeu_urba", "hiddenstatic");
            $form->setType("division", "selectstatic");
            $form->setType("autorite_competente", "selectstatic");
            $form->setType("a_qualifier", "hiddenstatic");
            $form->setType("terrain_references_cadastrales", "hiddenstatic");
            $form->setType("terrain_adresse_voie_numero", "hiddenstatic");
            $form->setType("terrain_adresse_voie", "hiddenstatic");
            $form->setType("terrain_adresse_lieu_dit", "hiddenstatic");
            $form->setType("terrain_adresse_localite", "hiddenstatic");
            $form->setType("terrain_adresse_code_postal", "hiddenstatic");
            $form->setType("terrain_adresse_bp", "hiddenstatic");
            $form->setType("terrain_adresse_cedex", "hiddenstatic");
            $form->setType("terrain_superficie", "hiddenstatic");
            $form->setType("dossier_autorisation", "selectstatic");
            $form->setType("dossier_instruction_type", "selectstatic");
            $form->setType("date_dernier_depot", "hiddenstatic");
            $form->setType("version", "hiddenstatic");
            $form->setType("incompletude", "hiddenstatic");
            $form->setType("evenement_suivant_tacite", "selectstatic");
            $form->setType("evenement_suivant_tacite_incompletude", "selectstatic");
            $form->setType("etat_pendant_incompletude", "selectstatic");
            $form->setType("date_limite_incompletude", "hiddenstatic");
            $form->setType("delai_incompletude", "hiddenstatic");
            $form->setType("dossier_libelle", "hiddenstatic");
            $form->setType("numero_versement_archive", "hiddenstatic");
            $form->setType("duree_validite", "hiddenstatic");
            $form->setType("quartier", "selectstatic");
            $form->setType("incomplet_notifie", "hiddenstatic");
            if ($_SESSION["niveau"] == 2) {
                $form->setType("om_collectivite", "selectstatic");
            } else {
                $form->setType("om_collectivite", "hidden");
            }
            $form->setType("tax_secteur", "hiddenstatic");
            $form->setType("tax_mtn_part_commu", "hiddenstatic");
            $form->setType("tax_mtn_part_depart", "hiddenstatic");
            $form->setType("tax_mtn_part_reg", "hiddenstatic");
            $form->setType("tax_mtn_total", "hiddenstatic");
            $form->setType("log_instructions", "hiddenstatic");
            $form->setType("geom", "geom");
            $form->setType("geom1", "geom");
        }

        // MODE CONSULTER
        if ($maj == 3 || $crud == 'read') {
            $form->setType("dossier", "static");
            $form->setType("annee", "static");
            $form->setType("etat", "selectstatic");
            $form->setType("instructeur", "selectstatic");
            $form->setType("date_demande", "datestatic");
            $form->setType("date_depot", "datestatic");
            $form->setType("date_complet", "datestatic");
            $form->setType("date_rejet", "datestatic");
            $form->setType("date_notification_delai", "datestatic");
            $form->setType("delai", "static");
            $form->setType("date_limite", "datestatic");
            $form->setType("accord_tacite", "static");
            $form->setType("date_decision", "datestatic");
            $form->setType("date_validite", "datestatic");
            $form->setType("date_chantier", "datestatic");
            $form->setType("date_achevement", "datestatic");
            $form->setType("date_conformite", "datestatic");
            $form->setType("parcelle", "selectstatic");
            $form->setType("pos", "selectstatic");
            $form->setType("sig", "static");
            $form->setType("batiment_nombre", "static");
            $form->setType("logement_nombre", "static");
            $form->setType("shon", "static");
            $form->setType("shon_calcul", "static");
            $form->setType("shob", "static");
            $form->setType("lot", "static");
            $form->setType("hauteur", "static");
            $form->setType("piece_nombre", "static");
            $form->setType("amenagement", "static");
            $form->setType("parcelle_lot", "selectstatic");
            $form->setType("parcelle_lot_lotissement", "static");
            $form->setType("description", "textareastatic");
            $form->setType("temp1", "static");
            $form->setType("temp2", "static");
            $form->setType("temp3", "static");
            $form->setType("temp4", "static");
            $form->setType("temp5", "static");
            $form->setType("servitude", "textareastatic");
            $form->setType("erp", "checkboxstatic");
            $form->setType("avis_decision", "selectstatic");
            $form->setType("enjeu_erp", "checkboxstatic");
            $form->setType("enjeu_urba", "checkboxstatic");
            $form->setType("division", "selectstatic");
            $form->setType("autorite_competente", "selectstatic");
            $form->setType("a_qualifier", "checkboxstatic");
            $form->setType("terrain_references_cadastrales", "textareastatic");
            $form->setType("terrain_adresse_voie_numero", "static");
            $form->setType("terrain_adresse_voie", "static");
            $form->setType("terrain_adresse_lieu_dit", "static");
            $form->setType("terrain_adresse_localite", "static");
            $form->setType("terrain_adresse_code_postal", "static");
            $form->setType("terrain_adresse_bp", "static");
            $form->setType("terrain_adresse_cedex", "static");
            $form->setType("terrain_superficie", "static");
            $form->setType("dossier_autorisation", "selectstatic");
            $form->setType("dossier_instruction_type", "selectstatic");
            $form->setType("date_dernier_depot", "datestatic");
            $form->setType("version", "static");
            $form->setType("incompletude", "checkboxstatic");
            $form->setType("evenement_suivant_tacite", "selectstatic");
            $form->setType("evenement_suivant_tacite_incompletude", "selectstatic");
            $form->setType("etat_pendant_incompletude", "selectstatic");
            $form->setType("date_limite_incompletude", "datestatic");
            $form->setType("delai_incompletude", "static");
            $form->setType("dossier_libelle", "static");
            $form->setType("numero_versement_archive", "static");
            $form->setType("duree_validite", "static");
            $form->setType("quartier", "selectstatic");
            $form->setType("incomplet_notifie", "checkboxstatic");
            if ($this->is_in_context_of_foreign_key("om_collectivite", $this->retourformulaire)) {
                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");
                }
            }
            $form->setType("tax_secteur", "static");
            $form->setType("tax_mtn_part_commu", "static");
            $form->setType("tax_mtn_part_depart", "static");
            $form->setType("tax_mtn_part_reg", "static");
            $form->setType("tax_mtn_total", "static");
            $form->setType("log_instructions", "textareastatic");
            $form->setType("geom", "geom");
            $form->setType("geom1", "geom");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('instructeur','VerifNum(this)');
        $form->setOnchange('date_demande','fdate(this)');
        $form->setOnchange('date_depot','fdate(this)');
        $form->setOnchange('date_complet','fdate(this)');
        $form->setOnchange('date_rejet','fdate(this)');
        $form->setOnchange('date_notification_delai','fdate(this)');
        $form->setOnchange('delai','VerifNum(this)');
        $form->setOnchange('date_limite','fdate(this)');
        $form->setOnchange('date_decision','fdate(this)');
        $form->setOnchange('date_validite','fdate(this)');
        $form->setOnchange('date_chantier','fdate(this)');
        $form->setOnchange('date_achevement','fdate(this)');
        $form->setOnchange('date_conformite','fdate(this)');
        $form->setOnchange('batiment_nombre','VerifNum(this)');
        $form->setOnchange('logement_nombre','VerifNum(this)');
        $form->setOnchange('shon','VerifFloat(this)');
        $form->setOnchange('shon_calcul','VerifFloat(this)');
        $form->setOnchange('shob','VerifFloat(this)');
        $form->setOnchange('lot','VerifNum(this)');
        $form->setOnchange('hauteur','VerifFloat(this)');
        $form->setOnchange('piece_nombre','VerifNum(this)');
        $form->setOnchange('parcelle_lot','VerifNum(this)');
        $form->setOnchange('avis_decision','VerifNum(this)');
        $form->setOnchange('division','VerifNum(this)');
        $form->setOnchange('autorite_competente','VerifNum(this)');
        $form->setOnchange('terrain_superficie','VerifFloat(this)');
        $form->setOnchange('dossier_instruction_type','VerifNum(this)');
        $form->setOnchange('date_dernier_depot','fdate(this)');
        $form->setOnchange('version','VerifNum(this)');
        $form->setOnchange('evenement_suivant_tacite','VerifNum(this)');
        $form->setOnchange('evenement_suivant_tacite_incompletude','VerifNum(this)');
        $form->setOnchange('date_limite_incompletude','fdate(this)');
        $form->setOnchange('delai_incompletude','VerifNum(this)');
        $form->setOnchange('duree_validite','VerifNum(this)');
        $form->setOnchange('quartier','VerifNum(this)');
        $form->setOnchange('om_collectivite','VerifNum(this)');
        $form->setOnchange('tax_secteur','VerifNum(this)');
        $form->setOnchange('tax_mtn_part_commu','VerifFloat(this)');
        $form->setOnchange('tax_mtn_part_depart','VerifFloat(this)');
        $form->setOnchange('tax_mtn_part_reg','VerifFloat(this)');
        $form->setOnchange('tax_mtn_total','VerifFloat(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("dossier", 30);
        $form->setTaille("annee", 10);
        $form->setTaille("etat", 20);
        $form->setTaille("instructeur", 11);
        $form->setTaille("date_demande", 12);
        $form->setTaille("date_depot", 12);
        $form->setTaille("date_complet", 12);
        $form->setTaille("date_rejet", 12);
        $form->setTaille("date_notification_delai", 12);
        $form->setTaille("delai", 11);
        $form->setTaille("date_limite", 12);
        $form->setTaille("accord_tacite", 10);
        $form->setTaille("date_decision", 12);
        $form->setTaille("date_validite", 12);
        $form->setTaille("date_chantier", 12);
        $form->setTaille("date_achevement", 12);
        $form->setTaille("date_conformite", 12);
        $form->setTaille("parcelle", 20);
        $form->setTaille("pos", 10);
        $form->setTaille("sig", 10);
        $form->setTaille("batiment_nombre", 11);
        $form->setTaille("logement_nombre", 11);
        $form->setTaille("shon", 20);
        $form->setTaille("shon_calcul", 20);
        $form->setTaille("shob", 20);
        $form->setTaille("lot", 11);
        $form->setTaille("hauteur", 20);
        $form->setTaille("piece_nombre", 11);
        $form->setTaille("amenagement", 12);
        $form->setTaille("parcelle_lot", 11);
        $form->setTaille("parcelle_lot_lotissement", 30);
        $form->setTaille("description", 80);
        $form->setTaille("temp1", 30);
        $form->setTaille("temp2", 30);
        $form->setTaille("temp3", 30);
        $form->setTaille("temp4", 30);
        $form->setTaille("temp5", 30);
        $form->setTaille("servitude", 80);
        $form->setTaille("erp", 1);
        $form->setTaille("avis_decision", 11);
        $form->setTaille("enjeu_erp", 1);
        $form->setTaille("enjeu_urba", 1);
        $form->setTaille("division", 11);
        $form->setTaille("autorite_competente", 11);
        $form->setTaille("a_qualifier", 1);
        $form->setTaille("terrain_references_cadastrales", 80);
        $form->setTaille("terrain_adresse_voie_numero", 20);
        $form->setTaille("terrain_adresse_voie", 30);
        $form->setTaille("terrain_adresse_lieu_dit", 30);
        $form->setTaille("terrain_adresse_localite", 30);
        $form->setTaille("terrain_adresse_code_postal", 10);
        $form->setTaille("terrain_adresse_bp", 15);
        $form->setTaille("terrain_adresse_cedex", 15);
        $form->setTaille("terrain_superficie", 20);
        $form->setTaille("dossier_autorisation", 20);
        $form->setTaille("dossier_instruction_type", 11);
        $form->setTaille("date_dernier_depot", 12);
        $form->setTaille("version", 11);
        $form->setTaille("incompletude", 1);
        $form->setTaille("evenement_suivant_tacite", 11);
        $form->setTaille("evenement_suivant_tacite_incompletude", 11);
        $form->setTaille("etat_pendant_incompletude", 20);
        $form->setTaille("date_limite_incompletude", 12);
        $form->setTaille("delai_incompletude", 11);
        $form->setTaille("dossier_libelle", 25);
        $form->setTaille("numero_versement_archive", 30);
        $form->setTaille("duree_validite", 11);
        $form->setTaille("quartier", 11);
        $form->setTaille("incomplet_notifie", 1);
        $form->setTaille("om_collectivite", 11);
        $form->setTaille("tax_secteur", 11);
        $form->setTaille("tax_mtn_part_commu", 10);
        $form->setTaille("tax_mtn_part_depart", 10);
        $form->setTaille("tax_mtn_part_reg", 10);
        $form->setTaille("tax_mtn_total", 10);
        $form->setTaille("log_instructions", 80);
        $form->setTaille("geom", 30);
        $form->setTaille("geom1", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("dossier", 30);
        $form->setMax("annee", 2);
        $form->setMax("etat", 20);
        $form->setMax("instructeur", 11);
        $form->setMax("date_demande", 12);
        $form->setMax("date_depot", 12);
        $form->setMax("date_complet", 12);
        $form->setMax("date_rejet", 12);
        $form->setMax("date_notification_delai", 12);
        $form->setMax("delai", 11);
        $form->setMax("date_limite", 12);
        $form->setMax("accord_tacite", 3);
        $form->setMax("date_decision", 12);
        $form->setMax("date_validite", 12);
        $form->setMax("date_chantier", 12);
        $form->setMax("date_achevement", 12);
        $form->setMax("date_conformite", 12);
        $form->setMax("parcelle", 20);
        $form->setMax("pos", 10);
        $form->setMax("sig", 3);
        $form->setMax("batiment_nombre", 11);
        $form->setMax("logement_nombre", 11);
        $form->setMax("shon", 20);
        $form->setMax("shon_calcul", 20);
        $form->setMax("shob", 20);
        $form->setMax("lot", 11);
        $form->setMax("hauteur", 20);
        $form->setMax("piece_nombre", 11);
        $form->setMax("amenagement", 12);
        $form->setMax("parcelle_lot", 11);
        $form->setMax("parcelle_lot_lotissement", 60);
        $form->setMax("description", 6);
        $form->setMax("temp1", 100);
        $form->setMax("temp2", 100);
        $form->setMax("temp3", 100);
        $form->setMax("temp4", 100);
        $form->setMax("temp5", 100);
        $form->setMax("servitude", 6);
        $form->setMax("erp", 1);
        $form->setMax("avis_decision", 11);
        $form->setMax("enjeu_erp", 1);
        $form->setMax("enjeu_urba", 1);
        $form->setMax("division", 11);
        $form->setMax("autorite_competente", 11);
        $form->setMax("a_qualifier", 1);
        $form->setMax("terrain_references_cadastrales", 6);
        $form->setMax("terrain_adresse_voie_numero", 20);
        $form->setMax("terrain_adresse_voie", 30);
        $form->setMax("terrain_adresse_lieu_dit", 30);
        $form->setMax("terrain_adresse_localite", 30);
        $form->setMax("terrain_adresse_code_postal", 5);
        $form->setMax("terrain_adresse_bp", 15);
        $form->setMax("terrain_adresse_cedex", 15);
        $form->setMax("terrain_superficie", 20);
        $form->setMax("dossier_autorisation", 20);
        $form->setMax("dossier_instruction_type", 11);
        $form->setMax("date_dernier_depot", 12);
        $form->setMax("version", 11);
        $form->setMax("incompletude", 1);
        $form->setMax("evenement_suivant_tacite", 11);
        $form->setMax("evenement_suivant_tacite_incompletude", 11);
        $form->setMax("etat_pendant_incompletude", 20);
        $form->setMax("date_limite_incompletude", 12);
        $form->setMax("delai_incompletude", 11);
        $form->setMax("dossier_libelle", 25);
        $form->setMax("numero_versement_archive", 100);
        $form->setMax("duree_validite", 11);
        $form->setMax("quartier", 11);
        $form->setMax("incomplet_notifie", 1);
        $form->setMax("om_collectivite", 11);
        $form->setMax("tax_secteur", 11);
        $form->setMax("tax_mtn_part_commu", -5);
        $form->setMax("tax_mtn_part_depart", -5);
        $form->setMax("tax_mtn_part_reg", -5);
        $form->setMax("tax_mtn_total", -5);
        $form->setMax("log_instructions", 6);
        $form->setMax("geom", 551424);
        $form->setMax("geom1", 551444);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('dossier',_('dossier'));
        $form->setLib('annee',_('annee'));
        $form->setLib('etat',_('etat'));
        $form->setLib('instructeur',_('instructeur'));
        $form->setLib('date_demande',_('date_demande'));
        $form->setLib('date_depot',_('date_depot'));
        $form->setLib('date_complet',_('date_complet'));
        $form->setLib('date_rejet',_('date_rejet'));
        $form->setLib('date_notification_delai',_('date_notification_delai'));
        $form->setLib('delai',_('delai'));
        $form->setLib('date_limite',_('date_limite'));
        $form->setLib('accord_tacite',_('accord_tacite'));
        $form->setLib('date_decision',_('date_decision'));
        $form->setLib('date_validite',_('date_validite'));
        $form->setLib('date_chantier',_('date_chantier'));
        $form->setLib('date_achevement',_('date_achevement'));
        $form->setLib('date_conformite',_('date_conformite'));
        $form->setLib('parcelle',_('parcelle'));
        $form->setLib('pos',_('pos'));
        $form->setLib('sig',_('sig'));
        $form->setLib('batiment_nombre',_('batiment_nombre'));
        $form->setLib('logement_nombre',_('logement_nombre'));
        $form->setLib('shon',_('shon'));
        $form->setLib('shon_calcul',_('shon_calcul'));
        $form->setLib('shob',_('shob'));
        $form->setLib('lot',_('lot'));
        $form->setLib('hauteur',_('hauteur'));
        $form->setLib('piece_nombre',_('piece_nombre'));
        $form->setLib('amenagement',_('amenagement'));
        $form->setLib('parcelle_lot',_('parcelle_lot'));
        $form->setLib('parcelle_lot_lotissement',_('parcelle_lot_lotissement'));
        $form->setLib('description',_('description'));
        $form->setLib('temp1',_('temp1'));
        $form->setLib('temp2',_('temp2'));
        $form->setLib('temp3',_('temp3'));
        $form->setLib('temp4',_('temp4'));
        $form->setLib('temp5',_('temp5'));
        $form->setLib('servitude',_('servitude'));
        $form->setLib('erp',_('erp'));
        $form->setLib('avis_decision',_('avis_decision'));
        $form->setLib('enjeu_erp',_('enjeu_erp'));
        $form->setLib('enjeu_urba',_('enjeu_urba'));
        $form->setLib('division',_('division'));
        $form->setLib('autorite_competente',_('autorite_competente'));
        $form->setLib('a_qualifier',_('a_qualifier'));
        $form->setLib('terrain_references_cadastrales',_('terrain_references_cadastrales'));
        $form->setLib('terrain_adresse_voie_numero',_('terrain_adresse_voie_numero'));
        $form->setLib('terrain_adresse_voie',_('terrain_adresse_voie'));
        $form->setLib('terrain_adresse_lieu_dit',_('terrain_adresse_lieu_dit'));
        $form->setLib('terrain_adresse_localite',_('terrain_adresse_localite'));
        $form->setLib('terrain_adresse_code_postal',_('terrain_adresse_code_postal'));
        $form->setLib('terrain_adresse_bp',_('terrain_adresse_bp'));
        $form->setLib('terrain_adresse_cedex',_('terrain_adresse_cedex'));
        $form->setLib('terrain_superficie',_('terrain_superficie'));
        $form->setLib('dossier_autorisation',_('dossier_autorisation'));
        $form->setLib('dossier_instruction_type',_('dossier_instruction_type'));
        $form->setLib('date_dernier_depot',_('date_dernier_depot'));
        $form->setLib('version',_('version'));
        $form->setLib('incompletude',_('incompletude'));
        $form->setLib('evenement_suivant_tacite',_('evenement_suivant_tacite'));
        $form->setLib('evenement_suivant_tacite_incompletude',_('evenement_suivant_tacite_incompletude'));
        $form->setLib('etat_pendant_incompletude',_('etat_pendant_incompletude'));
        $form->setLib('date_limite_incompletude',_('date_limite_incompletude'));
        $form->setLib('delai_incompletude',_('delai_incompletude'));
        $form->setLib('dossier_libelle',_('dossier_libelle'));
        $form->setLib('numero_versement_archive',_('numero_versement_archive'));
        $form->setLib('duree_validite',_('duree_validite'));
        $form->setLib('quartier',_('quartier'));
        $form->setLib('incomplet_notifie',_('incomplet_notifie'));
        $form->setLib('om_collectivite',_('om_collectivite'));
        $form->setLib('tax_secteur',_('tax_secteur'));
        $form->setLib('tax_mtn_part_commu',_('tax_mtn_part_commu'));
        $form->setLib('tax_mtn_part_depart',_('tax_mtn_part_depart'));
        $form->setLib('tax_mtn_part_reg',_('tax_mtn_part_reg'));
        $form->setLib('tax_mtn_total',_('tax_mtn_total'));
        $form->setLib('log_instructions',_('log_instructions'));
        $form->setLib('geom',_('geom'));
        $form->setLib('geom1',_('geom1'));
    }
    /**
     *
     */
    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";
        }

        // autorite_competente
        $this->init_select($form, $this->f->db, $maj, null, "autorite_competente", $sql_autorite_competente, $sql_autorite_competente_by_id, false);
        // avis_decision
        $this->init_select($form, $this->f->db, $maj, null, "avis_decision", $sql_avis_decision, $sql_avis_decision_by_id, false);
        // division
        $this->init_select($form, $this->f->db, $maj, null, "division", $sql_division, $sql_division_by_id, true);
        // dossier_autorisation
        $this->init_select($form, $this->f->db, $maj, null, "dossier_autorisation", $sql_dossier_autorisation, $sql_dossier_autorisation_by_id, false);
        // dossier_instruction_type
        $this->init_select($form, $this->f->db, $maj, null, "dossier_instruction_type", $sql_dossier_instruction_type, $sql_dossier_instruction_type_by_id, false);
        // etat
        $this->init_select($form, $this->f->db, $maj, null, "etat", $sql_etat, $sql_etat_by_id, false);
        // etat_pendant_incompletude
        $this->init_select($form, $this->f->db, $maj, null, "etat_pendant_incompletude", $sql_etat_pendant_incompletude, $sql_etat_pendant_incompletude_by_id, false);
        // evenement_suivant_tacite
        $this->init_select($form, $this->f->db, $maj, null, "evenement_suivant_tacite", $sql_evenement_suivant_tacite, $sql_evenement_suivant_tacite_by_id, false);
        // evenement_suivant_tacite_incompletude
        $this->init_select($form, $this->f->db, $maj, null, "evenement_suivant_tacite_incompletude", $sql_evenement_suivant_tacite_incompletude, $sql_evenement_suivant_tacite_incompletude_by_id, false);
        // instructeur
        $this->init_select($form, $this->f->db, $maj, null, "instructeur", $sql_instructeur, $sql_instructeur_by_id, true);
        // om_collectivite
        $this->init_select($form, $this->f->db, $maj, null, "om_collectivite", $sql_om_collectivite, $sql_om_collectivite_by_id, false);
        // parcelle
        $this->init_select($form, $this->f->db, $maj, null, "parcelle", $sql_parcelle, $sql_parcelle_by_id, false);
        // parcelle_lot
        $this->init_select($form, $this->f->db, $maj, null, "parcelle_lot", $sql_parcelle_lot, $sql_parcelle_lot_by_id, false);
        // pos
        $this->init_select($form, $this->f->db, $maj, null, "pos", $sql_pos, $sql_pos_by_id, false);
        // quartier
        $this->init_select($form, $this->f->db, $maj, null, "quartier", $sql_quartier, $sql_quartier_by_id, false);
        // geom
        if ($maj == 1 || $maj == 3) {
            $contenu = array();
            $contenu[0] = array("dossier", $this->getParameter("idx"), "0");
            $form->setSelect("geom", $contenu);
        }
        // geom1
        if ($maj == 1 || $maj == 3) {
            $contenu = array();
            $contenu[0] = array("dossier", $this->getParameter("idx"), "1");
            $form->setSelect("geom1", $contenu);
        }
    }


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

    //==================================
    // sous Formulaire 
    //==================================
    

    function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = 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($this->is_in_context_of_foreign_key('autorite_competente', $this->retourformulaire))
                $form->setVal('autorite_competente', $idxformulaire);
            if($this->is_in_context_of_foreign_key('avis_decision', $this->retourformulaire))
                $form->setVal('avis_decision', $idxformulaire);
            if($this->is_in_context_of_foreign_key('division', $this->retourformulaire))
                $form->setVal('division', $idxformulaire);
            if($this->is_in_context_of_foreign_key('dossier_autorisation', $this->retourformulaire))
                $form->setVal('dossier_autorisation', $idxformulaire);
            if($this->is_in_context_of_foreign_key('dossier_instruction_type', $this->retourformulaire))
                $form->setVal('dossier_instruction_type', $idxformulaire);
            if($this->is_in_context_of_foreign_key('instructeur', $this->retourformulaire))
                $form->setVal('instructeur', $idxformulaire);
            if($this->is_in_context_of_foreign_key('om_collectivite', $this->retourformulaire))
                $form->setVal('om_collectivite', $idxformulaire);
            if($this->is_in_context_of_foreign_key('parcelle', $this->retourformulaire))
                $form->setVal('parcelle', $idxformulaire);
            if($this->is_in_context_of_foreign_key('parcelle_lot', $this->retourformulaire))
                $form->setVal('parcelle_lot', $idxformulaire);
            if($this->is_in_context_of_foreign_key('pos', $this->retourformulaire))
                $form->setVal('pos', $idxformulaire);
            if($this->is_in_context_of_foreign_key('quartier', $this->retourformulaire))
                $form->setVal('quartier', $idxformulaire);
        }// fin validation
        if ($validation == 0 and $maj == 0) {
            if($this->is_in_context_of_foreign_key('etat', $this->retourformulaire))
                $form->setVal('etat', $idxformulaire);
            if($this->is_in_context_of_foreign_key('etat', $this->retourformulaire))
                $form->setVal('etat_pendant_incompletude', $idxformulaire);
            if($this->is_in_context_of_foreign_key('evenement', $this->retourformulaire))
                $form->setVal('evenement_suivant_tacite', $idxformulaire);
            if($this->is_in_context_of_foreign_key('evenement', $this->retourformulaire))
                $form->setVal('evenement_suivant_tacite_incompletude', $idxformulaire);
        }// fin validation
        $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 : blocnote
        $this->rechercheTable($this->f->db, "blocnote", "dossier", $id);
        // Verification de la cle secondaire : consultation
        $this->rechercheTable($this->f->db, "consultation", "dossier", $id);
        // Verification de la cle secondaire : demande
        $this->rechercheTable($this->f->db, "demande", "dossier_instruction", $id);
        // Verification de la cle secondaire : document_numerise
        $this->rechercheTable($this->f->db, "document_numerise", "dossier", $id);
        // Verification de la cle secondaire : donnees_techniques
        $this->rechercheTable($this->f->db, "donnees_techniques", "dossier_instruction", $id);
        // Verification de la cle secondaire : dossier_commission
        $this->rechercheTable($this->f->db, "dossier_commission", "dossier", $id);
        // Verification de la cle secondaire : dossier_contrainte
        $this->rechercheTable($this->f->db, "dossier_contrainte", "dossier", $id);
        // Verification de la cle secondaire : dossier_geolocalisation
        $this->rechercheTable($this->f->db, "dossier_geolocalisation", "dossier", $id);
        // Verification de la cle secondaire : dossier_message
        $this->rechercheTable($this->f->db, "dossier_message", "dossier", $id);
        // Verification de la cle secondaire : dossier_parcelle
        $this->rechercheTable($this->f->db, "dossier_parcelle", "dossier", $id);
        // Verification de la cle secondaire : instruction
        $this->rechercheTable($this->f->db, "instruction", "dossier", $id);
        // Verification de la cle secondaire : lien_dossier_demandeur
        $this->rechercheTable($this->f->db, "lien_dossier_demandeur", "dossier", $id);
        // Verification de la cle secondaire : lot
        $this->rechercheTable($this->f->db, "lot", "dossier", $id);
        // Verification de la cle secondaire : rapport_instruction
        $this->rechercheTable($this->f->db, "rapport_instruction", "dossier_instruction", $id);
    }


}

?>
