<?php
//$Id$ 
//gen openMairie le 25/03/2024 16:39

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

class reprise_abandon_gen extends om_dbform {

    protected $_absolute_class_name = "reprise_abandon";

    var $table = "reprise_abandon";
    var $clePrimaire = "reprise_abandon";
    var $typeCle = "N";
    var $required_field = array(
        "emplacement",
        "etat",
        "reprise_abandon",
        "statut"
    );
    
    var $foreign_keys_extended = array(
        "emplacement" => array("emplacement", "colombarium", "concession", "depositoire", "enfeu", "ossuaire", "terraincommunal", ),
    );
    
    /**
     *
     * @return string
     */
    function get_default_libelle() {
        return $this->getVal($this->clePrimaire)."&nbsp;".$this->getVal("emplacement");
    }

    /**
     *
     * @return array
     */
    function get_var_sql_forminc__champs() {
        return array(
            "reprise_abandon",
            "emplacement",
            "statut",
            "etat",
            "phase_preli",
            "date_envoi_convo_1",
            "date_constat_pv1",
            "heure_constat_pv1",
            "constat_pv1",
            "personnes_presentes_pv1",
            "date_notification_pv1",
            "date_pv1_affichage_1_debut",
            "date_pv1_affichage_1_fin",
            "date_pv1_affichage_2_debut",
            "date_pv1_affichage_2_fin",
            "date_pv1_affichage_3_debut",
            "date_pv1_affichage_3_fin",
            "date_envoi_convo_2",
            "date_constat_pv2",
            "heure_constat_pv2",
            "constat_pv2",
            "personnes_presentes_pv2",
            "date_notification_pv2",
            "date_pv2_affichage_debut",
            "date_pv2_affichage_fin",
            "arrete",
        );
    }

    /**
     *
     * @return string
     */
    function get_var_sql_forminc__sql_emplacement() {
        return "SELECT emplacement.emplacement, emplacement.nature FROM ".DB_PREFIXE."emplacement ORDER BY emplacement.nature ASC";
    }

    /**
     *
     * @return string
     */
    function get_var_sql_forminc__sql_emplacement_by_id() {
        return "SELECT emplacement.emplacement, emplacement.nature FROM ".DB_PREFIXE."emplacement WHERE emplacement = <idx>";
    }




