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

//set Label for module
require_once GTFWConfiguration::GetValue( 'application', 'docroot') .
'module/label/response/Label.proc.class.php';

class ViewInputProfile extends HtmlResponse {

   function TemplateModule() {
      $this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot').
         'module/user/template');
      $this->SetTemplateFile('input_profile.html');
   }
   
   function ProcessRequest() {
      $userObj = new AppUser();
      $result = $userObj->GetDataUserByUsername($_SESSION['username']);
      $dataUser = $userObj->GetDataUserById($result['user_id']);
      
      $return['dataUser']=$dataUser;
      return $return;
   }

   function TemplateLabeling(){
      $ObjLabel = new GetModuleLabel();
      $arrLabel = $ObjLabel->GetLabel();
      
      //patTemplate name yang memiliki label2 dinamic
      $arrContent=array("content");
      
      for($i=0;$i<count($arrContent);$i++){
         for($j=0;$j<count($arrLabel);$j++){
            $this->mrTemplate->AddVar($arrContent[$i],$arrLabel[$j]['labelCode'],$arrLabel[$j]['labelName']);
         }
      }
   }
   
	function ParseTemplate($data = NULL)
   {
      //set Label
      $this->TemplateLabeling();
      
      if (isset($_GET['err'])) {
         $error = Dispatcher::Instance()->Decrypt($_GET['err']);
         if ($error=='realname') {
            $this->mrTemplate->SetAttribute('warning_box', 'visibility', 'visible');
            $this->mrTemplate->AddVar('warning_box', 'ISI_PESAN', 'Data Nama Lengkap tidak boleh kosong');
         }
      }
      
      $dataUser=$data['dataUser'];
      $this->mrTemplate->AddVar('content', 'URL_ACTION',  Dispatcher::Instance()->GetUrl('user', 'updateProfile', 'do', 'html'));
      $this->mrTemplate->AddVar('content', 'REALNAME', $dataUser[0]['real_name']);
      $this->mrTemplate->AddVar('content', 'DESKRIPSI', $dataUser[0]['description']);
   }
}
?>
