Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-backend into dev-wahyu

pull/1/head
wahyu 11 months ago
parent
commit
f5990005e9
  1. 607
      app/Helpers/MasterFunctionsHelper.php
  2. 37
      app/Http/Controllers/AuthController.php
  3. 110
      app/Http/Controllers/CompanyController.php
  4. 287
      app/Http/Controllers/Controller.php
  5. 32
      app/Http/Controllers/DashboardBoDController.php
  6. 195
      app/Http/Controllers/MenuCompanyController.php
  7. 627
      app/Http/Controllers/ProjectController.php
  8. 1
      app/Http/Controllers/UserToActivityController.php
  9. 37
      app/Models/Company.php
  10. 36
      app/Models/Divisi.php
  11. 3
      app/Models/HumanResource.php
  12. 27
      app/Models/MenuCompany.php
  13. 22
      app/Models/Project.php
  14. 2
      app/Models/ProjectPhase.php
  15. 2
      app/Models/ProjectRole.php
  16. 2
      app/Models/ProjectType.php
  17. 2
      app/Models/Role.php
  18. 2
      app/Models/RoleMenu.php
  19. 2
      app/Models/Satuan.php
  20. 34
      routes/web.php

607
app/Helpers/MasterFunctionsHelper.php

@ -36,10 +36,11 @@ class MasterFunctionsHelper
return json_decode($output); return json_decode($output);
} }
public static function countDays($ganttId, $start, $end){ public static function countDays($ganttId, $start, $end)
{
$dayOffs = VersionGantt::where('id', $ganttId)->first()->config_dayoff; $dayOffs = VersionGantt::where('id', $ganttId)->first()->config_dayoff;
$diff = date_diff($start, $end); $diff = date_diff($start, $end);
$endCount = clone $end; $endCount = clone $end;
$duration = $diff->days + 1; $duration = $diff->days + 1;
$daysRemaining = $duration; $daysRemaining = $duration;
// Loop until the remaining days become zero // Loop until the remaining days become zero
@ -191,7 +192,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday'); $end->modify('next Friday');
$end->modify('next Friday'); $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
$actualMaxDate = DB::table('assign_material_to_activity as ama') $actualMaxDate = DB::table('assign_material_to_activity as ama')
@ -279,21 +280,20 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyPlanM->id) ->where('activity_id', '=', $keyPlanM->id)
->groupBy('activity_id') ->groupBy('activity_id')
->first(); ->first();
if($keyPlanM->duration){ if ($keyPlanM->duration) {
$weekCount = $keyPlanM->duration / 7; $weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7; $weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; // $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; $weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration; // $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{ } else {
// $weeklyProgress = 0; // $weeklyProgress = 0;
$weekCount = 1 / 7; $weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7; $weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; // $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; $weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
} }
// $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0; // $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0;
// $weeklyProgress = $weeklyPlan * $keyPlanM->bobot_planning; // $weeklyProgress = $weeklyPlan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id; $dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
@ -390,7 +390,7 @@ class MasterFunctionsHelper
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
if ($date < $today) { if ($date < $today) {
$tempPercentageReal[] = round($tempTtlPercentActual, 2); $tempPercentageReal[] = round($tempTtlPercentActual, 2);
} }
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) { if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break; break;
@ -399,7 +399,7 @@ class MasterFunctionsHelper
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2)); $tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2); $tempPercentagePlan[] = round($sumPercentagePlan, 2);
if ($date < $today) { if ($date < $today) {
$tempPercentageReal[] = round($sumPercentageActual, 2); $tempPercentageReal[] = round($sumPercentageActual, 2);
} }
} }
} }
@ -422,9 +422,9 @@ class MasterFunctionsHelper
$potential = "SAVING"; $potential = "SAVING";
} else { } else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN"; $potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
@ -485,7 +485,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P1D'); $interval = new \DateInterval('P1D');
} else { } else {
$actualMaxDate = DB::table('assign_material_to_activity as ama') $actualMaxDate = DB::table('assign_material_to_activity as ama')
@ -528,28 +528,32 @@ class MasterFunctionsHelper
// $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); // $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d");
$tempDate[] = array($dt->format("Y-m-d")); $tempDate[] = array($dt->format("Y-m-d"));
$dataPlanM = DB::table('m_activity') $dataPlanM = DB::table('m_activity')
->where('type_activity', 'task') ->where('type_activity', 'task')
->where('bobot_planning', '>', 0) ->where('bobot_planning', '>', 0)
->where('version_gantt_id', $keyGantt['id']) ->where('version_gantt_id', $keyGantt['id'])
->whereDate('planned_start', '<=', $loopDay) ->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay) ->whereDate('planned_end', '>=', $loopDay)
->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end') ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end')
->get(); ->get();
$dataActualM = DB::table('report_activity_material as ram') $dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id') ->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name', ->select(
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'), 'ram.activity_id',
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'), 'ram.qty as qty_actual',
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'), 'ma.bobot_planning',
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report') 'ma.name',
) DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report')
)
->where('ram.report_date', $loopDay) ->where('ram.report_date', $loopDay)
->where('ma.version_gantt_id', $keyGantt['id']) ->where('ma.version_gantt_id', $keyGantt['id'])
->get(); ->get();
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = date('Y-m-d'); $today = date('Y-m-d');
$statusCutOfDate = false; $statusCutOfDate = false;
@ -560,22 +564,22 @@ class MasterFunctionsHelper
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
} }
$dateWeek[] = [$loopDay]; $dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning # hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){ // if($keyPlanM->duration == 0){
// $duration = 2; // $duration = 2;
// Tanggal awal // Tanggal awal
$startDate = new DateTime($keyPlanM->planned_start); $startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir // Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end); $endDate = new DateTime($keyPlanM->planned_end);
// Menghitung selisih hari // Menghitung selisih hari
$interval = $startDate->diff($endDate); $interval = $startDate->diff($endDate);
// Mengambil hasil selisih hari // Mengambil hasil selisih hari
$duration = (int) $interval->days+1; $duration = (int) $interval->days + 1;
// }else{ // }else{
// $duration = $keyPlanM->duration + 2; // $duration = $keyPlanM->duration + 2;
// } // }
@ -600,22 +604,21 @@ class MasterFunctionsHelper
# hitung untuk persentase progress actual # hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ if ($keyActualM->sum_qty_actual > $keyActualM->qty_plan) {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * $keyActualM->bobot_planning; $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * $keyActualM->bobot_planning;
}else{ } else {
// jika total report < dari planning // jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; // $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if($keyActualM->qty_actual == 0){ if ($keyActualM->qty_actual == 0) {
$progressActualWeek = 0; $progressActualWeek = 0;
}else{ } else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
} }
} }
if($keyActualM->status_activity == 'done'){ if ($keyActualM->status_activity == 'done') {
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report; $progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
} } else {
else{ $progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek;
} }
$dataActivityActual[] = array( $dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek, 'progressActualDay' => $progressActualWeek,
@ -626,7 +629,7 @@ class MasterFunctionsHelper
'sum_qty_actual' => $keyActualM->sum_qty_actual, 'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name 'name' => $keyActualM->name
); );
$tmpProgressActualWeek += $progressActualWeek; $tmpProgressActualWeek += $progressActualWeek;
} }
@ -637,20 +640,20 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual, "activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek, "tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek "progressPlanWeek" => $tmpProgressPlanWeek
); );
} }
$dataFinal[] = array( $dataFinal[] = array(
// "date" => $dateWeek, // "date" => $dateWeek,
"proyek_name" => $dataProject->nama, "proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek, "data" => [
"percentagePlan" => $progressPlanKomulatifWeek, "date" => $dateWeek,
"percentageReal" => $progressActualKomulatifWeek, "percentagePlan" => $progressPlanKomulatifWeek,
"data_details" => $dataActivityPlanDate "percentageReal" => $progressActualKomulatifWeek,
], "data_details" => $dataActivityPlanDate
],
"gantt" => $keyGantt "gantt" => $keyGantt
); );
@ -694,7 +697,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday'); $end->modify('next Friday');
$end->modify('next Friday'); $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
// $maxDate = DB::table('assign_material_to_activity as ama') // $maxDate = DB::table('assign_material_to_activity as ama')
@ -845,17 +848,17 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id) ->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC') ->orderBy('status_activity', 'ASC')
->first(); ->first();
if (!isset($checkStatusActivity)) { if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [ $checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id, 'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open' 'status_activity' => 'open'
]; ];
} }
if ($sumVolActual->ttl_qty_plan == "0") { if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0; $actual = 0;
} else { } else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan; $actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
} }
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning; $dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; // $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){ // if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
@ -863,7 +866,7 @@ class MasterFunctionsHelper
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount; $sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
if ( $actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { if ($actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100); $sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
@ -898,7 +901,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual; $tempTtlPercentActual += $sumPercentageActual;
// todo // todo
// if ($tempTtlPercentPlan >= 100) // if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100; // $tempTtlPercentPlan = 100;
@ -942,7 +945,7 @@ class MasterFunctionsHelper
} }
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"percentage" => $tempPercentage, "percentage" => $tempPercentage,
@ -1006,7 +1009,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
$end->modify('next Friday'); $end->modify('next Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
// $maxDate = DB::table('assign_material_to_activity as ama') // $maxDate = DB::table('assign_material_to_activity as ama')
@ -1101,20 +1104,19 @@ class MasterFunctionsHelper
->groupBy('activity_id') ->groupBy('activity_id')
->first(); ->first();
if($keyPlanM->duration){ if ($keyPlanM->duration) {
$weekCount = $keyPlanM->duration / 7; $weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7; $weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; // $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; $weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration; // $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{ } else {
// $weeklyProgress = 0; // $weeklyProgress = 0;
$weekCount = 1 / 7; $weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7; $weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; // $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning; $weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
}
// $weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount; // $weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount;
// $weeklyProgress = 80; // $weeklyProgress = 80;
@ -1172,17 +1174,17 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id) ->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC') ->orderBy('status_activity', 'ASC')
->first(); ->first();
if (!isset($checkStatusActivity)) { if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [ $checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id, 'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open' 'status_activity' => 'open'
]; ];
} }
if ($sumVolActual->ttl_qty_plan == "0") { if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0; $actual = 0;
} else { } else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan; $actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
} }
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning; $dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; // $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){ // if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
@ -1190,7 +1192,7 @@ class MasterFunctionsHelper
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount; $sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
if ( $actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { if ($actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) {
$sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100); $sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100);
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else { } else {
@ -1228,7 +1230,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual; $tempTtlPercentActual += $sumPercentageActual;
// todo // todo
// if ($tempTtlPercentPlan >= 100) // if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100; // $tempTtlPercentPlan = 100;
@ -1277,7 +1279,7 @@ class MasterFunctionsHelper
// $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; // $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
// $lastReal = $tempPercentageReal[count($tempPercentageReal) < 1 ? count($tempPercentageReal) : count($tempPercentageReal) - 1]; // $lastReal = $tempPercentageReal[count($tempPercentageReal) < 1 ? count($tempPercentageReal) : count($tempPercentageReal) - 1];
// $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; // $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array( $dataResponse = array(
"date" => $tempDate, "date" => $tempDate,
"start" => $minDate, "start" => $minDate,
@ -1349,10 +1351,10 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P1D'); $interval = new \DateInterval('P1D');
} else { } else {
$maxDate = $dataProject->akhir_proyek; $maxDate = $dataProject->akhir_proyek;
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate);
$end = new \DateTime($end->format('Y-m-d') . ' Friday'); $end = new \DateTime($end->format('Y-m-d') . ' Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
@ -1409,122 +1411,125 @@ class MasterFunctionsHelper
// } // }
// } else { // } else {
$dataPlanM = DB::table('m_activity') $dataPlanM = DB::table('m_activity')
->where('type_activity', 'task') ->where('type_activity', 'task')
->where('bobot_planning', '>', 0) ->where('bobot_planning', '>', 0)
->where('proyek_id', $projectId) ->where('proyek_id', $projectId)
->whereDate('planned_start', '<=', $loopDay) ->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay) ->whereDate('planned_end', '>=', $loopDay)
->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end') ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end')
->get(); ->get();
$dataActualM = DB::table('report_activity_material as ram') $dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id') ->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name', ->select(
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'), 'ram.activity_id',
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'), 'ram.qty as qty_actual',
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'), 'ma.bobot_planning',
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report') 'ma.name',
) DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report')
)
->where('ram.report_date', $loopDay) ->where('ram.report_date', $loopDay)
->where('ma.proyek_id', $projectId) ->where('ma.proyek_id', $projectId)
->get(); ->get();
// } // }
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = date('Y-m-d'); $today = date('Y-m-d');
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
} }
$dateWeek[] = [$loopDay]; $dateWeek[] = [$loopDay];
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { // if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning # hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){ // if($keyPlanM->duration == 0){
// $duration = 2; // $duration = 2;
// Tanggal awal // Tanggal awal
$startDate = new DateTime($keyPlanM->planned_start); $startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir // Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end); $endDate = new DateTime($keyPlanM->planned_end);
// Menghitung selisih hari // Menghitung selisih hari
$interval = $startDate->diff($endDate); $interval = $startDate->diff($endDate);
// Mengambil hasil selisih hari // Mengambil hasil selisih hari
$duration = (int) $interval->days+1; $duration = (int) $interval->days + 1;
// }else{ // }else{
// $duration = $keyPlanM->duration + 2; // $duration = $keyPlanM->duration + 2;
// } // }
// $startPlan = new DateTime($keyPlanM->planned_start); // $startPlan = new DateTime($keyPlanM->planned_start);
// $endPlan = new DateTime($keyPlanM->planned_end); // $endPlan = new DateTime($keyPlanM->planned_end);
// $interval = $startPlan->diff($endPlan); // $interval = $startPlan->diff($endPlan);
// // Mengambil hasil selisih hari // // Mengambil hasil selisih hari
// $duration = $interval->days; // $duration = $interval->days;
// 2023-07-26 // 2023-07-26
$progressPlanWeek = $keyPlanM->bobot_planning / $duration; $progressPlanWeek = $keyPlanM->bobot_planning / $duration;
$dataActivityPlan[] = array( $dataActivityPlan[] = array(
'progressPlanDay' => $progressPlanWeek, 'progressPlanDay' => $progressPlanWeek,
'name' => $keyPlanM->name, 'name' => $keyPlanM->name,
'bobot_p' => $keyPlanM->bobot_planning, 'bobot_p' => $keyPlanM->bobot_planning,
'duration' => $keyPlanM->duration 'duration' => $keyPlanM->duration
); );
$tmpProgressPlanWeek += $progressPlanWeek; $tmpProgressPlanWeek += $progressPlanWeek;
} }
// } // }
// hitung progress actual // hitung progress actual
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { // if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) { foreach ($dataActualM as $keyActualM) {
# hitung untuk persentase progress actual # hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ if ($keyActualM->sum_qty_actual > $keyActualM->qty_plan) {
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100; $progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) * $keyActualM->bobot_planning / 100;
}else{ } else {
// jika total report < dari planning // jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; // $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if($keyActualM->qty_actual == 0){ if ($keyActualM->qty_actual == 0) {
$progressActualWeek = 0; $progressActualWeek = 0;
}else{ } else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
}
}
if($keyActualM->status_activity == 'done'){
// if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
// }
// if($progressActualWeek > $keyActualM->bobot_planning){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_actual == 0){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
// }else {
// $progressActualWeek = $progressActualWeek;
// }
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
}
else{
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek;
} }
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
'qty_act' => $keyActualM->qty_actual,
'bobot_p' => $keyActualM->bobot_planning,
'qty_plan' => $keyActualM->qty_plan,
'status_activity' => $keyActualM->status_activity,
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
} }
if ($keyActualM->status_activity == 'done') {
// if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
// }
// if($progressActualWeek > $keyActualM->bobot_planning){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_actual == 0){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
// }else {
// $progressActualWeek = $progressActualWeek;
// }
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
'qty_act' => $keyActualM->qty_actual,
'bobot_p' => $keyActualM->bobot_planning,
'qty_plan' => $keyActualM->qty_plan,
'status_activity' => $keyActualM->status_activity,
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
}
// } // }
$dataActivityPlanDate[] = array( $dataActivityPlanDate[] = array(
@ -1534,18 +1539,18 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual, "activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek, "tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek "progressPlanWeek" => $tmpProgressPlanWeek
); );
} }
$dataFinal[] = array( $dataFinal[] = array(
// "date" => $dateWeek, // "date" => $dateWeek,
"proyek_name" => $dataProject->nama, "proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek, "data" => [
"percentagePlan" => $progressPlanKomulatifWeek, "date" => $dateWeek,
"percentageReal" => $progressActualKomulatifWeek "percentagePlan" => $progressPlanKomulatifWeek,
// "data_details" => $dataActivityPlanDate "percentageReal" => $progressActualKomulatifWeek
] // "data_details" => $dataActivityPlanDate
]
); );
return $dataFinal; return $dataFinal;
@ -1592,10 +1597,10 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' Friday'); $end = new \DateTime($maxDate . ' Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P1D'); $interval = new \DateInterval('P1D');
} else { } else {
$maxDate = $dataProject->akhir_proyek; $maxDate = $dataProject->akhir_proyek;
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate);
$end = new \DateTime($end->format('Y-m-d') . ' Friday'); $end = new \DateTime($end->format('Y-m-d') . ' Friday');
// $end->modify('next Friday'); // $end->modify('next Friday');
@ -1661,126 +1666,129 @@ class MasterFunctionsHelper
->whereDate('planned_start', '<=', $loopDay) ->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay) ->whereDate('planned_end', '>=', $loopDay)
->select('ma.name', 'ma.bobot_planning', 'ma.biaya_actual', 'ma.duration', 'ma.persentase_progress', 'ma.id', 'ma.planned_start', 'ma.planned_end') ->select('ma.name', 'ma.bobot_planning', 'ma.biaya_actual', 'ma.duration', 'ma.persentase_progress', 'ma.id', 'ma.planned_start', 'ma.planned_end')
->get(); ->get();
$dataActualM = DB::table('m_hierarchy_ftth as mhf') $dataActualM = DB::table('m_hierarchy_ftth as mhf')
->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id') ->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id')
->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.id') ->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.id')
->join('report_activity_material as ram', 'ram.activity_id', '=', 'ma.id') ->join('report_activity_material as ram', 'ram.activity_id', '=', 'ma.id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', 'ma.name', ->select(
DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'), 'ram.activity_id',
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'), 'ram.qty as qty_actual',
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'), 'ma.bobot_planning',
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report') 'ma.name',
) DB::raw('(SELECT SUM(amta.qty_planning) FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS qty_plan'),
DB::raw('(SELECT SUM(ram.qty) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS sum_qty_actual'),
DB::raw('(SELECT DISTINCT status_activity FROM assign_material_to_activity amta WHERE amta.activity_id = ram.activity_id) AS status_activity'),
DB::raw('(SELECT COUNT(id) FROM report_activity_material ram WHERE ram.activity_id = ma.id) AS count_report')
)
->where('ram.report_date', $loopDay) ->where('ram.report_date', $loopDay)
// ->where('ma.proyek_id', $projectId) // ->where('ma.proyek_id', $projectId)
->where('mhf.project_id', $projectId) ->where('mhf.project_id', $projectId)
->get(); ->get();
// } // }
$dataActivityPlan = []; $dataActivityPlan = [];
$dataActivityActual = []; $dataActivityActual = [];
$today = date('Y-m-d'); $today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2); // $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
} }
$dateWeek[] = [$loopDay]; $dateWeek[] = [$loopDay];
} }
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) { // if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) { foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning # hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){ // if($keyPlanM->duration == 0){
// $duration = 2; // $duration = 2;
// Tanggal awal // Tanggal awal
if (count($keyPlanM) == 0) { if (count($keyPlanM) == 0) {
continue; continue;
}
$startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end);
// Menghitung selisih hari
$interval = $startDate->diff($endDate);
// Mengambil hasil selisih hari
$duration = (int) $interval->days+1;
// }else{
// $duration = $keyPlanM->duration + 2;
// }
// $startPlan = new DateTime($keyPlanM->planned_start);
// $endPlan = new DateTime($keyPlanM->planned_end);
// $interval = $startPlan->diff($endPlan);
// // Mengambil hasil selisih hari
// $duration = $interval->days;
// 2023-07-26
$progressPlanWeek = $keyPlanM->bobot_planning / $duration;
$dataActivityPlan[] = array(
'progressPlanDay' => $progressPlanWeek,
'name' => $keyPlanM->name,
'bobot_p' => $keyPlanM->bobot_planning,
'duration' => $keyPlanM->duration
);
$tmpProgressPlanWeek += $progressPlanWeek;
} }
$startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end);
// Menghitung selisih hari
$interval = $startDate->diff($endDate);
// Mengambil hasil selisih hari
$duration = (int) $interval->days + 1;
// }else{
// $duration = $keyPlanM->duration + 2;
// }
// $startPlan = new DateTime($keyPlanM->planned_start);
// $endPlan = new DateTime($keyPlanM->planned_end);
// $interval = $startPlan->diff($endPlan);
// // Mengambil hasil selisih hari
// $duration = $interval->days;
// 2023-07-26
$progressPlanWeek = $keyPlanM->bobot_planning / $duration;
$dataActivityPlan[] = array(
'progressPlanDay' => $progressPlanWeek,
'name' => $keyPlanM->name,
'bobot_p' => $keyPlanM->bobot_planning,
'duration' => $keyPlanM->duration
);
$tmpProgressPlanWeek += $progressPlanWeek;
}
// } // }
// hitung progress actual // hitung progress actual
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) { // if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) { foreach ($dataActualM as $keyActualM) {
if (count($keyPlanM) == 0) { if (count($keyPlanM) == 0) {
continue; continue;
} }
# hitung untuk persentase progress actual # hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning // jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ if ($keyActualM->sum_qty_actual > $keyActualM->qty_plan) {
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100; $progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) * $keyActualM->bobot_planning / 100;
}else{ } else {
// jika total report < dari planning // jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; // $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if($keyActualM->qty_actual == 0){ if ($keyActualM->qty_actual == 0) {
$progressActualWeek = 0; $progressActualWeek = 0;
}else{ } else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning; $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
}
}
if($keyActualM->status_activity == 'done'){
// if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
// }
// if($progressActualWeek > $keyActualM->bobot_planning){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_actual == 0){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
// }else {
// $progressActualWeek = $progressActualWeek;
// }
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
}
else{
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek;
} }
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
'qty_act' => $keyActualM->qty_actual,
'bobot_p' => $keyActualM->bobot_planning,
'qty_plan' => $keyActualM->qty_plan,
'status_activity' => $keyActualM->status_activity,
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
} }
if ($keyActualM->status_activity == 'done') {
// if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
// }
// if($progressActualWeek > $keyActualM->bobot_planning){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_actual == 0){
// $progressActualWeek = $keyActualM->bobot_planning;
// }else if($keyActualM->qty_plan == $keyActualM->sum_qty_actual){
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
// }else {
// $progressActualWeek = $progressActualWeek;
// }
// $progressActualWeek = $progressActualWeek > $keyActualM->bobot_planning ? $keyActualM->bobot_planning : $progressActualWeek;
// jika report lebih dari 1 x, maka harusnya di bagi sabanyak jumlah report,
// contoh ada 3 report, report ke 1 adalah 5 maka 100/3 dan di looping
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
'qty_act' => $keyActualM->qty_actual,
'bobot_p' => $keyActualM->bobot_planning,
'qty_plan' => $keyActualM->qty_plan,
'status_activity' => $keyActualM->status_activity,
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
}
// } // }
$dataActivityPlanDate[] = array( $dataActivityPlanDate[] = array(
@ -1790,18 +1798,18 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual, "activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek, "tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek "progressPlanWeek" => $tmpProgressPlanWeek
); );
} }
$dataFinal[] = array( $dataFinal[] = array(
// "date" => $dateWeek, // "date" => $dateWeek,
"proyek_name" => $dataProject->nama, "proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek, "data" => [
"percentagePlan" => $progressPlanKomulatifWeek, "date" => $dateWeek,
"percentageReal" => $progressActualKomulatifWeek "percentagePlan" => $progressPlanKomulatifWeek,
// "data_details" => $dataActivityPlanDate "percentageReal" => $progressActualKomulatifWeek
] // "data_details" => $dataActivityPlanDate
]
); );
return $dataFinal; return $dataFinal;
@ -1845,7 +1853,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['end_date'])) { if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date']; $maxDate = $dataPayload['end_date'];
$end = new \DateTime($maxDate); $end = new \DateTime($maxDate);
/* $interval = \DateInterval::createFromDateString('1 day'); */// should be using this but its bugged /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged
$interval = new \DateInterval('P7D'); $interval = new \DateInterval('P7D');
} else { } else {
// $maxDate = DB::table('assign_material_to_activity as ama') // $maxDate = DB::table('assign_material_to_activity as ama')
@ -2036,5 +2044,4 @@ class MasterFunctionsHelper
return $dataFinal; return $dataFinal;
} }
} }

