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

class ViewInputPenilaian extends HtmlResponse{

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') .
         'module/penilaian/template');
      $this->SetTemplateFile('view_input_penilaian.html');
   }
   
   function ProcessRequest() {
      $msg = Messenger::Instance()->Receive(__FILE__);
      $return['Pesan'] = $msg[0][1];
      $return['Data'] = $msg[0];
      $decUsr = Dispatcher::Instance()->Decrypt($_REQUEST['usr']);
      
      if ($decUsr == '')
         $decUsr = Dispatcher::Instance()->Decrypt($return['Data']['0']['usr']);

      $nilaiObj = new AppTaruna();

      $dataMhs = $nilaiObj->GetDataUserById($decUsr);
		#	print_r($dataUser);
      $dataUnitKerja = $nilaiObj->GetComboUnitKerja();

      $status[0]['id']='0';
      $status[0]['name']='Baik';
      $status[1]['id']='1';
      $status[1]['name']='Tidak Baik';
      
      
      $dataStatusSehat = $nilaiObj->GetDataJenisSmtaById($idDec);
      $statusSehat=empty($dataStatusSehat[0]['penilaian_sehat'])?$msg[0][0]['penilaian_sehat']:$dataStatusSehat[0]['penilaian_sehat'];
      
      if($statusSehat=='YA'){
        $statusSelected='1';
      }else{
        $statusSelected='0';
      }
      
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'kesehatan',
         array('penilaian_sehat',$status,$statusSelected,'false',''), Messenger::CurrentRequest);
         
         

      if (isset($dataMhs['0']['unit_kerja_id']))
         $unit_selected = $dataMhs['0']['unit_kerja_id'];
      else
         $unit_selected = $return['Data']['0']['unit_kerja'];

      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'unit_kerja', 
         array('unit_kerja',$dataUnitKerja,$unit_selected,'false','onChange="updateGroup();"'), Messenger::CurrentRequest);

      $dataGroup = $nilaiObj->GetDataGroup("", false);
      if (isset($unit_selected)) {
         $data_combo_group = $nilaiObj->GetDataGroupByUnitId("", $unit_selected);
         if ($_REQUEST['usr']=='')
            $group_selected = $return['Data']['0']['group'];
         else
            $group_selected = $dataMhs['0']['group_id'];
      } else {
         $data_combo_group = null;
      }
      
      Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'group', 
         array('group',$data_combo_group,$group_selected,'false',''), Messenger::CurrentRequest);
      
      $return['dataUser'] = $dataMhs;      
      return $return;
   }

   function ParseTemplate($data = NULL) {

      if (isset($_GET['dataId'])) {
         $tambah="Ubah";
      } else {
         $url="addNilai";
         $tambah="Tambah";  
      }
      $this->mrTemplate->AddVar('content', 'JUDUL', $tambah);
      
      $this->mrTemplate->AddVar('content', 'URL_ACTION', Dispatcher::Instance()->GetUrl('penilaian', $url, 'do', 'html') );
      $this->mrTemplate->AddVar('content', 'URL_VIEW', Dispatcher::Instance()->GetUrl('penilaian', 'penilaian', 'view', 'html') );
   }
}
?>
