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

class ViewUpdateCombo extends HtmlResponse{

	function TemplateModule() {
		$this->SetTemplateBasedir(GTFWConfiguration::GetValue( 'application', 'docroot') . 'module/mahasiswa/template');
		$this->SetTemplateFile('update_combo.html');
	}
	function ProcessRequest() {
		$mhsObj = new AppMahasiswa();
      
      $negara = Dispatcher::Instance()->Decrypt($_REQUEST['negara']);
      $kota = Dispatcher::Instance()->Decrypt($_REQUEST['kota']);
      $propinsi = Dispatcher::Instance()->Decrypt($_REQUEST['propinsi']);
      $name=Dispatcher::Instance()->Decrypt($_REQUEST['name']);
      $dataPropinsiByIdNeg=$mhsObj->GetPropinsiByKodeNegara($negara);
      $dataKota=$mhsObj->GetKotaByKodePropinsi($propinsi);
      //$dataSmta=$mhsObj->GetSmta($kota);

      switch ($name){
         case 'kota_lahir':{   
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',$disabled.' onChange="updateToInputHidden(\'combo_kota_lahir\',\'hidden_kota_lahir\');" id="combo_kota_lahir"'), Messenger::CurrentRequest);
            break;
         }
         case 'propinsi_tinggal':{
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataPropinsiByIdNeg,$propinsi,'false','onChange="updateComboTinggal();"'), Messenger::CurrentRequest);  
            break;
         }
         case 'kota_tinggal':{   
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',$disabled.' onChange="updateToInputHidden(\'combo_kota_tinggal\',\'hidden_kota_tinggal\');" id="combo_kota_tinggal"'), Messenger::CurrentRequest);
            break;
         }
         case 'kota_smta':{
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',''.$disabled), Messenger::CurrentRequest);  
            
            break;
         }
         case 'kota_pt':{
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',''.$disabled), Messenger::CurrentRequest);  
            
            break;
         }
        /* case 'mhs_smta':{  
            if(empty($dataSmta)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array('mhs['.$name.']',$dataSmta,$smta,'false',$disabled), Messenger::CurrentRequest);
            break;
         }*/
         case 'kota_ortu':{   
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',$disabled.' onChange="updateToInputHidden(\'combo_ortu_kota\',\'hidden_ortu_kota\');" id="combo_ortu_kota"'), Messenger::CurrentRequest);
            break;
         }
         case 'kota_wali':{   
            if(empty($dataKota)){
               $disabled="disabled";
            }else{
               $disabled="";
            }
            Messenger::Instance()->SendToComponent('combobox', 'Combobox', 'view', 'html', 'combo',
               array($name,$dataKota,$kota,'false',$disabled.' onChange="updateToInputHidden(\'combo_ortu_kota_wali\',\'hidden_ortu_kota_wali\');" id="combo_ortu_kota_wali"'), Messenger::CurrentRequest);
            break;
         }
      }
     
   }
}
?>