$ErrorActionPreference = 'Stop'
$base = 'c:\xampp\htdocs\tsdhhl26'
$outDir = 'c:\xampp\htdocs\tsdhhl26\update_patch'

# Clean previous if exists
if (Test-Path $outDir) { Remove-Item -Recurse -Force $outDir }
if (Test-Path "$base\update_patch.zip") { Remove-Item -Force "$base\update_patch.zip" }

New-Item -ItemType Directory -Force -Path $outDir | Out-Null
New-Item -ItemType Directory -Force -Path "$outDir\assets\css" | Out-Null
New-Item -ItemType Directory -Force -Path "$outDir\assets\js" | Out-Null
New-Item -ItemType Directory -Force -Path "$outDir\includes\components" | Out-Null
New-Item -ItemType Directory -Force -Path "$outDir\candidate" | Out-Null
New-Item -ItemType Directory -Force -Path "$outDir\admin" | Out-Null

Copy-Item "$base\assets\css\dashboard.css" -Destination "$outDir\assets\css\" -Force
Copy-Item "$base\assets\js\address_combo.js" -Destination "$outDir\assets\js\" -Force
Copy-Item "$base\includes\components\address_combo.php" -Destination "$outDir\includes\components\" -Force
Copy-Item "$base\candidate\profile.php" -Destination "$outDir\candidate\" -Force
Copy-Item "$base\candidate\apply.php" -Destination "$outDir\candidate\" -Force
Copy-Item "$base\admin\users.php" -Destination "$outDir\admin\" -Force

Start-Sleep -Seconds 2

Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory($outDir, "$base\update_patch.zip")

Remove-Item -Recurse -Force $outDir

Write-Host "Zip created successfully using .NET compression."
