<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/fakultas/business/AppFakultasToAdmisi.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/fakultas/business/AppFakultasToSia.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/fakultas/business/AppFakultasToPortal.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/fakultas/business/AppFakultasToFinansi.class.php';
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/fakultas/business/AppFakultasToUm.class.php';
class ViewInputFakultas extends HtmlResponse {
   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/fakultas/template');
      $this->SetTemplateFile('input_fakultas.html');
   }
   
   function ProcessRequest(){
      $fakObj=new AppFakultasToAdmisi();
      $fakObjSia=new AppFakultasToSia();
      $fakObjPortal=new AppFakultasToPortal();
      $fakObjFinansi=new AppFakultasToFinansi();
      $fakObjUm=new AppFakultasToUm();
      $useUm=GTFWConfiguration::GetValue( 'application', 'use_gtum');
     // print($fakObjUm->addConn);
      if(!$fakObjSia->addConn)
         $return['siaConn']=false;
      elseif($fakObjSia->addConn)
         $return['siaConn']=true;      

      if(!$fakObjPortal->addConn)
         $return['portalConn']=false;
      elseif($fakObjPortal->addConn)
         $return['portalConn']=true;      
      
      if(!$fakObjFinansi->addConn)
         $return['finansiConn']=false;
      else
         $return['finansiConn']=true;

      if(!$fakObjUm->addConn && $useUm==true){
      //print(Aaaa);
         $return['umConn']=false;
      }else
         $return['umConn']=true;
               
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      
      $dataFakultas = $fakObj->GetDataFakultasById($idDec);

      $msg = Messenger::Instance()->Receive(__FILE__);
      
      $return['Pesan'] = $msg[0][1];
      $return['Data'] = $msg[0][0];
      $return['decDataId'] = $idDec;
      $return['dataFakultas'] = $dataFakultas;
      return $return;
   }
   
   function ParseTemplate($data=null){
      $siaConn=$data['siaConn'];
      $portalConn=$data['portalConn'];
      $finansiConn=$data['finansiConn'];
      $umConn=$data['umConn'];
      $dataFakultas=$data['dataFakultas'];

      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('fakultas', 'fakultas', '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']);
      }
      
      if ($_REQUEST['dataId']=='') {
         $url="addFakultas";
         $tambah="Tambah";
      } else {
         $url="updateFakultas";
         $tambah="Ubah";
      }
      
      $this->mrTemplate->AddVar('status_koneksi', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('status_koneksi', 'FAK_KODE', empty($dataFakultas[0]['fak_kode'])?$data['Data']['fak_kode']:$dataFakultas[0]['fak_kode']);
      $this->mrTemplate->AddVar('status_koneksi', 'FAK_NAMA_RESMI',empty($dataFakultas[0]['fak_nama_resmi'])?$data['Data']['fak_nama_resmi']:$dataFakultas[0]['fak_nama_resmi']);
      $this->mrTemplate->AddVar('status_koneksi', 'FAK_NAMA_SINGKAT',empty($dataFakultas[0]['fak_nama_singkat'])?$data['Data']['fak_nama_singkat']:$dataFakultas[0]['fak_nama_singkat']);
      $this->mrTemplate->AddVar('status_koneksi', 'URL_ACTION', Dispatcher::Instance()->GetUrl('fakultas', $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']));

   }
}
?>