|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers; |
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use DateTime; |
|
|
|
use App\Models\Link; |
|
|
|
use App\Models\Link; |
|
|
|
use App\Models\User; |
|
|
|
use App\Models\User; |
|
|
|
use App\Models\Image; |
|
|
|
use App\Models\Image; |
|
|
@ -366,7 +367,16 @@ class ProjectController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function setSyncDate($activity_id, $activity, $report) { |
|
|
|
public static function setSyncDate($activity_id, $activity, $report) { |
|
|
|
$status = AssignMaterial::select('status_activity')->where('activity_id', $activity_id)->first(); |
|
|
|
$status = AssignMaterial::where('activity_id', $activity_id)->first(); |
|
|
|
|
|
|
|
if (!isset($status)) { |
|
|
|
|
|
|
|
$reports = array( |
|
|
|
|
|
|
|
'activity_id' => $activity_id, |
|
|
|
|
|
|
|
'min_date' => new DateTime($activity->start_date), |
|
|
|
|
|
|
|
'max_date' => new DateTime($activity->end_date), |
|
|
|
|
|
|
|
'status' => 'open' |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return $reports; |
|
|
|
|
|
|
|
} |
|
|
|
if (!isset($status->status_activity)) { |
|
|
|
if (!isset($status->status_activity)) { |
|
|
|
$status->status_activity = 'open'; |
|
|
|
$status->status_activity = 'open'; |
|
|
|
} |
|
|
|
} |
|
|
@ -406,7 +416,6 @@ class ProjectController extends Controller |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport); |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport); |
|
|
|
} |
|
|
|
} |
|
|
|
$activity->reports = $reports; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ |
|
|
|
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ |
|
|
|
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ |
|
|
|
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ |
|
|
@ -429,6 +438,18 @@ class ProjectController extends Controller |
|
|
|
$activity->save(); |
|
|
|
$activity->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach($activities as $activity) { |
|
|
|
|
|
|
|
$successor = Link::where('t_activity_id', $activity->id)->first(); |
|
|
|
|
|
|
|
if ($successor) { |
|
|
|
|
|
|
|
$predecessor = Activity::find($successor->s_activity_id); |
|
|
|
|
|
|
|
$activity->start_date = $predecessor->end_date; |
|
|
|
|
|
|
|
$end_date = new DateTime($activity->start_date); |
|
|
|
|
|
|
|
$end_date->modify("+" . $activity->duration . " days"); |
|
|
|
|
|
|
|
$activity->end_date = $end_date->format("Y-m-d H:i:sO"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$activity->save(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); |
|
|
|
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -476,7 +497,7 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
public function detail($id){ |
|
|
|
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){ |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
@ -484,37 +505,49 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
if (!isset($gantt_id)) { |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($id); |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($id); |
|
|
|
|
|
|
|
$ganttId = $gantt['last_gantt_id']; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$ganttId = $gantt_id; |
|
|
|
|
|
|
|
} |
|
|
|
$result->projectManager = User::where('id', $result->pm_id)->value('name'); |
|
|
|
$result->projectManager = User::where('id', $result->pm_id)->value('name'); |
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); |
|
|
|
|
|
|
|
// dd($result->header->start_date); |
|
|
|
|
|
|
|
$ganttId = $gantt['last_gantt_id']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); |
|
|
|
if (isset($s_curve)) { |
|
|
|
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); |
|
|
|
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); |
|
|
|
|
|
|
|
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); |
|
|
|
|
|
|
|
$actualEndExist = Activity::where('proyek_id', $id)->whereNotNull('actual_end')->exists(); |
|
|
|
|
|
|
|
$query = Activity::where('proyek_id', $id); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$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(); |
|
|
|
|
|
|
|
$actualEndExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_end')->exists(); |
|
|
|
|
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($actualStartExist) { |
|
|
|
if ($actualStartExist) { |
|
|
|
$startDate = Activity::where('version_gantt_id', $ganttId) |
|
|
|
$startDate = $query->orderBy('actual_start')->value('start_date'); |
|
|
|
->orderBy('actual_start') |
|
|
|
} else { |
|
|
|
->value('start_date'); |
|
|
|
$startDate = $query->orderBy('start_date')->value('start_date'); |
|
|
|
} else { |
|
|
|
} |
|
|
|
$startDate = Activity::where('version_gantt_id', $ganttId) |
|
|
|
|
|
|
|
->orderBy('start_date') |
|
|
|
if ($actualEndExist) { |
|
|
|
->value('start_date'); |
|
|
|
$endDate = $query->orderByDesc('actual_end')->value('end_date'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if ($actualEndExist) { |
|
|
|
$endDate = $query->orderByDesc('end_date')->value('end_date'); |
|
|
|
$endDate = Activity::where('version_gantt_id', $ganttId) |
|
|
|
} |
|
|
|
->orderByDesc('actual_end') |
|
|
|
|
|
|
|
->value('end_date'); |
|
|
|
$plannedStart = Activity::where('version_gantt_id', $ganttId) |
|
|
|
} else { |
|
|
|
->orderBy('planned_start') |
|
|
|
$endDate = Activity::where('version_gantt_id', $ganttId) |
|
|
|
->value('planned_start'); |
|
|
|
->orderByDesc('end_date') |
|
|
|
$plannedEnd = Activity::where('version_gantt_id', $ganttId) |
|
|
|
->value('end_date'); |
|
|
|
->orderByDesc('planned_end') |
|
|
|
} |
|
|
|
->value('planned_end'); |
|
|
|
$result->header->start_date = $startDate; |
|
|
|
$result->header->start_date = $startDate; |
|
|
|
$result->header->end_date = $endDate; |
|
|
|
$result->header->end_date = $endDate; |
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200); |
|
|
|
$result->header->planned_start = $plannedStart; |
|
|
|
|
|
|
|
$result->header->planned_end = $plannedEnd; |
|
|
|
|
|
|
|
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getOverdueActivities(Request $request){ |
|
|
|
public function getOverdueActivities(Request $request){ |
|
|
|