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

class ViewDetailRegistrasi extends HtmlResponse {
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/registrasi/template');
		$this->SetTemplateFile('view_detail_registrasi.html');
	}
   
   function ProcessRequest(){
      $regObj=new AppRegistrasi();
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $cari = Dispatcher::Instance()->Decrypt($_REQUEST['cari']);
      /*
      $totalData = $statusObj->GetCountRiwayatMahasiswa($idDec,$idDec,$idDec,$idDec,$idDec);
		$itemViewed = 20;
		$currPage = 1;
		$startRec = 0 ;
      if(isset($_GET['page'])) {
			$currPage = (string)$_GET['page']->StripHtmlTags()->SqlString()->Raw();
			$startRec =($currPage-1) * $itemViewed;
		}
		Messenger::Instance()->SendToComponent('paging', 'Paging', 'view', 'html', 'paging_top', array($itemViewed,$totalData, $url, $currPage), Messenger::CurrentRequest);
      */
      $msg = Messenger::Instance()->Receive(__file__);
      
      $dataPeriodeAktif = $regObj->GetPeriodeAktif();
      $dataMahasiswa = $regObj->GetDataMahasiswa($idDec);
      $dataDetilRegistrasi=$regObj->GetDetailRegistrasi($idDec,$idDec,$idDec);
      #print_r($dataDetilRegistrasi);
      
      $return['pesan'] = $msg[0][1];
		$return['css'] = $msg[0][2];  
      $return['dataMahasiswa'] = $dataMahasiswa;
      $return ['dataDetilRegistrasi']=$dataDetilRegistrasi;
      $return['dataPeriodeAktif'] = $dataPeriodeAktif;
      $return['start'] = $startRec+1;
      $return ['decId']=$idDec;
      $return ['cari']=$cari;
      return $return;
   }
   function ParseTemplate($data=NULL){
      $cari=$data['cari'];
      $dataMahasiswa = $data['dataMahasiswa'];
      $dataDetilRegistrasi=$data['dataDetilRegistrasi'];
      $URL_RETURN = Dispatcher::Instance()->GetUrl('registrasi', 'registrasi', 'view', 'html') . '&cari='.$cari;
      $this->mrTemplate->AddVar('content', 'URL_RETURN', $URL_RETURN);
      $this->mrTemplate->AddVar('content', 'CARI', $cari);
      $this->mrTemplate->AddVar('content', 'REGISTRASI_NIM', empty($dataMahasiswa[0]['nim'])?'-':$dataMahasiswa[0]['nim']);
      $this->mrTemplate->AddVar('content', 'REGISTRASI_NAMA', empty($dataMahasiswa[0]['nama'])?'-':$dataMahasiswa[0]['nama']);      
      $this->mrTemplate->AddVar('content', 'REGISTRASI_PRODI', empty($dataMahasiswa[0]['prodi'])?'-':$dataMahasiswa[0]['prodi']);
      $this->mrTemplate->AddVar('content', 'REGISTRASI_TAHUN_MASUK', empty($dataMahasiswa[0]['tahun_masuk'])?'-':$dataMahasiswa[0]['tahun_masuk']);
      #print_r($dataRiwayatMhs);
      if(!empty($data['dataPeriodeAktif'])){
         $this->mrTemplate->SetAttribute('periode', 'visibility', 'visible');
         $this->mrTemplate->AddVars('periode', $data['dataPeriodeAktif'][0], '');
      }      
      
      if (empty($data['dataDetilRegistrasi'])) {
			$this->mrTemplate->AddVar('data_detil', 'DETIL_EMPTY', 'YES');
		} else {
			$decPage = Dispatcher::Instance()->Decrypt($_REQUEST['page']);
			$encPage = Dispatcher::Instance()->Encrypt($decPage);
			$this->mrTemplate->AddVar('data_detil', 'DETIL_EMPTY', 'NO');
			$dataDetilRegistrasi = $data['dataDetilRegistrasi'];
			
         for ($i=0; $i<sizeof($dataDetilRegistrasi); $i++) {
				$no = $i+$data['start'];
				$dataDetilRegistrasi[$i]['number'] = $no;
				if ($no % 2 != 0) $dataDetilRegistrasi[$i]['class_name'] = 'table-common-even';
				else $dataDetilRegistrasi[$i]['class_name'] = '';
				
				if($dataDetilRegistrasi[$i]['keterangan'] == 'S'){
               $dataDetilRegistrasi[$i]['STATUS_TITLE'] = 'Sudah Registrasi';
            }else{
               $dataDetilRegistrasi[$i]['STATUS_TITLE'] = 'Belum Registrasi';
            }
				
				if($i == 0) $this->mrTemplate->AddVar('content', 'FIRST_NUMBER', $no);				
				if($i == sizeof($dataDetilRegistrasi)-1) $this->mrTemplate->AddVar('content', 'LAST_NUMBER', $no);
				$this->mrTemplate->AddVars('data_detil_item', $dataDetilRegistrasi[$i], 'DETIL_');
				$this->mrTemplate->parseTemplate('data_detil_item', 'a');	 
         }
      }
   }
}

?>