37
app/Http/Controllers/AuthController.php

@ -11,6 +11,7 @@ use App\Models\Role;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password; use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
class AuthController extends Controller class AuthController extends Controller
{ {
public function __construct() public function __construct()
@ -25,46 +26,50 @@ class AuthController extends Controller
$remember = $request->remember; $remember = $request->remember;
$is_mobile = $request->is_mobile; $is_mobile = $request->is_mobile;
if(empty($username) || empty($password)) if (empty($username) || empty($password))
return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400); return response()->json(['status' => 'error', 'message' => 'You must fill all the fields'], 400);
$usernameCheck = false; $usernameCheck = false;
$passwordCheck = false; $passwordCheck = false;
if (User::where('username', $username)->exists()) if (User::where('username', $username)->exists())
$usernameCheck = true; $usernameCheck = true;
if (User::where('password', md5($password))->exists()) if (User::where('password', md5($password))->exists())
$passwordCheck = true; $passwordCheck = true;
if ($usernameCheck & $passwordCheck){ if ($usernameCheck & $passwordCheck) {
$user = User::where('username', $username)->where('password', md5($password))->first(); $user = User::where('username', $username)->where('password', md5($password))->first();
if($is_mobile){ if ($is_mobile) {
$fcm_token = $request->fcm_token; $fcm_token = $request->fcm_token;
if(!$fcm_token || $fcm_token=="") if (!$fcm_token || $fcm_token == "")
return response()->json(['status'=>'error','message'=>'FCM Token is required'], 400); return response()->json(['status' => 'error', 'message' => 'FCM Token is required'], 400);
$dataUpdateFcm = array( $dataUpdateFcm = array(
"fcm_token"=>$fcm_token "fcm_token" => $fcm_token
); );
$hr = User::find($user->id); $hr = User::find($user->id);
if($hr) if ($hr)
$hr->update($dataUpdateFcm); $hr->update($dataUpdateFcm);
} }
$dataRole = Role::find($user->role_id); $dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
if($dataRole) if ($dataRole)
$user->role = $dataRole; $user->role = $dataRole;
if (! $token =Auth::login($user)) if ($dataHierarchy)
$user->hierarchy = $dataHierarchy;
if (!$token = Auth::login($user))
return response()->json(['error' => 'Unauthorized'], 401); return response()->json(['error' => 'Unauthorized'], 401);
$ttl = 60; $ttl = 60;
if($remember) if ($remember)
$ttl = 10080; $ttl = 10080;
// todo : change existing md5 hashed function to laravel's originally bcrypt // todo : change existing md5 hashed function to laravel's originally bcrypt
@ -80,13 +85,13 @@ class AuthController extends Controller
'expires_in' => auth()->factory()->getTTL() * $ttl, 'expires_in' => auth()->factory()->getTTL() * $ttl,
), ),
]); ]);
}else { } else {
if (!$usernameCheck && !$passwordCheck) if (!$usernameCheck && !$passwordCheck)
return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201); return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201);
if (!$passwordCheck) if (!$passwordCheck)
return response()->json(['code' => 201, 'message' => "password doesn't match"], 201); return response()->json(['code' => 201, 'message' => "password doesn't match"], 201);
if (!$usernameCheck) if (!$usernameCheck)
return response()->json(['code' => 201, 'message' => "username doesn't match"], 201); return response()->json(['code' => 201, 'message' => "username doesn't match"], 201);
} }
} }
} }

