<?php
// +-------------------------------------------------+
//  2002-2011 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: export_records.class.php,v 1.1.4.3 2026/03/09 15:00:26 dgoron Exp $

if (stristr($_SERVER['REQUEST_URI'], ".class.php")) die("no access");

global $class_path;
require_once ($class_path."/export/export_entities.class.php");

class export_records extends export_entities {
	
    protected static $custom_fields_prefix = 'notices';
    
    public static function _get_query_publisher($id) {
        return "select * from publishers where ed_id=".intval($id);
    }
    
    public static function _get_calculated_object_publisher($object) {
        $calculated = [];
        $calculated['ed_name'] = $object->ed_name;
        if ($object->ed_ville != '') {
            $calculated['ed_ville'] = $object->ed_ville;
        }
        return $calculated;
    }
    
    public static function _get_query_collection($id) {
        return "select * from collections where collection_id=".intval($id);
    }
    
    public static function _get_calculated_object_collection($object) {
        return ['collection_name' => $object->collection_name];
    }
    
    public static function _get_query_sub_collection($id) {
        return "select * from sub_collections where sub_coll_id=".intval($id);
    }
    
    public static function _get_calculated_object_sub_collection($object) {
        return ['sub_coll_name' => $object->sub_coll_name];
    }
    
    public static function _get_query_serie($id) {
        return "select serie_name from series where serie_id=".intval($id);
    }
    
    public static function _get_calculated_object_serie($object) {
        return ['serie_name' => $object->serie_name];
    }
    
    public static function _get_query_indexint($id) {
        return "select * from indexint where indexint_id=".intval($id);
    }
    
    public static function _get_calculated_object_indexint($object) {
        return [
            'indexint_name' => $object->indexint_name,
            'indexint_comment' => $object->indexint_comment
        ];
    }
    
    public static function _get_query_notice_statut($id) {
        return "select statut,gestion_libelle from notices join notice_statut on id_notice_statut = statut where notice_id = ".intval($id);
    }
    
    public static function _get_calculated_object_notice_statut($object) {
        return ['gestion_libelle' => $object->gestion_libelle];
    }
    
    public static function _get_query_origine_notice($id) {
        return "select orinot_nom from notices, origine_notice where notice_id=".intval($id)." and origine_catalogage=orinot_id";
    }
    
    public static function _get_calculated_object_origine_notice($object) {
        return ['orinot_nom' => $object->orinot_nom];
    }
    
    public static function _get_query_notices_langues($id) {
        return "select type_langue,code_langue from notices_langues where num_notice='".intval($id)."' order by ordre_langue";
    }
    
    public static function _get_query_authors($id) {
        return "SELECT author_name, author_rejete, author_type, responsability_fonction, responsability_type
        FROM authors, responsability where responsability_notice=".intval($id)." and responsability_author=author_id
        ORDER BY responsability_type, responsability_ordre, author_type, responsability_fonction";
    }
    
    public static function _get_calculated_object_authors($object) {
        $calculated = [];
        $calculated['author_name'] = $object->author_name;
        $calculated['author_rejete'] = $object->author_rejete;
        $calculated['author_type'] = $object->author_type;
        if ($object->responsability_fonction) {
            $calculated['responsability_fonction'] = $object->responsability_fonction;
        }
        if ($object->responsability_type) {
            $calculated['responsability_type'] = $object->responsability_type;
        }
        return $calculated;
    }
    
    public static function _get_query_categories($id) {
        return "SELECT libelle_categorie FROM categories, notices_categories
        WHERE notcateg_notice=".intval($id)." AND categories.num_noeud = notices_categories.num_noeud
        ORDER BY ordre_categorie, libelle_categorie ";
    }
    
    public static function _get_calculated_object_categories($object) {
        if ($object->libelle_categorie) {
            return ['libelle_categorie' => $object->libelle_categorie];
        }
        return [];
    }
}
