Browse Source

Merge branch 'master' of https://git.oslog.id/ibnu/generic-ospro-backend into dev-wahyun

pull/1/head
wahyuun 11 months ago
parent
commit
e1140b57a6
  1. 28
      app/Console/Commands/CalculateProgressGantt.php
  2. 3
      app/Console/Kernel.php
  3. 942
      app/Helpers/MasterFunctionsHelper.php
  4. 133
      app/Http/Controllers/ActivityController.php
  5. 216
      app/Http/Controllers/DashboardBoDController.php
  6. 81
      app/Http/Controllers/DivisiController.php
  7. 73
      app/Http/Controllers/HierarchyFtthController.php
  8. 37
      app/Http/Controllers/ProjectController.php
  9. 71
      app/Http/Controllers/RoleController.php
  10. 98
      app/Http/Controllers/VersionGanttController.php
  11. 3
      app/Models/ChecklistK3.php
  12. 3
      app/Models/Project.php
  13. 2
      app/Models/Role.php
  14. 120
      rest-client.http
  15. 25
      routes/web.php

28
app/Console/Commands/CalculateProgressGantt.php

@ -0,0 +1,28 @@
<?php
namespace App\Console\Commands;
use App\Models\HierarchyFtth;
use Illuminate\Console\Command;
use App\Helpers\MasterFunctionsHelper;
use App\Models\Project;
class CalculateProgressGantt extends Command
{
protected $signature = 'calculate:progressgantt {hierarchy_id}';
protected $description = 'Calculate Progress Gantt';
public function handle()
{
$hierarchy_id = $this->argument('hierarchy_id');
$hierarchy = HierarchyFtth::findOrFail($hierarchy_id);
$project = Project::find($hierarchy->project_id);
$data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id);
$hierarchy->bobot_planning = 100;
$hierarchy->progress =round(((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100, 2);
$hierarchy->save();
}
}

3
app/Console/Kernel.php

@ -14,7 +14,8 @@ class Kernel extends ConsoleKernel
*/ */
protected $commands = [ protected $commands = [
Commands\syncHumanResourceIntegration::class, Commands\syncHumanResourceIntegration::class,
Commands\CalculateSCurve::class Commands\CalculateSCurve::class,
Commands\CalculateProgressGantt::class
]; ];
/** /**

942
app/Helpers/MasterFunctionsHelper.php

File diff suppressed because it is too large Load Diff

133
app/Http/Controllers/ActivityController.php

@ -37,6 +37,94 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200);
} }
public function activitySCurve($proyek_id, $gantt_id){
// "data": [
// {
// "id": 1,
// "text": "Office itinerancy",
// "type": "project",
// "order": "10",
// "progress": 0.4,
// "open": true,
// "user":"0",
// "start_date": "02-04-2024 00:00",
// "duration": 17,
// "end_date": "19-04-2024 00:00",
// "parent": 0
// }
// ],
// "links": [
// {
// "id": "1",
// "source": "1",
// "target": "2",
// "type": "1"
// }
// ]
// }
$checkHeader = Activity::where('version_gantt_id', $gantt_id)->where('type_activity', 'header')->count();
$finalData = [];
if ($checkHeader > 0) {
$dataHeader = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->where('type_activity', 'header')->first();
// $dataHeader->start_date1 = isset($dataHeader->start) ? date_format(date_create($dataHeader->start), "d-m-Y H:i") : NULL;
// $dataHeader->end_date1 = isset($dataHeader->end) ? date_format(date_create($dataHeader->end), "d-m-Y H:i") : NULL;
$dataHeader->progress = $dataHeader->progress / 100;
$dataHeader->type = "project";
$dataHeader->text = $dataHeader->name;
$finalData[] = $dataHeader;
$data = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->where('parent_id', $dataHeader->id)->orderBy('sortorder', 'asc')->get();
} else {
$data = Activity::select('id', 'name as text', 'type_activity as type', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')->where('version_gantt_id', $gantt_id)->whereNull('parent_id')->orderBy('sortorder', 'asc')->get();
}
foreach ($data as $objRow) {
$type = "project";
$dataChildren = $this->getChildrenSCurve($gantt_id, $objRow->id);
if ($objRow->type_activity == "milestone")
$type = $objRow->type_activity;
if (empty($dataChildren))
$type = "task";
$objRow->parent = $objRow->parent_id ? $objRow->parent_id : null;
// $objRow->start_date = isset($objRow->start) ? date_format(date_create($objRow->start), "d-m-Y H:i") : NULL;
// $objRow->end_date1 = isset($objRow->end) ? date_format(date_create($objRow->end), "d-m-Y H:i") : NULL;
$objRow->progress = $objRow->persentase_progress / 100;
$objRow->type = $type;
$finalData[] = $objRow;
$finalData = array_merge($finalData, $dataChildren);
}
$dataLink = Link::where('version_gantt_id', $gantt_id)->get();
$finalLink = [];
foreach ($dataLink as $objRow) {
$dataRow = array(
'id' => $objRow->id,
'source' => $objRow->s_activity_id,
'target' => $objRow->t_activity_id,
'type' => $objRow->type_link,
'code' => $objRow->code_link
);
if ($objRow->lag)
$dataRow['lag'] = $objRow->lag;
$finalLink[] = $dataRow;
}
$resultData = array(
"data" => $finalData,
"links" => $finalLink
);
return response()->json(['status' => 'success', 'data' => $resultData, 'code' => 200], 200);
}
private function getDataActivity($id) private function getDataActivity($id)
{ {
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count();
@ -116,6 +204,43 @@ class ActivityController extends Controller
return $resultData; return $resultData;
} }
private function getChildrenSCurve($gantt_id, $parent_id)
{
$finalData = [];
$data = Activity::select('id', 'name as text', 'type_activity as type', 'bobot_planning', 'persentase_progress as progress', 'start_date', 'end_date', 'duration', 'parent_id', 'sortorder as order')
->where('version_gantt_id', $gantt_id)->where('parent_id', $parent_id)->orderBy('sortorder', 'asc')->get();
foreach ($data as $objRow) {
$objRow->parent = $parent_id;
$objRow->progress = (float) $objRow->bobot_planning /100;
// $objRow->start_date1 = isset($objRow->start) ? date_format(date_create($objRow->start), "d-m-Y H:i") : NULL;
// $objRow->end_date1 = isset($objRow->end) ? date_format(date_create($objRow->end), "d-m-Y H:i") : NULL;
$dataChildren = $this->getChildrenSCurve($gantt_id, $objRow->id);
if ($objRow->type_activity == "milestone") {
$objRow->type = $objRow->type_activity;
// $objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "d-m-Y") : NULL;
} elseif (empty($dataChildren)) {
$objRow->type = "task";
// $objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "d-m-Y") : NULL;
// $objRow->actual_end = isset($objRow->actual_end) ? date_format(date_create($objRow->actual_end), "d-m-Y") : NULL;
// if(isset($objRow->actual_start)){
// $objRow->auto_scheduling = false;
// }
} else {
$objRow->type = "project";
// $actualStart = $this->getFirstLastDateActivity($objRow->id, "start");
// $objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "d-m-Y") : NULL;
// $actualEnd = $this->getFirstLastDateActivity($objRow->id, "end");
// $objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "d-m-Y") : NULL;
}
$finalData[] = $objRow;
$finalData = array_merge($finalData, $dataChildren);
}
return $finalData;
}
private function getChildren($gantt_id, $parent_id) private function getChildren($gantt_id, $parent_id)
{ {
$finalData = []; $finalData = [];
@ -197,7 +322,7 @@ class ActivityController extends Controller
$actualEndValues = array_column(array_filter($dataFinal, function($item) { $actualEndValues = array_column(array_filter($dataFinal, function($item) {
return isset($item['actual_end']); return isset($item['actual_end']);
}), 'actual_end'); }), 'actual_end');
$returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) ? max($actualEndValues) : null; $returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) && count($actualEndValues) > 0 ? max($actualEndValues) : null;
if (isset($parent)) { if (isset($parent)) {
$parent->actual_end = $returnActualStartOrEnd; $parent->actual_end = $returnActualStartOrEnd;
$parent->save(); $parent->save();
@ -479,6 +604,7 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']); $activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text']; $entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100; $entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
$entity['data']['type_activity'] = $entity['data']['type'];
if (isset($entity['data']['rencana_biaya'])) { if (isset($entity['data']['rencana_biaya'])) {
$entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']); $entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']);
} }
@ -1030,4 +1156,9 @@ class ActivityController extends Controller
} }
return response()->json(['status' => 'success', 'data' => $request, 'message' => 'Update successful!', 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $request, 'message' => 'Update successful!', 'code' => 200], 200);
} }
// public function recalculateProject($by, $id){
// // query get activity
// $cekActivity =
// }
} }

216
app/Http/Controllers/DashboardBoDController.php

@ -41,49 +41,63 @@ class DashboardBoDController extends Controller
private function getInvoiceIntegration($search) private function getInvoiceIntegration($search)
{ {
if(empty($search)) if (empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$token = config('api.adw_token'); $token = config('api.adw_token');
$response = $this->curlReq($url, $token); $response = $this->curlReq($url, $token);
if(@$response->data->project_no == "") if (@$response->data->project_no == "")
return null; return null;
return $response; return $response;
} }
// to do public function getCompanyCashFlow($year = '%', $company_id, $all_project, $hierarchy)
public function getCompanyCashFlow($year = '%')
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
// we can't use eloquent's sum() method because someone decided to use varchar as datatype in rencana_biaya field $totalBudgets = null;
$totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) if ($all_project) {
->where('mulai_proyek', 'like', $year) $totalBudgets = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ ->where('company_id', $company_id)
->pluck('sum') ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
->first(); } else {
$totalBudgets = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)'));
}
$projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('company_id', $company_id)
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->get();
}
$projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */
->get();
foreach ($projects as $project) { foreach ($projects as $project) {
$project->expenses = 0; $project->expenses = 0;
$resp = null; $resp = null;
if ($project->kode_sortname != "") { if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
/* $resp = $project->kode_sortname; */
$cost = $resp->data->total_cost ?? 0;
$cost = substr($cost, 0, strpos($cost, "."));
$totalExpenditure += (int) $cost;
$totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
// $resp = $this->getInvoiceIntegration($project->kode_sortname);
// $cost = $resp->data->total_cost ?? 0;
// $cost = substr($cost, 0, strpos($cost, "."));
$cost = 0;
$totalExpenditure = 0;
$totalInvoice = 0;
$totalPaidInvoice = 0;
// $totalExpenditure += (int) $cost;
// $totalInvoice += $resp->data->total_invoice_amount ?? 0;
// $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
} }
return response()->json([ return response()->json([
@ -96,6 +110,7 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
// integrasi
public function getInvoiceOutstanding($year = '%') public function getInvoiceOutstanding($year = '%')
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
@ -122,7 +137,7 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerScheduleHealth($year = '%') public function getTotalProjectPerScheduleHealth($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
@ -132,7 +147,17 @@ class DashboardBoDController extends Controller
'on-schedule' => 0, 'on-schedule' => 0,
]; ];
$projects = Project::where('mulai_proyek', 'like', $year)->get(); $projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('company_id', $company_id)
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->get();
}
foreach ($projects as $index => $project) { foreach ($projects as $index => $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id); $project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0; $selisihProgress = 0;
@ -147,15 +172,13 @@ class DashboardBoDController extends Controller
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
try { try {
if ($selisihProgress > 0 && $selisihProgress <= 5){ if ($selisihProgress > 0 && $selisihProgress <= 5) {
$return['warning'] += 1; $return['warning'] += 1;
$projects[$index]->status = 'warning'; $projects[$index]->status = 'warning';
} } elseif ($selisihProgress == 0) {
elseif ($selisihProgress == 0){
$return['on-schedule'] += 1; $return['on-schedule'] += 1;
$projects[$index]->status = 'on-schedule'; $projects[$index]->status = 'on-schedule';
} } else {
else {
$return['behind-schedule'] += 1; $return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule'; $projects[$index]->status = 'behind-schedule';
} }
@ -167,9 +190,13 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200); return response()->json(['data' => $return, 'q' => $projects], 200);
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%') public function getTotalProjectScheduleHealthPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')
->where('company_id', $company_id)
->get();
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $index => $division) { foreach ($divisions as $index => $division) {
@ -191,13 +218,11 @@ class DashboardBoDController extends Controller
$actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0; $actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0;
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
if ($selisihProgress > 0 && $selisihProgress <= 5){ if ($selisihProgress > 0 && $selisihProgress <= 5) {
$warning++; $warning++;
} } elseif ($selisihProgress == 0) {
elseif ($selisihProgress == 0){
$onSchedule++; $onSchedule++;
} } else {
else {
$behindSchedule++; $behindSchedule++;
} }
} }
@ -214,16 +239,62 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerBudgetHealth($year = '%') public function getTotalProjectPerBudgetHealth($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
return response()->json([ $response = [
'data' => [ 'data' => [
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), 'overrun' => 0,
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), 'warning' => 0,
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), 'on-budget' => 0,
] ]
], 200); ];
if ($all_project) {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('company_id', $company_id)
->count();
} else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('company_id', $company_id)
->count();
} else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'warning')
->where('company_id', $company_id)
->count();
} else {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'warning')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'on-budget')
->where('company_id', $company_id)
->count();
} else {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'on-budget')
->where('created_by_id', $hierarchy)
->count();
}
return response()->json($response, 200);
} }
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health) private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
@ -236,12 +307,13 @@ class DashboardBoDController extends Controller
} }
public function getTotalProjectBudgetHealthPerDivision($year = '%') public function getTotalProjectBudgetHealthPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $division) { foreach ($divisions as $division) {
@ -266,15 +338,23 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerPhase($year = '%') public function getTotalProjectPerPhase($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get(); $projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get();
foreach ($projectPhases as $phase) { foreach ($projectPhases as $phase) {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year) if ($all_project) {
/* ->orWhere('akhir_proyek', 'like', $year) */ $phase->totalProject = Project::where('phase_id', $phase->id)
->count(); ->where('mulai_proyek', 'like', $year)
->where('company_id', $company_id)
->count();
} else {
$phase->totalProject = Project::where('phase_id', $phase->id)
->where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->count();
}
} }
return response()->json([ return response()->json([
'data' => [ 'data' => [
@ -290,15 +370,17 @@ class DashboardBoDController extends Controller
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%') public function getTotalProjectPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name','parent','color') $divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year); $v->total = $this->countTotalProjectInDivision($v->id, $year);
@ -323,16 +405,16 @@ class DashboardBoDController extends Controller
->first(); ->first();
} }
public function getTotalProjectValuePerDivision($year = '%') public function getTotalProjectValuePerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name', 'color') $divisions = Divisi::select('id', 'name', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); $v->total = $this->countTotalProjectValueInDivision($v->id, $year);
foreach ($v->children as $d) { foreach ($v->children as $d) {
@ -347,21 +429,29 @@ class DashboardBoDController extends Controller
} }
public function getDetailExpenditure($year = '%') public function getDetailExpenditure($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = null;
/* ->orWhere('akhir_proyek', 'like', $year) */ if ($all_project) {
->orderBy('id', 'desc') $projects = Project::where('mulai_proyek', 'like', $year)
->get(); ->where('company_id', $company_id)
->orderBy('id', 'desc')
->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->orderBy('id', 'desc')
->get();
}
foreach ($projects as $project) { foreach ($projects as $project) {
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);
if ($project->kode_sortname != "") { if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
$project->invoice = [ $project->invoice = [
'invoiced' => $resp->data->total_invoice_amount ?? 0, 'invoiced' => 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0, 'paid' => 0,
]; ];
} }

81
app/Http/Controllers/DivisiController.php

@ -8,21 +8,23 @@ use App\Models\Divisi;
class DivisiController extends Controller class DivisiController extends Controller
{ {
private function getAllChildren($divisi, $depth = 0, $array = []) { private function getAllChildren($divisi, $depth = 0, $array = [])
{
$divisi->depth = $depth; $divisi->depth = $depth;
array_push($array, $divisi); array_push($array, $divisi);
foreach($divisi->children as $child){ foreach ($divisi->children as $child) {
$array = $this->getAllChildren($child, $depth + 1, $array); $array = $this->getAllChildren($child, $depth + 1, $array);
} }
return $array; return $array;
} }
public function add(Request $request){ public function add(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required|unique:m_divisi,name', 'name' => 'string|required|unique:m_divisi,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'nullable|string', 'description' => 'nullable|string',
'parent' => 'nullable|integer', 'parent' => 'nullable|integer',
'color'=>'nullable|string|max:10' 'color' => 'nullable|string|max:10'
]); ]);
$data = $request->all(); $data = $request->all();
@ -30,15 +32,16 @@ class DivisiController extends Controller
$result = Divisi::create($data); $result = Divisi::create($data);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500]); return response()->json(['status' => 'failed', 'message' => 'Failed to add data', 'code' => 500]);
return response()->json(['status'=>'success','message'=>'Data created!','code'=>200]); return response()->json(['status' => 'success', 'message' => 'Data created!', 'code' => 200]);
} }
public function update(Request $request, $id){ public function update(Request $request, $id)
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required', 'name' => 'string|required',
@ -47,46 +50,46 @@ class DivisiController extends Controller
]); ]);
$data = Divisi::find($id); $data = Divisi::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_divisi,name']) : ''; $request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_divisi,name']) : '';
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all()); $result = $data->update($request->all());
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=> 'Update failed!','code'=> 500], 500); return response()->json(['status' => 'failed', 'message' => 'Update failed!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
} }
public function delete($id) public function delete($id)
{ {
if(empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Divisi::find($id); $data = Divisi::find($id);
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$delete = $data->delete(); $delete = $data->delete();
if(!$delete) if (!$delete)
return response()->json(['status'=>'failed','message'=> 'Delete failed!','code'=> 500], 500); return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
} }
public function search(Request $request) public function search(Request $request)
{ {
$payload = $request->all(); $payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_divisi'); $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
//return $this->list(); //return $this->list();
// cant use builder for this case // cant use builder for this case
} }
@ -95,20 +98,20 @@ class DivisiController extends Controller
{ {
$parentMenus = Divisi::whereNull('parent')->with('children')->get(); $parentMenus = Divisi::whereNull('parent')->with('children')->get();
$divisions = []; $divisions = [];
foreach($parentMenus as $menu){ foreach ($parentMenus as $menu) {
$childs = $this->getAllChildren($menu); $childs = $this->getAllChildren($menu);
foreach($childs as $d){ foreach ($childs as $d) {
$d->displayName = ' ' . $d->name; $d->displayName = ' ' . $d->name;
for($i=0; $i < $d->depth; $i++){ for ($i = 0; $i < $d->depth; $i++) {
$d->displayName = '--' . $d->displayName ; $d->displayName = '--' . $d->displayName;
} }
array_push($divisions, $d); array_push($divisions, $d);
} }
} }
$countData = count($divisions); $countData = count($divisions);
if($countData == 0) if ($countData == 0)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=> $divisions, 'totalRecord'=> $countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
} }
} }

73
app/Http/Controllers/HierarchyFtthController.php

@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use App\Models\HierarchyFtth; use App\Models\HierarchyFtth;
use App\Models\VersionGantt; use App\Models\VersionGantt;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Artisan;
class HierarchyFtthController extends Controller class HierarchyFtthController extends Controller
{ {
@ -102,36 +103,41 @@ class HierarchyFtthController extends Controller
} }
} }
public function countProgress($project_id) { public function countProgress($hierarchy_id) {
$ftthIds = VersionGantt::select('hierarchy_ftth_id') // $ftthIds = VersionGantt::select('hierarchy_ftth_id')
->where('proyek_id', $project_id) // ->where('proyek_id', $project_id)
->groupBy('hierarchy_ftth_id') // ->groupBy('hierarchy_ftth_id')
->get(); // ->get();
if($ftthIds){ // if($ftthIds){
foreach ($ftthIds as $ftthId) { // foreach ($ftthIds as $ftthId) {
$gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress'); // $gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress');
$bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot'); // $bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot');
$ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count(); // $ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count();
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
if($ftth){
$round = $gantts/$ganttCount;
$round_bobot = $bobot_planning/$ganttCount;
$ftth->progress = round($round, 2);
$ftth->bobot_planning = round($round_bobot, 2);
try {
$ftth->save();
} catch (\Exception $e) {
// Log the error or handle it in some other way
Log::error($e->getMessage());
}
if($ftth->parent_id){ // $ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
$this->countParent($ftth); // if($ftth){
} // $round = $gantts/$ganttCount;
} // $round_bobot = $bobot_planning/$ganttCount;
} // $ftth->progress = round($round, 2);
} // $ftth->bobot_planning = round($round_bobot, 2);
// try {
// $ftth->save();
// } catch (\Exception $e) {
// // Log the error or handle it in some other way
// Log::error($e->getMessage());
// }
// if($ftth->parent_id){
// $this->countParent($ftth);
// }
// }
// }
// }
// calculate ke curva berdasarkan site
Artisan::call('calculate:progressgantt', [
'hierarchy_id' => $hierarchy_id
]);
} }
public function countParent($ftth){ public function countParent($ftth){
@ -179,7 +185,6 @@ class HierarchyFtthController extends Controller
public function getTreeByProject($project_id) public function getTreeByProject($project_id)
{ {
$this->countProgress(intval($project_id));
$data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get(); $data = HierarchyFtth::where('project_id', $project_id)->whereNull('parent_id')->orderByRaw('id ASC')->get();
$finalData = []; $finalData = [];
foreach($data as $objRow){ foreach($data as $objRow){
@ -204,7 +209,13 @@ class HierarchyFtthController extends Controller
return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200); return response()->json(['status'=>'success','data'=>$finalData,'code'=>200], 200);
} }
public function countProgressTree($hierarchy_id)
{
Artisan::call('calculate:progressgantt', [
'hierarchy_id' => $hierarchy_id
]);
return response()->json(['status'=>'success','code'=>200], 200);
}
private function getChildren($project_id, $parent_id) private function getChildren($project_id, $parent_id)
{ {
$finalData = []; $finalData = [];

37
app/Http/Controllers/ProjectController.php

@ -360,6 +360,13 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
} }
// testing
public function calculateSCurvetest(Request $request)
{
$data = MasterFunctionsHelper::calculateSCurve($request->project_id);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function calculateSCurve(Request $request) public function calculateSCurve(Request $request)
{ {
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); $sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
@ -551,16 +558,25 @@ class ProjectController extends Controller
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if ($result['type_proyek_id'] === 9) { if ($result['type_proyek_id'] === 9) {
$actualEndExist = Activity::where('proyek_id', $id)->exists(); // $actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id); // $query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc')
->first();
} else { } else {
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
} else { } else {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
@ -569,10 +585,13 @@ class ProjectController extends Controller
} else { } else {
$startDate = $query->orderBy('start_date')->value('start_date'); $startDate = $query->orderBy('start_date')->value('start_date');
} }
if ($actualEndExist) { // if($actualEndExist)
$maxEndDate = $query->max('id'); // {
$endDate = $query->where('id', $maxEndDate)->first()->end_date; // // $maxEndDate = $query->max('id');
} // // get last end_date
// // $endDate = $query->where('id',$maxEndDate)->first()->end_date;
// }
$plannedStart = Activity::where('version_gantt_id', $ganttId) $plannedStart = Activity::where('version_gantt_id', $ganttId)
->orderBy('planned_start') ->orderBy('planned_start')
@ -581,7 +600,7 @@ class ProjectController extends Controller
->orderByDesc('planned_end') ->orderByDesc('planned_end')
->value('planned_end'); ->value('planned_end');
$result->header->start_date = $startDate; $result->header->start_date = $startDate;
$result->header->end_date = $endDate; $result->header->end_date = $maxEndDate->end_date;
$result->header->planned_start = $plannedStart; $result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd; $result->header->planned_end = $plannedEnd;
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200);

71
app/Http/Controllers/RoleController.php

@ -11,76 +11,77 @@ class RoleController extends Controller
public function add(Request $request) public function add(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required|unique:m_roles,name', 'name' => 'string|required|unique:m_roles,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'required' 'description' => 'required'
]); ]);
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
if (!isset($data['default_page'])) { if (!isset($data['default_page'])) {
$data['default_page'] = 29; // dashboard $data['default_page'] = 29; // dashboard
} }
$result = Role::create($data); $result = Role::create($data);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
} }
public function edit( $id){ public function edit($id)
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Role::find($id); $result = Role::find($id);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} }
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
if(empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required', 'name' => 'string|required',
'description' => 'required' 'description' => 'required'
]); ]);
$data = Role::find($id); $data = Role::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_roles,name']) : ''; $request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_roles,name']) : '';
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all()); $result = $data->update($request->all());
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to update the data!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to update the data!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
} }
public function delete($id) public function delete($id)
{ {
if(empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Role::find($id); $data = Role::find($id);
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=>404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$delete = $data->delete(); $delete = $data->delete();
if(!$delete) if (!$delete)
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200);
} }
public function search(Request $request) public function search(Request $request)
@ -93,7 +94,7 @@ class RoleController extends Controller
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
} }
public function list() public function list()
@ -101,9 +102,9 @@ class RoleController extends Controller
$data = Role::all(); $data = Role::all();
$countData = $data->count(); $countData = $data->count();
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list role, please try again later!', 'code' => 400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} }
} }

