Merge branch 'feature/108-Moznost-evidovat-platene-zamestnanie-ako-prax' into develop

This commit is contained in:
2025-11-29 16:48:18 +01:00
26 changed files with 243 additions and 145 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Enums;
enum InternshipStatus: string
{
case SUBMITTED = 'SUBMITTED';
case CONFIRMED_BY_COMPANY = 'CONFIRMED_BY_COMPANY';
case CONFIRMED_BY_ADMIN = 'CONFIRMED_BY_ADMIN';
case DENIED_BY_COMPANY = 'DENIED_BY_COMPANY';
case DENIED_BY_ADMIN = 'DENIED_BY_ADMIN';
case DEFENDED = 'DEFENDED';
case NOT_DEFENDED = 'NOT_DEFENDED';
public static function all(): array
{
return array_map(fn($case) => $case->value, self::cases());
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Company;
use App\Models\User;
use App\Models\Internship;
use App\Models\InternshipStatus;
use App\Models\InternshipStatusData;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -186,7 +186,7 @@ class CompanyController extends Controller
// mazanie statusov
$internships->each(function ($internship) {
InternshipStatus::whereInternshipId($internship->id)->delete();
InternshipStatusData::whereInternshipId($internship->id)->delete();
});
// mazanie praxov

View File

@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Company;
use App\Models\Internship;
use App\Models\InternshipStatus;
use App\Models\InternshipStatusData;
use App\Models\User;
use Illuminate\Http\Request;
use Mpdf\Mpdf;
@@ -61,7 +61,7 @@ class InternshipController extends Controller
return response()->json($internship);
}
public function get_default_agreement(Request $request, int $id)
public function get_default_proof(Request $request, int $id)
{
$user = auth()->user();
$internship = Internship::find($id);
@@ -78,7 +78,7 @@ class InternshipController extends Controller
$contact = User::find($internship->company->contact);
$html = view('agreement.default', [
$html = view('proof.default', [
'company' => $internship->company,
'companyContact' => $contact,
'internship' => $internship,
@@ -93,10 +93,10 @@ class InternshipController extends Controller
return response($pdf->Output('', 'S'), 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"');
->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"');
}
public function get_agreement(int $id)
public function get_proof(int $id)
{
$user = auth()->user();
$internship = Internship::find($id);
@@ -107,9 +107,9 @@ class InternshipController extends Controller
], 400);
}
if (!$internship->agreement) {
if (!$internship->proof) {
return response()->json([
'message' => 'No agreement file exists for this internship.'
'message' => 'No proof file exists for this internship.'
], 404);
}
@@ -117,9 +117,9 @@ class InternshipController extends Controller
abort(403, 'Unauthorized');
}
return response($internship->agreement, 200)
return response($internship->proof, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'attachment; filename="agreement_' . $id . '.pdf"');
->header('Content-Disposition', 'attachment; filename="proof_' . $id . '.pdf"');
}
public function get_report(int $id)
@@ -182,10 +182,10 @@ class InternshipController extends Controller
'year_of_study' => $request->year_of_study,
'semester' => $request->semester,
'position_description' => $request->position_description,
'agreement' => null
'proof' => null
]);
InternshipStatus::create([
InternshipStatusData::create([
'internship_id' => $Internship->id,
'status' => 'SUBMITTED',
'changed' => now(),
@@ -250,13 +250,13 @@ class InternshipController extends Controller
}
$request->validate([
'agreement' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'proof' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'report' => ['nullable', 'file', 'mimes:pdf', 'max:10240'],
'report_confirmed' => ['required', 'boolean'],
]);
if ($request->hasFile('agreement')) {
$internship->agreement = file_get_contents($request->file('agreement')->getRealPath());
if ($request->hasFile('proof')) {
$internship->proof = file_get_contents($request->file('proof')->getRealPath());
}
if ($request->hasFile('report')) {
@@ -264,9 +264,9 @@ class InternshipController extends Controller
}
if ($user->role === 'EMPLOYER') {
if ($request->report_confirmed && (!$internship->agreement || !$internship->report)) {
if ($request->report_confirmed && (!$internship->proof || !$internship->report)) {
return response()->json([
'message' => 'Report cannot be confirmed without an agreement and report.'
'message' => 'Report cannot be confirmed without an proof and report.'
], 400);
}

View File

@@ -2,19 +2,19 @@
namespace App\Http\Controllers;
use App\Enums\InternshipStatus;
use App\Mail\InternshipStatusUpdated;
use App\Models\Internship;
use App\Models\InternshipStatus;
use App\Models\User;
use App\Models\InternshipStatusData;
use Illuminate\Http\Request;
use Mail;
class InternshipStatusController extends Controller
class InternshipStatusDataController extends Controller
{
public function get(int $id)
{
$user = auth()->user();
$internship_statuses = InternshipStatus::whereInternshipId($id)->orderByDesc('changed')->get();
$internship_statuses = InternshipStatusData::whereInternshipId($id)->orderByDesc('changed')->get();
if (!$internship_statuses) {
return response()->json([
@@ -45,9 +45,7 @@ class InternshipStatusController extends Controller
abort(403, 'Unauthorized');
}
$currentStatus = $internship->status;
$nextPossibleStatuses = $this->possibleNewStatuses($currentStatus->status, $user->role, $internship->report_confirmed);
$nextPossibleStatuses = $internship->nextStates($user->role);
return response()->json($nextPossibleStatuses);
}
@@ -78,7 +76,7 @@ class InternshipStatusController extends Controller
/**
* Display the specified resource.
*/
public function show(InternshipStatus $internshipStatus)
public function show(InternshipStatusData $internshipStatus)
{
//
}
@@ -86,7 +84,7 @@ class InternshipStatusController extends Controller
/**
* Show the form for editing the specified resource.
*/
public function edit(InternshipStatus $internshipStatus)
public function edit(InternshipStatusData $internshipStatus)
{
//
}
@@ -110,14 +108,14 @@ class InternshipStatusController extends Controller
}
$internshipStatus = $internship->status;
$newStatusValidator = 'in:' . implode(',', $this->possibleNewStatuses($internshipStatus->status, $user->role, $internship->report_confirmed));
$newStatusValidator = 'in:' . implode(',', $internship->nextStates($user->role));
$request->validate([
'status' => ['required', 'string', 'uppercase', $newStatusValidator],
'note' => ['required', 'string', 'min:1']
]);
InternshipStatus::create([
$newStatus = InternshipStatusData::make([
'internship_id' => $id,
'status' => $request->status,
'note' => $request->note,
@@ -125,47 +123,26 @@ class InternshipStatusController extends Controller
'modified_by' => $user->id
]);
Mail::to($internship->student)->sendNow(new InternshipStatusUpdated($internship, $user->name, $internship->student->name, $internship->company->name, $internshipStatus->status, $request->status, $request->note));
Mail::to($internship->student)
->sendNow(new InternshipStatusUpdated(
$internship,
$user->name,
$internship->student->name,
$internship->company->name,
$internshipStatus->status,
$request->enum('status', InternshipStatus::class),
$request->note
));
$newStatus->save();
return response()->noContent();
}
/**
* Remove the specified resource from storage.
*/
public function destroy(InternshipStatus $internshipStatus)
public function destroy(InternshipStatusData $internshipStatus)
{
//
}
private function possibleNewStatuses(string $current_status, string $userRole, bool $report_confirmed)
{
if ($userRole === "STUDENT")
return [];
switch ($current_status) {
case 'SUBMITTED':
return ['CONFIRMED', 'DENIED'];
case 'CONFIRMED':
if ($userRole === 'EMPLOYER') {
return ['DENIED'];
}
if ($report_confirmed) {
return ['SUBMITTED', 'DENIED', 'DEFENDED', 'NOT_DEFENDED'];
}
return ['SUBMITTED', 'DENIED'];
case 'DENIED':
if ($userRole === 'EMPLOYER') {
return ['CONFIRMED'];
}
return ['SUBMITTED', 'CONFIRMED'];
case 'DEFENDED':
case 'NOT_DEFENDED':
return [];
default:
throw new \InvalidArgumentException('Unknown status');
}
}
}

View File

@@ -5,7 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Internship;
use App\Models\StudentData;
use App\Models\User;
use App\Models\InternshipStatus;
use App\Models\InternshipStatusData;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -208,7 +208,7 @@ class StudentDataController extends Controller
// mazanie statusov
$internships->each(function ($internship) {
InternshipStatus::whereInternshipId($internship->id)->delete();
InternshipStatusData::whereInternshipId($internship->id)->delete();
});
// mazanie praxov

View File

@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Enums\InternshipStatus;
use App\Models\Internship;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
@@ -17,14 +18,14 @@ class InternshipStatusUpdated extends Mailable
private string $changedByName;
private string $studentName;
private string $companyName;
private string $oldStatus;
private string $newStatus;
private InternshipStatus $oldStatus;
private InternshipStatus $newStatus;
private string $note;
/**
* Create a new message instance.
*/
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, string $oldStatus, string $newStatus, string $note)
public function __construct(Internship $internship, string $changedByName, string $studentName, string $companyName, InternshipStatus $oldStatus, InternshipStatus $newStatus, string $note)
{
$this->internship = $internship;
$this->changedByName = $changedByName;
@@ -57,8 +58,8 @@ class InternshipStatusUpdated extends Mailable
"changedByName" => $this->changedByName,
"studentName" => $this->studentName,
"companyName" => $this->companyName,
"oldStatus" => $this->prettyStatus($this->oldStatus),
"newStatus" => $this->prettyStatus($this->newStatus),
"oldStatus" => $this->prettyStatus($this->oldStatus->value),
"newStatus" => $this->prettyStatus($this->newStatus->value),
"note" => $this->note,
]
);
@@ -78,8 +79,10 @@ class InternshipStatusUpdated extends Mailable
{
return match ($status) {
'SUBMITTED' => 'Zadané',
'CONFIRMED' => 'Potvrdená',
'DENIED' => 'Zamietnutá',
'CONFIRMED_BY_COMPANY' => 'Potvrdená firmou',
'CONFIRMED_BY_ADMIN' => 'Potvrdená garantom',
'DENIED_BY_COMPANY' => 'Zamietnutá firmou',
'DENIED_BY_ADMIN' => 'Zamietnutá garantom',
'DEFENDED' => 'Obhájená',
'NOT_DEFENDED' => 'Neobhájená',
default => throw new \Exception("Invalid status: $status")

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Enums\InternshipStatus;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -24,7 +25,7 @@ class Internship extends Model
'year_of_study',
'semester',
'position_description',
'agreement',
'proof',
'report',
'report_confirmed',
];
@@ -63,7 +64,59 @@ class Internship extends Model
public function status()
{
return $this->hasOne(InternshipStatus::class, 'internship_id')->latestOfMany();
return $this->hasOne(InternshipStatusData::class, 'internship_id')->latestOfMany();
}
public function nextStates(string $userRole)
{
$current_status = $this->status->status;
$report_confirmed = $this->report_confirmed;
// študent nemôže meniť stav
if ($userRole === 'STUDENT')
return [];
/*
nasledujúci platný stav je určený podľa:
- aktuálneho stavu
- roly používateľa, ktorý ide meniť stav
- či bol výkaz potvrdený firmou
*/
return match (true) {
// prax bola iba vytvorená a ide ju meniť admin alebo firma
$current_status === InternshipStatus::SUBMITTED
=> ['CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
// prax bola potvrdená firmou a ide ju meniť admin
$current_status === InternshipStatus::CONFIRMED_BY_COMPANY && $userRole === "ADMIN"
=> ['CONFIRMED_BY_ADMIN', 'DENIED_BY_ADMIN'],
// prax bola potvrdená firmou a ide ju meniť firma
$current_status === InternshipStatus::CONFIRMED_BY_COMPANY && $userRole === "EMPLOYER"
=> ['DENIED_BY_COMPANY'],
// prax bola zamietnutá firmou a ide ju meniť admin
$current_status === InternshipStatus::DENIED_BY_COMPANY && $userRole === "ADMIN"
=> ['CONFIRMED_BY_COMPANY', 'SUBMITTED'],
// prax bola potvrdená garantom, ide ju meniť admin a výkaz bol potvrdený firmou
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && $report_confirmed
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY', 'DEFENDED', 'NOT_DEFENDED'],
// prax bola potvrdená garantom, ide ju meniť admin a výkaz nebol potvrdený firmou
$current_status === InternshipStatus::CONFIRMED_BY_ADMIN && $userRole === "ADMIN" && !$report_confirmed
=> ['DENIED_BY_ADMIN', 'CONFIRMED_BY_COMPANY', 'DENIED_BY_COMPANY'],
// prax bola obhájená a ide ju meniť admin
$current_status === InternshipStatus::DEFENDED && $userRole === "ADMIN"
=> ['NOT_DEFENDED'],
// prax nebola obhájená a ide ju meniť admin
$current_status === InternshipStatus::NOT_DEFENDED && $userRole === "ADMIN"
=> ['DEFENDED'],
default => []
};
}
/**
@@ -82,7 +135,7 @@ class Internship extends Model
'year_of_study' => $this->year_of_study,
'semester' => $this->semester,
'position_description' => $this->position_description,
'agreement' => $this->agreement !== null,
'proof' => $this->proof !== null,
'report' => $this->report !== null,
'report_confirmed' => $this->report_confirmed,
'status' => $this->status,

View File

@@ -5,7 +5,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class InternshipStatus extends Model
class InternshipStatusData extends Model
{
/** @use HasFactory<\Database\Factories\InternshipStatusFactory> */
use HasFactory;
@@ -33,6 +33,20 @@ class InternshipStatus extends Model
'updated_at',
];
protected $table = 'internship_statuses';
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'status' => '\App\Enums\InternshipStatus',
];
}
public function modifiedBy()
{
return $this->belongsTo(User::class, 'modified_by');
@@ -43,7 +57,7 @@ class InternshipStatus extends Model
return [
'id' => $this->id,
'internship_id' => $this->internship_id,
'status' => $this->status,
'status' => $this->status->value,
'changed' => $this->changed,
'note' => $this->note,
'modified_by' => $this->modifiedBy,

View File

@@ -12,7 +12,7 @@
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10.1",
"laravel/tinker": "^2.10",
"mpdf/mpdf": "^8.2"
},
"require-dev": {

14
backend/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9911f9a2eb5e48d459c109368a23930b",
"content-hash": "3b2e99453e86a7f518baa13eca7aa622",
"packages": [
{
"name": "brick/math",
@@ -1458,16 +1458,16 @@
},
{
"name": "laravel/tinker",
"version": "v2.10.1",
"version": "v2.10.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/tinker.git",
"reference": "22177cc71807d38f2810c6204d8f7183d88a57d3"
"reference": "3bcb5f62d6f837e0f093a601e26badafb127bd4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/tinker/zipball/22177cc71807d38f2810c6204d8f7183d88a57d3",
"reference": "22177cc71807d38f2810c6204d8f7183d88a57d3",
"url": "https://api.github.com/repos/laravel/tinker/zipball/3bcb5f62d6f837e0f093a601e26badafb127bd4c",
"reference": "3bcb5f62d6f837e0f093a601e26badafb127bd4c",
"shasum": ""
},
"require": {
@@ -1518,9 +1518,9 @@
],
"support": {
"issues": "https://github.com/laravel/tinker/issues",
"source": "https://github.com/laravel/tinker/tree/v2.10.1"
"source": "https://github.com/laravel/tinker/tree/v2.10.2"
},
"time": "2025-01-27T14:24:01+00:00"
"time": "2025-11-20T16:29:12+00:00"
},
{
"name": "league/commonmark",

View File

@@ -27,7 +27,7 @@ class InternshipFactory extends Factory
'year_of_study' => fake()->randomElement([1, 2, 3, 4, 5]),
'semester' => fake()->randomElement(["WINTER", "SUMMER"]),
'position_description' => fake()->jobTitle(),
'agreement' => null,
'proof' => null,
'report' => null,
'report_confirmed' => false,
];

View File

@@ -2,12 +2,13 @@
namespace Database\Factories;
use App\Enums\InternshipStatus;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\InternshipStatus>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\InternshipStatusData>
*/
class InternshipStatusFactory extends Factory
class InternshipStatusDataFactory extends Factory
{
/**
* Define the model's default state.
@@ -18,7 +19,7 @@ class InternshipStatusFactory extends Factory
{
return [
'internship_id' => 0,
'status' => fake()->randomElement(["SUBMITTED", "CONFIRMED", "DENIED", "DEFENDED", "NOT_DEFENDED"]),
'status' => fake()->randomElement(InternshipStatus::all()),
'changed' => fake()->dateTime(),
'note' => null,
'modified_by' => 0,

View File

@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
@@ -20,7 +19,7 @@ return new class extends Migration
$table->unsignedSmallInteger("year_of_study")->nullable(false);
$table->enum("semester", ["WINTER", "SUMMER"])->nullable(false);
$table->string("position_description")->nullable(false);
$table->binary("agreement")->nullable(true);
$table->binary("proof")->nullable(true);
$table->binary("report")->nullable(true);
$table->boolean("report_confirmed")->nullable(false)->default(false);
$table->timestamps();

View File

@@ -1,11 +1,11 @@
<?php
use App\Enums\InternshipStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
@@ -14,7 +14,7 @@ return new class extends Migration
Schema::create('internship_statuses', function (Blueprint $table) {
$table->id();
$table->foreignId("internship_id")->nullable(false)->constrained("internships")->onDelete("cascade");
$table->enum("status", ["SUBMITTED", "CONFIRMED", "DENIED", "DEFENDED", "NOT_DEFENDED"])->nullable(false)->default("SUBMITTED");
$table->enum("status", InternshipStatus::all())->nullable(false)->default(InternshipStatus::SUBMITTED);
$table->dateTimeTz("changed")->nullable(false);
$table->string("note")->nullable(true)->default(null);
$table->foreignId("modified_by")->nullable(false)->constrained("users")->onDelete("cascade");

View File

@@ -4,7 +4,7 @@ namespace Database\Seeders;
use App\Models\Company;
use App\Models\Internship;
use App\Models\InternshipStatus;
use App\Models\InternshipStatusData;
use App\Models\StudentData;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
@@ -57,7 +57,7 @@ class DatabaseSeeder extends Seeder
'company_id' => Company::inRandomOrder()->value('id'),
]);
InternshipStatus::factory()->create([
InternshipStatusData::factory()->create([
'internship_id' => $internship->id,
'status' => "SUBMITTED",
'note' => 'made by seeder',

View File

@@ -4,7 +4,7 @@ use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\CompanyController;
use App\Http\Controllers\InternshipController;
use App\Http\Controllers\StudentDataController;
use App\Http\Controllers\InternshipStatusController;
use App\Http\Controllers\InternshipStatusDataController;
use App\Models\Company;
use App\Models\StudentData;
use Illuminate\Http\Request;
@@ -46,11 +46,11 @@ Route::prefix('/internships')->group(function () {
//Route::middleware("auth:sanctum")->group(function () {
Route::prefix('/{id}')->group(function () {
Route::get("/", [InternshipController::class, 'get'])->name("api.internships.get");
Route::put("/status", [InternshipStatusController::class, 'update'])->name("api.internships.status.update");
Route::get("/statuses", [InternshipStatusController::class, 'get'])->name("api.internships.get");
Route::get("/next-statuses", [InternshipStatusController::class, 'get_next_states'])->name("api.internships.status.next.get");
Route::get("/default-agreement", [InternshipController::class, 'get_default_agreement'])->name("api.internships.agreement.default.get");
Route::get("/agreement", [InternshipController::class, 'get_agreement'])->name("api.internships.agreement.get");
Route::put("/status", [InternshipStatusDataController::class, 'update'])->name("api.internships.status.update");
Route::get("/statuses", [InternshipStatusDataController::class, 'get'])->name("api.internships.get");
Route::get("/next-statuses", [InternshipStatusDataController::class, 'get_next_states'])->name("api.internships.status.next.get");
Route::get("/default-proof", [InternshipController::class, 'get_default_proof'])->name("api.internships.proof.default.get");
Route::get("/proof", [InternshipController::class, 'get_proof'])->name("api.internships.proof.get");
Route::get("/report", [InternshipController::class, 'get_report'])->name("api.internships.report.get");
Route::post("/documents", [InternshipController::class, 'update_documents'])->name("api.internships.documents.set");
Route::post("/basic", [InternshipController::class, 'update_basic'])->name("api.internships.update.basic");

View File

@@ -2,7 +2,8 @@
import { FetchError } from 'ofetch';
const props = defineProps<{
internship_id: number
internship_id: number,
block?: boolean,
}>();
const client = useSanctumClient();
@@ -13,8 +14,8 @@ async function requestDownload() {
loading.value = true;
try {
const agreement = await client<Blob>(`/api/internships/${props.internship_id}/default-agreement`);
triggerDownload(agreement, `default-agreement-${props.internship_id}`);
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
triggerDownload(proof, `default-proof-${props.internship_id}`);
} catch (e) {
if (e instanceof FetchError) {
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
@@ -27,8 +28,8 @@ async function requestDownload() {
<template>
<div>
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2" block :disabled="loading"
@click="requestDownload">
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2 mb-2" :disabled="loading"
:block="block ?? undefined" @click="requestDownload">
<span v-show="!loading">Stiahnuť originálnu zmluvu</span>
<span v-show="loading">Prosím čakajte...</span>
</v-btn>

View File

@@ -18,7 +18,7 @@ const rules = {
const loading = ref(false);
const error = ref<string | null>(null);
const agreement = ref<File | null>(null);
const proof = ref<File | null>(null);
const report = ref<File | null>(null);
const report_confirmed = ref(props.internship.report_confirmed);
@@ -35,9 +35,9 @@ function triggerDownload(file: Blob, file_name: string) {
window.URL.revokeObjectURL(url);
}
async function downloadAgreement() {
const agreement: Blob = await client(`/api/internships/${props.internship.id}/agreement`);
triggerDownload(agreement, `agreement-${props.internship.id}`);
async function downloadProof() {
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
triggerDownload(proof, `proof-${props.internship.id}`);
}
async function downloadReport() {
@@ -51,8 +51,8 @@ async function onSubmit() {
const formData = new FormData();
formData.append('report_confirmed', report_confirmed.value ? '1' : '0');
if (agreement.value) {
formData.append('agreement', agreement.value);
if (proof.value) {
formData.append('proof', proof.value);
}
if (report.value) {
formData.append('report', report.value);
@@ -64,7 +64,7 @@ async function onSubmit() {
body: formData
});
agreement.value = null;
proof.value = null;
report.value = null;
emit('successfulSubmit');
} catch (e) {
@@ -87,19 +87,22 @@ async function onSubmit() {
<v-form @submit.prevent="onSubmit" :disabled="loading">
<div>
<h4 class="mb-2">Podpísaná zmluva / dohoda</h4>
<h4 class="mb-2">Dokument o vykonaní praxe</h4>
<WarningAlert v-if="props.internship.agreement" title="Existujúci dokument"
text="V systéme je už nahratá zmluva/dohoda. Ak chcete nahradiť existujúcu verziu, vyberte súbor, alebo v opačnom prípade nechajte toto pole nevyplnené.">
<p>Zmluva/dohoda o brigádnickej praxi alebo 3 faktúry v pre živnostníkov.</p>
<InternshipAgreementDownloader :internship_id="internship.id" />
<WarningAlert v-if="props.internship.proof" title="Existujúci dokument"
text="V systéme je už nahratý dokument. Ak chcete nahradiť existujúcu verziu, vyberte súbor, alebo v opačnom prípade nechajte toto pole nevyplnené.">
<br />
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2" @click="downloadAgreement">
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2" @click="downloadProof">
Stiahnuť
</v-btn>
</WarningAlert>
<v-file-input v-model="agreement" :rules="[rules.isPdf, rules.maxSize]" accept=".pdf,application/pdf"
prepend-icon="mdi-handshake" label="Nahrať PDF zmluvu" variant="outlined" show-size clearable
<v-file-input v-model="proof" :rules="[rules.isPdf, rules.maxSize]" accept=".pdf,application/pdf"
prepend-icon="mdi-handshake" label="Nahrať PDF dokument" variant="outlined" show-size clearable
hint="Povolené: PDF, max 10 MB" persistent-hint />
</div>
@@ -108,6 +111,12 @@ async function onSubmit() {
<div>
<h4 class="mb-2">Výkaz</h4>
<p>Dokument o hodnotení praxe.</p>
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2 mb-2" target="_blank"
href="https://www.fpvai.ukf.sk/images/Organizacia_studia/odborna_prax/aplikovana_informatika/Priloha_Vykaz_o_vykonanej_odbornej_praxi-AI.docx">
<span>Stiahnuť šablónu na výkaz</span>
</v-btn>
<WarningAlert v-if="props.internship.report" title="Existujúci dokument"
text="V systéme je už nahratý výkaz. Ak chcete nahradiť existujúcu verziu, vyberte súbor, alebo v opačnom prípade nechajte toto pole nevyplnené.">
@@ -123,14 +132,14 @@ async function onSubmit() {
hint="Povolené: PDF, max 10 MB" persistent-hint />
<v-checkbox v-if="user?.role === Role.EMPLOYER"
:disabled="!props.internship.agreement || !props.internship.report" v-model="report_confirmed"
:disabled="!props.internship.proof || !props.internship.report" v-model="report_confirmed"
label="Výkaz je správny"></v-checkbox>
</div>
<br />
<v-btn type="submit" color="success" size="large" block
:disabled="!agreement && !report && (!props.internship.agreement || !props.internship.report)">
:disabled="!proof && !report && (!props.internship.proof || !props.internship.report)">
Uloziť
</v-btn>
</v-form>

View File

@@ -8,8 +8,8 @@ const props = defineProps<{
const client = useSanctumClient();
async function downloadAgreement() {
const agreement: Blob = await client(`/api/internships/${props.internship.id}/agreement`);
triggerDownload(agreement, `agreement-${props.internship.id}`);
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
triggerDownload(proof, `proof-${props.internship.id}`);
}
async function downloadReport() {
@@ -21,18 +21,19 @@ async function downloadReport() {
<template>
<div>
<v-row class="d-flex">
<!-- Podpísaná zmluva -->
<!-- Podpísaný dokument k praxe -->
<v-col cols="12" md="6">
<v-card variant="outlined" class="h-100">
<v-card-title class="d-flex align-center ga-2">
<v-icon icon="mdi mdi-file-document-outline" />
Podpísaná zmluva / dohoda
Dokument o vykonaní praxe
</v-card-title>
<v-card-text>
<InternshipAgreementDownloader :internship_id="internship.id" />
<WarningAlert v-if="!props.internship.agreement" title="Neodovzdané"
text="Zmluva zatiaľ nebola nahratá." />
<v-card-text>
<InternshipAgreementDownloader :internship_id="internship.id" block />
<WarningAlert v-if="!props.internship.proof" title="Neodovzdané"
text="Dokument zatiaľ nebol nahratý." />
<div v-else>
<SuccessAlert title="Odovzdané" text="Zmluva bola nahratá." />
@@ -53,8 +54,14 @@ async function downloadReport() {
<v-icon icon="mdi-file-clock-outline" />
Výkaz
</v-card-title>
<v-card-text>
<InfoAlert v-if="!props.internship.report" title="Neodovzdané"
<v-btn prepend-icon="mdi-download" color="blue" class="mr-2 mt-2" block target="_blank"
href="https://www.fpvai.ukf.sk/images/Organizacia_studia/odborna_prax/aplikovana_informatika/Priloha_Vykaz_o_vykonanej_odbornej_praxi-AI.docx">
<span>Stiahnuť šablónu na výkaz</span>
</v-btn>
<WarningAlert v-if="!props.internship.report" title="Neodovzdané"
text="Výkaz zatiaľ nebol nahratý." />
<div v-else>

View File

@@ -68,10 +68,11 @@ async function submit() {
<ErrorAlert v-if="save_error" :error="`Nepodarilo uložiť: ${save_error}`" />
<!-- Chybová hláška -->
<ErrorAlert v-if="load_error" :error="`Nepodarilo sa načítať stavy: ${save_error}`" />
<ErrorAlert v-if="load_error" :error="`Nepodarilo sa načítať stavy: ${load_error}`" />
<!-- Chybová hláška -->
<ErrorAlert v-else-if="data?.length === 0" :error="`Nepodarilo sa načítať stavy: ${save_error}`" />
<WarningAlert v-else-if="data?.length === 0" title="Blokované"
text="Stav praxe už nie je možné meniť, pretože bola (ne)obhájená alebo zamietnutá. V prípade, že ste prax zamietli omylom, alebo ak máte technické problémy, prosíme kontaktovať garanta praxe." />
<v-form v-else v-model="isValid" @submit.prevent="submit" :disabled="loading">
<v-select v-model="new_state" label="Stav" :items="data" item-value="value"></v-select>

View File

@@ -99,7 +99,8 @@ async function handleUpdateOfBasicInfo(internship: NewInternship) {
<div>
<h2>Nahratie dokumentov</h2>
<ErrorAlert v-if="data?.status.status !== InternshipStatus.CONFIRMED" title="Blokované"
<ErrorAlert v-if="data?.status.status !== InternshipStatus.CONFIRMED_BY_COMPANY"
title="Blokované"
error='Vaša prax nie je v stave "Schválená" a teda nemôžete nahrať dokumenty.' />
<InternshipDocumentEditor v-else :internship="data!" @successful-submit="refresh" />

View File

@@ -92,7 +92,8 @@ async function handleUpdateOfBasicInfo(internship: NewInternship) {
<div>
<h2>Nahratie dokumentov</h2>
<ErrorAlert v-if="data?.status.status !== InternshipStatus.CONFIRMED" title="Blokované"
<ErrorAlert v-if="data?.status.status !== InternshipStatus.CONFIRMED_BY_COMPANY"
title="Blokované"
error='Vaša prax nie je v stave "Schválená" a teda nemôžete nahrať dokumenty.' />
<InternshipDocumentEditor v-else :internship="data!" @successful-submit="refresh" />

View File

@@ -14,20 +14,29 @@ export interface NewInternshipStatusData {
export enum InternshipStatus {
SUBMITTED = 'SUBMITTED',
CONFIRMED = 'CONFIRMED',
DENIED = 'DENIED',
CONFIRMED_BY_COMPANY = 'CONFIRMED_BY_COMPANY',
CONFIRMED_BY_ADMIN = 'CONFIRMED_BY_ADMIN',
DENIED_BY_COMPANY = 'DENIED_BY_COMPANY',
DENIED_BY_ADMIN = 'DENIED_BY_ADMIN',
DEFENDED = 'DEFENDED',
NOT_DEFENDED = 'NOT_DEFENDED'
};
NOT_DEFENDED = 'NOT_DEFENDED',
}
export function prettyInternshipStatus(status: InternshipStatus) {
switch (status) {
case InternshipStatus.SUBMITTED:
return "Zadané";
case InternshipStatus.CONFIRMED:
return "Potvrdené";
case InternshipStatus.DENIED:
return "Zamietnuté";
case InternshipStatus.CONFIRMED_BY_COMPANY:
return "Potvrdené firmou";
case InternshipStatus.CONFIRMED_BY_ADMIN:
return "Potvrdené garantom";
case InternshipStatus.DENIED_BY_COMPANY:
return "Zamietnuté firmou";
case InternshipStatus.DENIED_BY_ADMIN:
return "Zamietnuté garantom";
case InternshipStatus.DEFENDED:
return "Obhájené";
case InternshipStatus.NOT_DEFENDED:

View File

@@ -11,7 +11,7 @@ export interface Internship {
year_of_study: number;
semester: string;
position_description: string;
agreement: boolean;
proof: boolean;
report: boolean;
report_confirmed: boolean;
status: InternshipStatusData;

View File

@@ -14,7 +14,7 @@ describe('Admin Student Document Downloads', () => {
cy.url().should('include', '/dashboard/admin/internships')
})
it('should be able to generate and download the default agreement', () => {
it('should be able to generate and download the default proof', () => {
cy.get('table').within(() => {
cy.get('tbody tr')
.then(rows => {