update
This commit is contained in:
@@ -885,4 +885,63 @@ class ReportController extends Controller
|
||||
'detail' => $periksa
|
||||
]);
|
||||
}
|
||||
public function markRekapPenerimaanSamplePrinted(Request $request) {
|
||||
$userId = Session::get('id');
|
||||
$userNama = Session::get('nama');
|
||||
if (empty($userId)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Session login tidak valid.'
|
||||
], 401);
|
||||
}
|
||||
|
||||
$ids = $request->input('ids', []);
|
||||
if (!is_array($ids) || count($ids) === 0) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data yang dipilih tidak valid.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
$ids = collect($ids)
|
||||
->filter(function ($id) {
|
||||
return is_numeric($id);
|
||||
})
|
||||
->map(function ($id) {
|
||||
return intval($id);
|
||||
})
|
||||
->unique()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
if (count($ids) === 0) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data yang dipilih tidak valid.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
$printableIds = Periksa::whereIn('id', $ids)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('ppdsjunior2')
|
||||
->orWhere('ppdsjunior2', '')
|
||||
->orWhere('ppdsjunior2', '0');
|
||||
})
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
|
||||
if (count($printableIds) > 0) {
|
||||
Periksa::whereIn('id', $printableIds)->update([
|
||||
'ppdsjunior2' => $userId,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Status cetak berhasil diperbarui.',
|
||||
'affected_ids'=> $printableIds,
|
||||
'printed_by' => $userNama
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user