'id', ); $totalData = Project::count(); $totalFiltered = $totalData; $limit = $request->input('length'); $start = $request->input('start'); $order = $columns[$request->input('order.0.column')]; $dir = $request->input('order.0.dir'); if (empty($request->input('search.value'))) { $projects = Project::offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); }else{ $search = $request->input('search.value'); $projects = Project::where('projects.name', 'LIKE', "%{$search}%") ->offset($start) ->limit($limit) ->orderBy($order, $dir) ->get(); $totalFiltered = Project::where('projects.name', 'LIKE', "%{$search}%") ->count(); } $data = array(); if (!empty($projects)) { foreach ($projects as $row) { $nestedData['project'] = $row->name; $nestedData['opsi'] = "
"; $nestedData['opsi'] .= " detail
"; $data[] = $nestedData; } } $json_data = array( "draw" => intval($request->input('draw')), "recordsTotal" => intval($totalData), "recordsFiltered" => intval($totalFiltered), "data" => $data, ); echo json_encode($json_data); }elseif ($_GET['act'] == 'get_notif') { set_time_limit(0); $projects = Project::all(); $deviasi_minus = []; foreach ($projects as $row_p) { foreach ($row_p->progress as $row) { $bobot_kerja_c = []; $bobot_kerja_p = []; // for notif minus deviasi foreach($row_p->curva_s as $row): array_push($bobot_kerja_c,['total' => 0]); array_push($bobot_kerja_p,['total' => 0]); endforeach; foreach($row_p->rab->rabDetails as $row_rbd){ if ($row_rbd->ahs) { $i = 0; $minggu_ke = 1; foreach ($row_p->curva_s as $row) { $bobot_kerja_c[$i]['total'] += round(CurvasController::getCurvasDet($row->id,$row_rbd->id,'volume_progress'),2); $bobot_kerja_p[$i]['total'] += round(TimeLineController::getProgressDetail($minggu_ke,$row_rbd->id,'bobot_kerja',$minggu_ke),2); $minggu_ke++; $i++; } }else{ $i = 0; $minggu_ke = 1; foreach ($row_p->curva_s as $row) { $bobot_kerja_c[$i]['total'] += round(CurvasController::getCurvasDet($row->id,$row_rbd->id,'volume_progress'),2); $bobot_kerja_p[$i]['total'] += round((TimeLineController::getProgressDetail($row->id,$row_rbd->id,'volume_progress',$minggu_ke) / $row_rbd->volume * 100),2); $minggu_ke++; $i++; } } } $kumulatif_rencana = []; foreach($bobot_kerja_c as $key => $value): if($key > 0): array_push($kumulatif_rencana,['total' => ($kumulatif_rencana[(int)$key-1]['total'] + $value['total'])]); else: array_push($kumulatif_rencana,['total' => $value['total']]); endif; endforeach; $kumulatif_realisasi = []; foreach($bobot_kerja_p as $key => $value): if($key > 0): array_push($kumulatif_realisasi,['total' => ($kumulatif_realisasi[(int)$key-1]['total'] + $value['total'])]); else: array_push($kumulatif_realisasi,['total' => $value['total']]); endif; endforeach; foreach($kumulatif_realisasi as $key => $value): $deviasi = $value['total'] - $kumulatif_rencana[$key]['total']; if ($deviasi < 0) { $id_projects = array_column($deviasi_minus, 'id_project'); $found_key = array_search($row_p->id, $id_projects); if ($found_key !== false) { }else{ array_push($deviasi_minus, ['id_project' => $row_p->id,'nama_project' => $row_p->name,'deviasi' => $deviasi,'found_key' => $found_key]); break; } } endforeach; } } return response()->json(['deviasi_minus' => $deviasi_minus]); } } }else{ $project = Project::findOrFail($id); $ahsS = AhsKategori::with(['subkategoris.ahsS' => function($q) use ($project){ $q->whereHas('rabDetail',function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); })->with(['rabDetail' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }]); }])->with(['subkategoris.vendors' => function($q) use ($project){ $q->whereHas('rabDetail',function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); })->with(['rabDetail' => function($q2) use ($project){ $q2->where('id_rab',$project->rab->id); }]); }])->orderBy('urutan','asc')->get(); return view('staff.time-control-detail',compact('project','ahsS')); } } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } }