Browse Source

Merge pull request 'staging' (#31) from staging into master

Reviewed-on: ibnu/generic-ospro-backend#31
pull/1/head
farhantock 1 year ago
parent
commit
2e42d964b4
  1. 75
      app/Http/Controllers/ActivityController.php
  2. 100
      app/Http/Controllers/DashboardBoDController.php
  3. 93
      app/Http/Controllers/ProjectExpenditureController.php
  4. 93
      app/Http/Controllers/ProjectFinancialHealthController.php
  5. 93
      app/Http/Controllers/ProjectInvoiceController.php
  6. 93
      app/Http/Controllers/ProjectScheduleHealthController.php
  7. 17
      app/Models/ProjectExpenditure.php
  8. 17
      app/Models/ProjectFinancialHealth.php
  9. 17
      app/Models/ProjectInvoice.php
  10. 17
      app/Models/ProjectScheduleHealth.php
  11. 28
      routes/web.php

75
app/Http/Controllers/ActivityController.php

@ -1,4 +1,5 @@
<?php
namespace App\Http\Controllers;
use DateTime;
@ -37,7 +38,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'data' => $dataGantt, 'code' => 200], 200);
}
public function activitySCurve($proyek_id, $gantt_id){
public function activitySCurve($proyek_id, $gantt_id)
{
// "data": [
// {
@ -122,7 +124,6 @@ class ActivityController extends Controller
);
return response()->json(['status' => 'success', 'data' => $resultData, 'code' => 200], 200);
}
private function getDataActivity($id)
@ -212,7 +213,7 @@ class ActivityController extends Controller
->where('version_gantt_id', $gantt_id)->where('parent_id', $parent_id)->orderBy('sortorder', 'asc')->get();
foreach ($data as $objRow) {
$objRow->parent = $parent_id;
$objRow->progress = (float) $objRow->bobot_planning /100;
$objRow->progress = (float) $objRow->bobot_planning / 100;
// $objRow->start_date1 = isset($objRow->start) ? date_format(date_create($objRow->start), "d-m-Y H:i") : NULL;
// $objRow->end_date1 = isset($objRow->end) ? date_format(date_create($objRow->end), "d-m-Y H:i") : NULL;
@ -264,7 +265,7 @@ class ActivityController extends Controller
$objRow->type = "task";
$objRow->actual_start = isset($objRow->actual_start) ? date_format(date_create($objRow->actual_start), "Y-m-d") : NULL;
$objRow->actual_end = isset($objRow->actual_end) ? date_format(date_create($objRow->actual_end), "Y-m-d") : NULL;
if(isset($objRow->actual_start)){
if (isset($objRow->actual_start)) {
$objRow->auto_scheduling = false;
}
} else {
@ -281,36 +282,36 @@ class ActivityController extends Controller
return $finalData;
}
public function getActivityFirst($parentId){
public function getActivityFirst($parentId)
{
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_start ASC')->first();
if (!isset($activity)) {
return null;
}
if($activity->type_activity == "task"){
if ($activity->type_activity == "task") {
// Log::info("activity ", [$activity]);
return $activity->actual_start;
}else{
} else {
return $this->getActivityFirst($activity->id);
}
}
public function getFirstLastDateActivity($id, $params){
if($params == "start"){
public function getFirstLastDateActivity($id, $params)
{
if ($params == "start") {
$data = Activity::select('id', 'parent_id', 'name', 'actual_start')->where('parent_id', $id)->get();
}else{
} else {
$data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get();
}
$parent = Activity::findOrFail($id);
$dataFinal=[];
$dataFinal = [];
foreach ($data as $val) {
$activity = $this->getchildActivityForActual($val->id, $params);
$dataFinal[] = $val;
$dataFinal = array_merge($dataFinal, $activity);
}
if($params == "start"){
$actualStartValues = array_column(array_filter($dataFinal, function($item) {
if ($params == "start") {
$actualStartValues = array_column(array_filter($dataFinal, function ($item) {
return isset($item['actual_start']);
}), 'actual_start');
$returnActualStartOrEnd = count($actualStartValues) > 0 ? min($actualStartValues) : null;
@ -318,8 +319,8 @@ class ActivityController extends Controller
$parent->actual_start = $returnActualStartOrEnd;
$parent->save();
}
}else{
$actualEndValues = array_column(array_filter($dataFinal, function($item) {
} else {
$actualEndValues = array_column(array_filter($dataFinal, function ($item) {
return isset($item['actual_end']);
}), 'actual_end');
$returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) && count($actualEndValues) > 0 ? max($actualEndValues) : null;
@ -333,14 +334,15 @@ class ActivityController extends Controller
return $returnActualStartOrEnd;
}
public function getchildActivityForActual($parent, $params){
if($params == "start"){
public function getchildActivityForActual($parent, $params)
{
if ($params == "start") {
$activity = Activity::select('id', 'actual_start')->where('parent_id', $parent)->get();
}else{
} else {
$activity = Activity::select('id', 'actual_end')->where('parent_id', $parent)->get();
}
$temp = [];
foreach($activity as $val1){
foreach ($activity as $val1) {
$getChild = $this->getchildActivityForActual($val1->id, $params);
$temp[] = $val1;
$temp = array_merge($temp, $getChild);
@ -348,18 +350,18 @@ class ActivityController extends Controller
return $temp;
}
public function getActivityLast($parentId){
public function getActivityLast($parentId)
{
$activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first();
if (!isset($activity)) {
return null;
}
if($activity->type_activity == "task"){
if ($activity->type_activity == "task") {
// Log::info("activity ", [$activity]);
return $activity->actual_end;
}else{
} else {
return $this->getActivityLast($activity->id);
}
}
private function cloneTemplate($id, $proyek_id, $hierarchy_ftth_id = null)
@ -547,7 +549,8 @@ class ActivityController extends Controller
return response()->json(['status' => 'success', 'message' => 'Activity Updated!', 'code' => 200], 200);
}
public function updateSchedule($ganttId){
public function updateSchedule($ganttId)
{
if (empty($ganttId) || !is_int((int) $ganttId))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -574,10 +577,10 @@ class ActivityController extends Controller
$endDate = $today;
$bobotPlanning = (int) $activity->bobot_planning;
$rerataBobot = $duration > 0 ? $bobotPlanning / $duration : 0;
$bobotActual = (int) $activity->persentase_progress/100 * $bobotPlanning;
$bobotActual = (int) $activity->persentase_progress / 100 * $bobotPlanning;
$sisaBobot = $bobotPlanning - $bobotActual;
$sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+".ceil($sisaHari)." Days");
$endDate->modify("+" . ceil($sisaHari) . " Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration;
$activity->end_date = $endDate;
@ -593,7 +596,7 @@ class ActivityController extends Controller
$entities = $request->all();
if (empty($ganttId) || !is_int((int) $ganttId))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$activity = Activity::where('version_gantt_id',$ganttId)->get();
$activity = Activity::where('version_gantt_id', $ganttId)->get();
$link = Link::where('version_gantt_id', $ganttId)->get();
if (!$activity)
return response()->json(['status' => 'failed', 'message' => 'Activity not found!', 'code' => 404], 404);
@ -604,7 +607,7 @@ class ActivityController extends Controller
$activityToUpdate = $activity->firstWhere('id', $entity['data']['id']);
$entity['data']['name'] = $entity['data']['text'];
$entity['data']['persentase_progress'] = $entity['data']['progress'] * 100;
$entity['data']['type_activity'] = $entity['data']['type'];
$entity['data']['type_activity'] = $entity['data']['type'] ?? 'task';
if (isset($entity['data']['rencana_biaya'])) {
$entity['data']['rencana_biaya'] = str_replace(",", ".", $entity['data']['rencana_biaya']);
}
@ -640,8 +643,8 @@ class ActivityController extends Controller
AssignMaterial::where('activity_id', $activity_id)->delete();
$dataAd = ActivityDokumen::where("activity_id", $activity_id)->get();
foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){
unlink($this->pathActivityDocument.$ad->file);
if (file_exists($this->pathActivityDocument . $ad->file)) {
unlink($this->pathActivityDocument . $ad->file);
}
}
ActivityDokumen::where("activity_id", $activity_id)->delete();
@ -677,7 +680,7 @@ class ActivityController extends Controller
// ->where('m_activity.persentase_progress', '>', 0)
->groupByRaw('m_activity.name')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
}
public function searchAnalysis(Request $request)
@ -718,7 +721,7 @@ class ActivityController extends Controller
->groupBy('assign_material_to_activity.id')
->groupBy('user_names.user_name')
->get();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet ], 200);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200);
}
// before upload file
public function importOld(Request $request)
@ -777,8 +780,7 @@ class ActivityController extends Controller
$data['activities'][$key]['weight'] = $parentWeight / $siblingsCount;
}
}
;
};
}
$projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first();
foreach ($data['activities'] as $i => $activity_row) {
@ -1137,7 +1139,6 @@ class ActivityController extends Controller
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}
return response()->json(['status' => 'success', 'message' => 'Upload successful!', 'code' => 200], 200);
}
return response()->json(['status' => 'failed', 'message' => 'Upload failed!', 'code' => 500], 500);
}

100
app/Http/Controllers/DashboardBoDController.php

@ -2,15 +2,19 @@
namespace App\Http\Controllers;
use App\Helpers\MasterFunctionsHelper;
use App\Models\User;
use App\Models\Divisi;
use App\Models\Project;
use App\Models\ProjectPhase;
use App\Models\User;
use App\Models\ProjectExpenditure;
use App\Models\UserToVersionGantt;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Models\ProjectScheduleHealth;
use App\Helpers\MasterFunctionsHelper;
use App\Models\ProjectFinancialHealth;
use App\Models\ProjectInvoice;
class DashboardBoDController extends Controller
{
@ -110,6 +114,98 @@ class DashboardBoDController extends Controller
], 200);
}
public function getDetailExpenditureColor($company_id) {
$query = ProjectExpenditure::where('company_id',$company_id)->get();
$data = [];
foreach($query as $value) {
if($value['name'] === 'Total Budget') {
$data['total_budget'] = $value['color'];
}
if($value['name'] === 'Expenditure') {
$data['total_expenditure'] = $value['color'];
}
if($value['name'] === 'Invoice') {
$data['total_invoice'] = $value['color'];
}
if($value['name'] === 'Cash In') {
$data['total_paid_invoice'] = $value['color'];
}
}
return response()->json([
'data' => [
'total_budget' => $data['total_budget'] ?? '',
'total_expenditure' => $data['total_expenditure'] ?? '',
'total_invoice' => $data['total_invoice'] ?? '',
'total_paid_invoice' => $data['total_paid_invoice'] ?? '',
]
], 200);
}
public function getDetailFinancialHealthColor($company_id) {
$query = ProjectFinancialHealth::where('company_id',$company_id)->get();
$data = [];
foreach($query as $value) {
if($value['name'] === 'Cost Overrun') {
$data['overrun'] = $value['color'];
}
if($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if($value['name'] === 'On Budget') {
$data['on-budget'] = $value['color'];
}
}
return response()->json([
'data' => [
'overrun' => $data['overrun'] ?? '',
'warning' => $data['warning'] ?? '',
'on-budget' => $data['on-budget'] ?? '',
]
], 200);
}
public function getDetailScheduleHealthColor($company_id) {
$query = ProjectScheduleHealth::where('company_id',$company_id)->get();
$data = [];
foreach($query as $value) {
if($value['name'] === 'Behind Schedule') {
$data['behind-schedule'] = $value['color'];
}
if($value['name'] === 'Early Warning') {
$data['warning'] = $value['color'];
}
if($value['name'] === 'On Schedule') {
$data['on-schedule'] = $value['color'];
}
}
return response()->json([
'data' => [
'behind-schedule' => $data['behind-schedule'] ?? '',
'warning' => $data['warning'] ?? '',
'on-schedule' => $data['on-schedule'] ?? '',
]
], 200);
}
public function getDetailInvoiceColor($company_id) {
$query = ProjectInvoice::where('company_id',$company_id)->get();
$data = [];
foreach($query as $value) {
if($value['name'] === 'Invoiced') {
$data['invoiced'] = $value['color'];
}
if($value['name'] === 'Cash In') {
$data['paid'] = $value['color'];
}
}
return response()->json([
'data' => [
'invoiced' => $data['invoiced'] ?? '',
'paid' => $data['paid'] ?? ''
]
], 200);
}
// integrasi
public function getInvoiceOutstanding($year = '%', $company_id, $all_project, $hierarchy)
{

93
app/Http/Controllers/ProjectExpenditureController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectExpenditure;
class ProjectExpenditureController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectExpenditure::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectExpenditure::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project expenditure failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectExpenditure::find($id))
return response()->json(['status'=>'failed','message'=>'data project expenditure not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_expenditure');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectExpenditure::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project expenditure, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

93
app/Http/Controllers/ProjectFinancialHealthController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectFinancialHealth;
class ProjectFinancialHealthController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectFinancialHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectFinancialHealth::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'Data financial health failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectFinancialHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data financial health not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_financial_health');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectFinancialHealth::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list financial health, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

93
app/Http/Controllers/ProjectInvoiceController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectInvoice;
class ProjectInvoiceController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectInvoice::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectInvoice::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data project invoice failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectInvoice::find($id))
return response()->json(['status'=>'failed','message'=>'data project invoice not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_invoice');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectInvoice::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list project invoice, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

93
app/Http/Controllers/ProjectScheduleHealthController.php

@ -0,0 +1,93 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\ProjectScheduleHealth;
class ProjectScheduleHealthController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required'
]);
$data = $request->all();
// Set Unique
$result = ProjectScheduleHealth::query()
->where([
['company_id',$data['company_id']],
['name', $data['name']]
])->first();
if($result) {
return response()->json(['status'=>'failed','message'=>'Name is already exists!','code'=> 500], 500);
die;
}
$data['created_by'] = $this->currentName;
if(!ProjectScheduleHealth::create($data))
return response()->json(['status'=>'failed','message'=>'Failed to add data','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'data added!','code'=>200], 200);
}
public function edit($id){
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$result = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'Failed to get data!','code'=> 404], 404);
return response()->json(['status'=>'success','code'=>200,'data'=>$result], 200);
}
public function update(Request $request, $id)
{
if(!$id || (int) $id < 0 || $id=="")
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if(!$data = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400);
if(!$data->update($request->all()))
return response()->json(['status'=>'failed','message'=>'data schedule health failed updated!','code'=>400], 400);
return response()->json(['status'=>'success','message'=>'Data berhasil disimpan!','code'=>200], 200);
}
public function delete($id)
{
if(!$data = ProjectScheduleHealth::find($id))
return response()->json(['status'=>'failed','message'=>'data schedule health not found!','code'=>400], 400);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Data gagal dihapus!','code'=> 500], 500);
return response()->json(['status'=>'success','message'=>'Data berhasil dihapus!','code'=>200], 200);
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_proyek_schedule_health');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
$dataGet = $builder->get();
$totalRecord = $countBuilder->count();
return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200);
}
public function list()
{
$data = ProjectScheduleHealth::all();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'failed get list schedule health, please try again later!','code'=>400], 400);
return response()->json(['status'=>'success','code'=>200,'data'=>$data, 'totalRecord'=>$countData], 200);
}
}

