<?php



use app\libraries\DateHelper;

use app\libraries\ICSParser;

use app\libraries\TenantHelper;



defined('BASEPATH') or exit('No direct script access allowed');



require_once __DIR__ . '/../backend/Event_index_calendar.php';

class Event_calendar extends MY_ApiController

{

    use Event_index_calendar;



    public function __construct()

    {

        parent::__construct();

    }



    public function reload()

    {

        $res = $this->calendar();



        echo $this->respond([

            'data' => [

                '_events' => $res['events'],

                '_resources' => $res['resources'],

                '_action_' => ''

            ]

        ]);

    }



    public function teacher()

    {

        $this->load->model('Course_model');



        $this->is_get();

        $params = $this->input->get();



        $this->Course_model->setTenantNo($params['tenant_no'], true);

        $res = $this->Course_model->teacher_calendar();



        echo $this->respond(['activities' => $res]);

    }



    public function listing_students()

    {

        $this->load->model('Course_model');



        $this->is_get();

        $params = $this->input->get();



        $tenantNo = $params['tenant_no'];



        TenantHelper::setTenant($tenantNo);

        $this->Course_model->setTenantNo($tenantNo, true);

        $res = $this->Course_model->listing_students($params['timeslot_id']);



        echo $this->respond(['activities' => $res]);

    }

}

