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

class ViewInputTandaTangan extends HtmlResponse{

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 
         'module/setting_ktm/template');
      $this->SetTemplateFile('input_tanda_tangan.html');
   }
   

   function ProcessRequest(){
      $sktmObj = new AppSettingKtm();     
                   
      $msg = Messenger::Instance()->Receive(__FILE__);  
      
      $idDec = Dispatcher::Instance()->Decrypt($_REQUEST['dataId']);
      $dataSktm = $sktmObj->GetDataSettingKtmById($idDec);
    // print_r($dataRiwayat);
      
      $return ['cari']=$cari;
      $return['decDataId'] = $idDec;
      $return['pesan']=$msg[0][1];
      $return['data']=$msg[0][0];
      $return['$dataSktm'] = $dataSktm;
      return $return;
   } 
   
   function ParseTemplate($data=NULL){
   
      $ttd_path = GTFWConfiguration::GetValue( 'application', 'ttd_save_path');
   
      $cari=$data['cari'];
              
      $url_kembali=Dispatcher::Instance()->GetUrl('setting_ktm', 'settingKtm', 'view', 'html');
      $this->mrTemplate->AddVar('warning', 'URL_KEMBALI',$url_kembali );       
            
      if ($data['pesan']) {
         $this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
         $this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', $data['pesan']);
      }
      
      $dataSktm=$data['$dataSktm'];
      //print_r($dataSktm);
      
      if ($_REQUEST['dataId']=='')  {
         $url="addTandaTangan";
      } else {
         $url="addTandaTangan";
      }

      if (empty($dataSktm[0]['judul'])) { 
         $this->mrTemplate->AddVar('content', 'KTM_TTD_LABEL', 'Belum ada.');
      }else{
         $this->mrTemplate->AddVar('content', 'KTM_TTD', $dataSktm[0]['judul']);
         $this->mrTemplate->AddVar('content', 'KTM_TTD_LABEL', $dataSktm[0]['judul']);
         $this->mrTemplate->AddVar('content', 'KTM_TTD_PATH', $ttd_path);
      }   
            
      $this->mrTemplate->AddVar('content', 'KTM_ID', $dataSktm[0]['id']);
      $this->mrTemplate->AddVar('content', 'KTM_JABATAN', $dataSktm[0]['jabatan']);
      $this->mrTemplate->AddVar('content', 'KTM_NAMA', $dataSktm[0]['nama_pejabat']);
      $this->mrTemplate->AddVar('content', 'KTM_NIP', $dataSktm[0]['nip_pejabat']);
      
      $this->mrTemplate->AddVar('content', 'URL_ACTION', Dispatcher::Instance()->GetUrl('setting_ktm', $url, 'do', 'html') . 
         "&dataId=" . Dispatcher::Instance()->Encrypt($data['decDataId']));      
      
      $this->mrTemplate->AddVar('content','URL_RETURN',Dispatcher::Instance()->GetUrl('setting_ktm', 'setting_ktm', 'view', 'html'));
      $this->mrTemplate->AddVar('content','CARI',$cari);
      $this->mrTemplate->AddVar('content', 'DATAID', Dispatcher::Instance()->Decrypt($_GET['dataId']));
      $this->mrTemplate->AddVar('content', 'PAGE', Dispatcher::Instance()->Decrypt($_GET['page']));
      
   }
 }
?>