<?php



defined('BASEPATH') OR exit('No direct script access allowed');







class Jenis_kegiatan extends CI_Controller {



	



    public function __construct(){



        parent::__construct();		



        $this->load->model('M_jenis_kegiatan');



    }



	public function data_jenis_kegiatan(){



        $result = $this->M_jenis_kegiatan->data_jenis_kegiatan()->result_array();



        /*for($i=0; $i<count($result);$i++){



            $data['id_penerima'] = $result[$i]['id_penerima'];



            $donasi = $this->m_penerima->data_donasi($data)->result_array();



            $a=0;



            for($o=0; $o<count($donasi);$o++){



                $a+=$donasi[$o]['donasi'];



            }



            $result[$i]['hasil_donasi']=$a;



        }*/



        echo json_encode($result);



    }



    public function simpan_jenis_kegiatan(){



        $data["nama"] = $this->input->post('nama',TRUE);



        $data["kode"] = $this->input->post('kode',TRUE);



        $data["keterangan"]         = $this->input->post('keterangan',TRUE);



        $respon = $this->M_jenis_kegiatan->simpan_jenis_kegiatan($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function ambil_jenis_kegiatan(){



        $data["id_jenis_kegiatan"] = $this->input->post('id_jenis_kegiatan',TRUE);



        $respon = $this->M_jenis_kegiatan->ambil_jenis_kegiatan($data)->row_array();



        echo json_encode($respon);



        // echo json_encode($data["id_unit_misioner"]);



    }



	public function update_jenis_kegiatan(){



        $data["id_jenis_kegiatan"]         = $this->input->post('id_jenis_kegiatan',TRUE);



        $data["nama"] = $this->input->post('nama',TRUE);



        $data["kode"] = $this->input->post('kode',TRUE);



        $data["keterangan"]         = $this->input->post('keterangan',TRUE);



        $respon = $this->M_jenis_kegiatan->update_jenis_kegiatan($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function hapus_jenis_kegiatan(){



        $data["id_jenis_kegiatan"]         = $this->input->post('id_jenis_kegiatan',TRUE);



        $respon = $this->M_jenis_kegiatan->hapus_jenis_kegiatan($data);



        echo json_encode($respon);



    }



}



