Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('BASEPATH') or exit('No direct script access allowed');
- class stock_out_m extends CI_Model
- {
- public function get($id = null)
- {
- $this->db->from('t_stock');
- if ($id != null) {
- $this->db->where('stock_id', $id);
- }
- $query = $this->db->get();
- return $query;
- }
- public function del($id)
- {
- $this->db->where('stock_id', $id);
- $this->db->delete('t_stock');
- }
- public function get_stock_out()
- {
- $this->db->select('t_stock.stock_id,p_item.barcode, p_item.name as item_name
- ,qty,date,detail, p_item.item_id, customer.nama as customer_nama');
- $this->db->from('t_stock');
- $this->db->join('p_item', 't_stock.item_id = p_item.item_id');
- $this->db->join('customer', 't_stock.customer_id = customer.customer_id', 'left');
- $this->db->where('type', 'out');
- $this->db->order_by('stock_id', 'desc');
- $query = $this->db->get();
- return $query;
- }
- public function add_stock_out($post)
- {
- $params = [
- 'item_id' => $post['item_id'],
- 'type' => 'out',
- 'detail' => $post['detail'],
- 'qty' => $post['qty'],
- 'customer_id' => $post['customer'] == '' ? null : $post['customer'],
- 'date' => $post['date'],
- 'user_id' => $this->session->userdata('userid'),
- ];
- $this->db->insert('t_stock', $params);
- }
- //Tambahan get_sisa $itemname
- public function get_sisa($itemname)
- {
- $this->db->select('t_stock.stock_id,p_item.barcode, p_item.name as item_name
- ,qty,date,detail, p_item.item_id , customer.nama as customer_nama');
- $this->db->from('t_stock');
- $this->db->join('p_item', 't_stock.item_id = p_item.item_id');
- $this->db->join('customer', 't_stock.customer_id = customer.customer_id', 'left');
- $this->db->where('type', 'out');
- $this->db->where('p_item.name', $itemname);
- $this->db->order_by('stock_id', 'desc');
- $query = $this->db->get();
- return $query->row();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement