Browse Source

Merge pull request 'Dev-Farhan' (#20) from Dev-Farhan into staging

Reviewed-on: ibnu/generic-ospro-backend#20
pull/1/head
farhantock 1 year ago
parent
commit
c6563d54ca
  1. 145
      app/Http/Controllers/DashboardBoDController.php
  2. 67
      app/Http/Controllers/DivisiController.php
  3. 59
      app/Http/Controllers/RoleController.php
  4. 82
      app/Http/Controllers/VersionGanttController.php
  5. 12
      routes/web.php

145
app/Http/Controllers/DashboardBoDController.php

@ -54,48 +54,6 @@ class DashboardBoDController extends Controller
return $response; return $response;
} }
// OLD
// public function getCompanyCashFlow($year = '%')
// {
// $year = $this->interpolateYear($year);
// $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0;
// $totalBudgets = Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))'))
// ->where('mulai_proyek', 'like', $year)
// /* ->orWhere('akhir_proyek', 'like', $year) */
// ->pluck('sum')
// ->first();
// $projects = Project::where('mulai_proyek', 'like', $year)
// /* ->orWhere('akhir_proyek', 'like', $year) */
// ->get();
// foreach ($projects as $project) {
// $project->expenses = 0;
// $resp = null;
// if ($project->kode_sortname != "") {
// $resp = $this->getInvoiceIntegration($project->kode_sortname);
// /* $resp = $project->kode_sortname; */
// $cost = $resp->data->total_cost ?? 0;
// $cost = substr($cost, 0, strpos($cost, "."));
// $totalExpenditure += (int) $cost;
// $totalInvoice += $resp->data->total_invoice_amount ?? 0;
// $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
// }
// }
// return response()->json([
// 'data' => [
// 'total_budget' => (int) $totalBudgets ?? 0,
// 'total_expenditure' => $totalExpenditure,
// 'total_invoice' => $totalInvoice,
// 'total_paid_invoice' => $totalPaidInvoice,
// ]
// ], 200);
// }
public function getCompanyCashFlow($year = '%', $company_id, $all_project, $hierarchy) public function getCompanyCashFlow($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
@ -128,9 +86,9 @@ class DashboardBoDController extends Controller
$resp = null; $resp = null;
if ($project->kode_sortname != "") { if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname); // $resp = $this->getInvoiceIntegration($project->kode_sortname);
$cost = $resp->data->total_cost ?? 0; // $cost = $resp->data->total_cost ?? 0;
$cost = substr($cost, 0, strpos($cost, ".")); // $cost = substr($cost, 0, strpos($cost, "."));
$cost = 0; $cost = 0;
$totalExpenditure = 0; $totalExpenditure = 0;
$totalInvoice = 0; $totalInvoice = 0;
@ -152,7 +110,7 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
// integrasi
public function getInvoiceOutstanding($year = '%') public function getInvoiceOutstanding($year = '%')
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
@ -232,9 +190,13 @@ class DashboardBoDController extends Controller
return response()->json(['data' => $return, 'q' => $projects], 200); return response()->json(['data' => $return, 'q' => $projects], 200);
} }
public function getTotalProjectScheduleHealthPerDivision($year = '%') public function getTotalProjectScheduleHealthPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::whereNull('parent')
->where('company_id', $company_id)
->get();
$divisions = Divisi::whereNull('parent')->get(); $divisions = Divisi::whereNull('parent')->get();
foreach ($divisions as $index => $division) { foreach ($divisions as $index => $division) {
@ -277,16 +239,62 @@ class DashboardBoDController extends Controller
], 200); ], 200);
} }
public function getTotalProjectPerBudgetHealth($year = '%') public function getTotalProjectPerBudgetHealth($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
return response()->json([ $response = [
'data' => [ 'data' => [
'overrun' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'overrun')->count(), 'overrun' => 0,
'warning' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'warning')->count(), 'warning' => 0,
'on-budget' => Project::where('mulai_proyek', 'like', $year)->where('budget_health', 'on-budget')->count(), 'on-budget' => 0,
] ]
], 200); ];
if ($all_project) {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('company_id', $company_id)
->count();
} else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('company_id', $company_id)
->count();
} else {
$response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'overrun')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'warning')
->where('company_id', $company_id)
->count();
} else {
$response['data']['warning'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'warning')
->where('created_by_id', $hierarchy)
->count();
}
if ($all_project) {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'on-budget')
->where('company_id', $company_id)
->count();
} else {
$response['data']['on-budget'] = Project::where('mulai_proyek', 'like', $year)
->where('budget_health', 'on-budget')
->where('created_by_id', $hierarchy)
->count();
}
return response()->json($response, 200);
} }
private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health) private function countTotalProjectByBudgetHealthInDivision($divisi, $year, $health)
@ -299,12 +307,13 @@ class DashboardBoDController extends Controller
} }
public function getTotalProjectBudgetHealthPerDivision($year = '%') public function getTotalProjectBudgetHealthPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name') $divisions = Divisi::select('id', 'name')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $division) { foreach ($divisions as $division) {
@ -332,7 +341,7 @@ class DashboardBoDController extends Controller
public function getTotalProjectPerPhase($year = '%', $company_id, $all_project, $hierarchy) public function getTotalProjectPerPhase($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projectPhases = ProjectPhase::orderBy('order')->get(); $projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get();
foreach ($projectPhases as $phase) { foreach ($projectPhases as $phase) {
if ($all_project) { if ($all_project) {
@ -361,15 +370,17 @@ class DashboardBoDController extends Controller
->count(); ->count();
} }
public function getTotalProjectPerDivision($year = '%') public function getTotalProjectPerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name', 'parent', 'color') $divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child // to do : count in more than 1 level child
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectInDivision($v->id, $year); $v->total = $this->countTotalProjectInDivision($v->id, $year);
@ -394,16 +405,16 @@ class DashboardBoDController extends Controller
->first(); ->first();
} }
public function getTotalProjectValuePerDivision($year = '%') public function getTotalProjectValuePerDivision($year = '%', $company_id)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name', 'color') $divisions = Divisi::select('id', 'name', 'color')
->with('children') ->with('children')
->whereNull('parent') ->whereNull('parent')
->where('company_id', $company_id)
->get(); ->get();
// to do : count in more than 1 level child
foreach ($divisions as $v) { foreach ($divisions as $v) {
$v->total = $this->countTotalProjectValueInDivision($v->id, $year); $v->total = $this->countTotalProjectValueInDivision($v->id, $year);
foreach ($v->children as $d) { foreach ($v->children as $d) {
@ -418,21 +429,29 @@ class DashboardBoDController extends Controller
} }
public function getDetailExpenditure($year = '%') public function getDetailExpenditure($year = '%', $company_id, $all_project, $hierarchy)
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = null;
if ($all_project) {
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::where('mulai_proyek', 'like', $year)
/* ->orWhere('akhir_proyek', 'like', $year) */ ->where('company_id', $company_id)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->get(); ->get();
} else {
$projects = Project::where('mulai_proyek', 'like', $year)
->where('created_by_id', $hierarchy)
->orderBy('id', 'desc')
->get();
}
foreach ($projects as $project) { foreach ($projects as $project) {
$lastGantt = MasterFunctionsHelper::getLatestGantt($project->id); $lastGantt = MasterFunctionsHelper::getLatestGantt($project->id);
if ($project->kode_sortname != "") { if ($project->kode_sortname != "") {
$resp = $this->getInvoiceIntegration($project->kode_sortname);
$project->invoice = [ $project->invoice = [
'invoiced' => $resp->data->total_invoice_amount ?? 0, 'invoiced' => 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0, 'paid' => 0,
]; ];
} }

67
app/Http/Controllers/DivisiController.php

@ -8,21 +8,23 @@ use App\Models\Divisi;
class DivisiController extends Controller class DivisiController extends Controller
{ {
private function getAllChildren($divisi, $depth = 0, $array = []) { private function getAllChildren($divisi, $depth = 0, $array = [])
{
$divisi->depth = $depth; $divisi->depth = $depth;
array_push($array, $divisi); array_push($array, $divisi);
foreach($divisi->children as $child){ foreach ($divisi->children as $child) {
$array = $this->getAllChildren($child, $depth + 1, $array); $array = $this->getAllChildren($child, $depth + 1, $array);
} }
return $array; return $array;
} }
public function add(Request $request){ public function add(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required|unique:m_divisi,name', 'name' => 'string|required|unique:m_divisi,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'nullable|string', 'description' => 'nullable|string',
'parent' => 'nullable|integer', 'parent' => 'nullable|integer',
'color'=>'nullable|string|max:10' 'color' => 'nullable|string|max:10'
]); ]);
$data = $request->all(); $data = $request->all();
@ -30,15 +32,16 @@ class DivisiController extends Controller
$result = Divisi::create($data); $result = Divisi::create($data);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500]); return response()->json(['status' => 'failed', 'message' => 'Failed to add data', 'code' => 500]);
return response()->json(['status'=>'success','message'=>'Data created!','code'=>200]); return response()->json(['status' => 'success', 'message' => 'Data created!', 'code' => 200]);
} }
public function update(Request $request, $id){ 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); if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required', 'name' => 'string|required',
@ -47,35 +50,35 @@ class DivisiController extends Controller
]); ]);
$data = Divisi::find($id); $data = Divisi::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_divisi,name']) : ''; $request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_divisi,name']) : '';
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);
$result = $data->update($request->all()); $result = $data->update($request->all());
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=> 'Update failed!','code'=> 500], 500); return response()->json(['status' => 'failed', 'message' => 'Update failed!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
} }
public function delete($id) public function delete($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 = Divisi::find($id); $data = Divisi::find($id);
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);
$delete = $data->delete(); $delete = $data->delete();
if(!$delete) if (!$delete)
return response()->json(['status'=>'failed','message'=> 'Delete failed!','code'=> 500], 500); 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);
} }
public function search(Request $request) public function search(Request $request)
@ -86,7 +89,7 @@ class DivisiController extends Controller
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
//return $this->list(); //return $this->list();
// cant use builder for this case // cant use builder for this case
} }
@ -95,20 +98,20 @@ class DivisiController extends Controller
{ {
$parentMenus = Divisi::whereNull('parent')->with('children')->get(); $parentMenus = Divisi::whereNull('parent')->with('children')->get();
$divisions = []; $divisions = [];
foreach($parentMenus as $menu){ foreach ($parentMenus as $menu) {
$childs = $this->getAllChildren($menu); $childs = $this->getAllChildren($menu);
foreach($childs as $d){ foreach ($childs as $d) {
$d->displayName = ' ' . $d->name; $d->displayName = ' ' . $d->name;
for($i=0; $i < $d->depth; $i++){ for ($i = 0; $i < $d->depth; $i++) {
$d->displayName = '--' . $d->displayName ; $d->displayName = '--' . $d->displayName;
} }
array_push($divisions, $d); array_push($divisions, $d);
} }
} }
$countData = count($divisions); $countData = count($divisions);
if($countData == 0) if ($countData == 0)
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'=> $divisions, 'totalRecord'=> $countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200);
} }
} }

