<?php
require_once GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/periode/business/AppPeriode.class.php';
class ViewConfirmAddPeriode extends HtmlResponse {
	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').'module/periode/template');
		$this->SetTemplateFile('view_confirm_add.html');
	}
	
	function ProcessRequest() {
      $Obj = new AppPeriode();
      $msg = Messenger::Instance()->Receive(__FILE__);
    
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);

      $dataPeriode = $Obj->GetDataPeriodeById($idDec);
      $periodeAkhir = $Obj->GetPeriodeAkhir();
      #print_r($periodeAkhir);
		$_SESSION['tahun'] = $msg[0][0];
		$_SESSION['semester'] = $msg[0][1];

      $return['decDataId'] = $idDec;
      $return['dataPeriode'] = $dataPeriode;
      $return['periodeAkhir'] = $periodeAkhir;
      
      $return['tahun'] = $msg[0][0];
      $return['semester'] = $msg[0][1];
      $return['start'] = $startRec+1;
		return $return;
	}
	
	function ParseTemplate($data = NULL) {
      $tahun = $_SESSION['tahun'];
      $periode = $_SESSION['semester'];
      #print_r($_SESSION['semester']);
      
      if ($_REQUEST['dataId']=='') {
			$url="addPeriode";
		} else {
			$url="updatePeriode";
		}

		if($_SESSION['semester']=="2"){
         $data['semester'] = "Genap";
      }else{
         $data['semester'] = "Ganjil";
      }

      $dataTahun = $data['tahun']+1;
      
		$this->mrTemplate->AddVar('content', 'LABEL', "Periode");
      $this->mrTemplate->AddVar('content', 'PERIODE', $data['semester'].' '.$data['tahun'].'/'.$dataTahun);
      $this->mrTemplate->AddVar('content', 'PERIODE_AKHIR', $data['periodeAkhir'][0]['periode_akhir']);
      $this->mrTemplate->AddVar('content', 'FORM_ACTION_URL', Dispatcher::Instance()->GetUrl('periode', $url, 'do', 'html') . "&confirm=Y" . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
		$this->mrTemplate->AddVar('content', 'URL_KEMBALI', Dispatcher::Instance()->GetUrl('periode', 'inputPeriode', 'view', 'html')
         . "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));
      
		$this->mrTemplate->AddVar('content', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
	}
}
?>