Browse Source

Merge pull request 'upload 2023-12-27' (#307) from staging into master

Reviewed-on: ordo/adw-backend#307
pull/1/head
farhantock 1 year ago
parent
commit
5f37f9f36e
  1. 611
      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. 28
      app/Http/Controllers/DashboardBoDController.php
  6. 195
      app/Http/Controllers/MenuCompanyController.php
  7. 637
      app/Http/Controllers/ProjectController.php
  8. 37
      app/Models/Company.php
  9. 36
      app/Models/Divisi.php
  10. 3
      app/Models/HumanResource.php
  11. 27
      app/Models/MenuCompany.php
  12. 21
      app/Models/Project.php
  13. 2
      app/Models/ProjectPhase.php
  14. 2
      app/Models/ProjectRole.php
  15. 2
      app/Models/ProjectType.php
  16. 2
      app/Models/Role.php
  17. 2
      app/Models/RoleMenu.php
  18. 2
      app/Models/Satuan.php
  19. 34
      routes/web.php

611
app/Helpers/MasterFunctionsHelper.php

@ -36,10 +36,11 @@ class MasterFunctionsHelper
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;
$diff = date_diff($start, $end);
$endCount = clone $end;
$endCount = clone $end;
$duration = $diff->days + 1;
$daysRemaining = $duration;
// Loop until the remaining days become zero
@ -191,7 +192,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
$actualMaxDate = DB::table('assign_material_to_activity as ama')
@ -279,21 +280,20 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyPlanM->id)
->groupBy('activity_id')
->first();
if($keyPlanM->duration){
if ($keyPlanM->duration) {
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{
// $weeklyProgress = 0;
} else {
// $weeklyProgress = 0;
$weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
// $weeklyPlan = $weekCount > 0 ? $keyPlanM->bobot_planning / $weekCount : 0;
// $weeklyProgress = $weeklyPlan * $keyPlanM->bobot_planning;
$dataTempPlan[$x]['activity_id'] = $keyPlanM->id;
@ -390,7 +390,7 @@ class MasterFunctionsHelper
$tempPercentagePlan[] = round($tempTtlPercentPlan, 2);
$tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan];
if ($date < $today) {
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
$tempPercentageReal[] = round($tempTtlPercentActual, 2);
}
if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) {
break;
@ -399,7 +399,7 @@ class MasterFunctionsHelper
$tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2));
$tempPercentagePlan[] = round($sumPercentagePlan, 2);
if ($date < $today) {
$tempPercentageReal[] = round($sumPercentageActual, 2);
$tempPercentageReal[] = round($sumPercentageActual, 2);
}
}
}
@ -422,9 +422,9 @@ class MasterFunctionsHelper
$potential = "SAVING";
} else {
$potential = $costDeviation == 0 ? "ON BUDGET" : "OVERRUN";
}
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
}
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
@ -485,7 +485,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
$actualMaxDate = DB::table('assign_material_to_activity as ama')
@ -528,56 +528,58 @@ class MasterFunctionsHelper
// $minSevenDays = $minSevenDays->modify('-7 day')->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('bobot_planning', '>', 0)
->where('version_gantt_id', $keyGantt['id'])
->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay)
->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end')
->get();
->get();
$dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', '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')
)
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'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('ma.version_gantt_id', $keyGantt['id'])
->get();
$dataActivityPlan = [];
$dataActivityPlan = [];
$dataActivityActual = [];
$today = date('Y-m-d');
$statusCutOfDate = false;
// if (new \DateTime($loopDay) < $today) {
// $statusCutOfDate = true;
// }
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
}
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){
// $duration = 2;
// Tanggal awal
$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;
// $duration = 2;
// Tanggal awal
$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;
// }
@ -602,22 +604,21 @@ class MasterFunctionsHelper
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning
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;
}else{
} else {
// jika total report < dari 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;
}else{
} else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
}
}
if($keyActualM->status_activity == 'done'){
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
}
else{
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning*95)/100 ? ($keyActualM->bobot_planning*95)/100 : $progressActualWeek;
if ($keyActualM->status_activity == 'done') {
$progressActualWeek = $keyActualM->bobot_planning / $keyActualM->count_report;
} else {
$progressActualWeek = $progressActualWeek > ($keyActualM->bobot_planning * 95) / 100 ? ($keyActualM->bobot_planning * 95) / 100 : $progressActualWeek;
}
$dataActivityActual[] = array(
'progressActualDay' => $progressActualWeek,
@ -628,7 +629,7 @@ class MasterFunctionsHelper
'sum_qty_actual' => $keyActualM->sum_qty_actual,
'name' => $keyActualM->name
);
$tmpProgressActualWeek += $progressActualWeek;
}
@ -639,20 +640,20 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek,
"data_details" => $dataActivityPlanDate
],
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek,
"data_details" => $dataActivityPlanDate
],
"gantt" => $keyGantt
);
@ -696,7 +697,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
// $maxDate = DB::table('assign_material_to_activity as ama')
@ -847,17 +848,17 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC')
->first();
if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open'
];
}
if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0;
} else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
}
if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open'
];
}
if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0;
} else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
}
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
@ -865,7 +866,7 @@ class MasterFunctionsHelper
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} 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 = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
@ -900,7 +901,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
// todo
// todo
// if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100;
@ -944,7 +945,7 @@ class MasterFunctionsHelper
}
$lastReal = $tempPercentageReal[count($tempPercentageReal) - 1];
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$totalBCWP = $lastReal * $dataProject->rencana_biaya / 100;
$dataResponse = array(
"date" => $tempDate,
"percentage" => $tempPercentage,
@ -1008,7 +1009,7 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
// $maxDate = DB::table('assign_material_to_activity as ama')
@ -1103,20 +1104,19 @@ class MasterFunctionsHelper
->groupBy('activity_id')
->first();
if($keyPlanM->duration){
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
}else{
// $weeklyProgress = 0;
$weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
if ($keyPlanM->duration) {
$weekCount = $keyPlanM->duration / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
// $bobotHari = $keyPlanM->bobot_planning / $keyPlanM->duration;
} else {
// $weeklyProgress = 0;
$weekCount = 1 / 7;
$weeklyPlan = $weekCount >= 1 ? $sumVolPlan->ttl_qty_plan / $weekCount : $sumVolPlan->ttl_qty_plan / $weekCount / 7;
// $weeklyProgress = $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
$weeklyProgress = $weeklyPlan / $sumVolPlan->ttl_qty_plan * $keyPlanM->bobot_planning;
}
// $weeklyPlan = $sumVolPlan->ttl_qty_plan / $weekCount;
// $weeklyProgress = 80;
@ -1174,17 +1174,17 @@ class MasterFunctionsHelper
->where('activity_id', '=', $keyActualM->activity_id)
->orderBy('status_activity', 'ASC')
->first();
if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open'
];
}
if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0;
} else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
}
if (!isset($checkStatusActivity)) {
$checkStatusActivity = (object) [
'activity_id' => $keyActualM->activity_id,
'status_activity' => 'open'
];
}
if ($sumVolActual->ttl_qty_plan == "0") {
$actual = 0;
} else {
$actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan;
}
$dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning;
// $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
// if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){
@ -1192,7 +1192,7 @@ class MasterFunctionsHelper
$sumPercentageActual += $keyActualM->bobot_planning / $reportCount;
// $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} 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 = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual;
} else {
@ -1230,7 +1230,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') {
$tempTtlPercentPlan += $sumPercentagePlan;
$tempTtlPercentActual += $sumPercentageActual;
// todo
// todo
// if ($tempTtlPercentPlan >= 100)
// $tempTtlPercentPlan = 100;
@ -1279,7 +1279,7 @@ class MasterFunctionsHelper
// $lastReal = $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(
"date" => $tempDate,
"start" => $minDate,
@ -1351,10 +1351,10 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
$maxDate = $dataProject->akhir_proyek;
$maxDate = $dataProject->akhir_proyek;
$end = new \DateTime($maxDate);
$end = new \DateTime($end->format('Y-m-d') . ' Friday');
// $end->modify('next Friday');
@ -1411,124 +1411,125 @@ class MasterFunctionsHelper
// }
// } else {
$dataPlanM = DB::table('m_activity')
$dataPlanM = DB::table('m_activity')
->where('type_activity', 'task')
->where('bobot_planning', '>', 0)
->where('proyek_id', $projectId)
->whereDate('planned_start', '<=', $loopDay)
->whereDate('planned_end', '>=', $loopDay)
->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end')
->get();
->get();
$dataActualM = DB::table('report_activity_material as ram')
->join('m_activity as ma', 'ma.id', '=', 'ram.activity_id')
->select('ram.activity_id', 'ram.qty as qty_actual', 'ma.bobot_planning', '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')
)
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'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('ma.proyek_id', $projectId)
->get();
// }
$dataActivityPlan = [];
$dataActivityPlan = [];
$dataActivityActual = [];
$today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
}
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){
// $duration = 2;
// Tanggal awal
$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;
}
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){
// $duration = 2;
// Tanggal awal
$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
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) {
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100;
}else{
// jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if($keyActualM->qty_actual == 0){
$progressActualWeek = 0;
}else{
$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;
foreach ($dataActualM as $keyActualM) {
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning
if ($keyActualM->sum_qty_actual > $keyActualM->qty_plan) {
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) * $keyActualM->bobot_planning / 100;
} else {
// jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if ($keyActualM->qty_actual == 0) {
$progressActualWeek = 0;
} else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
}
$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(
@ -1538,18 +1539,18 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
]
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
]
);
return $dataFinal;
@ -1596,10 +1597,10 @@ class MasterFunctionsHelper
$end = new \DateTime($maxDate . ' 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');
} else {
$maxDate = $dataProject->akhir_proyek;
$maxDate = $dataProject->akhir_proyek;
$end = new \DateTime($maxDate);
$end = new \DateTime($end->format('Y-m-d') . ' Friday');
// $end->modify('next Friday');
@ -1665,126 +1666,129 @@ class MasterFunctionsHelper
->whereDate('planned_start', '<=', $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')
->get();
->get();
$dataActualM = DB::table('m_hierarchy_ftth as mhf')
->join('m_version_gantt as mvg', 'mvg.hierarchy_ftth_id', '=', 'mhf.id')
->join('m_activity as ma', 'ma.version_gantt_id', '=', 'mvg.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',
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')
)
->select(
'ram.activity_id',
'ram.qty as qty_actual',
'ma.bobot_planning',
'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('ma.proyek_id', $projectId)
->where('mhf.project_id', $projectId)
->get();
// }
$dataActivityPlan = [];
$dataActivityPlan = [];
$dataActivityActual = [];
$today = date('Y-m-d');
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2);
if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')) {
$progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek, 2);
if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) {
// $tempPercentageReal[] = round($tempTtlPercentActual, 2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2);
$progressActualKomulatifWeek[] += round($tmpProgressActualWeek, 2);
}
$dateWeek[] = [$loopDay];
$dateWeek[] = [$loopDay];
}
// $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek;
// if (count($dataPlanM) > 0 && count($dataPlanM[0]) > 0) {
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){
// $duration = 2;
// Tanggal awal
if (count($keyPlanM) == 0) {
continue;
}
$startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end);
// 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;
foreach ($dataPlanM as $keyPlanM) {
# hitung untuk persentase progress planning
// if($keyPlanM->duration == 0){
// $duration = 2;
// Tanggal awal
if (count($keyPlanM) == 0) {
continue;
}
$startDate = new DateTime($keyPlanM->planned_start);
// Tanggal akhir
$endDate = new DateTime($keyPlanM->planned_end);
// 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
// if (count($dataActualM) > 0 && count($dataActualM[0]) > 0) {
foreach ($dataActualM as $keyActualM) {
foreach ($dataActualM as $keyActualM) {
if (count($keyPlanM) == 0) {
continue;
}
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning
if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100;
}else{
// jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if($keyActualM->qty_actual == 0){
$progressActualWeek = 0;
}else{
$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;
# hitung untuk persentase progress actual
// $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100;
// jika total report > dari planning
if ($keyActualM->sum_qty_actual > $keyActualM->qty_plan) {
$progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) * $keyActualM->bobot_planning / 100;
} else {
// jika total report < dari planning
// $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning;
if ($keyActualM->qty_actual == 0) {
$progressActualWeek = 0;
} else {
$progressActualWeek = ($keyActualM->qty_actual / $keyActualM->qty_plan) * $keyActualM->bobot_planning;
}
$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(
@ -1794,18 +1798,18 @@ class MasterFunctionsHelper
"activity-actual" => $dataActivityActual,
"tmpProgressActualWeek" => $tmpProgressActualWeek,
"progressPlanWeek" => $tmpProgressPlanWeek
);
);
}
$dataFinal[] = array(
// "date" => $dateWeek,
"proyek_name" => $dataProject->nama,
"data" => ["date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
]
"data" => [
"date" => $dateWeek,
"percentagePlan" => $progressPlanKomulatifWeek,
"percentageReal" => $progressActualKomulatifWeek
// "data_details" => $dataActivityPlanDate
]
);
return $dataFinal;
@ -1849,7 +1853,7 @@ class MasterFunctionsHelper
if (isset($dataPayload['end_date'])) {
$maxDate = $dataPayload['end_date'];
$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');
} else {
// $maxDate = DB::table('assign_material_to_activity as ama')
@ -2040,5 +2044,4 @@ class MasterFunctionsHelper
return $dataFinal;
}
}