59
app/Http/Controllers/RoleController.php

@ -11,7 +11,7 @@ class RoleController extends Controller
public function add(Request $request) public function add(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required|unique:m_roles,name', 'name' => 'string|required|unique:m_roles,name,NULL,id,company_id,' . $request->input('company_id'),
'description' => 'required' 'description' => 'required'
]); ]);
@ -24,63 +24,64 @@ class RoleController extends Controller
$result = Role::create($data); $result = Role::create($data);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data added!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Data added!', 'code' => 200], 200);
} }
public function edit( $id){ public function edit($id)
if(empty($id) || !is_int((int)$id)) {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Role::find($id); $result = Role::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);
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);
$this->validate($request, [ $this->validate($request, [
'name' => 'string|required', 'name' => 'string|required',
'description' => 'required' 'description' => 'required'
]); ]);
$data = Role::find($id); $data = Role::find($id);
$request->name !== $data['name'] ? $this->validate($request,['name'=>'unique:m_roles,name']) : ''; $request->name !== $data['name'] ? $this->validate($request, ['name' => 'unique:m_roles,name']) : '';
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);
$result = $data->update($request->all()); $result = $data->update($request->all());
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=>'Failed to update the data!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to update the data!', '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);
} }
public function delete($id) public function delete($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 = Role::find($id); $data = Role::find($id);
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);
$delete = $data->delete(); $delete = $data->delete();
if(!$delete) if (!$delete)
return response()->json(['status'=>'failed','message'=>'Failed to delete!','code'=>500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to delete!', '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);
} }
public function search(Request $request) public function search(Request $request)
@ -93,7 +94,7 @@ class RoleController extends Controller
$dataGet = $builder->get(); $dataGet = $builder->get();
$totalRecord = $countBuilder->count(); $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200);
} }
public function list() public function list()
@ -101,9 +102,9 @@ class RoleController extends Controller
$data = Role::all(); $data = Role::all();
$countData = $data->count(); $countData = $data->count();
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=>'failed get list role, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list role, please try again later!', 'code' => 400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} }
} }

