Browse Source

merge conflict

pull/3/head
ardhi 2 years ago
parent
commit
b62cf5bfbb
  1. 1
      app/Http/Controllers/DashboardBoDController.php
  2. 11
      app/Http/Controllers/DivisiController.php
  3. 64
      app/Http/Controllers/MapMonitoringController.php
  4. 61
      app/Http/Controllers/PresenceController.php
  5. 7
      app/Http/Controllers/ProjectToChecklistK3Controller.php
  6. 7
      app/Models/Activity.php
  7. 4
      app/Models/HumanResource.php
  8. 3
      app/Models/UserToActivity.php
  9. 44
      rest-client.http

1
app/Http/Controllers/DashboardBoDController.php

@ -304,6 +304,7 @@ class DashboardBoDController extends Controller
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ /* ->orWhere('akhir_proyek', 'like', $year) */
->orderBy('id', 'desc')
->get(); ->get();
foreach($projects as $project){ foreach($projects as $project){
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);

11
app/Http/Controllers/DivisiController.php

@ -70,10 +70,15 @@ class DivisiController extends Controller
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200); return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=> 200], 200);
} }
public function search() public function search(Request $request)
{ {
return $this->list(); $payload = $request->all();
// cant use builder for this case $dataBuilder = $this->setUpPayload($payload, 'm_divisi');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }
public function list() public function list()

64
app/Http/Controllers/MapMonitoringController.php

@ -7,8 +7,6 @@ use Illuminate\Http\Request;
use App\Models\Presence; use App\Models\Presence;
use App\Models\Activity; use App\Models\Activity;
use App\Models\MapMonitoring; use App\Models\MapMonitoring;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -17,18 +15,56 @@ class MapMonitoringController extends Controller
// default map monitoring shows today's presence lat lon in the map // default map monitoring shows today's presence lat lon in the map
public function search(Request $request) public function search(Request $request)
{ {
// $payload = $request->all(); $dateNow = Carbon::today()->addHour(7)->format('Y-m-d');
// $dataBuilder = $this->setUpPayload($payload, 't_clock_in_out'); // get distinct human assign project
// $builder = $dataBuilder['builder']; $hr_assign_project = DB::table('assign_hr_to_proyek')
// $countBuilder = $dataBuilder['count']; ->select('user_id')
// $dataGet = $builder->get(); ->whereIn('proyek_id', $request->project_id)
// $totalRecord = $countBuilder->count(); ->distinct()
// return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); ->get();
// get position hr in presensi
$monitoringData = MapMonitoring::getUsers($request->all()); $tmp = [];
var_dump($monitoringData); foreach($hr_assign_project as $key){
$presensi = DB::table('t_clock_in_out as tcio')
->select('tcio.id as clock_in_out_id','mu.id as user_id', 'mu.name as fullname', 'tcio.clock_in', 'tcio.clock_out', 'tcio.clock_in_lat', 'tcio.clock_in_lng',
'tcio.clock_out_lat', 'tcio.clock_out_lng', 'tcio.clock_in_loc', 'tcio.clock_out_loc', 'tcio.clock_in_boundary',
'tcio.clock_out_boundary', 'mu.username', 'tcio.date_presence', 'tcio.created_at')
->join('m_users as mu', 'mu.id', '=', 'tcio.user_id')
->where('mu.id', $key->user_id)
->orderBy('tcio.id', 'DESC')
->first();
$project = DB::table('assign_hr_to_proyek as ahtp')
->select('ahtp.proyek_id as id', 'mp.nama as project_name')
->join('m_proyek as mp', 'mp.id', '=', 'ahtp.proyek_id')
->whereIn('ahtp.proyek_id', $request->project_id)
->where('ahtp.user_id', $key->user_id)
->get();
if($presensi && isset($presensi->user_id)){
$image = DB::table('m_image')->select('image')->where('category', 'presensi')->where('ref_id', $presensi->clock_in_out_id)->first();
$tmp[] = array(
'user_id' => $presensi->user_id,
'clock_in' => $presensi->clock_in,
'clock_out' => $presensi->clock_out,
'date_presence' => $presensi->date_presence,
'clock_in_lat' => $presensi->clock_in_lat,
'clock_in_lng' => $presensi->clock_in_lng,
'clock_out_lat' => $presensi->clock_out_lat,
'clock_out_lng' => $presensi->clock_out_lng,
'clock_in_loc' => $presensi->clock_in_loc,
'clock_out_loc' => $presensi->clock_out_loc,
'clock_in_boundary' => $presensi->clock_in_boundary,
'clock_out_boundary' => $presensi->clock_out_boundary,
'username' => $presensi->username,
'name' => $presensi->fullname,
'image_selfie' => isset($image->image) ? $image->image : '-',
'created_at' => $presensi->created_at,
'presence_status' => $presensi->date_presence == $dateNow ? true : false,//true, //status date_presence,
'projects' => $project
);
}
}
return response()->json(['status'=>'success','code'=>200, 'data' => $tmp, 'totalRecord'=>count($tmp)], 200);
} }
public function list() public function list()

61
app/Http/Controllers/PresenceController.php

@ -5,9 +5,9 @@ namespace App\Http\Controllers;
use Log; use Log;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\Presence; use App\Models\Presence;
use App\Models\Activity; // use App\Models\Activity;
use GuzzleHttp\Client; // use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http; // use Illuminate\Support\Facades\Http;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
@ -22,13 +22,31 @@ class PresenceController extends Controller
$checkLocation = $this->checkLocation($request); $checkLocation = $this->checkLocation($request);
$statusBoundary = false; $statusBoundary = false;
$date = date_create($request->clock_time); $date = date_create($request->clock_time);
// $ActivityId = null; // assign and in boundary
if(count($checkLocation) > 0){ if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){
// $checkLocation[0]['status_assign'] ? $statusBoundary = true
// :
$statusBoundary = true; $statusBoundary = true;
} }
// not assign
if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array(
'id' => null,
'boundary' => $statusBoundary
);
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda belum di assign ke area kerja.','code'=>200], 200);
}
// assign and not in boundary
if($checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false){
$data=array(
'id' => null,
'boundary' => true
);
return response()->json(['status'=>'failed', 'data'=>$data, 'message'=>'Tidak dapat melakukan presensi. Anda berada di luar area kerja.','code'=>200], 200);
}
if($request->type=="out"){ if($request->type=="out"){
$clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name; $clock_out_loc = $this->getLoc($request->clock_out_lat, $request->clock_out_lng)->display_name;
$dataUpdate = array( $dataUpdate = array(
"clock_out"=>$request->clock_time, "clock_out"=>$request->clock_time,
@ -125,14 +143,33 @@ class PresenceController extends Controller
$check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary")); $check = DB::select(DB::raw("SELECT ST_Intersects(ST_GeomFromGeoJSON('".json_encode($valGeom->geometry)."'), ST_GeomFromText('POINT(".$params->clock_in_lng." ".$params->clock_in_lat.")', 4326)) as boundary"));
} }
foreach ($check as $key) { foreach ($check as $key) {
// assign and in boundary
if($key->boundary){ if($key->boundary){
$temp[]=array( $temp[]=array(
"activity_id" => $dataGeom->id, "activity_id" => $dataGeom->id,
"boundary" => $key->boundary "boundary" => $key->boundary,
"status_assign" => true
); );
} }
}
// assign and not in boundary
if(count($temp) < 1){
$temp[]=array(
"activity_id" => null,
"boundary" => false,
"status_assign" => true
// "geom" => $geom,
// "cek" => $check[0]->boundary
);
} }
} }
}else{
// not assign
$temp[]=array(
"activity_id" => null,
"boundary" => false,
"status_assign" => false
);
} }
return $temp; return $temp;
} }
@ -152,14 +189,10 @@ class PresenceController extends Controller
} }
} }
public function clockinout($id) { public function clockinout($id) {
$dateTimeNow = Carbon::now()->addHour(7); $dateTimeNow = Carbon::now()->addHour(7);
$dataPresence = Presence::where('user_id', $id)->orderBy('id', 'DESC')->first(); $dataPresence = Presence::where('user_id', $id)->orderBy('id', 'DESC')->first();
if($dataPresence){ if($dataPresence){
$dateNow = date("Y-m-d"); $dateNow = date("Y-m-d");
@ -199,10 +232,8 @@ class PresenceController extends Controller
private function updateFormAdd($data, $id){ private function updateFormAdd($data, $id){
$date = date_create($data['clock_out']); $date = date_create($data['clock_out']);
$onlyDate = date_format($date,"Y-m-d"); $onlyDate = date_format($date,"Y-m-d");
$dataPresence = Presence::where('user_id',$id) $dataPresence = Presence::where('user_id',$id)
->where("clock_in", "<=", $data["clock_out"]) ->where("clock_in", "<=", $data["clock_out"])
->orderByDesc("id") ->orderByDesc("id")
@ -237,7 +268,6 @@ class PresenceController extends Controller
die(); die();
} }
if($result){ if($result){
return response()->json(['status'=>'success','message'=>'data presence successfully updated!','code'=>200], 200); return response()->json(['status'=>'success','message'=>'data presence successfully updated!','code'=>200], 200);
}else{ }else{
@ -256,7 +286,6 @@ class PresenceController extends Controller
die(); die();
} }
if($delete){ if($delete){
return response()->json(['status'=>'success','message'=>'data presence successfully deleted!','code'=>200], 200); return response()->json(['status'=>'success','message'=>'data presence successfully deleted!','code'=>200], 200);
}else{ }else{

7
app/Http/Controllers/ProjectToChecklistK3Controller.php

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\ProjectToChecklistK3; use App\Models\ProjectToChecklistK3;
use App\Models\ChecklistK3;
class ProjectToChecklistK3Controller extends Controller class ProjectToChecklistK3Controller extends Controller
{ {
@ -122,6 +123,12 @@ class ProjectToChecklistK3Controller extends Controller
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
foreach($dataGet as $key => $value) {
$checklist = ChecklistK3::where('id', $value->checklist_k3_id)->first();
$dataGet[$key]->checklist_k3_name = $checklist->name;
}
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
} }

7
app/Models/Activity.php

@ -127,6 +127,13 @@ class Activity extends Model
if($parent = Activity::find($this->parent_id)){ if($parent = Activity::find($this->parent_id)){
$parentActWeight = $parent->bobot_planning; $parentActWeight = $parent->bobot_planning;
if ($parentActWeight == 0) {
$parent->update([
"persentase_progress" => 0
]);
return;
}
$totalChildProportionalProgress = 0; $totalChildProportionalProgress = 0;
$childs = Activity::where("parent_id", $parent->id)->get(); $childs = Activity::where("parent_id", $parent->id)->get();
foreach($childs as $child){ foreach($childs as $child){

4
app/Models/HumanResource.php

@ -32,6 +32,8 @@ class HumanResource extends Model
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by', 'updated_by',
'divisi_id' 'divisi_id',
'status_boundary'
]; ];
} }

3
app/Models/UserToActivity.php

@ -50,6 +50,9 @@ class UserToActivity extends Model
} }
$activity->rencana_biaya -= $salary; $activity->rencana_biaya -= $salary;
if ($activity->rencana_biaya < 0) {
$activity->rencana_biaya = 0;
}
$activity->save(); $activity->save();
}); });

