<?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.formsubmissionid, a.submission_type, a.file, a.created_at, b.title FROM formsubmission a
                          LEFT JOIN formsubmission_translation b ON ( a.formsubmissionid = b.formsubmissionid )
                          WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' " . $search_query ;
    $mysqli_query      = $mysqli->query( $query . " ORDER BY a.created_at ASC LIMIT " . getLimit( $current ) ) ;

    if ( $mysqli_query->num_rows > 0 ){

        $status        = '200' ;

        $list          = [] ;
        while ( $row   = $mysqli_query->fetch_assoc() ){
            $row['formsubmissionid'] = dataFilter( $row['formsubmissionid'] ) ;
            $row['submission_type']  = dataFilter( $row['submission_type'] ) ;
            $row['title']            = dataFilter( $row['title'] ) ;
            $row['content']          = dataFilter( $row['content'] ) ;
            $row['file']             = ( $row['file'] != '' ? PATH.'uploads/FormSubmissionCategory/b/'.$row['file'] : '' ) ;
            $list[]                  = $row ;
        }

        $data['list']  = $list ;

    }
}

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