110
app/Http/Controllers/CompanyController.php

@ -0,0 +1,110 @@
<?php
namespace App\Http\Controllers;
use App\Models\Company;
use Illuminate\Http\Request;
class CompanyController extends Controller
{
public function add(Request $request)
{
$this->validate($request, [
'name' => 'required',
'description' => 'required'
]);
$data = $request->all();
$data['created_by'] = $this->currentName;
$result = Company::create($data);
if ($result) {
return response()->json(['status' => 'success', 'message' => 'add Company successfully!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data Company failed!', 'code' => 400], 400);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = Company::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Company, please try again later!', 'code' => 400], 400);
}
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$data = Company::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = Company::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Company successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Company failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_company');
$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 = Company::all();
$countData = $data->count();
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list Company, please try again later!', 'code' => 400], 400);
}
}
}

287
app/Http/Controllers/Controller.php

@ -1,11 +1,14 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity; use App\Models\UserToActivity;
use App\Models\Activity; use App\Models\Activity;
use App\Models\AssignMaterial; use App\Models\AssignMaterial;
use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController; use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail; use App\Models\ReportK3Detail;
@ -16,18 +19,21 @@ class Controller extends BaseController
protected $pathDocument = "assets/file/project/"; protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/"; protected $pathTmpImport = "assets/file/tmpimport/";
protected $pathActivityDocument = "assets/file/activity/"; protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth', protected $listJoinAll = [
'sixth', 'seventh', 'eighth', 'ninth', 'tenth']; 'first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'
];
protected $currentDate; protected $currentDate;
protected $currentName; protected $currentName;
protected $currentId; protected $currentId;
protected $companyId;
public function __construct() public function __construct()
{ {
$this->currentDate = date("Y-m-d H:i:s"); $this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system"; $this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0; $this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image'); $this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project'); $this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity'); $this->pathActivityDocument = config('assets.activity');
@ -36,43 +42,43 @@ class Controller extends BaseController
protected function setUpPayload($condition, $tableSelf) protected function setUpPayload($condition, $tableSelf)
{ {
$alias = "selfTable"; $alias = "selfTable";
$builder = DB::table($tableSelf." AS ".$alias); $builder = DB::table($tableSelf . " AS " . $alias);
// $builder = $builder->select($alias.".*"); // $builder = $builder->select($alias.".*");
if($condition){ if ($condition) {
if(isset($condition['select'])){ if (isset($condition['select'])) {
foreach($condition['select'] as $select){ foreach ($condition['select'] as $select) {
$builder = $builder->addSelect($alias.".".$select); $builder = $builder->addSelect($alias . "." . $select);
} }
}else{ } else {
$builder = $builder->addSelect($alias.".*"); $builder = $builder->addSelect($alias . ".*");
} }
if(isset($condition['joins'])){ if (isset($condition['joins'])) {
$selectColumn = []; $selectColumn = [];
$no = 0; $no = 0;
foreach($condition['joins'] as $join){ foreach ($condition['joins'] as $join) {
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias; $tableJoin = isset($join['name1']) ? $join['name1'] : $alias;
$tableName = $join['name']; $tableName = $join['name'];
$columnJoin = $join['column_join']; // foreign key table sini $columnJoin = $join['column_join']; // foreign key table sini
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan $columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan
if (isset($join['column_results'])) { if (isset($join['column_results'])) {
$columnResult = $join['column_results']; $columnResult = $join['column_results'];
foreach($columnResult as $sColumn){ foreach ($columnResult as $sColumn) {
$builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn); $builder = $builder->addSelect($tableName . "." . $sColumn . " as join_" . $this->listJoinAll[$no] . "_" . $sColumn);
} }
} }
$builder = $builder->leftJoin($tableName, $tableJoin.".".$columnJoin, '=', $tableName.'.'.$columnSelf); $builder = $builder->leftJoin($tableName, $tableJoin . "." . $columnJoin, '=', $tableName . '.' . $columnSelf);
$no++; $no++;
} }
} }
if(isset($condition['columns'])){ if (isset($condition['columns'])) {
$listWhere = $condition['columns']; $listWhere = $condition['columns'];
$builder = $builder->where(function ($query) use($listWhere, $alias){ $builder = $builder->where(function ($query) use ($listWhere, $alias) {
foreach($listWhere as $where){ foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
$column = $where['name']; $column = $where['name'];
$operator = strtolower($where['logic_operator']); // like, =, <>, range $operator = strtolower($where['logic_operator']); // like, =, <>, range
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
@ -83,22 +89,22 @@ class Controller extends BaseController
}); });
} }
if(isset($condition['group_column'])){ if (isset($condition['group_column'])) {
$builder = $this->groupWhere($builder, $condition['group_column'], $alias); $builder = $this->groupWhere($builder, $condition['group_column'], $alias);
} }
$data['count'] = clone $builder; $data['count'] = clone $builder;
if(isset($condition['paging'])){ if (isset($condition['paging'])) {
$builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']); $builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']);
} }
if(isset($condition['orders'])){ if (isset($condition['orders'])) {
$orders = $condition['orders']; $orders = $condition['orders'];
$sortBy = $orders['ascending'] ? "ASC" : "DESC"; $sortBy = $orders['ascending'] ? "ASC" : "DESC";
$columnOrder = $orders['columns']; $columnOrder = $orders['columns'];
foreach($columnOrder as $column){ foreach ($columnOrder as $column) {
$builder = $builder->orderBy($alias.".".$column, $sortBy); $builder = $builder->orderBy($alias . "." . $column, $sortBy);
} }
} }
} }
@ -113,8 +119,8 @@ class Controller extends BaseController
$operator = $listGroupWhere['operator']; $operator = $listGroupWhere['operator'];
$operatorGroup = $listGroupWhere['group_operator']; $operatorGroup = $listGroupWhere['group_operator'];
$listWhere = $listGroupWhere['where']; $listWhere = $listGroupWhere['where'];
if(strtolower($operator)=="and"){ if (strtolower($operator) == "and") {
$builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){ $builder = $builder->where(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1; $no = 1;
foreach ($listWhere as $where) { foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
@ -122,22 +128,22 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']); $operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
if($operatorGroup=="and"){ if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
if($no==1){ if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2);
} }
} }
} }
$no = $no+1; $no = $no + 1;
} }
}); });
}else if(strtolower($operator)=="or"){ } else if (strtolower($operator) == "or") {
$builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){ $builder = $builder->orWhere(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1; $no = 1;
foreach ($listWhere as $where) { foreach ($listWhere as $where) {
$value = $where['value']; $value = $where['value'];
@ -145,13 +151,13 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']); $operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : ""; $value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias; $tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){ if ($value && $value != "" && $value != " ") {
if($operatorGroup=="and"){ if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
if($no==1){ if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{ } else {
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2); $query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2);
} }
} }
@ -166,39 +172,40 @@ class Controller extends BaseController
private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) private function whereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2)
{ {
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]); $query = $query->whereBetween($tableColumn . "." . $column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%'); $query = $query->where($tableColumn . "." . $column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($tableColumn.".".$column, '~*', $value); $query = $query->where($tableColumn . "." . $column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->where($tableColumn.".".$column, $value); $query = $query->where($tableColumn . "." . $column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->whereIn($tableColumn.".".$column, $value); $query = $query->whereIn($tableColumn . "." . $column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->whereNotIn($tableColumn.".".$column, $value); $query = $query->whereNotIn($tableColumn . "." . $column, $value);
}else{ } else {
$query = $query->where($tableColumn.".".$column, $operator, $value); $query = $query->where($tableColumn . "." . $column, $operator, $value);
} }
return $query; return $query;
} }
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){ private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2)
{
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->whereBetween($column, [$value, $value2]); $query = $query->whereBetween($column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->where($column, 'like', '%'.$value.'%'); $query = $query->where($column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($column, '~*', $value); $query = $query->where($column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->where($column, $value); $query = $query->where($column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->whereIn($column, $value); $query = $query->whereIn($column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->whereNotIn($column, $value); $query = $query->whereNotIn($column, $value);
}else{ } else {
$query = $query->where($column, $operator, $value); $query = $query->where($column, $operator, $value);
} }
return $query; return $query;
@ -207,25 +214,26 @@ class Controller extends BaseController
private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2) private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2)
{ {
$query = $oldQuery; $query = $oldQuery;
if($operator=="range"){ if ($operator == "range") {
$query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]); $query = $query->orWhereBetween($tableColumn . "." . $column, [$value, $value2]);
}else if($operator=="like"){ } else if ($operator == "like") {
$query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%'); $query = $query->orWhere($tableColumn . "." . $column, 'like', '%' . $value . '%');
}else if($operator=="ilike"){ } else if ($operator == "ilike") {
$query = $query->where($tableColumn.".".$column, '~*', $value); $query = $query->where($tableColumn . "." . $column, '~*', $value);
}else if($operator=="="){ } else if ($operator == "=") {
$query = $query->orWhere($tableColumn.".".$column, $value); $query = $query->orWhere($tableColumn . "." . $column, $value);
}else if($operator=="in"){ } else if ($operator == "in") {
$query = $query->orWhereIn($tableColumn.".".$column, $value); $query = $query->orWhereIn($tableColumn . "." . $column, $value);
}else if($operator=="notin"){ } else if ($operator == "notin") {
$query = $query->orWhereNotIn($tableColumn.".".$column, $value); $query = $query->orWhereNotIn($tableColumn . "." . $column, $value);
}else{ } else {
$query = $query->orWhere($tableColumn.".".$column, $operator, $value); $query = $query->orWhere($tableColumn . "." . $column, $operator, $value);
} }
return $query; return $query;
} }
protected function calculateAllCost($activity_id, $proyek_id){ protected function calculateAllCost($activity_id, $proyek_id)
{
$humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id); $humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id);
$materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id); $materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id);
$toolsCostPlanning = 0; $toolsCostPlanning = 0;
@ -236,11 +244,11 @@ class Controller extends BaseController
private function calculateAllHumanCost($activity_id, $proyek_id) private function calculateAllHumanCost($activity_id, $proyek_id)
{ {
$dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate","ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate") $dataHuman = UserToActivity::select("ahp.standart_rate as standart_rate", "ahp.max_used as max_used", "ahp.cost_per_used as cost_per_used", "ahp.uom_standart_rate as uom_standart_rate")
->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id") ->leftJoin("assign_hr_to_proyek as ahp", "assign_hr_to_activity.user_id", "=", "ahp.user_id")
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id) ->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id)
->where("ahp.proyek_id", $proyek_id) ->where("ahp.proyek_id", $proyek_id)
->get(); ->get();
$totalCost = 0; $totalCost = 0;
foreach ($dataHuman as $human) { foreach ($dataHuman as $human) {
@ -255,61 +263,110 @@ class Controller extends BaseController
$activity = Activity::find($activity_id); $activity = Activity::find($activity_id);
$duration = $activity->duration; $duration = $activity->duration;
$standarRate = $human->standart_rate; $standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100; $maxUsed = $human->max_used / 100;
if ($human->uom_standart_rate == "Hour") { if ($human->uom_standart_rate == "Hour") {
$totalCost = ($standarRate*8*$duration)*$maxUsed; $totalCost = ($standarRate * 8 * $duration) * $maxUsed;
return $totalCost; return $totalCost;
} }
$totalCost = ($standarRate*$duration)*$maxUsed; $totalCost = ($standarRate * $duration) * $maxUsed;
return $totalCost; return $totalCost;
} }
private function calculateMaterialCost($activity_id, $proyek_id) private function calculateMaterialCost($activity_id, $proyek_id)
{ {
$totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost") $totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost")
->where("proyek_id", $proyek_id) ->where("proyek_id", $proyek_id)
->where("activity_id", $activity_id) ->where("activity_id", $activity_id)
->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)")); ->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)"));
return $totalCost; return $totalCost;
} }
protected function getLoc($lat, $lng){ protected function getLoc($lat, $lng)
{
// $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"); // $response = Http::get(config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json");
// return $response->json; // return $response->json;
$url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json"; $url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json";
// $token = config('api.adw_token'); // $token = config('api.adw_token');
$response = $this->curlRequest($url); $response = $this->curlRequest($url);
return $response; return $response;
} }
private function curlRequest($url){ private function curlRequest($url)
$ch = curl_init(); {
// $headers = [ $ch = curl_init();
// 'Authorization: '.$token // $headers = [
// ]; // 'Authorization: '.$token
curl_setopt($ch, CURLOPT_URL, $url); // ];
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch); $response = curl_exec($ch);
if ($response === false) if ($response === false)
$response = curl_error($ch); $response = curl_error($ch);
curl_close($ch); curl_close($ch);
return json_decode($response); return json_decode($response);
} }
protected function addDetailK3($dataDetail, $report_id){ protected function addDetailK3($dataDetail, $report_id)
{
foreach ($dataDetail as $value) { foreach ($dataDetail as $value) {
$dataNew = array( $dataNew = array(
"report_k3_id"=>$report_id, "report_k3_id" => $report_id,
"checklist_k3_id"=>$value['checklist_id'], "checklist_k3_id" => $value['checklist_id'],
"name_checklist_k3"=>$value['checklist_name'], "name_checklist_k3" => $value['checklist_name'],
"created_by"=>$this->currentName "created_by" => $this->currentName
); );
ReportK3Detail::create($dataNew); ReportK3Detail::create($dataNew);
} }
} }
protected function getDataHierarchy($divisi, $paramUserId)
{
$parentDivisi = Divisi::where('id', $divisi)->get();
$divisions = [];
$tempUser = [];
$userId = [$paramUserId];
// if ($parentDivisi->parent == null){
// }else{
foreach ($parentDivisi as $key) {
$data = $this->getAllChildrenDivisi($key->id);
$divisions[] = $data;
}
if (count($divisions) > 0) {
for ($i = 0; $i < count($divisions[0]); $i++) {
if (User::select('id', 'name', 'divisi_id')->where('divisi_id', $divisions[0][$i]->id)->exists()) {
$tempUser[] = User::select('id', 'name', 'divisi_id')->where('divisi_id', $divisions[0][$i]->id)->get();
}
}
for ($x = 0; $x < count($tempUser); $x++) {
for ($y = 0; $y < count($tempUser[$x]); $y++) {
$userId[] = $tempUser[$x][$y]->id;
}
}
}
return $userId;
// }
// return $userId;
}
private function getAllChildrenDivisi($divisi)
{
$finalData = [];
$divisi = Divisi::where('parent', $divisi)->get();
if (count($divisi) > 0) {
foreach ($divisi as $key) {
$childDivisi = $this->getAllChildrenDivisi($key->id);
$finalData[] = $key;
$finalData = array_merge($finalData, $childDivisi);
}
}
return $finalData;
}
} }

