Update besar apk finance
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Dashboard extends CI_Controller {
|
||||
class Dashboard extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('session');
|
||||
$this->load->library('PerformanceCacheService');
|
||||
|
||||
// Cek apakah user sudah login
|
||||
if (!$this->session->userdata('logged_in')) {
|
||||
@@ -16,6 +17,12 @@ class Dashboard extends CI_Controller {
|
||||
|
||||
public function index()
|
||||
{
|
||||
$companyId=(int)$this->companycontext->id();
|
||||
$summary=$this->performancecacheservice->remember('dashboard:summary:'.$companyId,300,function()use($companyId){
|
||||
$row=$this->db->query("SELECT COALESCE(SUM(IF(a.tipe='revenue',d.kredit-d.debit,0)),0) total_revenue,COALESCE(SUM(IF(a.tipe='expense',d.debit-d.kredit,0)),0) total_expense FROM journal_details d JOIN journals j ON j.id=d.journal_id JOIN accounts a ON a.id=d.account_id WHERE j.company_id=? AND j.status IN('posted','reversed') AND a.kategori='laba_rugi' AND a.is_active=1",array($companyId))->row_array();
|
||||
$row['net_profit']=(float)$row['total_revenue']-(float)$row['total_expense'];return$row;
|
||||
});
|
||||
goto dashboard_summary_ready;
|
||||
$this->db->select('
|
||||
accounts.id,
|
||||
accounts.kode_akun,
|
||||
@@ -26,6 +33,8 @@ class Dashboard extends CI_Controller {
|
||||
');
|
||||
$this->db->from('accounts');
|
||||
$this->db->join('journal_details','accounts.id = journal_details.account_id','left');
|
||||
$this->db->join('journals','journals.id = journal_details.journal_id','left');
|
||||
$this->db->where("(journals.status IN ('posted','reversed') OR journal_details.id IS NULL)", null, false);
|
||||
$this->db->where('accounts.kategori','laba_rugi');
|
||||
$this->db->where('accounts.is_active',1);
|
||||
$this->db->group_by('accounts.id');
|
||||
@@ -56,6 +65,7 @@ class Dashboard extends CI_Controller {
|
||||
'net_profit' => $revenue - $expense
|
||||
];
|
||||
|
||||
dashboard_summary_ready:
|
||||
$today = date('Y-m');
|
||||
$ai_insight = $this->db
|
||||
->select('type, severity, message, meta, created_at')
|
||||
@@ -214,6 +224,7 @@ class Dashboard extends CI_Controller {
|
||||
$this->db->from('journal_details');
|
||||
$this->db->join('journals', 'journals.id = journal_details.journal_id', 'left');
|
||||
$this->db->join('accounts', 'accounts.id = journal_details.account_id', 'left');
|
||||
$this->db->where_in('journals.status', array('posted', 'reversed'));
|
||||
$this->db->where('accounts.kategori', 'laba_rugi');
|
||||
$this->db->where('accounts.is_active', 1);
|
||||
|
||||
@@ -269,6 +280,7 @@ class Dashboard extends CI_Controller {
|
||||
{
|
||||
$this->db->select('DISTINCT YEAR(tanggal) as year');
|
||||
$this->db->from('journals');
|
||||
$this->db->where_in('status', array('posted', 'reversed'));
|
||||
$this->db->order_by('year', 'DESC');
|
||||
|
||||
$data = $this->db->get()->result();
|
||||
|
||||
Reference in New Issue
Block a user