copy dari repo om Irfan
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class ModelKelompok 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 getData_Kelompok($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('kelompok');
|
||||
$this->db->order_by('NAMA_KELOMPOK ASC');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('kelompok');
|
||||
$this->db->where(['ID_KELOMPOK' => $id]);
|
||||
$this->db->order_by('NAMA_KELOMPOK ASC');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getData_Pelanggan_byKELOMPOK($id){
|
||||
$this->db->select('*');
|
||||
$this->db->from('pelanggan a');
|
||||
$this->db->join('kelompok b','b.ID_KELOMPOK=a.KELOMPOK_ID');
|
||||
$this->db->where(['a.KELOMPOK_ID' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getKelompokKelompok($id)
|
||||
{
|
||||
$this->db->select('*,f.NAMA_KOTA as KS,g.NAMA_KOTA as KP,h.NAMA_KOTA as KTp');
|
||||
$this->db->from('kelompok a');
|
||||
$this->db->join('kelompok b', 'b.KELOMPOK_ID=a.ID_KELOMPOK');
|
||||
$this->db->join('supplier c', 'c.ID_SUPPLIER=b.ANGGOTA_ID','left');
|
||||
$this->db->join('pelanggan d', 'd.ID_PELANGGAN=b.ANGGOTA_ID','left');
|
||||
$this->db->join('tp e', 'e.ID_TP=b.ANGGOTA_ID','left');
|
||||
$this->db->join('kota f', 'f.ID_KOTA=c.KOTA_ID','left');
|
||||
$this->db->join('kota g', 'g.ID_KOTA=d.KOTA_ID','left');
|
||||
$this->db->join('kota h', 'h.ID_KOTA=e.KOTA_ID','left');
|
||||
$this->db->where(['a.ID_KELOMPOK' => $id]);
|
||||
$this->db->group_by('b.ID_KELOMPOK');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getNamaKelompok($id)
|
||||
{
|
||||
$this->db->select('NAMA_KELOMPOK');
|
||||
$this->db->from('kelompok');
|
||||
$this->db->where(['ID_KELOMPOK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getKelompokID($id)
|
||||
{
|
||||
$this->db->select('KELOMPOK_ID');
|
||||
$this->db->from('kelompok');
|
||||
$this->db->where(['ID_KELOMPOK' => $id]);
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function updateStatusKelompok($id)
|
||||
{
|
||||
$data = "None";
|
||||
$this->db->set('STATUS_KELOMPOK',$data);
|
||||
$this->db->update('kelompok');
|
||||
$this->db->where(['KELOMPOK_ID' => $id]);
|
||||
}
|
||||
|
||||
public function defaultStatusKelompok($id)
|
||||
{
|
||||
$data = NULL;
|
||||
$this->db->set('STATUS_KELOMPOK',$data);
|
||||
$this->db->update('kelompok');
|
||||
$this->db->where(['KELOMPOK_ID' => $id]);
|
||||
}
|
||||
|
||||
public function getDataTeknisi($id = null){
|
||||
if ($id === null) {
|
||||
$this->db->select('*');
|
||||
$this->db->from('operator');
|
||||
$this->db->where('ID_OPERATOR >=3');
|
||||
}else{
|
||||
$this->db->select('*');
|
||||
$this->db->from('operator');
|
||||
$this->db->where('ID_OPERATOR >=3');
|
||||
}
|
||||
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user