37
app/Http/Controllers/AuthController.php

@ -11,6 +11,7 @@ use App\Models\Role;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function __construct()
@ -25,46 +26,50 @@ class AuthController extends Controller
$remember = $request->remember;
$is_mobile = $request->is_mobile;
if(empty($username) || empty($password))
return response()->json(['status'=>'error','message'=>'You must fill all the fields'], 400);
if (empty($username) || empty($password))
return response()->json(['status' => 'error', 'message' => 'You must fill all the fields'], 400);
$usernameCheck = false;
$passwordCheck = false;
if (User::where('username', $username)->exists())
if (User::where('username', $username)->exists())
$usernameCheck = true;
if (User::where('password', md5($password))->exists())
if (User::where('password', md5($password))->exists())
$passwordCheck = true;
if ($usernameCheck & $passwordCheck){
if ($usernameCheck & $passwordCheck) {
$user = User::where('username', $username)->where('password', md5($password))->first();
if($is_mobile){
if ($is_mobile) {
$fcm_token = $request->fcm_token;
if(!$fcm_token || $fcm_token=="")
return response()->json(['status'=>'error','message'=>'FCM Token is required'], 400);
if (!$fcm_token || $fcm_token == "")
return response()->json(['status' => 'error', 'message' => 'FCM Token is required'], 400);
$dataUpdateFcm = array(
"fcm_token"=>$fcm_token
"fcm_token" => $fcm_token
);
$hr = User::find($user->id);
if($hr)
if ($hr)
$hr->update($dataUpdateFcm);
}
$dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
if($dataRole)
if ($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);
$ttl = 60;
if($remember)
if ($remember)
$ttl = 10080;
// 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,
),
]);
}else {
} else {
if (!$usernameCheck && !$passwordCheck)
return response()->json(['code' => 201, 'message' => "username and password doesn't match"], 201);
if (!$passwordCheck)
return response()->json(['code' => 201, 'message' => "password doesn't match"], 201);
if (!$usernameCheck)
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
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use App\Models\UserToActivity;
use App\Models\Activity;
use App\Models\AssignMaterial;
use App\Models\Divisi;
use App\Models\User;
use Laravel\Lumen\Routing\Controller as BaseController;
use App\Models\ReportK3Detail;
@ -16,18 +19,21 @@ class Controller extends BaseController
protected $pathDocument = "assets/file/project/";
protected $pathTmpImport = "assets/file/tmpimport/";
protected $pathActivityDocument = "assets/file/activity/";
protected $listJoinAll = ['first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
protected $listJoinAll = [
'first', 'second', 'third', 'fourth', 'fifth',
'sixth', 'seventh', 'eighth', 'ninth', 'tenth'
];
protected $currentDate;
protected $currentName;
protected $currentId;
protected $companyId;
public function __construct()
{
$this->currentDate = date("Y-m-d H:i:s");
$this->currentName = auth()->user() ? auth()->user()->name : "system";
$this->currentId = auth()->user() ? auth()->user()->id : 0;
$this->companyId = auth()->user() ? auth()->user()->company_id : 0;
$this->pathImage = config('assets.image');
$this->pathDocument = config('assets.project');
$this->pathActivityDocument = config('assets.activity');
@ -36,43 +42,43 @@ class Controller extends BaseController
protected function setUpPayload($condition, $tableSelf)
{
$alias = "selfTable";
$builder = DB::table($tableSelf." AS ".$alias);
$builder = DB::table($tableSelf . " AS " . $alias);
// $builder = $builder->select($alias.".*");
if($condition){
if(isset($condition['select'])){
foreach($condition['select'] as $select){
$builder = $builder->addSelect($alias.".".$select);
if ($condition) {
if (isset($condition['select'])) {
foreach ($condition['select'] as $select) {
$builder = $builder->addSelect($alias . "." . $select);
}
}else{
$builder = $builder->addSelect($alias.".*");
} else {
$builder = $builder->addSelect($alias . ".*");
}
if(isset($condition['joins'])){
if (isset($condition['joins'])) {
$selectColumn = [];
$no = 0;
foreach($condition['joins'] as $join){
foreach ($condition['joins'] as $join) {
$tableJoin = isset($join['name1']) ? $join['name1'] : $alias;
$tableName = $join['name'];
$columnJoin = $join['column_join']; // foreign key table sini
$columnSelf = isset($join['column_self']) ? $join['column_self'] : "id"; // primary key table lawan
if (isset($join['column_results'])) {
$columnResult = $join['column_results'];
$columnResult = $join['column_results'];
foreach($columnResult as $sColumn){
$builder = $builder->addSelect($tableName.".".$sColumn." as join_".$this->listJoinAll[$no]."_".$sColumn);
}
foreach ($columnResult as $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++;
}
}
if(isset($condition['columns'])){
if (isset($condition['columns'])) {
$listWhere = $condition['columns'];
$builder = $builder->where(function ($query) use($listWhere, $alias){
foreach($listWhere as $where){
$builder = $builder->where(function ($query) use ($listWhere, $alias) {
foreach ($listWhere as $where) {
$value = $where['value'];
if($value && $value!="" && $value!=" "){
if ($value && $value != "" && $value != " ") {
$column = $where['name'];
$operator = strtolower($where['logic_operator']); // like, =, <>, range
$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);
}
$data['count'] = clone $builder;
if(isset($condition['paging'])){
if (isset($condition['paging'])) {
$builder = $builder->offset($condition['paging']['start'])->limit($condition['paging']['length']);
}
if(isset($condition['orders'])){
if (isset($condition['orders'])) {
$orders = $condition['orders'];
$sortBy = $orders['ascending'] ? "ASC" : "DESC";
$columnOrder = $orders['columns'];
foreach($columnOrder as $column){
$builder = $builder->orderBy($alias.".".$column, $sortBy);
foreach ($columnOrder as $column) {
$builder = $builder->orderBy($alias . "." . $column, $sortBy);
}
}
}
@ -113,8 +119,8 @@ class Controller extends BaseController
$operator = $listGroupWhere['operator'];
$operatorGroup = $listGroupWhere['group_operator'];
$listWhere = $listGroupWhere['where'];
if(strtolower($operator)=="and"){
$builder = $builder->where(function($query) use($operatorGroup, $listWhere, $alias){
if (strtolower($operator) == "and") {
$builder = $builder->where(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1;
foreach ($listWhere as $where) {
$value = $where['value'];
@ -122,22 +128,22 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){
if($operatorGroup=="and"){
if ($value && $value != "" && $value != " ") {
if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{
if($no==1){
} else {
if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{
} else {
$query = $this->orWhereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}
}
}
$no = $no+1;
$no = $no + 1;
}
});
}else if(strtolower($operator)=="or"){
$builder = $builder->orWhere(function($query) use($operatorGroup, $listWhere, $alias){
} else if (strtolower($operator) == "or") {
$builder = $builder->orWhere(function ($query) use ($operatorGroup, $listWhere, $alias) {
$no = 1;
foreach ($listWhere as $where) {
$value = $where['value'];
@ -145,13 +151,13 @@ class Controller extends BaseController
$operator = strtolower($where['logic_operator']);
$value2 = isset($where['value1']) ? $where['value1'] : "";
$tableColumn = isset($where['table_name']) ? $where['table_name'] : $alias;
if($value && $value!="" && $value!=" "){
if($operatorGroup=="and"){
if ($value && $value != "" && $value != " ") {
if ($operatorGroup == "and") {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{
if($no==1){
} else {
if ($no == 1) {
$query = $this->whereCondition($query, $operator, $tableColumn, $column, $value, $value2);
}else{
} else {
$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)
{
$query = $oldQuery;
if($operator=="range"){
$query = $query->whereBetween($tableColumn.".".$column, [$value, $value2]);
}else if($operator=="like"){
$query = $query->where($tableColumn.".".$column, 'like', '%'.$value.'%');
}else if($operator=="ilike"){
$query = $query->where($tableColumn.".".$column, '~*', $value);
}else if($operator=="="){
$query = $query->where($tableColumn.".".$column, $value);
}else if($operator=="in"){
$query = $query->whereIn($tableColumn.".".$column, $value);
}else if($operator=="notin"){
$query = $query->whereNotIn($tableColumn.".".$column, $value);
}else{
$query = $query->where($tableColumn.".".$column, $operator, $value);
if ($operator == "range") {
$query = $query->whereBetween($tableColumn . "." . $column, [$value, $value2]);
} else if ($operator == "like") {
$query = $query->where($tableColumn . "." . $column, 'like', '%' . $value . '%');
} else if ($operator == "ilike") {
$query = $query->where($tableColumn . "." . $column, '~*', $value);
} else if ($operator == "=") {
$query = $query->where($tableColumn . "." . $column, $value);
} else if ($operator == "in") {
$query = $query->whereIn($tableColumn . "." . $column, $value);
} else if ($operator == "notin") {
$query = $query->whereNotIn($tableColumn . "." . $column, $value);
} else {
$query = $query->where($tableColumn . "." . $column, $operator, $value);
}
return $query;
}
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2){
private function whereConditionSingleTable($oldQuery, $operator, $column, $value, $value2)
{
$query = $oldQuery;
if($operator=="range"){
if ($operator == "range") {
$query = $query->whereBetween($column, [$value, $value2]);
}else if($operator=="like"){
$query = $query->where($column, 'like', '%'.$value.'%');
}else if($operator=="ilike"){
} else if ($operator == "like") {
$query = $query->where($column, 'like', '%' . $value . '%');
} else if ($operator == "ilike") {
$query = $query->where($column, '~*', $value);
}else if($operator=="="){
} else if ($operator == "=") {
$query = $query->where($column, $value);
}else if($operator=="in"){
} else if ($operator == "in") {
$query = $query->whereIn($column, $value);
}else if($operator=="notin"){
} else if ($operator == "notin") {
$query = $query->whereNotIn($column, $value);
}else{
} else {
$query = $query->where($column, $operator, $value);
}
return $query;
@ -207,25 +214,26 @@ class Controller extends BaseController
private function orWhereCondition($oldQuery, $operator, $tableColumn, $column, $value, $value2)
{
$query = $oldQuery;
if($operator=="range"){
$query = $query->orWhereBetween($tableColumn.".".$column, [$value, $value2]);
}else if($operator=="like"){
$query = $query->orWhere($tableColumn.".".$column, 'like', '%'.$value.'%');
}else if($operator=="ilike"){
$query = $query->where($tableColumn.".".$column, '~*', $value);
}else if($operator=="="){
$query = $query->orWhere($tableColumn.".".$column, $value);
}else if($operator=="in"){
$query = $query->orWhereIn($tableColumn.".".$column, $value);
}else if($operator=="notin"){
$query = $query->orWhereNotIn($tableColumn.".".$column, $value);
}else{
$query = $query->orWhere($tableColumn.".".$column, $operator, $value);
if ($operator == "range") {
$query = $query->orWhereBetween($tableColumn . "." . $column, [$value, $value2]);
} else if ($operator == "like") {
$query = $query->orWhere($tableColumn . "." . $column, 'like', '%' . $value . '%');
} else if ($operator == "ilike") {
$query = $query->where($tableColumn . "." . $column, '~*', $value);
} else if ($operator == "=") {
$query = $query->orWhere($tableColumn . "." . $column, $value);
} else if ($operator == "in") {
$query = $query->orWhereIn($tableColumn . "." . $column, $value);
} else if ($operator == "notin") {
$query = $query->orWhereNotIn($tableColumn . "." . $column, $value);
} else {
$query = $query->orWhere($tableColumn . "." . $column, $operator, $value);
}
return $query;
}
protected function calculateAllCost($activity_id, $proyek_id){
protected function calculateAllCost($activity_id, $proyek_id)
{
$humanCostPlanning = $this->calculateAllHumanCost($activity_id, $proyek_id);
$materialCostPlanning = $this->calculateMaterialCost($activity_id, $proyek_id);
$toolsCostPlanning = 0;
@ -236,11 +244,11 @@ class Controller extends BaseController
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")
->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("ahp.proyek_id", $proyek_id)
->get();
$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")
->where("assign_hr_to_activity.activity_id", $activity_id)->where("assign_hr_to_activity.proyek_id", $proyek_id)
->where("ahp.proyek_id", $proyek_id)
->get();
$totalCost = 0;
foreach ($dataHuman as $human) {
@ -255,61 +263,110 @@ class Controller extends BaseController
$activity = Activity::find($activity_id);
$duration = $activity->duration;
$standarRate = $human->standart_rate;
$maxUsed = $human->max_used/100;
$maxUsed = $human->max_used / 100;
if ($human->uom_standart_rate == "Hour") {
$totalCost = ($standarRate*8*$duration)*$maxUsed;
return $totalCost;
$totalCost = ($standarRate * 8 * $duration) * $maxUsed;
return $totalCost;
}
$totalCost = ($standarRate*$duration)*$maxUsed;
$totalCost = ($standarRate * $duration) * $maxUsed;
return $totalCost;
}
private function calculateMaterialCost($activity_id, $proyek_id)
{
$totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost")
->where("proyek_id", $proyek_id)
->where("activity_id", $activity_id)
->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)"));
$totalCost = AssignMaterial::selectRaw("COALESCE(qty_planning,0)*COALESCE(budget,0) as totalCost")
->where("proyek_id", $proyek_id)
->where("activity_id", $activity_id)
->sum(AssignMaterial::raw("COALESCE(qty_planning, 0) * COALESCE(budget, 0)"));
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");
// return $response->json;
$url = config('api.nominatim') . "/reverse?lat=".$lat."&lon=".$lng."&format=json";
// $token = config('api.adw_token');
$response = $this->curlRequest($url);
$url = config('api.nominatim') . "/reverse?lat=" . $lat . "&lon=" . $lng . "&format=json";
// $token = config('api.adw_token');
$response = $this->curlRequest($url);
return $response;
}
private function curlRequest($url){
$ch = curl_init();
// $headers = [
// 'Authorization: '.$token
// ];
curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
private function curlRequest($url)
{
$ch = curl_init();
// $headers = [
// 'Authorization: '.$token
// ];
curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if ($response === false)
$response = curl_error($ch);
curl_close($ch);
$response = curl_exec($ch);
if ($response === false)
$response = curl_error($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) {
$dataNew = array(
"report_k3_id"=>$report_id,
"checklist_k3_id"=>$value['checklist_id'],
"name_checklist_k3"=>$value['checklist_name'],
"created_by"=>$this->currentName
"report_k3_id" => $report_id,
"checklist_k3_id" => $value['checklist_id'],
"name_checklist_k3" => $value['checklist_name'],
"created_by" => $this->currentName
);
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;
}
}

28
app/Http/Controllers/DashboardBoDController.php

@ -41,14 +41,14 @@ class DashboardBoDController extends Controller
private function getInvoiceIntegration($search)
{
if(empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$token = config('api.adw_token');
$response = $this->curlReq($url, $token);
if(@$response->data->project_no == "")
if (@$response->data->project_no == "")
return null;
return $response;
@ -83,7 +83,6 @@ class DashboardBoDController extends Controller
$totalInvoice += $resp->data->total_invoice_amount ?? 0;
$totalPaidInvoice += $resp->data->total_invoice_paid_amount ?? 0;
}
}
return response()->json([
@ -110,6 +109,7 @@ class DashboardBoDController extends Controller
array_push($return, [
'project' => $project->nama,
'project_code' => $project->kode_sortname,
'nickname' => $project->nickname,
'invoiced' => $resp->data->total_invoice_amount ?? 0,
'paid' => $resp->data->total_invoice_paid_amount ?? 0,
'response' => $resp,
@ -147,15 +147,13 @@ class DashboardBoDController extends Controller
}
$selisihProgress = $planningProgress - $actualProgress;
try {
if ($selisihProgress > 0 && $selisihProgress <= 5){
if ($selisihProgress > 0 && $selisihProgress <= 20) {
$return['warning'] += 1;
$projects[$index]->status = 'warning';
}
elseif ($selisihProgress == 0){
} elseif ($selisihProgress == 0) {
$return['on-schedule'] += 1;
$projects[$index]->status = 'on-schedule';
}
else {
} else {
$return['behind-schedule'] += 1;
$projects[$index]->status = 'behind-schedule';
}
@ -191,13 +189,11 @@ class DashboardBoDController extends Controller
$actualProgress = !empty($actualArray) ? $actualArray[count($actualArray) - 1] : 0;
}
$selisihProgress = $planningProgress - $actualProgress;
if ($selisihProgress > 0 && $selisihProgress <= 5){
if ($selisihProgress > 0 && $selisihProgress <= 5) {
$warning++;
}
elseif ($selisihProgress == 0){
} elseif ($selisihProgress == 0) {
$onSchedule++;
}
else {
} else {
$behindSchedule++;
}
}
@ -294,7 +290,7 @@ class DashboardBoDController extends Controller
{
$year = $this->interpolateYear($year);
$divisions = Divisi::select('id', 'name','parent','color')
$divisions = Divisi::select('id', 'name', 'parent', 'color')
->with('children')
->whereNull('parent')
->get();

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);
}
}
}

637
app/Http/Controllers/ProjectController.php

@ -50,7 +50,7 @@ class ProjectController extends Controller
{
$this->validate($request, [
'nama' => 'required',
'mulai_proyek' => 'required',
'mulai_proyek' => 'required',
'akhir_proyek' => 'required',
'rencana_biaya' => 'required',
'type_proyek_id' => 'required',
@ -60,87 +60,117 @@ class ProjectController extends Controller
$data = $request->all();
$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;
$result = Project::create($data);
if(!$result)
return response()->json(['status'=>'failed','message'=>'Failed to add data!','code'=> 500], 500);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to add data!', 'code' => 500], 500);
$this->createOfficeHours($result->id);
$dataResultInsert = Project::where('nama', $data['nama'])->where('mulai_proyek', $data['mulai_proyek'])->first();
return response()->json(['status'=>'success','message'=>'Data added!', 'data_result' =>$dataResultInsert, 'code'=> 200], 200);
return response()->json(['status' => 'success', 'message' => 'Data added!', 'data_result' => $dataResultInsert, 'code' => 200], 200);
}
public function edit($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
public function edit($id)
{
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
// $result = Project::query()
// ->from('m_proyek AS mp')
// ->where('mp.id', $id)
// ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,
// $result = Project::query()
// ->from('m_proyek AS mp')
// ->where('mp.id', $id)
// ->selectRaw('value_proyek,scoupe_of_work,kode_sortname,jumlah_stakeholder,nama,mulai_proyek,akhir_proyek,
// area_kerja,rencana_biaya,biaya_actual,company,pm_id,type_proyek_id,divisi_id,persentase_progress,keterangan,durasi_proyek,progress_by_worklog,currency_symbol,late_consequence,assumtion,currency_code,currency_name,project_objectives,considered_success_when,potential_risk,testing_environment,budget_health,phase_id,calculation_status');
// if (!is_null($result->first()['divisi_id'])) {
// $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
// ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = Project::select('value_proyek','scoupe_of_work','kode_sortname','jumlah_stakeholder','nama','mulai_proyek','akhir_proyek',
'area_kerja','rencana_biaya','biaya_actual','company','pm_id','type_proyek_id','divisi_id','persentase_progress',
'keterangan','durasi_proyek','progress_by_worklog','currency_symbol','late_consequence','assumtion','currency_code',
'currency_name','project_objectives','considered_success_when','potential_risk','testing_environment','budget_health',
'phase_id','calculation_status','md.name as divisi_name', '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);
// if (!is_null($result->first()['divisi_id'])) {
// $result->leftJoin('m_divisi', 'mp.divisi_id', '=', 'm_divisi.id')
// ->addSelect(DB::raw('m_divisi.name AS nama_divisi'));
// }
$result = Project::select(
'value_proyek',
'scoupe_of_work',
'kode_sortname',
'jumlah_stakeholder',
'nama',
'mulai_proyek',
'akhir_proyek',
'area_kerja',
'rencana_biaya',
'biaya_actual',
'company',
'pm_id',
'type_proyek_id',
'divisi_id',
'persentase_progress',
'keterangan',
'durasi_proyek',
'progress_by_worklog',
'currency_symbol',
'late_consequence',
'assumtion',
'currency_code',
'currency_name',
'project_objectives',
'considered_success_when',
'potential_risk',
'testing_environment',
'budget_health',
'phase_id',
'calculation_status',
'md.name as divisi_name',
'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)
{
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($id) || !is_int((int)$id))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$data = Project::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$result = $data->update($request->all());
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Failed to update!','code'=> 500], 500);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Failed to update!', 'code' => 500], 500);
return response()->json(['status'=>'success','message'=>'Data updated!','code' => 200], 200);
return response()->json(['status' => 'success', 'message' => 'Data updated!', 'code' => 200], 200);
}
private function createOfficeHours($proyek_id)
{
$dataCreate = array(
"proyek_id"=>$proyek_id,
"monday_start"=> "08:00:00",
"monday_end"=> "16:00:00",
"tuesday_start"=> "08:00:00",
"tuesday_end"=> "16:00:00",
"wednesday_start"=> "08:00:00",
"wednesday_end"=> "16:00:00",
"thursday_start"=> "08:00:00",
"thursday_end"=> "16:00:00",
"friday_start"=> "08:00:00",
"friday_end"=> "16:00:00",
"saturday_start"=> "08:00:00",
"saturday_end"=> "16:00:00",
"sunday_start"=> "08:00:00",
"sunday_end"=> "16:00:00",
"created_by"=> $this->currentName
"proyek_id" => $proyek_id,
"monday_start" => "08:00:00",
"monday_end" => "16:00:00",
"tuesday_start" => "08:00:00",
"tuesday_end" => "16:00:00",
"wednesday_start" => "08:00:00",
"wednesday_end" => "16:00:00",
"thursday_start" => "08:00:00",
"thursday_end" => "16:00:00",
"friday_start" => "08:00:00",
"friday_end" => "16:00:00",
"saturday_start" => "08:00:00",
"saturday_end" => "16:00:00",
"sunday_start" => "08:00:00",
"sunday_end" => "16:00:00",
"created_by" => $this->currentName
);
OfficeHours::create($dataCreate);
@ -152,15 +182,15 @@ class ProjectController extends Controller
{
$data = Project::find($id);
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$this->deleteRelative($id);
if(!$data->delete())
return response()->json(['status'=>'failed','message'=>'Delete failed!','code'=> 500], 500);
if (!$data->delete())
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)
@ -175,12 +205,12 @@ class ProjectController extends Controller
ProjectChecklists::where('proyek_id', $project_id)->delete();
ProjectIssues::where('proyek_id', $project_id)->delete();
ProjectRisks::where('proyek_id', $project_id)->delete();
ProjectToChecklistK3::where('proyek_id', $project_id)->delete();
HierarchyFtth::where('project_id', $project_id)->delete();
AssignTools::where('proyek_id', $project_id)->delete();
OfficeHours::where('proyek_id', $project_id)->delete();
ReportK3::where('proyek_id', $project_id)->delete();
RequestMaterial::where('proyek_id', $project_id)->delete();
ProjectToChecklistK3::where('proyek_id', $project_id)->delete();
HierarchyFtth::where('project_id', $project_id)->delete();
AssignTools::where('proyek_id', $project_id)->delete();
OfficeHours::where('proyek_id', $project_id)->delete();
ReportK3::where('proyek_id', $project_id)->delete();
RequestMaterial::where('proyek_id', $project_id)->delete();
$this->deleteVersionGantt($project_id);
$this->deleteDokumenProject($project_id);
}
@ -195,16 +225,16 @@ class ProjectController extends Controller
foreach ($dataRa as $ra) {
$images = Image::where("ref_id", $ra->id)->where("category", "report_activity")->get();
foreach ($images as $image) {
if(file_exists($this->pathImage.$image->image)){
unlink($this->pathImage.$image->image);
if (file_exists($this->pathImage . $image->image)) {
unlink($this->pathImage . $image->image);
}
}
Image::where("ref_id", $ra->id)->where("category", "report_activity")->delete();
}
$dataAd = ActivityDokumen::whereIn("activity_id", $activityIds)->get();
foreach ($dataAd as $ad) {
if(file_exists($this->pathActivityDocument.$ad->file)){
unlink($this->pathActivityDocument.$ad->file);
if (file_exists($this->pathActivityDocument . $ad->file)) {
unlink($this->pathActivityDocument . $ad->file);
}
}
ActivityDokumen::whereIn("activity_id", $activityIds)->delete();
@ -222,8 +252,8 @@ class ProjectController extends Controller
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument . $dokumen->file);
}
}
DokumenProject::where("type_dokumen", "project-document-out-folder")->where('ref_id', $project_id)->delete();
@ -232,8 +262,8 @@ class ProjectController extends Controller
$ref_ids = $dataFolder->all();
$dataDokumen = DokumenProject::where("type_dokumen", "project-document-in-folder")->whereIn('ref_id', $ref_ids)->get();
foreach ($dataDokumen as $dokumen) {
if(file_exists($this->pathDocument.$dokumen->file)){
unlink($this->pathDocument.$dokumen->file);
if (file_exists($this->pathDocument . $dokumen->file)) {
unlink($this->pathDocument . $dokumen->file);
}
}
@ -247,11 +277,11 @@ class ProjectController extends Controller
$dataBuilder = $this->setUpPayload($payload, 'm_proyek');
$builder = $dataBuilder['builder'];
$countBuilder = $dataBuilder['count'];
// $builder->where("selfTable.created_by",$this->currentName);
// $builder->where("selfTable.created_by",$this->currentName);
$dataGet = $builder->get();
$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()
@ -293,107 +323,116 @@ class ProjectController extends Controller
'created_by',
'updated_at',
'updated_by'
)->orderBy('id', 'desc')
// ->where("created_by",$this->currentName)
->get();
)->orderBy('id', 'desc')
// ->where("created_by",$this->currentName)
->get();
$countData = $data->count();
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$data)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost')));
$totalActualCost = $data->sum('actualCost');
$totalPlannedCost = array_sum(array_map('intval', array_column($data->toArray(), 'plannedCost')));
$totalActualCost = $data->sum('actualCost');
$manpowers = User::count();
$projectsOnDanger = Project::where('budget_health', 'overrun')->count();
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name');
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name');
try {
$projectsByPhase = DB::table('m_proyek')
->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')
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color')
->get();
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]);
}
try {
$projectsByType = DB::table('m_proyek')
->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')
->groupBy('m_type_proyek.name')
->get();
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]);
}
$projectPhases = ProjectPhase::orderBy('order', 'asc')->pluck('name');
$projectTypes = ProjectType::orderBy('id', 'asc')->pluck('name');
try {
$projectsByPhase = DB::table('m_proyek')
->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')
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color')
->get();
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]);
}
try {
$projectsByType = DB::table('m_proyek')
->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')
->groupBy('m_type_proyek.name')
->get();
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()]);
}
return response()->json(
[
'status'=>'success',
'code'=>200,
'data'=>$data,
'totalRecord'=>$countData,
'totalPlannedCost' => $totalPlannedCost,
'totalActualCost' => $totalActualCost,
'totalRevenue' => $totalPlannedCost - $totalActualCost,
'manpowers' => $manpowers,
'projectsOnDanger'=> $projectsOnDanger,
'projectPhases' => $projectPhases,
'projectsByPhase' => $projectsByPhase,
'projectTypes' => $projectTypes,
'projectsByType' => $projectsByType,
], 200);
[
'status' => 'success',
'code' => 200,
'data' => $data,
'totalRecord' => $countData,
'totalPlannedCost' => $totalPlannedCost,
'totalActualCost' => $totalActualCost,
'totalRevenue' => $totalPlannedCost - $totalActualCost,
'manpowers' => $manpowers,
'projectsOnDanger' => $projectsOnDanger,
'projectPhases' => $projectPhases,
'projectsByPhase' => $projectsByPhase,
'projectTypes' => $projectTypes,
'projectsByType' => $projectsByType,
],
200
);
}
public function getListProjectTask($id){
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id","m_proyek.*")
public function getListProjectTask($id)
{
$data = UserToActivity::select("assign_hr_to_activity.user_id as user_id", "m_proyek.*")
->where("assign_hr_to_activity.user_id", $id)
->join('m_proyek', 'assign_hr_to_activity.proyek_id', '=', 'm_proyek.id')
->groupBy("m_proyek.proyek_id")
->get();
if(!$data)
return response()->json(['status'=>'failed','message'=>'Data not found!','code'=> 404], 404);
if (!$data)
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);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
// testing
public function calculateSCurvetest(Request $request){
$data = MasterFunctionsHelper::calculateSCurve($request->project_id);
return response()->json(['status'=>'success','code'=>200, 'data' => $data], 200);
}
// testing
public function calculateSCurvetest(Request $request)
{
$data = MasterFunctionsHelper::calculateSCurve($request->project_id);
return response()->json(['status' => 'success', 'code' => 200, 'data' => $data], 200);
}
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);
}
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);
}
public function sCurveCommand(Request $request){
Artisan::call('calculate:scurve', [
'project_id' => $request->project_id
]);
// $project = Project::find($request->project_id);
public function sCurveCommand(Request $request)
{
Artisan::call('calculate:scurve', [
'project_id' => $request->project_id
]);
// $project = Project::find($request->project_id);
// if ($project) {
// dispatch(new ProcessSCurve($project));
// if ($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);
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();
if (!isset($status)) {
$reports = array(
@ -425,17 +464,17 @@ class ProjectController extends Controller
return $reports;
}
public function synchronizeReport($gantt_id)
public function synchronizeReport($gantt_id)
{
$activities = Activity::where("version_gantt_id", $gantt_id)->get();
$reports = [];
foreach($activities as $activity) {
foreach ($activities as $activity) {
$activity_id = $activity->id;
$countReports = ReportActivityMaterial::where('activity_id', $activity_id)->count();
if ($countReports === 1) {
$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);
}
}
@ -456,15 +495,15 @@ class ProjectController extends Controller
/* return response()->json(['status'=>'success','data'=> $reports,'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']);
if($reports[$i]['status'] != 'done'){
if ($reports[$i]['status'] != 'done') {
$reports[$i]['max_date']->modify('-1 day');
}else if($reports[$i]['status'] == 'done'){
$activity->actual_end = $reports[$i]['max_date']->setTime(23,59,59);
} else if ($reports[$i]['status'] == 'done') {
$activity->actual_end = $reports[$i]['max_date']->setTime(23, 59, 59);
}
$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);
$endDate = new DateTime($activity->end_date);
$duration = MasterFunctionsHelper::countDays($activity->version_gantt_id, $startDate, $endDate);
@ -473,7 +512,7 @@ class ProjectController extends Controller
$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)
@ -482,104 +521,104 @@ class ProjectController extends Controller
foreach ($activities as $activity) {
$activity->update([
"planned_start"=>$activity->start_date,
"planned_end"=>$activity->end_date,
"early_start"=>$activity->start_date,
"early_end"=>$activity->end_date,
"planned_start" => $activity->start_date,
"planned_end" => $activity->end_date,
"early_start" => $activity->start_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) {
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
public function getInvoiceIntegration(Request $request)
{
$ganttCount = VersionGantt::where('proyek_id', $request->id)->count();
$search = urlencode($request->search);
if(empty($search))
return response()->json(['status'=>'error', 'message'=>'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw').'/project_cost?project_no=SEARCH');
if (empty($search))
return response()->json(['status' => 'error', 'message' => 'Empty query string!'], 400);
$url = str_replace("SEARCH", $search, config('api.adw') . '/project_cost?project_no=SEARCH');
$response = MasterFunctionsHelper::curlReq($url);
if (isset($request->gantt_id)) {
$response->data->total_cost = $response->data->total_cost / $ganttCount;
}
if (isset($request->gantt_id)) {
$response->data->total_cost = $response->data->total_cost / $ganttCount;
}
return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
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', '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);
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', '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);
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Data not found!','code'=> 404], 404);
if (!isset($gantt_id)) {
$gantt = MasterFunctionsHelper::getLatestGantt($id);
$ganttId = $gantt['last_gantt_id'];
} else {
$ganttId = $gantt_id;
}
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Data not found!', 'code' => 404], 404);
if (!isset($gantt_id)) {
$gantt = MasterFunctionsHelper::getLatestGantt($id);
$ganttId = $gantt['last_gantt_id'];
} else {
$ganttId = $gantt_id;
}
$result->projectManager = User::where('id', $result->pm_id)->value('name');
if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if($result['type_proyek_id'] === 9)
{
// $actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id);
if (isset($s_curve)) {
$result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->first();
$actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists();
if ($result['type_proyek_id'] === 9) {
// $actualEndExist = Activity::where('proyek_id', $id)->exists();
$query = Activity::where('proyek_id', $id);
$maxEndDate = Activity::where('proyek_id', $id)->select('end_date')
->orderBy('end_date', 'desc')
->first();
}else{
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
->orderBy('end_date', 'desc')
->first();
} else {
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId);
}
} else {
$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();
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId);
}
} else {
$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();
// $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists();
$maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date')
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId);
}
if ($actualStartExist) {
$startDate = $query->orderBy('actual_start')->value('start_date');
} else {
$startDate = $query->orderBy('start_date')->value('start_date');
}
// if($actualEndExist)
// {
// // $maxEndDate = $query->max('id');
->orderBy('end_date', 'desc')
->first();
$query = Activity::where('version_gantt_id', $ganttId);
}
if ($actualStartExist) {
$startDate = $query->orderBy('actual_start')->value('start_date');
} else {
$startDate = $query->orderBy('start_date')->value('start_date');
}
// if($actualEndExist)
// {
// // $maxEndDate = $query->max('id');
// // 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)
->orderBy('planned_start')
@ -587,34 +626,36 @@ class ProjectController extends Controller
$plannedEnd = Activity::where('version_gantt_id', $ganttId)
->orderByDesc('planned_end')
->value('planned_end');
$result->header->start_date = $startDate;
$result->header->end_date = $maxEndDate->end_date;
$result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
if (isset($result->header)) {
$result->header->start_date = $startDate;
$result->header->end_date = $maxEndDate->end_date;
$result->header->planned_start = $plannedStart;
$result->header->planned_end = $plannedEnd;
}
return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);
}
public function getOverdueActivities(Request $request){
public function getOverdueActivities(Request $request)
{
$payload = $request->all();
if(empty($payload['id']) || !is_int((int)$payload['id']))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($payload['id']) || !is_int((int)$payload['id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$result = Project::find($payload['id']);
if(!$result)
return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404);
if (!$result)
return response()->json(['status' => 'failed', 'message' => 'Project not found!', 'code' => 404], 404);
//TODO possible overdue bug
$endDate = Activity::where('proyek_id', $payload['id'])
->orderByDesc('end_date')
->value('end_date');
if(isset($payload['till_date'])) {
if (isset($payload['till_date'])) {
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 {
$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'])) {
$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 {
@ -623,53 +664,75 @@ class ProjectController extends Controller
}
$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();
if(empty($payload['project_id']) || !is_int((int)$payload['project_id']))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);
if (empty($payload['project_id']) || !is_int((int)$payload['project_id']))
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
$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',
'ram.lat', 'ram.lon', 'ram.description as report_notes', 'ram.report_date')
->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',
'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('m_req_material as rm', 'rm.id', '=', 'ama.material_id')
->join('m_activity as a', 'a.id', '=', 'ama.activity_id')
->join('m_users as u', 'u.id', '=', 'ram.user_id')
->where('ama.proyek_id', '=', $payload['project_id'])
->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();
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')
->join('m_activity', 'm_activity.id', '=', 'assign_hr_to_activity.activity_id')
->where('assign_hr_to_activity.version_gantt_id', $gantt_id)
->get();
return response()->json(['data'=>$results]);
return response()->json(['data' => $results]);
}
public function dashboard($id)
{
$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',
'mp.rencana_biaya', 'mp.company', '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);
->select(
'mp.kode_sortname',
'mp.nama as name_project',
'mp.mulai_proyek as start',
'mp.akhir_proyek as finish',
'mp.rencana_biaya',
'mp.company',
'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();
$rootActivity = Activity::whereNull('parent_id')->where('proyek_id', $id)->orderBy('version_gantt_id', 'desc')->first();
@ -678,38 +741,42 @@ class ProjectController extends Controller
$progress = @$rootActivity->persentase_progress ?? 0;
$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',
'ma.name as activity')
->join('m_activity as ma', 'ma.id', '=', 'mca.activity_id')
->where('ma.proyek_id', $id)
->orderBy('comment_by')
->take(2)
->get();
->select(
'mca.activity_id',
'mca.comment as comment',
'mca.created_by as comment_by',
'mca.created_at as comment_created',
'ma.name as activity'
)
->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->progress = $progress;
$data->comment = $commentActivity;
$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){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, str_replace("ADDR", $search, API_GEOLOCATION));
private function httpReq($search)
{
$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_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stderr', 'w'));
$info = curl_getinfo($ch);
$output = curl_exec($ch);
curl_close($ch);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
return json_decode($output);
}
}

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
{
protected $table = 'm_divisi';
protected $table = 'm_divisi';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $fillable = [
'name',
protected $fillable = [
'name',
'parent',
'description',
'color',
'created_at',
'created_by',
'updated_at',
'updated_by'
];
public static function boot() {
'description',
'color',
'created_at',
'created_by',
'updated_at',
'updated_by',
'company_id'
];
public static function boot()
{
parent::boot();
static::deleting(function($data) {
static::deleting(function ($data) {
$data->children()->delete();
});
}
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()
{
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_by',
'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'
];
}

21
app/Models/Project.php

@ -24,16 +24,16 @@ class Project extends Model
'biaya_actual',
'company',
'pm_id',
'scoupe_of_work',
'scoupe_of_work',
'type_proyek_id',
'divisi_id',
'value_proyek',
'value_proyek',
'persentase_progress',
'keterangan',
'durasi_proyek',
'progress_by_worklog',
'status',
'currency_symbol',
'currency_symbol',
'currency_code',
'currency_name',
'project_objectives',
@ -42,16 +42,15 @@ class Project extends Model
'testing_environment',
'budget_health',
'phase_id',
'late_consequence',
'assumtion',
'calculation_status',
'structur_organization',
'scurve',
'late_consequence',
'assumtion',
'calculation_status',
'structur_organization',
'scurve',
'created_at',
'created_by',
'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';
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';
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';
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';
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';
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';
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
$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('/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->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/add', 'ProjectController@add');
$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-analysis', 'ActivityController@searchAnalysis');
$router->post('/activity/search-analysis-prep', 'ActivityController@searchAnalysisPrep');
$router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->post('/activity/import', 'ActivityController@import');
$router->post('/activity/import-update', 'ActivityController@importUpdate');
$router->post('/activity/import-old', 'ActivityController@importOld');
$router->post('/activity/batch-update/{ganttId}', 'ActivityController@batchUpdate');
$router->get('/activity/update-schedule/{ganttId}', 'ActivityController@updateSchedule');
$router->get('/activity/s-curve/{proyek_id}/{gantt_id}', 'ActivityController@activitySCurve');
$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->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->put('/user-to-proyek/update/{id}', 'UserToProyekController@update');
$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->delete('/broadcast/delete/{id}', 'BroadcastController@delete');
$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