diff --git a/module/Olcs/src/Controller/Lva/AbstractUploadEvidenceController.php b/module/Olcs/src/Controller/Lva/AbstractUploadEvidenceController.php index aee8bc995..65d4047de 100644 --- a/module/Olcs/src/Controller/Lva/AbstractUploadEvidenceController.php +++ b/module/Olcs/src/Controller/Lva/AbstractUploadEvidenceController.php @@ -8,6 +8,8 @@ use Common\RefData; use Common\Service\Helper\FileUploadHelperService; use Common\Service\Helper\FormHelperService; +use DateTimeImmutable; +use DateTimeInterface; use Dvsa\Olcs\Transfer\Query\Application\UploadEvidence; use Dvsa\Olcs\Utils\Translation\NiTextTranslation; use Olcs\Controller\Lva\Traits\ApplicationControllerTrait; @@ -38,6 +40,7 @@ abstract class AbstractUploadEvidenceController extends AbstractController protected FormHelperService $formHelper; protected FileUploadHelperService $uploadHelper; + protected string $startTime; /** * @param NiTextTranslation $niTextTranslationUtil @@ -53,6 +56,7 @@ public function __construct( ) { $this->formHelper = $formHelper; $this->uploadHelper = $uploadHelper; + $this->startTime = (new DateTimeImmutable())->format(DateTimeInterface::ATOM); parent::__construct( $niTextTranslationUtil, @@ -69,6 +73,7 @@ public function __construct( public function indexAction() { $form = $this->getForm(); + $form->get('correlationId')->setValue($this->startTime); $request = $this->getRequest(); if ($request->isPost() && $request->getPost('saveAndContinue') !== null) { @@ -165,11 +170,14 @@ private function getForm() */ public function operatingCentreLoadFileUpload() { + $startDateTime = new DateTimeImmutable($this->getRequest()->getPost('correlationId', $this->startTime)); $data = $this->getData(); foreach ($data['operatingCentres'] as $aocData) { if ($aocData['operatingCentre']['id'] === $this->operatingCentreId) { - $documents = $aocData['operatingCentre']['adDocuments']; - return array_filter($documents, fn($document) => $document['isPostSubmissionUpload']); + return array_filter( + $aocData['operatingCentre']['adDocuments'], + fn($document) => $document['isPostSubmissionUpload'] && (new DateTimeImmutable($document['createdOn'])) > $startDateTime, + ); } } @@ -193,7 +201,7 @@ public function operatingCentreProcessFileUpload($file) 'licence' => $this->getLicenceId(), 'application' => $this->getIdentifier(), 'operatingCentre' => $this->operatingCentreId, - 'isPostSubmissionUpload' => true + 'isPostSubmissionUpload' => true, ]; $this->uploadFile($file, $data); @@ -278,7 +286,7 @@ public function financialEvidenceProcessFileUpload($file) 'subCategory' => \Common\Category::DOC_SUB_CATEGORY_FINANCIAL_EVIDENCE_DIGITAL, 'licence' => $applicationData['licence']['id'], 'isExternal' => true, - 'isPostSubmissionUpload' => true + 'isPostSubmissionUpload' => true, ]; $this->uploadFile($file, $data); @@ -290,7 +298,11 @@ public function financialEvidenceProcessFileUpload($file) /** Get list of financial evidence documents */ public function financialEvidenceLoadFileUpload(): array { - return array_filter($this->getFinancialEvidenceData()['documents'], fn($doc) => $doc['isPostSubmissionUpload']); + $startDateTime = new DateTimeImmutable($this->getRequest()->getPost('correlationId', $this->startTime)); + return array_filter( + $this->getFinancialEvidenceData()['documents'], + fn($doc) => $doc['isPostSubmissionUpload'] && (new DateTimeImmutable($doc['createdOn'])) > $startDateTime, + ); } /** @@ -310,7 +322,7 @@ public function supportingEvidenceProcessFileUpload($file) 'subCategory' => \Common\Category::DOC_SUB_CATEGORY_SUPPORTING_EVIDENCE, 'licence' => $applicationData['licence']['id'], 'isExternal' => true, - 'isPostSubmissionUpload' => true + 'isPostSubmissionUpload' => true, ]; $this->uploadFile($file, $data); @@ -322,7 +334,11 @@ public function supportingEvidenceProcessFileUpload($file) /** Get list of supporting evidence documents */ public function supportingEvidenceLoadFileUpload(): array { - return array_filter($this->getData()['supportingEvidence'], fn($doc) => $doc['isPostSubmissionUpload']); + $startDateTime = new DateTimeImmutable($this->getRequest()->getPost('correlationId', $this->startTime)); + return array_filter( + $this->getData()['supportingEvidence'], + fn($doc) => $doc['isPostSubmissionUpload'] && (new DateTimeImmutable($doc['createdOn'])) > $startDateTime, + ); } /**