diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index ed7a377..14a759f 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -589,15 +589,13 @@ class MasterFunctionsHelper // if (new \DateTime($loopDay) < $today) { // $statusCutOfDate = true; // } - if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) { - $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); - if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { - // $tempPercentageReal[] = round($tempTtlPercentActual, 2); - $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); - } - $dateWeek[] = [$loopDay]; + $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); + if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { + // $tempPercentageReal[] = round($tempTtlPercentActual, 2); + $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); } + $dateWeek[] = [$loopDay]; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; foreach ($dataPlanM as $keyPlanM) { # hitung untuk persentase progress planning @@ -1471,15 +1469,13 @@ class MasterFunctionsHelper $dataActivityPlan = []; $dataActivityActual = []; $today = date('Y-m-d'); - if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) { - $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); - if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { - // $tempPercentageReal[] = round($tempTtlPercentActual, 2); - $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); - } - $dateWeek[] = [$loopDay]; + $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2); + if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { + // $tempPercentageReal[] = round($tempTtlPercentActual, 2); + $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2); } + $dateWeek[] = [$loopDay]; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { foreach ($dataPlanM as $keyPlanM) { @@ -1740,6 +1736,9 @@ class MasterFunctionsHelper // if($keyPlanM->duration == 0){ // $duration = 2; // Tanggal awal + if (count($keyPlanM) == 0) { + continue; + } $startDate = new DateTime($keyPlanM->planned_start); // Tanggal akhir $endDate = new DateTime($keyPlanM->planned_end); @@ -1771,6 +1770,9 @@ class MasterFunctionsHelper // hitung progress actual // if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { foreach ($dataActualM as $keyActualM) { + if (count($keyPlanM) == 0) { + continue; + } # hitung untuk persentase progress actual // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // jika total report > dari planning diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php old mode 100644 new mode 100755 index a9a56e4..44f5a2a --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -691,6 +691,7 @@ class ActivityController extends Controller 'selfTable.name', 'persentase_progress', 'selfTable.start_date', + 'selfTable.id', 'selfTable.end_date', 'selfTable.planned_start', 'selfTable.planned_end', @@ -700,9 +701,10 @@ class ActivityController extends Controller 'm_version_gantt.name_version', DB::raw('user_names.user_name as user_name'), DB::raw('SUM(report_activity_material.qty) as qty'), - 'assign_material_to_activity.qty_planning', + // DB::raw('SUM(assign_material_to_activity.qty_planning) as qty_planning'), 'assign_material_to_activity.id as join_third_id' ) + ->addSelect(DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = report_activity_material.activity_id) as qty_planning')) ->join('m_version_gantt', 'm_version_gantt.id', '=', 'selfTable.version_gantt_id') ->leftJoin('assign_hr_to_activity', 'assign_hr_to_activity.activity_id', '=', 'selfTable.id') ->leftJoin('report_activity_material', 'report_activity_material.activity_id', '=', 'selfTable.id') @@ -713,13 +715,12 @@ class ActivityController extends Controller GROUP BY activity_id) as user_names'), function ($join) { $join->on('user_names.activity_id', '=', 'selfTable.id'); }) + ->where('assign_material_to_activity.id', '=', DB::raw('report_activity_material.assign_material_id')) ->groupBy('selfTable.id') - ->groupBy('selfTable.name') - ->groupBy('selfTable.persentase_progress') ->groupBy('m_version_gantt.name_version') - ->groupBy('assign_material_to_activity.qty_planning') ->groupBy('assign_material_to_activity.id') ->groupBy('user_names.user_name') + ->groupBy('report_activity_material.activity_id') ->get(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet], 200); } diff --git a/app/Http/Controllers/AssignMaterialController.php b/app/Http/Controllers/AssignMaterialController.php index 3d78384..0d7b303 100644 --- a/app/Http/Controllers/AssignMaterialController.php +++ b/app/Http/Controllers/AssignMaterialController.php @@ -7,6 +7,7 @@ use App\Models\AssignMaterial; use App\Models\RequestMaterial; use App\Models\Activity; use App\Models\ReportActivityMaterial; +use Illuminate\Support\Facades\DB; use Datatables; class AssignMaterialController extends Controller @@ -140,28 +141,29 @@ class AssignMaterialController extends Controller $id_activity = $request->query('idact'); $data = AssignMaterial::select( - AssignMaterial::raw('SUM(qty_planning) as qty_planning'), + DB::raw('(SELECT SUM(assign_material_to_activity.qty_planning) FROM assign_material_to_activity WHERE assign_material_to_activity.activity_id = ram.activity_id) as qty_planning'), + DB::raw('SUM(ram.qty) as qty_sum'), "m.description as material_name", "assign_material_to_activity.activity_id", - "assign_material_to_activity.type" - // "assign_material_to_activity.material_id", ) ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") ->groupBy("m.description") + ->groupBy("ram.activity_id") ->groupBy("assign_material_to_activity.activity_id") - ->groupBy("assign_material_to_activity.type") ->where("assign_material_to_activity.activity_id", $id_activity)->get(); return Datatables::of($data) ->addIndexColumn() - ->addColumn('qty_sum', function($row){ - $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1") - ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") - ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") - ->groupBy("m.description") - ->where("m.description", strval($row->material_name)) - ->where("ram.activity_id", $row->activity_id)->first(); - return $val_qty_act ? $val_qty_act->qty_sum : '-'; - }) + // ->addColumn('qty_planning', function($row){ + // $val_qty_act = AssignMaterial::select(ReportActivityMaterial::raw('SUM(ram.qty) as qty_sum'),"m.description as material_name1","m.id") + // ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") + // ->join("report_activity_material as ram", "ram.assign_material_id", "=", "assign_material_to_activity.id") + // ->groupBy("m.description") + // ->groupBy("m.id") + // ->where("m.description", strval($row->material_name)) + // ->where("ram.activity_id", $row->activity_id)->first(); + // return $val_qty_act ? $val_qty_act->qty_sum : '-'; + // }) ->addColumn('status_activity', function($row){ $val_status = AssignMaterial::select("status_activity") ->join('m_req_material as m', 'm.id', '=', 'assign_material_to_activity.material_id') @@ -196,8 +198,8 @@ class AssignMaterialController extends Controller ->addColumn('action', function($row){ $dataPlan = AssignMaterial::select('assign_material_to_activity.id')->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('activity_id', $row->activity_id)->where('m.description', $row->material_name)->first(); - $actionBtn = ''; - $actionBtn .= ''; + $actionBtn = ''; + $actionBtn .= ''; return $actionBtn; }) ->rawColumns(['action'])->make(true); diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 7ef300e..78fda02 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -13,6 +13,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Password; use Illuminate\Validation\ValidationException; + class AuthController extends Controller { public function __construct() diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 02049ab..a084601 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -7,8 +7,8 @@ use Illuminate\Support\Facades\Http; use App\Models\UserToActivity; use App\Models\Activity; use App\Models\AssignMaterial; -use App\Models\User; use App\Models\Divisi; +use App\Models\User; use Laravel\Lumen\Routing\Controller as BaseController; use App\Models\ReportK3Detail; @@ -33,7 +33,6 @@ class Controller extends BaseController $this->currentDate = date("Y-m-d H:i:s"); $this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentId = auth()->user() ? auth()->user()->id : 0; - $this->companyId = auth()->user() ? auth()->user()->company_id : 0; $this->pathImage = config('assets.image'); $this->pathDocument = config('assets.project'); $this->pathActivityDocument = config('assets.activity'); diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index d82a3e9..f1c8e16 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -47,41 +47,46 @@ class DashboardBoDController extends Controller { if (empty($search)) return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); + if (empty($search)) + return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400); + $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH'); $token = config('api.adw_token'); $response = $this->curlReq($url, $token); if (@$response->data->project_no == "") - return null; + if (@$response->data->project_no == "") + return null; return $response; } - public function getCompanyCashFlow($year = '%', $company_id, $all_project, $hierarchy) + public function getCompanyCashFlow($company_id, $all_project, $hierarchy, $role_name) { - $year = $this->interpolateYear($year); $totalExpenditure = $totalInvoice = $totalPaidInvoice = 0; $totalBudgets = null; - if ($all_project) { - $totalBudgets = Project::where('mulai_proyek', 'like', $year) - ->where('company_id', $company_id) + $role = urldecode($role_name); + if ($role === "Super Admin") { + $totalBudgets = Project::sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); + } elseif (!empty($all_project)) { + $totalBudgets = Project::where('company_id', $company_id) ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); } else { - $totalBudgets = Project::where('mulai_proyek', 'like', $year) - ->where('created_by_id', $hierarchy) + $totalBudgets = Project::where('created_by_id', $hierarchy) ->sum(DB::raw('CAST("rencana_biaya" AS DOUBLE PRECISION)')); } $projects = null; - if ($all_project) { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('company_id', $company_id) + + if ($role === "Super Admin") { + $projects = Project::get(); + } elseif (!empty($all_project)) { + $projects = Project::where('company_id', $company_id) ->get(); } else { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('created_by_id', $hierarchy) + $projects = Project::where('created_by_id', $hierarchy) ->get(); } @@ -114,24 +119,32 @@ 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([ + public function getDetailExpenditureColor($role_name, $company_id) + { + $role = urldecode($role_name); + $query = null; + if ($role === 'Super Admin') { + $query = ProjectExpenditure::get(); + } else { + $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'] ?? '', @@ -139,85 +152,109 @@ class DashboardBoDController extends Controller '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([ + } + + public function getDetailFinancialHealthColor($role_name, $company_id) + { + $role = urldecode($role_name); + $query = null; + if ($role === 'Super Admin') { + $query = ProjectFinancialHealth::get(); + } else { + $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([ + } + + public function getDetailScheduleHealthColor($role_name, $company_id) + { + $role = urldecode($role_name); + $query = null; + if ($role === 'Super Admin') { + $query = ProjectScheduleHealth::get(); + } else { + $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([ + } + + public function getDetailInvoiceColor($role_name, $company_id) + { + $role = urldecode($role_name); + $query = null; + if ($role === 'Super Admin') { + $query = ProjectInvoice::get(); + } else { + $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) + public function getInvoiceOutstanding($role_name, $company_id, $all_project, $hierarchy) { - $year = $this->interpolateYear($year); + $role = urldecode($role_name); $projects = null; - if ($all_project) { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('company_id', $company_id) + if ($role === 'Super Admin') { + $projects = Project::get(); + } elseif (!empty($all_project)) { + $projects = Project::where('company_id', $company_id) ->get(); } else { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('created_by_id', $hierarchy) + $projects = Project::where('created_by_id', $hierarchy) ->get(); } @@ -241,9 +278,9 @@ class DashboardBoDController extends Controller ], 200); } - public function getTotalProjectPerScheduleHealth($year = '%', $company_id, $all_project, $hierarchy) + public function getTotalProjectPerScheduleHealth($role_name, $company_id, $all_project, $hierarchy) { - $year = $this->interpolateYear($year); + $role = urldecode($role_name); $return = [ 'behind-schedule' => 0, @@ -252,13 +289,13 @@ class DashboardBoDController extends Controller ]; $projects = null; - if ($all_project) { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('company_id', $company_id) + if ($role === 'Super Admin') { + $projects = Project::get(); + } elseif ($all_project) { + $projects = Project::where('company_id', $company_id) ->get(); } else { - $projects = Project::where('mulai_proyek', 'like', $year) - ->where('created_by_id', $hierarchy) + $projects = Project::where('created_by_id', $hierarchy) ->get(); } @@ -276,7 +313,7 @@ class DashboardBoDController extends Controller } $selisihProgress = $planningProgress - $actualProgress; try { - if ($selisihProgress > 0 && $selisihProgress <= 5) { + if ($selisihProgress > 0 && $selisihProgress <= 20) { $return['warning'] += 1; $projects[$index]->status = 'warning'; } elseif ($selisihProgress == 0) { @@ -294,20 +331,24 @@ class DashboardBoDController extends Controller return response()->json(['data' => $return, 'q' => $projects], 200); } - public function getTotalProjectScheduleHealthPerDivision($year = '%', $company_id) + public function getTotalProjectScheduleHealthPerDivision($role_name, $company_id) { - $year = $this->interpolateYear($year); - $divisions = Divisi::whereNull('parent') - ->where('company_id', $company_id) - ->whereNull('parent') - ->get(); - + $role = urldecode($role_name); + $divisions = null; + if ($role === 'Super Admin') { + $divisions = Divisi::whereNull('parent') + ->get(); + } else { + $divisions = Divisi::whereNull('parent') + ->where('company_id', $company_id) + ->get(); + } foreach ($divisions as $index => $division) { $scheduleData = new Collection(); $behindSchedule = $warning = $onSchedule = 0; - $projects = Project::where('mulai_proyek', 'like', $year)->where('divisi_id', $division->id)->get(); + $projects = Project::where('divisi_id', $division->id)->get(); foreach ($projects as $project) { $project->scurve = MasterFunctionsHelper::getSCurve($project->id); $selisihProgress = 0; @@ -342,9 +383,9 @@ class DashboardBoDController extends Controller ], 200); } - public function getTotalProjectPerBudgetHealth($year = '%', $company_id, $all_project, $hierarchy) + public function getTotalProjectPerBudgetHealth($role_name, $company_id, $all_project, $hierarchy) { - $year = $this->interpolateYear($year); + $role = urldecode($role_name); $response = [ 'data' => [ 'overrun' => 0, @@ -353,81 +394,84 @@ class DashboardBoDController extends Controller ] ]; - 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) + if ($role === 'Super Admin') { + $response['data']['overrun'] = Project::where('budget_health', 'overrun') ->count(); - } - if ($all_project) { - $response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year) - ->where('budget_health', 'overrun') + } elseif ($all_project) { + $response['data']['overrun'] = Project::where('budget_health', 'overrun') ->where('company_id', $company_id) ->count(); } else { - $response['data']['overrun'] = Project::where('mulai_proyek', 'like', $year) - ->where('budget_health', 'overrun') + $response['data']['overrun'] = Project::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') + + if ($role === 'Super Admin') { + $response['data']['overrun'] = Project::where('budget_health', 'warning') + ->count(); + } elseif ($all_project) { + $response['data']['warning'] = Project::where('budget_health', 'warning') ->where('company_id', $company_id) ->count(); } else { - $response['data']['warning'] = Project::where('mulai_proyek', 'like', $year) - ->where('budget_health', 'warning') + $response['data']['warning'] = Project::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') + if ($role === 'Super Admin') { + Log::info('on-budget'); + $response['data']['on-budget'] = Project::where('budget_health', 'on-budget') + ->count(); + } elseif ($all_project) { + $response['data']['on-budget'] = Project::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') + $response['data']['on-budget'] = Project::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, $health) { return Project::where('divisi_id', $divisi) - ->where('mulai_proyek', 'like', $year) /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('budget_health', $health) ->count(); } - public function getTotalProjectBudgetHealthPerDivision($year = '%', $company_id) + public function getTotalProjectBudgetHealthPerDivision($role_name, $company_id) { - $year = $this->interpolateYear($year); - $divisions = Divisi::select('id', 'name') - ->with('children') - ->whereNull('parent') - ->where('company_id', $company_id) - ->get(); + $role = urldecode($role_name); + $divisions = null; + if ($role === 'Super Admin') { + $divisions = Divisi::select('id', 'name') + ->with('children') + ->whereNull('parent') + ->get(); + } else { + $divisions = Divisi::select('id', 'name') + ->with('children') + ->whereNull('parent') + ->where('company_id', $company_id) + ->get(); + } + + // to do : count in more than 1 level child foreach ($divisions as $division) { $budgetData = new Collection(); - $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'overrun'), 'overrun'); - $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'warning'), 'warning'); - $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, $year, 'on-budget'), 'on-budget'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'overrun'), 'overrun'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'warning'), 'warning'); + $budgetData->prepend($this->countTotalProjectByBudgetHealthInDivision($division->id, 'on-budget'), 'on-budget'); foreach ($division->children as $d) { - $budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'overrun'); - $budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'warning'); - $budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, $year, 'on-budget'); + $budgetData['overrun'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'overrun'); + $budgetData['warning'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'warning'); + $budgetData['on-budget'] += $this->countTotalProjectByBudgetHealthInDivision($d->id, 'on-budget'); } unset($division->children); $division->budgetData = $budgetData; @@ -441,20 +485,28 @@ class DashboardBoDController extends Controller ], 200); } - public function getTotalProjectPerPhase($year = '%', $company_id, $all_project, $hierarchy) + public function getTotalProjectPerPhase($role_name, $company_id, $all_project, $hierarchy) { - $year = $this->interpolateYear($year); - $projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get(); + $role = urldecode($role_name); + $projectPhases = null; + if ($role === 'Super Admin') { + $projectPhases = ProjectPhase::orderBy('order')->get(); + } else { + $projectPhases = ProjectPhase::where('company_id', $company_id)->orderBy('order')->get(); + } + + foreach ($projectPhases as $phase) { - if ($all_project) { + if ($role === 'Super Admin') { + $phase->totalProject = Project::where('phase_id', $phase->id) + ->count(); + } elseif ($all_project) { $phase->totalProject = Project::where('phase_id', $phase->id) - ->where('mulai_proyek', 'like', $year) ->where('company_id', $company_id) ->count(); } else { $phase->totalProject = Project::where('phase_id', $phase->id) - ->where('mulai_proyek', 'like', $year) ->where('created_by_id', $hierarchy) ->count(); } @@ -466,29 +518,37 @@ class DashboardBoDController extends Controller ], 200); } - private function countTotalProjectInDivision($id, $year) + private function countTotalProjectInDivision($id) { return Project::where('divisi_id', $id) - ->where('mulai_proyek', 'like', $year) ->count(); } - public function getTotalProjectPerDivision($year = '%', $company_id) + public function getTotalProjectPerDivision($role_name, $company_id) { - $year = $this->interpolateYear($year); + $role = urldecode($role_name); + $divisions = null; + if ($role === 'Super Admin') { + $divisions = Divisi::select('id', 'name', 'parent', 'color') + ->with('children') + ->whereNull('parent') + ->get(); + } else { + $divisions = Divisi::select('id', 'name', 'parent', 'color') + ->with('children') + ->whereNull('parent') + ->where('company_id', $company_id) + ->get(); + } + - $divisions = Divisi::select('id', 'name', 'parent', 'color') - ->with('children') - ->whereNull('parent') - ->where('company_id', $company_id) - ->get(); // to do : count in more than 1 level child foreach ($divisions as $v) { - $v->total = $this->countTotalProjectInDivision($v->id, $year); + $v->total = $this->countTotalProjectInDivision($v->id); foreach ($v->children as $d) { - $v->total += $this->countTotalProjectInDivision($d->id, $year); + $v->total += $this->countTotalProjectInDivision($d->id); } unset($v->children); } @@ -498,30 +558,35 @@ class DashboardBoDController extends Controller ], 200); } - private function countTotalProjectValueInDivision($id, $year) + private function countTotalProjectValueInDivision($id) { return Project::select(DB::raw('SUM(CAST("rencana_biaya" AS DOUBLE PRECISION))')) - ->where('mulai_proyek', 'like', $year) - /* ->orWhere('akhir_proyek', 'like', $year) */ ->where('divisi_id', $id) ->pluck('sum') ->first(); } - public function getTotalProjectValuePerDivision($year = '%', $company_id) + public function getTotalProjectValuePerDivision($role_name, $company_id) { - $year = $this->interpolateYear($year); + $role = urldecode($role_name); + if ($role === 'Super Admin') { + $divisions = Divisi::select('id', 'name', 'color') + ->with('children') + ->whereNull('parent') + ->get(); + } else { + $divisions = Divisi::select('id', 'name', 'color') + ->with('children') + ->whereNull('parent') + ->where('company_id', $company_id) + ->get(); + } - $divisions = Divisi::select('id', 'name', 'color') - ->with('children') - ->whereNull('parent') - ->where('company_id', $company_id) - ->get(); foreach ($divisions as $v) { - $v->total = $this->countTotalProjectValueInDivision($v->id, $year); + $v->total = $this->countTotalProjectValueInDivision($v->id); foreach ($v->children as $d) { - $v->total += $this->countTotalProjectValueInDivision($d->id, $year); + $v->total += $this->countTotalProjectValueInDivision($d->id); } unset($v->children); } diff --git a/app/Http/Controllers/DivisiController.php b/app/Http/Controllers/DivisiController.php index d46c927..dad48a9 100644 --- a/app/Http/Controllers/DivisiController.php +++ b/app/Http/Controllers/DivisiController.php @@ -83,13 +83,26 @@ class DivisiController extends Controller public function search(Request $request) { - $payload = $request->all(); - $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); - $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; - $dataGet = $builder->get(); - $totalRecord = $countBuilder->count(); - return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); + $parentDivisi = Divisi::whereNull('parent')->with('children')->get(); + $divisions = []; + foreach ($parentDivisi as $objRow) { + $objRow->children = $this->getAllChildren($objRow); + // $objRow->key = rand(1, 1000); + $divisions[] = $objRow; + } + $countData = count($divisions); + if ($countData == 0) + return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); + + return response()->json(['status' => 'success', 'code' => 200, 'data' => $divisions, 'totalRecord' => $countData], 200); + + // $payload = $request->all(); + // $dataBuilder = $this->setUpPayload($payload, 'm_divisi'); + // $builder = $dataBuilder['builder']; + // $countBuilder = $dataBuilder['count']; + // $dataGet = $builder->get(); + // $totalRecord = $countBuilder->count(); + // return response()->json(['status' => 'success', 'code' => 200, 'data' => $dataGet, 'totalRecord' => $totalRecord], 200); //return $this->list(); // cant use builder for this case } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index c69e57d..0254307 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -51,10 +51,11 @@ class ProjectController extends Controller $this->validate($request, [ 'nama' => 'required', 'mulai_proyek' => 'required', + 'mulai_proyek' => 'required', 'akhir_proyek' => 'required', 'rencana_biaya' => 'required', 'type_proyek_id' => 'required', - 'company_id' => 'required' + 'company_id' => 'required' ]); $data = $request->all(); @@ -81,18 +82,52 @@ class ProjectController extends Controller if (empty($id) || !is_int((int)$id)) return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); - $result = Project::query() - ->from('m_proyek AS mp') - ->where('mp.id', $id) - ->selectRaw('value_proyek,mp.company_id,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); - - if (!is_null($result->first()['divisi_id'])) { - $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id') - ->addSelect(DB::raw('m_divisi.name AS nama_divisi')); - } - - $result = $result->first(); + // $result = Project::query() + // ->from('m_proyek AS mp') + // ->where('mp.id', $id) + // ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek, + // area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status'); + // if (!is_null($result->first()['divisi_id'])) { + // $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id') + // ->addSelect(DB::raw('m_divisi.name AS nama_divisi')); + // } + $result = Project::select( + 'value_proyek', + 'scoupe_of_work', + 'kode_sortname', + 'jumlah_stakeholder', + 'nama', + 'mulai_proyek', + 'akhir_proyek', + 'area_kerja', + 'rencana_biaya', + 'biaya_actual', + 'company', + 'pm_id', + 'type_proyek_id', + 'divisi_id', + 'persentase_progress', + 'keterangan', + 'durasi_proyek', + 'progress_by_worklog', + 'currency_symbol', + 'late_consequence', + 'assumtion', + 'currency_code', + 'currency_name', + 'project_objectives', + 'considered_success_when', + 'potential_risk', + 'testing_environment', + 'budget_health', + 'phase_id', + 'calculation_status', + 'md.name as divisi_name', + ) + ->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id') + ->where('m_proyek.id', $id) + ->first(); if (!$result) return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404); @@ -511,29 +546,20 @@ class ProjectController extends Controller return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); } - public function getByUser($id) { + public function getByUser($id) + { + $alias = "utp"; $userProyek = UserToProyek::query() - ->from('assign_hr_to_proyek AS ahtp') + ->from('assign_hr_to_proyek AS ' . $alias) ->where([ ['is_customer', true], ['user_id', $id] ]) - ->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id') - ->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id') - ->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id') - ->select( - 'mp.id', - 'mp.nama', - 'mp.rencana_biaya', - 'mp.type_proyek_id', - 'mp.currency_symbol', - 'mp.mulai_proyek', - 'mp.akhir_proyek', - 'm_users.name AS join_first_name', - 'm_users.username AS join_first_username', - 'm_type_proyek.name AS join_second_name', - 'm_type_proyek.name AS join_second_description' - )->get(); + ->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id') + ->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id') + ->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') + ->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name') + ->get(); $totalRecord = $userProyek->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); @@ -560,7 +586,7 @@ class ProjectController extends Controller $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); if ($result['type_proyek_id'] === 9) { // $actualEndExist = Activity::where('proyek_id', $id)->exists(); - // $query = Activity::where('proyek_id', $id); + $query = Activity::where('proyek_id', $id); $maxEndDate = Activity::where('proyek_id', $id)->select('end_date') ->orderBy('end_date', 'desc') ->first(); @@ -600,10 +626,12 @@ class ProjectController extends Controller $plannedEnd = Activity::where('version_gantt_id', $ganttId) ->orderByDesc('planned_end') ->value('planned_end'); - $result->header->start_date = $startDate; - $result->header->end_date = $maxEndDate->end_date; - $result->header->planned_start = $plannedStart; - $result->header->planned_end = $plannedEnd; + if (isset($result->header)) { + $result->header->start_date = $startDate; + $result->header->end_date = $maxEndDate->end_date; + $result->header->planned_start = $plannedStart; + $result->header->planned_end = $plannedEnd; + } return response()->json(['status' => 'success', 'code' => 200, 'data' => $result, 'gantt' => $ganttId], 200); } @@ -623,15 +651,15 @@ class ProjectController extends Controller ->value('end_date'); if (isset($payload['till_date'])) { if (isset($payload['scurve'])) { - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); + $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); } else { - $overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); + $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date', '<=', $endDate)->orderBy('end_date', 'asc')->get(); } } else { if (isset($payload['scurve'])) { - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); + $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('m_activity.proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); } else { - $overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); + $overdueActivities = Activity::join('m_version_gantt', 'm_activity.version_gantt_id', '=', 'm_version_gantt.id')->where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); } } $result->overdueActivities = $overdueActivities; diff --git a/app/Http/Controllers/ReportActivityMaterialController.php b/app/Http/Controllers/ReportActivityMaterialController.php index e451129..a55e15f 100644 --- a/app/Http/Controllers/ReportActivityMaterialController.php +++ b/app/Http/Controllers/ReportActivityMaterialController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Helpers\MasterFunctionsHelper; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use App\Models\ReportActivityMaterial; use App\Models\Activity; use App\Models\AssignMaterial; @@ -64,10 +65,18 @@ class ReportActivityMaterialController extends Controller } else { $sumAssignMaterial = AssignMaterial::where('activity_id', $request->activity_id)->sum('qty_planning'); $sumReportActivityMaterial = ReportActivityMaterial::where('activity_id', $request->activity_id)->sum('qty'); + // if actual >= plan + if ($sumReportActivityMaterial >= $sumAssignMaterial){ + $persentaseProgress = 95; + }else{ + // actual < plan + $persentaseProgress = $sumReportActivityMaterial/$sumAssignMaterial*100; + } + $dataUpdate = array( "actual_start" => null, - "actual_end" => null, - "persentase_progress" => $sumReportActivityMaterial/$sumAssignMaterial*100, + "actual_end" => null, + "persentase_progress" => $persentaseProgress, "updated_by" => $this->currentName ); if ($sumReportActivityMaterial > 0) { @@ -124,8 +133,10 @@ class ReportActivityMaterialController extends Controller public function datatables(Request $request){ $id_activity = $request->query('idAct'); + $id_am = $request->query('idAmi'); $type = $request->query('type'); $materialName = $request->query('materialName'); + $materialId = $request->query('materialId'); if($type == 'plan'){ $activity = Activity::findOrFail($id_activity); $baselineDuration = 0; @@ -135,6 +146,7 @@ class ReportActivityMaterialController extends Controller $data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom") ->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id") ->where('assign_material_to_activity.activity_id', $id_activity) + ->where('assign_material_to_activity.id', $id_am) ->where('m.description', $materialName) ->orderBy('assign_material_to_activity.id', 'asc') ->get(); diff --git a/app/Http/Controllers/UserToActivityController.php b/app/Http/Controllers/UserToActivityController.php index b387c24..bfe4f22 100644 --- a/app/Http/Controllers/UserToActivityController.php +++ b/app/Http/Controllers/UserToActivityController.php @@ -158,7 +158,7 @@ class UserToActivityController extends Controller $dataBuilder = $this->setUpPayload($payload, 'assign_hr_to_activity'); $builder = $dataBuilder['builder']; - $countBuilder = $dataBuilder['count']; + // $countBuilder = $dataBuilder['count']; if (isset($join_column)) { $startDate = $join_column['start_date']; $endDate = $join_column['end_date']; @@ -187,8 +187,35 @@ class UserToActivityController extends Controller } $dataGet = $filteredData; } - $totalRecord = $countBuilder->count(); - return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>$totalRecord], 200); + // $totalRecord = $countBuilder->count(); + return response()->json(['status'=>'success','code'=>200,'data'=>$dataGet, 'totalRecord'=>count($dataGet)], 200); + } + + public function activityUser(Request $request){ + $payload = $request->all(); + $activity = DB::table('m_activity as ma') + ->select('ahta.id', 'ma.id as activity_id', 'ma.proyek_id', 'ma.name as join_second_name', 'ma.start_date as join_second_start_date', + 'ma.end_date as join_second_end_date', 'ma.persentase_progress', 'mvg.name_version', 'mp.nama as nama_proyek', 'mp.type_proyek_id') + ->join('assign_hr_to_activity as ahta', 'ahta.activity_id', '=', 'ma.id') + ->join('m_version_gantt as mvg', 'mvg.id', '=', 'ma.version_gantt_id') + ->join('m_proyek as mp', 'mp.id', '=', 'ma.proyek_id') + ->where('ahta.user_id', $payload['user_id']) + ->where('ma.start_date', '<=', $payload['end_date']) + ->where('ma.end_date', '>=', $payload['start_date']) + ->where('ma.proyek_id', $payload['proyek_id']) + ->get(); + + if ($payload['status'] != "") { + $filteredData = []; + foreach ($activity as $value) { + $assignMaterial = AssignMaterial::where('activity_id', $value->activity_id)->first(); + if ($assignMaterial->status_activity == $payload['status']) { + $filteredData[] = $value; + } + } + $activity = $filteredData; + } + return response()->json(['status'=>'success','code'=>200,'data'=>$activity, 'totalRecord'=>count($activity)], 200); } public function list() diff --git a/app/Http/Controllers/UserToProyekController.php b/app/Http/Controllers/UserToProyekController.php index 0e8736e..1f6e55c 100644 --- a/app/Http/Controllers/UserToProyekController.php +++ b/app/Http/Controllers/UserToProyekController.php @@ -50,7 +50,8 @@ class UserToProyekController extends Controller "user_id" => $item, "proyek_id" => $request->proyek_id, "created_by" => $this->currentName, - 'is_customer'=>true + 'is_customer'=>true, + 'project_role'=> $request->project_role ); $result = UserToProyek::create($dataInsert); diff --git a/app/Http/Controllers/VersionGanttController.php b/app/Http/Controllers/VersionGanttController.php index 37cb585..91984a2 100644 --- a/app/Http/Controllers/VersionGanttController.php +++ b/app/Http/Controllers/VersionGanttController.php @@ -121,11 +121,9 @@ class VersionGanttController extends Controller ->where('m_activity.parent_id', null) ->get(); foreach ($progress as $item) { - if ($item->persentase_progress) { - $item->progress = $item->persentase_progress; - $item->bobot = $item->bobot_planning; - $item->save(); - } + $item->progress = $item->persentase_progress; + $item->bobot = $item->bobot_planning; + $item->save(); } } diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 6e8b9fe..425f0a5 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -34,6 +34,5 @@ class HumanResource extends Model 'updated_by', 'divisi_id', 'status_boundary', - 'company_id' ]; } diff --git a/app/Models/Project.php b/app/Models/Project.php index 43c0a1e..cfd463f 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -15,6 +15,7 @@ class Project extends Model 'kode_sortname', 'jumlah_stakeholder', 'nama', + 'nickname', 'mulai_proyek', 'akhir_proyek', 'area_kerja', @@ -23,8 +24,10 @@ class Project extends Model 'biaya_actual', 'company', 'pm_id', + 'scoupe_of_work', 'type_proyek_id', 'divisi_id', + 'value_proyek', 'persentase_progress', 'keterangan', 'durasi_proyek', diff --git a/app/Models/ProjectRole.php b/app/Models/ProjectRole.php index 9d15c1a..52a7b46 100644 --- a/app/Models/ProjectRole.php +++ b/app/Models/ProjectRole.php @@ -12,6 +12,6 @@ class ProjectRole extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' + 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; } diff --git a/app/Models/RoleMenu.php b/app/Models/RoleMenu.php index 2a59ede..3540ea6 100644 --- a/app/Models/RoleMenu.php +++ b/app/Models/RoleMenu.php @@ -12,6 +12,6 @@ class RoleMenu extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete" + 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; } diff --git a/app/Models/Satuan.php b/app/Models/Satuan.php index 9779db6..05305af 100644 --- a/app/Models/Satuan.php +++ b/app/Models/Satuan.php @@ -12,6 +12,6 @@ class Satuan extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id' + 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; } diff --git a/routes/web.php b/routes/web.php index 85251b2..2a75e85 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,20 +23,20 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->group(['middleware' => ['auth', 'cors']], function () use ($router) { - $router->get('/dashboard/get-company-cashflow/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure - $router->get('/dashboard/get-invoice-outstanding/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in - $router->get('/dashboard/get-total-project-per-schedule-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); - $router->get('/dashboard/get-total-project-per-budget-health/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); - $router->get('/dashboard/get-total-project-schedule-health-per-division/{year}/{company_id}/{all_project}/{hierarchy}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); - $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-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->get('/dashboard/get-company-cashflow/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getCompanyCashFlow'); // project expenditure + $router->get('/dashboard/get-invoice-outstanding/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getInvoiceOutstanding'); // project invoice vs cash in + $router->get('/dashboard/get-total-project-per-schedule-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerScheduleHealth'); + $router->get('/dashboard/get-total-project-per-budget-health/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerBudgetHealth'); + $router->get('/dashboard/get-total-project-schedule-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectScheduleHealthPerDivision'); + $router->get('/dashboard/get-total-project-budget-health-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectBudgetHealthPerDivision'); + $router->get('/dashboard/get-total-project-per-phase/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerPhase'); + $router->get('/dashboard/get-total-project-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectPerDivision'); + $router->get('/dashboard/get-total-project-value-per-division/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getTotalProjectValuePerDivision'); + $router->get('/dashboard/get-detail-expenditure/{company_id}/{all_project}/{hierarchy}/{role_name}', 'DashboardBoDController@getDetailExpenditure'); + $router->get('/dashboard/get-detail-expenditure-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailExpenditureColor'); + $router->get('/dashboard/get-detail-financial-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailFinancialHealthColor'); + $router->get('/dashboard/get-detail-schedule-health-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailScheduleHealthColor'); + $router->get('/dashboard/get-detail-invoice-color/{company_id}/{role_name}', 'DashboardBoDController@getDetailInvoiceColor'); $router->post('/role/search', 'RoleController@search'); $router->post('/role/add', 'RoleController@add'); @@ -78,6 +78,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->post('/project/get-overdue-activities', 'ProjectController@getOverdueActivities'); $router->post('/project/get-integration-invoice', 'ProjectController@getInvoiceIntegration'); $router->post('/project/get-report-distribution', 'ProjectController@getReportDistribution'); + $router->get('/project/get-integration-project-cost={name}', 'ProjectController@getProjectCostIntegration'); /* $router->get('/project/get-expenditure/{id}/{date?}', 'ProjectController@getExpenditure'); */ @@ -228,6 +229,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro $router->get('/user-to-activity/edit/{id}', 'UserToActivityController@edit'); $router->put('/user-to-activity/update/{id}', 'UserToActivityController@update'); $router->post('/user-to-activity/search', 'UserToActivityController@search'); + $router->post('/user-to-activity/by-date-status', 'UserToActivityController@activityUser'); $router->post('/user-to-activity/search-analysis', 'UserToActivityController@searchAnalysis'); $router->post('/user-to-activity/list-filtered', 'UserToActivityController@listFiltered'); $router->delete('/user-to-activity/delete/{id}', 'UserToActivityController@delete');