@php // Komponent modalny kreatora. Dane pobierane wyłącznie po ID szkolenia. $trainingId = (int)($trainingId ?? 0); $overlayId = !empty($overlayId) ? (string)$overlayId : 'trainingPreparationWizardOverlay_'.$trainingId; $wizardTraining = null; $wizardMaterialsCount = 0; $wizardMaterialsIntroExists = false; $wizardTestRecord = null; $wizardParticipantsCount = 0; if ($trainingId > 0) { $wizardTraining = DB::table('t051_szkolenia')->where('id', $trainingId)->first(); if (!empty($wizardTraining)) { $hasMaterialsTable = \Illuminate\Support\Facades\Schema::hasTable('t056_szkolenie_materialy'); if ($hasMaterialsTable) { $wizardMaterialsCount = (int) DB::table('t056_szkolenie_materialy') ->where('id_szkolenie', $trainingId) ->count(); } if (\Illuminate\Support\Facades\Schema::hasColumn('t051_szkolenia', 'wprowadzenie_html')) { $wizardMaterialsIntroExists = trim((string) ($wizardTraining->wprowadzenie_html ?? '')) !== ''; } if (\Illuminate\Support\Facades\Schema::hasTable('t057_testy')) { $wizardTestRecord = DB::table('t057_testy') ->where('id_szkolenie', $trainingId) ->orderBy('id', 'asc') ->first(); } $wizardParticipantsCount = (int) DB::table('v052_uczestnicy_szkolenia') ->where('v052_id_szkolenie', $trainingId) ->where('v052_osoba_status_aktywny', '1') ->distinct() ->count('v052_osoba_id'); } } $wizardTraining = $wizardTraining ?: (object)[]; // Logika gotowości publikacji. $isElearning = (int)($wizardTraining->forma_szkolenia ?? -1) === 0; $placeNormalized = trim(mb_strtolower((string)($wizardTraining->miejsce_szkolenia ?? ''), 'UTF-8')); $isInternalPlace = strpos($placeNormalized, 'szkolenie wewn') !== false; $checkElearningInternal = $isElearning && $isInternalPlace; $checkTopicAndGoal = trim((string)($wizardTraining->temat ?? '')) !== '' && trim((string)($wizardTraining->cel_szkolenia_opis ?? '')) !== ''; $checkSchedule = !empty($wizardTraining->data) && !empty($wizardTraining->godzina_start) && !empty($wizardTraining->data_do) && !empty($wizardTraining->godzina_stop); $checkMaterials = ($wizardMaterialsCount > 0) || $wizardMaterialsIntroExists; $checkActiveTest = !empty($wizardTestRecord) && (int)($wizardTestRecord->status_aktywny ?? 0) === 1; $checkParticipants = $wizardParticipantsCount > 0; $preparationSteps = [ ['label' => 'Tryb e-Learning + miejsce Szkolenie Wewnętrzne', 'done' => $checkElearningInternal], ['label' => 'Temat i cel szkolenia', 'done' => $checkTopicAndGoal], ['label' => 'Harmonogram (daty i godziny)', 'done' => $checkSchedule], ['label' => 'Materiały szkoleniowe', 'done' => $checkMaterials], ['label' => 'Aktywny test', 'done' => $checkActiveTest], ['label' => 'Lista uczestnikow', 'done' => $checkParticipants], ]; $preparedSteps = 0; foreach ($preparationSteps as $stepItem) { if (!empty($stepItem['done'])) { $preparedSteps++; } } $totalPreparationSteps = count($preparationSteps); $isReadyToPublish = $preparedSteps === $totalPreparationSteps; @endphp @once @endonce @once @push('scripts') @endpush @endonce