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

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

    $search_query          = '' ;
    $search_query         .= " AND catalog_id = '".$array['id']."'" ;

    $query                 = "SELECT catalog_id, title, content, view_format, file, file_type, video_url, created_at FROM catalog
                              WHERE deleted_at IS NULL " . $search_query ;
    $mysqli_query          = $mysqli->query( $query . " ORDER BY created_at DESC LIMIT " . getLimit( $current ) ) ;

    if ( $mysqli_query->num_rows > 0 ){

        $status            = '200' ;
        $row               = $mysqli_query->fetch_assoc() ;

        $file              = '' ;
        if ( $row['file'] != '' ){
            if ( $row['file_type'] == 'pdf' ){
                $file      = PATH.'uploads/Catalog/'.$row['file'] ;
            }else{
                $file      = PATH.'uploads/Catalog/b/'.$row['file'] ;
            }
        }

        $row['id']         = dataFilter( $row['catalog_id'] ) ;
        $row['title']      = dataFilter( $row['title'] ) ;
        $row['content']    = dataFilter( $row['content'] ) ;
        $row['file']       = $file ;
        $row['created_at'] = dataFilter( $row['created_at'] ) ;

        $data['list']      = $row ;
    }
}

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