17
app/Models/ProjectExpenditure.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectExpenditure extends Model
{
protected $table = 'm_proyek_expenditure';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

17
app/Models/ProjectFinancialHealth.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectFinancialHealth extends Model
{
protected $table = 'm_proyek_financial_health';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

17
app/Models/ProjectInvoice.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectInvoice extends Model
{
protected $table = 'm_proyek_invoice';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

17
app/Models/ProjectScheduleHealth.php

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ProjectScheduleHealth extends Model
{
protected $table = 'm_proyek_schedule_health';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name', 'color', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
];
}

28
routes/web.php

@ -33,6 +33,10 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/dashboard/get-total-project-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerDivision');
$router->get('/dashboard/get-total-project-value-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectValuePerDivision');
$router->get('/dashboard/get-detail-expenditure/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getDetailExpenditure');
$router->get('/dashboard/get-detail-expenditure-color/{company_id}', 'DashboardBoDController@getDetailExpenditureColor');
$router->get('/dashboard/get-detail-financial-health-color/{company_id}', 'DashboardBoDController@getDetailFinancialHealthColor');
$router->get('/dashboard/get-detail-schedule-health-color/{company_id}', 'DashboardBoDController@getDetailScheduleHealthColor');
$router->get('/dashboard/get-detail-invoice-color/{company_id}', 'DashboardBoDController@getDetailInvoiceColor');
$router->post('/role/search', 'RoleController@search');
$router->post('/role/add', 'RoleController@add');
@ -139,6 +143,30 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->delete('/project-phase/delete/{id}', 'ProjectPhaseController@delete');
$router->get('/project-phase/list', 'ProjectPhaseController@list');
$router->post('/project-expenditure/add', 'ProjectExpenditureController@add');
$router->post('/project-expenditure/search', 'ProjectExpenditureController@search');
$router->get('/project-expenditure/edit/{id}', 'ProjectExpenditureController@edit');
$router->put('/project-expenditure/update/{id}', 'ProjectExpenditureController@update');
$router->delete('/project-expenditure/delete/{id}', 'ProjectExpenditureController@delete');
$router->post('/project-financial-health/add', 'ProjectFinancialHealthController@add');
$router->post('/project-financial-health/search', 'ProjectFinancialHealthController@search');
$router->get('/project-financial-health/edit/{id}', 'ProjectFinancialHealthController@edit');
$router->put('/project-financial-health/update/{id}', 'ProjectFinancialHealthController@update');
$router->delete('/project-financial-health/delete/{id}', 'ProjectFinancialHealthController@delete');
$router->post('/project-schedule-health/add', 'ProjectScheduleHealthController@add');
$router->post('/project-schedule-health/search', 'ProjectScheduleHealthController@search');
$router->get('/project-schedule-health/edit/{id}', 'ProjectScheduleHealthController@edit');
$router->put('/project-schedule-health/update/{id}', 'ProjectScheduleHealthController@update');
$router->delete('/project-schedule-health/delete/{id}', 'ProjectScheduleHealthController@delete');
$router->post('/project-invoice/add', 'ProjectInvoiceController@add');
$router->post('/project-invoice/search', 'ProjectInvoiceController@search');
$router->get('/project-invoice/edit/{id}', 'ProjectInvoiceController@edit');
$router->put('/project-invoice/update/{id}', 'ProjectInvoiceController@update');
$router->delete('/project-invoice/delete/{id}', 'ProjectInvoiceController@delete');
$router->post('/user-to-project/assign', 'UserProyekController@assignUserProyek');
$router->post('/request-material/add', 'RequestMaterialController@add');

Loading…
Cancel
Save