beginTransaction(); changeApplicationStatus( $pdo, $applicationId, 'draft', 'under_review', 'UNISEARCH administrator accepted the draft application for review.', $adminName ); $pdo->commit(); notifyStudentForApplicationStatus( $pdo, (int)$application['student_id'], $applicationId, 'under_review', 'UNISEARCH has started reviewing your university application.' ); $_SESSION[ 'admin_flash_success' ] = 'Application progressed from Draft to Under Review.'; header( 'Location: application.php?id=' . $applicationId ); exit; } } catch (Throwable $e) { if ($pdo->inTransaction()) { $pdo->rollBack(); } error_log( 'Admin draft progression error: ' . $e->getMessage() ); $errors[] = 'We could not progress the draft application.'; } } } /* |-------------------------------------------------------------------------- | ADMIN DELETE DRAFT APPLICATION |-------------------------------------------------------------------------- | | Permanent deletion is intentionally restricted to Draft applications. | This prevents accidental destruction of an application which already has | university decisions, offers, CAS or visa history. |-------------------------------------------------------------------------- */ if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_application']) ) { $csrf = (string)( $_POST['csrf_token'] ?? '' ); $confirmReference = trim( (string)( $_POST['confirm_reference'] ?? '' ) ); if ( $csrf === '' || !hash_equals( $_SESSION['admin_csrf_token'], $csrf ) ) { $errors[] = 'Your session expired. Please refresh and try again.'; } if (!$errors) { try { $application = findApplicationForAction( $pdo, $applicationId ); if (!$application) { $errors[] = 'Application not found.'; } elseif ( (string)$application[ 'application_status' ] !== 'draft' ) { $errors[] = 'Only Draft applications can be permanently deleted.'; } elseif ( $confirmReference !== (string)$application[ 'reference_number' ] ) { $errors[] = 'The application reference entered does not match.'; } else { $pdo->beginTransaction(); /* |-------------------------------------------------------------------------- | DELETE CHILD RECORDS FIRST |-------------------------------------------------------------------------- */ $deleteOfferResponses = $pdo->prepare( " DELETE FROM application_offer_responses WHERE application_id = ? " ); $deleteOfferResponses->execute([ $applicationId ]); $deleteDocuments = $pdo->prepare( " DELETE FROM documents WHERE application_id = ? " ); $deleteDocuments->execute([ $applicationId ]); $deleteConditions = $pdo->prepare( " DELETE FROM application_conditions WHERE application_id = ? " ); $deleteConditions->execute([ $applicationId ]); $deleteOfferProgress = $pdo->prepare( " DELETE FROM application_offer_progress WHERE application_id = ? " ); $deleteOfferProgress->execute([ $applicationId ]); $deleteCasRecords = $pdo->prepare( " DELETE FROM application_cas_records WHERE application_id = ? " ); $deleteCasRecords->execute([ $applicationId ]); $deleteDocumentRequests = $pdo->prepare( " DELETE FROM document_requests WHERE application_id = ? " ); $deleteDocumentRequests->execute([ $applicationId ]); $deleteStatusHistory = $pdo->prepare( " DELETE FROM application_status_history WHERE application_id = ? " ); $deleteStatusHistory->execute([ $applicationId ]); /* |-------------------------------------------------------------------------- | DELETE UNIVERSITY DECISIONS LAST |-------------------------------------------------------------------------- */ $deleteDecisions = $pdo->prepare( " DELETE FROM application_decisions WHERE application_id = ? " ); $deleteDecisions->execute([ $applicationId ]); /* |-------------------------------------------------------------------------- | DELETE APPLICATION |-------------------------------------------------------------------------- */ $deleteApplication = $pdo->prepare( " DELETE FROM applications WHERE id = ? AND application_status = 'draft' " ); $deleteApplication->execute([ $applicationId ]); if ( $deleteApplication->rowCount() !== 1 ) { throw new RuntimeException( 'Application could not be deleted.' ); } $pdo->commit(); $_SESSION[ 'admin_flash_success' ] = 'Draft application deleted successfully.'; header( 'Location: applications.php' ); exit; } } catch (Throwable $e) { if ($pdo->inTransaction()) { $pdo->rollBack(); } error_log( 'Delete application error: ' . $e->getMessage() ); $errors[] = 'We could not delete this application.'; } } } /* |-------------------------------------------------------------------------- | STEP 2 | | FIND THIS EXISTING SECTION INSIDE THE REQUEST DOCUMENTS HANDLER: | | [ | 'submitted_to_unisearch', | 'under_review', | 'ready_for_university', | 'submitted_to_university' | ] | | REPLACE THAT ARRAY WITH THIS: |-------------------------------------------------------------------------- */ $documentRequestAllowedStatuses = [ 'draft', 'submitted_to_unisearch', 'under_review', 'ready_for_university', 'submitted_to_university' ]; /* |-------------------------------------------------------------------------- | THEN CHANGE THE EXISTING VALIDATION TO: |-------------------------------------------------------------------------- */ if ( !in_array( $oldStatus, $documentRequestAllowedStatuses, true ) ) { $errors[] = 'Additional documents cannot be requested at the current application stage.'; } /* |-------------------------------------------------------------------------- | STEP 3 | | GO TO: | |
|
Current Workflow
|

Case Actions

| | DIRECTLY AFTER

Case Actions

| PASTE EVERYTHING BELOW. |-------------------------------------------------------------------------- */ ?>

Progress Application

This application is currently saved as Draft. If UNISEARCH is ready to take control of the case, move it directly into formal review.

Request Documents

Ask the student to upload missing documents before or during the formal application review.

Delete Application

Permanently delete this Draft application. This action cannot be undone. To confirm deletion, enter the application reference: