Browse Source

update conflict

pull/3/head
ibnu 2 years ago
parent
commit
ff4cde0eb4
  1. 20
      app/Http/Controllers/AssignMaterialController.php
  2. 1
      app/Http/Controllers/DashboardBoDController.php
  3. 20
      app/Http/Controllers/ReportActivityMaterialController.php
  4. 7
      app/Models/Activity.php
  5. 3
      app/Models/UserToActivity.php
  6. 114
      rest-client.http

20
app/Http/Controllers/AssignMaterialController.php

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\RequestMaterial; use App\Models\RequestMaterial;
use App\Models\Activity;
use App\Models\ReportActivityMaterial; use App\Models\ReportActivityMaterial;
use Datatables; use Datatables;
@ -23,23 +24,30 @@ class AssignMaterialController extends Controller
'qty_planning' => 'required' 'qty_planning' => 'required'
]); ]);
$activity = Activity::where('id', $request->activity_id)->first();
$checkStock = RequestMaterial::where("id", $request->material_id)->first(); $checkStock = RequestMaterial::where("id", $request->material_id)->first();
$currentStock = $checkStock->qty; $currentStock = $checkStock->qty;
if((int)$currentStock < (int)$request->qty_planning){ if((int)$currentStock < (int)$request->qty_planning){
return response()->json(['status'=>'failed','message'=>'Stock is not enough!','code'=> 500]); 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 = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$data['budget'] = $checkStock->price; $data['budget'] = $checkStock->price;
$data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']); $data['qty_planning'] = $this->sanitizeDecimal($data['qty_planning']);
$result = AssignMaterial::create($data); if ($planDate > $startDate) {
if(!$result) $result = AssignMaterial::create($data);
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500]); return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200], 200);
}else{
return response()->json(['status'=>'success','message'=>'Data added!', 'code'=>200]); return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 400], 400);
}
} }
public function update(Request $request, $id){ public function update(Request $request, $id){

1
app/Http/Controllers/DashboardBoDController.php

@ -103,6 +103,7 @@ class DashboardBoDController extends Controller
$resp = $this->getInvoiceIntegration($project->kode_sortname); $resp = $this->getInvoiceIntegration($project->kode_sortname);
array_push($return, [ array_push($return, [
'project' => $project->nama, 'project' => $project->nama,
'project_code' => $project->kode_sortname,
'invoiced' => $resp->data->total_invoice_amount ?? 0, 'invoiced' => $resp->data->total_invoice_amount ?? 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0, 'paid' => $resp->data->total_invoice_paid_amount ?? 0,
'response' => $resp, 'response' => $resp,

20
app/Http/Controllers/ReportActivityMaterialController.php

@ -23,18 +23,24 @@ class ReportActivityMaterialController extends Controller
'qty' => 'required' '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 = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
/* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */ /* $data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first(); */
$data['assign_material_id'] = $request->assign_material_id; $data['assign_material_id'] = $request->assign_material_id;
$data['qty'] = $this->sanitizeDecimal($data['qty']); $data['qty'] = $this->sanitizeDecimal($data['qty']);
if($reportDate > $startDate){
$created = ReportActivityMaterial::create($data); $created = ReportActivityMaterial::create($data);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
if(!$created) } else {
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null]); return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400,'data'=>null], 400);
}
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200,'data'=>array('report_id'=>$created->id)]);
} }
public function updateStatusStartFinish(Request $request){ public function updateStatusStartFinish(Request $request){

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){

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();
}); });

114
rest-client.http

@ -1,12 +1,12 @@
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y @token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3Q6ODQ0NFwvYXBpXC9sb2dpbiIsImlhdCI6MTY3NzQ3NzIzMSwiZXhwIjoxNjc4MDgyMDMxLCJuYmYiOjE2Nzc0NzcyMzEsImp0aSI6ImR5WWhRY3ZIbUJEcmFKMG0iLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.9zT6CBbQholzIdQ9ZBDoxMvrR-PKvIYkGzdNB6bim0Y
# @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
# @hostname = http://localhost:8444/adw-ba/api # @hostname = http://localhost:8444/adw-backend/api
###### login ###### login
POST {{hostname}}/login POST {{hostname}}/login
@ -749,6 +749,10 @@ content-type: application/json
"project_id": [15] "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 POST {{hostname}}/presence/search
@ -766,8 +770,8 @@ content-type: application/json
"name": "m_users", "name": "m_users",
"column_join": "user_id", "column_join": "user_id",
"column_results": [ "column_results": [
"name", "username",
"ktp_number" "name"
] ]
} }
], ],
@ -780,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 POST {{hostname}}/assign-material/ForReportActivityByMaterial
@ -974,6 +1067,7 @@ content-type: application/json
# } # }
<<<<<<< HEAD
GET /stock_master?name=SEARCH GET /stock_master?name=SEARCH
###### ######
@ -1008,4 +1102,12 @@ content-type: application/json
}] }]
} }
} }
=======
### get image
# GET {{hostname}}/image/106/presensi
GET {{hostname}}/image/1634/report_activity
Authorization: Bearer {{token}}
content-type: application/json
>>>>>>> e18d0c3c5b06faa60a69b484259ec0102546422f

Loading…
Cancel
Save