73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
class ModelInventorySn 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 getDataInventorySn($id = null){
|
|
if ($id === null) {
|
|
$this->db->select('*','c.NAMA_TYPE');
|
|
$this->db->from('sn a');
|
|
$this->db->join('inventory b','b.ID_INVENTORY=a.ID_INVENTORY');
|
|
$this->db->join('type c','c.ID_TYPE=b.ID_TYPE');
|
|
}else{
|
|
$this->db->select('*','c.NAMA_TYPE');
|
|
$this->db->from('sn a');
|
|
$this->db->join('inventory b','b.ID_INVENTORY=a.ID_INVENTORY');
|
|
$this->db->join('type c','c.ID_TYPE=b.ID_TYPE');
|
|
$this->db->where(['ID_SN' => $id]);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
public function getInventory()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('inventory a');
|
|
$this->db->join('type b','b.ID_TYPE=a.ID_TYPE');
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function getSnn($id)
|
|
{
|
|
$this->db->select('ID_SN, NAMA_SN');
|
|
$this->db->from('sn');
|
|
$this->db->where(['ID_INVENTORY' => $id]);
|
|
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|
|
?>
|