refactor: simplify internship approval process by removing unit approval and adding supervisor name tracking
This commit is contained in:
@@ -232,30 +232,20 @@ class InternApplicationResource extends Resource
|
||||
|
||||
if ($entry && trim($content) !== '') {
|
||||
$supApproved = $entry->supervisor_approved;
|
||||
$unitApproved = $entry->unit_approved;
|
||||
$supName = $entry->supervisor_name;
|
||||
|
||||
$html .= ' <div style="display:flex; align-items:center; gap:12px; margin-top:12px; padding-top:10px; border-top:1px dashed #e2e8f0; font-size:11px;">';
|
||||
|
||||
// Supervisor approval
|
||||
$supBg = $supApproved ? '#d1fae5' : '#f1f5f9';
|
||||
$supColor = $supApproved ? '#065f46' : '#64748b';
|
||||
$supText = $supApproved ? 'Sorumlu Onayladı' : 'Sorumlu Onayı Bekliyor';
|
||||
$supText = $supApproved ? 'Sorumlu Onayladı' . ($supName ? ' (Onaylayan: ' . e($supName) . ')' : '') : 'Sorumlu Onayı Bekliyor';
|
||||
$html .= ' <span id="sup-badge-' . $entry->id . '" style="background:' . $supBg . '; color:' . $supColor . '; padding: 2px 8px; border-radius: 4px; font-weight: 700;">' . $supText . '</span>';
|
||||
|
||||
// Unit approval
|
||||
$unitBg = $unitApproved ? '#d1fae5' : '#f1f5f9';
|
||||
$unitColor = $unitApproved ? '#065f46' : '#64748b';
|
||||
$unitText = $unitApproved ? 'Birim Yetkilisi Onayladı' : 'Birim Yetkilisi Onayı Bekliyor';
|
||||
$html .= ' <span id="unit-badge-' . $entry->id . '" style="background:' . $unitBg . '; color:' . $unitColor . '; padding: 2px 8px; border-radius: 4px; font-weight: 700;">' . $unitText . '</span>';
|
||||
|
||||
// Buttons
|
||||
$supBtnText = $supApproved ? 'Onayı Kaldır' : 'Onayla';
|
||||
$supBtnBg = $supApproved ? '#ef4444' : '#2563eb';
|
||||
$html .= ' <button type="button" onclick="toggleApproval(' . $entry->id . ', \'supervisor\', this)" style="margin-left:auto; background:' . $supBtnBg . '; color:white; border:none; padding:4px 10px; border-radius:6px; font-weight:bold; cursor:pointer; font-size:10px;">Sorumlu ' . $supBtnText . '</button>';
|
||||
|
||||
$unitBtnText = $unitApproved ? 'Onayı Kaldır' : 'Onayla';
|
||||
$unitBtnBg = $unitApproved ? '#ef4444' : '#2563eb';
|
||||
$html .= ' <button type="button" onclick="toggleApproval(' . $entry->id . ', \'unit\', this)" style="background:' . $unitBtnBg . '; color:white; border:none; padding:4px 10px; border-radius:6px; font-weight:bold; cursor:pointer; font-size:10px;">Yetkili ' . $unitBtnText . '</button>';
|
||||
$html .= ' <button type="button" onclick="toggleApproval(' . $entry->id . ', this)" style="margin-left:auto; background:' . $supBtnBg . '; color:white; border:none; padding:4px 10px; border-radius:6px; font-weight:bold; cursor:pointer; font-size:10px;">Sorumlu ' . $supBtnText . '</button>';
|
||||
|
||||
$html .= ' </div>';
|
||||
}
|
||||
@@ -268,7 +258,7 @@ class InternApplicationResource extends Resource
|
||||
$html .= '
|
||||
<script>
|
||||
if (typeof window.toggleApproval !== "function") {
|
||||
window.toggleApproval = function(entryId, type, btn) {
|
||||
window.toggleApproval = function(entryId, btn) {
|
||||
btn.disabled = true;
|
||||
btn.style.opacity = "0.5";
|
||||
|
||||
@@ -279,43 +269,25 @@ class InternApplicationResource extends Resource
|
||||
"X-CSRF-TOKEN": "' . csrf_token() . '"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
entry_id: entryId,
|
||||
type: type
|
||||
entry_id: entryId
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
if (type === "supervisor") {
|
||||
const badge = document.getElementById("sup-badge-" + entryId);
|
||||
if (data.status) {
|
||||
badge.style.background = "#d1fae5";
|
||||
badge.style.color = "#065f46";
|
||||
badge.textContent = "Sorumlu Onayladı";
|
||||
btn.textContent = "Sorumlu Onayı Kaldır";
|
||||
btn.style.background = "#ef4444";
|
||||
} else {
|
||||
badge.style.background = "#f1f5f9";
|
||||
badge.style.color = "#64748b";
|
||||
badge.textContent = "Sorumlu Onayı Bekliyor";
|
||||
btn.textContent = "Sorumlu Onayla";
|
||||
btn.style.background = "#2563eb";
|
||||
}
|
||||
const badge = document.getElementById("sup-badge-" + entryId);
|
||||
if (data.status) {
|
||||
badge.style.background = "#d1fae5";
|
||||
badge.style.color = "#065f46";
|
||||
badge.textContent = "Sorumlu Onayladı (Onaylayan: " + data.supervisor_name + ")";
|
||||
btn.textContent = "Sorumlu Onayı Kaldır";
|
||||
btn.style.background = "#ef4444";
|
||||
} else {
|
||||
const badge = document.getElementById("unit-badge-" + entryId);
|
||||
if (data.status) {
|
||||
badge.style.background = "#d1fae5";
|
||||
badge.style.color = "#065f46";
|
||||
badge.textContent = "Birim Yetkilisi Onayladı";
|
||||
btn.textContent = "Yetkili Onayı Kaldır";
|
||||
btn.style.background = "#ef4444";
|
||||
} else {
|
||||
badge.style.background = "#f1f5f9";
|
||||
badge.style.color = "#64748b";
|
||||
badge.textContent = "Birim Yetkilisi Onayı Bekliyor";
|
||||
btn.textContent = "Yetkili Onayla";
|
||||
btn.style.background = "#2563eb";
|
||||
}
|
||||
badge.style.background = "#f1f5f9";
|
||||
badge.style.color = "#64748b";
|
||||
badge.textContent = "Sorumlu Onayı Bekliyor";
|
||||
btn.textContent = "Sorumlu Onayla";
|
||||
btn.style.background = "#2563eb";
|
||||
}
|
||||
} else {
|
||||
alert(data.message || "Bir hata oluştu.");
|
||||
@@ -353,13 +325,6 @@ class InternApplicationResource extends Resource
|
||||
->label('Staj Sorumlusu Adı / Ünvanı')
|
||||
->placeholder('Örn: Alperen Trunç')
|
||||
->default('Alperen Trunç'),
|
||||
\Filament\Forms\Components\Toggle::make('notebook_unit_signed')
|
||||
->label('İlgili Birim Yetkilisi İmzala / Onayla')
|
||||
->live(),
|
||||
TextInput::make('notebook_unit_name')
|
||||
->label('Birim Yetkilisi Adı / Ünvanı')
|
||||
->placeholder('Örn: Yetkili Birim Amiri')
|
||||
->default('Yetkili Birim Amiri'),
|
||||
\Filament\Forms\Components\Toggle::make('notebook_approved')
|
||||
->label('Staj Defterini Genel Olarak Onayla')
|
||||
->columnSpanFull(),
|
||||
|
||||
@@ -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.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class InternshipJournalEntry extends Model
|
||||
'is_retroactive',
|
||||
'supervisor_approved',
|
||||
'unit_approved',
|
||||
'supervisor_name',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
Reference in New Issue
Block a user