<?php
defined('BASEPATH') or exit('No direct script access allowed');

require_once 'vendor/autoload.php';

class Wsbpjsprb extends CI_Controller
{	
   
		public function __construct()
		{
			parent::__construct();
			$this->load->model('data_menu');
            $this->load->library('LibHttpRequest');				
		}


		public function insert()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'PRB/insert';
			echo $this->HttpRequest("POST",$url,$params,$postMethod) ;		
		}

		
		public function update()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'PRB/Update';
			echo $this->HttpRequest("PUT",$url,$params,$postMethod) ;		
		}

		public function delete()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$params = $obj ;
			$postMethod = "application/x-www-form-urlencoded" ;

			$url = 'PRB/Delete';
			echo $this->HttpRequest("DELETE",$url,$params,$postMethod) ;		
		}

		public function noSrb()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$noSrbPeserta = $this->GetJsonObject($obj->{'noSrbPeserta'}) ;
			$noSep = $this->GetJsonObject($obj->{'noSep'}) ;
			
			$url = 'prb/'.$noSrbPeserta.'/nosep/'.$noSep;
			echo $this->HttpRequest("GET",$url) ;		
		}

		public function tanggalSrb()
		{	
			$json = file_get_contents('php://input');
			$obj = json_decode($json);

			$tanggalMulai = $this->GetJsonObject($obj->{'tanggalMulai'}) ;
			$tanggalAkhir = $this->GetJsonObject($obj->{'tanggalAkhir'}) ;
			
			$url = 'prb/tglMulai/'.$tanggalMulai.'/tglAkhir/'.$tanggalAkhir;
			echo $this->HttpRequest("GET",$url) ;		
		}

        public function HttpRequest($method,$endPoint,$params="",$contentType="application/x-www-form-urlencoded")
		{			
			echo $this->libhttprequest->vclaim($method,$endPoint,$params,$contentType);
			exit();			
		}
	
		function GetJsonObject($obj){
			return isset($obj) ? $obj : ""; 
		}
	
	
	
	
	
	
	
	
	

}