77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelJabatan extends CI_Model {
|
|
public function create($table, $data, $batch = false)
|
|
{
|
|
if($batch === false){
|
|
$insert = $this->db->insert($table, $data);
|
|
}else{
|
|
$insert = $this->db->insert_batch($table, $data);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function update($table, $data, $pk, $id = null, $batch = false)
|
|
{
|
|
if($batch === false){
|
|
$insert = $this->db->update($table, $data, array($pk => $id));
|
|
}else{
|
|
$insert = $this->db->update_batch($table, $data, $pk);
|
|
}
|
|
return $insert;
|
|
}
|
|
|
|
public function delete($table, $data, $pk)
|
|
{
|
|
$this->db->where_in($pk, $data);
|
|
return $this->db->delete($table);
|
|
}
|
|
|
|
public function cekPass($id, $pass)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('karyawan');
|
|
$this->db->where(['ID_KARYAWAN' => $id]);
|
|
$this->db->where(['PASSWORD' => $pass]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Model getData
|
|
public function getData_Jabatan($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*');
|
|
$this->db->from('jabatan');
|
|
$this->db->order_by('NAMA_JABATAN ASC');
|
|
}else{
|
|
$this->db->select('*');
|
|
$this->db->from('jabatan');
|
|
$this->db->where(['ID_JABATAN' => $id]);
|
|
}
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getData_Karyawan_byJABATAN($id){
|
|
$this->db->select('*');
|
|
$this->db->from('karyawan a');
|
|
$this->db->join('jabatan b','b.ID_JABATAN=a.JABATAN_ID');
|
|
$this->db->where(['a.JABATAN_ID' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getData_Karyawan_byUSERNAME($id){
|
|
$this->db->select('*');
|
|
$this->db->from('karyawan');
|
|
$this->db->where(['USERNAME' => $id]);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
//Model getID
|
|
public function getID_SetdataMax(){
|
|
$this->db->select_max('ID_SETDATA');
|
|
$this->db->from('setdata');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
|
|
}
|
|
?>
|