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

class ViewInputPesertaLolos extends HtmlResponse {
   
   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/peserta_lolos/template');
      $this->SetTemplateFile('view_input_peserta_lolos.html');
   }
   
   function ProcessRequest() {
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $msg = Messenger::Instance()->Receive(__FILE__);

      $jenisSmtaObj = new AppPesertaLolos();
      
      if(!$siaObj->addConn)
         $return['siaConn']=false;
      else
         $return['siaConn']=true;      
         
      $status[0]['id']='0';
      $status[0]['name']='Lulus';
      $status[1]['id']='1';
      $status[1]['name']='Tidak Lulus';
      
      $dataJenisSmta = $jenisSmtaObj->GetDataJenisSmtaById($idDec);
      //print_r($dataJenisSmta);
      $statusSmta=empty($dataJenisSmta[0]['jenis_smta_status'])?$msg[0][0]['jenis_smta_status']:$dataJenisSmta[0]['jenis_smta_status'];
      //var_dump($statusSmta);
      //$statusSelected=empty($statusSmta)?'0':$statusSmta;
      if($statusSmta=='YA'){
        $statusSelected='1';
      }else{
        $statusSelected='0';
      }
      
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'status',
         array('jenis_smta_status',$status,$statusSelected,'false',''), Messenger::CurrentRequest);
         
      $dataProdi=$jenisSmtaObj->GetDataProdi();
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'program_studi',
            array('program_studi',$dataProdi,$prodi,'false',''), Messenger::CurrentRequest);
            

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

   function ParseTemplate($data = NULL) {
      $dataJenisSmta = $data['dataJenisSmta'];
      $siaConn=$data['siaConn'];
      
      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('jenis_tes', 'jenisTes', 'view', 'html');
         $this->mrTemplate->AddVar('warning', 'URL_KEMBALI', $url_kembali);
      }elseif($siaConn==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 (isset($_GET['dataId'])) {
         $tambah="Ubah";
      } else {
         $url="addPeserta";
         $tambah="Tambah";  
      }
      
      $this->mrTemplate->AddVar('content', 'JUDUL', $tambah);
      $this->mrTemplate->AddVar('connection', 'JENIS_SMTA_NAMA', empty($dataJenisSmta[0]['jenis_smta_nama'])?$data['data']['jenis_smta_nama']:$dataJenisSmta[0]['jenis_smta_nama']);
      $this->mrTemplate->AddVar('connection', 'URL_ACTION', Dispatcher::Instance()->GetUrl('jenis_tes', $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']));
   }
}
?>