98
app/Http/Controllers/VersionGanttController.php

@ -14,7 +14,8 @@ use App\Models\ActivityProgressLog;
class VersionGanttController extends Controller class VersionGanttController extends Controller
{ {
public function add(Request $request){ public function add(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'name_version' => 'required', 'name_version' => 'required',
'proyek_id' => 'required' 'proyek_id' => 'required'
@ -23,30 +24,31 @@ class VersionGanttController extends Controller
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$result = VersionGantt::create($data); $result = VersionGantt::create($data);
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfull created', 'code' => 200, 'id' => $result->id]);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>400]); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed created', 'code' => 400]);
} }
} }
public function update(Request $request, $id){ public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){ if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
} }
$data = VersionGantt::find($id); $data = VersionGantt::find($id);
if($data){ if ($data) {
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die(); die();
} }
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully updated!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed updated!', 'code' => 400], 400);
} }
} }
@ -54,19 +56,19 @@ class VersionGanttController extends Controller
{ {
$data = VersionGantt::find($id); $data = VersionGantt::find($id);
if($data){ if ($data) {
$delete = $data->delete(); $delete = $data->delete();
$this->deleteRelative($data['id']); $this->deleteRelative($data['id']);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die(); die();
} }
if($delete){ if ($delete) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully deleted!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed deleted!', 'code' => 400], 400);
} }
} }
@ -81,18 +83,19 @@ class VersionGanttController extends Controller
ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete();
} }
public function edit($id){ public function edit($id)
if(!$id || (int) $id < 0 || $id==""){ {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die(); die();
} }
$result = VersionGantt::find($id); $result = VersionGantt::find($id);
if($result){ if ($result) {
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get data version gantt, please try again later!', 'code' => 400], 400);
} }
} }
@ -106,23 +109,24 @@ class VersionGanttController extends Controller
$dataGet = $builder->get(); $dataGet = $builder->get();
// $totalRecord = $countBuilder->count(); // $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
} }
public function ganttProgress($column, $value){ public function ganttProgress($column, $value)
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning') {
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') $progress = VersionGantt::select('m_version_gantt.id', 'm_activity.persentase_progress', 'm_activity.bobot_planning')
->where("m_version_gantt.".$column, $value) ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
// ->where('m_activity.type_activity', "project") ->where("m_version_gantt." . $column, $value)
->where('m_activity.parent_id', null) // ->where('m_activity.type_activity', "project")
->get(); ->where('m_activity.parent_id', null)
foreach($progress as $item) { ->get();
if($item->persentase_progress){ foreach ($progress as $item) {
$item->progress = $item->persentase_progress; if ($item->persentase_progress) {
$item->bobot = $item->bobot_planning; $item->progress = $item->persentase_progress;
$item->save(); $item->bobot = $item->bobot_planning;
$item->save();
}
} }
}
} }
public function list() public function list()
@ -130,10 +134,10 @@ class VersionGanttController extends Controller
$data = VersionGantt::all(); $data = VersionGantt::all();
$countData = $data->count(); $countData = $data->count();
if($data){ if ($data) {
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list version gantt, please try again later!', 'code' => 400], 400);
} }
} }
} }