32
app/Http/Controllers/DashboardBoDController.php

@ -41,14 +41,14 @@ class DashboardBoDController extends Controller
private function getInvoiceIntegration($search) private function getInvoiceIntegration($search)
{ {
if(empty($search)) if (empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$token = config('api.adw_token'); $token = config('api.adw_token');
$response = $this->curlReq($url, $token); $response = $this->curlReq($url, $token);
if(@$response->data->project_no == "") if (@$response->data->project_no == "")
return null; return null;
return $response; return $response;
@ -83,7 +83,6 @@ class DashboardBoDController extends Controller
$totalInvoice += $resp->data->total_invoice_amount ?? 0; $totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0; $totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
} }
} }
return response()->json([ return response()->json([
@ -148,15 +147,13 @@ class DashboardBoDController extends Controller
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
try { try {
if ($selisihProgress > 0 && $selisihProgress <= 5){ if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1; $return['warning'] += 1;
$projects[$index]->status = 'warning'; $projects[$index]->status = 'warning';
} } elseif ($selisihProgress == 0) {
elseif ($selisihProgress == 0){
$return['on-schedule'] += 1; $return['on-schedule'] += 1;
$projects[$index]->status = 'on-schedule'; $projects[$index]->status = 'on-schedule';
} } else {
else {
$return['behind-schedule'] += 1; $return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule'; $projects[$index]->status = 'behind-schedule';
} }
@ -192,13 +189,11 @@ class DashboardBoDController extends Controller
$actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0; $actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0;
} }
$selisihProgress = $planningProgress - $actualProgress; $selisihProgress = $planningProgress - $actualProgress;
if ($selisihProgress > 0 && $selisihProgress <= 5){ if ($selisihProgress > 0 && $selisihProgress <= 5) {
$warning++; $warning++;
} } elseif ($selisihProgress == 0) {
elseif ($selisihProgress == 0){
$onSchedule++; $onSchedule++;
} } else {
else {
$behindSchedule++; $behindSchedule++;
} }
} }
@ -295,7 +290,7 @@ class DashboardBoDController extends Controller
{ {
$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')
->get(); ->get();
@ -351,8 +346,9 @@ class DashboardBoDController extends Controller
public function getDetailExpenditure($year = '%') public function getDetailExpenditure($year = '%')
{ {
$year = $this->interpolateYear($year); $year = $this->interpolateYear($year);
$projects = Project::where('mulai_proyek', 'like', $year) $projects = Project::select('m_proyek.*', 'md.name as divisi_name')
/* ->orWhere('akhir_proyek', 'like', $year) */ ->where('mulai_proyek', 'like', $year)
->join('m_divisi as md', 'md.id', '=', 'm_proyek.divisi_id')
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->get(); ->get();
foreach ($projects as $project) { foreach ($projects as $project) {

195
app/Http/Controllers/MenuCompanyController.php

@ -0,0 +1,195 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\MenuCompany;
use App\Models\RoleMenu;
use Illuminate\Support\Facades\Log;
class MenuCompanyController extends Controller
{
// public function add(Request $request)
// {
// $this->validate($request, [
// 'icon' => 'required',
// 'name' => 'string|required',
// 'url' => 'required|unique:m_company_menu,url',
// 'sequence' => 'required|integer',
// ]);
// $data = $request->all();
// $data['created_by'] = $this->currentName;
// $result = MenuCompany::create($data);
// if ($result) {
// return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200], 200);
// } else {
// return response()->json(['status' => 'failed', 'message' => 'add data menu failed!', 'code' => 400], 400);
// }
// }
public function addMultiple(Request $request)
{
$menus = $request->all();
if (is_array($menus) && count($menus) > 0) {
$countRes = 0;
foreach ($menus as $menu) {
$dataInsert = array(
"menu_id" => $menu['menu_id'],
"parent_menu_id" => $menu['parent_id'],
"company_id" => $menu['company_id'],
"icon" => $menu['icon'],
"alias_name" => $menu['alias_name'],
"url" => $menu['url'],
"sequence" => $menu['sequence'],
"created_by" => $this->currentName
);
$result = MenuCompany::create($dataInsert);
if ($result) {
$countRes++;
} else {
$countRes--;
}
}
if ($countRes > 0) {
return response()->json(['status' => 'success', 'message' => 'add data menu successfully!', 'code' => 200]);
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
}
} else {
return response()->json(['status' => 'failed', 'message' => 'add data menu failed created!', 'code' => 400]);
}
}
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
}
$result = MenuCompany::find($id);
if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get data menu, please try again later!', 'code' => 400], 400);
}
}
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
}
$this->validate($request, [
'icon' => 'required',
'sequence' => 'required|integer',
]);
$data = MenuCompany::find($id);
if ($data) {
$result = $data->update($request->all());
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if ($result) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully updated!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = MenuCompany::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data menu successfully deleted!', 'code' => 200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data menu failed deleted!', 'code' => 400], 400);
}
}
public function search(Request $request)
{
$payload = $request->all();
$dataBuilder = $this->setUpPayload($payload, 'm_company_menu');
$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 listMenu($id)
{
$dataParent = RoleMenu::select("m_company_menu.*")
->join('m_company_menu', 'm_company_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->whereNull('m_company_menu.parent_id')
->where('m_roles.id', $id)
->orderBy('m_company_menu.sequence', 'ASC')
->get();
$finalData = [];
foreach ($dataParent as $data) {
$data->children = $this->getChildrenMenu($data->id, $id);
$finalData[] = $data;
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $finalData], 200);
}
protected function getChildrenMenu($id, $role_id)
{
$dataChildren = RoleMenu::select("m_company_menu.*")
->join('m_company_menu', 'm_company_menu.id', '=', 't_roles_menu.menu_id')
->join('m_roles', 'm_roles.id', '=', 't_roles_menu.role_id')
->where('m_roles.id', $role_id)
->where('m_company_menu.parent_id', $id)
->orderBy('m_company_menu.sequence', 'ASC')
->get();
$children = [];
if ($dataChildren) {
foreach ($dataChildren as $data) {
$data->children = $this->getChildrenMenu($data->id, $role_id);
$children[] = $data;
}
}
return $children;
}
public function list()
{
$data = MenuCompany::all();
$countData = $data->count();
if ($data) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data, 'totalRecord' => $countData], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'failed get list menu, please try again later!', 'code' => 400], 400);
}
}
}

