<?php



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







class Bidang extends CI_Controller {



	



    public function __construct(){



        parent::__construct();		



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



    }



	public function data_bidang(){



        $result = $this->M_bidang->data_bidang()->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_bidang(){



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



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



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



        $respon = $this->M_bidang->simpan_bidang($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function ambil_bidang(){



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



        $respon = $this->M_bidang->ambil_bidang($data)->row_array();



        echo json_encode($respon);



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



    }



    public function update_bidang(){



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



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



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



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



        $respon = $this->M_bidang->update_bidang($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function hapus_bidang(){



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



        $respon = $this->M_bidang->hapus_bidang($data);



        echo json_encode($respon);



    }



	



}



