Browse Source

Merge pull request 'dev-wahyu' (#46) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#46
Reviewed-by: ibnu <ibnu@mail.com>
pull/3/head
ibnu 2 years ago
parent
commit
7201188a33
  1. 11
      app/Helpers/MasterFunctionsHelper.php
  2. 8
      app/Http/Controllers/DashboardBoDController.php

11
app/Helpers/MasterFunctionsHelper.php

@ -6,6 +6,7 @@ use App\Models\Activity;
use App\Models\Project;
use App\Models\VersionGantt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class MasterFunctionsHelper {
@ -34,10 +35,16 @@ class MasterFunctionsHelper {
public function getLatestGantt($id){
$maxGanttId = VersionGantt::where("proyek_id", $id)->max("id");
if(!$maxGanttId){
$data = array(
"proyek_id" => $id
);
} else {
$data = array(
"last_gantt_id" => $maxGanttId,
"proyek_id" => $id
);
}
return $data;
}
@ -102,7 +109,8 @@ class MasterFunctionsHelper {
$begin = new \DateTime($minDate.' Monday');
if(isset($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 = new \DateInterval('P7D');
} else {
@ -112,6 +120,7 @@ class MasterFunctionsHelper {
->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
$end = new \DateTime($maxDate. ' Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
}
$period = new \DatePeriod($begin, $interval, $end);

8
app/Http/Controllers/DashboardBoDController.php

@ -319,8 +319,12 @@ class DashboardBoDController extends Controller
$project->pm = User::find($project->pm_id);
/* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
if(!isset($lastGantt['last_gantt_id'])){
$project->manPowers = 0;
} else {
$project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count();
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
}
$project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id);
}

Loading…
Cancel
Save