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

if ( $boolean_login ){
	$status   		   = '201' ;

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

    $query             = "SELECT a.announcement_id, a.is_hide, a.file, a.created_at, b.title FROM announcement a 
                          LEFT JOIN announcement_translation b ON ( a.announcement_id = b.announcement_id )
                          WHERE a.deleted_at IS NULL AND a.status = 'active' AND b.lang = '".$array['lang']."' AND a.branch LIKE '%/".$array['branch_id']."/%' " . $search_query ;
    $mysqli_query      = $mysqli->query( $query . " ORDER BY a.created_at DESC LIMIT " . getLimit( $current ) ) ;

    if ( $mysqli_query->num_rows > 0 ){

        $status        = '200' ;

        $list          = [] ;
        while ( $row   = $mysqli_query->fetch_assoc() ){
            $row['id']      = dataFilter( $row['announcement_id'] ) ;
            $row['title']   = ( $row['is_hide'] == 'no' ? dataFilter( $row['title'] ) : '' ) ;
            $row['file']    = ( $row['file'] != '' ? PATH.'uploads/Announcement/b/'.$row['file'] : '' ) ;
            $list[]         = $row ;
        }

        $data['list']  = $list ;

    }
}

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