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

class MPos extends CI_Model{

  public function __construct()
  {
    parent::__construct();
    //Codeigniter : Write Less Do More
  }

  function get_penjualan($idmitra, $tgl_awal, $tgl_akhir)
  {
    return $this->db
      ->select("penjualan.*, SUM(hpp_penjualan) as total_hpp")
      ->join("detail_penjualan","detail_penjualan.penjualan_idpenjualan = penjualan.idpenjualan")
      ->where("penjualan.mitra_idmitra",$idmitra)
      ->where('LEFT(penjualan.tanggal,10) BETWEEN "'.date("Y-m-d", strtotime($tgl_awal)).'" AND "'.date("Y-m-d", strtotime($tgl_akhir)).'"')
      ->group_by("penjualan.idpenjualan")
      ->get("penjualan");
  }

}