627
app/Http/Controllers/ProjectController.php

@ -50,7 +50,7 @@ class ProjectController extends Controller
{ {
$this->validate($request, [ $this->validate($request, [
'nama' => 'required', 'nama' => 'required',
'mulai_proyek' => 'required', 'mulai_proyek' => 'required',
'akhir_proyek' => 'required', 'akhir_proyek' => 'required',
'rencana_biaya' => 'required', 'rencana_biaya' => 'required',
'type_proyek_id' => 'required', 'type_proyek_id' => 'required',
@ -60,81 +60,117 @@ class ProjectController extends Controller
$data = $request->all(); $data = $request->all();
$data['created_by'] = $this->currentName; $data['created_by'] = $this->currentName;
$data['created_by_id'] = $this->currentId;
if(empty($data['phase_id'])) if (empty($data['phase_id']))
$data['phase_id'] = 1; $data['phase_id'] = 1;
$result = Project::create($data); $result = Project::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);
$this->createOfficeHours($result->id); $this->createOfficeHours($result->id);
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first(); $dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first();
return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200); return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200);
} }
public function edit($id) public function edit($id)
{ {
if (empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::query() // $result = Project::query()
->from('m_proyek AS mp') // ->from('m_proyek AS mp')
->where('mp.id', $id) // ->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'); // ->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') // if (!is_null($result->first()['divisi_id'])) {
->addSelect(DB::raw('m_divisi.name AS nama_divisi')); // $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
} // ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = $result->first(); $result = Project::select(
'value_proyek',
if(!$result) 'scoupe_of_work',
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); 'kode_sortname',
'jumlah_stakeholder',
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); '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',
'nickname'
)
->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);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} }
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
if(empty($id) || !is_int((int)$id)) if (empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Project::find($id); $data = Project::find($id);
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); 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!','code'=> 500], 500); return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200); return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
} }
private function createOfficeHours($proyek_id) private function createOfficeHours($proyek_id)
{ {
$dataCreate = array( $dataCreate = array(
"proyek_id"=>$proyek_id, "proyek_id" => $proyek_id,
"monday_start"=> "08:00:00", "monday_start" => "08:00:00",
"monday_end"=> "16:00:00", "monday_end" => "16:00:00",
"tuesday_start"=> "08:00:00", "tuesday_start" => "08:00:00",
"tuesday_end"=> "16:00:00", "tuesday_end" => "16:00:00",
"wednesday_start"=> "08:00:00", "wednesday_start" => "08:00:00",
"wednesday_end"=> "16:00:00", "wednesday_end" => "16:00:00",
"thursday_start"=> "08:00:00", "thursday_start" => "08:00:00",
"thursday_end"=> "16:00:00", "thursday_end" => "16:00:00",
"friday_start"=> "08:00:00", "friday_start" => "08:00:00",
"friday_end"=> "16:00:00", "friday_end" => "16:00:00",
"saturday_start"=> "08:00:00", "saturday_start" => "08:00:00",
"saturday_end"=> "16:00:00", "saturday_end" => "16:00:00",
"sunday_start"=> "08:00:00", "sunday_start" => "08:00:00",
"sunday_end"=> "16:00:00", "sunday_end" => "16:00:00",
"created_by"=> $this->currentName "created_by" => $this->currentName
); );
OfficeHours::create($dataCreate); OfficeHours::create($dataCreate);
@ -146,15 +182,15 @@ class ProjectController extends Controller
{ {
$data = Project::find($id); $data = Project::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);
$this->deleteRelative($id); $this->deleteRelative($id);
if(!$data->delete()) if (!$data->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);
} }
private function deleteRelative($project_id) private function deleteRelative($project_id)
@ -169,12 +205,12 @@ class ProjectController extends Controller
ProjectChecklists::where('proyek_id', $project_id)->delete(); ProjectChecklists::where('proyek_id', $project_id)->delete();
ProjectIssues::where('proyek_id', $project_id)->delete(); ProjectIssues::where('proyek_id', $project_id)->delete();
ProjectRisks::where('proyek_id', $project_id)->delete(); ProjectRisks::where('proyek_id', $project_id)->delete();
ProjectToChecklistK3::where('proyek_id', $project_id)->delete(); ProjectToChecklistK3::where('proyek_id', $project_id)->delete();
HierarchyFtth::where('project_id', $project_id)->delete(); HierarchyFtth::where('project_id', $project_id)->delete();
AssignTools::where('proyek_id', $project_id)->delete(); AssignTools::where('proyek_id', $project_id)->delete();
OfficeHours::where('proyek_id', $project_id)->delete(); OfficeHours::where('proyek_id', $project_id)->delete();
ReportK3::where('proyek_id', $project_id)->delete(); ReportK3::where('proyek_id', $project_id)->delete();
RequestMaterial::where('proyek_id', $project_id)->delete(); RequestMaterial::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id); $this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id); $this->deleteDokumenProject($project_id);
} }
@ -189,16 +225,16 @@ class ProjectController extends Controller
foreach ($dataRa as $ra) { foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get(); $images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) { foreach ($images as $image) {
if(file_exists($this->pathImage.$image->image)){ if (file_exists($this->pathImage . $image->image)) {
unlink($this->pathImage.$image->image); unlink($this->pathImage . $image->image);
} }
} }
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete(); Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
} }
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get(); $dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) { foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){ if (file_exists($this->pathActivityDocument . $ad->file)) {
unlink($this->pathActivityDocument.$ad->file); unlink($this->pathActivityDocument . $ad->file);
} }
} }
ActivityDokumen::whereIn("activity_id", $activityIds)->delete(); ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
@ -216,8 +252,8 @@ class ProjectController extends Controller
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get(); $dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get();
foreach ($dataDokumen as $dokumen) { foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){ if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument.$dokumen->file); unlink($this->pathDocument . $dokumen->file);
} }
} }
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete(); DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete();
@ -226,8 +262,8 @@ class ProjectController extends Controller
$ref_ids = $dataFolder->all(); $ref_ids = $dataFolder->all();
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get(); $dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get();
foreach ($dataDokumen as $dokumen) { foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){ if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument.$dokumen->file); unlink($this->pathDocument . $dokumen->file);
} }
} }
@ -241,11 +277,11 @@ class ProjectController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'm_proyek'); $dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$builder = $dataBuilder['builder']; $builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count']; $countBuilder = $dataBuilder['count'];
// $builder->where("selfTable.created_by",$this->currentName); // $builder->where("selfTable.created_by",$this->currentName);
$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()
@ -287,107 +323,116 @@ class ProjectController extends Controller
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by'
)->orderBy('id', 'desc') )->orderBy('id', 'desc')
// ->where("created_by",$this->currentName) // ->where("created_by",$this->currentName)
->get(); ->get();
$countData = $data->count(); $countData = $data->count();
if(!$data) if (!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost'))); $totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost')));
$totalActualCost = $data->sum('actualCost'); $totalActualCost = $data->sum('actualCost');
$manpowers = User::count(); $manpowers = User::count();
$projectsOnDanger = Project::where('budget_health', 'overrun')->count(); $projectsOnDanger = Project::where('budget_health', 'overrun')->count();
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name'); $projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name');
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name'); $projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name');
try { try {
$projectsByPhase = DB::table('m_proyek') $projectsByPhase = DB::table('m_proyek')
->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total')) ->select('m_proyek_phase.name', 'm_proyek_phase.color', DB::raw('count(*) as total'))
->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id') ->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id')
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color') ->groupBy('m_proyek_phase.name', 'm_proyek_phase.color')
->get(); ->get();
} catch (\Exception $e) { } catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]); return response()->json(['message' => $e->getMessage()]);
} }
try { try {
$projectsByType = DB::table('m_proyek') $projectsByType = DB::table('m_proyek')
->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total')) ->select('m_type_proyek.name', DB::raw('count(m_type_proyek.id) as total'))
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id') ->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id')
->groupBy('m_type_proyek.name') ->groupBy('m_type_proyek.name')
->get(); ->get();
} catch (\Exception $e) { } catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]); return response()->json(['message' => $e->getMessage()]);
} }
return response()->json( return response()->json(
[ [
'status'=>'success', 'status' => 'success',
'code'=>200, 'code' => 200,
'data'=>$data, 'data' => $data,
'totalRecord'=>$countData, 'totalRecord' => $countData,
'totalPlannedCost' => $totalPlannedCost, 'totalPlannedCost' => $totalPlannedCost,
'totalActualCost' => $totalActualCost, 'totalActualCost' => $totalActualCost,
'totalRevenue' => $totalPlannedCost - $totalActualCost, 'totalRevenue' => $totalPlannedCost - $totalActualCost,
'manpowers' => $manpowers, 'manpowers' => $manpowers,
'projectsOnDanger'=> $projectsOnDanger, 'projectsOnDanger' => $projectsOnDanger,
'projectPhases' => $projectPhases, 'projectPhases' => $projectPhases,
'projectsByPhase' => $projectsByPhase, 'projectsByPhase' => $projectsByPhase,
'projectTypes' => $projectTypes, 'projectTypes' => $projectTypes,
'projectsByType' => $projectsByType, 'projectsByType' => $projectsByType,
], 200); ],
200
);
} }
public function getListProjectTask($id){ public function getListProjectTask($id)
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*") {
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*")
->where("assign_hr_to_activity.user_id", $id) ->where("assign_hr_to_activity.user_id", $id)
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id') ->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id')
->groupBy("m_proyek.proyek_id") ->groupBy("m_proyek.proyek_id")
->get(); ->get();
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);
return response()->json(['status'=>'success','code'=>200,'data'=>$data], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
} }
public function getSCurve(Request $request){ public function getSCurve(Request $request)
{
$data = MasterFunctionsHelper::getSCurve($request); $data = MasterFunctionsHelper::getSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
} }
// testing // testing
public function calculateSCurvetest(Request $request){ public function calculateSCurvetest(Request $request)
$data = MasterFunctionsHelper::calculateSCurve($request->project_id); {
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); $data = MasterFunctionsHelper::calculateSCurve($request->project_id);
} return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
public function calculateSCurve(Request $request){ public function calculateSCurve(Request $request)
$sCurve = Project::select('scurve')->where('id', $request->project_id)->first(); {
return response()->json(['status'=>'success','code'=>200, 'data' => json_decode($sCurve->scurve)], 200); $sCurve = Project::select('scurve')->where('id', $request->project_id)->first();
} return response()->json(['status' => 'success', 'code' => 200, 'data' => json_decode($sCurve->scurve)], 200);
}
public function sCurveCommand(Request $request){ public function sCurveCommand(Request $request)
Artisan::call('calculate:scurve', [ {
'project_id' => $request->project_id Artisan::call('calculate:scurve', [
]); 'project_id' => $request->project_id
// $project = Project::find($request->project_id); ]);
// $project = Project::find($request->project_id);
// if ($project) { // if ($project) {
// dispatch(new ProcessSCurve($project)); // dispatch(new ProcessSCurve($project));
// return response()->json(['message' => 'S Curve calculation queued']); // return response()->json(['message' => 'S Curve calculation queued']);
// } // }
// return response()->json(['message' => 'Project not found'], 404); // return response()->json(['message' => 'Project not found'], 404);
} }
public function getLinearSCurve(Request $request){ public function getLinearSCurve(Request $request)
{
$data = MasterFunctionsHelper::getLinearSCurve($request); $data = MasterFunctionsHelper::getLinearSCurve($request);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
} }
public static function setSyncDate($activity_id, $activity, $report) { public static function setSyncDate($activity_id, $activity, $report)
{
$status = AssignMaterial::where('activity_id', $activity_id)->first(); $status = AssignMaterial::where('activity_id', $activity_id)->first();
if (!isset($status)) { if (!isset($status)) {
$reports = array( $reports = array(
@ -419,17 +464,17 @@ class ProjectController extends Controller
return $reports; return $reports;
} }
public function synchronizeReport($gantt_id) public function synchronizeReport($gantt_id)
{ {
$activities = Activity::where("version_gantt_id", $gantt_id)->get(); $activities = Activity::where("version_gantt_id", $gantt_id)->get();
$reports = []; $reports = [];
foreach($activities as $activity) { foreach ($activities as $activity) {
$activity_id = $activity->id; $activity_id = $activity->id;
$countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count(); $countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count();
if ($countReports === 1) { if ($countReports === 1) {
$dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get(); $dataReports = ReportActivityMaterial::where('activity_id', $activity_id)->orderBy('report_date')->get();
foreach($dataReports as $dr) { foreach ($dataReports as $dr) {
$reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr); $reports[] = ProjectController::setSyncDate($activity_id, $activity, $dr);
} }
} }
@ -450,15 +495,15 @@ class ProjectController extends Controller
/* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */ /* return response()->json(['status'=>'success','data'=> $reports,'code'=>200], 200); */
/* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */ /* return response()->json(['status'=>'success','data'=> $activities,'code'=>200], 200); */
for ($i=0; $i < count($reports); $i++) { for ($i = 0; $i < count($reports); $i++) {
$activity = Activity::find($reports[$i]['activity_id']); $activity = Activity::find($reports[$i]['activity_id']);
if($reports[$i]['status'] != 'done'){ if ($reports[$i]['status'] != 'done') {
$reports[$i]['max_date']->modify('-1 day'); $reports[$i]['max_date']->modify('-1 day');
}else if($reports[$i]['status'] == 'done'){ } else if ($reports[$i]['status'] == 'done') {
$activity->actual_end = $reports[$i]['max_date']->setTime(23,59,59); $activity->actual_end = $reports[$i]['max_date']->setTime(23, 59, 59);
} }
$activity->start_date = $reports[$i]['min_date']; //same early $activity->start_date = $reports[$i]['min_date']; //same early
$activity->end_date = $reports[$i]['max_date']->setTime(23,59,59); // same early $activity->end_date = $reports[$i]['max_date']->setTime(23, 59, 59); // same early
$startDate = new DateTime($activity->start_date); $startDate = new DateTime($activity->start_date);
$endDate = new DateTime($activity->end_date); $endDate = new DateTime($activity->end_date);
$duration = MasterFunctionsHelper::countDays($activity->version_gantt_id, $startDate, $endDate); $duration = MasterFunctionsHelper::countDays($activity->version_gantt_id, $startDate, $endDate);
@ -467,7 +512,7 @@ class ProjectController extends Controller
$activity->save(); $activity->save();
} }
return response()->json(['status'=>'success','message'=>'Synchronize to report success!','code'=>200], 200); return response()->json(['status' => 'success', 'message' => 'Synchronize to report success!', 'code' => 200], 200);
} }
public function setBaseline($gantt_id) public function setBaseline($gantt_id)
@ -476,104 +521,104 @@ class ProjectController extends Controller
foreach ($activities as $activity) { foreach ($activities as $activity) {
$activity->update([ $activity->update([
"planned_start"=>$activity->start_date, "planned_start" => $activity->start_date,
"planned_end"=>$activity->end_date, "planned_end" => $activity->end_date,
"early_start"=>$activity->start_date, "early_start" => $activity->start_date,
"early_end"=>$activity->end_date, "early_end" => $activity->end_date,
]); ]);
} }
return response()->json(['status'=>'success','message'=>'Set baseline success!','code'=> 200], 200); return response()->json(['status' => 'success', 'message' => 'Set baseline success!', 'code' => 200], 200);
} }
public function getInvoiceIntegration(Request $request) { public function getInvoiceIntegration(Request $request)
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count(); {
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
$search = urlencode($request->search); $search = urlencode($request->search);
if(empty($search)) if (empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400); return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH'); $url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$response = MasterFunctionsHelper::curlReq($url); $response = MasterFunctionsHelper::curlReq($url);
if (isset($request->gantt_id)) { if (isset($request->gantt_id)) {
$response->data->total_cost = $response->data->total_cost / $ganttCount; $response->data->total_cost = $response->data->total_cost / $ganttCount;
} }
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200);
}
public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ' . $alias)
->where([
['is_customer', true],
['user_id', $id]
])
->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name')
->get();
$totalRecord = $userProyek->count();
return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
} }
public function getByUser($id) public function detail(Request $request, $id, $gantt_id = null, $s_curve = null)
{ {
$alias = "utp"; if (empty($id) || !is_int((int)$id))
$userProyek = UserToProyek::query() return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
->from('assign_hr_to_proyek AS ' . $alias)
->where([
['is_customer', true],
['user_id', $id]
])
->leftJoin('m_users', $alias.'.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias.'.proyek_id', '=', 'm_proyek.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id')
->select('m_proyek.*', 'm_type_proyek.name AS join_second_name','m_users.name AS join_first_name')
->get();
$totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
public function detail(Request $request, $id, $gantt_id = null, $s_curve = null){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
$result = Project::find($id); $result = Project::find($id);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
if (!isset($gantt_id)) { if (!isset($gantt_id)) {
$gantt = MasterFunctionsHelper::getLatestGantt($id); $gantt = MasterFunctionsHelper::getLatestGantt($id);
$ganttId = $gantt['last_gantt_id']; $ganttId = $gantt['last_gantt_id'];
} else { } else {
$ganttId = $gantt_id; $ganttId = $gantt_id;
} }
$result->projectManager = User::where('id', $result->pm_id)->value('name'); $result->projectManager = User::where('id', $result->pm_id)->value('name');
if (isset($s_curve)) { if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if($result['type_proyek_id'] === 9) if ($result['type_proyek_id'] === 9) {
{ // $actualEndExist = Activity::where('proyek_id', $id)->exists();
// $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') $maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc') ->orderBy('end_date', 'desc')
->first(); ->first();
} else {
}else{ // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') $maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc') ->orderBy('end_date', 'desc')
->first(); ->first();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
} else { } else {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first();
$actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists();
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') $maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc') ->orderBy('end_date', 'desc')
->first(); ->first();
$query = Activity::where('version_gantt_id', $ganttId); $query = Activity::where('version_gantt_id', $ganttId);
} }
if ($actualStartExist) { if ($actualStartExist) {
$startDate = $query->orderBy('actual_start')->value('start_date'); $startDate = $query->orderBy('actual_start')->value('start_date');
} else { } else {
$startDate = $query->orderBy('start_date')->value('start_date'); $startDate = $query->orderBy('start_date')->value('start_date');
} }
// if($actualEndExist) // if($actualEndExist)
// { // {
// // $maxEndDate = $query->max('id'); // // $maxEndDate = $query->max('id');
// // get last end_date // // get last end_date
// // $endDate = $query->where('id',$maxEndDate)->first()->end_date; // // $endDate = $query->where('id',$maxEndDate)->first()->end_date;
// } // }
$plannedStart = Activity::where('version_gantt_id', $ganttId) $plannedStart = Activity::where('version_gantt_id', $ganttId)
->orderBy('planned_start') ->orderBy('planned_start')
@ -590,27 +635,27 @@ class ProjectController extends Controller
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200); return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);
} }
public function getOverdueActivities(Request $request){ public function getOverdueActivities(Request $request)
{
$payload = $request->all(); $payload = $request->all();
if(empty($payload['id']) || !is_int((int)$payload['id'])) if (empty($payload['id']) || !is_int((int)$payload['id']))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::find($payload['id']); $result = Project::find($payload['id']);
if(!$result) if (!$result)
return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404);
//TODO possible overdue bug //TODO possible overdue bug
$endDate = Activity::where('proyek_id', $payload['id']) $endDate = Activity::where('proyek_id', $payload['id'])
->orderByDesc('end_date') ->orderByDesc('end_date')
->value('end_date'); ->value('end_date');
if(isset($payload['till_date'])) { if (isset($payload['till_date'])) {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$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(); $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 { } else {
$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(); $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 {
else {
if (isset($payload['scurve'])) { if (isset($payload['scurve'])) {
$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(); $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 { } else {
@ -619,53 +664,75 @@ class ProjectController extends Controller
} }
$result->overdueActivities = $overdueActivities; $result->overdueActivities = $overdueActivities;
return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} }
public function getReportDistribution(Request $request){ public function getReportDistribution(Request $request)
{
$payload = $request->all(); $payload = $request->all();
if(empty($payload['project_id']) || !is_int((int)$payload['project_id'])) if (empty($payload['project_id']) || !is_int((int)$payload['project_id']))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$reports = DB::table('assign_material_to_activity as ama') $reports = DB::table('assign_material_to_activity as ama')
->select('u.name', 'a.name as activity_name', 'ama.qty_planning', 'ram.qty as qty_real','rm.description as material_name', 'rm.uom as material_unit', ->select(
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date') 'u.name',
'a.name as activity_name',
'ama.qty_planning',
'ram.qty as qty_real',
'rm.description as material_name',
'rm.uom as material_unit',
'ram.lat',
'ram.lon',
'ram.description as report_notes',
'ram.report_date'
)
->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id') ->join('report_activity_material as ram', 'ram.assign_material_id', '=', 'ama.id')
->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id') ->join('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
->join('m_activity as a', 'a.id', '=', 'ama.activity_id') ->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->join('m_users as u', 'u.id', '=', 'ram.user_id') ->join('m_users as u', 'u.id', '=', 'ram.user_id')
->where('ama.proyek_id', '=', $payload['project_id']) ->where('ama.proyek_id', '=', $payload['project_id'])
->whereNotNull('ram.lat') ->whereNotNull('ram.lat')
->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]); ->whereBetween('ram.report_date', [$payload['start_date'], $payload['end_date']]);
return response()->json(['status'=>'success', 'code'=> 200, 'data'=> $reports], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $reports], 200);
} }
public function getManpower($proyek_id){ public function getManpower($proyek_id)
{
$manCount = UserToProyek::where('proyek_id', $proyek_id)->count(); $manCount = UserToProyek::where('proyek_id', $proyek_id)->count();
return response()->json(['totalRecord'=>$manCount]); return response()->json(['totalRecord' => $manCount]);
} }
public function getAssignedHR($gantt_id){ public function getAssignedHR($gantt_id)
{
$results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date') $results = UserToActivity::select('assign_hr_to_activity.proyek_id', 'assign_hr_to_activity.user_id', 'm_activity.id', 'm_activity.name', 'm_activity.start_date', 'm_activity.end_date')
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id') ->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id')
->where('assign_hr_to_activity.version_gantt_id', $gantt_id) ->where('assign_hr_to_activity.version_gantt_id', $gantt_id)
->get(); ->get();
return response()->json(['data'=>$results]); return response()->json(['data' => $results]);
} }
public function dashboard($id) public function dashboard($id)
{ {
$data = DB::table('m_proyek as mp') $data = DB::table('m_proyek as mp')
->select('mp.kode_sortname', 'mp.nama as name_project', 'mp.mulai_proyek as start', 'mp.akhir_proyek as finish', ->select(
'mp.rencana_biaya', 'mp.company', 'mp.currency_symbol', 'mu.name as pm', 'mp.budget_health') 'mp.kode_sortname',
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id') 'mp.nama as name_project',
->where('mp.id', $id) 'mp.mulai_proyek as start',
->first(); 'mp.akhir_proyek as finish',
'mp.rencana_biaya',
if(!$data) 'mp.company',
return response()->json(['status'=>'failed','message'=>'Data tidak ditemukan!','code'=> 404], 404); 'mp.currency_symbol',
'mu.name as pm',
'mp.budget_health'
)
->join('m_users as mu', 'mu.id', '=', 'mp.pm_id')
->where('mp.id', $id)
->first();
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data tidak ditemukan!', 'code' => 404], 404);
$manpowers = UserToProyek::where('proyek_id', $id)->count(); $manpowers = UserToProyek::where('proyek_id', $id)->count();
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first(); $rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first();
@ -674,38 +741,42 @@ class ProjectController extends Controller
$progress = @$rootActivity->persentase_progress ?? 0; $progress = @$rootActivity->persentase_progress ?? 0;
$commentActivity = DB::table('m_comment_activity as mca') $commentActivity = DB::table('m_comment_activity as mca')
->select('mca.activity_id', 'mca.comment as comment', 'mca.created_by as comment_by', 'mca.created_at as comment_created', ->select(
'ma.name as activity') 'mca.activity_id',
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id') 'mca.comment as comment',
->where('ma.proyek_id', $id) 'mca.created_by as comment_by',
->orderBy('comment_by') 'mca.created_at as comment_created',
->take(2) 'ma.name as activity'
->get(); )
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id')
->where('ma.proyek_id', $id)
->orderBy('comment_by')
->take(2)
->get();
$data->actual_cost = $actualCost; $data->actual_cost = $actualCost;
$data->progress = $progress; $data->progress = $progress;
$data->comment = $commentActivity; $data->comment = $commentActivity;
$data->man_power = $manpowers; $data->man_power = $manpowers;
return response()->json(['status'=>'success','code'=>200,'data'=> $data], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
} }
private function httpReq($search){ private function httpReq($search)
$ch = curl_init(); {
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION)); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w')); curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w'));
$info = curl_getinfo($ch); $info = curl_getinfo($ch);
$output = curl_exec($ch); $output = curl_exec($ch);
curl_close($ch); curl_close($ch);
return json_decode($output); return json_decode($output);
} }
} }

