<?php
$must_login             = true ;
$require_path           = '../../../' ;
$require_sub            = '../../' ;
require( $require_sub.'header.php' ) ;

$list                   = [] ;
if ( $boolean_login ){
    $status             = '201' ;

    $searchyear         = ( $array['searchyear'] != '' ? $array['searchyear'] : date("Y", time()) ) ;

    $search_query       = " AND holiday_year = '".$searchyear."'" ;
    if ( $array['search'] != '' ){
        $search_query  .= " AND holiday_name LIKE '%".$array['search']."%'" ;
    }

    $query              = "SELECT * FROM setting_holiday
                           WHERE deleted_at IS NULL " . $search_query ;
    $mysqli_query       = $mysqli->query( $query . " ORDER BY holiday_date ASC" ) ;

    if ( $mysqli_query->num_rows > 0 ){

        $status         = '200' ;

        while ( $row    = $mysqli_query->fetch_assoc() ){

            $set_status     = 'current' ;
            if ( $row['holiday_date'] > date( "Y-m-d", time() ) ){
                $set_status = 'future' ;
            }elseif ( $row['holiday_date'] < date( "Y-m-d", time() ) ){
                $set_status = 'passed' ;
            }
            $row['status']  = $set_status ;

            $list[]     = $row ;
        }

    }
}

$data['list']           = $list ;

require( $require_sub.'footer.php' ) ;
?>