|
|
@ -6,6 +6,7 @@ use App\Helpers\MasterFunctionsHelper; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use Illuminate\Console\Command; |
|
|
|
use Illuminate\Console\Command; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
|
|
|
class ActualProgressProject extends Command |
|
|
|
class ActualProgressProject extends Command |
|
|
|
{ |
|
|
|
{ |
|
|
@ -40,7 +41,7 @@ class ActualProgressProject extends Command |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function handle() |
|
|
|
public function handle() |
|
|
|
{ |
|
|
|
{ |
|
|
|
$projects = Project::join('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') |
|
|
|
$projects = Project::leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') |
|
|
|
->select('m_proyek.*', 'm_type_proyek.is_multiLocation') |
|
|
|
->select('m_proyek.*', 'm_type_proyek.is_multiLocation') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
|
@ -55,6 +56,7 @@ class ActualProgressProject extends Command |
|
|
|
$progress[$key] = $gantt->progress; |
|
|
|
$progress[$key] = $gantt->progress; |
|
|
|
} |
|
|
|
} |
|
|
|
$actualProgress = round(array_sum($progress) / count($versionGantt), 2); |
|
|
|
$actualProgress = round(array_sum($progress) / count($versionGantt), 2); |
|
|
|
|
|
|
|
$progress = array(); // unset/kosongkan array progress untuk project selanjutnya |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// untuk project single location |
|
|
|
// untuk project single location |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($project->id); |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($project->id); |
|
|
@ -65,12 +67,15 @@ class ActualProgressProject extends Command |
|
|
|
'gantt_id' => $lastGantt, |
|
|
|
'gantt_id' => $lastGantt, |
|
|
|
'periode' => 'week' |
|
|
|
'periode' => 'week' |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
// kondisi jika tidak ada gantt_id |
|
|
|
$project->scurve = MasterFunctionsHelper::getSCurve(collect($arr)); |
|
|
|
if (empty($arr['gantt_id'])) { |
|
|
|
$actualArray = $project->scurve[0]['data']['percentageReal']; |
|
|
|
$actualProgress = 0; |
|
|
|
$actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0; |
|
|
|
} else { |
|
|
|
|
|
|
|
$project->scurve = MasterFunctionsHelper::getSCurve(collect($arr)); |
|
|
|
|
|
|
|
$actualArray = $project->scurve[0]['data']['percentageReal']; |
|
|
|
|
|
|
|
$actualProgress = !empty($actualArray) ? round(end($actualArray), 2) : 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Project::where('id', $project->id)->update(['persentase_progress' => $actualProgress]); |
|
|
|
Project::where('id', $project->id)->update(['persentase_progress' => $actualProgress]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|