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

class ProcessKdpPengembangan
{
	var $_POST;
	var $Obj;
	var $pageView;
	var $pageInput;

	var $cssDone = "notebox-done";
	var $cssFail = "notebox-warning";

	var $return;
	var $decId;
	var $encId;

	function __construct() {
		$this->Obj = new KdpPengembangan();
		$this->_POST = $_POST->AsArray();
		$this->decId = Dispatcher::Instance()->Decrypt($_REQUEST['kdpId']);
		$this->encId = Dispatcher::Instance()->Encrypt($this->decId);
		$this->pageView = Dispatcher::Instance()->GetUrl('kdp_pengembangan', 'Pengembangan', 'view', 'html');
		$this->pageInput = Dispatcher::Instance()->GetUrl('kdp_pengembangan', 'UpdatePengembangan', 'view', 'html');
	}
   
   function Check()
   {
      if (isset($this->_POST['btnbalik'])) return $this->pageView;
      if (($this->_POST['kode_kdp']))
      {
         $msg = array($this->_POST, 'Kode KDP tidak boleh kosong!', '');
         Messenger::Instance()->Send('kdp_pengembangan', 'UpdatePengembangan', 'view', 'html', $msg, Messenger::NextRequest);
         
         $return = $this->pageInput;
         if (isset($_GET['kdpId'])) $return .= "&kdpId=".$_GET['kdpId'];
         return $return;
      }
         
      return true;
   }
   
   function Update()
   {
     	$check = $this->Check();
    	if ($check !== true) return $check;
	 	
      $result = $this->Obj->UpdateKdp($this->_POST, $this->decId);
      
      if ($result === 0)
         $msg = array(1=>'Perubahan Data Berhasil Dilakukan.', $this->cssDone);
      else $msg = array(1=>'Tidak Berhasil Mengubah Data!', $this->cssFail);
      Messenger::Instance()->Send('kdp_pengembangan', 'Pengembangan', 'view', 'html', $msg, Messenger::NextRequest);
      
      return $this->pageView;
   }
    
   function Delete()
   {
      $result = $this->Obj->DeleteKdp($this->_POST['idDelete']);
      if ($result == 0)
         $msg = array(1=>'Penghapusan Data Berhasil Dilakukan.', $this->cssDone);
      else $msg = array(1=>'Proses Penghapusan Data Gagal!', $this->cssFail);
      Messenger::Instance()->Send('kdp_pengembangan', 'Pengembangan', 'view', 'html', $msg, Messenger::NextRequest);
      
      return $this->pageView;
   }
   
   function Add(){
   	return $this->pageView;   
   }
}
?>
