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

class MPinjam extends CI_Model{

  public function __construct()
  {
    parent::__construct();
    //Codeigniter : Write Less Do More
  }

  function riwayatPengajuan($iddata_user)
  {
    $this->db->join("data_user","pembiayaan.data_user_iddata_user = data_user.iddata_user");
    $this->db->where("data_user_iddata_user", $iddata_user);
    $this->db->order_by("tanggal","DESC");
    return $this->db->get("pembiayaan");
  }

  function get_rek_tabungan($iddata_user)
  {
    $this->db->where("jenis_rekening_idjenis_rekening", "1");
    $this->db->where("data_user_iddata_user", $iddata_user);
    return $this->db->get("rekening_nasabah");
  }
  function get_rek_pinjaman($iddata_user)
  {
    $this->db->where("jenis_rekening_idjenis_rekening", "2");
    $this->db->where("data_user_iddata_user", $iddata_user);
    return $this->db->get("rekening_nasabah");
  }

  function RiwayatPinjamAktif($iddata_user)
  {
    $this->db->where("statlunas","BELUM");
    $this->db->where("data_user_iddata_user", $iddata_user);
    return $this->db->get("pembiayaan");
  }

  function RiwayatPinjam($iddata_user)
  {
    $this->db->where("data_user_iddata_user", $iddata_user);
    return $this->db->get("pembiayaan");
  }

  public function get_data_angsuran($nobiaya){
    $this->db->join("pembiayaan", "pembiayaan.nobiaya = bayar.nobiaya");
    $this->db->join("data_user","data_user.iddata_user = pembiayaan.data_user_iddata_user");
    $this->db->where("pembiayaan.nobiaya", $nobiaya);
    return $this->db->get("bayar");
  }

}
