/** * * Delete claim details for the given Claim Reference Number * * @param int $referenceNumber * * @param int $agentSchemeNum * * @return void */ public function deleteClaim($referenceNumber, $agentSchemeNum) { $dsGuarantors = new Datasource_Insurance_RentGuaranteeClaim_Guarantor(); $dsRentPayments = new Datasource_Insurance_RentGuaranteeClaim_RentalPayment(); $dsTenants = new Datasource_Insurance_RentGuaranteeClaim_Tenant(); $dsSupportingDocuments = new Datasource_Insurance_RentGuaranteeClaim_SupportingDocuments(); $dsKeyHouseValidation = new Datasource_Insurance_RentGuaranteeClaim_KeyhouseValidation(); $dsGuarantors->removeGuarantors($referenceNumber); $dsRentPayments->deleteByReferenceNumber($referenceNumber); $dsTenants->removeTenants($referenceNumber); $dsSupportingDocuments->deleteByReferenceNumber($referenceNumber); $dsKeyHouseValidation->deleteByReferenceNumber($referenceNumber); if (empty($this->_onlineclaimModel)) { $this->_onlineclaimModel = new Datasource_Insurance_RentGuaranteeClaim_Claim(); } $this->_onlineclaimModel->deleteClaim($referenceNumber); //remove the supporting documents files $supportDocManager = new Manager_Insurance_RentGuaranteeClaim_SupportingDocument($referenceNumber, $agentSchemeNum); $docPath = $supportDocManager->getPath(); //."/".$agentSchemeNum."/".$referenceNumber; if (file_exists($docPath)) { rmdir($docPath); } }
/** * Initialise the step 2 form * * @return void */ public function step3Action() { $pageForm = new Connect_Form_RentGuaranteeClaims_Step3(); $this->view->pageTitle = 'Online Claims - Step3 - Additional information and Rental payments'; // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 3;'); if ($this->getRequest()->isPost()) { if (isset($_POST['back'])) { $this->_formStepCommonNavigate(3); return; } $this->_formStepAgentPopulate($pageForm); if ($this->_formStepCommonValidate($pageForm, 3)) { $data = $pageForm->getValues(); // Instantiate the claim manager $claimManager = new Manager_Insurance_RentGuaranteeClaim_Claim($this->_claimReferenceNumber); $claim = $claimManager->getClaim($this->_claimReferenceNumber, $this->_agentSchemeNumber); $claim->setAdditionalInfo($data['additional_information']); // Claim payment bank acount details $claim->setClaimPaymentBankAccountName($data['dd_accountname']); $claim->setClaimPaymentBankAccountNumber($data['bank_account_number']); $claim->setClaimPaymentBankAccountSortCode($data['bank_sortcode_number']); $claimManager->updateClaim($claim); // TODO: The following code for the saving of the rent schedule // data as a supporting doc needs to be moved into a manager, // not be performed by a controller. // Get ready for saving arrears data as a supporting document $supportManager = new Manager_Insurance_RentGuaranteeClaim_SupportingDocument($this->_claimReferenceNumber, $this->_agentSchemeNumber); // Prepare upload directories $supportManager->prepareUploadDirs(); // Save the arrears data into a supporting document file $manager = new Manager_Insurance_RentGuaranteeClaim_RentalPayment(); $supportManagerDs = new Datasource_Insurance_RentGuaranteeClaim_SupportingDocuments(); $paymentDs = new Datasource_Insurance_RentGuaranteeClaim_RentalPayment(); // Encode data $paymentDataEncoded = $paymentDs->processToCsv($this->_claimReferenceNumber); // Save data $path = $supportManager->getPath() . 'Rent_Schedule.csv'; // TODO: parameterise filename file_put_contents($path, $paymentDataEncoded); // Note saved data in DB if not already in it $files = $supportManagerDs->getByReferenceNumber($this->_claimReferenceNumber); $csvInDb = false; foreach ($files as $file) { if ($file->type == 'rent_schedule' && $file->name == 'Rent_Schedule.csv') { $csvInDb = true; break 1; } } if (!$csvInDb) { $shortPath = substr($path, strlen(APPLICATION_PATH . '/../private/uploads/')); $supportManagerDs->addSupportingDocument($this->_claimReferenceNumber, 'rent_schedule', $shortPath); } // Everything has been saved ok so navigate to next step $this->_formStepCommonNavigate(3); return; } } else { $this->_formStepCommonPopulate($pageForm, 3); } // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step3'); $this->view->pageTitle = 'Online Claims - Step3 - Additional Information and Rental Payments'; }