Browse Source

Merge pull request 'staging' (#117) from staging into master

Reviewed-on: ordo/adw-backend#117
pull/3/head
ibnu 1 year ago
parent
commit
1db962d836
  1. 30
      app/Http/Controllers/ActivityController.php
  2. 42
      app/Http/Controllers/ProjectController.php

30
app/Http/Controllers/ActivityController.php

@ -36,7 +36,8 @@ class ActivityController extends Controller
private function getDataActivity($id)
{
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count(); $finalData = [];
$checkHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->count();
$finalData = [];
if ($checkHeader > 0) {
$dataHeader = Activity::where('version_gantt_id', $id)->where('type_activity', 'header')->first();
$startDate = date_create($dataHeader->start_date);
@ -79,8 +80,7 @@ class ActivityController extends Controller
$dataLink = Link::where('version_gantt_id', $id)->get();
$finalLink = [];
foreach($dataLink as $objRow)
{
foreach ($dataLink as $objRow) {
$dataRow = array(
'id' => $objRow->id,
'source' => $objRow->s_activity_id,
@ -129,7 +129,8 @@ class ActivityController extends Controller
return $finalData;
}
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null) {
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
{
$project = Project::find($proyek_id);
if ($hierarchy_ftth_id) {
$gantt = VersionGantt::find($id);
@ -233,7 +234,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'action' => 'inserted', 'tid' => $result->id, '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);
@ -270,7 +272,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'update_bobot' => $updateBobot, 'data' => $dataUpdate, 'action' => 'updated', 'message' => 'Activity updated!', 'code' => 200], 200);
}
private function updateOrder($taskId, $target){
private function updateOrder($taskId, $target)
{
$nextTask = false;
$targetId = $target;
@ -293,7 +296,8 @@ class ActivityController extends Controller
$updatedTask->save();
}
public function updateRegular(Request $request, $id){
public function updateRegular(Request $request, $id)
{
if (empty($id) || !is_int((int) $id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -396,7 +400,8 @@ class ActivityController extends Controller
$data['activities'][$key]['weight'] = $parentWeight / $siblingsCount;
}
};
}
;
}
$projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first();
foreach ($data['activities'] as $i => $activity_row) {
@ -527,7 +532,8 @@ class ActivityController extends Controller
return response()->json(['stack' => $activityStack, 'status' => 'success', 'message' => 'Data imported!', 'projectId' => $projectId, 'code' => 200], 200);
}
private function getLatestGantt($id){
private function getLatestGantt($id)
{
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
$data = array(
"last_gantt_id" => $maxGanttId,
@ -696,7 +702,8 @@ class ActivityController extends Controller
"date" => $tempDate,
"percentage" => $tempPercentage,
"data_details" => $arr_ActualM,
"budget_control" =>array("current_budget"=> $totalRencanaBudget,
"budget_control" => array(
"current_budget" => $totalRencanaBudget,
"acwp" => round($totalACWP, 0),
"bcwp" => round($totalBCWP, 0),
"rem_to_complete" => ($totalRencanaBudget - round($totalACWP, 0)),
@ -756,7 +763,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'failed', 'message' => 'File is required!', 'code' => 400], 400);
}
public function importUpdate(Request $request) {
public function importUpdate(Request $request)
{
$data = $request->all();
foreach ($data as $value) {
$activity = Activity::find($value['id']);

42
app/Http/Controllers/ProjectController.php

@ -349,6 +349,25 @@ class ProjectController extends Controller
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public static function setSyncDate($activity_id, $activity, $report) {
$status = ReportActivityMaterial::select('description')->where('activity_id', $activity_id)->first();
if (isset($status) && $status != 'done') {
$minDate = date_create($report->report_date);
$maxDate = date_create($report->report_date);
date_add($maxDate, date_interval_create_from_date_string($activity->duration . " days"));
} else {
$material = AssignMaterial::where('activity_id', $activity_id)->first();
$minDate = $material->start_activity;
$maxDate = $material->finish_activity;
}
$reports = array(
'activity_id' => $activity_id,
'min_date' => $minDate,
'max_date' => $maxDate
);
return $reports;
}
public function synchronizeReport($gantt_id)
{
$activities = Activity::where("version_gantt_id", $gantt_id)->get();
@ -360,21 +379,12 @@ class ProjectController extends Controller
if ($countReports === 1) {
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get();
foreach($dataReports as $dr) {
$reports[] = array(
'activity_id'=>$activity_id,
'min_date'=>$dr->report_date,
'max_date'=>date_modify(date_create($dr->report_date), "1 days")
);
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr);
}
}
if ($countReports > 1) {
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first();
$lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first();
$reports[] = array(
'activity_id'=>$activity_id,
'min_date'=>$firstReport->report_date,
'max_date'=>date_modify(date_create($lastReport->report_date), "1 days")
);
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport);
}
$activity->reports = $reports;
}
@ -383,8 +393,16 @@ class ProjectController extends Controller
for ($i=0; $i < count($reports); $i++) {
$activity = Activity::find($reports[$i]['activity_id']);
$successor = Link::where('t_activity_id', $activity->id)->first();
if ($successor) {
$predecessor = Activity::find($successor->s_activity_id);
$activity->start_date = $predecessor->end_date;
$reports[$i]['max_date']->modify('1 day');
} else {
$reports[$i]['max_date']->modify('-1 day');
}
$activity->start_date = $reports[$i]['min_date'];
$activity->end_date = $reports[$i]['max_date'];
$activity->end_date = $reports[$i]['max_date']->setTime(23,59,59);
$activity->save();
}

Loading…
Cancel
Save