#!/bin/bash
# Exit on error
set -e
# Source environment variables
if [ -f ".env" ]; then
source .env
else
echo "Error: .env file not found. Please create it with the required variables."
exit 1
fi
echo "===== Fixing Certificate Reports Critical Error ====="
# Create script to fix certificate reports
FIX_CERT_SCRIPT="Please log in to view certificate reports.
\";
return;
}
if ( ! current_user_can( \"view_hvac_dashboard\" ) ) {
echo \"You do not have permission to view certificate reports.
\";
return;
}
?>
Certificate Reports
Certificate reporting functionality is being restored.
This page will show certificate generation and management tools once the system is fully operational.
Coming Soon
- Certificate generation reports
- Attendee certificate status
- Bulk certificate operations
- Certificate download management
';
// Save the minimal template
if (file_put_contents(\$cert_template_path, \$minimal_template)) {
echo \"Created minimal certificate reports template\n\";
} else {
echo \"Failed to create minimal template\n\";
}
}
} else {
echo \"Certificate reports template not found\n\";
// Create the template directory if it doesn't exist
\$cert_dir = WP_CONTENT_DIR . '/plugins/hvac-community-events/templates/certificates';
if (!is_dir(\$cert_dir)) {
mkdir(\$cert_dir, 0755, true);
echo \"Created certificates template directory\n\";
}
// Create a basic template
\$basic_template = 'Please log in to view certificate reports.\";
return;
}
?>
Certificate Reports
Certificate reports are currently being set up.
';
if (file_put_contents(\$cert_template_path, \$basic_template)) {
echo \"Created basic certificate reports template\n\";
} else {
echo \"Failed to create basic template\n\";
}
}
echo \"Certificate reports fix complete\n\";
"
# Execute the fix
echo "Executing certificate reports fix..."
sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > fix-cert-reports.php << 'EOF'
$FIX_CERT_SCRIPT
EOF"
sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && php fix-cert-reports.php"
# Clean up
sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && rm fix-cert-reports.php"
echo -e "\n===== Certificate Reports Fix Complete ====="
echo "The certificate reports page should now load without critical errors."
echo "Please try accessing the Certificate Reports page again."