<?php

class RiwayatJual_model extends CI_Model
{


	 
	private $_table = 'tabel_riwayat_penjualan';
 
    

	public function get_published_count()
	{
// cari semua produk id yang ingin ditampilkan list debet akhirnya
$query = "(SELECT  *   ";
$query = $query . "FROM   `beta`.`tabel_riwayat_penjualan` ";
//$query = $query . "WHERE     transaksi.jenis IN ('5822spo' , '5822so' , '5822pkd', '5822spd')" ;
$query = $query . "order by  BY id_master  ASC ";       
 $query = $query . " )";
 // jalankan query ambil semua produk idnya taruh ke var listIdProduk 
$listIdProduk   = $this->db->query($query);

return $listIdProduk->num_rows();
	}


	public function get_published($limit = null, $offset = null,$date1 = null , $date2 = null)
	{
		if (!$limit && !$offset) {

        // cari semua produk id yang ingin ditampilkan list debet akhirnya
        $query = "(SELECT  * ";
        $query = $query . " FROM   `beta`.`tabel_riwayat_penjualan`  ";
        //    $query = $query . " WHERE id_master = '269563' " ;
        $query = $query . " ORDER BY id_master  ASC limit 0,20 ";       
         $query = $query . " )";

         // jalankan query ambil semua produk idnya taruh ke var listIdProduk 
        $records   = $this->db->query($query)->result();
        
 

		} else {

	/* percobaan 1 */
// cari semua produk id yang ingin ditampilkan list debet akhirnya selanjutnya
$query = "(SELECT  *  ";
$query = $query . " FROM   `beta`.`tabel_riwayat_penjualan`  ";
//$query = $query . "WHERE    transaksi.jenis IN ('5822spo' , '5822so' , '5822pkd', '5822spd') " ;
$query = $query . " ORDER BY id_master  ASC limit ".$offset.",".$limit." ";       
 $query = $query . " )";
 // jalankan query ambil semua produk idnya taruh ke var listIdProduk 
$records   = $this->db->query($query)->result();
  
 		}
 
	//return $this->db->query($query)->result();
    return $records;
}

	

}
 