|
|
@ -3,46 +3,16 @@ |
|
|
|
namespace App\Http\Controllers; |
|
|
|
namespace App\Http\Controllers; |
|
|
|
|
|
|
|
|
|
|
|
use DateTime; |
|
|
|
use DateTime; |
|
|
|
use App\Models\Link; |
|
|
|
|
|
|
|
use App\Models\User; |
|
|
|
|
|
|
|
use App\Models\Image; |
|
|
|
|
|
|
|
use App\Models\Company; |
|
|
|
|
|
|
|
use App\Models\Holiday; |
|
|
|
|
|
|
|
use App\Models\Project; |
|
|
|
|
|
|
|
use App\Models\Activity; |
|
|
|
|
|
|
|
use App\Models\ReportK3; |
|
|
|
|
|
|
|
use App\Jobs\ProcessSCurve; |
|
|
|
use App\Jobs\ProcessSCurve; |
|
|
|
use App\Models\AssignTools; |
|
|
|
|
|
|
|
use App\Models\OfficeHours; |
|
|
|
|
|
|
|
use App\Models\ProjectType; |
|
|
|
|
|
|
|
use App\Models\ProjectPhase; |
|
|
|
|
|
|
|
use App\Models\ProjectRisks; |
|
|
|
|
|
|
|
use App\Models\UserToProyek; |
|
|
|
|
|
|
|
use App\Models\VersionGantt; |
|
|
|
|
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use App\Models\HierarchyFtth; |
|
|
|
use App\Models\{ReportActivityMaterial,ProjectToChecklistK3,FolderDocumentProyek,ProjectParticipants,ProductTransaction,ProjectChecklists, |
|
|
|
use App\Models\ProjectIssues; |
|
|
|
ProjectMileStone,RequestMaterial,ProjectApproval,CommentActivity,ActivityDokumen,UserToActivity,ShowHideColumn,ReportActivity,ProjectCharter,DokumenProject, |
|
|
|
use App\Models\AssignMaterial; |
|
|
|
AssignMaterial,ProjectIssues,HierarchyFtth,VersionGantt,UserToProyek,ProjectRisks,ProjectPhase,ProjectType,OfficeHours,AssignTools,ReportK3,Activity,Project, |
|
|
|
use App\Models\DokumenProject; |
|
|
|
Holiday,Company,Image,User,Link |
|
|
|
use App\Models\ProjectCharter; |
|
|
|
}; |
|
|
|
use App\Models\ReportActivity; |
|
|
|
|
|
|
|
use App\Models\ShowHideColumn; |
|
|
|
|
|
|
|
use App\Models\UserToActivity; |
|
|
|
|
|
|
|
use App\Models\ActivityDokumen; |
|
|
|
|
|
|
|
use App\Models\CommentActivity; |
|
|
|
|
|
|
|
use App\Models\ProjectApproval; |
|
|
|
|
|
|
|
use App\Models\RequestMaterial; |
|
|
|
|
|
|
|
use App\Models\ProjectMileStone; |
|
|
|
|
|
|
|
use App\Models\ProjectChecklists; |
|
|
|
|
|
|
|
use App\Models\ProductTransaction; |
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
|
|
|
use App\Models\ProjectParticipants; |
|
|
|
|
|
|
|
use App\Models\FolderDocumentProyek; |
|
|
|
|
|
|
|
use App\Models\ProjectToChecklistK3; |
|
|
|
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
|
|
|
use App\Models\ReportActivityMaterial; |
|
|
|
|
|
|
|
use Illuminate\Database\Query\Builder; |
|
|
|
use Illuminate\Database\Query\Builder; |
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
|
|
use Illuminate\Support\Facades\{Artisan,DB}; |
|
|
|
|
|
|
|
use App\Helpers\MasterFunctionsHelper; |
|
|
|
|
|
|
|
|
|
|
|
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; |
|
|
|
const API_GEOLOCATION = "https://nominatim.oslogdev.com/search/ADDR?format=json&addressdetails=1&limit=1"; |
|
|
|
|
|
|
|
|
|
|
@ -60,16 +30,15 @@ class ProjectController extends Controller |
|
|
|
'type_proyek_id' => 'required', |
|
|
|
'type_proyek_id' => 'required', |
|
|
|
'company_id' => 'required' |
|
|
|
'company_id' => 'required' |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$data = $request->all(); |
|
|
|
$data = $request->all(); |
|
|
|
|
|
|
|
|
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by'] = $this->currentName; |
|
|
|
$data['created_by_id'] = $this->currentId; |
|
|
|
$data['created_by_id'] = $this->currentId; |
|
|
|
|
|
|
|
|
|
|
|
if (empty($data['phase_id'])) { |
|
|
|
if (empty($data['phase_id'])) { |
|
|
|
$data['phase_id'] = 1; |
|
|
|
$data['phase_id'] = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$transaction = ProductTransaction::query() |
|
|
|
$transaction = ProductTransaction::query() |
|
|
|
->where('company_id', $request->company_id); |
|
|
|
->where('company_id', $request->company_id); |
|
|
|
$cloneQueryTransaction = clone $transaction; |
|
|
|
$cloneQueryTransaction = clone $transaction; |
|
|
@ -93,23 +62,27 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
if($countCreate) { |
|
|
|
if($countCreate) { |
|
|
|
$result = Project::create($data); |
|
|
|
$result = Project::create($data); |
|
|
|
|
|
|
|
if (!$result) { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$this->createOfficeHours($result['id']); |
|
|
|
|
|
|
|
$dataResultInsert = Project::where([['nama', $data['nama']],['mulai_proyek', $data['mulai_proyek']]])->first(); |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Limited to create project!', 'code' => 500], 500); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Limited to create project!', 'code' => 500], 500); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
if (!$result) |
|
|
|
DB::rollBack(); |
|
|
|
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) |
|
|
|
public function edit($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
if (empty($id) || !is_int((int)$id)) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// $result = Project::query() |
|
|
|
// $result = Project::query() |
|
|
|
// ->from('m_proyek AS mp') |
|
|
|
// ->from('m_proyek AS mp') |
|
|
@ -157,28 +130,30 @@ class ProjectController extends Controller |
|
|
|
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') |
|
|
|
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') |
|
|
|
->where('m_proyek.id', $id) |
|
|
|
->where('m_proyek.id', $id) |
|
|
|
->first(); |
|
|
|
->first(); |
|
|
|
if (!$result) |
|
|
|
if (!$result) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} else { |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function update(Request $request, $id) |
|
|
|
public function update(Request $request, $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
if (empty($id) || !is_int((int)$id)) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$data = Project::find($id); |
|
|
|
$data = Project::find($id); |
|
|
|
|
|
|
|
|
|
|
|
if (!$data) |
|
|
|
if ($data) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
if ($data->update($request->all())) { |
|
|
|
|
|
|
|
|
|
|
|
$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); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function createOfficeHours($proyek_id) |
|
|
|
private function createOfficeHours($proyek_id) |
|
|
@ -209,21 +184,26 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function delete($id, $company_id) |
|
|
|
public function delete($id, $company_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
$data = Project::find($id); |
|
|
|
$data = Project::find($id); |
|
|
|
|
|
|
|
if ($data) { |
|
|
|
if (!$data) |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->deleteRelative($id, $company_id); |
|
|
|
$this->deleteRelative($id, $company_id); |
|
|
|
|
|
|
|
if ($data->delete()) { |
|
|
|
if (!$data->delete()) |
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Data deleted!', 'code' => 200], 200); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Delete failed!', 'code' => 500], 500); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function deleteRelative($project_id, $company_id) |
|
|
|
private function deleteRelative($project_id, $company_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::transaction(function() use($project_id, $company_id) { |
|
|
|
UserToProyek::where('proyek_id', $project_id)->delete(); |
|
|
|
UserToProyek::where('proyek_id', $project_id)->delete(); |
|
|
|
UserToActivity::where('proyek_id', $project_id)->delete(); |
|
|
|
UserToActivity::where('proyek_id', $project_id)->delete(); |
|
|
|
AssignMaterial::where('proyek_id', $project_id)->delete(); |
|
|
|
AssignMaterial::where('proyek_id', $project_id)->delete(); |
|
|
@ -242,10 +222,12 @@ class ProjectController extends Controller |
|
|
|
RequestMaterial::where('proyek_id', $project_id)->delete(); |
|
|
|
RequestMaterial::where('proyek_id', $project_id)->delete(); |
|
|
|
$this->deleteVersionGantt($project_id, $company_id); |
|
|
|
$this->deleteVersionGantt($project_id, $company_id); |
|
|
|
$this->deleteDokumenProject($project_id, $company_id); |
|
|
|
$this->deleteDokumenProject($project_id, $company_id); |
|
|
|
|
|
|
|
},5); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function deleteVersionGantt($project_id, $company_id) |
|
|
|
private function deleteVersionGantt($project_id, $company_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::transaction(function() use($project_id, $company_id) { |
|
|
|
$dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id"); |
|
|
|
$dataVg = VersionGantt::where("proyek_id", $project_id)->pluck("id"); |
|
|
|
$vhIds = $dataVg->all(); |
|
|
|
$vhIds = $dataVg->all(); |
|
|
|
$activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id'); |
|
|
|
$activity = Activity::whereIn("version_gantt_id", $vhIds)->pluck('id'); |
|
|
@ -278,11 +260,13 @@ class ProjectController extends Controller |
|
|
|
ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete(); |
|
|
|
ShowHideColumn::whereIn("version_gantt_id", $vhIds)->delete(); |
|
|
|
Activity::whereIn("version_gantt_id", $vhIds)->delete(); |
|
|
|
Activity::whereIn("version_gantt_id", $vhIds)->delete(); |
|
|
|
ReportActivity::whereIn("activity_id", $activityIds)->delete(); |
|
|
|
ReportActivity::whereIn("activity_id", $activityIds)->delete(); |
|
|
|
|
|
|
|
},5); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function deleteDokumenProject($project_id, $company_id) |
|
|
|
private function deleteDokumenProject($project_id, $company_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); |
|
|
|
DB::transaction(function() use($project_id, $company_id){ |
|
|
|
|
|
|
|
$dataDokumen = DokumenProject::where([['type_dokumen', 'project-document-out-folder'],['ref_id', $project_id]])->get(); |
|
|
|
$company = Company::find($company_id); |
|
|
|
$company = Company::find($company_id); |
|
|
|
if($company) { |
|
|
|
if($company) { |
|
|
|
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); |
|
|
|
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); |
|
|
@ -292,8 +276,7 @@ class ProjectController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DokumenProject::where([['type_dokumen', 'project-document-out-folder'],['ref_id', $project_id]])->delete(); |
|
|
|
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete(); |
|
|
|
|
|
|
|
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id"); |
|
|
|
$dataFolder = FolderDocumentProyek::where('proyek_id', $project_id)->pluck("id"); |
|
|
|
$ref_ids = $dataFolder->all(); |
|
|
|
$ref_ids = $dataFolder->all(); |
|
|
|
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); |
|
|
|
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); |
|
|
@ -302,8 +285,8 @@ class ProjectController extends Controller |
|
|
|
unlink($destinationPath['pathDocument'] . $dokumen->file); |
|
|
|
unlink($destinationPath['pathDocument'] . $dokumen->file); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); |
|
|
|
DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->delete(); |
|
|
|
|
|
|
|
},5); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function search(Request $request) |
|
|
|
public function search(Request $request) |
|
|
@ -313,7 +296,6 @@ class ProjectController extends Controller |
|
|
|
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); |
|
|
|
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); |
|
|
|
$builder = $dataBuilder['builder']; |
|
|
|
$builder = $dataBuilder['builder']; |
|
|
|
$countBuilder = $dataBuilder['count']; |
|
|
|
$countBuilder = $dataBuilder['count']; |
|
|
|
// $builder->where("selfTable.created_by",$this->currentName); |
|
|
|
|
|
|
|
$dataGet = $builder->get(); |
|
|
|
$dataGet = $builder->get(); |
|
|
|
$totalRecord = $countBuilder->count(); |
|
|
|
$totalRecord = $countBuilder->count(); |
|
|
|
|
|
|
|
|
|
|
@ -322,6 +304,8 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function list() |
|
|
|
public function list() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$data = Project::select( |
|
|
|
$data = Project::select( |
|
|
|
'id', |
|
|
|
'id', |
|
|
|
'kode_sortname', |
|
|
|
'kode_sortname', |
|
|
@ -359,13 +343,12 @@ class ProjectController extends Controller |
|
|
|
'created_by', |
|
|
|
'created_by', |
|
|
|
'updated_at', |
|
|
|
'updated_at', |
|
|
|
'updated_by' |
|
|
|
'updated_by' |
|
|
|
)->orderBy('id', 'desc') |
|
|
|
)->orderByDesc('id') |
|
|
|
// ->where("created_by",$this->currentName) |
|
|
|
|
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
$countData = $data->count(); |
|
|
|
$countData = $data->count(); |
|
|
|
|
|
|
|
if (!$data) { |
|
|
|
if (!$data) |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost'))); |
|
|
|
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost'))); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
|
$totalActualCost = $data->sum('actualCost'); |
|
|
@ -373,25 +356,17 @@ class ProjectController extends Controller |
|
|
|
$projectsOnDanger = Project::where('budget_health', 'overrun')->count(); |
|
|
|
$projectsOnDanger = Project::where('budget_health', 'overrun')->count(); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); |
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); |
|
|
|
try { |
|
|
|
|
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
$projectsByPhase = DB::table('m_proyek') |
|
|
|
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) |
|
|
|
->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') |
|
|
|
->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') |
|
|
|
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') |
|
|
|
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
$projectsByType = DB::table('m_proyek') |
|
|
|
$projectsByType = DB::table('m_proyek') |
|
|
|
->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total')) |
|
|
|
->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total')) |
|
|
|
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') |
|
|
|
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') |
|
|
|
->groupBy('m_type_proyek.name') |
|
|
|
->groupBy('m_type_proyek.name') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
DB::commit(); |
|
|
|
return response()->json(['message' => $e->getMessage()]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json( |
|
|
|
return response()->json( |
|
|
|
[ |
|
|
|
[ |
|
|
|
'status' => 'success', |
|
|
|
'status' => 'success', |
|
|
@ -410,6 +385,9 @@ class ProjectController extends Controller |
|
|
|
], |
|
|
|
], |
|
|
|
200 |
|
|
|
200 |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getListProjectTask($id) |
|
|
|
public function getListProjectTask($id) |
|
|
@ -420,10 +398,12 @@ class ProjectController extends Controller |
|
|
|
->groupBy("m_proyek.proyek_id") |
|
|
|
->groupBy("m_proyek.proyek_id") |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
|
|
|
|
|
|
|
|
|
if (!$data) |
|
|
|
if ($data) { |
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
|
|
|
} else { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
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) |
|
|
|
public function getSCurve(Request $request) |
|
|
@ -469,15 +449,17 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public static function setSyncDate($activity_id, $activity, $report) |
|
|
|
public static function setSyncDate($activity_id, $activity, $report) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$status = AssignMaterial::where('activity_id', $activity_id)->first(); |
|
|
|
$status = AssignMaterial::where('activity_id', $activity_id)->first(); |
|
|
|
if (!isset($status)) { |
|
|
|
if (!isset($status)) { |
|
|
|
$reports = array( |
|
|
|
DB::commit(); |
|
|
|
|
|
|
|
return [ |
|
|
|
'activity_id' => $activity_id, |
|
|
|
'activity_id' => $activity_id, |
|
|
|
'min_date' => new DateTime($activity->start_date), |
|
|
|
'min_date' => new DateTime($activity->start_date), |
|
|
|
'max_date' => new DateTime($activity->end_date), |
|
|
|
'max_date' => new DateTime($activity->end_date), |
|
|
|
'status' => 'open' |
|
|
|
'status' => 'open' |
|
|
|
); |
|
|
|
]; |
|
|
|
return $reports; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!isset($status->status_activity)) { |
|
|
|
if (!isset($status->status_activity)) { |
|
|
|
$status->status_activity = 'open'; |
|
|
|
$status->status_activity = 'open'; |
|
|
@ -491,17 +473,22 @@ class ProjectController extends Controller |
|
|
|
$minDate = date_create($material->start_activity); |
|
|
|
$minDate = date_create($material->start_activity); |
|
|
|
$maxDate = date_create($material->finish_activity); |
|
|
|
$maxDate = date_create($material->finish_activity); |
|
|
|
} |
|
|
|
} |
|
|
|
$reports = array( |
|
|
|
DB::commit(); |
|
|
|
|
|
|
|
return [ |
|
|
|
'activity_id' => $activity_id, |
|
|
|
'activity_id' => $activity_id, |
|
|
|
'min_date' => $minDate, |
|
|
|
'min_date' => $minDate, |
|
|
|
'max_date' => $maxDate, |
|
|
|
'max_date' => $maxDate, |
|
|
|
'status' => $status->status_activity |
|
|
|
'status' => $status->status_activity |
|
|
|
); |
|
|
|
]; |
|
|
|
return $reports; |
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
public function synchronizeReport($gantt_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); |
|
|
|
$reports = []; |
|
|
|
$reports = []; |
|
|
|
|
|
|
|
|
|
|
@ -511,12 +498,12 @@ class ProjectController extends Controller |
|
|
|
if ($countReports === 1) { |
|
|
|
if ($countReports === 1) { |
|
|
|
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); |
|
|
|
foreach ($dataReports as $dr) { |
|
|
|
foreach ($dataReports as $dr) { |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr); |
|
|
|
$reports[] = self::setSyncDate($activity_id, $activity, $dr); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ($countReports > 1) { |
|
|
|
if ($countReports > 1) { |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$firstReport = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->first(); |
|
|
|
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $firstReport); |
|
|
|
$reports[] = self::setSyncDate($activity_id, $activity, $firstReport); |
|
|
|
} |
|
|
|
} |
|
|
|
$successor = Link::where('t_activity_id', $activity->id)->first(); |
|
|
|
$successor = Link::where('t_activity_id', $activity->id)->first(); |
|
|
|
if ($successor) { |
|
|
|
if ($successor) { |
|
|
@ -544,8 +531,11 @@ class ProjectController extends Controller |
|
|
|
$activity->actual_start = $reports[$i]['min_date']; |
|
|
|
$activity->actual_start = $reports[$i]['min_date']; |
|
|
|
$activity->save(); |
|
|
|
$activity->save(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Synchronize to report success!', 'code' => 200], 200); |
|
|
|
return response()->json(['status' => 'success', 'message' => 'Synchronize to report success!', 'code' => 200], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setBaseline($gantt_id) |
|
|
|
public function setBaseline($gantt_id) |
|
|
@ -566,10 +556,7 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function setBaselineActivity($activity_id, $gantt_id) |
|
|
|
public function setBaselineActivity($activity_id, $gantt_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$activity = Activity::where([ |
|
|
|
$activity = Activity::where([["version_gantt_id", $gantt_id],['id',$activity_id]])->first(); |
|
|
|
["version_gantt_id", $gantt_id], |
|
|
|
|
|
|
|
['id',$activity_id] |
|
|
|
|
|
|
|
])->first(); |
|
|
|
|
|
|
|
$activity->update([ |
|
|
|
$activity->update([ |
|
|
|
"planned_start" => $activity->start_date, |
|
|
|
"planned_start" => $activity->start_date, |
|
|
|
"planned_end" => $activity->end_date, |
|
|
|
"planned_end" => $activity->end_date, |
|
|
@ -581,30 +568,32 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
public function getInvoiceIntegration(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); |
|
|
|
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); |
|
|
|
$search = urlencode($request->search); |
|
|
|
$search = urlencode($request->search); |
|
|
|
if (empty($search)) |
|
|
|
if (empty($search)) { |
|
|
|
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); |
|
|
|
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); |
|
|
|
|
|
|
|
} |
|
|
|
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); |
|
|
|
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); |
|
|
|
|
|
|
|
|
|
|
|
$response = MasterFunctionsHelper::curlReq($url); |
|
|
|
$response = MasterFunctionsHelper::curlReq($url); |
|
|
|
if (isset($request->gantt_id)) { |
|
|
|
if (isset($request->gantt_id)) { |
|
|
|
$response->data->total_cost = $response->data->total_cost / $ganttCount; |
|
|
|
$response->data->total_cost = $response->data->total_cost / $ganttCount; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); |
|
|
|
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
public function getByUser($id) |
|
|
|
public function getByUser($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$alias = "utp"; |
|
|
|
|
|
|
|
$userProyek = UserToProyek::query() |
|
|
|
$userProyek = UserToProyek::query() |
|
|
|
->from('assign_hr_to_proyek AS ' . $alias) |
|
|
|
->from('assign_hr_to_proyek AS utp') |
|
|
|
->where([ |
|
|
|
->where([['is_customer', true],['user_id', $id]]) |
|
|
|
['is_customer', true], |
|
|
|
->leftJoin('m_users', 'utp.user_id', '=', 'm_users.id') |
|
|
|
['user_id', $id] |
|
|
|
->leftJoin('m_proyek', 'utp.proyek_id', '=', 'm_proyek.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') |
|
|
|
->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') |
|
|
|
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name') |
|
|
|
->get(); |
|
|
|
->get(); |
|
|
@ -612,15 +601,19 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null) |
|
|
|
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (empty($id) || !is_int((int)$id)) |
|
|
|
DB::beginTransaction(); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
try { |
|
|
|
|
|
|
|
if (empty($id) || !is_int((int)$id)) { |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$result = Project::find($id); |
|
|
|
$result = Project::find($id); |
|
|
|
|
|
|
|
if (!$result) { |
|
|
|
if (!$result) |
|
|
|
|
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
if (!isset($gantt_id)) { |
|
|
|
if (!isset($gantt_id)) { |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($id); |
|
|
|
$gantt = MasterFunctionsHelper::getLatestGantt($id); |
|
|
|
$ganttId = $gantt['last_gantt_id']; |
|
|
|
$ganttId = $gantt['last_gantt_id']; |
|
|
@ -641,7 +634,7 @@ class ProjectController extends Controller |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
->orderBy('end_date', 'desc') |
|
|
|
->orderByDesc('end_date') |
|
|
|
->first(); |
|
|
|
->first(); |
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
} |
|
|
|
} |
|
|
@ -650,7 +643,7 @@ class ProjectController extends Controller |
|
|
|
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); |
|
|
|
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); |
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); |
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') |
|
|
|
->orderBy('end_date', 'desc') |
|
|
|
->orderByDesc('end_date') |
|
|
|
->first(); |
|
|
|
->first(); |
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
$query = Activity::where('version_gantt_id', $ganttId); |
|
|
|
} |
|
|
|
} |
|
|
@ -680,19 +673,27 @@ class ProjectController extends Controller |
|
|
|
$result->header->planned_start = $plannedStart; |
|
|
|
$result->header->planned_start = $plannedStart; |
|
|
|
$result->header->planned_end = $plannedEnd; |
|
|
|
$result->header->planned_end = $plannedEnd; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getOverdueActivities(Request $request) |
|
|
|
public function getOverdueActivities(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$payload = $request->all(); |
|
|
|
$payload = $request->all(); |
|
|
|
if (empty($payload['id']) || !is_int((int)$payload['id'])) |
|
|
|
if (empty($payload['id']) || !is_int((int)$payload['id'])) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$result = Project::find($payload['id']); |
|
|
|
$result = Project::find($payload['id']); |
|
|
|
|
|
|
|
|
|
|
|
if (!$result) |
|
|
|
if (!$result) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
//TODO possible overdue bug |
|
|
|
//TODO possible overdue bug |
|
|
|
$endDate = Activity::where('proyek_id', $payload['id']) |
|
|
|
$endDate = Activity::where('proyek_id', $payload['id']) |
|
|
|
->orderByDesc('end_date') |
|
|
|
->orderByDesc('end_date') |
|
|
@ -711,18 +712,25 @@ class ProjectController extends Controller |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$result->overdueActivities = $overdueActivities; |
|
|
|
$result->overdueActivities = $overdueActivities; |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getReportDistribution(Request $request) |
|
|
|
public function getReportDistribution(Request $request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
$payload = $request->all(); |
|
|
|
$payload = $request->all(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($payload['project_id']) || !is_int((int)$payload['project_id'])) |
|
|
|
if (empty($payload['project_id']) || !is_int((int)$payload['project_id'])) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$reports = DB::table('assign_material_to_activity as ama') |
|
|
|
$reports = AssignMaterial::query() |
|
|
|
|
|
|
|
->from('assign_material_to_activity AS ama') |
|
|
|
->select( |
|
|
|
->select( |
|
|
|
'u.name', |
|
|
|
'u.name', |
|
|
|
'a.name as activity_name', |
|
|
|
'a.name as activity_name', |
|
|
@ -742,8 +750,11 @@ class ProjectController extends Controller |
|
|
|
->where('ama.proyek_id', '=', $payload['project_id']) |
|
|
|
->where('ama.proyek_id', '=', $payload['project_id']) |
|
|
|
->whereNotNull('ram.lat') |
|
|
|
->whereNotNull('ram.lat') |
|
|
|
->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); |
|
|
|
->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getManpower($proyek_id) |
|
|
|
public function getManpower($proyek_id) |
|
|
@ -763,7 +774,10 @@ class ProjectController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function dashboard($id) |
|
|
|
public function dashboard($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$data = DB::table('m_proyek as mp') |
|
|
|
DB::beginTransaction(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
$data = Project::query() |
|
|
|
|
|
|
|
->from('m_proyek AS mp') |
|
|
|
->select( |
|
|
|
->select( |
|
|
|
'mp.kode_sortname', |
|
|
|
'mp.kode_sortname', |
|
|
|
'mp.nama as name_project', |
|
|
|
'mp.nama as name_project', |
|
|
@ -779,16 +793,18 @@ class ProjectController extends Controller |
|
|
|
->where('mp.id', $id) |
|
|
|
->where('mp.id', $id) |
|
|
|
->first(); |
|
|
|
->first(); |
|
|
|
|
|
|
|
|
|
|
|
if (!$data) |
|
|
|
if (!$data) { |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data tidak ditemukan!', 'code' => 404], 404); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
$manpowers = UserToProyek::where('proyek_id', $id)->count(); |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); |
|
|
|
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderByDesc('version_gantt_id')->first(); |
|
|
|
|
|
|
|
|
|
|
|
$actualCost = @$rootActivity->biaya_actual ?? 0; |
|
|
|
$actualCost = @$rootActivity->biaya_actual ?? 0; |
|
|
|
$progress = @$rootActivity->persentase_progress ?? 0; |
|
|
|
$progress = @$rootActivity->persentase_progress ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
$commentActivity = DB::table('m_comment_activity as mca') |
|
|
|
$commentActivity = CommentActivity::query() |
|
|
|
|
|
|
|
->from('m_comment_activity AS mca') |
|
|
|
->select( |
|
|
|
->select( |
|
|
|
'mca.activity_id', |
|
|
|
'mca.activity_id', |
|
|
|
'mca.comment as comment', |
|
|
|
'mca.comment as comment', |
|
|
@ -806,8 +822,11 @@ class ProjectController extends Controller |
|
|
|
$data->progress = $progress; |
|
|
|
$data->progress = $progress; |
|
|
|
$data->comment = $commentActivity; |
|
|
|
$data->comment = $commentActivity; |
|
|
|
$data->man_power = $manpowers; |
|
|
|
$data->man_power = $manpowers; |
|
|
|
|
|
|
|
DB::commit(); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200); |
|
|
|
|
|
|
|
} catch (\Throwable $th) { |
|
|
|
|
|
|
|
DB::rollBack(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private function httpReq($search) |
|
|
|
private function httpReq($search) |
|
|
|