3
app/Models/ChecklistK3.php

@ -17,6 +17,7 @@ class ChecklistK3 extends Model
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by',
'company_id'
]; ];
} }

3
app/Models/Project.php

@ -48,6 +48,7 @@ class Project extends Model
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by', 'updated_by',
'created_by_id' 'created_by_id',
'company_id'
]; ];
} }

2
app/Models/Role.php

@ -12,6 +12,6 @@ class Role extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', 'all_project'
]; ];
} }

120
rest-client.http

@ -1,4 +1,5 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY5MTc2MDYyNCwiZXhwIjoxNjkyMzY1NDI0LCJuYmYiOjE2OTE3NjA2MjQsImp0aSI6Ikd2bEFPTE4yZ2FuRFdVbjEiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.XNGbsmcgQ-CkV8vLlvnItGKM0R1am5X5b6qUFOR1DRo @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9iYWNrZW5kLnRlc3RcL2FwaVwvbG9naW4iLCJpYXQiOjE3MDEzNzMzNzQsImV4cCI6MTcwMTk3ODE3NCwibmJmIjoxNzAxMzczMzc0LCJqdGkiOiJhbkJWOHIwUDZndFRXZk5KIiwic3ViIjoxNzg4LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.QCiXq-62da7Sdk7sEb_J0apEij_R6IQgZVYG9iL6M8g
@tokenS = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjkxNTcyMTIwLCJleHAiOjE2OTIxNzY5MjAsIm5iZiI6MTY5MTU3MjEyMCwianRpIjoiVUdqbnhLRVdlZzYyTTBnayIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.5QqK0dLW5jzbVOkSCSW0mFo0K7ycGOBW9NCG_2Zldm4 @tokenS = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjkxNTcyMTIwLCJleHAiOjE2OTIxNzY5MjAsIm5iZiI6MTY5MTU3MjEyMCwianRpIjoiVUdqbnhLRVdlZzYyTTBnayIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.5QqK0dLW5jzbVOkSCSW0mFo0K7ycGOBW9NCG_2Zldm4
@ -6,7 +7,7 @@
# @hostname = https://ospro-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api
# @hostname = https://api-iu.ospro.id/api # @hostname = https://api-iu.ospro.id/api
# @hostname = https://api-staging-adw.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api
@hostname = http://localhost:8444/api @hostname = http://backend.test/api
# @hostname = http://103.73.125.81:8444/api # @hostname = http://103.73.125.81:8444/api
# @hostname = http://localhost:8444/adw-backend/api # @hostname = http://localhost:8444/adw-backend/api
@ -17,8 +18,8 @@ POST {{hostname}}/login
content-type: application/json content-type: application/json
{ {
"username": "admin", "username": "testing",
"password": "1nt3gr4s14" "password": "testing123"
} }
###### Tools Req ###### Tools Req
@ -418,7 +419,7 @@ content-type: application/json
"operator": "AND" "operator": "AND"
} }
], ],
"select": ["kode_sortname", "nama", "mulai_proyek"], "select": ["id", "nama", "rencana_biaya", "type_proyek_id", "currency_symbol", "mulai_proyek", "akhir_proyek"],
"joins": [ "joins": [
{ {
"name": "m_users", "name": "m_users",
@ -455,7 +456,43 @@ Authorization: Bearer {{tokenS}}
content-type: application/json content-type: application/json
{ {
"columns":[{"name":"nama","logic_operator":"ilike","value":"","operator":"AND"}],"joins":[{"name":"m_users","column_join":"pm_id","column_results":["name","username"]},{"name":"m_type_proyek","column_join":"type_proyek_id","column_results":["name","description"]}],"orders":{"columns":["id"],"ascending":false},"paging":{"start":0,"length":10} "columns": [
{
"name": "nama",
"logic_operator": "ilike",
"value": "",
"operator": "AND"
}
],
"select": ["id", "nama", "rencana_biaya", "color_progress", "currency_symbol", "mulai_proyek", "akhir_proyek"],
"joins": [
{
"name": "m_users",
"column_join": "pm_id",
"column_results": [
"name",
"username"
]
},
{
"name": "m_type_proyek",
"column_join": "type_proyek_id",
"column_results": [
"name",
"description"
]
}
],
"orders": {
"columns": [
"id"
],
"ascending": false
},
"paging": {
"start": 0,
"length": 10
}
} }
### add ### add
@ -529,7 +566,7 @@ content-type: application/json
###### Activity ###### Activity
### get data by id version ### get data by id version
GET {{hostname}}/activity/33/29/get GET {{hostname}}/activity/550/137/get
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
@ -785,24 +822,44 @@ content-type: application/json
### ###
POST {{hostname}}/activity/get-curva-s POST {{hostname}}/dashboard/curva-s
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{ {
"project_id": [47], "project_id": [15]
"period": "week"
} }
###
POST {{hostname}}/project/s-curve-command-test
Authorization: Bearer {{token}}
content-type: application/json
# {"period":"week","project_id":"137","gantt_id":"916"}
# {"period":"week","project_id":"129","gantt_id":"862"}
{"period":"week","project_id":"140","gantt_id":"1103"}
### ###
POST {{hostname}}/dashboard/curva-s POST {{hostname}}/project/calculate-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{"period":"week","project_id":"129","gantt_id":"862"}
### {"period":"week","project_id":"135","gantt_id":"891"}
#######
POST {{hostname}}/project/get-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{"project_id":"164","gantt_id":"973","period":"week"}
### {"period":"week","project_id":"129","gantt_id":"800"}
#######
GET {{hostname}}/activity/s-curve/137/892
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{
"project_id": [15]
}
### ###
GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c
@ -957,6 +1014,27 @@ content-type: application/json
"user_id": 1247 "user_id": 1247
} }
# -6.226761,106.809311 jkarta
# -6.465806,106.760559
# -6.356175,108.336182 indramayu
# -6.266805,106.468048, tigaraksa
# -6.205115,106.918373 jatinegara
######
POST {{hostname}}/presence/test
Authorization: Bearer {{token}}
content-type: application/json
{
"clock_in_out": {
"clock_out_lat": -6.356175,
"clock_out_lng": 108.336182,
"type" : "out"
},
"time": "2023-08-15T14:48:17+07:00",
"user_id": 1566
}
###### ######
POST {{hostname}}/presence/add POST {{hostname}}/presence/add
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
@ -1016,9 +1094,7 @@ POST {{hostname}}/map-monitoring/search
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
{ {"project_id":[140,138,132,130]}
"project_id" : [75, 76, 78]
}
###### ######
POST {{hostname}}/waypoint/add-bulk POST {{hostname}}/waypoint/add-bulk
@ -1159,13 +1235,3 @@ content-type: application/json
} }
} }
#######
POST {{hostname}}/project/get-s-curve
Authorization: Bearer {{token}}
content-type: application/json
{
"period":"week",
"project_id":"118",
"gantt_id":"287"
}

