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

class Belumlulustes_model extends CI_Model {

	public function __construct()
	{
		parent::__construct();
		$this->load->database();
		$this->load->library('pdf');
	}	

	//ambil data data
	public function listing()
	{
		$this->db->select('*');
		$this->db->from('v_rpt_data_pengumuman');
		$this->db->order_by('tanggal_pengumuman','desc');
		$query = $this->db->get();
		return $query->result();	
	}

	//ambil detail data data
	public function detail($no_pendaftaran)
	{
		$this->db->select('*');
		$this->db->from('v_rpt_data_pengumuman');
		//where
		$this->db->where('no_pendaftaran', $no_pendaftaran);
		$this->db->order_by('no_pendaftaran','desc');
		$query = $this->db->get();
		return $query->row();			
	}

	// Total nilai belum lulus
	public function belumlulus()
	{
		$this->db->select('*');
		$this->db->from('v_rpt_data_pengumuman');
		//where
		$this->db->where('status','BELUM LULUS');
		$this->db->order_by('no_pendaftaran','desc');
		$query = $this->db->get();
		return $query->result();	
	}	

	//ambil detail data data
	public function setting()
	{

		$this->db->select('*');
		$this->db->from('setting');
		$this->db->order_by('id','desc');
		$query = $this->db->get();
		return $query->result();		
	}

	//hitung total data
	public function total()
	{
		$this->db->select('COUNT(*) AS total');
		$this->db->from('v_rpt_data_pengumuman');
		//where
		$this->db->where('status','BELUM LULUS');
		$this->db->order_by('no_pendaftaran','desc');
		$query = $this->db->get();
		return $query->row();						
	}

	//fungsi edit
	public function edit($data)
	{
		$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
		$this->db->update('pengumuman', $data);
	}

	//fungsi delete
	public function delete($data)
	{
		$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
		$this->db->delete('pengumuman', $data);
	}

	//fungsi delete
	public function delete2($data2)
	{
		$this->db->where('userid', $data2['userid']);
		$this->db->delete('user2', $data2);
	}

	//tambah user
	public function tambah($data)
	{
		$this->db->insert('pengumuman', $data);
	}

	//tambah user
	public function tambah2($data2)
	{
		$this->db->insert('user2', $data2);
	}
}