#!/bin/bash
#
# Helper script to open all verification PDFs one by one
#
set -e

echo "=========================================="
echo "Opening Verification PDFs"
echo "=========================================="
echo ""

echo "📋 This will open PDFs in 3 groups:"
echo "   1. PL11089 documents (3 PDFs)"
echo "   2. BP102 documents (3 PDFs)"
echo "   3. PL689 sample documents (3 PDFs)"
echo ""
echo "Press ENTER after viewing each group to continue..."
echo ""

# Group 1: PL11089
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "GROUP 1: PL11089 Documents (3 PDFs)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

pl11089_files=(
    "/tmp/PL11089_History_Card_doc10000000013787.pdf"
    "/tmp/PL11089_Property_File_46pages_doc10000000013791.pdf"
    "/tmp/PL11089_Land_Form_7_doc10000000013800.pdf"
)

for pdf in "${pl11089_files[@]}"; do
    if [ -f "$pdf" ]; then
        echo "📄 Opening: $(basename "$pdf")"
        xdg-open "$pdf" 2>/dev/null &
        sleep 1
    else
        echo "⚠️  Not found: $(basename "$pdf")"
    fi
done

echo ""
echo "✅ Check these 3 PDFs for PL11089"
echo "   For each one, note what document number is shown in the 'R OF O NO' field"
echo ""
read -p "Press ENTER when ready to continue to BP102..." 

# Group 2: BP102
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "GROUP 2: BP102 Documents (3 PDFs)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

bp102_files=(
    "/tmp/aumentum_audit_2015/BP102_doc10000000014368.pdf"
    "/tmp/aumentum_audit_2015/BP102_doc10000000014369.pdf"
    "/tmp/aumentum_audit_2015/BP102_doc10000000014377.pdf"
)

for pdf in "${bp102_files[@]}"; do
    if [ -f "$pdf" ]; then
        echo "📄 Opening: $(basename "$pdf")"
        xdg-open "$pdf" 2>/dev/null &
        sleep 1
    else
        echo "⚠️  Not found: $(basename "$pdf")"
    fi
done

echo ""
echo "✅ Check these 3 PDFs for BP102"
echo "   Verify they all show 'BP102' correctly"
echo ""
read -p "Press ENTER when ready to continue to PL689..." 

# Group 3: PL689 samples
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "GROUP 3: PL689 Sample Documents (3 PDFs)"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

pl689_files=(
    "/tmp/aumentum_audit_2015/PL689_doc10000000012415.pdf"
    "/tmp/aumentum_audit_2015/PL689_doc10000000012418.pdf"
    "/tmp/aumentum_audit_2015/PL689_doc10000000012419.pdf"
)

for pdf in "${pl689_files[@]}"; do
    if [ -f "$pdf" ]; then
        echo "📄 Opening: $(basename "$pdf")"
        xdg-open "$pdf" 2>/dev/null &
        sleep 1
    else
        echo "⚠️  Not found: $(basename "$pdf")"
    fi
done

echo ""
echo "✅ Check these 3 PDFs for PL689"
echo "   Verify they show 'PL689' correctly"
echo ""

echo "=========================================="
echo "Verification Complete!"
echo "=========================================="
echo ""
echo "📝 Now please fill out the verification form:"
echo ""
echo "PL11089 Documents:"
echo "  History Card:    Shows ___________"
echo "  Property File:   Shows ___________"
echo "  Land Form 7:     Shows ___________"
echo ""
echo "BP102 Documents:"
echo "  Property File:   Shows ___________"
echo "  History Card:    Shows ___________"
echo "  Land Form 7:     Shows ___________"
echo ""
echo "PL689 Documents:"
echo "  History Card:    Shows ___________"
echo "  Property File:   Shows ___________"
echo "  Land Form 7:     Shows ___________"
echo ""
echo "Share these findings so we can create the proper fix!"

