<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_nikah/business/AppStatusNikah.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_nikah/business/AppStatusNikahToSia.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_nikah/business/AppStatusNikahToUm.class.php';

class ViewInputStatusNikah extends HtmlResponse {
	
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/status_nikah/template');
		$this->SetTemplateFile('input_status_nikah.html');
	}
	
	function ProcessRequest() {
		$idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
		$msg = Messenger::Instance()->Receive(__FILE__);
		$useUm=GTFWConfiguration::GetValue( 'application', 'use_gtum');
      $statusNikahObj = new AppStatusNikah();
      $siaObj = new AppStatusNikahToSia();
      $umObj = new AppStatusNikahToUm();
      
      if(!$siaObj->addConn)
		   $return['siaConn']=false;
      else
         $return['siaConn']=true;
      
      if(!$umObj->addConn && $useUm==true)
		   $return['umConn']=false;
      else
         $return['umConn']=true;
               
		$dataStatusNikah = $statusNikahObj->GetDataStatusNikahById($idDec);

      $return['Pesan'] = $msg[0][1];
		$return['css'] = $msg[0][2];
		
      $return['decDataId'] = $idDec;
		$return['dataStatusNikah'] = $dataStatusNikah;
		$return['start'] = $startRec+1;
		return $return;
	}

	function ParseTemplate($data = NULL) {
      $siaConn = $data['siaConn'];
      $umConn = $data['umConn'];
      $dataStatusNikah = $data['dataStatusNikah'];
      
      if($siaConn==false){
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'NO');
         $this->mrTemplate->AddVar('warning', 'ISI_PESAN', 'Gagal menghubungi ke database SI Akademik');
         $url_kembali=Dispatcher::Instance()->GetUrl('status_nikah', 'statusNikah', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI', $url_kembali);
      }elseif($siaConn==true){
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'YES');
      }
    #  var_dump($umConn);exit;
      if($umConn==false){
      
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'NO');
         $this->mrTemplate->AddVar('warning', 'ISI_PESAN', 'Gagal menghubungi ke database SI Admisi');
         $url_kembali=Dispatcher::Instance()->GetUrl('status_nikah', 'statusNikah', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI', $url_kembali);
      }elseif($umConn==true){
         $this->mrTemplate->AddVar('connection', 'CONNECTION', 'YES');
      }   
      
		if ($data['Pesan']) {
			$this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
			$this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['Pesan']);
		}
		
		if ($_REQUEST['dataId']=='') {
			$url="addStatusNikah";
			$tambah="Tambah";
		} else {
			$url="updateStatusNikah";
			$tambah="Ubah";
		}
		$this->mrTemplate->AddVar('connection', 'JUDUL', $tambah);
		$this->mrTemplate->AddVar('connection', 'STATUS_NIKAH_NAMA', empty($dataStatusNikah[0]['status_nikah_nama'])?$data['data']['status_nikah_nama']:$dataStatusNikah[0]['status_nikah_nama']);
		$this->mrTemplate->AddVar('connection', 'URL_ACTION', Dispatcher::Instance()->GetUrl('status_nikah', $url, 'do', 'html') . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
		$this->mrTemplate->AddVar('connection', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
		$this->mrTemplate->AddVar('connection', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
	}
}
?>
