|
|
@ -6,6 +6,7 @@ use App\Models\Activity; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\Project; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use App\Models\VersionGantt; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
|
|
|
|
|
class MasterFunctionsHelper { |
|
|
|
class MasterFunctionsHelper { |
|
|
|
|
|
|
|
|
|
|
@ -34,10 +35,16 @@ class MasterFunctionsHelper { |
|
|
|
|
|
|
|
|
|
|
|
public function getLatestGantt($id){ |
|
|
|
public function getLatestGantt($id){ |
|
|
|
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); |
|
|
|
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); |
|
|
|
|
|
|
|
if(!$maxGanttId){ |
|
|
|
|
|
|
|
$data = array( |
|
|
|
|
|
|
|
"proyek_id" => $id |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
$data = array( |
|
|
|
$data = array( |
|
|
|
"last_gantt_id" => $maxGanttId, |
|
|
|
"last_gantt_id" => $maxGanttId, |
|
|
|
"proyek_id" => $id |
|
|
|
"proyek_id" => $id |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -47,7 +54,7 @@ class MasterFunctionsHelper { |
|
|
|
if(!is_int($request)){ |
|
|
|
if(!is_int($request)){ |
|
|
|
$dataPayload = $request->all(); |
|
|
|
$dataPayload = $request->all(); |
|
|
|
if(isset($dataPayload['gantt_id'])){ |
|
|
|
if(isset($dataPayload['gantt_id'])){ |
|
|
|
$allGantt = $dataPayload['gantt_id']; |
|
|
|
$allGantt[] = $dataPayload['gantt_id']; |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
$allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']); |
|
|
|
$allGantt[] = MasterFunctionsHelper::getLatestGantt($dataPayload['project_id']); |
|
|
|
} |
|
|
|
} |
|
|
@ -55,7 +62,15 @@ class MasterFunctionsHelper { |
|
|
|
$allGantt[] = MasterFunctionsHelper::getLatestGantt($request); |
|
|
|
$allGantt[] = MasterFunctionsHelper::getLatestGantt($request); |
|
|
|
} |
|
|
|
} |
|
|
|
foreach($allGantt as $gantt){ |
|
|
|
foreach($allGantt as $gantt){ |
|
|
|
$gantt = VersionGantt::where('id', $gantt['last_gantt_id'])->first()->toArray(); |
|
|
|
if (!isset($gantt['last_gantt_id'])) { |
|
|
|
|
|
|
|
$ganttId = $gantt; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$ganttId = $gantt['last_gantt_id']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$gantt = VersionGantt::find($ganttId)->toArray(); |
|
|
|
|
|
|
|
// foreach ($gantt as $key => $value) { |
|
|
|
|
|
|
|
// Log::info('gantt '.$value.' index '.$key); |
|
|
|
|
|
|
|
// } |
|
|
|
if($gantt['calculation_type'] == 'simple') { |
|
|
|
if($gantt['calculation_type'] == 'simple') { |
|
|
|
// to do |
|
|
|
// to do |
|
|
|
return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt); |
|
|
|
return MasterFunctionsHelper::calculateProgressBasedOnSimple($gantt); |
|
|
@ -102,7 +117,8 @@ class MasterFunctionsHelper { |
|
|
|
$begin = new \DateTime($minDate.' Monday'); |
|
|
|
$begin = new \DateTime($minDate.' Monday'); |
|
|
|
if(isset($dataPayload['end_date'])){ |
|
|
|
if(isset($dataPayload['end_date'])){ |
|
|
|
$maxDate = $dataPayload['end_date']; |
|
|
|
$maxDate = $dataPayload['end_date']; |
|
|
|
$end = new \DateTime($maxDate); |
|
|
|
$end = new \DateTime($maxDate. ' Friday'); |
|
|
|
|
|
|
|
$end->modify('next Friday'); |
|
|
|
/* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged |
|
|
|
/* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged |
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -112,6 +128,7 @@ class MasterFunctionsHelper { |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['id']) |
|
|
|
->where('a.version_gantt_id', '=', $keyGantt['id']) |
|
|
|
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's |
|
|
|
->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's |
|
|
|
$end = new \DateTime($maxDate. ' Friday'); |
|
|
|
$end = new \DateTime($maxDate. ' Friday'); |
|
|
|
|
|
|
|
$end->modify('next Friday'); |
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
$interval = new \DateInterval('P7D'); |
|
|
|
} |
|
|
|
} |
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|
$period = new \DatePeriod($begin, $interval, $end); |
|
|
|