<?php

use Google\Service\CloudSearch\Resource\Query;

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

class Select_model extends CI_Model
{
    // Alamat Baru
    function vd_kotkab()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('sistem_alamat');
        $query = $this->db->group_by('kot_kab', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    function vd_kecamatan($nm_kot_kab)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('sistem_alamat');
        $query = $this->db->where('kot_kab', $nm_kot_kab);
        $query = $this->db->group_by('nm_kecamatan', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    function vd_desa($nm_kecamatan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('sistem_alamat');
        $query = $this->db->where('nm_kecamatan', $nm_kecamatan);
        $query = $this->db->group_by('nm_desa', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Data Referral Anggota
    function getDataReferralAnggota()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('sistem_login as A');
        $query = $this->db->join('sistem_identitas as B', 'A.id=B.login_id');
        $query = $this->db->where('id_role !=', 6);
        $query = $this->db->get();
        return $query->result();
    }
    // Data Arisan Heboh Belum
    function getProdukArisanHebohBelum()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('produk_id', 21);
        $query = $this->db->where('status_arisan', 'PROSES');
        $query = $this->db->get();
        return $query->result();
    }
    // Data Arisan Heboh Aktif
    function getProdukArisanMotorBelum()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('produk_id', 22);
        $query = $this->db->where('status_arisan', 'PROSES');
        $query = $this->db->get();
        return $query->result();
    }
    // Data Arisan Heboh Aktif
    function getProdukArisanHeboh()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('produk_id', 21);
        $query = $this->db->where('status_arisan', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Data Arisan Heboh Aktif
    function getProdukArisanMotor()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('produk_id', 22);
        $query = $this->db->where('status_arisan', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Data Arisan
    function getDataArisanAktif()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('status_arisan', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Mengambil data semua kas kelompok
    function getDataSemuaKasKelompok()
    {
        $query = $this->db->select('(SUM(saldo_masuk))-(SUM(saldo_pemenang)) as saldo_kaskelompok');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('substr(regist_arisan, 3, 2)=', '21');
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil data semua kas lelang
    function getDataSemuaKasLelang()
    {
        $query = $this->db->select('saldo_lelang as saldo_kaslelang');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('substr(regist_arisan, 3, 2)=', '22');
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->order_by('jadwal_id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil data semua pendapatan kelompok
    function getDataSemuaPendapatanKelompok()
    {
        $query = $this->db->select('(SUM(administrasi)) as pendapatan_kelompok');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('substr(regist_arisan, 3, 2)=', '21');
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil data semua pendapatan kelompok
    function getDataSemuaPendapatanLelang()
    {
        $query = $this->db->select('(SUM(administrasi))+(SUM(dn_kehilangan))+(SUM(fee_dealer)) as pendapatan_lelang');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('substr(regist_arisan, 3, 2)=', '22');
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan semua laporan arisan heboh
    function getDataSemuaLaporanHeboh()
    {
        $query = $this->db->select('*, A.id as kd_laporan, A.administrasi as pot_admin');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as F', 'A.regist_arisan=F.id');
        $query = $this->db->join('p_arisan_jadwal as G', 'A.jadwal_id=G.id');
        $query = $this->db->join('lap_arisan_menang as B', 'A.id=B.laporan_id');
        $query = $this->db->join('p_arisan_anggota as D', 'B.regist_undian=D.regist_undian');
        $query = $this->db->join('anggota as E', 'D.anggota_id=E.id');
        $query = $this->db->where('F.produk_id', '21');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan semua laporan arisan motor
    function getDataSemuaLaporanLelang()
    {
        $query = $this->db->select('*, A.id as kd_laporan, A.administrasi as pot_admin');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as F', 'A.regist_arisan=F.id');
        $query = $this->db->join('p_arisan_jadwal as G', 'A.jadwal_id=G.id');
        $query = $this->db->join('lap_arisan_menang as B', 'A.id=B.laporan_id');
        $query = $this->db->join('p_arisan_lelang_undian as C', 'B.regist_undian=C.regist_undian');
        $query = $this->db->join('p_arisan_anggota as D', 'C.regist_undian=D.regist_undian');
        $query = $this->db->join('anggota as E', 'D.anggota_id=E.id');
        $query = $this->db->where('F.produk_id', '22');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan semua anggota yang menunggak
    function getDataTunggakanArisan()
    {
        $query = $this->db->select('*, D.tgl_undian as tgl_tenanan');
        $query = $this->db->from('lap_arisan_nunggak as A');
        $query = $this->db->join('p_arisan_anggota as B', 'A.regist_undian=B.regist_undian');
        $query = $this->db->join('anggota as C', 'B.anggota_id=C.id');
        $query = $this->db->join('p_arisan_jadwal as D', 'A.jadwal_id=D.id');
        $query = $this->db->join('p_arisan as E', 'A.regist_arisan=E.id');
        $query = $this->db->join('sistem_login as F', 'B.login_id=F.id');
        $query = $this->db->where('A.status_tunggakan', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Mengambil semua data kategori arisan
    function getDataKategoriArisan()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_arisan_kategori');
        $query = $this->db->get();
        return $query->result();
    }
    // Mengambil semua data arisan kategori heboh
    function getAllDataArisanHeboh()
    {
        $query = $this->db->select('*, A.id as regist_arisan');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('sistem_produk_koperasi as B', 'A.produk_id=B.id');
        $query = $this->db->where('A.produk_id', 21);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan jumlah anggota aktif setiap kelompok
    function getDataJmlAnggota()
    {
        $query = $this->db->select('B.regist_arisan as regist_arisan, count(B.regist_arisan) as anggota');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('p_arisan_anggota as B', 'A.id=B.regist_arisan');
        $query = $this->db->where('B.status', 'AKTIF');
        $query = $this->db->group_by('B.regist_arisan');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan jumlah Pengajuan anggota setiap kelompok
    function getDataJmlPengajuanAnggota()
    {
        $query = $this->db->select('regist_arisan, count(id) as anggota');
        $query = $this->db->from('p_arisan_pengajuan');
        $query = $this->db->group_by('regist_arisan');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan total tagihan yang masuk
    function getDataRealisasiTagihan($regist_arisan)
    {
        $jadwal = $this->db->get_where('p_arisan_jadwal', ['regist_arisan' => $regist_arisan, 'status_undian' => 'BELUM'])->row_array();
        $query = $this->db->select('sum(bayar) as realisasi_bulan_ini');
        $query = $this->db->from('p_arisan_nota');
        $query = $this->db->where('jadwal_id', $jadwal['id']);
        $query = $this->db->where('status_bayar', 'LANCAR');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Detail Arisan Heboh
    function Aktif($kode_regist)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_arisan');
        $query = $this->db->where('id', $kode_regist);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan anggota arisan heboh
    function getDataAnggotaArisanHeboh($regist_arisan)
    {
        $query = $this->db->select('*, B.id as anggota_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota arisan heboh Aktif
    function getDataAnggotaArisanHebohAktif($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->where('status', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota arisan heboh Aktif
    function getDataAnggotaArisanMotorAktifTerus($kode_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('regist_arisan', $kode_arisan);
        $query = $this->db->where('status !=', 'MUNDUR');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota arisan heboh Mundur
    function getDataAnggotaArisanHebohMundur($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->where('status', 'MUNDUR');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota arisan heboh Menang
    function getDataAnggotaArisanHebohMenang($regist_arisan)
    {
        $query = $this->db->select('*, A.id as kd_laporan');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('lap_arisan_menang as B', 'A.id=B.laporan_id');
        $query = $this->db->join('p_arisan_anggota as D', 'B.regist_undian=D.regist_undian');
        $query = $this->db->join('anggota as E', 'D.anggota_id=E.id');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->group_by('A.id');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan nomor undian paling besar
    function getDataNomorUndian($regist_arisan)
    {
        $query = $this->db->select('no_urut');
        $query = $this->db->from('p_arisan_anggota');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->order_by('no_urut', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan saldo terakhir arisan heboh
    function getDataSaldoKelompok($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->order_by('jadwal_id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataJadwalArisanTerbesar($kode_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_jadwal');
        $query = $this->db->where('regist_arisan', $kode_arisan);
        $query = $this->db->order_by('id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data Pengajuan Anggota Arisan
    function getDataPengajuanAnggota()
    {
        // 
        $query = $this->db->select('*, D.nm_panggilan as karyawan, A.id as pengajuan_id');
        $query = $this->db->from('p_arisan_pengajuan as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('p_arisan as C', 'A.regist_arisan=C.id');
        $query = $this->db->join('sistem_login as D', 'A.rekom_id=D.id');
        $query = $this->db->join('sistem_produk_koperasi as E', 'C.produk_id=E.id');
        $query = $this->db->join('sistem_alamat as F', 'B.id_alamat=F.id');
        $query = $this->db->where('C.status_arisan', 'PROSES');
        $query = $this->db->order_by('A.tgl_pengajuan', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data identitas Pengajuan Anggota Arisan
    function getDataIdentitasAnggota($id_anggota)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('anggota as A');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('A.id', $id_anggota);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Jumlah produk anggota
    function getJumlahProdukAnggota($id_anggota)
    {
        $query = $this->db->select('count(*) as jml_produk');
        $query = $this->db->from('tbl_anggota_produk');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->where('status_produk', 'AKTIF');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Jumlah produk Arisan anggota
    function getJumlahProdukArisanAnggota($id_anggota)
    {
        $tahun = date('y');
        $query = $this->db->select('count() as jml_produk');
        $query = $this->db->from('tbl_anggota_produk');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->where('status_produk', 'AKTIF');
        $query = $this->db->like('no_regist', $tahun . '2', 'after');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Jumlah produk Arisan anggota
    function getJumlahArisanHeboh($id_anggota)
    {
        $tahun = date('y');
        $query = $this->db->select('count(*) as jml_arisanheboh');
        $query = $this->db->from('tbl_anggota_produk');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->where('status_produk', 'AKTIF');
        $query = $this->db->like('no_regist', $tahun . '21', 'after');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Jumlah produk Arisan anggota
    function getJumlahArisanMotor($id_anggota)
    {
        $tahun = date('y');
        $query = $this->db->select('count(*) as jml_arisanmotor');
        $query = $this->db->from('tbl_anggota_produk');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->where('status_produk', 'AKTIF');
        $query = $this->db->like('no_regist', $tahun . '22', 'after');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataNomorCadangan($id_anggota)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_hpcadangan');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data arisan heboh per anggota
    function getDataArisanHebohAktif($id_anggota)
    {
        $query = $this->db->select('*, B.id as regist_arisan, A.status as status_arisan, C.nm_panggilan as karyawan');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('sistem_login as C', 'A.login_id=C.id');
        $query = $this->db->where('anggota_id', $id_anggota);
        $query = $this->db->where('B.produk_id', 21);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data produk arisan heboh aktif anggota
    function getDataProdukAHA($id_anggota)
    {
        $query = $this->db->select('*, A.status as status_arisan, B.id as arisan_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('sistem_login as C', 'A.login_id=C.id');
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->where('A.anggota_id', $id_anggota);
        $query = $this->db->where('B.produk_id', 21);
        $query = $this->db->get();
        return $query->result();
    }
    function getDataProdukAHP($id_anggota)
    {
        $query = $this->db->select('*, A.status as status_arisan, B.id as arisan_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('sistem_login as C', 'A.login_id=C.id');
        $query = $this->db->where('A.status !=', 'AKTIF');
        $query = $this->db->where('A.anggota_id', $id_anggota);
        $query = $this->db->where('B.produk_id', 21);
        $query = $this->db->get();
        return $query->result();
    }
    function getDataProdukAMA($id_anggota)
    {
        $query = $this->db->select('*, A.status as status_arisan, B.id as arisan_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('sistem_login as C', 'A.login_id=C.id');
        $query = $this->db->where('B.status_arisan', 'AKTIF');
        $query = $this->db->where('A.anggota_id', $id_anggota);
        $query = $this->db->where('B.produk_id', 22);
        $query = $this->db->get();
        return $query->result();
    }
    function getDataProdukAMP($id_anggota)
    {
        $query = $this->db->select('*, A.status as status_arisan, B.id as arisan_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('sistem_login as C', 'A.login_id=C.id');
        $query = $this->db->where('B.status_arisan', 'SELESAI');
        $query = $this->db->where('A.anggota_id', $id_anggota);
        $query = $this->db->where('B.produk_id', 22);
        $query = $this->db->get();
        return $query->result();
    }
    // Hapus Menyesatkan
    // Menampilkan Jumlah produk Arisan anggota
    // Menampilkan data identitas anggota dengan NIK
    function getDataAnggota($nik)
    {
        $query = $this->db->select('*, A.id as id_anggota');
        $query = $this->db->from('anggota as A');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('A.nik', $nik);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data identitas anggota dengan Nomor HP
    function getDataAnggotaNomorHP($nik)
    {
        $query = $this->db->select('*, A.id as id_anggota');
        $query = $this->db->from('anggota as A');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('A.no_hp', $nik);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data identitas anggota dengan Nomor Undian
    function getDataAnggotaNoUndian($nik)
    {
        $query = $this->db->select('*, A.id as id_anggota');
        $query = $this->db->from('anggota as A');
        $query = $this->db->join('p_arisan_anggota as C', 'A.id=C.anggota_id');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('C.regist_undian', $nik);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data identitas anggota dengan Nomor HP
    function getDataAnggotaNoHp($no_hp)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_anggota as A');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('A.no_hp', $no_hp);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data identitas anggota keluarga
    function getDataAnggotaKeluarga($id_keluarga)
    {
        $query = $this->db->select('*, C.id as anggota_id');
        $query = $this->db->from('tbl_arisan_keluarga_detail as A');
        $query = $this->db->join('tbl_arisan_keluarga as B', 'A.arisan_keluarga_id=B.id');
        $query = $this->db->join('tbl_anggota as C', 'A.id_anggota=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.arisan_keluarga_id', $id_keluarga);
        $query = $this->db->get();
        return $query->result();
    }

    // Menu Kelola Data -> Arisan Motor
    // Menampilkan data arisan motor
    function getDataArisanMotor()
    {
        $query = $this->db->select('*, A.id as regist_arisan');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('sistem_produk_koperasi as B', 'A.produk_id=B.id');
        $query = $this->db->where('A.produk_id', 22);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan kelompok arisan terakhir ditambahkan
    function getKelompokMotorTerakhir()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('sistem_produk_koperasi as B', 'A.produk_id=B.id');
        $query = $this->db->where('A.produk_id', 22);
        $query = $this->db->order_by('A.nm_kelompok', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data identitas arisan motor
    function getDataKelompokArisanMotor($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan');
        $query = $this->db->where('id', $regist_arisan);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data anggota arisan motor
    function getDataAnggotaArisanMotor($regist_arisan)
    {
        $query = $this->db->select('*, B.id as anggota_id');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota arisan motor aktif
    function getDataAnggotaArisanMotorAktif($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota arisan motor yang menang
    function getDataAnggotaArisanMotorMenang($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->where('A.status', 'MENANG');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota arisan motor yang mundur
    function getDataAnggotaArisanMotorMundur($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->where('A.status', 'MUNDUR');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data jadwal undian arisan motor
    function getDataJadwalMotor($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_jadwal');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->where('status_undian', 'SELESAI');
        $query = $this->db->order_by('undian_ke', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataLelangMotorMenang($kode_regist)
    {
        $query = $this->db->select();
        $query = $this->db->from('tbl_arisan_lelang as A');
        $query = $this->db->join('tbl_lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->where('A.status_lelang', 'MENANG');
        $query = $this->db->group_by('A.id_anggota');
        $query = $this->db->get();
        return $query->result();
    }
    // Menu Kelola data anggota keluarga
    // Menampilkan semua data anggota arisan
    function getDataAnggotaArisan()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota_keluarga as A');
        $query = $this->db->join('anggota as B', 'A.kepala_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->group_by('A.kepala_id');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataAnggotaArisanNew()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->group_by('B.id');
        $query = $this->db->get();
        return $query->result();
    }
    function v_ArisanHebohKepalaKeluarga($data_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('B.produk_id', 21);
        $query = $this->db->where('A.anggota_id', $data_id['kepala_id']);
        $query = $this->db->get();
        return $query->result();
    }
    function v_ArisanHebohAnggotaKeluarga($data_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('B.produk_id', 21);
        $query = $this->db->where('A.anggota_id', $data_id['anggota_id']);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota dengan anggota lain apakah berkeluarga
    function getDataKeluargaAnggota()
    {
        $query = $this->db->select();
        $query = $this->db->from('p_arisan_anggota_keluarga as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->group_by('A.anggota_id');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan anggota dari keluarga A
    function v_DataAnggotaKeluarga($kepala_id)
    {
        $query = $this->db->select();
        $query = $this->db->from('p_arisan_anggota_keluarga as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('A.kepala_id', $kepala_id);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan produk anggota dari keluarga A
    function v_ArisanAnggotaKeluarga($kepala_id)
    {
        $query = $this->db->select();
        $query = $this->db->from('p_arisan_anggota_keluarga as A');
        $query = $this->db->join('p_arisan_anggota as B', 'A.anggota_id=B.anggota_id');
        $query = $this->db->join('p_arisan as C', 'B.regist_arisan=C.id');
        $query = $this->db->join('anggota as D', 'A.anggota_id=D.id');
        $query = $this->db->where('A.kepala_id', $kepala_id);
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan produk yang diikuti kepala keluarga
    function v_ArisanKepala($kepala_id)
    {
        $query = $this->db->select();
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('anggota as C', 'A.anggota_id=C.id');
        $query = $this->db->where('A.anggota_id', $kepala_id);
        $query = $this->db->get();
        return $query->result();
    }
    // Data identitas kepala keluarga
    function v_dkepala($kepala_id)
    {
        $query = $this->db->select();
        $query = $this->db->from('anggota as A');
        $query = $this->db->join('sistem_alamat as B', 'A.id_alamat=B.id');
        $query = $this->db->where('A.id', $kepala_id);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menu Kelola Aktifitas
    // Menu Jadwal Aktifitas Arisan
    // Menampilkan semua data arisan aktif
    function getDataAllHistoryArisanAktif()
    {
        $query = $this->db->select('*, C.id as jadwal_id');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('sistem_produk_koperasi as B', 'A.produk_id=B.id');
        $query = $this->db->join('p_arisan_jadwal as C', 'C.regist_arisan=A.id');
        $query = $this->db->where('A.status_arisan', 'AKTIF');
        $query = $this->db->where('C.status_undian', 'SELESAI');
        $query = $this->db->group_by('A.id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan semua data arisan aktif
    function getDataAllArisanAktif()
    {
        $query = $this->db->select('*, C.id as jadwal_id');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->join('sistem_produk_koperasi as B', 'A.produk_id=B.id');
        $query = $this->db->join('p_arisan_jadwal as C', 'C.regist_arisan=A.id');
        $query = $this->db->where('A.status_arisan', 'AKTIF');
        $query = $this->db->where('C.status_undian !=', 'SELESAI');
        $query = $this->db->group_by('A.id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota aktif arisan
    function getDataAnggotaAktif()
    {
        $query = $this->db->select('regist_arisan, count(A.regist_arisan) as anggota_aktif');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->group_by('A.regist_arisan');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota menang arisan
    function getDataAnggotaMenang()
    {
        $query = $this->db->select('regist_arisan, count(A.regist_arisan) as anggota_menang');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->where('A.status', 'MENANG');
        $query = $this->db->group_by('A.regist_arisan');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota menang arisan
    function getDataAnggotaMundur()
    {
        $query = $this->db->select('regist_arisan, count(A.regist_arisan) as anggota_mundur');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->where('A.status', 'MUNDUR');
        $query = $this->db->group_by('A.regist_arisan');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data jadwal arisan sesuai dengan kode arisan
    function getDataJadwalArisanHeboh($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_jadwal');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->order_by('undian_ke', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan Data Tagihan Anggota Yang Belum Bayar Bulan ini
    function getDataAnggotaTagihan($jadwal_id, $kode_arisan)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Where A.regist_arisan=" . $kode_arisan . " 
        and A.status= 'AKTIF' 
        and NOT EXISTS (Select * from p_arisan_nota as D 
        where jadwal_id=" . $jadwal_id . " 
        and D.regist_undian=A.regist_undian)");
        return $query->result();
    }
    // Menampilkan Data Tagihan Anggota Yang Belum Bayar Bulan ini
    function getDataAnggotaTagihanMotor($jadwal_id, $kode_arisan)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Where A.regist_arisan=" . $kode_arisan . " 
        and A.status != 'MUNDUR' 
        and NOT EXISTS (Select * from p_arisan_nota as D 
        where jadwal_id=" . $jadwal_id . " 
        and D.regist_undian=A.regist_undian)");
        return $query->result();
    }
    function v_dataAnggotaKeluargaBayar($anggota_id, $jadwal_id, $regist_arisan)
    {
        $query = $this->db->query("Select * from p_arisan_anggota_keluarga as A join p_arisan_anggota as B ON A.anggota_id=B.anggota_id where A.kepala_id = " . $anggota_id . " and B.regist_arisan=" . $regist_arisan . " and NOT EXISTS (Select * from p_arisan_nota as D where jadwal_id=" . $jadwal_id . " and D.regist_undian=B.regist_undian)");
        return $query->result();
    }
    function v_dataKepalaKeluargaBayar($anggota_id, $jadwal_id, $regist_arisan)
    {
        $query = $this->db->query("select * from p_arisan_anggota as A JOIN p_arisan_nota as B ON A.regist_undian=B.regist_undian where A.anggota_id=" . $anggota_id . " and A.status='AKTIF' and A.regist_arisan=" . $regist_arisan . " and B.jadwal_id=" . $jadwal_id . "");
        return $query->result();
    }
    function getDataAnggotaBelumBayar($jadwal_id, $regist_arisan)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Where A.regist_arisan=" . $regist_arisan . " and A.status= 'AKTIF' and 
        NOT EXISTS (Select * from tbl_tagihan_arisan_detail as D where D.jadwal_id=" . $jadwal_id . " and D.regist_undian=A.no_regist)");
        return $query->result();
    }
    function getDataAnggotaBelumBayarMotor($jadwal_id, $regist_arisan)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Where A.regist_arisan=" . $regist_arisan . " and 
        NOT EXISTS (Select * from p_arisan_nota as D where D.jadwal_id=" . $jadwal_id . " and D.regist_undian=A.regist_undian)");
        return $query->result();
    }
    // Menampilkan Data Anggota Sudah Bayar Bulan Ini / Sesuai Kode Jadwal
    function getDataAnggotaTagihanSelesai($jadwal_id, $kode_arisan)
    {
        $query = $this->db->query("Select *, D.id as kd_nota from 
        p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Join p_arisan_nota as Z ON A.regist_undian = Z.regist_undian 
        join nota as D ON Z.nota_id=D.id
        Where A.regist_arisan=" . $kode_arisan . " and A.status= 'AKTIF' and EXISTS (Select * from p_arisan_nota as D where jadwal_id=" . $jadwal_id . " and D.regist_undian=A.regist_undian)
        group by A.regist_undian");
        return $query->result();
    }
    function getDataAnggotaTagihanMotorSelesai($jadwal_id, $kode_arisan)
    {
        $query = $this->db->query("Select *, D.id as kd_nota from 
        p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Join p_arisan_nota as Z ON A.regist_undian = Z.regist_undian 
        join nota as D ON Z.nota_id=D.id
        Where A.regist_arisan=" . $kode_arisan . " and A.status != 'MUNDUR' and EXISTS (Select * from p_arisan_nota as D where jadwal_id=" . $jadwal_id . " and D.regist_undian=A.regist_undian)
        group by A.regist_undian");
        return $query->result();
    }
    // Menampilkan data arisan sesuai nomor ID anggota dan nomor arisan
    function getDataArisanAnggota($anggota_id, $regist_arisan, $jadwal_id)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        where A.anggota_id =" . $anggota_id . " 
        and status='AKTIF' and A.regist_arisan=" . $regist_arisan . "
        and not EXISTS (Select * from p_arisan_nota as B where B.regist_arisan=" . $regist_arisan . " 
        and B.jadwal_id=" . $jadwal_id . " and B.regist_undian=A.regist_undian)");
        return $query->result();
    }
    // Menampilkan data identitas arisan
    function getDataArisanIdentitas($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan as A');
        $query = $this->db->where('A.id', $regist_arisan);
        $query = $this->db->where('A.status_arisan', 'AKTIF');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data jadwal arisan
    function getDataTagihanJadwal($jadwal_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_jadwal_undian as A');
        $query = $this->db->where('A.id', $jadwal_id);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan nomor urut invoice paling besar 
    function getDataTagihanUrutHeboh()
    {
        $date = date('Y-m-d');
        $query = $this->db->select('*, id as kd_invoice');
        $query = $this->db->from('nota');
        $query = $this->db->where('tgl_pembayaran', $date);
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->order_by('id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan nomor urut invoice paling besar
    function getDataTagihanUrutMotor()
    {
        $date = date('Y-m-d');
        $query = $this->db->select('*, id as kd_invoice');
        $query = $this->db->from('nota');
        $query = $this->db->where('tgl_pembayaran', $date);
        $query = $this->db->where('produk_id', '22');
        $query = $this->db->order_by('id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan detail ragihan
    function setDataAnggota($anggota_id, $regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->where('A.regist_arisan', $regist_arisan);
        $query = $this->db->where('A.anggota_id', $anggota_id);
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data apakah anggota sudah bayar atau belum bulan ini
    function getDataTagihanAnggota($jadwal_id, $regist_arisan, $anggota_id)
    {
        $query = $this->db->query("Select * from p_arisan_anggota as A 
        where A.anggota_id =" . $anggota_id . " 
        and status='AKTIF' and A.regist_arisan=" . $regist_arisan . "
        and not EXISTS (Select * from p_arisan_nota as B where B.regist_arisan=" . $regist_arisan . " 
        and B.jadwal_id=" . $jadwal_id . " and B.regist_undian=A.regist_undian)");
        return $query->result();
    }
    // Menampilkan data anggota keluarga dari rujukan ID keluarga
    function getDataAnggotaKeluargaArisan($id_keluarga, $regist_arisan, $jadwal_id)
    {
        $query = $this->db->query("SELECT * FROM `tbl_arisan_keluarga_detail` as `A` 
        JOIN `tbl_arisan_keluarga` as `B` ON `A`.`arisan_keluarga_id`=`B`.`id` 
        JOIN `tbl_anggota` as `C` ON `A`.`id_anggota`=`C`.`id` 
        JOIN `sistem_alamat` as `D` ON `C`.`id_alamat`=`D`.`id` 
        JOIN `tbl_arisan_anggota` as `E` ON `A`.`id_anggota`=`E`.`id_anggota` 
        WHERE `A`.`arisan_keluarga_id` = '" . $id_keluarga . "' AND `E`.`id_arisan` = '" . $regist_arisan . "' AND `E`.`status` = 'AKTIF' and NOT EXISTS ( Select * from tbl_tagihan_arisan_detail as F where jadwal_id=" . $jadwal_id . " and F.regist_undian=E.no_regist )");
        return $query->result();
    }
    // Menampilkan data apakah kepala keluarga sudah bayar
    function getKepalaBayar($id_kepala, $jadwal_id, $regist_arisan)
    {
        $query = $this->db->select('*, B.id as Kd_bayar');
        $query = $this->db->from('tbl_tagihan_arisan_detail as A');
        $query = $this->db->join('tbl_tagihan_arisan as B', 'A.tagihan_id=B.id');
        $query = $this->db->where('A.anggota_id', $id_kepala);
        $query = $this->db->where('B.jadwal_id', $jadwal_id);
        $query = $this->db->where('B.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Laporan Lelang Motor Bulan Kemarin
    function getDataLapLelangKemarin($kode_arisan, $jadwal_id_kemarin)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('regist_arisan', $kode_arisan);
        $query = $this->db->where('jadwal_id', $jadwal_id_kemarin);
        $query = $this->db->get();
        return $query->row_array();
    }
    function DataLapLelangKemarin($kode_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_lap_arisan');
        $query = $this->db->where('regist_arisan', $kode_arisan);
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->order_by('undian_ke', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataLapKemarin($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->order_by('jadwal_id', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil 2 anggota lelang tertinggi
    function getData2LelangSekarang($jadwal_id)
    {
        $query = $this->db->select('MAX(total_lelang) as dua_lelang_tertinggi');
        $query = $this->db->from('p_arisan_lelang_undian');
        $query = $this->db->where('jadwal_id', $jadwal_id);
        $query = $this->db->limit(2);
        $query = $this->db->order_by('total_lelang', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil 2 anggota lelang tertinggi
    function getData1LelangSekarang($jadwal_id)
    {
        $query = $this->db->select('MAX(total_lelang) as lelang_tertinggi');
        $query = $this->db->from('p_arisan_lelang_undian');
        $query = $this->db->where('jadwal_id', $jadwal_id);
        $query = $this->db->limit(1);
        $query = $this->db->order_by('total_lelang', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan data anggota lelang
    function getDataAnggotaLelang($jadwal_id)
    {
        $query = $this->db->select('*, A.id as lelang_id');
        $query = $this->db->from('p_arisan_lelang_undian as A');
        $query = $this->db->join('p_arisan_anggota as B', 'A.regist_undian=B.regist_undian');
        $query = $this->db->join('anggota as C', 'B.anggota_id=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.jadwal_id', $jadwal_id);
        $query = $this->db->order_by('A.total_lelang', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    // Menampilkan data anggota lelang
    function getDataSaldoLelang($jadwal_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_lelang_undian as A');
        $query = $this->db->join('p_arisan_anggota as B', 'A.regist_undian=B.regist_undian');
        $query = $this->db->join('anggota as C', 'B.anggota_id=C.id');
        $query = $this->db->where('A.jadwal_id', $jadwal_id);
        $query = $this->db->order_by('A.total_lelang', 'DESC');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan Jumlah Iuran anggota lelang
    function getDataSaldoIuran($jadwal_id)
    {
        $query = $this->db->select('SUM(bayar) as jml_iuran');
        $query = $this->db->from('p_arisan_nota');
        $query = $this->db->where('jadwal_id', $jadwal_id);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Laporan Pendapatan Arisan
    function getDataPendapatanArisanHeboh($regist_arisan)
    {
        $query = $this->db->select('SUM(administrasi) as admin');
        $query = $this->db->from('lap_arisan');
        $query = $this->db->where('regist_arisan', $regist_arisan);
        $query = $this->db->where('status_laporan', 'VERIFIED');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Mengambil data Invoice, Detail Invoice, Bayar Invoice, Keluarga Invoice
    function getDataInvoice($kd_invoice)
    {
        $query = $this->db->select('*, A.id as kd_invoice');
        $query = $this->db->from('nota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->join('sistem_alamat as C', 'B.id_alamat=C.id');
        $query = $this->db->where('A.id', $kd_invoice);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Data Invoice Rincian
    function getDataInvoiceRinci($kd_invoice)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('nota as A');
        $query = $this->db->join('p_arisan_nota as B', 'B.nota_id=A.id');
        $query = $this->db->join('p_arisan_jadwal as C', 'B.jadwal_id=C.id');
        $query = $this->db->join('p_arisan as D', 'B.regist_arisan=D.id');
        $query = $this->db->join('p_arisan_anggota as E', 'B.regist_undian=E.regist_undian');
        $query = $this->db->where('A.id', $kd_invoice);
        $query = $this->db->get();
        return $query->result();
    }
    // Data Identitas Marketing
    function getDataMarketing($kd_invoice)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('nota as A');
        $query = $this->db->join('sistem_login as B', 'A.petugas=B.id');
        $query = $this->db->where('A.id', $kd_invoice);
        $query = $this->db->get();
        return $query->row_array();
    }
    // Cek apakah anggota sudah bayar atau belum
    function cariAnggotaSudahBayar($nomor_urut, $arisan_id, $jadwal_id)
    {
        $query = $this->db->query("Select *, A.regist_undian as kd_undian from p_arisan_anggota as A 
        Join anggota as B ON A.anggota_id = B.id 
        Join sistem_alamat as C ON B.id_alamat = C.id 
        Where A.no_urut=" . $nomor_urut . " and regist_arisan=" . $arisan_id . " and A.status= 'AKTIF' and 
        EXISTS (Select * from p_arisan_nota as 
        D where D.jadwal_id=" . $jadwal_id . " and D.regist_undian=A.regist_undian)");
        return $query->row_array();
    }
    function getDataPemenangArisanHeboh($no_regist)
    {
        $query = $this->db->select('*, A.regist_undian as kd_anggota');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('anggota as B', 'A.anggota_id=B.id');
        $query = $this->db->where('A.regist_undian', $no_regist);
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataAnggotaAktifSekarang($arisan_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota');
        $query = $this->db->where('regist_arisan', $arisan_id);
        $query = $this->db->where('status', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataAnggotaMundurSekarang($arisan_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota');
        $query = $this->db->where('regist_arisan', $arisan_id);
        $query = $this->db->where('status', 'MUNDUR');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataAnggotaMenangSekarang($arisan_id)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota');
        $query = $this->db->where('regist_arisan', $arisan_id);
        $query = $this->db->where('status', 'MENANG');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataLaporanAnggotaTunggakan($kd_laporan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan_nunggak as A');
        $query = $this->db->join('lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->join('p_arisan_anggota as C', 'A.regist_undian=C.regist_undian');
        $query = $this->db->join('anggota as D', 'C.anggota_id=D.id');
        $query = $this->db->join('sistem_alamat as E', 'D.id_alamat=E.id');
        $query = $this->db->where('A.laporan_id', $kd_laporan);
        $query = $this->db->where('A.status_tunggakan', 'AKTIF');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataDetailLaporan($kd_laporan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan_menang as A');
        $query = $this->db->join('lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->join('p_arisan_anggota as C', 'A.regist_undian=C.regist_undian');
        $query = $this->db->join('anggota as D', 'C.anggota_id=D.id');
        $query = $this->db->join('sistem_alamat as E', 'D.id_alamat=E.id');
        $query = $this->db->where('A.laporan_id', $kd_laporan);
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataDetailLaporanPemenang($kd_laporan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('tbl_lap_pemenang_arisan as A');
        $query = $this->db->join('tbl_lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->join('tbl_arisan_anggota as C', 'A.regist_undian=C.no_regist');
        $query = $this->db->join('tbl_anggota as D', 'C.id_anggota=D.id');
        $query = $this->db->join('sistem_alamat as E', 'D.id_alamat=E.id');
        $query = $this->db->where('A.laporan_id', $kd_laporan);
        $query = $this->db->get();
        return $query->result();
    }
    function getDataLelangKe($id_jadwal, $kd_arisan)
    {
        $query = $this->db->select('sum(qty) as jumlah_lelang');
        $query = $this->db->from('tbl_lap_arisan');
        $query = $this->db->where('undian_ke <=', $id_jadwal);
        $query = $this->db->where('regist_arisan', $kd_arisan);
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataLaporanAnggotaTunggakanBayar($kd_laporan)
    {
        $query = $this->db->select('*, F.nota_id as kd_tagihan');
        $query = $this->db->from('lap_arisan_nunggak as A');
        $query = $this->db->join('lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->join('p_arisan_anggota as C', 'A.regist_undian=C.regist_undian');
        $query = $this->db->join('anggota as D', 'C.anggota_id=D.id');
        $query = $this->db->join('sistem_alamat as E', 'D.id_alamat=E.id');
        $query = $this->db->join('p_arisan_nota as F', 'C.regist_undian=F.regist_undian');
        $query = $this->db->join('nota as G', 'G.id=F.nota_id');
        $query = $this->db->where('A.laporan_id', $kd_laporan);
        $query = $this->db->where('A.status_tunggakan', 'LUNAS');
        $query = $this->db->where('F.status_bayar', 'TUNGGAKAN');
        $query = $this->db->get();
        return $query->result();
    }
    function ambilDanaTunggakanLaporan()
    {
        $query = $this->db->select('SUM(bayar) as dana_tunggakan');
        $query = $this->db->from('tbl_tagihan_arisan_nunggak');
        $query = $this->db->where('status_tunggakan', 'LUNAS');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataRinciPemenangArisanMotorLaporan($kd_laporan_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('lap_arisan_menang as B', 'A.id=B.laporan_id');
        $query = $this->db->join('p_arisan_anggota as C', 'B.regist_undian=C.regist_undian');
        $query = $this->db->join('anggota as D', 'C.anggota_id=D.id');
        $query = $this->db->where('A.id', $kd_laporan_arisan);
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataTotalLelang($regist_arisan)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('lap_arisan_menang as A');
        $query = $this->db->join('lap_arisan as B', 'A.laporan_id=B.id');
        $query = $this->db->where('B.regist_arisan', $regist_arisan);
        $query = $this->db->get();
        return $query->result();
    }
    function getTotalIuranArisan($jadwal_id)
    {
        $query = $this->db->select('sum(bayar) as ttl_iuran');
        $query = $this->db->from('p_arisan_nota');
        $query = $this->db->where('jadwal_id', $jadwal_id);
        $query = $this->db->where('status_bayar', 'LANCAR');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Bagian Menu Kas
    function getDataARusKasArisanBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('*');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->or_where('produk_id', '22');
        $query = $this->db->or_where('status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->get();
        return $query->result();
    }
    // Bagian Menu Kas
    function getDataARusKasArisanMasukHarian()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masuk');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('date(B.tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.status_nota', 'TERIMA');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->or_where('B.status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->or_where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Heboh Harian Lancar
    function getDataARusKasArisanMasukHarianHeboh()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masuk');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('date(B.tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.status_nota', 'TERIMA');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Heboh Bulanan Lancar
    function getDataARusKasArisanMasukBulananHeboh()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masukbulanan');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('MONTH(B.tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(B.tgl_pembayaran)', $tahun);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.status_nota', 'TERIMA');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Motor Harian Lancar
    function getDataARusKasArisanMasukHarianMotor()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masuk');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('date(B.tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.status_nota', 'TERIMA');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Motor Bulanan Lancar
    function getDataARusKasArisanMasukBulananMotor()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masukbulanan');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('MONTH(B.tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(B.tgl_pembayaran)', $tahun);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.status_nota', 'TERIMA');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Heboh Harian Tunggakan
    function getDataARusKasArisanMasukHarianHebohTunggakan()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masuk');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('date(B.tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->where('B.status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Heboh Bulanan Tunggakan
    function getDataARusKasArisanMasukBulananHebohTunggakan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masukbulanan');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('MONTH(B.tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(B.tgl_pembayaran)', $tahun);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->where('B.status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Motor Harian Tunggakan
    function getDataARusKasArisanMasukHarianMotorTunggakan()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masuk');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('date(B.tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->where('B.status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Masuk Iuran Motor Bulanan Tunggakan
    function getDataARusKasArisanMasukBulananMotorTunggakan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.bayar) as kas_masukbulanan');
        $query = $this->db->from('p_arisan_nota as A');
        $query = $this->db->join('nota as B', 'A.nota_id=B.id');
        $query = $this->db->where('MONTH(B.tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(B.tgl_pembayaran)', $tahun);
        $query = $this->db->where('B.status_kas', 'MASUK');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->where('B.status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataARusKasArisanMasukBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('sum(ttl_bayar) as saldo');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'MASUK');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->or_where('produk_id', '22');
        $query = $this->db->or_where('status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->or_where('status_kas', 'OMSET');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataARusKasArisanKeluarHarian()
    {
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(ttl_bayar) as saldo');
        $query = $this->db->from('nota');
        $query = $this->db->where('date(tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->or_where('produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Iuran Heboh Harian Lancar
    function getDataARusKasArisanKeluarHarianHeboh()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(ttl_bayar) as kas_keluar');
        $query = $this->db->from('nota');
        $query = $this->db->where('date(tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Iuran Motor Harian Lancar
    function getDataARusKasArisanKeluarHarianMotor()
    {
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(ttl_bayar) as kas_keluar');
        $query = $this->db->from('nota');
        $query = $this->db->where('date(tgl_pembayaran)', $tanggal_hari);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Arisan Heboh Pemenang
    function getDataArusKasArisanKeluarPemenangHeboh()
    {
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.saldo_pemenang) as kas_keluar');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('date(A.tgl_laporan)', $tanggal_hari);
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Arisan Heboh Pemenang
    function getDataArusKasArisanKeluarPemenangMotor()
    {
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.saldo_pemenang) as kas_keluar');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('date(A.tgl_laporan)', $tanggal_hari);
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataARusKasArisanKeluarBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('sum(ttl_bayar) as saldo');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->or_where('produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Iuran Heboh Harian Lancar
    function getDataARusKasArisanKeluarBulananHeboh()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $query = $this->db->select('sum(ttl_bayar) as kas_keluarbulanan');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Iuran Motor Harian Lancar
    function getDataARusKasArisanKeluarBulananMotor()
    {
        $bulan = date('m');
        $tahun = date('Y');
        // SELECT date_format(tgl_transaksi, '%Y-%m-%d') FROM `kas`
        $query = $this->db->select('sum(ttl_bayar) as kas_keluarbulanan');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'KELUAR');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Arisan Heboh Pemenang
    function getDataArusKasArisanKeluarPemenangHebohBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $tanggal_hari = date('Y-m-d');
        $query = $this->db->select('sum(A.saldo_pemenang) as kas_keluarbulanan');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('MONTH(A.tgl_laporan)', $bulan);
        $query = $this->db->where('YEAR(A.tgl_laporan)', $tahun);
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Arisan Heboh Pemenang
    function getDataArusKasArisanOmsetPemenangHebohBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('sum(ttl_bayar) as kas_omsetbulanan');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'OMSET');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataArusKasArisanOmsetPemenangMotorBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('sum(ttl_bayar) as kas_omsetbulanan');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_kas', 'OMSET');
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Saldo Keluar Arisan Heboh Pemenang
    function getDataArusKasArisanKeluarPemenangMotorBulanan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('sum(A.saldo_pemenang) as kas_keluarbulanan');
        $query = $this->db->from('lap_arisan as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->where('MONTH(A.tgl_laporan)', $bulan);
        $query = $this->db->where('YEAR(A.tgl_laporan)', $tahun);
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->row_array();
    }
    // Menampilkan arus kas arisan
    function getDataNotaArisan()
    {
        $bulan = date('m');
        $tahun = date('Y');
        $query = $this->db->select('*');
        $query = $this->db->from('nota');
        $query = $this->db->where('MONTH(tgl_pembayaran)', $bulan);
        $query = $this->db->where('YEAR(tgl_pembayaran)', $tahun);
        $query = $this->db->where('status_nota', 'TERIMA');
        $query = $this->db->where('produk_id', '21');
        $query = $this->db->or_where('produk_id', '22');
        $query = $this->db->or_where('status_nota', 'TERIMA_TUNGGAKAN');
        $query = $this->db->order_by('tgl_pembayaran', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataARusKasArisanFilterTanggal($tgl_mulai, $tgl_selesai)
    {
        $query = $this->db->select('*');
        $query = $this->db->from('kas');
        $query = $this->db->where('date(tgl_transaksi) BETWEEN "' . date('Y-m-d', strtotime($tgl_mulai)) . '" and "' . date('Y-m-d', strtotime($tgl_selesai)) . '"');
        $query = $this->db->where('kas_id', '1');
        $query = $this->db->or_where('kas_id', '2');
        $query = $this->db->get();
        return $query->result();
    }
    function getDataARusKasArisanMasukFilterTanggal($tgl_mulai, $tgl_selesai)
    {
        $query = $this->db->select('sum(ttl_transaksi) as saldo');
        $query = $this->db->from('kas');
        $query = $this->db->where('date(tgl_transaksi) BETWEEN "' . date('Y-m-d', strtotime($tgl_mulai)) . '" and "' . date('Y-m-d', strtotime($tgl_selesai)) . '"');
        $query = $this->db->where('status', 'MASUK');
        $query = $this->db->where('kas_id', '1');
        $query = $this->db->or_where('kas_id', '2');
        $query = $this->db->get();
        return $query->row_array();
    }
    function getDataARusKasArisanKeluarFilterTanggal($tgl_mulai, $tgl_selesai)
    {
        $query = $this->db->select('sum(ttl_transaksi) as saldo');
        $query = $this->db->from('kas');
        $query = $this->db->where('date(tgl_transaksi) BETWEEN "' . date('Y-m-d', strtotime($tgl_mulai)) . '" and "' . date('Y-m-d', strtotime($tgl_selesai)) . '"');
        $query = $this->db->where('status', 'KELUAR');
        $query = $this->db->where('kas_id', '1');
        $query = $this->db->or_where('kas_id', '2');
        $query = $this->db->get();
        return $query->row_array();
    }
    function vd_anggotaArisanHeboh()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('anggota as C', 'A.anggota_id=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->where('B.status_arisan', 'AKTIF');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->group_by('A.anggota_id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    function vd_detailanggotaArisanHeboh()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('anggota as C', 'A.anggota_id=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.status', 'AKTIF');
        $query = $this->db->where('B.status_arisan', 'AKTIF');
        $query = $this->db->where('B.produk_id', '21');
        $query = $this->db->get();
        return $query->result();
    }
    function vd_anggotaArisanMotor()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('anggota as C', 'A.anggota_id=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.status !=', 'MUNDUR');
        $query = $this->db->where('B.status_arisan', 'AKTIF');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->group_by('A.anggota_id', 'DESC');
        $query = $this->db->get();
        return $query->result();
    }
    function vd_detailanggotaArisanMotor()
    {
        $query = $this->db->select('*');
        $query = $this->db->from('p_arisan_anggota as A');
        $query = $this->db->join('p_arisan as B', 'A.regist_arisan=B.id');
        $query = $this->db->join('anggota as C', 'A.anggota_id=C.id');
        $query = $this->db->join('sistem_alamat as D', 'C.id_alamat=D.id');
        $query = $this->db->where('A.status !=', 'MUNDUR');
        $query = $this->db->where('B.status_arisan', 'AKTIF');
        $query = $this->db->where('B.produk_id', '22');
        $query = $this->db->get();
        return $query->result();
    }
}
