Update besar apk finance
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
class Professionalreports extends MY_Controller
|
||||
{
|
||||
public function __construct(){parent::__construct();$this->requirePermission('reports');$this->load->database();$this->load->library(array('ProfessionalReportService','CompanyContext','JobQueueService'));}
|
||||
private function filter(){$to=$this->input->get_post('to')?:date('Y-m-d');return array('from'=>$this->input->get_post('from')?:date('Y-m-01',strtotime($to)),'to'=>$to,'account_id'=>(int)$this->input->get_post('account_id'));}
|
||||
private function reportFilter($code,array$f){if($code==='balance_sheet')$f['from']='1900-01-01';return$f;}
|
||||
public function index(){$code=$this->input->get('report')?:'trial_balance';$f=$this->filter();$reportFilters=$this->reportFilter($code,$f);$d=array('active_menu'=>'professional_reports','report'=>$code,'filters'=>$f,'rows'=>$this->professionalreportservice->run($code,$reportFilters),'profit_loss_rows'=>$code==='balance_sheet'?$this->professionalreportservice->run('profit_loss',$reportFilters):array());$d['accounts']=$this->db->where('company_id',$this->companycontext->id())->order_by('kode_akun')->get('accounts')->result();$d['company']=$this->db->get_where('companies',array('id'=>$this->companycontext->id()))->row();$this->load->view('partials/header',$d);$this->load->view('professional_reports/index',$d);$this->load->view('partials/footer');}
|
||||
public function export($code){$f=$this->reportFilter($code,$this->filter());$rows=$this->professionalreportservice->run($code,$f);$this->output->set_content_type('text/csv')->set_header('Content-Disposition: attachment; filename="'.$code.'-'.$f['to'].'.csv"');$h=fopen('php://output','w');if($rows){fputcsv($h,array_keys($rows[0]));foreach($rows as$r)fputcsv($h,$r);}fclose($h);}
|
||||
public function save_filter(){$this->db->insert('saved_report_filters',array('user_id'=>$this->session->userdata('user_id'),'report_code'=>$this->input->post('report_code'),'name'=>$this->input->post('name',true),'filter_json'=>json_encode($this->filter()),'created_at'=>date('Y-m-d H:i:s'),'company_id'=>$this->companycontext->id()));redirect('professionalreports?report='.$this->input->post('report_code'));}
|
||||
public function snapshot($code){$f=$this->reportFilter($code,$this->filter());$rows=$this->professionalreportservice->run($code,$f);$hash=hash('sha256',json_encode($f));if(!$this->db->get_where('report_snapshots',array('report_code'=>$code,'period_end'=>$f['to'],'filter_hash'=>$hash,'company_id'=>$this->companycontext->id()))->row())$this->db->insert('report_snapshots',array('report_code'=>$code,'period_end'=>$f['to'],'filter_hash'=>$hash,'payload'=>json_encode($rows),'created_by'=>$this->session->userdata('user_id'),'created_at'=>date('Y-m-d H:i:s'),'company_id'=>$this->companycontext->id()));redirect('professionalreports?report='.$code.'&to='.$f['to']);}
|
||||
public function queue($code){$filters=$this->reportFilter($code,$this->filter());$format=$this->input->post('format')?:'csv';$key='report:'.$this->companycontext->id().':'.$this->session->userdata('user_id').':'.$code.':'.$format.':'.hash('sha256',json_encode($filters));$this->jobqueueservice->enqueue('report_export',array('report_code'=>$code,'format'=>$format,'filters'=>$filters,'requested_by'=>$this->session->userdata('user_id')),$key,'reports',5,3,$this->companycontext->id());$this->session->set_flashdata('success','Export laporan masuk antrean background.');redirect('professionalreports?report='.$code);}
|
||||
}
|
||||
Reference in New Issue
Block a user