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

class Pelayanan extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('M_pelayanan');
	}

	public function data_pelayanan()
	{
		$result = $this->M_pelayanan->data_pelayanan()->result_array();
		echo json_encode($result);
	}

	public function data_pelayanan_by_jenis_pelatihan()
	{
		$id_jenis_pelayanan = $this->input->post('id_jenis_pelayanan');
		$result = $this->M_pelayanan->data_pelayanan_by_jenis_pelatihan($id_jenis_pelayanan)->result_array();
		echo json_encode($result);
	}


	public function simpan_pelayanan()
	{
		$data["nama"] = $this->input->post('nama', TRUE);
		$data["jenis_pelayanan_id"] = $this->input->post('jenis_pelayanan_id', TRUE);
		$data["stipendium"] = $this->input->post('stipendium', TRUE);
		$data["stipendium_daring"] = $this->input->post('stipendium_daring', TRUE);
		$data["keterangan"] = $this->input->post('keterangan', TRUE);
		$respon = $this->M_pelayanan->simpan_pelayanan($data);
		echo json_encode($respon);
	}

	public function ambil_pelayanan()
	{
		$data["id_pelayanan"] = $this->input->post('id_pelayanan', TRUE);
		$respon = $this->M_pelayanan->ambil_pelayanan($data)->row_array();
		echo json_encode($respon);
	}

	public function update_pelayanan()
	{
		$data["id_pelayanan"] = $this->input->post('id_pelayanan', TRUE);
		$data["nama"] = $this->input->post('nama', TRUE);
		$data["jenis_pelayanan_id"] = $this->input->post('jenis_pelayanan_id', TRUE);
		$data["stipendium"] = $this->input->post('stipendium', TRUE);
		$data["stipendium_daring"] = $this->input->post('stipendium_daring', TRUE);
		$data["keterangan"] = $this->input->post('keterangan', TRUE);
		$respon = $this->M_pelayanan->update_pelayanan($data);
		echo json_encode($respon);
	}

	public function hapus_pelayanan()
	{
		$data["id_pelayanan"] = $this->input->post('id_pelayanan', TRUE);
		$respon = $this->M_pelayanan->hapus_pelayanan($data);
		echo json_encode($respon);
	}
}
