refactor: simplify internship approval process by removing unit approval and adding supervisor name tracking
This commit is contained in:
@@ -530,6 +530,55 @@ class CareerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getJournalEntry(Request $request)
|
||||
{
|
||||
if (!auth()->check()) {
|
||||
return response()->json(['success' => false, 'message' => 'Yetkisiz işlem.'], 403);
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'intern_id' => 'required|integer|exists:career_applications,id',
|
||||
'date' => 'required|date',
|
||||
]);
|
||||
|
||||
$intern = \App\Models\CareerApplication::findOrFail($request->intern_id);
|
||||
|
||||
$days = self::getInternshipDates($intern->internship_start_date, $intern->internship_total_days);
|
||||
$dayNum = null;
|
||||
$dateFormatted = null;
|
||||
foreach ($days as $d) {
|
||||
if ($d['date'] === $request->date) {
|
||||
$dayNum = $d['day_number'];
|
||||
$dateFormatted = $d['formatted_date'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$dayNum) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Seçilen tarih staj dönemi dışındadır veya haftasonudur.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
$entry = $intern->journalEntries()->where('date', $request->date)->first();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'intern_name' => $intern->name,
|
||||
'day_number' => $dayNum,
|
||||
'date' => $request->date,
|
||||
'date_formatted' => $dateFormatted,
|
||||
'entry' => $entry ? [
|
||||
'id' => $entry->id,
|
||||
'content' => $entry->content,
|
||||
'is_retroactive' => $entry->is_retroactive,
|
||||
'supervisor_approved' => $entry->supervisor_approved,
|
||||
'supervisor_name' => $entry->supervisor_name,
|
||||
] : null
|
||||
]);
|
||||
}
|
||||
|
||||
public function toggleJournalApproval(Request $request)
|
||||
{
|
||||
if (!auth()->check()) {
|
||||
@@ -538,28 +587,24 @@ class CareerController extends Controller
|
||||
|
||||
$request->validate([
|
||||
'entry_id' => 'required|integer|exists:internship_journal_entries,id',
|
||||
'type' => 'required|string|in:supervisor,unit',
|
||||
]);
|
||||
|
||||
$entry = \App\Models\InternshipJournalEntry::findOrFail($request->entry_id);
|
||||
|
||||
if ($request->type === 'supervisor') {
|
||||
$entry->supervisor_approved = !$entry->supervisor_approved;
|
||||
$entry->save();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => $entry->supervisor_approved,
|
||||
'message' => 'Staj sorumlusu onayı güncellendi.'
|
||||
]);
|
||||
$entry->supervisor_approved = !$entry->supervisor_approved;
|
||||
if ($entry->supervisor_approved) {
|
||||
$entry->supervisor_name = auth()->user()->name;
|
||||
} else {
|
||||
$entry->unit_approved = !$entry->unit_approved;
|
||||
$entry->save();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => $entry->unit_approved,
|
||||
'message' => 'Birim yetkilisi onayı güncellendi.'
|
||||
]);
|
||||
$entry->supervisor_name = null;
|
||||
}
|
||||
$entry->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'status' => $entry->supervisor_approved,
|
||||
'supervisor_name' => $entry->supervisor_name,
|
||||
'message' => 'Staj sorumlusu onayı güncellendi.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user