44
rest-client.http

@ -1,12 +1,20 @@
<<<<<<< HEAD
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8 @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8
=======
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g
>>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b
@hostname = https://adw-api.ospro.id/api @hostname = https://adw-api.ospro.id/api
# @hostname = https://ospro-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api
# @hostname = https://api-iu.ospro.id/api # @hostname = https://api-iu.ospro.id/api
# @hostname = https://api-staging-adw.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api
# @hostname = http://localhost:8444/api @hostname = http://localhost:8444/api
# @hostname = http://103.73.125.81:8444/api # @hostname = http://103.73.125.81:8444/api
<<<<<<< HEAD
# @hostname = http://localhost:8074/adw-backend/api # @hostname = http://localhost:8074/adw-backend/api
=======
# @hostname = http://localhost:8444/adw-ba/api
>>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b
###### login ###### login
POST {{hostname}}/login POST {{hostname}}/login
@ -800,14 +808,12 @@ GET {{hostname}}/presence/clockinout/262
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
#######
"clock_out_lat": -1.4264273154149407,
"clock_out_lng": 113.98530036945851,
###### ######
POST {{hostname}}/presence/add POST {{hostname}}/presence/add
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json
<<<<<<< HEAD
# { # {
# "clock_out_lat": -6.16678379060529, # "clock_out_lat": -6.16678379060529,
# "clock_out_lng": 106.9175039866567, # "clock_out_lng": 106.9175039866567,
@ -817,7 +823,28 @@ content-type: application/json
# } # }
{"clock_time":"2023-02-14T02:34:28+07:00","type":"in","user_id":1247,"clock_in_lat":-6.2646449,"clock_in_lng":106.7893041} {"clock_time":"2023-02-14T02:34:28+07:00","type":"in","user_id":1247,"clock_in_lat":-6.2646449,"clock_in_lng":106.7893041}
=======
{
"clock_in_lat": -6.16678379060529,
"clock_in_lng": 106.9175039866567,
"clock_time": "2023-02-10T14:48:17+07:00",
"type": "in",
"user_id": 1247
}
>>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b
######
POST {{hostname}}/presence/add
Authorization: Bearer {{token}}
content-type: application/json
{
"clock_in_lat": -1.4264273154149407,
"clock_in_lng": 113.98530036945851,
"clock_time": "2023-02-13T16:40:17+07:00",
"type": "in",
"user_id": 1
}
###### ######
# POST {{hostname}}/ # POST {{hostname}}/
@ -861,7 +888,16 @@ content-type: application/json
} }
###### ######
POST {{hostname}}/map-monitoring/search
Authorization: Bearer {{token}}
content-type: application/json
{
"project_id" : [1, 2, 3]
}
######
POST {{hostname}}/waypoint/add-bulk POST {{hostname}}/waypoint/add-bulk
Authorization: Bearer {{token}} Authorization: Bearer {{token}}
content-type: application/json content-type: application/json

Loading…
Cancel
Save