<?php 
$document_id = '';
$arr = [];
$status = 'failed';
$remark = '';
if(isset($_GET['document_id'])&&!empty($_GET['document_id'])){
    $document_id = $_GET['document_id'];
    $sql = "SELECT * FROM publication_version t1 
        INNER JOIN publication_document t2 ON t1.document_id=t2.document_id INNER JOIN publication_document_translation t3 ON t2.document_translation_parent_id=t3.document_id WHERE t2.document_id=".$document_id;
    $model = Yii::$app->db->createCommand($sql)->queryAll();
    
    if(!empty($model)){
        foreach($model as $row){
            $status = 'success';
            $arr2 = [];
            $arr2['language'] = $row['document_translation_language'];
            $arr2['title'] = $row['document_translation_title'];
            $arr2['content'] = $row['document_translation_content'];
            
           $arr2['category'] = $row['document_category'];
            $arr2['subcategory'] = $row['document_subcategory'];
            $arr2['status'] = $row['document_status'];
            $arr2['document_date'] = $row['document_date'];
            $arr2['sorting'] = $row['document_sorting'];
            $arr2['thumbnail'] = $row['document_image'];
            $arr2['version_no'] = $row['version_no'];
            $arr2['version_title'] = $row['version_title'];
            $arr2['version_content'] = $row['version_content'];
            $arr2['version_img'] = $row['version_img'];
            $arr2['version_pdf'] = $row['version_pdf'];
            $arr2['version_zip'] = $row['version_zip'];
            
            $arr[] = $arr2;
        }
    }else{
        $remark = 'Record not found';
    }
    
}else{
    $remark = 'Please specify the document_id using $_GET method';
}
echo json_encode(['result_status'=>$status,'remark'=>$remark,'data'=>$arr]);