1
app/Http/Controllers/UserToActivityController.php

@ -202,6 +202,7 @@ class UserToActivityController extends Controller
->where('ahta.user_id', $payload['user_id']) ->where('ahta.user_id', $payload['user_id'])
->where('ma.start_date', '<=', $payload['start_date']) ->where('ma.start_date', '<=', $payload['start_date'])
->where('ma.end_date', '>=', $payload['end_date']) ->where('ma.end_date', '>=', $payload['end_date'])
->where('ma.proyek_id', $payload['proyek_id'])
->get(); ->get();
if ($payload['status'] != "") { if ($payload['status'] != "") {

37
app/Models/Company.php

@ -0,0 +1,37 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
protected $table = 'm_company';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
"registration_no",
"company_name",
"address",
"phone_no",
"email",
"description",
"logo_login",
"logo_header",
"favicon_image",
"login_instruction",
"about",
"html_title",
"app_name",
"base_url",
"is_active",
"template_id",
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
}

36
app/Models/Divisi.php

@ -6,37 +6,39 @@ use Illuminate\Database\Eloquent\Model;
class Divisi extends Model class Divisi extends Model
{ {
protected $table = 'm_divisi'; protected $table = 'm_divisi';
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'name',
'parent', 'parent',
'description', 'description',
'color', 'color',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by',
]; 'company_id'
];
public static function boot() {
public static function boot()
{
parent::boot(); parent::boot();
static::deleting(function($data) { static::deleting(function ($data) {
$data->children()->delete(); $data->children()->delete();
}); });
} }
public function parent() public function parent()
{ {
return $this->belongsTo('App\Models\Divisi','parent')->where('parent', null)->with('parent'); return $this->belongsTo('App\Models\Divisi', 'parent')->where('parent', null)->with('parent');
} }
public function children() public function children()
{ {
return $this->hasMany('App\Models\Divisi','parent')->with('children'); return $this->hasMany('App\Models\Divisi', 'parent')->with('children');
} }
} }

