<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/tahap_penerimaan/business/AppTahapPenerimaan.class.php';

class ViewInputTahapPenerimaan extends HtmlResponse {

	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/tahap_penerimaan/template');
		$this->SetTemplateFile('input_tahap_penerimaan.html');
	}
	
	function ProcessRequest() {
		$idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
		$jurusanObj = new AppTahapPenerimaan();
                 
		$msg = Messenger::Instance()->Receive(__FILE__);


		$dataJurusan = $jurusanObj->GetDataJurusanSmtaById($idDec);
      
      $return['pesan']=$msg[0][1];
      $return['data']=$msg[0][0];
		$return['decDataId'] = $idDec;
		$return['dataJurusan'] = $dataJurusan;
		return $return;
	}

	function ParseTemplate($data = NULL) {
      $siaConn=$data['siaConn'];
      $umConn=$data['umConn'];
      
      if($siaConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
			$this->mrTemplate->AddVar('warning', 'ISI_PESAN_SIA', 'Gagal Menghubungi SI Akademik');
         $url_kembali=Dispatcher::Instance()->GetUrl('tahap_penerimaan', 'TahapPenerimaan', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI_SIA',$url_kembali );
      }elseif($siaConn==true){
         $this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'YES');
      }
      if($umConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
			$this->mrTemplate->AddVar('warning', 'ISI_PESAN_SIA', 'Gagal Menghubungi SI Admisi');
         $url_kembali=Dispatcher::Instance()->GetUrl('tahap_penerimaan', 'TahapPenerimaan', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI_SIA',$url_kembali );
      }elseif($umConn==true){
         $this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'YES');
      }
		if ($data['pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['pesan']);
		}
		$dataJurusan = $data['dataJurusan'];
		
		if (isset($_GET['dataId'])) {
         $tambah="Ubah";
      } else {
         $url="addTahap";
         $tambah="Tambah";  
      }

		$this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('status_koneksi', 'JURUSAN_NAMA', empty($dataJurusan[0]['jurusan_nama'])?$data['data']['jurusan_nama']:$dataJurusan[0]['jurusan_nama']);
      $this->mrTemplate->AddVar('status_koneksi', 'JURUSAN_KODE', empty($dataJurusan[0]['jurusan_kode'])?$data['data']['jurusan_kode']:$dataJurusan[0]['jurusan_kode']);
		$this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('tahap_penerimaan', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
		$this->mrTemplate->AddVar('status_koneksi', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('status_koneksi', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
	}
}
?>
