<?php

namespace App\Controllers\home;

use App\Controllers\BaseController;
use App\Models\Home\HomeModel;

class Home extends BaseController
{
    private $homeModel;

    private $sdate = '';
    private $edate = '';
    public function __construct()
    {

        $this->sdate = date('Y-m-d', strtotime('-1 month'));
        $this->edate = date('Y-m-d');

        $this->homeModel = new HomeModel();
    }

    public function index()
    {

    }

    public function dashboard(): string
    {

        $notice = $this->homeModel->getNoticeList();
        $statistics = $this->homeModel->getHomeStatistics($this->sdate, $this->edate);

        $this->data['menus'] = $this->data;
        $this->data['notice'] = $notice;
        $this->data['statistics'] = $statistics;

        return view('pages/home/dashboard', $this->data);
    }

    // 실적조회
    public function viewStatData()
    {
        $params = [
            's_date' => $this->request->getGet('s_date'),
            'usr_sq' => session('usr_sq'),
        ];

        $data = $this->homeModel->viewStatData($params);

        return $this->response->setJSON($data);
    }

    // 팩스건수 조회    
    public function getHomeFaxCount()
    {

        $data = $this->homeModel->getHomeFaxCount();

        return $this->response->setJSON($data);
    }
}
