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

class ViewDetilStatusBayar extends HtmlResponse {
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/status_bayar/template');
		$this->SetTemplateFile('view_detil_status_bayar.html');
	}
   
   function ProcessRequest(){
      $byrObj=new AppStatusBayar();
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $cari = Dispatcher::Instance()->Decrypt($_REQUEST['cari']);
      
      $msg = Messenger::Instance()->Receive(__file__);
      
      $dataPeriodeAktif = $byrObj->GetPeriodeAktif();
      $dataMahasiswa = $byrObj->GetDataMahasiswa($idDec);
      $dataDetilStatusBayar=$byrObj->GetDetilStatusBayar($idDec,$idDec);
      #print_r($dataDetilStatusBayar);
      
      $return['pesan'] = $msg[0][1];
		$return['css'] = $msg[0][2];  
      $return['dataMahasiswa'] = $dataMahasiswa;
      $return['dataDetilStatusBayar']=$dataDetilStatusBayar;
      $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'];
      $dataDetilStatusBayar=$data['dataDetilStatusBayar'];
      
      $URL_RETURN = Dispatcher::Instance()->GetUrl('status_bayar', 'statusBayar', 'view', 'html') . '&cari='.$cari;
      
      $this->mrTemplate->AddVar('content', 'URL_RETURN', $URL_RETURN);
      $this->mrTemplate->AddVar('content', 'CARI', $cari);
      $this->mrTemplate->AddVar('content', 'STS_BYR_NIM', empty($dataMahasiswa[0]['nim'])?'-':$dataMahasiswa[0]['nim']);
      $this->mrTemplate->AddVar('content', 'STS_BYR_NAMA', empty($dataMahasiswa[0]['nama'])?'-':$dataMahasiswa[0]['nama']);      
      $this->mrTemplate->AddVar('content', 'STS_BYR_PRODI', empty($dataMahasiswa[0]['prodi'])?'-':$dataMahasiswa[0]['prodi']);
      $this->mrTemplate->AddVar('content', 'STS_BYR_TAHUN_MASUK', empty($dataMahasiswa[0]['tahun_masuk'])?'-':$dataMahasiswa[0]['tahun_masuk']);
      
      if(!empty($data['dataPeriodeAktif'])){
         $this->mrTemplate->SetAttribute('periode', 'visibility', 'visible');
         $this->mrTemplate->AddVars('periode', $data['dataPeriodeAktif'][0], '');
      }      
      
      if (empty($data['dataDetilStatusBayar'])) {
			$this->mrTemplate->AddVar('data_detil_bayar', 'DETIL_BYR_EMPTY', 'YES');
		} else {
			$decPage = Dispatcher::Instance()->Decrypt($_REQUEST['page']);
			$encPage = Dispatcher::Instance()->Encrypt($decPage);
			$this->mrTemplate->AddVar('data_detil_bayar', 'DETIL_BYR_EMPTY', 'NO');
			$dataDetilStatusBayar = $data['dataDetilStatusBayar'];
			
         for ($i=0; $i<sizeof($dataDetilStatusBayar); $i++) {
				$no = $i+$data['start'];
				$dataDetilStatusBayar[$i]['number'] = $no;
				if ($no % 2 != 0) $dataDetilStatusBayar[$i]['class_name'] = 'table-common-even';
				else $dataDetilStatusBayar[$i]['class_name'] = '';
				
				if($dataDetilStatusBayar[$i]['status_byr'] == 'BB'){
               $dataDetilStatusBayar[$i]['STATUS_TITLE_BYR'] = 'Belum Bayar';
            }elseif($dataDetilStatusBayar[$i]['status_byr'] == 'BL'){
               $dataDetilStatusBayar[$i]['STATUS_TITLE_BYR'] = 'Belum Lunas';
            }elseif($dataDetilStatusBayar[$i]['status_byr'] == 'L'){
               $dataDetilStatusBayar[$i]['STATUS_TITLE_BYR'] = 'Lunas';
            }
				
				if($i == 0) $this->mrTemplate->AddVar('content', 'FIRST_NUMBER', $no);				
				if($i == sizeof($dataDetilStatusBayar)-1) $this->mrTemplate->AddVar('content', 'LAST_NUMBER', $no);
				$this->mrTemplate->AddVars('data_detil_bayar_item', $dataDetilStatusBayar[$i], 'DETIL_BYR_');
				$this->mrTemplate->parseTemplate('data_detil_bayar_item', 'a');	 
         }
      }
   }
}

?>