<?php
/**
* @package ViewReadFile
* @copyright Copyright (c) PT Gamatechno Indonesia
* @Analyzed By Dyan Galih
* @author Didi Zuliansyah
* @version 01
* @startDate 2013-01-01
* @lastUpdate 2013-01-01
* @description Read file in stream
*/

require_once Configuration::Instance()->GetValue('application', 'docroot') . "main/lib/smartRead/smartReadFile.class.php";

class ViewReadFile extends HtmlResponse {

	function TemplateModule() {
	}

	function ProcessRequest() {
		
		$path = Configuration::Instance()->GetValue('application','docroot');
		if($_GET['pid'] == '1') $path = $path.'images/gedung/';
	    elseif($_GET['pid'] == '2') $path = $path.'images/ruang/';
	    elseif($_GET['pid'] == '3') $path = $path.'document/inventarisasi/';
	    else $path = $path.'file/';

      	$_GET = $_GET->AsArray();

      	$file = urldecode($_GET['file']);
      	@$id = $_GET['id'];
      	$realPath = $path.$file;
      	
      	$data = SmartReadFile::Instance()->readFile($realPath,$file); //pathFile, nama output file
      	if($data){
      		echo $data;
      		exit;
      	}else 
      		echo "<script>alert('Data Tidak Ditemukan')</script>";
      
      	exit;
	}

	function ParseTemplate($data = NULL) {
	}
}
?>