3
app/Models/HumanResource.php

@ -33,6 +33,7 @@ class HumanResource extends Model
'updated_at', 'updated_at',
'updated_by', 'updated_by',
'divisi_id', 'divisi_id',
'status_boundary' 'status_boundary',
'company_id'
]; ];
} }

27
app/Models/MenuCompany.php

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MenuCompany extends Model
{
protected $table = 'm_company_menu';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'menu_id',
'parent_menu_id',
'company_id',
'icon',
'alias_name',
'url',
'sequence',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
}

22
app/Models/Project.php

@ -15,6 +15,7 @@ class Project extends Model
'kode_sortname', 'kode_sortname',
'jumlah_stakeholder', 'jumlah_stakeholder',
'nama', 'nama',
'nickname',
'mulai_proyek', 'mulai_proyek',
'akhir_proyek', 'akhir_proyek',
'area_kerja', 'area_kerja',
@ -23,16 +24,16 @@ class Project extends Model
'biaya_actual', 'biaya_actual',
'company', 'company',
'pm_id', 'pm_id',
'scoupe_of_work', 'scoupe_of_work',
'type_proyek_id', 'type_proyek_id',
'divisi_id', 'divisi_id',
'value_proyek', 'value_proyek',
'persentase_progress', 'persentase_progress',
'keterangan', 'keterangan',
'durasi_proyek', 'durasi_proyek',
'progress_by_worklog', 'progress_by_worklog',
'status', 'status',
'currency_symbol', 'currency_symbol',
'currency_code', 'currency_code',
'currency_name', 'currency_name',
'project_objectives', 'project_objectives',
@ -41,16 +42,15 @@ class Project extends Model
'testing_environment', 'testing_environment',
'budget_health', 'budget_health',
'phase_id', 'phase_id',
'late_consequence', 'late_consequence',
'assumtion', 'assumtion',
'calculation_status', 'calculation_status',
'structur_organization', 'structur_organization',
'scurve', 'scurve',
'created_at', 'created_at',
'created_by', 'created_by',
'updated_at', 'updated_at',
'updated_by' 'updated_by',
'created_by_id'
]; ];
} }

