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

include(APPPATH . 'libraries/Format.php');
include(APPPATH . 'libraries/RestController.php');

use chriskacerguis\RestServer\RestController;

class ControllerPinjamanNasabah extends RestController
{

    public function __construct()
    {
        parent::__construct();
        // Membatasi Jumlah akses sesuai kebutuhan
        $this->methods['index_get']['limit'] = 200;
        $this->methods['index_post']['limit'] = 200;
        $this->load->library('encrypt');
        $this->load->library('mycustom');
        $this->load->model('api/insert_model');
        $this->load->model('api/select_model');
        $this->load->model('api/update_model');
        $this->methods['index_get']['limit'] = 100;
        $this->methods['index_post']['limit'] = 100;
    }

    // Menampilkan data 
    public function index_get()
    {
        $kd_kontrak         = $this->get('id');
        if ($kd_kontrak === null) {
            $this->response([
                'status' => 0,
                'message' => 'Masukkan Nomor Kontrak Pinjaman!'
            ], RestController::HTTP_NOT_FOUND);
        } else {
            $data_kontrak  = $this->select_model->vd_KontrakPinjaman($kd_kontrak);
            $data_angsuran = $this->select_model->vd_Angsuran($kd_kontrak);
            if ($data_kontrak != null) {
                $this->response([
                    'status' => 1,
                    'data_kontrak'    => $data_kontrak,
                    'data_angsuran'   => $data_angsuran,
                ], RestController::HTTP_OK);
            } else {
                $this->response([
                    'status' => 0,
                    'message' => 'Kontrak Tidak Ada!',
                    'kd_kontrak' => $kd_kontrak,
                ], RestController::HTTP_NOT_FOUND);
            }
        }
    }
}

/* End of file ControllerPinjamanNasabah.php and path \application\controllers\apikey\ControllerPinjamanNasabah.php */