From e8c8961bd5d2e2c5675c532f75600f339c2e3299 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 23 Aug 2023 18:11:45 +0700 Subject: [PATCH 1/8] add endpoint project-by-customer/{id} --- app/Http/Controllers/ProjectController.php | 991 +++++++++++---------- app/Models/UserToProyek.php | 38 +- routes/web.php | 908 +++++++++---------- 3 files changed, 994 insertions(+), 943 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 6e8ca66..e558e78 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -36,237 +36,252 @@ const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json& class ProjectController extends Controller { - public function add(Request $request) - { - $this->validate($request, [ - 'nama' => 'required', - 'mulai_proyek' => 'required', - 'akhir_proyek' => 'required', - 'rencana_biaya' => 'required', - 'type_proyek_id' => 'required' - ]); - - $data = $request->all(); - - $data['created_by'] = $this->currentName; - - if(empty($data['phase_id'])) - $data['phase_id'] = 1; - - $result = Project::create($data); - - if(!$result) - return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500], 500); - - $this->createOfficeHours($result->id); - $dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); - - return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200); - } - - public function edit($id){ - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $result = Project::find($id); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); - - return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); - } - - public function update(Request $request, $id) - { - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $data = Project::find($id); - - if(!$data) - return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); - - $result = $data->update($request->all()); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Failed to update!','code'=> 500], 500); - - return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200); - } - - private function createOfficeHours($proyek_id) - { - $dataCreate = array( - "proyek_id"=>$proyek_id, - "monday_start"=> "08:00:00", - "monday_end"=> "16:00:00", - "tuesday_start"=> "08:00:00", - "tuesday_end"=> "16:00:00", - "wednesday_start"=> "08:00:00", - "wednesday_end"=> "16:00:00", - "thursday_start"=> "08:00:00", - "thursday_end"=> "16:00:00", - "friday_start"=> "08:00:00", - "friday_end"=> "16:00:00", - "saturday_start"=> "08:00:00", - "saturday_end"=> "16:00:00", - "sunday_start"=> "08:00:00", - "sunday_end"=> "16:00:00", - "created_by"=> $this->currentName - ); - - OfficeHours::create($dataCreate); - - return true; - } - - public function delete($id) - { - $data = Project::find($id); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - - $this->deleteRelative($id); - - if(!$data->delete()) - return response()->json(['status'=>'failed','message'=>'Delete failed!','code'=> 500], 500); - - return response()->json(['status'=>'success','message'=>'Data deleted!','code'=>200], 200); - } - - private function deleteRelative($project_id) - { - UserToProyek::where('proyek_id', $project_id)->delete(); - UserToActivity::where('proyek_id', $project_id)->delete(); - AssignMaterial::where('proyek_id', $project_id)->delete(); - ProjectCharter::where('proyek_id', $project_id)->delete(); - ProjectApproval::where('proyek_id', $project_id)->delete(); - ProjectMileStone::where('proyek_id', $project_id)->delete(); - ProjectParticipants::where('proyek_id', $project_id)->delete(); - $this->deleteVersionGantt($project_id); - $this->deleteDokumenProject($project_id); - } - - private function deleteVersionGantt($project_id) - { - $dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id"); - $vhIds = $dataVg->all(); - $activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id'); - $activityIds = $activity->all(); - $dataRa = ReportActivity::whereIn("activity_id", $activityIds)->get(); - foreach ($dataRa as $ra) { - $images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get(); - foreach ($images as $image) { - if(file_exists($this->pathImage.$image->image)){ - unlink($this->pathImage.$image->image); - } - } - Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete(); - } - $dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get(); - foreach ($dataAd as $ad) { - if(file_exists($this->pathActivityDocument.$ad->file)){ - unlink($this->pathActivityDocument.$ad->file); - } - } - ActivityDokumen::whereIn("activity_id", $activityIds)->delete(); - CommentActivity::whereIn("activity_id", $activityIds)->delete(); - Holiday::where("proyek_id", $project_id)->delete(); - VersionGantt::where("proyek_id", $project_id)->delete(); - Link::whereIn("version_gantt_id", $vhIds)->delete(); - ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete(); - Activity::whereIn("version_gantt_id", $vhIds)->delete(); - ReportActivity::whereIn("activity_id", $activityIds)->delete(); - } - - private function deleteDokumenProject($project_id) - { - $dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); - - foreach ($dataDokumen as $dokumen) { - if(file_exists($this->pathDocument.$dokumen->file)){ - unlink($this->pathDocument.$dokumen->file); - } - } - DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete(); - - $dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id"); - $ref_ids = $dataFolder->all(); - $dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); - foreach ($dataDokumen as $dokumen) { - if(file_exists($this->pathDocument.$dokumen->file)){ - unlink($this->pathDocument.$dokumen->file); - } - } - - DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); - } - - public function search(Request $request) - { - $payload = $request->all(); - - $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); - $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 = Project::orderBy('id', 'desc')->get(); - $countData = $data->count(); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - - $scheduleWarningThreshold = 10; - $scheduleDangerThreshold = 5; - foreach($data as $d){ - $progress = $costVariance = $actualCost = 0; - $lastActivity = null; - $scheduleHealth = "on-track"; - $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); - if($rootActivity){ - $costVariance = (int)$d->rencana_biaya - (int)$rootActivity->biaya_actual; - $actualCost = $rootActivity->biaya_actual ?? 0; - $progress = $rootActivity->persentase_progress ?? 0; - - $timeleft = strtotime($d->mulai_proyek) - strtotime($rootActivity->end_date); - $date1 = new \DateTime(date("Y-m-d", strtotime($d->mulai_proyek))); - $date2 = new \DateTime(date("Y-m-d", strtotime($rootActivity->end_date))); - $daysRemaining = $date2->diff($date1); - $daysRemaining = $daysRemaining->d; - - if($daysRemaining <= $scheduleDangerThreshold) { - $scheduleHealth = "danger"; - } elseif ($daysRemaining <= $scheduleWarningThreshold) { - $scheduleHealth = "warning"; - } - $lastActivity = date("d/m/Y", strtotime($rootActivity->end_date)); - } - $d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); - $d->plannedCost = $d->rencana_biaya; - $d->actualCost = $actualCost; - $d->lastActivity = $lastActivity ?? "-"; - $d->costVariance = $costVariance; - $d->costHealth = $d->budget_health; - $d->scheduleHealth = $scheduleHealth; - $d->progress = $progress; - $d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; - $d->manpower = UserToProyek::where("proyek_id", $d->id)->count() ?? 0; + public function add(Request $request) + { + $this->validate($request, [ + 'nama' => 'required', + 'mulai_proyek' => 'required', + 'akhir_proyek' => 'required', + 'rencana_biaya' => 'required', + 'type_proyek_id' => 'required' + ]); + + $data = $request->all(); + + $data['created_by'] = $this->currentName; + + if (empty($data['phase_id'])) + $data['phase_id'] = 1; + + $result = Project::create($data); + + if (!$result) + return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500); + + $this->createOfficeHours($result->id); + $dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); + + return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200); + } + + public function edit($id) + { + if (empty($id) || !is_int((int)$id)) + return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); + + $result = Project::find($id); + + if (!$result) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } + + public function update(Request $request, $id) + { + if (empty($id) || !is_int((int)$id)) + return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); + + $data = Project::find($id); + + if (!$data) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + $result = $data->update($request->all()); + + if (!$result) + return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500); + + return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200); + } + + private function createOfficeHours($proyek_id) + { + $dataCreate = array( + "proyek_id" => $proyek_id, + "monday_start" => "08:00:00", + "monday_end" => "16:00:00", + "tuesday_start" => "08:00:00", + "tuesday_end" => "16:00:00", + "wednesday_start" => "08:00:00", + "wednesday_end" => "16:00:00", + "thursday_start" => "08:00:00", + "thursday_end" => "16:00:00", + "friday_start" => "08:00:00", + "friday_end" => "16:00:00", + "saturday_start" => "08:00:00", + "saturday_end" => "16:00:00", + "sunday_start" => "08:00:00", + "sunday_end" => "16:00:00", + "created_by" => $this->currentName + ); + + OfficeHours::create($dataCreate); + + return true; + } + + public function delete($id) + { + $data = Project::find($id); + + if (!$data) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + $this->deleteRelative($id); + + if (!$data->delete()) + return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500); + + return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200); + } + + private function deleteRelative($project_id) + { + UserToProyek::where('proyek_id', $project_id)->delete(); + UserToActivity::where('proyek_id', $project_id)->delete(); + AssignMaterial::where('proyek_id', $project_id)->delete(); + ProjectCharter::where('proyek_id', $project_id)->delete(); + ProjectApproval::where('proyek_id', $project_id)->delete(); + ProjectMileStone::where('proyek_id', $project_id)->delete(); + ProjectParticipants::where('proyek_id', $project_id)->delete(); + $this->deleteVersionGantt($project_id); + $this->deleteDokumenProject($project_id); + } + + private function deleteVersionGantt($project_id) + { + $dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id"); + $vhIds = $dataVg->all(); + $activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id'); + $activityIds = $activity->all(); + $dataRa = ReportActivity::whereIn("activity_id", $activityIds)->get(); + foreach ($dataRa as $ra) { + $images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get(); + foreach ($images as $image) { + if (file_exists($this->pathImage . $image->image)) { + unlink($this->pathImage . $image->image); + } + } + Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete(); + } + $dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get(); + foreach ($dataAd as $ad) { + if (file_exists($this->pathActivityDocument . $ad->file)) { + unlink($this->pathActivityDocument . $ad->file); + } + } + ActivityDokumen::whereIn("activity_id", $activityIds)->delete(); + CommentActivity::whereIn("activity_id", $activityIds)->delete(); + Holiday::where("proyek_id", $project_id)->delete(); + VersionGantt::where("proyek_id", $project_id)->delete(); + Link::whereIn("version_gantt_id", $vhIds)->delete(); + ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete(); + Activity::whereIn("version_gantt_id", $vhIds)->delete(); + ReportActivity::whereIn("activity_id", $activityIds)->delete(); + } + + private function deleteDokumenProject($project_id) + { + $dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); + + foreach ($dataDokumen as $dokumen) { + if (file_exists($this->pathDocument . $dokumen->file)) { + unlink($this->pathDocument . $dokumen->file); + } + } + DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete(); + + $dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id"); + $ref_ids = $dataFolder->all(); + $dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); + foreach ($dataDokumen as $dokumen) { + if (file_exists($this->pathDocument . $dokumen->file)) { + unlink($this->pathDocument . $dokumen->file); + } + } + + 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(); + + $dataBuilder = $this->setUpPayload($payload, 'm_proyek'); + $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 = Project::orderBy('id', 'desc')->get(); + $countData = $data->count(); + + if (!$data) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + $scheduleWarningThreshold = 10; + $scheduleDangerThreshold = 5; + foreach ($data as $d) { + $progress = $costVariance = $actualCost = 0; + $lastActivity = null; + $scheduleHealth = "on-track"; + $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $d->id)->orderBy('version_gantt_id', 'desc')->first(); + if ($rootActivity) { + $costVariance = (int)$d->rencana_biaya - (int)$rootActivity->biaya_actual; + $actualCost = $rootActivity->biaya_actual ?? 0; + $progress = $rootActivity->persentase_progress ?? 0; + + $timeleft = strtotime($d->mulai_proyek) - strtotime($rootActivity->end_date); + $date1 = new \DateTime(date("Y-m-d", strtotime($d->mulai_proyek))); + $date2 = new \DateTime(date("Y-m-d", strtotime($rootActivity->end_date))); + $daysRemaining = $date2->diff($date1); + $daysRemaining = $daysRemaining->d; + + if ($daysRemaining <= $scheduleDangerThreshold) { + $scheduleHealth = "danger"; + } elseif ($daysRemaining <= $scheduleWarningThreshold) { + $scheduleHealth = "warning"; + } + $lastActivity = date("d/m/Y", strtotime($rootActivity->end_date)); + } + $d->plannedInterval = date("d/m/Y", strtotime($d->mulai_proyek)) . " - " . date("d/m/Y", strtotime($d->akhir_proyek)); + $d->plannedCost = $d->rencana_biaya; + $d->actualCost = $actualCost; + $d->lastActivity = $lastActivity ?? "-"; + $d->costVariance = $costVariance; + $d->costHealth = $d->budget_health; + $d->scheduleHealth = $scheduleHealth; + $d->progress = $progress; + $d->lastGanttId = VersionGantt::where("proyek_id", $d->id)->orderBy('id', 'desc')->first()->id ?? null; + $d->manpower = UserToProyek::where("proyek_id", $d->id)->count() ?? 0; $d->projectManager = DB::table('m_proyek') - ->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') - ->where('m_proyek.id', $d->id) - ->pluck('m_users.name') - ->first(); - if($d->area_kerja != ''){ + ->join('m_users', 'm_users.id', '=', 'm_proyek.pm_id') + ->where('m_proyek.id', $d->id) + ->pluck('m_users.name') + ->first(); + if ($d->area_kerja != '') { $d->geolocation = $this->httpReq($d->area_kerja); - $d->geolocation = []; + $d->geolocation = []; } else { $d->geolocation = []; } @@ -274,268 +289,304 @@ class ProjectController extends Controller $totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost'))); $totalActualCost = $data->sum('actualCost'); - $manpowers = User::count(); - $projectsOnDanger = Project::where('budget_health', 'overrun')->count(); + $manpowers = User::count(); + $projectsOnDanger = Project::where('budget_health', 'overrun')->count(); $projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); $projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); try { $projectsByPhase = DB::table('m_proyek') - ->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) - ->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') - ->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') - ->get(); + ->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) + ->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') + ->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') + ->get(); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()]); } try { $projectsByType = DB::table('m_proyek') - ->select('m_type_proyek.name', DB::raw('count(*) as total')) - ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') - ->groupBy('m_type_proyek.name') - ->get(); + ->select('m_type_proyek.name', DB::raw('count(*) as total')) + ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') + ->groupBy('m_type_proyek.name') + ->get(); } catch (\Exception $e) { return response()->json(['message' => $e->getMessage()]); } - return response()->json( - [ - 'status'=>'success', - 'code'=>200, - 'data'=>$data, - 'totalRecord'=>$countData, - 'totalPlannedCost' => $totalPlannedCost, - 'totalActualCost' => $totalActualCost, - 'totalRevenue' => $totalPlannedCost - $totalActualCost, - 'manpowers' => $manpowers, - 'projectsOnDanger'=> $projectsOnDanger, - 'projectPhases' => $projectPhases, - 'projectsByPhase' => $projectsByPhase, - 'projectTypes' => $projectTypes, - 'projectsByType' => $projectsByType, - ], 200); - } - - 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') - ->groupBy("m_proyek.proyek_id") - ->get(); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); - - return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); - } - - public function getSCurve(Request $request){ - $data = MasterFunctionsHelper::getSCurve($request); - return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); - } - - 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){ - Artisan::call('calculate:scurve', [ - 'project_id' => $request->project_id - ]); - } - - public function getLinearSCurve(Request $request){ - $data = MasterFunctionsHelper::getLinearSCurve($request); - return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); - } - - public function synchronizeReport($gantt_id) - { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - $reports = []; - - foreach($activities as $activity) { - $activity_id = $activity->id; - $countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); - if ($countReports === 1) { - $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); - foreach($dataReports as $dr) { - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$dr->report_date, - 'max_date'=>date_modify(date_create($dr->report_date), "1 days") - ); - } - } - if ($countReports > 1) { - $firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); - $lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); - $reports[] = array( - 'activity_id'=>$activity_id, - 'min_date'=>$firstReport->report_date, - 'max_date'=>date_modify(date_create($lastReport->report_date), "1 days") - ); - } - $activity->reports = $reports; - } - /* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ - /* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ - - for ($i=0; $i < count($reports); $i++) { - $activity = Activity::find($reports[$i]['activity_id']); - $activity->start_date = $reports[$i]['min_date']; - $activity->end_date = $reports[$i]['max_date']; - $activity->save(); - } - - return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); - } - - public function setBaseline($gantt_id) - { - $activities = Activity::where("version_gantt_id", $gantt_id)->get(); - - foreach ($activities as $activity) { - $activity->update([ - "planned_start"=>$activity->start_date, - "planned_end"=>$activity->end_date, - ]); - } - - return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); - } - - public function getInvoiceIntegration(Request $request) { - // $search = urlencode($request->search); - // if(empty($search)) - // return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); - // $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); - - $response = null; - - // return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); - return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200); - } - - public function detail($id){ - if(empty($id) || !is_int((int)$id)) - return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); - - $result = Project::find($id); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); - - $gantt = MasterFunctionsHelper::getLatestGantt($id); - $result->projectManager = User::where('id', $result->pm_id)->value('name'); - $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); - return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$gantt], 200); - } - - 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); - - $result = Project::find($payload['id']); - - if(!$result) - return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); - //TODO possible overdue bug - if(isset($payload['till_date'])) - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); - else - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); - - $result->overdueActivities = $overdueActivities; - - return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); - } - - 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') - ->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') - ->join('m_users as u', 'u.id', '=', 'ram.user_id') - ->where('ama.proyek_id', '=', $payload['project_id']) - ->whereNotNull('ram.lat') - ->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); - - return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); - } - - public function getManpower($proyek_id){ - $manCount = UserToProyek::where('proyek_id', $proyek_id)->count(); - return response()->json(['totalRecord'=>$manCount]); - } - - 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) - ->get(); - return response()->json(['data'=>$results]); - } - - 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') - ->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') - ->where('mp.id', $id) - ->first(); - - if(!$data) - return response()->json(['status'=>'failed','message'=>'Data tidak ditemukan!','code'=> 404], 404); - - $manpowers = UserToProyek::where('proyek_id', $id)->count(); - $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); - - $actualCost = @$rootActivity->biaya_actual ?? 0; - $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') - ->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') - ->where('ma.proyek_id', $id) - ->orderBy('comment_by') - ->take(2) - ->get(); - - $data->actual_cost = $actualCost; - $data->progress = $progress; - $data->comment = $commentActivity; - $data->man_power = $manpowers; - - return response()->json(['status'=>'success','code'=>200,'data'=> $data], 200); - } - - private function httpReq($search){ - $ch = curl_init(); + return response()->json( + [ + 'status' => 'success', + 'code' => 200, + 'data' => $data, + 'totalRecord' => $countData, + 'totalPlannedCost' => $totalPlannedCost, + 'totalActualCost' => $totalActualCost, + 'totalRevenue' => $totalPlannedCost - $totalActualCost, + 'manpowers' => $manpowers, + 'projectsOnDanger' => $projectsOnDanger, + 'projectPhases' => $projectPhases, + 'projectsByPhase' => $projectsByPhase, + 'projectTypes' => $projectTypes, + 'projectsByType' => $projectsByType, + ], + 200 + ); + } + + 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') + ->groupBy("m_proyek.proyek_id") + ->get(); + + if (!$data) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); + } + + public function getSCurve(Request $request) + { + $data = MasterFunctionsHelper::getSCurve($request); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); + } + + 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) + { + Artisan::call('calculate:scurve', [ + 'project_id' => $request->project_id + ]); + } + + public function getLinearSCurve(Request $request) + { + $data = MasterFunctionsHelper::getLinearSCurve($request); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); + } + + public function synchronizeReport($gantt_id) + { + $activities = Activity::where("version_gantt_id", $gantt_id)->get(); + $reports = []; + + foreach ($activities as $activity) { + $activity_id = $activity->id; + $countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); + if ($countReports === 1) { + $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); + foreach ($dataReports as $dr) { + $reports[] = array( + 'activity_id' => $activity_id, + 'min_date' => $dr->report_date, + 'max_date' => date_modify(date_create($dr->report_date), "1 days") + ); + } + } + if ($countReports > 1) { + $firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); + $lastReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderByDesc('report_date')->first(); + $reports[] = array( + 'activity_id' => $activity_id, + 'min_date' => $firstReport->report_date, + 'max_date' => date_modify(date_create($lastReport->report_date), "1 days") + ); + } + $activity->reports = $reports; + } + /* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ + /* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ + + for ($i = 0; $i < count($reports); $i++) { + $activity = Activity::find($reports[$i]['activity_id']); + $activity->start_date = $reports[$i]['min_date']; + $activity->end_date = $reports[$i]['max_date']; + $activity->save(); + } + + return response()->json(['status' => 'success', 'message' => 'Synchronize to report success!', 'code' => 200], 200); + } + + public function setBaseline($gantt_id) + { + $activities = Activity::where("version_gantt_id", $gantt_id)->get(); + + foreach ($activities as $activity) { + $activity->update([ + "planned_start" => $activity->start_date, + "planned_end" => $activity->end_date, + ]); + } + + return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200); + } + + public function getInvoiceIntegration(Request $request) + { + // $search = urlencode($request->search); + // if(empty($search)) + // return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); + // $url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); + + $response = null; + + // return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); + return response()->json(['status' => 'success', 'data' => '', 'code' => 200], 200); + } + + public function detail($id) + { + if (empty($id) || !is_int((int)$id)) + return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); + + $result = Project::find($id); + + if (!$result) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + $gantt = MasterFunctionsHelper::getLatestGantt($id); + $result->projectManager = User::where('id', $result->pm_id)->value('name'); + $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $gantt['last_gantt_id'])->first(); + return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $gantt], 200); + } + + 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); + + $result = Project::find($payload['id']); + + if (!$result) + return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404); + //TODO possible overdue bug + if (isset($payload['till_date'])) + $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $payload['till_date'])->orderBy('end_date', 'asc')->get(); + else + $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); + + $result->overdueActivities = $overdueActivities; + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); + } + + 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' + ) + ->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') + ->join('m_users as u', 'u.id', '=', 'ram.user_id') + ->where('ama.proyek_id', '=', $payload['project_id']) + ->whereNotNull('ram.lat') + ->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200); + } + + public function getManpower($proyek_id) + { + $manCount = UserToProyek::where('proyek_id', $proyek_id)->count(); + return response()->json(['totalRecord' => $manCount]); + } + + 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) + ->get(); + return response()->json(['data' => $results]); + } + + 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' + ) + ->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') + ->where('mp.id', $id) + ->first(); + + if (!$data) + return response()->json(['status' => 'failed', 'message' => 'Data tidak ditemukan!', 'code' => 404], 404); + + $manpowers = UserToProyek::where('proyek_id', $id)->count(); + $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); + + $actualCost = @$rootActivity->biaya_actual ?? 0; + $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' + ) + ->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') + ->where('ma.proyek_id', $id) + ->orderBy('comment_by') + ->take(2) + ->get(); + + $data->actual_cost = $actualCost; + $data->progress = $progress; + $data->comment = $commentActivity; + $data->man_power = $manpowers; + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); + } + + private function httpReq($search) + { + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_VERBOSE, true); - curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); + curl_setopt($ch, CURLOPT_VERBOSE, true); + curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); - $info = curl_getinfo($ch); + $info = curl_getinfo($ch); $output = curl_exec($ch); curl_close($ch); return json_decode($output); - } - + } } - diff --git a/app/Models/UserToProyek.php b/app/Models/UserToProyek.php index eb80c9b..ef83af1 100644 --- a/app/Models/UserToProyek.php +++ b/app/Models/UserToProyek.php @@ -1,19 +1,19 @@ -get('/', function () use ($router) { - return $router->app->version(); + return $router->app->version(); }); -$router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($router) { - $router->post('/login', 'AuthController@login'); - - $router->post('/menu/add', 'MenuController@add'); - $router->get('/menu/edit/{id}', 'MenuController@edit'); - $router->put('/menu/update/{id}', 'MenuController@update'); - $router->delete('/menu/delete/{id}', 'MenuController@delete'); - $router->post('/menu/search', 'MenuController@search'); - $router->get('/menu/management/{id}', 'MenuController@listMenu'); - $router->get('/menu/list', 'MenuController@list'); - $router->post('/role-menu/add', 'RoleMenuController@add'); - $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); - $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); - $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); - $router->post('/role-menu/search', 'RoleMenuController@search'); - $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); - - $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { - - $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in - $router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); - $router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); - $router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); - $router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); - $router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase'); - $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); - $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); - $router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); - - $router->post('/role/search', 'RoleController@search'); - $router->post('/role/add', 'RoleController@add'); - $router->get('/role/edit/{id}', 'RoleController@edit'); - $router->put('/role/update/{id}', 'RoleController@update'); - $router->delete('/role/delete/{id}', 'RoleController@delete'); - $router->get('/role/list', 'RoleController@list'); - - $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); - $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); - $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); - $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); - $router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen'); - - $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); - $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); - $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); - $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); - $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); - - $router->post('/project/search', 'ProjectController@search'); - $router->post('/project/add', 'ProjectController@add'); - $router->put('/project/update/{id}', 'ProjectController@update'); - $router->get('/project/edit/{id}', 'ProjectController@edit'); - $router->get('/project/detail/{id}', 'ProjectController@detail'); - $router->delete('/project/delete/{id}', 'ProjectController@delete'); - $router->get('/project/list', 'ProjectController@list'); - $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); - $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); - $router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower'); - $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); - - $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); - $router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve'); - $router->post('/project/s-curve-command', 'ProjectController@sCurveCommand'); - $router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve'); - $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); - $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); - $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); - - /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ - /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ - /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ - /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ - - - $router->post('/project-charter/search', 'ProjectCharterController@search'); - $router->post('/project-charter/add', 'ProjectCharterController@add'); - $router->put('/project-charter/update/{id}', 'ProjectCharterController@update'); - - $router->post('/divisi/add', 'DivisiController@add'); - $router->get('/divisi/edit/{id}', 'DivisiController@edit'); - $router->put('/divisi/update/{id}', 'DivisiController@update'); - $router->post('/divisi/search', 'DivisiController@search'); - $router->delete('/divisi/delete/{id}', 'DivisiController@delete'); - $router->get('/divisi/list', 'DivisiController@list'); - - $router->post('/config-alert/search', 'ConfigAlertController@search'); - $router->post('/config-alert/add', 'ConfigAlertController@add'); - $router->get('/config-alert/edit/{id}', 'ConfigAlertController@edit'); - $router->put('/config-alert/update/{id}', 'ConfigAlertController@update'); - $router->delete('/config-alert/delete/{id}', 'ConfigAlertController@delete'); - $router->get('/config-alert/list', 'ConfigAlertController@list'); - - $router->post('/config-alert-to-user/search', 'ConfigAlertUserController@search'); - $router->post('/config-alert-to-user/add', 'ConfigAlertUserController@add'); - $router->put('/config-alert-to-user/update/{id}', 'ConfigAlertUserController@update'); - $router->delete('/config-alert-to-user/delete/{id}', 'ConfigAlertUserController@delete'); - $router->get('/config-alert/get-user/{id}', 'ConfigAlertUserController@getConfigUser'); - - $router->post('/human-resource/search', 'HumanResourceController@search'); - $router->post('/human-resource/add', 'HumanResourceController@add'); - $router->get('/human-resource/edit/{id}', 'HumanResourceController@edit'); - $router->put('/human-resource/update/{id}', 'HumanResourceController@update'); - $router->delete('/human-resource/delete/{id}', 'HumanResourceController@delete'); - $router->get('/human-resource/list', 'HumanResourceController@list'); - $router->get('/human-resource/select', 'HumanResourceController@select'); - $router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword'); - $router->get('/human-resource/sync', 'HumanResourceController@sync'); - - $router->post('/project-role/search', 'ProjectRoleController@search'); - $router->post('/project-role/add', 'ProjectRoleController@add'); - $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); - $router->put('/project-role/update/{id}', 'ProjectRoleController@update'); - $router->delete('/project-role/delete/{id}', 'ProjectRoleController@delete'); - $router->get('/project-role/list', 'ProjectRoleController@list'); - $router->get('/project-role/select', 'ProjectRoleController@select'); - - $router->post('/project-type/search', 'ProjectTypeController@search'); - $router->post('/project-type/add', 'ProjectTypeController@add'); - $router->get('/project-type/edit/{id}', 'ProjectTypeController@edit'); - $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); - $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); - $router->get('/project-type/list', 'ProjectTypeController@list'); - - $router->post('/project-phase/search', 'ProjectPhaseController@search'); - $router->post('/project-phase/add', 'ProjectPhaseController@add'); - $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); - $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); - $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); - $router->get('/project-phase/list', 'ProjectPhaseController@list'); - - $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); - - $router->post('/request-material/add', 'RequestMaterialController@add'); - $router->post('/request-material/search', 'RequestMaterialController@search'); - $router->get('/request-material/edit/{id}', 'RequestMaterialController@edit'); - $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); - $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); - $router->get('/request-material/list', 'RequestMaterialController@list'); - $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); - - $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); - - $router->post('/material-to-project/assign', 'MaterialProjectController@assignMaterial'); - - $router->post('/material-resource/add', 'MaterialResourceController@add'); - $router->post('/material-resource/search', 'MaterialResourceController@search'); - $router->get('/material-resource/update/{id}', 'MaterialResourceController@edit'); - $router->put('/material-resource/update/{id}', 'MaterialResourceController@update'); - $router->delete('/material-resource/delete/{id}', 'MaterialResourceController@delete'); - $router->get('/material-resource/list', 'MaterialResourceController@list'); - $router->get('/material-resource/select', 'MaterialResourceController@select'); - - $router->post('/tools-to-project/assign', 'ToolsProjectController@assignTools'); - $router->get('/tools-to-project/search', 'ToolsProjectController@searchTools'); - - $router->post('/tools-resource/add', 'ToolsResourceController@add'); - $router->post('/tools-resource/search', 'ToolsResourceController@search'); - $router->get('/tools-resource/edit/{id}', 'ToolsResourceController@edit'); - $router->put('/tools-resource/update/{id}', 'ToolsResourceController@update'); - $router->delete('/tools-resource/delete/{id}', 'ToolsResourceController@delete'); - $router->get('/tools-resource/list', 'ToolsResourceController@list'); - $router->get('/tools-resource/select', 'ToolsResourceController@select'); - - $router->post('/req-tools/add', 'ToolsRequestController@add'); - $router->get('/req-tools/edit/{id}', 'ToolsRequestController@edit'); - $router->put('/req-tools/update/{id}', 'ToolsRequestController@update'); - $router->post('/req-tools/search', 'ToolsRequestController@search'); - $router->delete('/req-tools/delete/{id}', 'ToolsRequestController@delete'); - $router->get('/req-tools/list', 'ToolsRequestController@list'); - - $router->post('/version-gantt/add', 'VersionGanttController@add'); - $router->get('/version-gantt/edit/{id}', 'VersionGanttController@edit'); - $router->put('/version-gantt/update/{id}', 'VersionGanttController@update'); - $router->post('/version-gantt/search', 'VersionGanttController@search'); - $router->delete('/version-gantt/delete/{id}', 'VersionGanttController@delete'); - $router->get('/version-gantt/list', 'VersionGanttController@list'); - - $router->post('/user-to-version-gantt/add', 'UserToVersionGanttController@add'); - $router->post('/user-to-version-gantt/add-multiple', 'UserToVersionGanttController@addMultiple'); - $router->get('/user-to-version-gantt/edit/{id}', 'UserToVersionGanttController@edit'); - $router->put('/user-to-version-gantt/update/{id}', 'UserToVersionGanttController@update'); - $router->post('/user-to-version-gantt/search', 'UserToVersionGanttController@search'); - $router->delete('/user-to-version-gantt/delete/{id}', 'UserToVersionGanttController@delete'); - $router->get('/user-to-version-gantt/list', 'UserToVersionGanttController@list'); - $router->get('/user-to-version-gantt/get-by-gantt/{gantt_id}', 'UserToVersionGanttController@getByUserGantt'); - - $router->post('/user-to-activity/add', 'UserToActivityController@add'); - $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); - $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); - $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); - $router->post('/user-to-activity/search', 'UserToActivityController@search'); - $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); - $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); - $router->get('/user-to-activity/list', 'UserToActivityController@list'); - $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables'); - - $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); - $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); - $router->get('/activity/search', 'ActivityController@search'); - $router->post('/activity/import', 'ActivityController@import'); - $router->post('/activity/import-update', 'ActivityController@importUpdate'); - $router->post('/activity/import-old', 'ActivityController@importOld'); - $router->post('/task', 'ActivityController@add'); - $router->get('/task/edit/{id}', 'ActivityController@edit'); - $router->put('/task/{id}', 'ActivityController@update'); - $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); - $router->delete('/task/{id}', 'ActivityController@delete'); - $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); - $router->post('/tmp-import/upload', 'ActivityController@uploadTmpImport'); - - $router->post('/link', 'LinkController@add'); - $router->put('/link/{id}', 'LinkController@update'); - $router->delete('/link/{id}', 'LinkController@delete'); - - $router->post('/template-gantt/add', 'TemplateGanttController@add'); - $router->get('/template-gantt/edit/{id}', 'TemplateGanttController@edit'); - $router->put('/template-gantt/update/{id}', 'TemplateGanttController@update'); - $router->post('/template-gantt/search', 'TemplateGanttController@search'); - $router->delete('/template-gantt/delete/{id}', 'TemplateGanttController@delete'); - $router->get('/template-gantt/list', 'TemplateGanttController@list'); - $router->get('/template-gantt/get-tree/{id}', 'TemplateGanttController@getTreeByTypeProject'); - - $router->post('/comment-activity/add', 'CommentActivityController@add'); - $router->get('/comment-activity/edit/{id}', 'CommentActivityController@edit'); - $router->put('/comment-activity/update/{id}', 'CommentActivityController@update'); - $router->post('/comment-activity/search', 'CommentActivityController@search'); - $router->delete('/comment-activity/delete/{id}', 'CommentActivityController@delete'); - $router->get('/comment-activity/list', 'CommentActivityController@list'); - - $router->post('/presence/add', 'PresenceController@add'); - $router->get('/presence/edit/{id}', 'PresenceController@edit'); - $router->put('/presence/update/{id}', 'PresenceController@update'); - $router->post('/presence/search', 'PresenceController@search'); - $router->delete('/presence/delete/{id}', 'PresenceController@delete'); - $router->get('/presence/list', 'PresenceController@list'); - $router->get('/presence/clockinout/{id}', 'PresenceController@clockinout'); - $router->post('/presence/reportk3', 'PresenceController@reportK3'); - $router->get('/presence/bulk-update-location', 'PresenceController@bulkUpdateLocation'); - - $router->post('/permit/add', 'AbsentController@add'); - $router->get('/permit/edit/{id}', 'AbsentController@edit'); - $router->put('/permit/update/{id}', 'AbsentController@update'); - $router->post('/permit/search', 'AbsentController@search'); - $router->delete('/permit/delete/{id}', 'AbsentController@delete'); - $router->get('/permit/list', 'AbsentController@list'); - - $router->post('/assign-tools/add', 'AssignToolsController@add'); - $router->get('/assign-tools/edit/{id}', 'AssignToolsController@edit'); - $router->put('/assign-tools/update/{id}', 'AssignToolsController@update'); - $router->post('/assign-tools/search', 'AssignToolsController@search'); - $router->delete('/assign-tools/delete/{id}', 'AssignToolsController@delete'); - $router->get('/assign-tools/list', 'AssignToolsController@list'); - $router->get('/assign-tools/datatables', 'AssignToolsController@datatables'); - - $router->post('/assign-material/add', 'AssignMaterialController@add'); - $router->get('/assign-material/edit/{id}', 'AssignMaterialController@edit'); - $router->put('/assign-material/update/{id}', 'AssignMaterialController@update'); - $router->post('/assign-material/search', 'AssignMaterialController@search'); - $router->delete('/assign-material/delete/{id}', 'AssignMaterialController@delete'); - $router->get('/assign-material/list', 'AssignMaterialController@list'); - $router->get('/assign-material/datatables', 'AssignMaterialController@datatables'); - $router->get('/assign-material/datatablesForReportActivity', 'AssignMaterialController@datatablesForReportActivity'); - $router->post('/assign-material/ForReportActivityByMaterial', 'AssignMaterialController@ForReportActivityByMaterial'); - - $router->post('/image/search', 'ImageController@search'); - $router->delete('/image/delete/{id}', 'ImageController@delete'); - $router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef'); - $router->post('/image/upload', 'ImageController@uploadImage'); - $router->get('/image/{id}/{category}', 'ImageController@getByRefId'); - - $router->post('/panic-button/add', 'PanicButtonController@add'); - $router->get('/panic-button/edit/{id}', 'PanicButtonController@edit'); - $router->put('/panic-button/update/{id}', 'PanicButtonController@update'); - $router->post('/panic-button/search', 'PanicButtonController@search'); - $router->delete('/panic-button/delete/{id}', 'PanicButtonController@delete'); - $router->get('/panic-button/list', 'PanicButtonController@list'); - - $router->post('/rate-sallary/add', 'RateSallaryController@add'); - $router->get('/rate-sallary/edit/{id}', 'RateSallaryController@edit'); - $router->put('/rate-sallary/update/{id}', 'RateSallaryController@update'); - $router->post('/rate-sallary/search', 'RateSallaryController@search'); - $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); - $router->get('/rate-sallary/list', 'RateSallaryController@list'); - - $router->post('/project-participants/add', 'ProjectParticipantsController@add'); - $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); - $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); - $router->post('/project-participants/search', 'ProjectParticipantsController@search'); - $router->delete('/project-participants/delete/{id}', 'ProjectParticipantsController@delete'); - $router->delete('/project-participants/delete-by-proyek/{id}', 'ProjectParticipantsController@deleteByProyek'); - $router->get('/project-participants/list', 'ProjectParticipantsController@list'); - $router->get('/project-participants/{where}/{val}', 'ProjectParticipantsController@customWhere'); - - $router->post('/project-approval/add', 'ProjectApprovalController@add'); - $router->get('/project-approval/edit/{id}', 'ProjectApprovalController@edit'); - $router->put('/project-approval/update/{id}', 'ProjectApprovalController@update'); - $router->post('/project-approval/search', 'ProjectApprovalController@search'); - $router->delete('/project-approval/delete/{id}', 'ProjectApprovalController@delete'); - $router->delete('/project-approval/delete-by-proyek/{id}', 'ProjectApprovalController@deleteByProyek'); - $router->get('/project-approval/list', 'ProjectApprovalController@list'); - $router->get('/project-approval/{where}/{val}', 'ProjectApprovalController@customWhere'); - - $router->post('/project-milestone/add', 'ProjectMileStoneController@add'); - $router->get('/project-milestone/edit/{id}', 'ProjectMileStoneController@edit'); - $router->put('/project-milestone/update/{id}', 'ProjectMileStoneController@update'); - $router->post('/project-milestone/search', 'ProjectMileStoneController@search'); - $router->delete('/project-milestone/delete/{id}', 'ProjectMileStoneController@delete'); - $router->delete('/project-milestone/delete-by-proyek/{id}', 'ProjectMileStoneController@deleteByProyek'); - $router->get('/project-milestone/list', 'ProjectMileStoneController@list'); - $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); - $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); - - $router->post('/report-activity/add', 'ReportActivityController@add'); - $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); - $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); - $router->post('/report-activity/search', 'ReportActivityController@search'); - $router->delete('/report-activity/delete/{id}', 'ReportActivityController@delete'); - $router->get('/report-activity/list', 'ReportActivityController@list'); - $router->post('/report-activity/search-point', 'ReportActivityController@searchPoint'); - $router->get('/report-activity/datatables', 'ReportActivityController@datatables'); - - $router->post('/report-activity-material/add', 'ReportActivityMaterialController@add'); - $router->post('/report-activity-material/search', 'ReportActivityMaterialController@search'); - $router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete'); - $router->get('/report-activity-material/list', 'ReportActivityMaterialController@list'); - $router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables'); - $router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish'); - - $router->post('/waypoint/add', 'WaypointController@add'); - $router->post('/waypoint/add-bulk', 'WaypointController@addBulk'); - $router->get('/waypoint/edit/{id}', 'WaypointController@edit'); - $router->put('/waypoint/update/{id}', 'WaypointController@update'); - $router->post('/waypoint/search', 'WaypointController@search'); - $router->delete('/waypoint/delete/{id}', 'WaypointController@delete'); - $router->get('/waypoint/list', 'WaypointController@list'); - - $router->post('/holiday/add', 'HolidayController@add'); - $router->get('/holiday/edit/{id}', 'HolidayController@edit'); - $router->put('/holiday/update/{id}', 'HolidayController@update'); - $router->post('/holiday/search', 'HolidayController@search'); - $router->delete('/holiday/delete/{id}', 'HolidayController@delete'); - $router->get('/holiday/list', 'HolidayController@list'); - $router->get('/holiday/datatables', 'HolidayController@datatables'); - - $router->post('/satuan/add', 'SatuanController@add'); - $router->get('/satuan/edit/{id}', 'SatuanController@edit'); - $router->put('/satuan/update/{id}', 'SatuanController@update'); - $router->post('/satuan/search', 'SatuanController@search'); - $router->delete('/satuan/delete/{id}', 'SatuanController@delete'); - $router->get('/satuan/list', 'SatuanController@list'); - - $router->post('/checklist-k3/add', 'ChecklistK3Controller@add'); - $router->get('/checklist-k3/edit/{id}', 'ChecklistK3Controller@edit'); - $router->put('/checklist-k3/update/{id}', 'ChecklistK3Controller@update'); - $router->post('/checklist-k3/search', 'ChecklistK3Controller@search'); - $router->delete('/checklist-k3/delete/{id}', 'ChecklistK3Controller@delete'); - $router->get('/checklist-k3/list', 'ChecklistK3Controller@list'); - - $router->post('/report-k3/add', 'ReportK3Controller@add'); - $router->get('/report-k3/edit/{id}', 'ReportK3Controller@edit'); - $router->put('/report-k3/update/{id}', 'ReportK3Controller@update'); - $router->post('/report-k3/search', 'ReportK3Controller@search'); - $router->delete('/report-k3/delete/{id}', 'ReportK3Controller@delete'); - $router->get('/report-k3/list', 'ReportK3Controller@list'); - - $router->post('/report-k3-detail/add', 'ReportK3DetailController@add'); - $router->get('/report-k3-detail/edit/{id}', 'ReportK3DetailController@edit'); - $router->put('/report-k3-detail/update/{id}', 'ReportK3DetailController@update'); - $router->post('/report-k3-detail/search', 'ReportK3DetailController@search'); - $router->delete('/report-k3-detail/delete/{id}', 'ReportK3DetailController@delete'); - $router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); - - $router->post('/user-to-proyek/add', 'UserToProyekController@add'); - $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); - $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); - $router->post('/user-to-proyek/search', 'UserToProyekController@search'); - $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); - $router->get('/user-to-proyek/list', 'UserToProyekController@list'); - $router->get('/user-to-proyek/select', 'UserToProyekController@select'); - $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); - - $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); - $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); - $router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update'); - $router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search'); - $router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete'); - $router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list'); - $router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree'); - - $router->post('/office-hours/add', 'OfficeHoursController@add'); - $router->get('/office-hours/edit/{id}', 'OfficeHoursController@edit'); - $router->put('/office-hours/update/{id}', 'OfficeHoursController@update'); - $router->post('/office-hours/search', 'OfficeHoursController@search'); - $router->delete('/office-hours/delete/{id}', 'OfficeHoursController@delete'); - $router->get('/office-hours/list', 'OfficeHoursController@list'); - - $router->get('/gantt-show-hide/get-by-gantt/{gantt_id}', 'ShowHideColumnController@getByUserGantt'); - $router->post('/gantt-show-hide/add', 'ShowHideColumnController@add'); - $router->post('/gantt-show-hide/update/{gantt_id}', 'ShowHideColumnController@update'); - $router->get('/gantt-show-hide/get-column-by-type/{type}', 'ShowHideColumnController@getColumnByType'); - - - $router->post('/shift/add', 'ShiftController@add'); - $router->get('/shift/edit/{id}', 'ShiftController@edit'); - $router->put('/shift/update/{id}', 'ShiftController@update'); - $router->post('/shift/search', 'ShiftController@search'); - $router->delete('/shift/delete/{id}', 'ShiftController@delete'); - $router->get('/shift/list', 'ShiftController@list'); - - $router->post('/user-monthly-shift/add', 'UserMonthlyShiftController@add'); - $router->put('/user-monthly-shift/update/{id}', 'UserMonthlyShiftController@update'); - $router->post('/user-monthly-shift/search', 'UserMonthlyShiftController@search'); - $router->delete('/user-monthly-shift/delete/{id}', 'UserMonthlyShiftController@delete'); - $router->delete('/user-monthly-shift/delete-at/{yyyymm}', 'UserMonthlyShiftController@deleteYYYYMM'); - $router->get('/user-monthly-shift/list', 'UserMonthlyShiftController@list'); - $router->post('/user-monthly-shift/import', 'UserMonthlyShiftController@import'); - $router->get('/user-monthly-shift/list/{yyyymm}', 'UserMonthlyShiftController@listYYYYMM'); - - $router->post('/user-to-shift/add', 'UserToShiftController@add'); - $router->get('/user-to-shift/edit/{id}', 'UserToShiftController@edit'); - $router->put('/user-to-shift/update/{id}', 'UserToShiftController@update'); - $router->post('/user-to-shift/search', 'UserToShiftController@search'); - $router->delete('/user-to-shift/delete/{id}', 'UserToShiftController@delete'); - $router->get('/user-to-shift/list', 'UserToShiftController@list'); - - $router->post('/control-monitoring/search', 'ControlMonitoringController@search'); - $router->get('/currency/list', 'CurrencyController@list'); - - $router->post('/project-to-checklist-k3/add', 'ProjectToChecklistK3Controller@add'); - $router->post('/project-to-checklist-k3/add-multiple', 'ProjectToChecklistK3Controller@addMultiple'); - $router->get('/project-to-checklist-k3/edit/{id}', 'ProjectToChecklistK3Controller@edit'); - $router->put('/project-to-checklist-k3/update/{id}', 'ProjectToChecklistK3Controller@update'); - $router->post('/project-to-checklist-k3/search', 'ProjectToChecklistK3Controller@search'); - $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); - $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); - - $router->post('/project-comment/add', 'ProjectCommentController@add'); - $router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); - $router->post('/project-comment/search', 'ProjectCommentController@search'); - - $router->get('/hierarchy-ftths', 'HierarchyFtthController@index'); - $router->post('/hierarchy-ftths', 'HierarchyFtthController@store'); - $router->post('/hierarchy-ftths/search', 'HierarchyFtthController@search'); - $router->get('/hierarchy-ftths/{id}', 'HierarchyFtthController@show'); - $router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update'); - $router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy'); - $router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject'); - $router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt'); - - $router->post('/map-monitoring/search', 'MapMonitoringController@search'); - }); - +$router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($router) { + $router->post('/login', 'AuthController@login'); + + $router->post('/menu/add', 'MenuController@add'); + $router->get('/menu/edit/{id}', 'MenuController@edit'); + $router->put('/menu/update/{id}', 'MenuController@update'); + $router->delete('/menu/delete/{id}', 'MenuController@delete'); + $router->post('/menu/search', 'MenuController@search'); + $router->get('/menu/management/{id}', 'MenuController@listMenu'); + $router->get('/menu/list', 'MenuController@list'); + $router->post('/role-menu/add', 'RoleMenuController@add'); + $router->put('/role-menu/update/{id}', 'RoleMenuController@update'); + $router->delete('/role-menu/delete/{id}', 'RoleMenuController@delete'); + $router->delete('/role-menu/delete-byrole/{id}', 'RoleMenuController@deleteByRole'); + $router->post('/role-menu/search', 'RoleMenuController@search'); + $router->get('/role-menu/get-role/{id}', 'RoleMenuController@listMenu'); + + $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { + + $router->get('/dashboard/get-company-cashflow[/{year}]', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure + $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-total-project-per-schedule-health[/{year}]', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); + $router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); + $router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); + $router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); + $router->get('/dashboard/get-total-project-per-phase[/{year}]', 'DashboardBoDController@getTotalProjectPerPhase'); + $router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); + $router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); + $router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); + + $router->post('/role/search', 'RoleController@search'); + $router->post('/role/add', 'RoleController@add'); + $router->get('/role/edit/{id}', 'RoleController@edit'); + $router->put('/role/update/{id}', 'RoleController@update'); + $router->delete('/role/delete/{id}', 'RoleController@delete'); + $router->get('/role/list', 'RoleController@list'); + + $router->post('/document-project/upload', 'ProjectDokumenController@uploadProjectDokumen'); + $router->get('/document-project/get/{id}', 'ProjectDokumenController@dokumenByProyekId'); + $router->delete('/document-project/delete/{id}', 'ProjectDokumenController@delete'); + $router->post('/document-project/search', 'ProjectDokumenController@searchDocProject'); + $router->get('/document-project/download/{id}', 'ProjectDokumenController@downloadDokumen'); + + $router->post('/document-activity/upload', 'ActivityDokumenController@uploadProjectDokumen'); + $router->get('/document-activity/get/{id}', 'ActivityDokumenController@dokumenByActivityId'); + $router->delete('/document-activity/delete/{id}', 'ActivityDokumenController@delete'); + $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'); + $router->get('/project/edit/{id}', 'ProjectController@edit'); + $router->get('/project/detail/{id}', 'ProjectController@detail'); + $router->delete('/project/delete/{id}', 'ProjectController@delete'); + $router->get('/project/list', 'ProjectController@list'); + $router->get('/project/set-baseline/{gantt_id}', 'ProjectController@setBaseline'); + $router->get('/project/synchronize-report/{gantt_id}', 'ProjectController@synchronizeReport'); + $router->get('/project/manpower/{proyek_id}', 'ProjectController@getManpower'); + $router->get('/project/manpower/assigned/{gantt_id}', 'ProjectController@getAssignedHR'); + + $router->post('/project/get-s-curve', 'ProjectController@getSCurve'); + $router->post('/project/calculate-s-curve', 'ProjectController@calculateSCurve'); + $router->post('/project/s-curve-command', 'ProjectController@sCurveCommand'); + $router->post('/project/get-linear-s-curve', 'ProjectController@getLinearSCurve'); + $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); + $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); + $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); + + /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ + /* $router->get('/project/get-total-expenditure/{id}', 'ProjectController@getTotalExpenditure'); */ + /* $router->get('/project/get-status-health-schedule/{id}', 'ProjectController@getStatusSchedule'); */ + /* $router->get('/project/get-status-health-budget/{id}', 'ProjectController@getStatusBudget'); */ + + + $router->post('/project-charter/search', 'ProjectCharterController@search'); + $router->post('/project-charter/add', 'ProjectCharterController@add'); + $router->put('/project-charter/update/{id}', 'ProjectCharterController@update'); + + $router->post('/divisi/add', 'DivisiController@add'); + $router->get('/divisi/edit/{id}', 'DivisiController@edit'); + $router->put('/divisi/update/{id}', 'DivisiController@update'); + $router->post('/divisi/search', 'DivisiController@search'); + $router->delete('/divisi/delete/{id}', 'DivisiController@delete'); + $router->get('/divisi/list', 'DivisiController@list'); + + $router->post('/config-alert/search', 'ConfigAlertController@search'); + $router->post('/config-alert/add', 'ConfigAlertController@add'); + $router->get('/config-alert/edit/{id}', 'ConfigAlertController@edit'); + $router->put('/config-alert/update/{id}', 'ConfigAlertController@update'); + $router->delete('/config-alert/delete/{id}', 'ConfigAlertController@delete'); + $router->get('/config-alert/list', 'ConfigAlertController@list'); + + $router->post('/config-alert-to-user/search', 'ConfigAlertUserController@search'); + $router->post('/config-alert-to-user/add', 'ConfigAlertUserController@add'); + $router->put('/config-alert-to-user/update/{id}', 'ConfigAlertUserController@update'); + $router->delete('/config-alert-to-user/delete/{id}', 'ConfigAlertUserController@delete'); + $router->get('/config-alert/get-user/{id}', 'ConfigAlertUserController@getConfigUser'); + + $router->post('/human-resource/search', 'HumanResourceController@search'); + $router->post('/human-resource/add', 'HumanResourceController@add'); + $router->get('/human-resource/edit/{id}', 'HumanResourceController@edit'); + $router->put('/human-resource/update/{id}', 'HumanResourceController@update'); + $router->delete('/human-resource/delete/{id}', 'HumanResourceController@delete'); + $router->get('/human-resource/list', 'HumanResourceController@list'); + $router->get('/human-resource/select', 'HumanResourceController@select'); + $router->post('/human-resource/check-old-password/{id}', 'HumanResourceController@checkOldPassword'); + $router->get('/human-resource/sync', 'HumanResourceController@sync'); + + $router->post('/project-role/search', 'ProjectRoleController@search'); + $router->post('/project-role/add', 'ProjectRoleController@add'); + $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); + $router->put('/project-role/update/{id}', 'ProjectRoleController@update'); + $router->delete('/project-role/delete/{id}', 'ProjectRoleController@delete'); + $router->get('/project-role/list', 'ProjectRoleController@list'); + $router->get('/project-role/select', 'ProjectRoleController@select'); + + $router->post('/project-type/search', 'ProjectTypeController@search'); + $router->post('/project-type/add', 'ProjectTypeController@add'); + $router->get('/project-type/edit/{id}', 'ProjectTypeController@edit'); + $router->put('/project-type/update/{id}', 'ProjectTypeController@update'); + $router->delete('/project-type/delete/{id}', 'ProjectTypeController@delete'); + $router->get('/project-type/list', 'ProjectTypeController@list'); + + $router->post('/project-phase/search', 'ProjectPhaseController@search'); + $router->post('/project-phase/add', 'ProjectPhaseController@add'); + $router->get('/project-phase/edit/{id}', 'ProjectPhaseController@edit'); + $router->put('/project-phase/update/{id}', 'ProjectPhaseController@update'); + $router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete'); + $router->get('/project-phase/list', 'ProjectPhaseController@list'); + + $router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek'); + + $router->post('/request-material/add', 'RequestMaterialController@add'); + $router->post('/request-material/search', 'RequestMaterialController@search'); + $router->get('/request-material/edit/{id}', 'RequestMaterialController@edit'); + $router->put('/request-material/update/{id}', 'RequestMaterialController@update'); + $router->delete('/request-material/delete/{id}', 'RequestMaterialController@delete'); + $router->get('/request-material/list', 'RequestMaterialController@list'); + $router->get('/request-material/get-material-integration', 'RequestMaterialController@getMaterialIntegration'); + + $router->put('/request-material/update-warehouse-site/{id}', 'RequestMaterialController@updateWarehouseSite'); + + $router->post('/material-to-project/assign', 'MaterialProjectController@assignMaterial'); + + $router->post('/material-resource/add', 'MaterialResourceController@add'); + $router->post('/material-resource/search', 'MaterialResourceController@search'); + $router->get('/material-resource/update/{id}', 'MaterialResourceController@edit'); + $router->put('/material-resource/update/{id}', 'MaterialResourceController@update'); + $router->delete('/material-resource/delete/{id}', 'MaterialResourceController@delete'); + $router->get('/material-resource/list', 'MaterialResourceController@list'); + $router->get('/material-resource/select', 'MaterialResourceController@select'); + + $router->post('/tools-to-project/assign', 'ToolsProjectController@assignTools'); + $router->get('/tools-to-project/search', 'ToolsProjectController@searchTools'); + + $router->post('/tools-resource/add', 'ToolsResourceController@add'); + $router->post('/tools-resource/search', 'ToolsResourceController@search'); + $router->get('/tools-resource/edit/{id}', 'ToolsResourceController@edit'); + $router->put('/tools-resource/update/{id}', 'ToolsResourceController@update'); + $router->delete('/tools-resource/delete/{id}', 'ToolsResourceController@delete'); + $router->get('/tools-resource/list', 'ToolsResourceController@list'); + $router->get('/tools-resource/select', 'ToolsResourceController@select'); + + $router->post('/req-tools/add', 'ToolsRequestController@add'); + $router->get('/req-tools/edit/{id}', 'ToolsRequestController@edit'); + $router->put('/req-tools/update/{id}', 'ToolsRequestController@update'); + $router->post('/req-tools/search', 'ToolsRequestController@search'); + $router->delete('/req-tools/delete/{id}', 'ToolsRequestController@delete'); + $router->get('/req-tools/list', 'ToolsRequestController@list'); + + $router->post('/version-gantt/add', 'VersionGanttController@add'); + $router->get('/version-gantt/edit/{id}', 'VersionGanttController@edit'); + $router->put('/version-gantt/update/{id}', 'VersionGanttController@update'); + $router->post('/version-gantt/search', 'VersionGanttController@search'); + $router->delete('/version-gantt/delete/{id}', 'VersionGanttController@delete'); + $router->get('/version-gantt/list', 'VersionGanttController@list'); + + $router->post('/user-to-version-gantt/add', 'UserToVersionGanttController@add'); + $router->post('/user-to-version-gantt/add-multiple', 'UserToVersionGanttController@addMultiple'); + $router->get('/user-to-version-gantt/edit/{id}', 'UserToVersionGanttController@edit'); + $router->put('/user-to-version-gantt/update/{id}', 'UserToVersionGanttController@update'); + $router->post('/user-to-version-gantt/search', 'UserToVersionGanttController@search'); + $router->delete('/user-to-version-gantt/delete/{id}', 'UserToVersionGanttController@delete'); + $router->get('/user-to-version-gantt/list', 'UserToVersionGanttController@list'); + $router->get('/user-to-version-gantt/get-by-gantt/{gantt_id}', 'UserToVersionGanttController@getByUserGantt'); + + $router->post('/user-to-activity/add', 'UserToActivityController@add'); + $router->post('/user-to-activity/add-multiple', 'UserToActivityController@addMultiple'); + $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); + $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); + $router->post('/user-to-activity/search', 'UserToActivityController@search'); + $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); + $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete'); + $router->get('/user-to-activity/list', 'UserToActivityController@list'); + $router->get('/user-to-activity/datatables', 'UserToActivityController@datatables'); + + $router->get('/sumVolActualM/{id}', 'ActivityController@sumVolumeActualMaterial'); + $router->get('/activity/{id}/{proyek_id}/get', 'ActivityController@getByGanttId'); + $router->get('/activity/search', 'ActivityController@search'); + $router->post('/activity/import', 'ActivityController@import'); + $router->post('/activity/import-update', 'ActivityController@importUpdate'); + $router->post('/activity/import-old', 'ActivityController@importOld'); + $router->post('/task', 'ActivityController@add'); + $router->get('/task/edit/{id}', 'ActivityController@edit'); + $router->put('/task/{id}', 'ActivityController@update'); + $router->put('/task/update-regular/{id}', 'ActivityController@updateRegular'); + $router->delete('/task/{id}', 'ActivityController@delete'); + $router->get('/task/get-update/{id}', 'ActivityController@getUpdate'); + $router->post('/tmp-import/upload', 'ActivityController@uploadTmpImport'); + + $router->post('/link', 'LinkController@add'); + $router->put('/link/{id}', 'LinkController@update'); + $router->delete('/link/{id}', 'LinkController@delete'); + + $router->post('/template-gantt/add', 'TemplateGanttController@add'); + $router->get('/template-gantt/edit/{id}', 'TemplateGanttController@edit'); + $router->put('/template-gantt/update/{id}', 'TemplateGanttController@update'); + $router->post('/template-gantt/search', 'TemplateGanttController@search'); + $router->delete('/template-gantt/delete/{id}', 'TemplateGanttController@delete'); + $router->get('/template-gantt/list', 'TemplateGanttController@list'); + $router->get('/template-gantt/get-tree/{id}', 'TemplateGanttController@getTreeByTypeProject'); + + $router->post('/comment-activity/add', 'CommentActivityController@add'); + $router->get('/comment-activity/edit/{id}', 'CommentActivityController@edit'); + $router->put('/comment-activity/update/{id}', 'CommentActivityController@update'); + $router->post('/comment-activity/search', 'CommentActivityController@search'); + $router->delete('/comment-activity/delete/{id}', 'CommentActivityController@delete'); + $router->get('/comment-activity/list', 'CommentActivityController@list'); + + $router->post('/presence/add', 'PresenceController@add'); + $router->get('/presence/edit/{id}', 'PresenceController@edit'); + $router->put('/presence/update/{id}', 'PresenceController@update'); + $router->post('/presence/search', 'PresenceController@search'); + $router->delete('/presence/delete/{id}', 'PresenceController@delete'); + $router->get('/presence/list', 'PresenceController@list'); + $router->get('/presence/clockinout/{id}', 'PresenceController@clockinout'); + $router->post('/presence/reportk3', 'PresenceController@reportK3'); + $router->get('/presence/bulk-update-location', 'PresenceController@bulkUpdateLocation'); + + $router->post('/permit/add', 'AbsentController@add'); + $router->get('/permit/edit/{id}', 'AbsentController@edit'); + $router->put('/permit/update/{id}', 'AbsentController@update'); + $router->post('/permit/search', 'AbsentController@search'); + $router->delete('/permit/delete/{id}', 'AbsentController@delete'); + $router->get('/permit/list', 'AbsentController@list'); + + $router->post('/assign-tools/add', 'AssignToolsController@add'); + $router->get('/assign-tools/edit/{id}', 'AssignToolsController@edit'); + $router->put('/assign-tools/update/{id}', 'AssignToolsController@update'); + $router->post('/assign-tools/search', 'AssignToolsController@search'); + $router->delete('/assign-tools/delete/{id}', 'AssignToolsController@delete'); + $router->get('/assign-tools/list', 'AssignToolsController@list'); + $router->get('/assign-tools/datatables', 'AssignToolsController@datatables'); + + $router->post('/assign-material/add', 'AssignMaterialController@add'); + $router->get('/assign-material/edit/{id}', 'AssignMaterialController@edit'); + $router->put('/assign-material/update/{id}', 'AssignMaterialController@update'); + $router->post('/assign-material/search', 'AssignMaterialController@search'); + $router->delete('/assign-material/delete/{id}', 'AssignMaterialController@delete'); + $router->get('/assign-material/list', 'AssignMaterialController@list'); + $router->get('/assign-material/datatables', 'AssignMaterialController@datatables'); + $router->get('/assign-material/datatablesForReportActivity', 'AssignMaterialController@datatablesForReportActivity'); + $router->post('/assign-material/ForReportActivityByMaterial', 'AssignMaterialController@ForReportActivityByMaterial'); + + $router->post('/image/search', 'ImageController@search'); + $router->delete('/image/delete/{id}', 'ImageController@delete'); + $router->delete('/image/delete/{id}/{category}', 'ImageController@deleteByRef'); + $router->post('/image/upload', 'ImageController@uploadImage'); + $router->get('/image/{id}/{category}', 'ImageController@getByRefId'); + + $router->post('/panic-button/add', 'PanicButtonController@add'); + $router->get('/panic-button/edit/{id}', 'PanicButtonController@edit'); + $router->put('/panic-button/update/{id}', 'PanicButtonController@update'); + $router->post('/panic-button/search', 'PanicButtonController@search'); + $router->delete('/panic-button/delete/{id}', 'PanicButtonController@delete'); + $router->get('/panic-button/list', 'PanicButtonController@list'); + + $router->post('/rate-sallary/add', 'RateSallaryController@add'); + $router->get('/rate-sallary/edit/{id}', 'RateSallaryController@edit'); + $router->put('/rate-sallary/update/{id}', 'RateSallaryController@update'); + $router->post('/rate-sallary/search', 'RateSallaryController@search'); + $router->delete('/rate-sallary/delete/{id}', 'RateSallaryController@delete'); + $router->get('/rate-sallary/list', 'RateSallaryController@list'); + + $router->post('/project-participants/add', 'ProjectParticipantsController@add'); + $router->get('/project-participants/edit/{id}', 'ProjectParticipantsController@edit'); + $router->put('/project-participants/update/{id}', 'ProjectParticipantsController@update'); + $router->post('/project-participants/search', 'ProjectParticipantsController@search'); + $router->delete('/project-participants/delete/{id}', 'ProjectParticipantsController@delete'); + $router->delete('/project-participants/delete-by-proyek/{id}', 'ProjectParticipantsController@deleteByProyek'); + $router->get('/project-participants/list', 'ProjectParticipantsController@list'); + $router->get('/project-participants/{where}/{val}', 'ProjectParticipantsController@customWhere'); + + $router->post('/project-approval/add', 'ProjectApprovalController@add'); + $router->get('/project-approval/edit/{id}', 'ProjectApprovalController@edit'); + $router->put('/project-approval/update/{id}', 'ProjectApprovalController@update'); + $router->post('/project-approval/search', 'ProjectApprovalController@search'); + $router->delete('/project-approval/delete/{id}', 'ProjectApprovalController@delete'); + $router->delete('/project-approval/delete-by-proyek/{id}', 'ProjectApprovalController@deleteByProyek'); + $router->get('/project-approval/list', 'ProjectApprovalController@list'); + $router->get('/project-approval/{where}/{val}', 'ProjectApprovalController@customWhere'); + + $router->post('/project-milestone/add', 'ProjectMileStoneController@add'); + $router->get('/project-milestone/edit/{id}', 'ProjectMileStoneController@edit'); + $router->put('/project-milestone/update/{id}', 'ProjectMileStoneController@update'); + $router->post('/project-milestone/search', 'ProjectMileStoneController@search'); + $router->delete('/project-milestone/delete/{id}', 'ProjectMileStoneController@delete'); + $router->delete('/project-milestone/delete-by-proyek/{id}', 'ProjectMileStoneController@deleteByProyek'); + $router->get('/project-milestone/list', 'ProjectMileStoneController@list'); + $router->get('/project-milestone/select', 'ProjectMileStoneController@select'); + $router->get('/project-milestone/{where}/{val}', 'ProjectMileStoneController@customWhere'); + + $router->post('/report-activity/add', 'ReportActivityController@add'); + $router->get('/report-activity/edit/{id}', 'ReportActivityController@edit'); + $router->put('/report-activity/update/{id}', 'ReportActivityController@update'); + $router->post('/report-activity/search', 'ReportActivityController@search'); + $router->delete('/report-activity/delete/{id}', 'ReportActivityController@delete'); + $router->get('/report-activity/list', 'ReportActivityController@list'); + $router->post('/report-activity/search-point', 'ReportActivityController@searchPoint'); + $router->get('/report-activity/datatables', 'ReportActivityController@datatables'); + + $router->post('/report-activity-material/add', 'ReportActivityMaterialController@add'); + $router->post('/report-activity-material/search', 'ReportActivityMaterialController@search'); + $router->delete('/report-activity-material/delete/{id}', 'ReportActivityMaterialController@delete'); + $router->get('/report-activity-material/list', 'ReportActivityMaterialController@list'); + $router->get('/report-activity-material/datatables', 'ReportActivityMaterialController@datatables'); + $router->post('/report-activity-material/update-status', 'ReportActivityMaterialController@updateStatusStartFinish'); + + $router->post('/waypoint/add', 'WaypointController@add'); + $router->post('/waypoint/add-bulk', 'WaypointController@addBulk'); + $router->get('/waypoint/edit/{id}', 'WaypointController@edit'); + $router->put('/waypoint/update/{id}', 'WaypointController@update'); + $router->post('/waypoint/search', 'WaypointController@search'); + $router->delete('/waypoint/delete/{id}', 'WaypointController@delete'); + $router->get('/waypoint/list', 'WaypointController@list'); + + $router->post('/holiday/add', 'HolidayController@add'); + $router->get('/holiday/edit/{id}', 'HolidayController@edit'); + $router->put('/holiday/update/{id}', 'HolidayController@update'); + $router->post('/holiday/search', 'HolidayController@search'); + $router->delete('/holiday/delete/{id}', 'HolidayController@delete'); + $router->get('/holiday/list', 'HolidayController@list'); + $router->get('/holiday/datatables', 'HolidayController@datatables'); + + $router->post('/satuan/add', 'SatuanController@add'); + $router->get('/satuan/edit/{id}', 'SatuanController@edit'); + $router->put('/satuan/update/{id}', 'SatuanController@update'); + $router->post('/satuan/search', 'SatuanController@search'); + $router->delete('/satuan/delete/{id}', 'SatuanController@delete'); + $router->get('/satuan/list', 'SatuanController@list'); + + $router->post('/checklist-k3/add', 'ChecklistK3Controller@add'); + $router->get('/checklist-k3/edit/{id}', 'ChecklistK3Controller@edit'); + $router->put('/checklist-k3/update/{id}', 'ChecklistK3Controller@update'); + $router->post('/checklist-k3/search', 'ChecklistK3Controller@search'); + $router->delete('/checklist-k3/delete/{id}', 'ChecklistK3Controller@delete'); + $router->get('/checklist-k3/list', 'ChecklistK3Controller@list'); + + $router->post('/report-k3/add', 'ReportK3Controller@add'); + $router->get('/report-k3/edit/{id}', 'ReportK3Controller@edit'); + $router->put('/report-k3/update/{id}', 'ReportK3Controller@update'); + $router->post('/report-k3/search', 'ReportK3Controller@search'); + $router->delete('/report-k3/delete/{id}', 'ReportK3Controller@delete'); + $router->get('/report-k3/list', 'ReportK3Controller@list'); + + $router->post('/report-k3-detail/add', 'ReportK3DetailController@add'); + $router->get('/report-k3-detail/edit/{id}', 'ReportK3DetailController@edit'); + $router->put('/report-k3-detail/update/{id}', 'ReportK3DetailController@update'); + $router->post('/report-k3-detail/search', 'ReportK3DetailController@search'); + $router->delete('/report-k3-detail/delete/{id}', 'ReportK3DetailController@delete'); + $router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); + + $router->post('/user-to-proyek/add', 'UserToProyekController@add'); + $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); + $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); + $router->post('/user-to-proyek/search', 'UserToProyekController@search'); + $router->delete('/user-to-proyek/delete/{id}', 'UserToProyekController@delete'); + $router->get('/user-to-proyek/list', 'UserToProyekController@list'); + $router->get('/user-to-proyek/select', 'UserToProyekController@select'); + $router->get('/user-to-proyek/get-employee-integration', 'UserToProyekController@getEmployeeIntegration'); + + $router->post('/folder-document-proyek/add', 'FolderDocumentProyekController@add'); + $router->get('/folder-document-proyek/edit/{id}', 'FolderDocumentProyekController@edit'); + $router->put('/folder-document-proyek/update/{id}', 'FolderDocumentProyekController@update'); + $router->post('/folder-document-proyek/search', 'FolderDocumentProyekController@search'); + $router->delete('/folder-document-proyek/delete/{id}', 'FolderDocumentProyekController@delete'); + $router->get('/folder-document-proyek/list', 'FolderDocumentProyekController@list'); + $router->get('/folder-document-proyek/get-tree/{id}', 'FolderDocumentProyekController@getTree'); + + $router->post('/office-hours/add', 'OfficeHoursController@add'); + $router->get('/office-hours/edit/{id}', 'OfficeHoursController@edit'); + $router->put('/office-hours/update/{id}', 'OfficeHoursController@update'); + $router->post('/office-hours/search', 'OfficeHoursController@search'); + $router->delete('/office-hours/delete/{id}', 'OfficeHoursController@delete'); + $router->get('/office-hours/list', 'OfficeHoursController@list'); + + $router->get('/gantt-show-hide/get-by-gantt/{gantt_id}', 'ShowHideColumnController@getByUserGantt'); + $router->post('/gantt-show-hide/add', 'ShowHideColumnController@add'); + $router->post('/gantt-show-hide/update/{gantt_id}', 'ShowHideColumnController@update'); + $router->get('/gantt-show-hide/get-column-by-type/{type}', 'ShowHideColumnController@getColumnByType'); + + + $router->post('/shift/add', 'ShiftController@add'); + $router->get('/shift/edit/{id}', 'ShiftController@edit'); + $router->put('/shift/update/{id}', 'ShiftController@update'); + $router->post('/shift/search', 'ShiftController@search'); + $router->delete('/shift/delete/{id}', 'ShiftController@delete'); + $router->get('/shift/list', 'ShiftController@list'); + + $router->post('/user-monthly-shift/add', 'UserMonthlyShiftController@add'); + $router->put('/user-monthly-shift/update/{id}', 'UserMonthlyShiftController@update'); + $router->post('/user-monthly-shift/search', 'UserMonthlyShiftController@search'); + $router->delete('/user-monthly-shift/delete/{id}', 'UserMonthlyShiftController@delete'); + $router->delete('/user-monthly-shift/delete-at/{yyyymm}', 'UserMonthlyShiftController@deleteYYYYMM'); + $router->get('/user-monthly-shift/list', 'UserMonthlyShiftController@list'); + $router->post('/user-monthly-shift/import', 'UserMonthlyShiftController@import'); + $router->get('/user-monthly-shift/list/{yyyymm}', 'UserMonthlyShiftController@listYYYYMM'); + + $router->post('/user-to-shift/add', 'UserToShiftController@add'); + $router->get('/user-to-shift/edit/{id}', 'UserToShiftController@edit'); + $router->put('/user-to-shift/update/{id}', 'UserToShiftController@update'); + $router->post('/user-to-shift/search', 'UserToShiftController@search'); + $router->delete('/user-to-shift/delete/{id}', 'UserToShiftController@delete'); + $router->get('/user-to-shift/list', 'UserToShiftController@list'); + + $router->post('/control-monitoring/search', 'ControlMonitoringController@search'); + $router->get('/currency/list', 'CurrencyController@list'); + + $router->post('/project-to-checklist-k3/add', 'ProjectToChecklistK3Controller@add'); + $router->post('/project-to-checklist-k3/add-multiple', 'ProjectToChecklistK3Controller@addMultiple'); + $router->get('/project-to-checklist-k3/edit/{id}', 'ProjectToChecklistK3Controller@edit'); + $router->put('/project-to-checklist-k3/update/{id}', 'ProjectToChecklistK3Controller@update'); + $router->post('/project-to-checklist-k3/search', 'ProjectToChecklistK3Controller@search'); + $router->delete('/project-to-checklist-k3/delete/{id}', 'ProjectToChecklistK3Controller@delete'); + $router->get('/project-to-checklist-k3/list', 'ProjectToChecklistK3Controller@list'); + + $router->post('/project-comment/add', 'ProjectCommentController@add'); + $router->put('/project-comment/update/{id}', 'ProjectCommentController@update'); + $router->post('/project-comment/search', 'ProjectCommentController@search'); + + $router->get('/hierarchy-ftths', 'HierarchyFtthController@index'); + $router->post('/hierarchy-ftths', 'HierarchyFtthController@store'); + $router->post('/hierarchy-ftths/search', 'HierarchyFtthController@search'); + $router->get('/hierarchy-ftths/{id}', 'HierarchyFtthController@show'); + $router->put('/hierarchy-ftths/{id}', 'HierarchyFtthController@update'); + $router->delete('/hierarchy-ftths/{id}', 'HierarchyFtthController@destroy'); + $router->get('/hierarchy-ftths/tree/{project_id}', 'HierarchyFtthController@getTreeByProject'); + $router->get('/hierarchy-ftths/tree-gantt/{gantt_id}', 'HierarchyFtthController@getTreeByGantt'); + + $router->post('/map-monitoring/search', 'MapMonitoringController@search'); + }); }); From 866d7478922073d67a52c7834f7c2c344eb35f7d Mon Sep 17 00:00:00 2001 From: wahyuun Date: Sun, 27 Aug 2023 19:57:50 +0700 Subject: [PATCH 2/8] add endpoint project-by-customer --- app/Http/Controllers/Controller.php | 689 ++++++++++++--------- app/Http/Controllers/ProjectController.php | 20 +- routes/web.php | 2 +- 3 files changed, 393 insertions(+), 318 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index c431f28..90e141a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,306 +1,383 @@ -currentDate = date("Y-m-d H:i:s"); - $this->currentName = auth()->user() ? auth()->user()->name : "system"; - $this->currentId = auth()->user() ? auth()->user()->id : 0; - - $this->pathImage = config('assets.image'); - $this->pathDocument = config('assets.project'); - $this->pathActivityDocument = config('assets.activity'); - } - - protected function setUpPayload($condition, $tableSelf) - { - $alias = "selfTable"; - $builder = DB::table($tableSelf." AS ".$alias); - $builder = $builder->select($alias.".*"); - if($condition){ - if(isset($condition['joins'])){ - $selectColumn = []; - $no = 0; - foreach($condition['joins'] as $join){ - $tableJoin = isset($join['name1']) ? $join['name1'] : $alias; - $tableName = $join['name']; - $columnJoin = $join['column_join']; // foreign key table sini - $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan - $columnResult = $join['column_results']; - - foreach($columnResult as $sColumn){ - $builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); - } - $builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); - $no++; - } - } - - if(isset($condition['columns'])){ - $listWhere = $condition['columns']; - - $builder = $builder->where(function ($query) use($listWhere, $alias){ - foreach($listWhere as $where){ - $value = $where['value']; - if($value && $value!="" && $value!=" "){ - $column = $where['name']; - $operator = strtolower($where['logic_operator']); // like, =, <>, range - $value2 = isset($where['value1']) ? $where['value1'] : ""; - $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - } - } - }); - } - - if(isset($condition['group_column'])){ - $builder = $this->groupWhere($builder, $condition['group_column'], $alias); - } - - $data['count'] = clone $builder; - - if(isset($condition['paging'])){ - $builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); - } - - if(isset($condition['orders'])){ - $orders = $condition['orders']; - $sortBy = $orders['ascending'] ? "ASC" : "DESC"; - $columnOrder = $orders['columns']; - foreach($columnOrder as $column){ - $builder = $builder->orderBy($alias.".".$column, $sortBy); - } - } - } - $data['builder'] = $builder; - return $data; - } - - private function groupWhere($oldBuilder, $groupWhere, $alias) - { - $builder = $oldBuilder; - $listGroupWhere = $groupWhere; - $operator = $listGroupWhere['operator']; - $operatorGroup = $listGroupWhere['group_operator']; - $listWhere = $listGroupWhere['where']; - if(strtolower($operator)=="and"){ - $builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){ - $no = 1; - foreach ($listWhere as $where) { - $value = $where['value']; - $column = $where['name']; - $operator = strtolower($where['logic_operator']); - $value2 = isset($where['value1']) ? $where['value1'] : ""; - $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - if($value && $value!="" && $value!=" "){ - if($operatorGroup=="and"){ - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - if($no==1){ - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); - } - } - } - $no = $no+1; - } - }); - }else if(strtolower($operator)=="or"){ - $builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){ - $no = 1; - foreach ($listWhere as $where) { - $value = $where['value']; - $column = $where['name']; - $operator = strtolower($where['logic_operator']); - $value2 = isset($where['value1']) ? $where['value1'] : ""; - $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - if($value && $value!="" && $value!=" "){ - if($operatorGroup=="and"){ - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - if($no==1){ - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - }else{ - $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); - } - } - } - $no++; - } - }); - } - return $builder; - } - - private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) - { - $query = $oldQuery; - if($operator=="range"){ - $query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ - $query = $query->where($tableColumn.".".$column, '~*', $value); - }else if($operator=="="){ - $query = $query->where($tableColumn.".".$column, $value); - }else if($operator=="in"){ - $query = $query->whereIn($tableColumn.".".$column, $value); - }else if($operator=="notin"){ - $query = $query->whereNotIn($tableColumn.".".$column, $value); - }else{ - $query = $query->where($tableColumn.".".$column, $operator, $value); - } - return $query; - } - - private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){ - $query = $oldQuery; - if($operator=="range"){ - $query = $query->whereBetween($column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->where($column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ - $query = $query->where($column, '~*', $value); - }else if($operator=="="){ - $query = $query->where($column, $value); - }else if($operator=="in"){ - $query = $query->whereIn($column, $value); - }else if($operator=="notin"){ - $query = $query->whereNotIn($column, $value); - }else{ - $query = $query->where($column, $operator, $value); - } - return $query; - } - - private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) - { - $query = $oldQuery; - if($operator=="range"){ - $query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]); - }else if($operator=="like"){ - $query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%'); - }else if($operator=="ilike"){ - $query = $query->where($tableColumn.".".$column, '~*', $value); - }else if($operator=="="){ - $query = $query->orWhere($tableColumn.".".$column, $value); - }else if($operator=="in"){ - $query = $query->orWhereIn($tableColumn.".".$column, $value); - }else if($operator=="notin"){ - $query = $query->orWhereNotIn($tableColumn.".".$column, $value); - }else{ - $query = $query->orWhere($tableColumn.".".$column, $operator, $value); - } - return $query; - } - - protected function calculateAllCost($activity_id, $proyek_id){ - $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); - $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); - $toolsCostPlanning = 0; - - $allCost = $humanCostPlanning + $materialCostPlanning + $toolsCostPlanning; - return $allCost; - } - - private function calculateAllHumanCost($activity_id, $proyek_id) - { - $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") - ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") - ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) - ->where("ahp.proyek_id", $proyek_id) - ->get(); - - $totalCost = 0; - foreach ($dataHuman as $human) { - $totalCost += $this->calculateHumanCost($human, $activity_id); - } - - return $totalCost; - } - - private function calculateHumanCost($human, $activity_id) - { - $activity = Activity::find($activity_id); - $duration = $activity->duration; - $standarRate = $human->standart_rate; - $maxUsed = $human->max_used/100; - if ($human->uom_standart_rate == "Hour") { - $totalCost = ($standarRate*8*$duration)*$maxUsed; - return $totalCost; - } - $totalCost = ($standarRate*$duration)*$maxUsed; - return $totalCost; - } - - private function calculateMaterialCost($activity_id, $proyek_id) - { - $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") - ->where("proyek_id", $proyek_id) - ->where("activity_id", $activity_id) - ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); - return $totalCost; - } - - protected function getLoc($lat, $lng){ - // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); - // return $response->json; - - $url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"; - // $token = config('api.adw_token'); - $response = $this->curlRequest($url); - return $response; - } - - private function curlRequest($url){ - $ch = curl_init(); - // $headers = [ - // 'Authorization: '.$token - // ]; - curl_setopt($ch, CURLOPT_URL, $url); - // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - - $response = curl_exec($ch); - if ($response === false) - $response = curl_error($ch); - curl_close($ch); - - return json_decode($response); - } - - protected function addDetailK3($dataDetail, $report_id){ - foreach ($dataDetail as $value) { - $dataNew = array( - "report_k3_id"=>$report_id, - "checklist_k3_id"=>$value['checklist_id'], - "name_checklist_k3"=>$value['checklist_name'], - "created_by"=>$this->currentName - ); - - ReportK3Detail::create($dataNew); - } - } -} +currentDate = date("Y-m-d H:i:s"); + $this->currentName = auth()->user() ? auth()->user()->name : "system"; + $this->currentId = auth()->user() ? auth()->user()->id : 0; + + $this->pathImage = config('assets.image'); + $this->pathDocument = config('assets.project'); + $this->pathActivityDocument = config('assets.activity'); + } + + protected function setUpPayloadByUser($condition) + { + $alias = "utp"; + + $userProyek = UserToProyek::from('assign_hr_to_proyek AS ' . $alias); + $userProyek = $userProyek->where([ + ['is_customer', true], + // $condition['user_id']['user_id'] + ['user_id', 1561] + ])->select('m_proyek.*', 'm_type_proyek.name AS nama_type_proyek'); + + if (isset($condition['joins'])) { + $no = 0; + foreach ($condition['joins'] as $join) { + $tableJoin = isset($join['name1']) ? $join['name1'] : $alias; + $tableName = $join['name']; + $columnJoin = $join['column_join']; // foreign key table sini + $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan + $columnResult = $join['column_results']; + + foreach ($columnResult as $sColumn) { + $userProyek = $userProyek->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn); + } + $userProyek = $userProyek->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf); + $no++; + } + $userProyek->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id'); + } + + if (isset($condition['columns'])) { + $listWhere = $condition['columns']; + + $userProyek = $userProyek->where(function ($query) use ($listWhere, $alias) { + foreach ($listWhere as $where) { + $value = $where['value']; + if ($value && $value != "" && $value != " ") { + $column = $where['name']; + $operator = strtolower($where['logic_operator']); // like, =, <>, range + $value2 = isset($where['value1']) ? $where['value1'] : ""; + $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } + } + }); + } + + if (isset($condition['group_column'])) { + $userProyek = $this->groupWhere($userProyek, $condition['group_column'], $alias); + } + + $data['count'] = clone $userProyek; + + if (isset($condition['paging'])) { + $userProyek = $userProyek->offset($condition['paging']['start'])->limit($condition['paging']['length']); + } + + if (isset($condition['orders'])) { + $orders = $condition['orders']; + $sortBy = $orders['ascending'] ? "ASC" : "DESC"; + $columnOrder = $orders['columns']; + foreach ($columnOrder as $column) { + $userProyek = $userProyek->orderBy($alias . "." . $column, $sortBy); + } + } + $data['userProyek'] = $userProyek; + return $data; + } + + protected function setUpPayload($condition, $tableSelf) + { + $alias = "selfTable"; + $builder = DB::table($tableSelf . " AS " . $alias); + $builder = $builder->select($alias . ".*"); + if ($condition) { + if (isset($condition['joins'])) { + $selectColumn = []; + $no = 0; + foreach ($condition['joins'] as $join) { + $tableJoin = isset($join['name1']) ? $join['name1'] : $alias; + $tableName = $join['name']; + $columnJoin = $join['column_join']; // foreign key table sini + $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan + $columnResult = $join['column_results']; + + foreach ($columnResult as $sColumn) { + $builder = $builder->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn); + } + $builder = $builder->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf); + $no++; + } + } + + if (isset($condition['columns'])) { + $listWhere = $condition['columns']; + + $builder = $builder->where(function ($query) use ($listWhere, $alias) { + foreach ($listWhere as $where) { + $value = $where['value']; + if ($value && $value != "" && $value != " ") { + $column = $where['name']; + $operator = strtolower($where['logic_operator']); // like, =, <>, range + $value2 = isset($where['value1']) ? $where['value1'] : ""; + $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } + } + }); + } + + if (isset($condition['group_column'])) { + $builder = $this->groupWhere($builder, $condition['group_column'], $alias); + } + + $data['count'] = clone $builder; + + if (isset($condition['paging'])) { + $builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); + } + + if (isset($condition['orders'])) { + $orders = $condition['orders']; + $sortBy = $orders['ascending'] ? "ASC" : "DESC"; + $columnOrder = $orders['columns']; + foreach ($columnOrder as $column) { + $builder = $builder->orderBy($alias . "." . $column, $sortBy); + } + } + } + $data['builder'] = $builder; + return $data; + } + + private function groupWhere($oldBuilder, $groupWhere, $alias) + { + $builder = $oldBuilder; + $listGroupWhere = $groupWhere; + $operator = $listGroupWhere['operator']; + $operatorGroup = $listGroupWhere['group_operator']; + $listWhere = $listGroupWhere['where']; + if (strtolower($operator) == "and") { + $builder = $builder->where(function ($query) use ($operatorGroup, $listWhere, $alias) { + $no = 1; + foreach ($listWhere as $where) { + $value = $where['value']; + $column = $where['name']; + $operator = strtolower($where['logic_operator']); + $value2 = isset($where['value1']) ? $where['value1'] : ""; + $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; + if ($value && $value != "" && $value != " ") { + if ($operatorGroup == "and") { + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } else { + if ($no == 1) { + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } else { + $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } + } + } + $no = $no + 1; + } + }); + } else if (strtolower($operator) == "or") { + $builder = $builder->orWhere(function ($query) use ($operatorGroup, $listWhere, $alias) { + $no = 1; + foreach ($listWhere as $where) { + $value = $where['value']; + $column = $where['name']; + $operator = strtolower($where['logic_operator']); + $value2 = isset($where['value1']) ? $where['value1'] : ""; + $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; + if ($value && $value != "" && $value != " ") { + if ($operatorGroup == "and") { + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } else { + if ($no == 1) { + $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } else { + $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); + } + } + } + $no++; + } + }); + } + return $builder; + } + + private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) + { + $query = $oldQuery; + if ($operator == "range") { + $query = $query->whereBetween($tableColumn . "." . $column, [$value, $value2]); + } else if ($operator == "like") { + $query = $query->where($tableColumn . "." . $column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { + $query = $query->where($tableColumn . "." . $column, '~*', $value); + } else if ($operator == "=") { + $query = $query->where($tableColumn . "." . $column, $value); + } else if ($operator == "in") { + $query = $query->whereIn($tableColumn . "." . $column, $value); + } else if ($operator == "notin") { + $query = $query->whereNotIn($tableColumn . "." . $column, $value); + } else { + $query = $query->where($tableColumn . "." . $column, $operator, $value); + } + return $query; + } + + private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2) + { + $query = $oldQuery; + if ($operator == "range") { + $query = $query->whereBetween($column, [$value, $value2]); + } else if ($operator == "like") { + $query = $query->where($column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { + $query = $query->where($column, '~*', $value); + } else if ($operator == "=") { + $query = $query->where($column, $value); + } else if ($operator == "in") { + $query = $query->whereIn($column, $value); + } else if ($operator == "notin") { + $query = $query->whereNotIn($column, $value); + } else { + $query = $query->where($column, $operator, $value); + } + return $query; + } + + private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) + { + $query = $oldQuery; + if ($operator == "range") { + $query = $query->orWhereBetween($tableColumn . "." . $column, [$value, $value2]); + } else if ($operator == "like") { + $query = $query->orWhere($tableColumn . "." . $column, 'like', '%' . $value . '%'); + } else if ($operator == "ilike") { + $query = $query->where($tableColumn . "." . $column, '~*', $value); + } else if ($operator == "=") { + $query = $query->orWhere($tableColumn . "." . $column, $value); + } else if ($operator == "in") { + $query = $query->orWhereIn($tableColumn . "." . $column, $value); + } else if ($operator == "notin") { + $query = $query->orWhereNotIn($tableColumn . "." . $column, $value); + } else { + $query = $query->orWhere($tableColumn . "." . $column, $operator, $value); + } + return $query; + } + + protected function calculateAllCost($activity_id, $proyek_id) + { + $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); + $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); + $toolsCostPlanning = 0; + + $allCost = $humanCostPlanning + $materialCostPlanning + $toolsCostPlanning; + return $allCost; + } + + private function calculateAllHumanCost($activity_id, $proyek_id) + { + $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate", "ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") + ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") + ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) + ->where("ahp.proyek_id", $proyek_id) + ->get(); + + $totalCost = 0; + foreach ($dataHuman as $human) { + $totalCost += $this->calculateHumanCost($human, $activity_id); + } + + return $totalCost; + } + + private function calculateHumanCost($human, $activity_id) + { + $activity = Activity::find($activity_id); + $duration = $activity->duration; + $standarRate = $human->standart_rate; + $maxUsed = $human->max_used / 100; + if ($human->uom_standart_rate == "Hour") { + $totalCost = ($standarRate * 8 * $duration) * $maxUsed; + return $totalCost; + } + $totalCost = ($standarRate * $duration) * $maxUsed; + return $totalCost; + } + + private function calculateMaterialCost($activity_id, $proyek_id) + { + $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") + ->where("proyek_id", $proyek_id) + ->where("activity_id", $activity_id) + ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); + return $totalCost; + } + + protected function getLoc($lat, $lng) + { + // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); + // return $response->json; + + $url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json"; + // $token = config('api.adw_token'); + $response = $this->curlRequest($url); + return $response; + } + + private function curlRequest($url) + { + $ch = curl_init(); + // $headers = [ + // 'Authorization: '.$token + // ]; + curl_setopt($ch, CURLOPT_URL, $url); + // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + if ($response === false) + $response = curl_error($ch); + curl_close($ch); + + return json_decode($response); + } + + protected function addDetailK3($dataDetail, $report_id) + { + foreach ($dataDetail as $value) { + $dataNew = array( + "report_k3_id" => $report_id, + "checklist_k3_id" => $value['checklist_id'], + "name_checklist_k3" => $value['checklist_name'], + "created_by" => $this->currentName + ); + + ReportK3Detail::create($dataNew); + } + } +} diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index e558e78..7117d65 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -204,18 +204,16 @@ class ProjectController extends Controller DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); } - public function getByUser($id) + public function getByUser(Request $request) { - $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); - } + $payload = $request->all(); + $dataBuilder = $this->setUpPayloadByUser($payload); + $builder = $dataBuilder['userProyek']; + $countBuilder = $dataBuilder['count']; + $dataGet = $builder->get(); + $totalRecord = $countBuilder->count(); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); } public function search(Request $request) diff --git a/routes/web.php b/routes/web.php index a35676c..47ed601 100644 --- a/routes/web.php +++ b/routes/web.php @@ -53,7 +53,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $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-by-customer', 'ProjectController@getByUser'); $router->post('/project/search', 'ProjectController@search'); $router->post('/project/add', 'ProjectController@add'); $router->put('/project/update/{id}', 'ProjectController@update'); From d383f5c1d847a5738e27b0f65fd0824b4121e350 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 28 Aug 2023 18:13:41 +0700 Subject: [PATCH 3/8] update method endpoint --- app/Http/Controllers/Controller.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 90e141a..c131d43 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -44,9 +44,8 @@ class Controller extends BaseController $userProyek = UserToProyek::from('assign_hr_to_proyek AS ' . $alias); $userProyek = $userProyek->where([ ['is_customer', true], - // $condition['user_id']['user_id'] - ['user_id', 1561] - ])->select('m_proyek.*', 'm_type_proyek.name AS nama_type_proyek'); + ['user_id', $condition['user_id']['user_id']] + ])->select('m_proyek.*', 'm_type_proyek.name AS join_second_name'); if (isset($condition['joins'])) { $no = 0; From 9fb9744dd5cf564af7c69f3458953995ec5d3e63 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 29 Aug 2023 10:34:43 +0700 Subject: [PATCH 4/8] update bcwp --- app/Helpers/MasterFunctionsHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 6d75174..5c9764f 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -428,7 +428,7 @@ class MasterFunctionsHelper } $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; - $totalBCWP = $lastReal * $totalBCWP; + $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $dataResponse = array( "date" => $tempDate, "percentage" => $tempPercentage, @@ -723,7 +723,7 @@ class MasterFunctionsHelper } $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; - $totalBCWP = $lastReal * $totalBCWP; + $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $dataResponse = array( "date" => $tempDate, "percentage" => $tempPercentage, From ff353fbf53707f58dffd1a6f642849c9dcbcd416 Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 29 Aug 2023 14:08:50 +0700 Subject: [PATCH 5/8] scurve queue --- app/Http/Controllers/ProjectController.php | 13 +++++-- app/Jobs/ProcessSCurve.php | 36 +++++++++++++++++++ .../2023_08_29_130624_create_jobs_table.php | 36 +++++++++++++++++++ 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 app/Jobs/ProcessSCurve.php create mode 100644 database/migrations/2023_08_29_130624_create_jobs_table.php diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 3a204d7..7478494 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -30,6 +30,7 @@ use Illuminate\Support\Facades\DB; use App\Helpers\MasterFunctionsHelper; use App\Models\ReportActivityMaterial; use Illuminate\Support\Facades\Artisan; +use App\Jobs\ProcessSCurve; const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; @@ -328,9 +329,15 @@ class ProjectController extends Controller } public function sCurveCommand(Request $request){ - Artisan::call('calculate:scurve', [ - 'project_id' => $request->project_id - ]); + $project = Project::find($request->project_id); + + if ($project) { + dispatch(new ProcessSCurve($project)); + + return response()->json(['message' => 'S Curve calculation queued']); + } + + return response()->json(['message' => 'Project not found'], 404); } public function getLinearSCurve(Request $request){ diff --git a/app/Jobs/ProcessSCurve.php b/app/Jobs/ProcessSCurve.php new file mode 100644 index 0000000..fe07ab9 --- /dev/null +++ b/app/Jobs/ProcessSCurve.php @@ -0,0 +1,36 @@ +project = $project; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + $data = MasterFunctionsHelper::CalculateSCurve($this->project->id); + + $this->project->scurve = json_encode($data); + $this->project->calculation_status = true; + $this->project->save(); + } +} diff --git a/database/migrations/2023_08_29_130624_create_jobs_table.php b/database/migrations/2023_08_29_130624_create_jobs_table.php new file mode 100644 index 0000000..1be9e8a --- /dev/null +++ b/database/migrations/2023_08_29_130624_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +} From 427449bb26f4d468c8e119be35b8c7f722f5171c Mon Sep 17 00:00:00 2001 From: wahyu Date: Tue, 29 Aug 2023 14:55:32 +0700 Subject: [PATCH 6/8] disable queue --- app/Http/Controllers/ProjectController.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 7478494..48cb86e 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -329,15 +329,18 @@ class ProjectController extends Controller } public function sCurveCommand(Request $request){ - $project = Project::find($request->project_id); + Artisan::call('calculate:scurve', [ + 'project_id' => $request->project_id + ]); + // $project = Project::find($request->project_id); - if ($project) { - dispatch(new ProcessSCurve($project)); + // if ($project) { + // dispatch(new ProcessSCurve($project)); - return response()->json(['message' => 'S Curve calculation queued']); - } + // return response()->json(['message' => 'S Curve calculation queued']); + // } - return response()->json(['message' => 'Project not found'], 404); + // return response()->json(['message' => 'Project not found'], 404); } public function getLinearSCurve(Request $request){ From bf63d4ac3b0e746b9e1d08533f596f6f1ed49d6c Mon Sep 17 00:00:00 2001 From: wahyu Date: Wed, 30 Aug 2023 10:19:04 +0700 Subject: [PATCH 7/8] fix broadcast --- app/Http/Controllers/BroadcastController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/BroadcastController.php b/app/Http/Controllers/BroadcastController.php index 5bb223e..87eb02d 100644 --- a/app/Http/Controllers/BroadcastController.php +++ b/app/Http/Controllers/BroadcastController.php @@ -15,6 +15,12 @@ class BroadcastController extends Controller $data = $request->all(); $data['status_send'] = true; $data['created_by'] = $this->currentName; + if (isset($data['send_to_id'])) { + $idArray = $data['send_to_id']; + if (is_array($data['send_to_id'])) { + $data['send_to_id'] = implode(", ", $idArray); + } + } // dd($data); $result = Broadcast::create($data); if($result){ @@ -140,8 +146,10 @@ class BroadcastController extends Controller } break; - case 'user': - $user = User::where("id", $data['send_to_id'])->whereNotNull('fcm_token')->first(); + case 'users': + $idArray = explode(", ", $data['send_to_id']); + foreach ($idArray as $key => $value) { + $user = User::where("id", $value)->whereNotNull('fcm_token')->first(); if (isset($user)) { FCMService::send( $user->fcm_token, @@ -151,6 +159,7 @@ class BroadcastController extends Controller ] ); } + } break; default: From ab5fd49d37698ee06c16efc51a128866482b3a3e Mon Sep 17 00:00:00 2001 From: wahyuun Date: Wed, 30 Aug 2023 10:22:41 +0700 Subject: [PATCH 8/8] update post to get method --- app/Http/Controllers/Controller.php | 67 ---------------------- app/Http/Controllers/ProjectController.php | 25 +++++--- routes/web.php | 2 +- 3 files changed, 17 insertions(+), 77 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index c131d43..a77975b 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -37,73 +37,6 @@ class Controller extends BaseController $this->pathActivityDocument = config('assets.activity'); } - protected function setUpPayloadByUser($condition) - { - $alias = "utp"; - - $userProyek = UserToProyek::from('assign_hr_to_proyek AS ' . $alias); - $userProyek = $userProyek->where([ - ['is_customer', true], - ['user_id', $condition['user_id']['user_id']] - ])->select('m_proyek.*', 'm_type_proyek.name AS join_second_name'); - - if (isset($condition['joins'])) { - $no = 0; - foreach ($condition['joins'] as $join) { - $tableJoin = isset($join['name1']) ? $join['name1'] : $alias; - $tableName = $join['name']; - $columnJoin = $join['column_join']; // foreign key table sini - $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan - $columnResult = $join['column_results']; - - foreach ($columnResult as $sColumn) { - $userProyek = $userProyek->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn); - } - $userProyek = $userProyek->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf); - $no++; - } - $userProyek->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id'); - } - - if (isset($condition['columns'])) { - $listWhere = $condition['columns']; - - $userProyek = $userProyek->where(function ($query) use ($listWhere, $alias) { - foreach ($listWhere as $where) { - $value = $where['value']; - if ($value && $value != "" && $value != " ") { - $column = $where['name']; - $operator = strtolower($where['logic_operator']); // like, =, <>, range - $value2 = isset($where['value1']) ? $where['value1'] : ""; - $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; - $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); - } - } - }); - } - - if (isset($condition['group_column'])) { - $userProyek = $this->groupWhere($userProyek, $condition['group_column'], $alias); - } - - $data['count'] = clone $userProyek; - - if (isset($condition['paging'])) { - $userProyek = $userProyek->offset($condition['paging']['start'])->limit($condition['paging']['length']); - } - - if (isset($condition['orders'])) { - $orders = $condition['orders']; - $sortBy = $orders['ascending'] ? "ASC" : "DESC"; - $columnOrder = $orders['columns']; - foreach ($columnOrder as $column) { - $userProyek = $userProyek->orderBy($alias . "." . $column, $sortBy); - } - } - $data['userProyek'] = $userProyek; - return $data; - } - protected function setUpPayload($condition, $tableSelf) { $alias = "selfTable"; diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 7117d65..553a5dd 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -204,16 +204,23 @@ class ProjectController extends Controller DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); } - public function getByUser(Request $request) + public function getByUser($id) { - $payload = $request->all(); - $dataBuilder = $this->setUpPayloadByUser($payload); - $builder = $dataBuilder['userProyek']; - $countBuilder = $dataBuilder['count']; - $dataGet = $builder->get(); - $totalRecord = $countBuilder->count(); - - return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); + $alias = "utp"; + $userProyek = UserToProyek::query() + ->from('assign_hr_to_proyek AS ' . $alias) + ->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(); + $totalRecord = $userProyek->count(); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); } public function search(Request $request) diff --git a/routes/web.php b/routes/web.php index 47ed601..254d963 100644 --- a/routes/web.php +++ b/routes/web.php @@ -53,7 +53,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); - $router->post('/project-by-customer', 'ProjectController@getByUser'); + $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');