69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
use Codeigniter\HTTP\RequestInterface;
|
|
|
|
class ModelJurnal extends Model
|
|
{
|
|
|
|
protected $db;
|
|
protected $request;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = \Config\Database::connect();
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
protected $table = 'jurnal';
|
|
protected $primaryKey = 'id_jurnal';
|
|
protected $returnType = 'object';
|
|
protected $allowedFields = ['id_jurnal', 'bulan', 'tahun', 'mapel', 'total_jurnal', 'keterangan', 'nip'];
|
|
|
|
public function getJurnal($nip)
|
|
{
|
|
return $this->db->table('jurnal')
|
|
->join('guru', 'jurnal.nip = guru.nip')
|
|
->where([
|
|
'jurnal.nip' => $nip,
|
|
])
|
|
->get()
|
|
->getResult();
|
|
}
|
|
|
|
public function getJurnalAll()
|
|
{
|
|
return $this->db->table('jurnal')
|
|
->join('guru', 'jurnal.nip = guru.nip')->get()->getResult();
|
|
}
|
|
|
|
public function getAllJurnal()
|
|
{
|
|
return $this->get()->getResult();
|
|
}
|
|
|
|
public function insert_jurnal($data)
|
|
{
|
|
return $this->db->table($this->table)->insert($data);
|
|
}
|
|
|
|
public function getById($id)
|
|
{
|
|
return $this->where(['id_jurnal' => $id])->get();
|
|
}
|
|
|
|
public function getRekapJurnal($bulan, $tahun, $nip)
|
|
{
|
|
$builder = $this->db->table($this->table);
|
|
$builder->select('*')
|
|
->where('nip', $nip)
|
|
->where('tahun', $tahun)
|
|
->where('bulan >=', $bulan - 2)
|
|
->where('bulan <=', $bulan)
|
|
->orderBy('bulan', 'ASC');
|
|
|
|
return $builder->get()->getResult();
|
|
}
|
|
} |