Commit f445df84 by Febry San

query kalender data e-office

parent 87c371b4
......@@ -30,10 +30,10 @@ public function index(Request $request)
// ->get();
// dd($ngajar);
if($request->ajax()) {
if ($request->ajax()) {
$tahun = '2023';
$nip = '199309052019032017';
$nip = '197410082006041002';
// $data = UserAgenda::whereDate('start', '>=', $request->start)
// ->whereDate('end', '<=', $request->end)
......@@ -42,15 +42,54 @@ public function index(Request $request)
$data = DB::connection('eoffice')->table('tr_surat_masuk')
->select('tr_surat_masuk.id', 'tr_surat_masuk.perihal as title', 'tr_surat_masuk.tglmulai as start', 'tr_surat_masuk.tglmulai as end', 'tr_surat_masuk.jam_mulai', 'tr_surat_masuk.jam_selesai')
->leftJoin('tr_penerima_surat_masuk as a', 'a.idsurat', '=', 'tr_surat_masuk.id')
// ->where('a.nip', $nip)
->where('tr_surat_masuk.perihal', 'like', '%undangan%')
->where('a.nip', $nip)
// ->where('tr_surat_masuk.perihal', 'like', '%undangan%')
->where('tr_surat_masuk.tglmulai', '>=', $request->start)
->where('tr_surat_masuk.tglmulai', '<=', $request->end)
// ->where('tr_surat_masuk.tahun', $tahun)
->get(['id', 'title', 'start', 'end']);
// dd($data);
$getData = array();
$i = 0;
foreach ($data as $item) {
if ($item->jam_mulai !== null) {
$date = $item->start . ' ' . $item->jam_mulai;
$newDate = date('Y-m-d H:i:s', strtotime($date));
$start = $newDate;
} else {
$date = $item->start . ' 08:00:00';
$newDate = date('Y-m-d H:i:s', strtotime($date));
$start = $newDate;
}
if ($item->jam_selesai !== null) {
$date = $item->start . ' ' . $item->jam_selesai;
$newDate = date('Y-m-d H:i:s', strtotime($date));
$end = $newDate;
} else {
$date = $item->start . ' 16:00:00';
$newDate = date('Y-m-d H:i:s', strtotime($date));
$end = $newDate;
}
$getData[$i++] = [
'id' => $item->id,
'title' => $item->title,
'start' => $start,
'end' => $end,
];
// $getData[$i++]['title'] = $item->title;
// $getData[$i++]['start'] = $item->start;
// $getData[$i++]['end'] = $item->end;
}
......@@ -62,7 +101,7 @@ public function index(Request $request)
// ->where('tr_surat_keluar.tahun', $tahun)
// ->get();
// dd($surat);
return response()->json($data);
return response()->json($getData);
}
// $data = UserAgenda::all();
// return $data;
......@@ -116,7 +155,7 @@ public function store(Request $request)
// 'type' => 'success',
// 'title' => 'Agenda'
// ];
$data = $request->except(['_method','_token']);
$data = $request->except(['_method', '_token']);
$data['id'] =
$data['idunit'] = '1526d530-d992-49ba-b663-3ed703b96a0f'; //nanti bakal diambil dari session user
$data['statusacara'] = 0;
......@@ -128,7 +167,7 @@ public function store(Request $request)
return back()->with('notify-swal', );
alert()->flash('Data berhasil ditambahkan', 'success');
} catch(Exception $e) {
} catch (Exception $e) {
dd($e);
Log::debug('Tambah Agenda Error');
Log::error($e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment