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

class kelola_ruta_agt extends CI_Controller
{

    public function __construct()
    {
        setlocale(LC_ALL, 'id_ID.utf8');
        parent::__construct();
        $this->load->library('form_validation');
        $this->load->model('Tambah_ruta_model', 'ruta', true);

        // $this->load->model('user_model', '', true);

        is_login();
        // is_admin();
    }
    public function index()
    {
        $data['pengguna'] = $this->db->get_where('dc_pengguna', ['email' => $this->session->userdata('email')])->row_array();
        $data['agt'] = $this->ruta->getagt();
        // var_dump($data['ruta']);
        $this->template->render_page('anggota_rumah_tangga', $data);
    }
    public function ubahart($id_agt, $id_pm_agt)
    {
        $this->form_validation->set_rules('nama', 'nama', 'required|trim', [
            'required'        => "Nama Anggota Rumah Tangga harus diisi",
        ]);
        $this->form_validation->set_rules('nik', 'nik', 'required|trim', [
            'required'        => "Jenis Lahan harus diisi",
        ]);
        $id = $this->input->post('id', TRUE);
        // $nokk = $this->input->post('nokk', TRUE);
        $nokk = $this->input->post('nokk', TRUE);
        $nama = $this->input->post('nama', TRUE);
        $nik = $this->input->post('nik', TRUE);
        $hubkel = $this->input->post('hubkel', TRUE);
        $jk = $this->input->post('jk', TRUE);
        $umur = $this->input->post('umur', TRUE);
        $sts = $this->input->post('sts', TRUE);
        $pemilik = $this->input->post('pemilik', TRUE);
        $kk = $this->input->post('kk', TRUE);
        $ki = $this->input->post('ki', TRUE);
        $hamil = $this->input->post('hamil', TRUE);
        $kb = $this->input->post('kb', TRUE);
        $jc = $this->input->post('jc', TRUE);
        $kronis = $this->input->post('kronis', TRUE);
        $goldar = $this->input->post('goldar', TRUE);
        $sekolah = $this->input->post('sekolah', TRUE);
        $pend = $this->input->post('pend', TRUE);
        $kelas = $this->input->post('kelas', TRUE);
        $ijazah = $this->input->post('ijazah', TRUE);
        $pensi = $this->input->post('pensi', TRUE);
        $kerja = $this->input->post('kerja', TRUE);
        $lapangan = $this->input->post('lapangan', TRUE);
        $statkerja = $this->input->post('statkerja', TRUE);
        $jumpkerja = $this->input->post('jumpkerja', TRUE);
        $tmptlokasi = $this->input->post('tmptlokasi', TRUE);
        $omsetusaha = $this->input->post('omsetusaha', TRUE);
        $agm = $this->input->post('agm', TRUE);
        $suku = $this->input->post('suku', TRUE);
        $dmsl = $this->input->post('dmsl', TRUE);
        $bansos = $this->input->post('bansos', TRUE);
        $edit = $this->ruta->ubahblok7($id, $nokk, $nama, $nik, $hubkel, $jk, $umur, $sts, $pemilik, $kk, $ki, $hamil, $kb, $jc, $kronis, $goldar, $sekolah, $pend, $kelas, $ijazah, $pensi, $kerja, $lapangan, $statkerja, $jumpkerja, $tmptlokasi, $omsetusaha, $agm, $suku, $dmsl, $bansos);
        // $data['blok1'] = $this->ruta->getrutabyid($idz);
        // $data['agt'] = $this->ruta->get_agt($idz);
        // $data['countagt'] = $this->ruta->countart($idz);
        $data['pengguna'] = $this->db->get_where('dc_pengguna', ['email' => $this->session->userdata('email')])->row_array();

        $data['k'] = $this->db->get_where('dc_agt_keluarga', ['id_agt' => $id_agt, 'id_pm_agt' => $id_pm_agt])->row_array();
        // var_dump($data['agt']);
        if ($this->form_validation->run() == false) {
            // $data['lahan1'] = $this->ruta->get_lahanbyid($idut);
            // $data['countlahan1'] = $this->ruta->countlahan($idut);
            // $this->session->set_flashdata("informasi", "<script>swal('Gagal!','Mohon isi dengan lengkap','error');</script>");
            $this->template->render_page('ubah_art', $data);
            // var_dump($idut);
        } else {
            if ($edit) {

                // var_dump($data['blok1']);
                $this->session->set_flashdata("informasi", "<script>swal('Berhasil!','Berhasil Mengganti Data ','success');</script>");
                $this->template->render_page('ubah_art', $data);
            }
            // $this->user_model->tambah_kegiatan();
            // // $this->user_model->tambah_kegiatan2();
            // $this->session->set_flashdata("informasi", "<script>swal('Berhasil!','Berhasil Menambah Kelola Kegiatan','success');</script>");
            // redirect('kelola_kegiatan');
        }
    }
}