25
routes/web.php

@ -23,16 +23,16 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->group(['middleware' => ['auth', 'cors']], function () use ($router) { $router->group(['middleware' => ['auth', 'cors']], function () use ($router) {
$router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure $router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); $router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); $router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); $router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); $router->get('/dashboard/get-total-project-budget-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase'); $router->get('/dashboard/get-total-project-per-phase/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); $router->get('/dashboard/get-total-project-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); $router->get('/dashboard/get-total-project-value-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); $router->get('/dashboard/get-detail-expenditure/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getDetailExpenditure');
$router->post('/role/search', 'RoleController@search'); $router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add'); $router->post('/role/add', 'RoleController@add');
@ -69,17 +69,19 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/project/get-s-curve', 'ProjectController@getSCurve'); $router->post('/project/get-s-curve', 'ProjectController@getSCurve');
$router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve'); $router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve');
$router->post('/project/s-curve-command', 'ProjectController@sCurveCommand'); $router->post('/project/s-curve-command', 'ProjectController@sCurveCommand');
$router->post('/project/s-curve-command-test', 'ProjectController@calculateSCurvetest');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve'); $router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');
/* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */
/* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */
/* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */
/* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */
$router->get('/project-carausell','ProjectCarausellController@invoke'); $router->get('/project-carausell', 'ProjectCarausellController@invoke');
$router->post('/project-charter/search', 'ProjectCharterController@search'); $router->post('/project-charter/search', 'ProjectCharterController@search');
$router->post('/project-charter/add', 'ProjectCharterController@add'); $router->post('/project-charter/add', 'ProjectCharterController@add');
@ -214,6 +216,8 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate'); $router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule'); $router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->get('/activity/s-curve/{proyek_id}/{gantt_id}', 'ActivityController@activitySCurve');
$router->post('/task', 'ActivityController@add'); $router->post('/task', 'ActivityController@add');
$router->get('/task/edit/{id}', 'ActivityController@edit'); $router->get('/task/edit/{id}', 'ActivityController@edit');
$router->put('/task/{id}', 'ActivityController@update'); $router->put('/task/{id}', 'ActivityController@update');
@ -488,6 +492,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update'); $router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update');
$router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy'); $router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy');
$router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject'); $router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject');
$router->get('/hierarchy-ftths/count-tree/{hierarchy_id}', 'HierarchyFtthController@countProgressTree');
$router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt'); $router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt');
$router->post('/map-monitoring/search', 'MapMonitoringController@search'); $router->post('/map-monitoring/search', 'MapMonitoringController@search');

Loading…
Cancel
Save