2
app/Models/ProjectPhase.php

@ -12,6 +12,6 @@ class ProjectPhase extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'color', 'order', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/ProjectRole.php

@ -12,6 +12,6 @@ class ProjectRole extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/ProjectType.php

@ -12,6 +12,6 @@ class ProjectType extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/Role.php

@ -12,6 +12,6 @@ class Role extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'default_page', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

2
app/Models/RoleMenu.php

@ -12,6 +12,6 @@ class RoleMenu extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by' 'role_id', 'menu_id', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id', "create", "read", "update", "delete"
]; ];
} }

2
app/Models/Satuan.php

@ -12,6 +12,6 @@ class Satuan extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by', 'company_id'
]; ];
} }

34
routes/web.php

@ -1,10 +1,10 @@
<?php <?php
$router->get('/', function () use ($router) { $router->get('/', function () use ($router) {
return $router->app->version(); return $router->app->version();
}); });
$router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($router) { $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($router) {
$router->post('/login', 'AuthController@login'); $router->post('/login', 'AuthController@login');
$router->post('/menu/add', 'MenuController@add'); $router->post('/menu/add', 'MenuController@add');
@ -53,7 +53,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject'); $router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen'); $router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}','ProjectController@getByUser'); $router->get('/project-by-customer/{id}', 'ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search'); $router->post('/project/search', 'ProjectController@search');
$router->post('/project/add', 'ProjectController@add'); $router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update'); $router->put('/project/update/{id}', 'ProjectController@update');
@ -211,11 +211,11 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/activity/search', 'ActivityController@search'); $router->post('/activity/search', 'ActivityController@search');
$router->post('/activity/search-analysis', 'ActivityController@searchAnalysis'); $router->post('/activity/search-analysis', 'ActivityController@searchAnalysis');
$router->post('/activity/search-analysis-prep', 'ActivityController@searchAnalysisPrep'); $router->post('/activity/search-analysis-prep', 'ActivityController@searchAnalysisPrep');
$router->post('/activity/import', 'ActivityController@import'); $router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate'); $router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld'); $router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate'); $router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule'); $router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->get('/activity/s-curve/{proyek_id}/{gantt_id}', 'ActivityController@activitySCurve'); $router->get('/activity/s-curve/{proyek_id}/{gantt_id}', 'ActivityController@activitySCurve');
$router->post('/task', 'ActivityController@add'); $router->post('/task', 'ActivityController@add');
@ -417,7 +417,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->get('/report-k3-detail/list', 'ReportK3DetailController@list'); $router->get('/report-k3-detail/list', 'ReportK3DetailController@list');
$router->post('/user-to-proyek/add', 'UserToProyekController@add'); $router->post('/user-to-proyek/add', 'UserToProyekController@add');
$router->post('/user-to-proyek/add-multiple', 'UserToProyekController@addMultiple'); $router->post('/user-to-proyek/add-multiple', 'UserToProyekController@addMultiple');
$router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit'); $router->get('/user-to-proyek/edit/{id}', 'UserToProyekController@edit');
$router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update'); $router->put('/user-to-proyek/update/{id}', 'UserToProyekController@update');
$router->post('/user-to-proyek/search', 'UserToProyekController@search'); $router->post('/user-to-proyek/search', 'UserToProyekController@search');
@ -503,6 +503,20 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/broadcast/search', 'BroadcastController@search'); $router->post('/broadcast/search', 'BroadcastController@search');
$router->delete('/broadcast/delete/{id}', 'BroadcastController@delete'); $router->delete('/broadcast/delete/{id}', 'BroadcastController@delete');
$router->get('/broadcast/list', 'BroadcastController@list'); $router->get('/broadcast/list', 'BroadcastController@list');
});
$router->post('/company-management/add', 'CompanyController@add');
$router->get('/company-management/edit/{id}', 'CompanyController@edit');
$router->put('/company-management/update/{id}', 'CompanyController@update');
$router->post('/company-management/search', 'CompanyController@search');
$router->delete('/company-management/delete/{id}', 'CompanyController@delete');
$router->get('/company-management/list', 'CompanyController@list');
$router->post('/menu-company/add-multiple', 'MenuCompanyController@addMultiple');
$router->get('/menu-company/edit/{id}', 'MenuCompanyController@edit');
$router->put('/menu-company/update/{id}', 'MenuCompanyController@update');
$router->delete('/menu-company/delete/{id}', 'MenuCompanyController@delete');
$router->post('/menu-company/search', 'MenuCompanyController@search');
$router->get('/menu-company/management/{id}', 'MenuCompanyController@listMenu');
$router->get('/menu-company/list', 'MenuCompanyController@list');
});
}); });

Loading…
Cancel
Save