Browse Source

add endpoint project-by-customer/{id}

pull/3/head
wahyuun 1 year ago
parent
commit
e8c8961bd5
  1. 95
      app/Http/Controllers/ProjectController.php
  2. 2
      app/Models/UserToProyek.php
  3. 2
      routes/web.php

95
app/Http/Controllers/ProjectController.php

@ -64,7 +64,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200);
}
public function edit($id){
public function edit($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -203,6 +204,20 @@ class ProjectController extends Controller
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete();
}
public function getByUser($id)
{
$result = UserToProyek::query()
->where([
['user_id', $id],
['is_customer', true]
])->get();
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'Get User Project Not Found!', 'code' => 404], 404);
}
}
public function search(Request $request)
{
$payload = $request->all();
@ -312,10 +327,13 @@ class ProjectController extends Controller
'projectsByPhase' => $projectsByPhase,
'projectTypes' => $projectTypes,
'projectsByType' => $projectsByType,
], 200);
],
200
);
}
public function getListProjectTask($id){
public function getListProjectTask($id)
{
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*")
->where("assign_hr_to_activity.user_id", $id)
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id')
@ -328,23 +346,27 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function getSCurve(Request $request){
public function getSCurve(Request $request)
{
$data = MasterFunctionsHelper::getSCurve($request);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function calculateSCurve(Request $request){
public function calculateSCurve(Request $request)
{
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200);
}
public function sCurveCommand(Request $request){
public function sCurveCommand(Request $request)
{
Artisan::call('calculate:scurve', [
'project_id' => $request->project_id
]);
}
public function getLinearSCurve(Request $request){
public function getLinearSCurve(Request $request)
{
$data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
@ -405,7 +427,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200);
}
public function getInvoiceIntegration(Request $request) {
public function getInvoiceIntegration(Request $request)
{
// $search = urlencode($request->search);
// if(empty($search))
// return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
@ -417,7 +440,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'data' => '', 'code' => 200], 200);
}
public function detail($id){
public function detail($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -432,7 +456,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $gantt], 200);
}
public function getOverdueActivities(Request $request){
public function getOverdueActivities(Request $request)
{
$payload = $request->all();
if (empty($payload['id']) || !is_int((int)$payload['id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -452,15 +477,26 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}
public function getReportDistribution(Request $request){
public function getReportDistribution(Request $request)
{
$payload = $request->all();
if (empty($payload['project_id']) || !is_int((int)$payload['project_id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$reports = DB::table('assign_material_to_activity as ama')
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit',
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date')
->select(
'u.name',
'a.name as activity_name',
'ama.qty_planning',
'ram.qty as qty_real',
'rm.description as material_name',
'rm.uom as material_unit',
'ram.lat',
'ram.lon',
'ram.description as report_notes',
'ram.report_date'
)
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id')
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
@ -472,12 +508,14 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200);
}
public function getManpower($proyek_id){
public function getManpower($proyek_id)
{
$manCount = UserToProyek::where('proyek_id', $proyek_id)->count();
return response()->json(['totalRecord' => $manCount]);
}
public function getAssignedHR($gantt_id){
public function getAssignedHR($gantt_id)
{
$results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id')
->where('assign_hr_to_activity.version_gantt_id', $gantt_id)
@ -488,8 +526,17 @@ class ProjectController extends Controller
public function dashboard($id)
{
$data = DB::table('m_proyek as mp')
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish',
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health')
->select(
'mp.kode_sortname',
'mp.nama as name_project',
'mp.mulai_proyek as start',
'mp.akhir_proyek as finish',
'mp.rencana_biaya',
'mp.company',
'mp.currency_symbol',
'mu.name as pm',
'mp.budget_health'
)
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id')
->where('mp.id', $id)
->first();
@ -504,8 +551,13 @@ class ProjectController extends Controller
$progress = @$rootActivity->persentase_progress ?? 0;
$commentActivity = DB::table('m_comment_activity as mca')
->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created',
'ma.name as activity')
->select(
'mca.activity_id',
'mca.comment as comment',
'mca.created_by as comment_by',
'mca.created_at as comment_created',
'ma.name as activity'
)
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id')
->where('ma.proyek_id', $id)
->orderBy('comment_by')
@ -520,7 +572,8 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
private function httpReq($search){
private function httpReq($search)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION));
@ -536,6 +589,4 @@ class ProjectController extends Controller
return json_decode($output);
}
}

2
app/Models/UserToProyek.php

@ -12,7 +12,7 @@ class UserToProyek extends Model
const UPDATED_AT = 'updated_at';
protected $fillable = [
'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate',
'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'is_customer', 'standart_rate',
'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at',
'base_calender', 'created_at', 'created_by', 'updated_at', 'updated_by'
];

2
routes/web.php

@ -53,6 +53,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}', 'ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search');
$router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update');
@ -456,5 +457,4 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/map-monitoring/search', 'MapMonitoringController@search');
});
});

Loading…
Cancel
Save