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

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

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

    $query                 = "SELECT a.form_id, a.file, a.file_type, a.created_at, b.title FROM form a
                              LEFT JOIN form_translation b ON ( a.form_id = b.form_id )
                              WHERE a.deleted_at IS NULL AND b.lang = '".$array['lang']."' AND ( ( a.receiver_type IN ( '0' ) ) OR ( a.receiver_type IN ( '1', '2' ) AND a.staff_id LIKE '%/".$staff_info['staff_id']."/%' ) ) " . $search_query ;
    $mysqli_query          = $mysqli->query( $query ) ;

    if ( $mysqli_query->num_rows > 0 ){

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

        $file              = '' ;
        if ( $row['file'] != '' ){
            if ( $row['file_type'] == 'pdf' || $row['file_type'] == 'xls' || $row['file_type'] == 'xlsx' || $row['file_type'] == 'doc' || $row['file_type'] == 'docx' ){
                $file      = PATH.'uploads/Form/'.$row['file'] ;
            }else{
                $file      = PATH.'uploads/Form/b/'.$row['file'] ;
            }
        }

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

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

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