<?php
/**
* @package : ViewImportBmn
* @copyright : Copyright (c) PT Gamatechno Indonesia
* @Analyzed By : Nanang Ruswianto
* @author : Didi Zuliansyah
* @version : 01
* @startDate : 2013-01-01
* @lastUpdate : 2013-01-01
* @description : Class view import bmn
*/
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/'.Dispatcher::Instance()->mModule.'/business/importBmn'.GTFWConfiguration::GetValue('application','university_code').'.class.php';

class ViewImportBmn extends HtmlResponse {

	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/'.Dispatcher::Instance()->mModule.'/template');
		$this->SetTemplateFile('view_import_bmn.html');
	}

	function ProcessRequest() {
		@$msg = Messenger::Instance()->Receive(__FILE__);
		@$this->Data = $msg[0][0];
		@$this->Pesan = $msg[0][1];
		@$this->css = $msg[0][2];
		
		$univCode = GTFWConfiguration::GetValue('application','university_code');
		$dynClass = 'importBmn'.$univCode;
		$Obj = new $dynClass();
		
		$isFirstConvertion = $Obj->countInventarisasiDetail();
		if((int)$isFirstConvertion == 0){
			$status = 'Data gtAset21 masih kosong';
			$action = '<b>Konversi database SIMAKBMN ke database gtAset21</b>';
		}else{
			$status = 'Data gtAset21 sudah menggunakan data konversi';
			$action = '<b>Update database gtAset21 dengan SIMAKBMN terbaru</b>';
		}

		$return['status'] = $status;
		$return['action'] = $action;
		return $return;
	}

	function ParseTemplate($data = NULL) {
		if($this->Pesan){
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $this->Pesan);
			$this->mrTemplate->AddVar('warning_box', 'CLASS_PESAN', $this->css);
		}
		
		$urlAction = Dispatcher::Instance()->GetUrl(Dispatcher::Instance()->mModule, 'ImportBmn', 'do', 'json');
		$this->mrTemplate->AddVar('content', 'STATUS_IMPORT', $data['status']);
		$this->mrTemplate->AddVar('content', 'ACTION', $data['action']);
		$this->mrTemplate->AddVar('content', 'URL_ACTION', $urlAction);
	}
}
?>