Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-backend

pull/3/head
ardhi 2 years ago
parent
commit
513c71e8cd
  1. 6
      app/Http/Controllers/AssignMaterialController.php
  2. 27
      app/Http/Controllers/PresenceController.php

6
app/Http/Controllers/AssignMaterialController.php

@ -174,10 +174,10 @@ class AssignMaterialController extends Controller
->where('description', '=', $row->material_name)->first();
return $val_uom ? $val_uom->uom : null;
})
->addColumn('material_id', function($row){
$material_id =AssignMaterial::select('assign_material_to_activity.material_id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->addColumn('assign_material_id', function($row){
$assignMaterial =AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first();
return $material_id ? $material_id->material_id : null;
return $assignMaterial ? $assignMaterial->id : null;
})
->addColumn('action', function($row){
$dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")

27
app/Http/Controllers/PresenceController.php

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Log;
use Illuminate\Http\Request;
use App\Models\Presence;
use App\Models\Activity;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
use Carbon\Carbon;
@ -14,6 +15,10 @@ class PresenceController extends Controller
{
public function add(Request $request)
{
//
// $test = $this->checkLocation($request);
// return response()->json(['status'=>$test,'code'=>200], 200);
$this->validate($request, [
'user_id' => 'required'
]);
@ -58,12 +63,32 @@ class PresenceController extends Controller
$result = Presence::create($dataAdd);
$data=array(
'id' => $result->id,
'boundary' => true
);
if($result){
return response()->json(['status'=>'success', 'id'=>$result->id,'message'=>'clock in successfully!','code'=>200], 200);
return response()->json(['status'=>'success', 'data' => $data,'message'=>'clock in successfully!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'clock in failed!','code'=>400], 400);
}
}
private function checkLocation($params){
// cek user tersebut apakah punya assign task yang ada bondary nya
// geom ada di table activity
$geom = DB::table("assign_hr_to_activity as ahta")->select("ma.geom", "ma.id")
->join("m_activity as ma", "ma.id", "=", "ahta.activity_id")
->where("ahta.user_id", $params->user_id)
->whereDate("ma.start_date", "<=", $params->clock_time)
->whereDate("ma.end_date", ">=", $params->clock_time)
->where(DB::raw("ST_Intersects(ST_GeomFromGeoJSON('ma.geom'), ST_GeomFromText('POINT(".$params->clock_out_lng." ".$params->clock_out_lat.")', 4326))"))
->get();
// Activity::select('geom')->where('');
// gejson to geom
// intersect dengan point req
return $geom;
}
public function edit($id){
if(!$id || (int) $id < 0 || $id==""){

Loading…
Cancel
Save