@extends('layouts.app') @section('content')
{{-- Page Header --}}

Data Collection Management

New Data Collection
{{-- Flash Messages --}} @if(session('success')) @endif {{-- Table Card --}}
@if($dataCollections->isEmpty())
No data collection forms found.
@else @foreach($dataCollections as $entry) @endforeach
Title Description Start Date End Date Status Actions
{{ $entry->title }} {{ $entry->description }} {{ $entry->start_date->format('d M Y') }} {{ $entry->end_date->format('d M Y') }} {{-- Status Toggle --}}
status ? 'checked' : '' }} title="{{ $entry->status ? 'Active — click to deactivate' : 'Inactive — click to activate' }}">
{{-- View --}} @if($entry->slug) @else @endif {{-- View Responses (from Google Form) --}} @php $responseUrl = null; if (!empty($entry->iframe_code) && preg_match('/src="([^"]+)"/', $entry->iframe_code, $m)) { $formUrl = $m[1]; $baseUrl = strtok($formUrl, '?'); $responseUrl = str_replace('/viewform', '/edit', $baseUrl) . '#responses'; } @endphp @if($responseUrl) @endif {{-- Download Excel & Open Sheet --}} @php $sheetId = null; $isSheetUrl = false; if (!empty($entry->sheet_url)) { // Check if it's a proper Google Sheets URL if (preg_match('/\/spreadsheets\/d\/([a-zA-Z0-9_-]+)/', $entry->sheet_url, $sm)) { $sheetId = $sm[1]; $isSheetUrl = true; } } @endphp @if($isSheetUrl && $sheetId) {{-- Proper Sheets URL: show Excel download + open sheet --}} @elseif(!empty($entry->sheet_url)) {{-- URL set but not a Sheets URL (e.g. a Forms URL) — show open link only --}} @else {{-- No sheet URL set at all --}} @endif {{-- Edit --}} @if($entry->slug) @else @endif {{-- Delete --}}
@csrf @method('DELETE')
@endif
@endsection