<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Unit_misioner extends CI_Controller {
    public function __construct(){
        parent::__construct();		
        $this->load->model('M_unit_misioner');
    }
	public function data_unit_misioner(){
        $result = $this->M_unit_misioner->data_unit_misioner()->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_unit_misioner(){
        $data["nama_unit_misioner"] = $this->input->post('nama_unit_misioner',TRUE);
        $data["kode_unit_misioner"] = $this->input->post('kode_unit_misioner',TRUE);
        $data["keterangan"]         = $this->input->post('keterangan',TRUE);
        $respon = $this->M_unit_misioner->simpan_unit_misioner($data);
        echo json_encode($respon);
        // echo json_encode("jhgjgfhfytft6yfty");
    }
    public function ambil_unit_misioner(){
        $data["id_unit_misioner"] = $this->input->post('id_unit_misioner',TRUE);
        $respon = $this->M_unit_misioner->ambil_unit_misioner($data)->row_array();
        echo json_encode($respon);
        // echo json_encode($data["id_unit_misioner"]);
    }
    public function update_unit_misioner(){
        $data["id_unit_misioner"]         = $this->input->post('id_unit_misioner',TRUE);
        $data["nama_unit_misioner"] = $this->input->post('nama_unit_misioner',TRUE);
        $data["kode_unit_misioner"] = $this->input->post('kode_unit_misioner',TRUE);
        $data["keterangan"]         = $this->input->post('keterangan',TRUE);
        $respon = $this->M_unit_misioner->update_unit_misioner($data);
        echo json_encode($respon);
        // echo json_encode("jhgjgfhfytft6yfty");
    }
    public function hapus_unit_misioner(){
        $data["id_unit_misioner"]         = $this->input->post('id_unit_misioner',TRUE);
        $respon = $this->M_unit_misioner->hapus_unit_misioner($data);
        echo json_encode($respon);
    }
}
