<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Manajer_model extends CI_Model {

	public function getDataToko() {
		$this->db->limit(1);
		return $this->db->get('tabel_toko');
	}

	public function getUser() {
		return $this->db->get('tabel_user');
	}
	public function ongkir() {
		return $this->db->query('select b.nacab,a.* from ongkir a
								 left join cabang b on a.kode=b.kdcab;');
	}
	public function pongkir() {
		return $this->db->query('select b.nacab,a.* from detailongkir a
								 left join cabang b on a.kode=b.kdcab;');
	}
	public function listjob() {
		return $this->db->get('promoheader');
	}

	public function kedai1() {
		return $this->db->query('select b.nacab,a.* from ongkir a
								 left join cabang b on a.kode=b.kdcab
								 where st="1";');
	}
	
	public function kedai() {
		$this->db->where('jspete', '2');
		$this->db->order_by('kdcab');
		return $this->db->get('cabang');
	}

	public function cekUsername($username) {
		return $this->db->query("SELECT id_user FROM tabel_user WHERE id_user='$username'");
	}
	
	public function ceklistjob() {
	return $this->db->query("SELECT nobukti,tgl,idprogram,tglawal,tglakhir,minorder,maxdisc,disc1,ndisc1,IF(stat='1','All Kedai','Tertentu') AS kedai,IF(stat='1','Aktif','Close') AS kstat
		    FROM promoheader a ORDER BY stat,nobukti,tgl desc;"); 		
	}	

	public function getDataBarang($kd_barang) {
		$this->db->where('kd_barang', $kd_barang);
		return $this->db->get('tabel_barang');
	}

	public function getListKartuStok($kd_barang) {
		$this->db->where('kode_barang', $kd_barang);
		return $this->db->get('tabel_kartu_stok');
	}

	public function getDataMutasi() {
		$this->db->join('tabel_barang AS b', 'a.kd_barang = b.kd_barang', 'left');
		return $this->db->get('tabel_mutasi AS a');
	}

}

/* End of file Manajer_model.php */
/* Location: ./application/models/Manajer_model.php */