Browse Source

Merge pull request 'staging upload 23/07/03' (#99) from staging into master

Reviewed-on: ordo/adw-backend#99
pull/3/head
ibnu 1 year ago
parent
commit
6cb7cbd810
  1. 54
      app/Helpers/MasterFunctionsHelper.php
  2. 14
      app/Http/Controllers/DashboardBoDController.php
  3. 7
      app/Http/Controllers/HierarchyFtthController.php
  4. 7
      app/Http/Controllers/ProjectController.php
  5. 3
      app/Http/Controllers/VersionGanttController.php
  6. 2
      app/Models/HierarchyFtth.php
  7. 1
      app/Models/VersionGantt.php
  8. 1
      routes/web.php

54
app/Helpers/MasterFunctionsHelper.php

@ -5,6 +5,7 @@ namespace App\Helpers;
use App\Models\Activity;
use App\Models\Project;
use App\Models\VersionGantt;
use App\Models\HierarchyFtth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@ -82,6 +83,59 @@ class MasterFunctionsHelper {
}
}
public function getLinearSCurve($request){
$ftths = HierarchyFtth::where('project_id', $request->project_id)->get();
$ttlProgress = 0;
$ttlPlanning = 0;
foreach ($ftths as $ftth) {
$progress = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('progress');
$planning = VersionGantt::where('hierarchy_ftth_id', $ftth->id)->sum('bobot');
$ttlProgress += $progress;
$ttlPlanning += $planning;
}
$minDate = Project::select('mulai_proyek')->where('id', $request->project_id)->first();
$maxDate = Project::select('akhir_proyek')->where('id', $request->project_id)->first();
$begin = new \DateTime($minDate->mulai_proyek. ' Monday');
$begin->modify('last Monday');
$end = new \DateTime($maxDate->akhir_proyek. ' Friday');
$end->modify('next Friday');
$end->modify('next Friday');
$interval = new \DateInterval('P7D');
$period = new \DatePeriod($begin, $interval, $end);
$dates = iterator_to_array($period);
$count = count($dates);
$avgProgress = $ttlProgress/$count;
$avgPlanning = $ttlPlanning/$count;
$progressData = [];
$planningData = [];
$tempProgress = 0;
$tempPlanning = 0;
foreach($period as $p){
array_push($progressData, $tempProgress);
array_push($planningData, $tempPlanning);
$tempProgress += $avgProgress;
$tempPlanning += $avgPlanning;
}
$dataResponse = array(
"percentagePlan" => $progressData,
"percentageReal" => $planningData,
);
$dataFinal[] = array(
"data"=>$dataResponse,
);
return $dataFinal;
}
public function calculateProgressBasedOnReportMaterial($keyGantt)
{
DB::enableQueryLog();

14
app/Http/Controllers/DashboardBoDController.php

@ -127,13 +127,19 @@ class DashboardBoDController extends Controller
$projects = Project::where('mulai_proyek', 'like', $year)->get();
foreach($projects as $project) {
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$project->scurve = MasterFunctionsHelper::getSCurve($project->id);
$selisihProgress = 0;
if($project->scurve && $project->scurve[0]){
$planningProgress = $project->scurve[0]['data']['percentagePlan'][count($project->scurve[0]['data']['percentagePlan'])-1];
$actualProgress = $project->scurve[0]['data']['percentageReal'][count($project->scurve[0]['data']['percentageReal'])-1];
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if(@$project->scurve['difference'] > 0 && @$project->scurve['difference'] <= 5)
if($selisihProgress > 0 && $selisihProgress <= 5)
$return['warning'] += 1;
elseif(@$project->scurve['difference'] > 5 && @$project->scurve['difference'] <= 100)
elseif($selisihProgress > 5 && $selisihProgress <= 100)
$return['behind-schedule'] += 1;
elseif(@$project->scurve['difference'] == 0)
elseif($selisihProgress == 0)
$return['on-schedule'] += 1;
} catch (\Error $e) {
return response()->json(['msg' => $e->getMessage(), 'data' => $project], 200);

7
app/Http/Controllers/HierarchyFtthController.php

@ -110,12 +110,15 @@ class HierarchyFtthController extends Controller
if($ftthIds){
foreach ($ftthIds as $ftthId) {
$gantts = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('progress');
$bobot_planning = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->sum('bobot');
$ganttCount = VersionGantt::where('hierarchy_ftth_id', $ftthId->hierarchy_ftth_id)->count();
$ftth = HierarchyFtth::find($ftthId->hierarchy_ftth_id);
if($ftth){
$round = $gantts/$ganttCount;
$round_bobot = $bobot_planning/$ganttCount;
$ftth->progress = round($round, 2);
$ftth->bobot_planning = round($round_bobot, 2);
try {
$ftth->save();
} catch (\Exception $e) {
@ -189,6 +192,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) {
if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
}
}
}
@ -216,6 +220,7 @@ class HierarchyFtthController extends Controller
foreach ($progress as $p) {
if ($p->id == $gantt->id) {
$gantt->progress = $p->persentase_progress;
$gantt->bobot_planning = $p->bobot_planning ? $p->bobot_planning : 0;
}
}
}
@ -228,7 +233,7 @@ class HierarchyFtthController extends Controller
}
public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress')
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value)
->where('m_activity.type_activity', "project")

7
app/Http/Controllers/ProjectController.php

@ -330,6 +330,11 @@ class ProjectController extends Controller
public function getSCurve(Request $request){
$data = MasterFunctionsHelper::getSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public function getLinearSCurve(Request $request){
$data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
public function synchronizeReport($gantt_id)
@ -412,7 +417,7 @@ class ProjectController extends Controller
$gantt = MasterFunctionsHelper::getLatestGantt($id);
$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();
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200);
}
public function getOverdueActivities(Request $request){

3
app/Http/Controllers/VersionGanttController.php

@ -91,7 +91,7 @@ class VersionGanttController extends Controller
}
public function ganttProgress($column, $value){
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress')
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value)
// ->where('m_activity.type_activity', "project")
@ -100,6 +100,7 @@ class VersionGanttController extends Controller
foreach($progress as $item) {
if($item->persentase_progress){
$item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning;
$item->save();
}
}

2
app/Models/HierarchyFtth.php

@ -12,6 +12,6 @@ class HierarchyFtth extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress'
'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning'
];
}

1
app/Models/VersionGantt.php

@ -25,6 +25,7 @@ class VersionGantt extends Model
'committed_cost',
'cost_to_complete',
'progress',
'bobot',
'hierarchy_ftth_id',
'created_at',
'created_by',

1
routes/web.php

@ -66,6 +66,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR');
$router->post('/project/get-s-curve', 'ProjectController@getSCurve');
$router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve');
$router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities');
$router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration');
$router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution');

Loading…
Cancel
Save