From f7bb82f792f5f1f0354cc830b04cb99fba6bbf86 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 8 Dec 2023 15:16:59 +0700 Subject: [PATCH 1/5] update select customer role --- app/Http/Controllers/ProjectController.php | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 3015327..ff9a3cf 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -503,20 +503,29 @@ class ProjectController extends Controller return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); } - public function getByUser($id) - { - $alias = "utp"; + public function getByUser($id) { $userProyek = UserToProyek::query() - ->from('assign_hr_to_proyek AS ' . $alias) + ->from('assign_hr_to_proyek AS ahtp') ->where([ ['is_customer', true], ['user_id', $id] ]) - ->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id') - ->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id') - ->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') - ->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name') - ->get(); + ->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id') + ->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id') + ->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id') + ->select( + 'mp.id', + 'mp.nama', + 'mp.rencana_biaya', + 'mp.type_proyek_id', + 'mp.currency_symbol', + 'mp.mulai_proyek', + 'mp.akhir_proyek', + 'm_users.name AS join_first_name', + 'm_users.username AS join_first_username', + 'm_type_proyek.name AS join_second_name', + 'm_type_proyek.name AS join_second_description' + )->get(); $totalRecord = $userProyek->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); From 67da512ce725fa0f1f14e534c19caad4de602188 Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 13 Dec 2023 20:36:12 +0700 Subject: [PATCH 2/5] update filter project by company --- .../ProjectCarausellController.php | 40 +++++++++++++------ routes/web.php | 2 +- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/ProjectCarausellController.php b/app/Http/Controllers/ProjectCarausellController.php index e64aca9..6abd158 100644 --- a/app/Http/Controllers/ProjectCarausellController.php +++ b/app/Http/Controllers/ProjectCarausellController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use Illuminate\Http\Request; use App\Models\{ User, Project, @@ -9,33 +10,46 @@ use App\Models\{ ProjectIssues, ProjectRisks }; + class ProjectCarausellController extends Controller { - public function invoke() { + public function invoke(Request $request) + { // Master Data - $projectData = Project::query() - ->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") - ->get(); + $company_id = $request->route('company_id'); + $all_project = $request->route('all_project'); + $hierarchy = $request->route('hierarchy'); + + $query = Project::query() + ->select("id", "nama", "kode_sortname", "pm_id", "budget_health", "calculation_status", "mulai_proyek", "akhir_proyek", "rencana_biaya", "company", "scurve"); + + if ($all_project) { + $query->where('company_id', $company_id); + } else { + $query->where('created_by_id', $hierarchy); + } + + $projectData = $query->get(); $arr = []; - foreach($projectData as $project) { + foreach ($projectData as $project) { $projectRisk = ProjectRisks::query() - ->select('proyek_id','description','level_risk','preventive_risk') + ->select('proyek_id', 'description', 'level_risk', 'preventive_risk') ->where('proyek_id', $project['id']) ->get() ->toArray(); $projectIssue = ProjectIssues::query() - ->select('proyek_id','description','level_issue') - ->where('proyek_id',$project['id']) + ->select('proyek_id', 'description', 'level_issue') + ->where('proyek_id', $project['id']) ->get() ->toArray(); $ganttData = VersionGantt::query() - ->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id','calculation_type') - ->where('proyek_id',$project['id']) + ->select('id', 'name_version', 'hierarchy_ftth_id', 'cost_to_complete', 'proyek_id', 'calculation_type') + ->where('proyek_id', $project['id']) ->orderByDesc('id') ->first(); $projectManager = User::where('id', $project['pm_id'])->value('name'); - $arr[]= [ + $arr[] = [ "project" => [ "id" => $project['id'], "pm_id" => $project['pm_id'], @@ -52,9 +66,9 @@ class ProjectCarausellController extends Controller "project_manager" => $projectManager, "project_risk" => $projectRisk, "project_issue" => $projectIssue, - "gantt"=> $ganttData + "gantt" => $ganttData ]; } - return response()->json(['status'=>'success','code'=> 200,'data'=> $arr, "total_project"=>count($arr)], 200); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $arr, "total_project" => count($arr)], 200); } } diff --git a/routes/web.php b/routes/web.php index 0d334f0..77ce518 100644 --- a/routes/web.php +++ b/routes/web.php @@ -81,7 +81,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ - $router->get('/project-carausell', 'ProjectCarausellController@invoke'); + $router->get('/project-carausell/{company_id}/{all_project}/{hierarchy}', 'ProjectCarausellController@invoke'); $router->post('/project-charter/search', 'ProjectCharterController@search'); $router->post('/project-charter/add', 'ProjectCharterController@add'); From d1f1deac35e2fab60a4bbd8a8e896a0e3483ad12 Mon Sep 17 00:00:00 2001 From: farhantock Date: Wed, 13 Dec 2023 21:48:39 +0700 Subject: [PATCH 3/5] update func getInvoiceOutstanding --- .../Controllers/DashboardBoDController.php | 22 +++++++++++++------ routes/web.php | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 9b77805..cabc763 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -111,22 +111,30 @@ class DashboardBoDController extends Controller } // integrasi - public function getInvoiceOutstanding($year = '%') + public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy) { $year = $this->interpolateYear($year); - $projects = Project::where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ - ->get(); + $projects = null; + if ($all_project) { + $projects = Project::where('mulai_proyek', 'like', $year) + ->where('company_id', $company_id) + ->get(); + } else { + $projects = Project::where('mulai_proyek', 'like', $year) + ->where('created_by_id', $hierarchy) + ->get(); + } + $return = []; foreach ($projects as $project) { $resp = null; if ($project->kode_sortname != "") { - $resp = $this->getInvoiceIntegration($project->kode_sortname); + // $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, + 'invoiced' => 0, + 'paid' => 0, 'response' => $resp, ]); } diff --git a/routes/web.php b/routes/web.php index 77ce518..4d69afb 100644 --- a/routes/web.php +++ b/routes/web.php @@ -24,7 +24,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { $router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-invoice-outstanding/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in $router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); $router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); $router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); From 1971cb56146d26228705cb64b56bf4269ff7739f Mon Sep 17 00:00:00 2001 From: farhantock Date: Thu, 14 Dec 2023 10:34:16 +0700 Subject: [PATCH 4/5] update filter --- app/Http/Controllers/DashboardBoDController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index cabc763..81c8830 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -203,12 +203,11 @@ class DashboardBoDController extends Controller $year = $this->interpolateYear($year); $divisions = Divisi::whereNull('parent') ->where('company_id', $company_id) + ->whereNull('parent') ->get(); - $divisions = Divisi::whereNull('parent')->get(); foreach ($divisions as $index => $division) { - $scheduleData = new Collection(); $behindSchedule = $warning = $onSchedule = 0; From adfeb117f62a4fbada2e00cac5737472246d50d7 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 20 Dec 2023 05:54:05 +0700 Subject: [PATCH 5/5] add endpoint & logic color chart --- .../Controllers/DashboardBoDController.php | 100 +++++++++++++++++- .../ProjectExpenditureController.php | 93 ++++++++++++++++ .../ProjectFinancialHealthController.php | 93 ++++++++++++++++ .../Controllers/ProjectInvoiceController.php | 93 ++++++++++++++++ .../ProjectScheduleHealthController.php | 93 ++++++++++++++++ app/Models/ProjectExpenditure.php | 17 +++ app/Models/ProjectFinancialHealth.php | 17 +++ app/Models/ProjectInvoice.php | 17 +++ app/Models/ProjectScheduleHealth.php | 17 +++ routes/web.php | 28 +++++ 10 files changed, 566 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/ProjectExpenditureController.php create mode 100644 app/Http/Controllers/ProjectFinancialHealthController.php create mode 100644 app/Http/Controllers/ProjectInvoiceController.php create mode 100644 app/Http/Controllers/ProjectScheduleHealthController.php create mode 100644 app/Models/ProjectExpenditure.php create mode 100644 app/Models/ProjectFinancialHealth.php create mode 100644 app/Models/ProjectInvoice.php create mode 100644 app/Models/ProjectScheduleHealth.php diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index 81c8830..d82a3e9 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -2,15 +2,19 @@ namespace App\Http\Controllers; -use App\Helpers\MasterFunctionsHelper; +use App\Models\User; use App\Models\Divisi; use App\Models\Project; use App\Models\ProjectPhase; -use App\Models\User; +use App\Models\ProjectExpenditure; use App\Models\UserToVersionGantt; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; +use App\Models\ProjectScheduleHealth; +use App\Helpers\MasterFunctionsHelper; +use App\Models\ProjectFinancialHealth; +use App\Models\ProjectInvoice; class DashboardBoDController extends Controller { @@ -110,6 +114,98 @@ class DashboardBoDController extends Controller ], 200); } + public function getDetailExpenditureColor($company_id) { + $query = ProjectExpenditure::where('company_id',$company_id)->get(); + $data = []; + foreach($query as $value) { + if($value['name'] === 'Total Budget') { + $data['total_budget'] = $value['color']; + } + if($value['name'] === 'Expenditure') { + $data['total_expenditure'] = $value['color']; + } + if($value['name'] === 'Invoice') { + $data['total_invoice'] = $value['color']; + } + if($value['name'] === 'Cash In') { + $data['total_paid_invoice'] = $value['color']; + } + } + return response()->json([ + 'data' => [ + 'total_budget' => $data['total_budget'] ?? '', + 'total_expenditure' => $data['total_expenditure'] ?? '', + 'total_invoice' => $data['total_invoice'] ?? '', + 'total_paid_invoice' => $data['total_paid_invoice'] ?? '', + ] + ], 200); + } + + public function getDetailFinancialHealthColor($company_id) { + $query = ProjectFinancialHealth::where('company_id',$company_id)->get(); + $data = []; + foreach($query as $value) { + if($value['name'] === 'Cost Overrun') { + $data['overrun'] = $value['color']; + } + if($value['name'] === 'Early Warning') { + $data['warning'] = $value['color']; + } + if($value['name'] === 'On Budget') { + $data['on-budget'] = $value['color']; + } + } + return response()->json([ + 'data' => [ + 'overrun' => $data['overrun'] ?? '', + 'warning' => $data['warning'] ?? '', + 'on-budget' => $data['on-budget'] ?? '', + ] + ], 200); + } + + public function getDetailScheduleHealthColor($company_id) { + $query = ProjectScheduleHealth::where('company_id',$company_id)->get(); + $data = []; + foreach($query as $value) { + if($value['name'] === 'Behind Schedule') { + $data['behind-schedule'] = $value['color']; + } + if($value['name'] === 'Early Warning') { + $data['warning'] = $value['color']; + } + if($value['name'] === 'On Schedule') { + $data['on-schedule'] = $value['color']; + } + } + return response()->json([ + 'data' => [ + 'behind-schedule' => $data['behind-schedule'] ?? '', + 'warning' => $data['warning'] ?? '', + 'on-schedule' => $data['on-schedule'] ?? '', + ] + ], 200); + } + + public function getDetailInvoiceColor($company_id) { + $query = ProjectInvoice::where('company_id',$company_id)->get(); + $data = []; + foreach($query as $value) { + if($value['name'] === 'Invoiced') { + $data['invoiced'] = $value['color']; + } + if($value['name'] === 'Cash In') { + $data['paid'] = $value['color']; + } + } + return response()->json([ + 'data' => [ + 'invoiced' => $data['invoiced'] ?? '', + 'paid' => $data['paid'] ?? '' + ] + ], 200); + } + // integrasi public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy) { diff --git a/app/Http/Controllers/ProjectExpenditureController.php b/app/Http/Controllers/ProjectExpenditureController.php new file mode 100644 index 0000000..43f379d --- /dev/null +++ b/app/Http/Controllers/ProjectExpenditureController.php @@ -0,0 +1,93 @@ +validate($request, [ + 'name' => 'required' + ]); + $data = $request->all(); + // Set Unique + $result = ProjectExpenditure::query() + ->where([ + ['company_id',$data['company_id']], + ['name', $data['name']] + ])->first(); + if($result) { + return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); + die; + } + + $data['created_by'] = $this->currentName; + + if(!ProjectExpenditure::create($data)) + return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$result = ProjectExpenditure::find($id)) + return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); + + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$data = ProjectExpenditure::find($id)) + return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400); + + if(!$data->update($request->all())) + return response()->json(['status'=>'failed','message'=>'data project expenditure failed updated!','code'=>400], 400); + + return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); + } + + public function delete($id) + { + + if(!$data = ProjectExpenditure::find($id)) + return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400); + + if(!$data->delete()) + return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_proyek_expenditure'); + $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() + { + $data = ProjectExpenditure::all(); + $countData = $data->count(); + + if(!$data) + return response()->json(['status'=>'failed','message'=>'failed get list project expenditure, please try again later!','code'=>400], 400); + + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + + } +} diff --git a/app/Http/Controllers/ProjectFinancialHealthController.php b/app/Http/Controllers/ProjectFinancialHealthController.php new file mode 100644 index 0000000..7fcabd6 --- /dev/null +++ b/app/Http/Controllers/ProjectFinancialHealthController.php @@ -0,0 +1,93 @@ +validate($request, [ + 'name' => 'required' + ]); + $data = $request->all(); + // Set Unique + $result = ProjectFinancialHealth::query() + ->where([ + ['company_id',$data['company_id']], + ['name', $data['name']] + ])->first(); + if($result) { + return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); + die; + } + + $data['created_by'] = $this->currentName; + + if(!ProjectFinancialHealth::create($data)) + return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$result = ProjectFinancialHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); + + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$data = ProjectFinancialHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400); + + if(!$data->update($request->all())) + return response()->json(['status'=>'failed','message'=>'Data financial health failed updated!','code'=>400], 400); + + return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); + } + + public function delete($id) + { + + if(!$data = ProjectFinancialHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400); + + if(!$data->delete()) + return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_proyek_financial_health'); + $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() + { + $data = ProjectFinancialHealth::all(); + $countData = $data->count(); + + if(!$data) + return response()->json(['status'=>'failed','message'=>'failed get list financial health, please try again later!','code'=>400], 400); + + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + + } +} diff --git a/app/Http/Controllers/ProjectInvoiceController.php b/app/Http/Controllers/ProjectInvoiceController.php new file mode 100644 index 0000000..12f9a6f --- /dev/null +++ b/app/Http/Controllers/ProjectInvoiceController.php @@ -0,0 +1,93 @@ +validate($request, [ + 'name' => 'required' + ]); + $data = $request->all(); + // Set Unique + $result = ProjectInvoice::query() + ->where([ + ['company_id',$data['company_id']], + ['name', $data['name']] + ])->first(); + if($result) { + return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); + die; + } + + $data['created_by'] = $this->currentName; + + if(!ProjectInvoice::create($data)) + return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$result = ProjectInvoice::find($id)) + return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); + + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$data = ProjectInvoice::find($id)) + return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400); + + if(!$data->update($request->all())) + return response()->json(['status'=>'failed','message'=>'data project invoice failed updated!','code'=>400], 400); + + return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); + } + + public function delete($id) + { + + if(!$data = ProjectInvoice::find($id)) + return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400); + + if(!$data->delete()) + return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_proyek_invoice'); + $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() + { + $data = ProjectInvoice::all(); + $countData = $data->count(); + + if(!$data) + return response()->json(['status'=>'failed','message'=>'failed get list project invoice, please try again later!','code'=>400], 400); + + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + + } +} diff --git a/app/Http/Controllers/ProjectScheduleHealthController.php b/app/Http/Controllers/ProjectScheduleHealthController.php new file mode 100644 index 0000000..2bae0bd --- /dev/null +++ b/app/Http/Controllers/ProjectScheduleHealthController.php @@ -0,0 +1,93 @@ +validate($request, [ + 'name' => 'required' + ]); + $data = $request->all(); + // Set Unique + $result = ProjectScheduleHealth::query() + ->where([ + ['company_id',$data['company_id']], + ['name', $data['name']] + ])->first(); + if($result) { + return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500); + die; + } + + $data['created_by'] = $this->currentName; + + if(!ProjectScheduleHealth::create($data)) + return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200); + } + + public function edit($id){ + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$result = ProjectScheduleHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404); + + return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); + } + + public function update(Request $request, $id) + { + if(!$id || (int) $id < 0 || $id=="") + return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); + + if(!$data = ProjectScheduleHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400); + + if(!$data->update($request->all())) + return response()->json(['status'=>'failed','message'=>'data schedule health failed updated!','code'=>400], 400); + + return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200); + } + + public function delete($id) + { + + if(!$data = ProjectScheduleHealth::find($id)) + return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400); + + if(!$data->delete()) + return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500); + + return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200); + } + + public function search(Request $request) + { + $payload = $request->all(); + $dataBuilder = $this->setUpPayload($payload, 'm_proyek_schedule_health'); + $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() + { + $data = ProjectScheduleHealth::all(); + $countData = $data->count(); + + if(!$data) + return response()->json(['status'=>'failed','message'=>'failed get list schedule health, please try again later!','code'=>400], 400); + + return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); + + } +} diff --git a/app/Models/ProjectExpenditure.php b/app/Models/ProjectExpenditure.php new file mode 100644 index 0000000..2eb803d --- /dev/null +++ b/app/Models/ProjectExpenditure.php @@ -0,0 +1,17 @@ +group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->get('/dashboard/get-total-project-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerDivision'); $router->get('/dashboard/get-total-project-value-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectValuePerDivision'); $router->get('/dashboard/get-detail-expenditure/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getDetailExpenditure'); + $router->get('/dashboard/get-detail-expenditure-color/{company_id}', 'DashboardBoDController@getDetailExpenditureColor'); + $router->get('/dashboard/get-detail-financial-health-color/{company_id}', 'DashboardBoDController@getDetailFinancialHealthColor'); + $router->get('/dashboard/get-detail-schedule-health-color/{company_id}', 'DashboardBoDController@getDetailScheduleHealthColor'); + $router->get('/dashboard/get-detail-invoice-color/{company_id}', 'DashboardBoDController@getDetailInvoiceColor'); $router->post('/role/search', 'RoleController@search'); $router->post('/role/add', 'RoleController@add'); @@ -139,6 +143,30 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); $router->get('/project-phase/list', 'ProjectPhaseController@list'); + $router->post('/project-expenditure/add', 'ProjectExpenditureController@add'); + $router->post('/project-expenditure/search', 'ProjectExpenditureController@search'); + $router->get('/project-expenditure/edit/{id}', 'ProjectExpenditureController@edit'); + $router->put('/project-expenditure/update/{id}', 'ProjectExpenditureController@update'); + $router->delete('/project-expenditure/delete/{id}', 'ProjectExpenditureController@delete'); + + $router->post('/project-financial-health/add', 'ProjectFinancialHealthController@add'); + $router->post('/project-financial-health/search', 'ProjectFinancialHealthController@search'); + $router->get('/project-financial-health/edit/{id}', 'ProjectFinancialHealthController@edit'); + $router->put('/project-financial-health/update/{id}', 'ProjectFinancialHealthController@update'); + $router->delete('/project-financial-health/delete/{id}', 'ProjectFinancialHealthController@delete'); + + $router->post('/project-schedule-health/add', 'ProjectScheduleHealthController@add'); + $router->post('/project-schedule-health/search', 'ProjectScheduleHealthController@search'); + $router->get('/project-schedule-health/edit/{id}', 'ProjectScheduleHealthController@edit'); + $router->put('/project-schedule-health/update/{id}', 'ProjectScheduleHealthController@update'); + $router->delete('/project-schedule-health/delete/{id}', 'ProjectScheduleHealthController@delete'); + + $router->post('/project-invoice/add', 'ProjectInvoiceController@add'); + $router->post('/project-invoice/search', 'ProjectInvoiceController@search'); + $router->get('/project-invoice/edit/{id}', 'ProjectInvoiceController@edit'); + $router->put('/project-invoice/update/{id}', 'ProjectInvoiceController@update'); + $router->delete('/project-invoice/delete/{id}', 'ProjectInvoiceController@delete'); + $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); $router->post('/request-material/add', 'RequestMaterialController@add');