<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/business/AppJenjangAkademikToAdmisi.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/business/AppJenjangAkademikToSia.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/business/AppJenjangAkademikToPortal.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/business/AppJenjangAkademikToFinansi.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/business/AppJenjangAkademikToUm.class.php';
class ViewInputJenjangAkademik extends HtmlResponse{
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/jenjang_akademik/template');
		$this->SetTemplateFile('input_jenjang_akademik.html');
	}

   function ProcessRequest() {
		$idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $useUm=GTFWConfiguration::GetValue( 'application', 'use_gtum');
		$jjAdmisiObj = new AppJenjangAkademikToAdmisi();
		$jjSiaObj = new AppJenjangAkademikToSia();
		$jjPortalObj = new AppJenjangAkademikToPortal();
		$jjFinansiObj = new AppJenjangAkademikToFinansi();
		$jjUmObj = new AppJenjangAkademikToUm();
      
      if(!$jjSiaObj->addConn)
         $return['siaConn']=false;
      else
         $return['siaConn']=true;              
      
      if(!$jjPortalObj->addConn)
         $return['portalConn']=0;
      else
         $return['portalConn']=true;      
      
      if(!$jjFinansiObj->addConn)
         $return['finansiConn']=false;
      else
         $return['finansiConn']=true;
      
      if(!$jjUmObj->addConn && $useUm)
         $return['umConn']=false;
      else
         $return['umConn']=true;
                
		$msg = Messenger::Instance()->Receive(__FILE__);
		$dataJenjangAkademik = $jjAdmisiObj->GetDataJenjangAkademikById($idDec);

      $return['pesan']=$msg[0][1];
      $return['data']=$msg[0][0];
		$return['decDataId'] = $idDec;
		$return['dataJenjangAkademik'] = $dataJenjangAkademik;
		return $return;
	}

   function ParseTemplate($data = NULL) {
      $siaConn = $data['siaConn'];
      $umConn = $data['umConn'];
      $portalConn = $data['portalConn'];
      $finansiConn = $data['finansiConn'];

      if($siaConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
         $this->mrTemplate->SetAttribute('sia_conn', 'visibility', 'visible');
			$this->mrTemplate->AddVar('sia_conn', 'ISI_PESAN_SIA', 'Gagal Menghubungi SI Akademik');
      }

      if($umConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
         $this->mrTemplate->SetAttribute('sia_conn', 'visibility', 'visible');
			$this->mrTemplate->AddVar('sia_conn', 'ISI_PESAN_SIA', 'Gagal Menghubungi SI Admisi');
      }
      
      if($portalConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
         $this->mrTemplate->SetAttribute('portal_conn', 'visibility', 'visible');
			$this->mrTemplate->AddVar('portal_conn', 'ISI_PESAN_PORTAL', 'Gagal Menghubungi SI Portal');
      }
      
      if($finansiConn==false){
      	$this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'NO');
         $this->mrTemplate->SetAttribute('finansi_conn', 'visibility', 'visible');
			$this->mrTemplate->AddVar('finansi_conn', 'ISI_PESAN_FINANSI', 'Gagal Menghubungi SI Finansi');
      }
      
      if(($finansiConn==true)and ($portalConn==true) and ($siaConn==true) and ($umConn==true) ){
         $this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'YES');
      }
      
      
      $url_kembali=Dispatcher::Instance()->GetUrl('jenjang_akademik', 'jenjangAkademik', 'view', 'html');
      $this->mrTemplate->AddVar('warning', 'URL_KEMBALI',$url_kembali );
      
		if ($data['pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['pesan']);
		}
		$dataJenjangAkademik = $data['dataJenjangAkademik'];

		if ($_REQUEST['dataId']=='') {
			$url="addJenjangAkademik";
			$tambah="Tambah";
		} else {
			$url="updateJenjangAkademik";
			$tambah="Ubah";
		}

		$this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('status_koneksi', 'JENJANG_KODE', empty($dataJenjangAkademik[0]['jenjang_kode'])?$data['data']['jenjang_kode']:$dataJenjangAkademik[0]['jenjang_kode']);
      $this->mrTemplate->AddVar('status_koneksi', 'JENJANG_KODE_DIKTI', empty($dataJenjangAkademik[0]['jenjang_kode_dikti'])?$data['data']['jenjang_kode_dikti']:$dataJenjangAkademik[0]['jenjang_kode_dikti']);
      $this->mrTemplate->AddVar('status_koneksi', 'JENJANG_NAMA', empty($dataJenjangAkademik[0]['jenjang_nama'])?$data['data']['jenjang_nama']:$dataJenjangAkademik[0]['jenjang_nama']);
      $this->mrTemplate->AddVar('status_koneksi', 'LABEL_NIM', empty($dataJenjangAkademik[0]['jenjang_label_nim'])?$data['data']['jenjang_label_nim']:$dataJenjangAkademik[0]['jenjang_label_nim']);
		$this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('jenjang_akademik', $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']));
	}
}
?>
