<?php
/**
 * Ce script définit la classe 'operation_archive'.
 *
 * @package opencimetiere
 * @version SVN : $Id$
 */

require_once "../gen/obj/operation_archive.class.php";

/**
 * Définition de la classe 'operation_archive' (om_dbform).
 */
class operation_archive extends operation_archive_gen {

    /**
     * Définition des actions disponibles sur la classe.
     *
     * @return void
     */
    function init_class_actions() {
        parent::init_class_actions();
        // ACTION - 001 - modifier
        // -> modification impossible
        unset($this->class_actions[1]);
        // ACTION - 002 - supprimer
        // -> suppression impossible
        unset($this->class_actions[2]);
    }

    /**
     *
     * @return array
     */
    function get_var_sql_forminc__champs() {
        return array(
            "operation_archive.operation",
            "numdossier",
            "date",
            "heure",
            "emplacement_archive.famille as emplacement",
            "societe_coordonnee",
            "pf_coordonnee",
            "etat",
            "categorie",
            "CONCAT_WS(' ',
                '(' ||
                    CASE WHEN autorisation_archive.nature IS NOT NULL AND autorisation_archive.nature = 'ayantdroit'
                        THEN
                            'ayant-droit'
                        ELSE
                            autorisation_archive.nature
                    END
                || ')',
                titre_de_civilite.libelle,
                CASE WHEN autorisation_archive.marital IS NOT NULL AND autorisation_archive.marital != ''
                    THEN
                        autorisation_archive.marital
                    ELSE
                        autorisation_archive.nom
                END,
                autorisation_archive.prenom
            ) as demandeur",
            "particulier",
            'CASE WHEN emplacement_transfert_archive.famille IS NOT NULL THEN emplacement_transfert_archive.famille ELSE emplacement_transfert.famille END  as "'.__("emplacement_transfert").'"',
            "operation_archive.observation",
            "consigne_acces",
            "prive",
            "consigne_acces_transfert",
            "edition_operation",
        );
    }


    /**
     * GETTER_FORMINC - tableSelect.
     *
     * @return string
     */
    function get_var_sql_forminc__tableSelect() {
        return sprintf(
            '%1$soperation_archive
            INNER JOIN
                %1$semplacement_archive
                    ON operation_archive.emplacement = emplacement_archive.emplacement
            INNER JOIN
                %1$soperation_defunt_archive
                    ON operation_archive.operation = operation_defunt_archive.operation
            LEFT JOIN
                %1$semplacement AS emplacement_transfert
                    ON operation_archive.emplacement_transfert = emplacement_transfert.emplacement
            LEFT JOIN
                %1$semplacement_archive AS emplacement_transfert_archive
                    ON operation_archive.emplacement_transfert = emplacement_transfert_archive.emplacement
            LEFT JOIN
                %1$sautorisation_archive
                    ON autorisation_archive.autorisation = operation_archive.demandeur
            LEFT JOIN
                %1$stitre_de_civilite
                    ON autorisation_archive.titre = titre_de_civilite.titre_de_civilite',
            DB_PREFIXE
        );
    }
}
