<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/gelombang/business/AppGelombangToAdmisi.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/gelombang/business/AppGelombangToFinansi.class.php';

class ViewInputGelombang extends HtmlResponse {
   
   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue('application','docroot') . 'module/gelombang/template');
      $this->SetTemplateFile('input_gelombang.html');
   }
   
   function ProcessRequest() {
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $gelObjToAdmisi= new AppGelombangToAdmisi();
      $gelObjToFinansi= new AppGelombangToFinansi();

      if(!$gelObjToFinansi->addConn)
         $return['finansiConn']=false;
      else
         $return['finansiConn']=true;
         
      $msg = Messenger::Instance()->Receive(__FILE__);
      $return['Pesan'] = $msg[0][1];
      $return['Data'] = $msg[0][0];

      $dataGelombang = $gelObjToAdmisi->GetDataGelombangById($idDec);

      $return['decDataId'] = $idDec;
      $return['dataGelombang'] = $dataGelombang;
      return $return;
   
   }   

   function ParseTemplate($data = NULL) {
      $dataGel=$data['Data'];
   //print_r($dataGel);
      $finansiConn=$data['finansiConn'];
      
      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');
      }else{
          $this->mrTemplate->AddVar('status_koneksi', 'BERHASIL', 'YES');
      }
      
      $url_kembali=Dispatcher::Instance()->GetUrl('gelombang', 'gelombang', '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']);
      }
      $dataGelombang = $data['dataGelombang'];
      
      if ($_REQUEST['dataId']=='') {
         $url="addGelombang";
         $tambah="Tambah";
      } else {
         $url="updateGelombang";
         $tambah="Ubah";
      }
      $this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('status_koneksi', 'GELOMBANG_ID', empty($dataGelombang[0]['gelombang_id'])?$dataGel['gelombang_id']:$dataGelombang[0]['gelombang_id']);
      $this->mrTemplate->AddVar('status_koneksi', 'GELOMBANG_NAMA', empty($dataGelombang[0]['gelombang_nama'])?$dataGel['gelombang_nama']:$dataGelombang[0]['gelombang_nama']);
      $this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('gelombang', $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']));
   }
}
?>
