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

class Nilai_model extends CI_Model {

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

		//ambil data nilai
		public function listing()
		{

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

				//ambil detail data nilai
		public function detail($no_pendaftaran)
		{

			$this->db->select('*');
			$this->db->from('v_rpt_nilai_tes');
			//where
			$this->db->where('no_pendaftaran', $no_pendaftaran);
			$this->db->order_by('no_pendaftaran','desc');
			$query = $this->db->get();
			return $query->row();			
		}

		//hitung total nilai
		public function total()
		{

			$this->db->select('COUNT(*) AS total');
			$this->db->from('nilai_tes');
			$this->db->order_by('no_pendaftaran','desc');
			$query = $this->db->get();
			return $query->row();			
		}

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

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

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

		//ambil data ViewUrut
		public function ViewUrut()
		{

			$this->db->select('*');
			$this->db->from('v_rpt_nilai_tes');
			$this->db->order_by('no_pendaftaran','ASC');
			$query = $this->db->get();
			return $query->result();			
		}

}

/* End of file User_model.php */
/* Location: ./application/models/User_model.php */