|
|
@ -3,6 +3,7 @@ namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
use App\Models\Activity; |
|
|
|
use App\Models\Activity; |
|
|
|
|
|
|
|
use App\Models\AssignMaterial; |
|
|
|
use App\Models\CommentActivity; |
|
|
|
use App\Models\CommentActivity; |
|
|
|
use App\Models\Link; |
|
|
|
use App\Models\Link; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\Project; |
|
|
@ -422,7 +423,14 @@ class ActivityController extends Controller |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Activities not found!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Activities not found!', 'code' => 404], 404); |
|
|
|
$duration = 0; |
|
|
|
$duration = 0; |
|
|
|
foreach ($activities as $key => $activity) { |
|
|
|
foreach ($activities as $key => $activity) { |
|
|
|
if (isset($activity->planned_start) && isset($activity->planned_end)) { |
|
|
|
$assignMaterial = AssignMaterial::where('activity_id', $activity->id)->first(); |
|
|
|
|
|
|
|
if (isset($assignMaterial)) { |
|
|
|
|
|
|
|
$statusActivity = $assignMaterial->status_activity; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$statusActivity = ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (isset($activity->planned_start) && isset($activity->planned_end) && $statusActivity != "done") { |
|
|
|
|
|
|
|
// todo check report for no report / progress == 0 |
|
|
|
$today = new DateTime(); |
|
|
|
$today = new DateTime(); |
|
|
|
$endDate = new DateTime($activity->end_date); |
|
|
|
$endDate = new DateTime($activity->end_date); |
|
|
|
$startDate = new DateTime($activity->start_date); |
|
|
|
$startDate = new DateTime($activity->start_date); |
|
|
@ -431,11 +439,12 @@ class ActivityController extends Controller |
|
|
|
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd); |
|
|
|
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd); |
|
|
|
if ($today >= $endDate) { |
|
|
|
if ($today >= $endDate) { |
|
|
|
$endDate = $today; |
|
|
|
$endDate = $today; |
|
|
|
$rerataBobot = $duration > 0 ? $activity->bobot_planning / $duration : 0; |
|
|
|
$bobotPlanning = (int) $activity->bobot_planning; |
|
|
|
$bobotActual = $activity->progress * $activity->bobot_planning; |
|
|
|
$rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0; |
|
|
|
$sisaBobot = $activity->bobot_planning - $bobotActual; |
|
|
|
$bobotActual = (int) $activity->persentase_progress/100 * $bobotPlanning; |
|
|
|
|
|
|
|
$sisaBobot = $bobotPlanning - $bobotActual; |
|
|
|
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0; |
|
|
|
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0; |
|
|
|
$endDate->modify("+".$sisaHari." Days"); |
|
|
|
$endDate->modify("+".ceil($sisaHari)." Days"); |
|
|
|
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate); |
|
|
|
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate); |
|
|
|
$activity->duration = $actualDuration; |
|
|
|
$activity->duration = $actualDuration; |
|
|
|
$activity->end_date = $endDate; |
|
|
|
$activity->end_date = $endDate; |
|
|
|