From 9503d9e6c6c146a54eff450ddf364d48acfc184b Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 20 Feb 2023 12:41:20 +0700 Subject: [PATCH 1/8] Handling if cost planning < 0 --- app/Models/Activity.php | 7 +++++++ app/Models/UserToActivity.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 9be182c..7ee841a 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -127,6 +127,13 @@ class Activity extends Model if($parent = Activity::find($this->parent_id)){ $parentActWeight = $parent->bobot_planning; + if ($parentActWeight == 0) { + $parent->update([ + "persentase_progress" => 0 + ]); + return; + } + $totalChildProportionalProgress = 0; $childs = Activity::where("parent_id", $parent->id)->get(); foreach($childs as $child){ diff --git a/app/Models/UserToActivity.php b/app/Models/UserToActivity.php index 3dac828..a33667c 100644 --- a/app/Models/UserToActivity.php +++ b/app/Models/UserToActivity.php @@ -50,6 +50,9 @@ class UserToActivity extends Model } $activity->rencana_biaya -= $salary; + if ($activity->rencana_biaya < 0) { + $activity->rencana_biaya = 0; + } $activity->save(); }); From 418cf7c6b4c3674fef3957b55f9eeeb5dc7c3c80 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 11:14:40 +0700 Subject: [PATCH 2/8] change rest-client.http --- rest-client.http | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/rest-client.http b/rest-client.http index 453e2e5..e0ef125 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,12 +1,12 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODA3NFwvYWR3LWJhY2tlbmRcL2FwaVwvbG9naW4iLCJpYXQiOjE2NzYxODQ5ODgsImV4cCI6MTY3Njc4OTc4OCwibmJmIjoxNjc2MTg0OTg4LCJqdGkiOiJSMkk1R3FLdXM3bWhMUWwzIiwic3ViIjoxMjQ3LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.GlxG-DaiY1Slc0dR8sRK6CvU-F7MTjT47989MImubJ0 +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8 -# @hostname = https://adw-api.ospro.id/api +@hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.ospro.id/api # @hostname = https://api-staging-adw.ospro.id/api # @hostname = http://localhost:8444/api # @hostname = http://103.73.125.81:8444/api -@hostname = http://localhost:8074/adw-backend/api +# @hostname = http://localhost:8074/adw-backend/api ###### login POST {{hostname}}/login @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req @@ -749,6 +749,10 @@ content-type: application/json "project_id": [15] } +### +GET https://adw-api.ospro.id/api/request-material/get-material-integration?name=c +Authorization: Bearer {{token}} +content-type: application/json ### POST {{hostname}}/presence/search @@ -766,8 +770,8 @@ content-type: application/json "name": "m_users", "column_join": "user_id", "column_results": [ - "name", - "ktp_number" + "username", + "name" ] } ], @@ -804,13 +808,15 @@ POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json -{ - "clock_out_lat": -6.16678379060529, - "clock_out_lng": 106.9175039866567, - "clock_time": "2023-02-10T14:48:17+07:00", - "type": "in", - "user_id": 1247 -} +# { +# "clock_out_lat": -6.16678379060529, +# "clock_out_lng": 106.9175039866567, +# "clock_time": "2023-02-10T14:48:17+07:00", +# "type": "in", +# "user_id": 1247 +# } +{"clock_time":"2023-02-14T02:34:28+07:00","type":"in","user_id":1247,"clock_in_lat":-6.2646449,"clock_in_lng":106.7893041} + ###### @@ -954,4 +960,12 @@ content-type: application/json # "length": 25, # "start": 0 # } -# } \ No newline at end of file +# } + + +### get image +# GET {{hostname}}/image/106/presensi +GET {{hostname}}/image/1634/report_activity +Authorization: Bearer {{token}} +content-type: application/json + From 57161f5fe1a5d111dae5fcd1d4a17aa80888cf21 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 14:23:05 +0700 Subject: [PATCH 3/8] add project_code in dashboard --- app/Http/Controllers/DashboardBoDController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index c6309e5..6901b21 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -103,6 +103,7 @@ class DashboardBoDController extends Controller $resp = $this->getInvoiceIntegration($project->kode_sortname); array_push($return, [ 'project' => $project->nama, + 'project_code' => $project->kode_sortname, 'invoiced' => $resp->data->total_invoice_amount ?? 0, 'paid' => $resp->data->total_invoice_paid_amount ?? 0, 'response' => $resp, From ff1e6082823d43ebf13ea2e7c8dc39f1f313cce3 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 15:39:08 +0700 Subject: [PATCH 4/8] change rest-client.http --- rest-client.http | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/rest-client.http b/rest-client.http index 22de8e8..247fbcb 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,20 +1,12 @@ -<<<<<<< HEAD -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2NTE5NDQ2LCJleHAiOjE2NzcxMjQyNDYsIm5iZiI6MTY3NjUxOTQ0NiwianRpIjoiTXE4R3QzeTZRMllCMnRCWiIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.bXhL34fVSLDvAn4OIqiJnDtUCPcTG-Lyct_WtNPd9K8 -======= @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api # @hostname = https://api-iu.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 -<<<<<<< HEAD -# @hostname = http://localhost:8074/adw-backend/api -======= -# @hostname = http://localhost:8444/adw-ba/api ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b +# @hostname = http://localhost:8444/adw-backend/api ###### login POST {{hostname}}/login @@ -813,17 +805,6 @@ POST {{hostname}}/presence/add Authorization: Bearer {{token}} content-type: application/json -<<<<<<< HEAD -# { -# "clock_out_lat": -6.16678379060529, -# "clock_out_lng": 106.9175039866567, -# "clock_time": "2023-02-10T14:48:17+07:00", -# "type": "in", -# "user_id": 1247 -# } -{"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, @@ -831,7 +812,6 @@ content-type: application/json "type": "in", "user_id": 1247 } ->>>>>>> 9503d9e6c6c146a54eff450ddf364d48acfc184b ###### POST {{hostname}}/presence/add From c3f076716692d450c1a9a8def6c6dd0a3536bd1e Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 16:02:25 +0700 Subject: [PATCH 5/8] rest-client --- rest-client.http | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest-client.http b/rest-client.http index 247fbcb..fb33a36 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,4 +1,4 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NjI5MTQwNiwiZXhwIjoxNjc2ODk2MjA2LCJuYmYiOjE2NzYyOTE0MDYsImp0aSI6IkNNRVNGMEcwVzVNQlRLenoiLCJzdWIiOjEyNDcsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.ZV2ncAf6H61vnK7fmg-bMfeqBTcxm0aFE5zs_4tor8g +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTY4ODM5LCJleHAiOjE2Nzc1NzM2MzksIm5iZiI6MTY3Njk2ODgzOSwianRpIjoiYW9jS3djZWYyaHRyQ2w1cCIsInN1YiI6MTI0NywicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.krJmIqfkqQ4Dh9mZye5gCQeB2-JjVf1t1B_GEwnIslQ @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "admin", - "password": "1nt3gr4s14" + "username": "demo", + "password": "demo123" } ###### Tools Req From f9e957a522d39085e1c28b46dc643301170abe22 Mon Sep 17 00:00:00 2001 From: ardhi Date: Tue, 21 Feb 2023 18:05:35 +0700 Subject: [PATCH 6/8] change rest-client --- rest-client.http | 95 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 3 deletions(-) diff --git a/rest-client.http b/rest-client.http index fb33a36..47496cb 100644 --- a/rest-client.http +++ b/rest-client.http @@ -1,4 +1,4 @@ -@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTY4ODM5LCJleHAiOjE2Nzc1NzM2MzksIm5iZiI6MTY3Njk2ODgzOSwianRpIjoiYW9jS3djZWYyaHRyQ2w1cCIsInN1YiI6MTI0NywicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.krJmIqfkqQ4Dh9mZye5gCQeB2-JjVf1t1B_GEwnIslQ +@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hZHctYXBpLm9zcHJvLmlkXC9hcGlcL2xvZ2luIiwiaWF0IjoxNjc2OTc2Mjc1LCJleHAiOjE2Nzc1ODEwNzUsIm5iZiI6MTY3Njk3NjI3NSwianRpIjoiQ1dMUFZOend6cHdZd0dDZyIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.w0ZXoDAch3Hu8ziKBQTSTF5QH5SbaOhFsA__DHJp66A @hostname = https://adw-api.ospro.id/api # @hostname = https://ospro-api.ospro.id/api @@ -15,8 +15,8 @@ POST {{hostname}}/login content-type: application/json { - "username": "demo", - "password": "demo123" + "username": "admin", + "password": "1nt3gr4s14" } ###### Tools Req @@ -784,6 +784,95 @@ content-type: application/json } +### +POST {{hostname}}/report-k3/search +Authorization: Bearer {{token}} +content-type: application/json + +{ + "paging": { + "start": 0, + "length": 10 + }, + "filter_columns": [ + { + "name": "name", + "value": "", + "table_name": "m_users" + } + ], + "columns": [ + { + "name": "report_date", + "logic_operator": "range", + "value": "2023-02-21 00:00:00", + "value1": "2023-02-21 23:59:59", + "operator": "AND" + }, + { + "name": "name", + "logic_operator": "ilike", + "value": "", + "operator": "AND", + "table_name": "m_users" + }, + { + "name": "proyek_id", + "logic_operator": "in", + "value": [ + 80, + 79, + 78, + 76, + 75, + 74, + 73, + 72, + 71, + 66, + 64, + 63, + 62, + 58, + 57, + 49, + 48, + 47, + 37, + 31 + ] + } + ], + "joins": [ + { + "name": "m_users", + "column_join": "user_id", + "column_results": [ + "name" + ] + }, + { + "name": "m_proyek", + "column_join": "proyek_id", + "column_results": [ + "nama" + ] + } + ], + "orders": { + "columns": [ + "id" + ], + "ascending": false + }, + "child_data": { + "table_name": "t_report_k3_detail", + "column_table": "report_k3_id", + "column_name": "id" + } +} + + ### POST {{hostname}}/assign-material/ForReportActivityByMaterial From f4a3195ec597c2d77f1cc22eac4215059688f575 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 23 Feb 2023 16:38:01 +0700 Subject: [PATCH 7/8] Report date validation --- .../ReportActivityMaterialController.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index a4a120b..fd61e5f 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -23,18 +23,24 @@ class ReportActivityMaterialController extends Controller 'qty' => 'required' ]); + $activity = Activity::where('id', $request->activity_id)->first(); + + $start_date = $activity->start_date; + $start_date = substr($start_date, 0, 19); // remove the timezone offset + $startDate = new \DateTime(date("Y-m-d", strtotime($start_date))); + $reportDate = new \DateTime(date("Y-m-d", strtotime($request->report_date))); + $data = $request->all(); $data['created_by'] = $this->currentName; /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ $data['assign_material_id'] = $request->assign_material_id; $data['qty'] = $this->sanitizeDecimal($data['qty']); - - $created = ReportActivityMaterial::create($data); - - if(!$created) - return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null]); - - return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); + if($reportDate > $startDate){ + $created = ReportActivityMaterial::create($data); + return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]); + } else { + return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400); + } } public function updateStatusStartFinish(Request $request){ From e18d0c3c5b06faa60a69b484259ec0102546422f Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 23 Feb 2023 18:51:33 +0700 Subject: [PATCH 8/8] Plan date has to be more than start date --- .../Controllers/AssignMaterialController.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 16f848a..5a89147 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\AssignMaterial; use App\Models\RequestMaterial; +use App\Models\Activity; use App\Models\ReportActivityMaterial; use Datatables; @@ -23,23 +24,30 @@ class AssignMaterialController extends Controller 'qty_planning' => 'required' ]); + $activity = Activity::where('id', $request->activity_id)->first(); + $checkStock = RequestMaterial::where("id", $request->material_id)->first(); $currentStock = $checkStock->qty; if((int)$currentStock < (int)$request->qty_planning){ return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]); } + + $start_date = $activity->start_date; + $start_date = substr($start_date, 0, 19); // remove the timezone offset + $startDate = new \DateTime(date("Y-m-d", strtotime($start_date))); + $planDate = new \DateTime(date("Y-m-d", strtotime($request->plan_date))); $data = $request->all(); $data['created_by'] = $this->currentName; $data['budget'] = $checkStock->price; $data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']); - $result = AssignMaterial::create($data); - if(!$result) - return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]); - - return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200]); - + if ($planDate > $startDate) { + $result = AssignMaterial::create($data); + return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200); + }else{ + return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 400], 400); + } } public function update(Request $request, $id){