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

class ProcessPindahRuang
{
	var $_POST;
	var $Obj;
	var $pageView;
	var $pageInput;
	//css hanya dipake di view
	var $cssDone = "notebox-done";
	var $cssFail = "notebox-warning";

	function __construct() {
		$this->Obj = new Ruang;
		$this->_POST = $_POST->AsArray();
		$this->pageView = Dispatcher::Instance()->GetUrl('gedung', 'listRuang', 'view', 'html');
		$this->pageInput = Dispatcher::Instance()->GetUrl('gedung', 'inputPindahRuang', 'view', 'html');
	}
   
   function Check ()
   {
      if (isset($this->_POST['btnbalik'])) return $this->pageView.'&lantaiId='.$this->_POST['lantaiId']."&id=".$this->_POST['ruangId'];
      
      $msg = array();
      if ($this->_POST['gedung'] =="" || $this->_POST['lantai'] =="") $msg[] = 'Isian bertanda * (bintang) tidak boleh kosong!';

      if (count($msg) > 0){
         $msg = array($this->_POST, $msg, $this->cssFail);
         Messenger::Instance()->Send('gedung', 'inputPindahRuang', 'view', 'html', $msg, Messenger::NextRequest);
         
         $return = $this->pageInput."&id=".$this->_POST['ruangId']."&lantaiId=".$this->_POST['lantaiId'];
         if (!empty($this->_POST['ruangId']))
         return $return;
      }
      
      return true;
   }

   function UpdatePindahRuang()
   {
      $check = $this->Check();
      if($check !== true) return $check;

      $result = $this->Obj->DoUpdatePindahRuang($this->_POST);

      if ($result){
         $msg = array(1=>'Pemindahan Ruang Berhasil Dilakukan.', $this->cssDone);
      } else $msg = array(1=>'Proses Pemindahan Ruang Gagal!', $this->cssFail);
      Messenger::Instance()->Send('gedung', 'listRuang', 'view', 'html', $msg, Messenger::NextRequest).'&lantaiId='.$this->_POST['lantaiId'];
      
      return $this->pageView.'&lantaiId='.$this->_POST['lantaiId'];
   }
}
?>