    function setvalF($val = array()) {
        //affectation valeur formulaire
        if (!is_numeric($val['reprise_abandon'])) {
            $this->valF['reprise_abandon'] = ""; // -> requis
        } else {
            $this->valF['reprise_abandon'] = $val['reprise_abandon'];
        }
        if (!is_numeric($val['emplacement'])) {
            $this->valF['emplacement'] = ""; // -> requis
        } else {
            $this->valF['emplacement'] = $val['emplacement'];
        }
        $this->valF['statut'] = $val['statut'];
        $this->valF['etat'] = $val['etat'];
        if ($val['phase_preli'] == 1 || $val['phase_preli'] == "t" || $val['phase_preli'] == "Oui") {
            $this->valF['phase_preli'] = true;
        } else {
            $this->valF['phase_preli'] = false;
        }
        if ($val['date_envoi_convo_1'] != "") {
            $this->valF['date_envoi_convo_1'] = $this->dateDB($val['date_envoi_convo_1']);
        } else {
            $this->valF['date_envoi_convo_1'] = NULL;
        }
        if ($val['date_constat_pv1'] != "") {
            $this->valF['date_constat_pv1'] = $this->dateDB($val['date_constat_pv1']);
        } else {
            $this->valF['date_constat_pv1'] = NULL;
        }
            $this->valF['heure_constat_pv1'] = $val['heure_constat_pv1'];
            $this->valF['constat_pv1'] = $val['constat_pv1'];
            $this->valF['personnes_presentes_pv1'] = $val['personnes_presentes_pv1'];
        if ($val['date_notification_pv1'] != "") {
            $this->valF['date_notification_pv1'] = $this->dateDB($val['date_notification_pv1']);
        } else {
            $this->valF['date_notification_pv1'] = NULL;
        }
        if ($val['date_pv1_affichage_1_debut'] != "") {
            $this->valF['date_pv1_affichage_1_debut'] = $this->dateDB($val['date_pv1_affichage_1_debut']);
        } else {
            $this->valF['date_pv1_affichage_1_debut'] = NULL;
        }
        if ($val['date_pv1_affichage_1_fin'] != "") {
            $this->valF['date_pv1_affichage_1_fin'] = $this->dateDB($val['date_pv1_affichage_1_fin']);
        } else {
            $this->valF['date_pv1_affichage_1_fin'] = NULL;
        }
        if ($val['date_pv1_affichage_2_debut'] != "") {
            $this->valF['date_pv1_affichage_2_debut'] = $this->dateDB($val['date_pv1_affichage_2_debut']);
        } else {
            $this->valF['date_pv1_affichage_2_debut'] = NULL;
        }
        if ($val['date_pv1_affichage_2_fin'] != "") {
            $this->valF['date_pv1_affichage_2_fin'] = $this->dateDB($val['date_pv1_affichage_2_fin']);
        } else {
            $this->valF['date_pv1_affichage_2_fin'] = NULL;
        }
        if ($val['date_pv1_affichage_3_debut'] != "") {
            $this->valF['date_pv1_affichage_3_debut'] = $this->dateDB($val['date_pv1_affichage_3_debut']);
        } else {
            $this->valF['date_pv1_affichage_3_debut'] = NULL;
        }
        if ($val['date_pv1_affichage_3_fin'] != "") {
            $this->valF['date_pv1_affichage_3_fin'] = $this->dateDB($val['date_pv1_affichage_3_fin']);
        } else {
            $this->valF['date_pv1_affichage_3_fin'] = NULL;
        }
        if ($val['date_envoi_convo_2'] != "") {
            $this->valF['date_envoi_convo_2'] = $this->dateDB($val['date_envoi_convo_2']);
        } else {
            $this->valF['date_envoi_convo_2'] = NULL;
        }
        if ($val['date_constat_pv2'] != "") {
            $this->valF['date_constat_pv2'] = $this->dateDB($val['date_constat_pv2']);
        } else {
            $this->valF['date_constat_pv2'] = NULL;
        }
            $this->valF['heure_constat_pv2'] = $val['heure_constat_pv2'];
            $this->valF['constat_pv2'] = $val['constat_pv2'];
            $this->valF['personnes_presentes_pv2'] = $val['personnes_presentes_pv2'];
        if ($val['date_notification_pv2'] != "") {
            $this->valF['date_notification_pv2'] = $this->dateDB($val['date_notification_pv2']);
        } else {
            $this->valF['date_notification_pv2'] = NULL;
        }
        if ($val['date_pv2_affichage_debut'] != "") {
            $this->valF['date_pv2_affichage_debut'] = $this->dateDB($val['date_pv2_affichage_debut']);
        } else {
            $this->valF['date_pv2_affichage_debut'] = NULL;
        }
        if ($val['date_pv2_affichage_fin'] != "") {
            $this->valF['date_pv2_affichage_fin'] = $this->dateDB($val['date_pv2_affichage_fin']);
        } else {
            $this->valF['date_pv2_affichage_fin'] = NULL;
        }
        if ($val['arrete'] == "") {
            $this->valF['arrete'] = NULL;
        } else {
            $this->valF['arrete'] = $val['arrete'];
        }
    }

    //=================================================
    //cle primaire automatique [automatic primary key]
    //==================================================

    function setId(&$dnu1 = null) {
    //numero automatique
        $this->valF[$this->clePrimaire] = $this->f->db->nextId(DB_PREFIXE.$this->table);
    }

    function setValFAjout($val = array()) {
    //numero automatique -> pas de controle ajout cle primaire
    }

    function verifierAjout($val = array(), &$dnu1 = null) {
    //numero automatique -> pas de verfication de cle primaire
    }

