/** * Move all rent guarantee claim details to keyHouse database, but does not * complete the claim * * @param int $referenceNum * * @return void */ public function submitClaim($referenceNum) { // Get Claim Information $dsClaim = new Datasource_Insurance_RentGuaranteeClaim_Claim(); $claimInfo = $dsClaim->getClaimByReferenceNumber($referenceNum); // Get Guarantors Information $dsGuarantors = new Datasource_Insurance_RentGuaranteeClaim_Guarantor(); $guarantorsInfo = $dsGuarantors->getGuarantors($referenceNum); // Get Rent Payments Information $dsRentPayments = new Datasource_Insurance_RentGuaranteeClaim_RentalPayment(); $rentPaymentsInfo = $dsRentPayments->getRentPaymentsByReferenceNumber($referenceNum); // Get Tenants Information $dsTenants = new Datasource_Insurance_RentGuaranteeClaim_Tenant(); $tenantsInfo = $dsTenants->getTenants($referenceNum); // Get Supporting Documents Information $supportingDocuments = new Datasource_Insurance_RentGuaranteeClaim_SupportingDocuments(); $documentsInfo = $supportingDocuments->getByReferenceNumber($referenceNum); // Submit all the data to keyhouse DB $dsKHClaim = new Datasource_Insurance_KeyHouse_Claim(); $validData = array(); if ($dsKHClaim->save($claimInfo)) { $dsKHGuarantors = new Datasource_Insurance_KeyHouse_Guarantors(); if (count($guarantorsInfo) > 0) { foreach ($guarantorsInfo as $guarantor) { $dsKHGuarantors->save($guarantor); } } $dsKHRentPayments = new Datasource_Insurance_KeyHouse_RentPayments(); if (count($rentPaymentsInfo) > 0) { foreach ($rentPaymentsInfo as $rentalPayment) { $dsKHRentPayments->save($rentalPayment); } } $dsKHTenants = new Datasource_Insurance_KeyHouse_Tenants(); if (count($tenantsInfo) > 0) { foreach ($tenantsInfo as $tenant) { $dsKHTenants->save($tenant); } } $dsKHSupportingDocuments = new Datasource_Insurance_KeyHouse_SupportingDocuments(); if (count($documentsInfo) > 0) { foreach ($documentsInfo as $document) { // Convert from StdClass to array as expected. $doc = array(); $doc['reference_number'] = $referenceNum; $doc['supporting_document_name'] = $document->type; $doc['attachment_filename'] = $this->_pathConvert($document->fullPath); $dsKHSupportingDocuments->save($doc); } } } }
/** * * 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); } }