99 lines
3.0 KiB
PHP
99 lines
3.0 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class ModelLaporan extends CI_Model{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
//Codeigniter : Write Less Do More
|
|
}
|
|
|
|
public function getGrafik()
|
|
{
|
|
$this->db->select('*, SUM(total_pembayaran) as totalSemua,tanggal as tgl');
|
|
$this->db->where('status_pemesanan', '4');
|
|
$this->db->where("mitra_idmitra", $_SESSION["idmitra"]);
|
|
$this->db->group_by('tanggal');
|
|
return $this->db->get('pemesanan');
|
|
}
|
|
|
|
public function getAnggota()
|
|
{
|
|
return $this->db->get('data_user');
|
|
}
|
|
|
|
public function getBarang()
|
|
{
|
|
return $this->db->get("barang");
|
|
}
|
|
|
|
public function getTransaksi($tgl = null)
|
|
{
|
|
if ($tgl != null || $tgl != "") {
|
|
$this->db->where("tanggal", date("Y-m-d", strtotime($tgl)));
|
|
}
|
|
$this->db->where('status_pemesanan', '4');
|
|
$this->db->where("mitra_idmitra", $_SESSION["idmitra"]);
|
|
return $this->db->get('pemesanan');
|
|
}
|
|
|
|
public function getPendapatan($tgl = null)
|
|
{
|
|
$this->db->select('*, SUM(total_pembayaran) as totalSemua');
|
|
if ($tgl != null || $tgl != "") {
|
|
$this->db->where("tanggal", date("Y-m-d", strtotime($tgl)));
|
|
}
|
|
$this->db->group_by('tanggal');
|
|
$this->db->where('status_pemesanan', '4');
|
|
$this->db->where("mitra_idmitra", $_SESSION["idmitra"]);
|
|
return $this->db->get('pemesanan');
|
|
}
|
|
|
|
public function getSisaHutangAnggota($id)
|
|
{
|
|
$this->db->select("(SUM(harus_dibayar) - SUM(pembayaran)) as total");
|
|
$this->db->join("bayar_hutang","bayar_hutang.pemesanan_idpemesanan = pemesanan.idpemesanan", "left");
|
|
// $this->db->where("data_user_iddata_user", $id);
|
|
$this->db->where("metode_pembayaran", 2);
|
|
$this->db->where("status_hutang", 0);
|
|
$this->db->group_by("pemesanan_idpemesanan");
|
|
return $this->db->get("pemesanan");
|
|
}
|
|
|
|
public function getHutangAnggota($id)
|
|
{
|
|
$this->db->select("SUM(harus_dibayar) as total");
|
|
$this->db->where("data_user_iddata_user", $id);
|
|
$this->db->where("metode_pembayaran", 2);
|
|
$this->db->where("status_hutang", 0);
|
|
return $this->db->get("pemesanan");
|
|
}
|
|
|
|
public function getListHutangAnggota($id)
|
|
{
|
|
$this->db->where("data_user_iddata_user", $id);
|
|
$this->db->where("metode_pembayaran", 2);
|
|
$this->db->where("status_hutang", 0);
|
|
return $this->db->get("pemesanan");
|
|
}
|
|
|
|
public function getListCicilanHutangAnggota($id)
|
|
{
|
|
$this->db->where("pemesanan_idpemesanan", $id);
|
|
return $this->db->get("bayar_hutang");
|
|
}
|
|
|
|
public function getListSisaHutangAnggota($id)
|
|
{
|
|
$this->db->select("pemesanan.idpemesanan, pemesanan.tanggal, pemesanan.status_hutang, harus_dibayar - SUM(pembayaran) as harus_dibayar");
|
|
$this->db->join("bayar_hutang","bayar_hutang.pemesanan_idpemesanan = pemesanan.idpemesanan", "left");
|
|
// $this->db->where("data_user_iddata_user", $id);
|
|
$this->db->where("metode_pembayaran", 2);
|
|
$this->db->where("status_hutang", 0);
|
|
$this->db->group_by("pemesanan_idpemesanan");
|
|
return $this->db->get("pemesanan");
|
|
}
|
|
|
|
}
|