    //==========================
    // 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("reprise_abandon", "hidden");
            if ($this->is_in_context_of_foreign_key("emplacement", $this->retourformulaire)) {
                $form->setType("emplacement", "selecthiddenstatic");
            } else {
                $form->setType("emplacement", "select");
            }
            $form->setType("statut", "text");
            $form->setType("etat", "text");
            $form->setType("phase_preli", "checkbox");
            $form->setType("date_envoi_convo_1", "date");
            $form->setType("date_constat_pv1", "date");
            $form->setType("heure_constat_pv1", "text");
            $form->setType("constat_pv1", "textarea");
            $form->setType("personnes_presentes_pv1", "textarea");
            $form->setType("date_notification_pv1", "date");
            $form->setType("date_pv1_affichage_1_debut", "date");
            $form->setType("date_pv1_affichage_1_fin", "date");
            $form->setType("date_pv1_affichage_2_debut", "date");
            $form->setType("date_pv1_affichage_2_fin", "date");
            $form->setType("date_pv1_affichage_3_debut", "date");
            $form->setType("date_pv1_affichage_3_fin", "date");
            $form->setType("date_envoi_convo_2", "date");
            $form->setType("date_constat_pv2", "date");
            $form->setType("heure_constat_pv2", "text");
            $form->setType("constat_pv2", "textarea");
            $form->setType("personnes_presentes_pv2", "textarea");
            $form->setType("date_notification_pv2", "date");
            $form->setType("date_pv2_affichage_debut", "date");
            $form->setType("date_pv2_affichage_fin", "date");
            $form->setType("arrete", "text");
        }

        // MDOE MODIFIER
        if ($maj == 1 || $crud == 'update') {
            $form->setType("reprise_abandon", "hiddenstatic");
            if ($this->is_in_context_of_foreign_key("emplacement", $this->retourformulaire)) {
                $form->setType("emplacement", "selecthiddenstatic");
            } else {
                $form->setType("emplacement", "select");
            }
            $form->setType("statut", "text");
            $form->setType("etat", "text");
            $form->setType("phase_preli", "checkbox");
            $form->setType("date_envoi_convo_1", "date");
            $form->setType("date_constat_pv1", "date");
            $form->setType("heure_constat_pv1", "text");
            $form->setType("constat_pv1", "textarea");
            $form->setType("personnes_presentes_pv1", "textarea");
            $form->setType("date_notification_pv1", "date");
            $form->setType("date_pv1_affichage_1_debut", "date");
            $form->setType("date_pv1_affichage_1_fin", "date");
            $form->setType("date_pv1_affichage_2_debut", "date");
            $form->setType("date_pv1_affichage_2_fin", "date");
            $form->setType("date_pv1_affichage_3_debut", "date");
            $form->setType("date_pv1_affichage_3_fin", "date");
            $form->setType("date_envoi_convo_2", "date");
            $form->setType("date_constat_pv2", "date");
            $form->setType("heure_constat_pv2", "text");
            $form->setType("constat_pv2", "textarea");
            $form->setType("personnes_presentes_pv2", "textarea");
            $form->setType("date_notification_pv2", "date");
            $form->setType("date_pv2_affichage_debut", "date");
            $form->setType("date_pv2_affichage_fin", "date");
            $form->setType("arrete", "text");
        }

        // MODE SUPPRIMER
        if ($maj == 2 || $crud == 'delete') {
            $form->setType("reprise_abandon", "hiddenstatic");
            $form->setType("emplacement", "selectstatic");
            $form->setType("statut", "hiddenstatic");
            $form->setType("etat", "hiddenstatic");
            $form->setType("phase_preli", "hiddenstatic");
            $form->setType("date_envoi_convo_1", "hiddenstatic");
            $form->setType("date_constat_pv1", "hiddenstatic");
            $form->setType("heure_constat_pv1", "hiddenstatic");
            $form->setType("constat_pv1", "hiddenstatic");
            $form->setType("personnes_presentes_pv1", "hiddenstatic");
            $form->setType("date_notification_pv1", "hiddenstatic");
            $form->setType("date_pv1_affichage_1_debut", "hiddenstatic");
            $form->setType("date_pv1_affichage_1_fin", "hiddenstatic");
            $form->setType("date_pv1_affichage_2_debut", "hiddenstatic");
            $form->setType("date_pv1_affichage_2_fin", "hiddenstatic");
            $form->setType("date_pv1_affichage_3_debut", "hiddenstatic");
            $form->setType("date_pv1_affichage_3_fin", "hiddenstatic");
            $form->setType("date_envoi_convo_2", "hiddenstatic");
            $form->setType("date_constat_pv2", "hiddenstatic");
            $form->setType("heure_constat_pv2", "hiddenstatic");
            $form->setType("constat_pv2", "hiddenstatic");
            $form->setType("personnes_presentes_pv2", "hiddenstatic");
            $form->setType("date_notification_pv2", "hiddenstatic");
            $form->setType("date_pv2_affichage_debut", "hiddenstatic");
            $form->setType("date_pv2_affichage_fin", "hiddenstatic");
            $form->setType("arrete", "hiddenstatic");
        }

        // MODE CONSULTER
        if ($maj == 3 || $crud == 'read') {
            $form->setType("reprise_abandon", "static");
            $form->setType("emplacement", "selectstatic");
            $form->setType("statut", "static");
            $form->setType("etat", "static");
            $form->setType("phase_preli", "checkboxstatic");
            $form->setType("date_envoi_convo_1", "datestatic");
            $form->setType("date_constat_pv1", "datestatic");
            $form->setType("heure_constat_pv1", "static");
            $form->setType("constat_pv1", "textareastatic");
            $form->setType("personnes_presentes_pv1", "textareastatic");
            $form->setType("date_notification_pv1", "datestatic");
            $form->setType("date_pv1_affichage_1_debut", "datestatic");
            $form->setType("date_pv1_affichage_1_fin", "datestatic");
            $form->setType("date_pv1_affichage_2_debut", "datestatic");
            $form->setType("date_pv1_affichage_2_fin", "datestatic");
            $form->setType("date_pv1_affichage_3_debut", "datestatic");
            $form->setType("date_pv1_affichage_3_fin", "datestatic");
            $form->setType("date_envoi_convo_2", "datestatic");
            $form->setType("date_constat_pv2", "datestatic");
            $form->setType("heure_constat_pv2", "static");
            $form->setType("constat_pv2", "textareastatic");
            $form->setType("personnes_presentes_pv2", "textareastatic");
            $form->setType("date_notification_pv2", "datestatic");
            $form->setType("date_pv2_affichage_debut", "datestatic");
            $form->setType("date_pv2_affichage_fin", "datestatic");
            $form->setType("arrete", "static");
        }

    }


    function setOnchange(&$form, $maj) {
    //javascript controle client
        $form->setOnchange('reprise_abandon','VerifNum(this)');
        $form->setOnchange('emplacement','VerifNum(this)');
        $form->setOnchange('date_envoi_convo_1','fdate(this)');
        $form->setOnchange('date_constat_pv1','fdate(this)');
        $form->setOnchange('date_notification_pv1','fdate(this)');
        $form->setOnchange('date_pv1_affichage_1_debut','fdate(this)');
        $form->setOnchange('date_pv1_affichage_1_fin','fdate(this)');
        $form->setOnchange('date_pv1_affichage_2_debut','fdate(this)');
        $form->setOnchange('date_pv1_affichage_2_fin','fdate(this)');
        $form->setOnchange('date_pv1_affichage_3_debut','fdate(this)');
        $form->setOnchange('date_pv1_affichage_3_fin','fdate(this)');
        $form->setOnchange('date_envoi_convo_2','fdate(this)');
        $form->setOnchange('date_constat_pv2','fdate(this)');
        $form->setOnchange('date_notification_pv2','fdate(this)');
        $form->setOnchange('date_pv2_affichage_debut','fdate(this)');
        $form->setOnchange('date_pv2_affichage_fin','fdate(this)');
    }
    /**
     * Methode setTaille
     */
    function setTaille(&$form, $maj) {
        $form->setTaille("reprise_abandon", 11);
        $form->setTaille("emplacement", 11);
        $form->setTaille("statut", 30);
        $form->setTaille("etat", 30);
        $form->setTaille("phase_preli", 1);
        $form->setTaille("date_envoi_convo_1", 12);
        $form->setTaille("date_constat_pv1", 12);
        $form->setTaille("heure_constat_pv1", 8);
        $form->setTaille("constat_pv1", 80);
        $form->setTaille("personnes_presentes_pv1", 80);
        $form->setTaille("date_notification_pv1", 12);
        $form->setTaille("date_pv1_affichage_1_debut", 12);
        $form->setTaille("date_pv1_affichage_1_fin", 12);
        $form->setTaille("date_pv1_affichage_2_debut", 12);
        $form->setTaille("date_pv1_affichage_2_fin", 12);
        $form->setTaille("date_pv1_affichage_3_debut", 12);
        $form->setTaille("date_pv1_affichage_3_fin", 12);
        $form->setTaille("date_envoi_convo_2", 12);
        $form->setTaille("date_constat_pv2", 12);
        $form->setTaille("heure_constat_pv2", 8);
        $form->setTaille("constat_pv2", 80);
        $form->setTaille("personnes_presentes_pv2", 80);
        $form->setTaille("date_notification_pv2", 12);
        $form->setTaille("date_pv2_affichage_debut", 12);
        $form->setTaille("date_pv2_affichage_fin", 12);
        $form->setTaille("arrete", 30);
    }

    /**
     * Methode setMax
     */
    function setMax(&$form, $maj) {
        $form->setMax("reprise_abandon", 11);
        $form->setMax("emplacement", 11);
        $form->setMax("statut", 255);
        $form->setMax("etat", 255);
        $form->setMax("phase_preli", 1);
        $form->setMax("date_envoi_convo_1", 12);
        $form->setMax("date_constat_pv1", 12);
        $form->setMax("heure_constat_pv1", 8);
        $form->setMax("constat_pv1", 6);
        $form->setMax("personnes_presentes_pv1", 6);
        $form->setMax("date_notification_pv1", 12);
        $form->setMax("date_pv1_affichage_1_debut", 12);
        $form->setMax("date_pv1_affichage_1_fin", 12);
        $form->setMax("date_pv1_affichage_2_debut", 12);
        $form->setMax("date_pv1_affichage_2_fin", 12);
        $form->setMax("date_pv1_affichage_3_debut", 12);
        $form->setMax("date_pv1_affichage_3_fin", 12);
        $form->setMax("date_envoi_convo_2", 12);
        $form->setMax("date_constat_pv2", 12);
        $form->setMax("heure_constat_pv2", 8);
        $form->setMax("constat_pv2", 6);
        $form->setMax("personnes_presentes_pv2", 6);
        $form->setMax("date_notification_pv2", 12);
        $form->setMax("date_pv2_affichage_debut", 12);
        $form->setMax("date_pv2_affichage_fin", 12);
        $form->setMax("arrete", 100);
    }


    function setLib(&$form, $maj) {
    //libelle des champs
        $form->setLib('reprise_abandon', __('reprise_abandon'));
        $form->setLib('emplacement', __('emplacement'));
        $form->setLib('statut', __('statut'));
        $form->setLib('etat', __('etat'));
        $form->setLib('phase_preli', __('phase_preli'));
        $form->setLib('date_envoi_convo_1', __('date_envoi_convo_1'));
        $form->setLib('date_constat_pv1', __('date_constat_pv1'));
        $form->setLib('heure_constat_pv1', __('heure_constat_pv1'));
        $form->setLib('constat_pv1', __('constat_pv1'));
        $form->setLib('personnes_presentes_pv1', __('personnes_presentes_pv1'));
        $form->setLib('date_notification_pv1', __('date_notification_pv1'));
        $form->setLib('date_pv1_affichage_1_debut', __('date_pv1_affichage_1_debut'));
        $form->setLib('date_pv1_affichage_1_fin', __('date_pv1_affichage_1_fin'));
        $form->setLib('date_pv1_affichage_2_debut', __('date_pv1_affichage_2_debut'));
        $form->setLib('date_pv1_affichage_2_fin', __('date_pv1_affichage_2_fin'));
        $form->setLib('date_pv1_affichage_3_debut', __('date_pv1_affichage_3_debut'));
        $form->setLib('date_pv1_affichage_3_fin', __('date_pv1_affichage_3_fin'));
        $form->setLib('date_envoi_convo_2', __('date_envoi_convo_2'));
        $form->setLib('date_constat_pv2', __('date_constat_pv2'));
        $form->setLib('heure_constat_pv2', __('heure_constat_pv2'));
        $form->setLib('constat_pv2', __('constat_pv2'));
        $form->setLib('personnes_presentes_pv2', __('personnes_presentes_pv2'));
        $form->setLib('date_notification_pv2', __('date_notification_pv2'));
        $form->setLib('date_pv2_affichage_debut', __('date_pv2_affichage_debut'));
        $form->setLib('date_pv2_affichage_fin', __('date_pv2_affichage_fin'));
        $form->setLib('arrete', __('arrete'));
    }
    /**
     *
     */
    function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) {

        // emplacement
        $this->init_select(
            $form, 
            $this->f->db,
            $maj,
            null,
            "emplacement",
            $this->get_var_sql_forminc__sql("emplacement"),
            $this->get_var_sql_forminc__sql("emplacement_by_id"),
            false
        );
    }


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

    function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) {
        $this->retourformulaire = $retourformulaire;
        if($validation == 0) {
            if($this->is_in_context_of_foreign_key('emplacement', $this->retourformulaire))
                $form->setVal('emplacement', $idxformulaire);
        }// fin validation
        $this->set_form_default_values($form, $maj, $validation);
    }// fin setValsousformulaire

    //==================================
    // cle secondaire
    //==================================
    

}
