<?php
class M_menu extends CI_Model{

	function get_all_menu(){
		$hsl=$this->db->query("SELECT * FROM tbl_menu where menu_id='9A11' ");
		return $hsl;	
	}

	function simpan_menu($nama,$deskripsi,$harga,$kategori,$kat_nama,$gambar){
		$hsl=$this->db->query("INSERT INTO tbl_menu (menu_nama,menu_deskripsi,menu_harga_baru,menu_kategori_id,menu_kategori_nama,menu_gambar) VALUES ('$nama','$deskripsi','$harga','$kategori','$kat_nama','$gambar')");
		return $hsl;
	}

	//UPDATE MENU DENGAN GAMBAR //
	function update_menu_tanpa_harga_baru($kode,$nama,$deskripsi,$harga_lama,$kategori,$kat_nama,$gambar){
		$hsl=$this->db->query("UPDATE tbl_menu set menu_nama='$nama',menu_deskripsi='$deskripsi',menu_harga_baru='$harga_lama',menu_kategori_id='$kategori',menu_kategori_nama='$kat_nama',menu_gambar='$gambar' where menu_id='$kode'");
		return $hsl;
	}
	function update_menu_dengan_harga_baru($kode,$nama,$deskripsi,$harga_lama,$harga_baru,$kategori,$kat_nama,$gambar){
		$hsl=$this->db->query("UPDATE tbl_menu set menu_nama='$nama',menu_deskripsi='$deskripsi',menu_harga_lama='$harga_lama',menu_harga_baru='$harga_baru',menu_kategori_id='$kategori',menu_kategori_nama='$kat_nama',menu_gambar='$gambar' where menu_id='$kode'");
		return $hsl;
	}
	//END EDIT MENU DENGAN GAMBAR//

	//UPDATE MENU TANPA GAMBAR//
	function update_menu_tanpa_harga_baru_tanpa_gambar($kode,$nama,$deskripsi,$harga_lama,$kategori,$kat_nama){
		$hsl=$this->db->query("UPDATE tbl_menu set menu_nama='$nama',menu_deskripsi='$deskripsi',menu_harga_baru='$harga_lama',menu_kategori_id='$kategori',menu_kategori_nama='$kat_nama' where menu_id='$kode'");
		return $hsl;
	}
	function update_menu_dengan_harga_baru_tanpa_gambar($kode,$nama,$deskripsi,$harga_lama,$harga_baru,$kategori,$kat_nama){
		$hsl=$this->db->query("UPDATE tbl_menu set menu_nama='$nama',menu_deskripsi='$deskripsi',menu_harga_lama='$harga_lama',menu_harga_baru='$harga_baru',menu_kategori_id='$kategori',menu_kategori_nama='$kat_nama' where menu_id='$kode'");
		return $hsl;
	}
	//END UPDATE MENU TANPA GAMBAR//

	function hapus_menu($kode){
		$hsl=$this->db->query("DELETE FROM tbl_menu where menu_id='$kode'");
		return $hsl;
	}

//j03 TO
//j01 OR
//jo2 snc
//j04 minum
//j07 gokil
	//MODEL UNTUK MOBILE
	
	function lokasi(){
		$hsl=$this->db->query("select * FROM tabel_toko where gmap<>''");
		return $hsl;
	}
	function toko($kdtoko){
		$hsl=$this->db->query("select * FROM tabel_toko where kdtoko='$kdtoko'");
		return $hsl;
	}

	
	function hot_promo(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar 
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J01' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1' and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function hot_menu(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J01' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1' and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_likes desc limit 2;");
		return $hsl;
	}
	function makanan(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J01' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01'  and a.menu_status='1' and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function allmenu(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE  b.`kdcabang`='kdr01' AND b.`kdharga`='kh01'  and a.menu_status='1' and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function makanana(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J08' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function makanan1(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru ,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J07' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01'  and a.menu_status='1' and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function makanan1a(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru ,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar, 
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J09' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function makanan2(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J03' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function makanan3(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J02' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function mtop1(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J81' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function mtop2(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J82' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function mtop3(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J83' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function mtop4(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J84' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function gtop1(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J91' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function gtop2(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J92' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function gtop3(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J93' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function gtop4(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.jenismenu='J94' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	function minuman(){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,b.hargajual as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar,
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_kategori_id='J04' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;
	}
	
	function favorite(){
		$hsl=$this->db->query("SELECT menu_id,menu_nama,menu_deskripsi,if(menu_harga_lama>=10000,LEFT(menu_harga_lama,2),LEFT(menu_harga_lama,1)) AS harga_lama,if(menu_harga_baru>=10000,LEFT(menu_harga_baru,2),LEFT(menu_harga_baru,1)) AS harga_baru,menu_harga_lama,menu_harga_baru,menu_likes,menu_kategori_id,menu_kategori_nama,menu_gambar FROM tbl_menu WHERE menu_likes <> 0 ORDER BY menu_likes DESC");
		return $hsl;
	}

	function detail_menu($kode){
	    $nobukti=$this->session->userdata('nobukti');
	    $cabang=$this->session->userdata('cabang');
		$hsl=$this->db->query("SELECT a.menu_id,a.menu_nama,a.menu_deskripsi,
                                 ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_lama,
                                ROUND((((b.`hargajual`)*1.1)/1000),1) AS harga_baru,b.ppn,
                                b.hargajual as menu_harga_lama,(b.hargajual*1.1) as menu_harga_baru,a.menu_likes,a.menu_kategori_id,a.menu_kategori_nama,a.menu_gambar, 
                                ifnull((select qty from tbl_belanja_detail where kdcabang='$cabang' and kdbrg=a.menu_id and nobukti='$nobukti' ),0) as qty
                                FROM tbl_menu a 
                                LEFT JOIN hargajual b ON a.`menu_id`=b.`kdbrg` 
                                WHERE a.menu_id='$kode' AND b.`kdcabang`='kdr04' AND b.`kdharga`='kh01' and a.menu_status='1'  and b.tglawal<=curdate() and b.tglakhir>=curdate() ORDER BY a.menu_id;");
		return $hsl;	
	}

	function add_like($kode){
		$hsl=$this->db->query("UPDATE tbl_menu SET menu_likes=menu_likes+1 where menu_id='$kode'");
		return $hsl;	
	}


	//END MODEL UNTUK MOBILE

}