<?php

class calendar extends datatable
{
    protected static $table = array(
        "name" => "mis_calendar",
        "primary" => "id"
    );

    protected static $data = array(

        "created_by" => [
            "locked" => true,
            "default" => "#user"
        ],
        "created_at" => [
            "locked" => true,
            "default" => "#timestamp"
        ],
        "duedate" => [
            "validators" => ["date"],
            "default" => "#date"
        ],
        "note" => [],
        "state" => []
    );

    public static function due_today_count()
    {

        return 5;

        $query = self::query("select count(*) as count from mis_calendar where created_by = :user and DATE(duedate) = :today", ["user" => auth::user_id(), "today" => date("Y-m-d")]);

        if ($query['success'] && $query['count'] > 0) {
            return $query['data'][0]["count"];
        } else {
            return false;
        }
    }
}
