Files
web-sekolah/application/models/Pengumuman_model.php
T
2026-06-26 13:37:55 +07:00

126 lines
2.8 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Pengumuman_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();
}
//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');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->row();
}
//hitung get siswa
public function get_siswa()
{
$this->db->select('*');
$this->db->from('data_siswa');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->result();
}
public function viewByNo($no_pendaftaran) {
$sql = "SELECT * FROM data_siswa
WHERE no_pendaftaran = ?
AND no_pendaftaran NOT IN (
SELECT no_pendaftaran FROM pengumuman
)";
$query = $this->db->query($sql, array($no_pendaftaran));
$result = $query->row(); // Ambil hasil query
return $result;
}
//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);
}
//ambil data ViewUrut
public function ViewUrut()
{
$this->db->select('*');
$this->db->from('v_rpt_data_pengumuman');
$this->db->order_by('no_pendaftaran','ASC');
$query = $this->db->get();
return $query->result();
}
public function download($no_pendaftaran){
$query = $this->db->get_where('v_rpt_data_pengumuman',array('no_pendaftaran'=>$no_pendaftaran));
return $query->row_array();
}
}