<?php



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







class Strategi extends CI_Controller {



	



    public function __construct(){



        parent::__construct();		



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



    }



	public function data_strategi(){



        $result = $this->M_strategi->data_strategi()->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 data_head_strategi(){



        $result = $this->M_strategi->data_head_strategi()->result_array();



        echo json_encode($result);



    }



	public function ambil_nomor_head(){



        $row = $this->M_strategi->ambil_nomor_head()->row_array();



        echo json_encode($row);



    }



    public function ambil_nomor_strategi($kode_head){



        $row = $this->M_strategi->ambil_nomor_strategi($kode_head)->row_array();



        echo json_encode($row);



    }



    public function simpan_strategi(){



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



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



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



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



        $respon = $this->M_strategi->simpan_strategi($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function data_detail_strategi($kode_head){



        $result = $this->M_strategi->data_detail_strategi($kode_head)->result_array();



        echo json_encode($result);



    }



    public function update_nomor_strategi(){



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



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



        $respon = $this->M_strategi->update_nomor_strategi($data);



        echo json_encode($respon);



        // echo json_encode("jhgjgfhfytft6yfty");



    }



    public function hapus_nomor_strategi(){



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



        $respon = $this->M_strategi->hapus_nomor_strategi($data);



        echo json_encode($respon);



    }



    public function hapus_head_strategi(){



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



        $respon = $this->M_strategi->hapus_head_strategi($data);



        echo json_encode($respon);



    }



    public function ganti_nama_head(){



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



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



        $respon = $this->M_strategi->ganti_nama_head($data);



        echo json_encode($respon);



    }



}