82
app/Http/Controllers/VersionGanttController.php

@ -14,7 +14,8 @@ use App\Models\ActivityProgressLog;
class VersionGanttController extends Controller class VersionGanttController extends Controller
{ {
public function add(Request $request){ public function add(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'name_version' => 'required', 'name_version' => 'required',
'proyek_id' => 'required' 'proyek_id' => 'required'
@ -23,30 +24,31 @@ class VersionGanttController extends Controller
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$result = VersionGantt::create($data); $result = VersionGantt::create($data);
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfull created','code'=>200]); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfull created', 'code' => 200, 'id' => $result->id]);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed created','code'=>400]); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed created', 'code' => 400]);
} }
} }
public function update(Request $request, $id){ public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id==""){ if (!$id || (int) $id < 0 || $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 = VersionGantt::find($id); $data = VersionGantt::find($id);
if($data){ if ($data) {
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die(); die();
} }
if($result){ if ($result) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfully updated!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully updated!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed updated!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed updated!', 'code' => 400], 400);
} }
} }
@ -54,19 +56,19 @@ class VersionGanttController extends Controller
{ {
$data = VersionGantt::find($id); $data = VersionGantt::find($id);
if($data){ if ($data) {
$delete = $data->delete(); $delete = $data->delete();
$this->deleteRelative($data['id']); $this->deleteRelative($data['id']);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'data version gantt Project not found!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'data version gantt Project not found!', 'code' => 400], 400);
die(); die();
} }
if($delete){ if ($delete) {
return response()->json(['status'=>'success','message'=>'version gantt Project successfully deleted!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'version gantt Project successfully deleted!', 'code' => 200], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'version gantt Project failed deleted!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'version gantt Project failed deleted!', 'code' => 400], 400);
} }
} }
@ -81,18 +83,19 @@ class VersionGanttController extends Controller
ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete(); ActivityProgressLog::where('version_gantt_id', $version_gantt_id)->delete();
} }
public function edit($id){ public function edit($id)
if(!$id || (int) $id < 0 || $id==""){ {
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die(); die();
} }
$result = VersionGantt::find($id); $result = VersionGantt::find($id);
if($result){ if ($result) {
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'failed get data version gantt, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get data version gantt, please try again later!', 'code' => 400], 400);
} }
} }
@ -106,18 +109,19 @@ class VersionGanttController extends Controller
$dataGet = $builder->get(); $dataGet = $builder->get();
// $totalRecord = $countBuilder->count(); // $totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
} }
public function ganttProgress($column, $value){ public function ganttProgress($column, $value)
$progress = VersionGantt::select('m_version_gantt.id','m_activity.persentase_progress', 'm_activity.bobot_planning') {
$progress = VersionGantt::select('m_version_gantt.id', 'm_activity.persentase_progress', 'm_activity.bobot_planning')
->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id') ->join('m_activity', 'm_version_gantt.id', '=', 'm_activity.version_gantt_id')
->where("m_version_gantt.".$column, $value) ->where("m_version_gantt." . $column, $value)
// ->where('m_activity.type_activity', "project") // ->where('m_activity.type_activity', "project")
->where('m_activity.parent_id', null) ->where('m_activity.parent_id', null)
->get(); ->get();
foreach($progress as $item) { foreach ($progress as $item) {
if($item->persentase_progress){ if ($item->persentase_progress) {
$item->progress = $item->persentase_progress; $item->progress = $item->persentase_progress;
$item->bobot = $item->bobot_planning; $item->bobot = $item->bobot_planning;
$item->save(); $item->save();
@ -130,10 +134,10 @@ class VersionGanttController extends Controller
$data = VersionGantt::all(); $data = VersionGantt::all();
$countData = $data->count(); $countData = $data->count();
if($data){ if ($data) {
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
}else{ } else {
return response()->json(['status'=>'failed','message'=>'failed get list version gantt, please try again later!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'failed get list version gantt, please try again later!', 'code' => 400], 400);
} }
} }
} }

12
routes/web.php

@ -26,13 +26,13 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure $router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure
$router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in $router->get('/dashboard/get-invoice-outstanding[/{year}]', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in
$router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); $router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth');
$router->get('/dashboard/get-total-project-per-budget-health[/{year}]', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); $router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth');
$router->get('/dashboard/get-total-project-schedule-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); $router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision');
$router->get('/dashboard/get-total-project-budget-health-per-division[/{year}]', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); $router->get('/dashboard/get-total-project-budget-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision');
$router->get('/dashboard/get-total-project-per-phase/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerPhase'); $router->get('/dashboard/get-total-project-per-phase/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerPhase');
$router->get('/dashboard/get-total-project-per-division[/{year}]', 'DashboardBoDController@getTotalProjectPerDivision'); $router->get('/dashboard/get-total-project-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division[/{year}]', 'DashboardBoDController@getTotalProjectValuePerDivision'); $router->get('/dashboard/get-total-project-value-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure[/{year}]', 'DashboardBoDController@getDetailExpenditure'); $router->get('/dashboard/get-detail-expenditure/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getDetailExpenditure');
$router->post('/role/search', 'RoleController@search'); $router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add'); $router->post('/role/add', 'RoleController@add');

Loading…
Cancel
Save