<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * Simulatore contabilità
 *
 * @package    mod_mtcontabilita
 * @copyright  2026 Mediatouch 2000 Srl <https://www.mediatouch.it>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @author     Marco Cappuccio <m.cappuccio@mediatouch.it>
 */

declare(strict_types=1);

namespace mod_mtcontabilita\reportbuilder\datasource;

use mod_mtcontabilita\reportbuilder\local\entities\mtcontabilita_list;
use core_reportbuilder\datasource;

/**
 * mtlist class
 */
class mtlist extends datasource {

    /**
     * get name
     */
    public static function get_name(): string {
        return get_string('mtlist', 'mtcontabilita');
    }

    /**
     * initialise
     */
    protected function initialise(): void {
        $categoryentity = new mtcontabilita_list();

        $mtalias = $categoryentity->get_table_alias('mtcontabilita_list');
        // $contextalias = $categoryentity->get_table_alias('context');

        $this->set_main_table('mtcontabilita_list', $mtalias);
        $this->add_entity($categoryentity);
        // Add all elements from entities to be available in custom reports.
        $this->add_all_from_entities();
    }

    /**
     * get columns
     */
    public function get_default_columns(): array {
        return [
            'mtcontabilita_list:name',
            'mtcontabilita_list:nature',
            'mtcontabilita_list:scheme',
        ];
    }

    /**
     * get sorting
     */
    public function get_default_column_sorting(): array {
        return [
            'mtcontabilita_list:name' => SORT_ASC,
        ];
    }

    /**
     * get filter
     */
    public function get_default_filters(): array {
        return [
            'mtcontabilita_list:name',
        ];
    }

    /**
     * get condition
     */
    public function get_default_conditions(): array {
        return [];
    }
}
