@ -111,22 +111,30 @@ class DashboardBoDController extends Controller
}
}
// integrasi
// integrasi
public function getInvoiceOutstanding($year = '%')
public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy )
{
{
$year = $this->interpolateYear($year);
$year = $this->interpolateYear($year);
$projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year)
$projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->where('company_id', $company_id)
->get();
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->get();
}
$return = [];
$return = [];
foreach ($projects as $project) {
foreach ($projects as $project) {
$resp = null;
$resp = null;
if ($project->kode_sortname != "") {
if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
// $resp = $this->getInvoiceIntegration($project->kode_sortname);
array_push($return, [
array_push($return, [
'project' => $project->nama,
'project' => $project->nama,
'project_code' => $project->kode_sortname,
'project_code' => $project->kode_sortname,
'invoiced' => $resp->data->total_invoice_amount ?? 0,
'invoiced' => 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0,
'paid' => 0,
'response' => $resp,
'response' => $resp,
]);
]);
}
}