Files
shopee-apps/application/delete/models/ModelInvoice.php
T
2026-06-13 16:02:07 +10:00

47 lines
1.5 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ModelInvoice 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 getDataInvoice($id = null){
if ($id === null) {
$this->db->select('*,a.NO_INVOICE,a.TGL_INVOICE,b.NAMA_DISTRIBUTOR,a.NAMA_SKU,FORMAT(a.HPP,0) as HARGA_HPP,a.JUMLAH');
$this->db->from('invoice a');
$this->db->join('distributor b','b.ID_DISTRIBUTOR=a.ID_DISTRIBUTOR');
}else{
$this->db->select('*,a.NO_INVOICE,a.TGL_INVOICE,b.NAMA_DISTRIBUTOR,a.NAMA_SKU,FORMAT(a.HPP,0) as HARGA_HPP,a.JUMLAH');
$this->db->from('invoice a');
$this->db->join('distributor b','b.ID_DISTRIBUTOR=a.ID_DISTRIBUTOR');
$this->db->where(['ID_INVOICE' => $id]);
}
return $this->db->get()->result_array();
}
}