82 lines
4.2 KiB
PHP
82 lines
4.2 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Exports;
|
||
|
|
||
|
use DB;
|
||
|
use Illuminate\Contracts\View\View;
|
||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||
|
|
||
|
class LaporanProjectExport implements FromView
|
||
|
{
|
||
|
|
||
|
protected $param;
|
||
|
|
||
|
public function __construct($param)
|
||
|
{
|
||
|
|
||
|
$this->param = $param;
|
||
|
}
|
||
|
|
||
|
public function view(): View
|
||
|
{
|
||
|
$param = $this->param;
|
||
|
$path = $param['path'];
|
||
|
|
||
|
if ($path == 'new') {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
where mpt.status_id = 7
|
||
|
order by created_at desc");
|
||
|
} else if($path == 'op') {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
where mpt.status_id in (1,2,3,4)
|
||
|
order by created_at desc");
|
||
|
} else if($path == 'cancel') {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
where mpt.status_id in (6, 8)
|
||
|
order by created_at desc");
|
||
|
} else if($path == 'overdue') {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
where mpt.status_id not in (5,6,7,8) and (DATE_PART('day', mpt.date_deadline::timestamp - CURRENT_DATE::timestamp)) >=0
|
||
|
order by created_at desc");
|
||
|
} else if($path == 'done') {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
where mpt.status_id = 5 and mpt.status_approve = true
|
||
|
order by created_at desc");
|
||
|
} else {
|
||
|
$data = DB::select("select mpt.*, rs.definition as status, rcl.definition as lvlurgent, mp.project_name, mu.full_name as implementor
|
||
|
from master_project_task mpt
|
||
|
join master_project mp on mp.id = mpt.project_id
|
||
|
left join master_user mu on mu.id = mpt.user_imp_id
|
||
|
left join ref_status rs on rs.id = mpt.status_id
|
||
|
left join ref_critical_level rcl on rcl.id = mpt.critical_level_id
|
||
|
order by created_at desc");
|
||
|
}
|
||
|
|
||
|
return view('content.others.laporan_project', ['data' => $data, 'path' => $path]);
|
||
|
}
|
||
|
}
|