<?php
/**
 * Chay mot lan tren host (CLI hoac trinh duyet neu dat bao ve) de kiem tra file plugin.
 *
 * CLI tu thu muc plugin:
 *   php tools/plugin-self-check.php
 *
 * @package DatvetaucaotocBooking
 */

$plugin_dir = dirname( __DIR__ );
$checks     = array(
	'datvetaucaotoc-booking.php',
	'includes/class-plugin.php',
	'includes/class-database.php',
	'includes/bootstrap-polyfills.php',
	'includes/class-rest-api.php',
	'includes/admin/class-admin.php',
	'assets/build/wizard.js',
);

$ok = true;
foreach ( $checks as $rel ) {
	$path = $plugin_dir . '/' . $rel;
	$exists = is_readable( $path );
	$size   = $exists ? (string) filesize( $path ) : '0';
	echo ( $exists ? '[OK]' : '[MISSING]' ) . ' ' . $rel . ' (' . $size . " bytes)\n";
	if ( ! $exists ) {
		$ok = false;
	}
}

echo 'PHP ' . PHP_VERSION . "\n";
echo class_exists( 'ZipArchive' ) ? "[OK] ZipArchive\n" : "[WARN] ZipArchive missing (Import Excel se loi)\n";

exit( $ok ? 0 : 1 );
