@php $stage=$query['stage']??''; $draft=session()->has('import')?json_decode(\App\Support\Repository::unseal(session('import')),true):null; if($draft&&(int)$draft['semester']===$sid&&in_array($stage,['map','review'],true)): @endphp
← Import center

{!! $stage==='map'?'Map file columns':'Review before importing' !!}

{!! e($draft['filename']) !!} · {!! e($draft['kind']) !!} · {!! count($draft['rows']) !!} data rows

@if($stage==='map')
{!! \App\Support\Ui::csrf() !!}
@foreach(\App\Services\SpreadsheetService::IMPORT_FIELDS[$draft['kind']] as $field)@endforeach
@php else: $review=\App\Services\ImportService::prepare_import($sid,$draft['kind'],$draft['rows'],session('mapping', [])??[]);foreach($review['warnings'] as $w): @endphp
{!! e($w) !!}
@php endforeach;if($review['errors']): @endphp
No rows will be imported.
@else
{!! count($review['rows']) !!} validated, unique rows. Allocation and notifications are processed after commit.
@php endif; $heads=\App\Services\SpreadsheetService::IMPORT_FIELDS[$draft['kind']];$body=[];foreach(array_slice($review['rows'],0,12) as $r){$body[]=array_map(fn($h)=>$h==='access_code'?'•••••• (protected)':e($r[$h]??''),$heads);} echo \App\Support\Ui::table($heads,$body); @endphp

Preview shows up to 12 validated rows. The entire file has been checked.

@php if(!$review['errors']): echo \App\Support\Ui::post_form('commit_import',$sid,'','Commit import');endif;@endphpChange column mapping@endif
@else

Upload a staff-supplied file

Choose the file type, map its columns, then review validation results. No mailbox access is used.

{!! \App\Support\Ui::csrf() !!}

One worksheet · Maximum 8 MB / 10,000 rows · Format IDs, ISBNs and access codes as text.

Download import templates

Headers are in English. Fill one row per student-course-section, required book, access code or delivered book as appropriate.

@foreach(\App\Services\SpreadsheetService::IMPORT_FIELDS as $key=>$fields){!! e(ucfirst($key)) !!}XLSX ↓@endforeach
@endif

Committed imports

{!! \App\Support\Ui::table(['Time (UTC)','Type','Filename','Rows','Actor'],array_map(fn($r)=>[e($r['created_at']),\App\Support\Ui::badge($r['kind']),e($r['filename']),e($r['row_count']),e($r['actor'])],$records->importHistory([$sid]))) !!}
@if(isset($records->paginators['imports']))@include('components.pagination',['paginator'=>$records->paginators['imports']])@endif