Browse Source

Merge branch 'staging' into dev-wahyun

pull/3/head
wahyun 1 year ago
parent
commit
0e5ccb8e8f
  1. 58
      app/Http/Controllers/ActivityController.php
  2. 7
      app/Http/Controllers/PresenceController.php

58
app/Http/Controllers/ActivityController.php

@ -48,9 +48,9 @@ class ActivityController extends Controller
$dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL; $dataHeader->planned_start = isset($dataHeader->planned_start) ? date_format(date_create($dataHeader->planned_start), "Y-m-d H:i:s") : NULL;
$dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL; $dataHeader->planned_end = isset($dataHeader->planned_end) ? date_format(date_create($dataHeader->planned_end), "Y-m-d H:i:s") : NULL;
$actualStart = $this->getActivityFirst($dataHeader->id); $actualStart = $this->getFirstLastDateActivity($dataHeader->id, "start");
$dataHeader->actual_start = date_format(date_create($actualStart), "Y-m-d"); $dataHeader->actual_start = date_format(date_create($actualStart), "Y-m-d");
$actualEnd = $this->getActivityLast($dataHeader->id); $actualEnd = $this->getFirstLastDateActivity($dataHeader->id, "end");
$dataHeader->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; $dataHeader->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
$dataHeader->type = "header"; $dataHeader->type = "header";
@ -79,9 +79,9 @@ class ActivityController extends Controller
$objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL; $objRow->planned_start = isset($objRow->planned_start) ? date_format(date_create($objRow->planned_start), "Y-m-d H:i:s") : NULL;
$objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL; $objRow->planned_end = isset($objRow->planned_end) ? date_format(date_create($objRow->planned_end), "Y-m-d H:i:s") : NULL;
$actualStart = $this->getActivityFirst($objRow->id); $actualStart = $this->getFirstLastDateActivity($objRow->id, "start");
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; $objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL;
$actualEnd = $this->getActivityLast($objRow->id); $actualEnd = $this->getFirstLastDateActivity($objRow->id, "end");
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; $objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
$objRow->progress = $objRow->persentase_progress / 100; $objRow->progress = $objRow->persentase_progress / 100;
@ -141,10 +141,10 @@ class ActivityController extends Controller
} }
} else { } else {
$objRow->type = "project"; $objRow->type = "project";
$actualStart = $this->getActivityFirst($objRow->id); $actualStart = $this->getFirstLastDateActivity($objRow->id, "start");
$objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL; $objRow->actual_start = isset($actualStart) ? date_format(date_create($actualStart), "Y-m-d") : NULL;
$actualEnd = $this->getActivityLast($objRow->id); $actualEnd = $this->getFirstLastDateActivity($objRow->id, "end");
$objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL; $objRow->actual_end = isset($actualEnd) ? date_format(date_create($actualEnd), "Y-m-d") : NULL;
} }
$finalData[] = $objRow; $finalData[] = $objRow;
@ -167,6 +167,52 @@ class ActivityController extends Controller
} }
public function getFirstLastDateActivity($id, $params){
if($params == "start"){
$data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get();
}else{
$data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get();
}
$dataFinal=[];
foreach ($data as $val) {
$activity = $this->getchildActivityForActual($val->id, $params);
$dataFinal[] = $val;
$dataFinal = array_merge($dataFinal, $activity);
}
if($params == "start"){
$actualStartValues = array_column(array_filter($dataFinal, function($item) {
return isset($item['actual_start']);
}), 'actual_start');
$returnActualStartOrEnd = count($actualStartValues) > 0 ? min($actualStartValues) : null;
}else{
$actualEndValues = array_column(array_filter($dataFinal, function($item) {
return isset($item['actual_end']);
}), 'actual_end');
$returnActualStartOrEnd = count($actualEndValues) > 0 ? max($actualEndValues) : null;
}
// return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]);
return $returnActualStartOrEnd;
}
public function getchildActivityForActual($parent, $params){
if($params == "start"){
$activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get();
}else{
$activity = Activity::select('id', 'actual_end')->where('parent_id', $parent)->get();
}
$temp = [];
foreach($activity as $val1){
$getChild = $this->getchildActivityForActual($val1->id, $params);
$temp[] = $val1;
$temp = array_merge($temp, $getChild);
}
return $temp;
}
public function getActivityLast($parentId){ public function getActivityLast($parentId){
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first(); $activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first();
if (!isset($activity)) { if (!isset($activity)) {

7
app/Http/Controllers/PresenceController.php

@ -258,6 +258,7 @@ class PresenceController extends Controller
// cek user tersebut apakah punya assign task yang ada bondary nya // cek user tersebut apakah punya assign task yang ada bondary nya
// geom ada di table activity // geom ada di table activity
// $clock_time = // $clock_time =
$user = HumanResource::find($params->user_id);
$geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id") $geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id") ->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id) ->where("ahta.user_id", $params->user_id)
@ -326,14 +327,14 @@ class PresenceController extends Controller
ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary")); ST_GeomFromText('POINT(".$params->clock_in_out['clock_in_lng']." ".$params->clock_in_out['clock_in_lat'].")', 4326)) as boundary"));
} }
} }
if(count($check)>0){ if(!$user->status_boundary || count($check)>0){
if(isset($check[0]->boundary) && $check[0]->boundary){ if(!$user->status_boundary || (isset($check[0]->boundary) && $check[0]->boundary)){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
"boundary" => $check[0]->boundary, "boundary" => $check[0]->boundary,
"status_assign" => true "status_assign" => true
); );
} else if (isset($check[0]->within_radius) && $check[0]->within_radius) { } else if (!$user->status_boundary || (isset($check[0]->within_radius) && $check[0]->within_radius)) {
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
"boundary" => $check[0]->within_radius, "boundary" => $check[0]->within_radius,

Loading…
Cancel
Save