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

117 lines
2.8 KiB
PHP

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Biayaformulir_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function viewByNoInvoice($no_pendaftaran){
$cari = $this->db->get_where("invoice", ["no_pendaftaran" => $no_pendaftaran])->num_rows();
if ($cari < 1) {
$this->db->select('data_siswa.*,
(CASE
WHEN data_siswa.kd_kompetensi = "TJKT" THEN (SELECT biaya_tkj FROM biaya_ppdb LIMIT 1)
WHEN data_siswa.kd_kompetensi = "MPLB" THEN (SELECT biaya_otkp FROM biaya_ppdb LIMIT 1)
WHEN data_siswa.kd_kompetensi = "ANIMASI" THEN (SELECT biaya_animasi FROM biaya_ppdb LIMIT 1)
ELSE (SELECT biaya_kuliner FROM biaya_ppdb LIMIT 1)
END) AS biaya_pendaftaran');
$this->db->from('data_siswa');
$this->db->where('data_siswa.no_pendaftaran', $no_pendaftaran);
$result = $this->db->get()->row(); // Tampilkan data
return $result;
}
else {
return null;
}
}
public function viewByNo($no_pendaftaran) {
$sql = "SELECT * FROM data_siswa
WHERE no_pendaftaran = ?
AND no_pendaftaran NOT IN (
SELECT no_pendaftaran FROM tr_formulir
)";
$query = $this->db->query($sql, array($no_pendaftaran));
$result = $query->row(); // Ambil hasil query
return $result;
}
public function ViewUrut()
{
$this->db->select('*');
$this->db->from('v_rpt_trans_formulir');
$this->db->order_by('no_trans','ASC');
$query = $this->db->get();
return $query->result();
}
public function viewByNo2($no_pendaftaran){
$this->db->where('no_pendaftaran', $no_pendaftaran);
$result = $this->db->get('v_rpt_data_pengumuman')->row(); // Tampilkan data
return $result;
}
//ambil data user
public function listing()
{
$this->db->select('*');
$this->db->from('nilai_tes');
$this->db->order_by('no_pendaftaran','desc');
$query = $this->db->get();
return $query->result();
}
//hitung total tes
public function total()
{
$this->db->select('COUNT(*) AS total');
$this->db->from('tr_formulir');
$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();
}
//tambah nilai
public function tambah($data)
{
$this->db->insert('nilai_tes', $data);
}
//fungsi delete
public function delete($data)
{
$this->db->where('no_pendaftaran', $data['no_pendaftaran']);
$this->db->delete('tr_formulir', $data);
}
//ubah status
public function edit($data2)
{
$this->db->where('no_pendaftaran', $data2['no_pendaftaran']);
$this->db->update('data_siswa', $data2);
}
}