<?php
namespace App\Services;
use App\Entity\Transaction;
use App\Repository\BirthDeathMarriageCertificatesRepository;
use App\Repository\CriminalRecordCheckRepository;
use App\Repository\DrivingLicenseRepository;
use App\Repository\EmploymentContractsRepository;
use App\Repository\FinancialStatementsRepository;
use App\Repository\HealthInsuranceRepository;
use App\Repository\MedicalRepository;
use App\Repository\PassportsRepository;
use App\Repository\SchoolAttendanceCertificatesRepository;
use App\Repository\ServicesOfferedRepository;
use App\Repository\TenancyAgreementsRepository;
use App\Repository\TransactionRepository;
use App\Repository\UtilityBillsRepository;
class TransactionAllDocsReady
{
public function checkStatus(Transaction $transaction)
{
$service = $transaction->getService();
$client = $transaction->getClient();
$passportRequired = $service->isDocsPassport();
$birthMarriageDeathCertificateRequired = $service->isDocsBirthMarriageDeathCertificate();
$drivingLicenseRequired = $service->isDocsDrivingLicense();
$medicalRequired = $service->isDocsMedical();
$healthInsuranceRequired = $service->isDocsHealthInsurance();
$schoolAttendanceCertificateRequired = $service->isDocsSchoolAttendanceCertificate();
$financialStatementsRequired = $service->isDocsFinancialStatements();
$employmentContractRequired = $service->isDocsEmploymentContract();
$utilityBillRequired = $service->isDocsUtilityBill();
$tenancyAgreementRequired = $service->isDocsTenancyAgreement();
$criminalRecordCheckRequired = $service->isDocsCriminalRecordCheck();
$overall_status = TRUE;
if ($passportRequired) {
if (!$this->passportRepository->isPassportUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($birthMarriageDeathCertificateRequired) {
if (!$this->birthDeathMarriageCertificatesRepository->isBirthMarriageDeathCertificateUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($drivingLicenseRequired) {
if (!$this->drivingLicenseRepository->isDrivingLicenseUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($medicalRequired) {
if (!$this->medicalRepository->isMedicalUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($healthInsuranceRequired) {
if (!$this->healthInsuranceRepository->isHealthInsuranceUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($schoolAttendanceCertificateRequired) {
if (!$this->schoolAttendanceCertificatesRepository->isSchoolAttendanceCertificateUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($financialStatementsRequired) {
if (!$this->financialStatementsRepository->isFinancialStatementsUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($employmentContractRequired) {
if (!$this->employmentContractsRepository->isEmploymentContractUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($utilityBillRequired) {
if (!$this->utilityBillsRepository->isUtilityBillUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($tenancyAgreementRequired) {
if (!$this->tenancyAgreementsRepository->isTenancyAgreementUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
if ($criminalRecordCheckRequired) {
if (!$this->criminalRecordCheckRepository->isCriminalRecordCheckUploadedAndChecked($client)) {
$overall_status = FALSE;
}
}
return $overall_status;
}
public function __construct(TransactionRepository $transactionRepository, ServicesOfferedRepository $servicesOfferedRepository, PassportsRepository $passportRepository,
BirthDeathMarriageCertificatesRepository $birthDeathMarriageCertificatesRepository, DrivingLicenseRepository $drivingLicenseRepository, MedicalRepository $medicalRepository,
HealthInsuranceRepository $healthInsuranceRepository, SchoolAttendanceCertificatesRepository $schoolAttendanceCertificatesRepository, FinancialStatementsRepository $financialStatementsRepository,
EmploymentContractsRepository $employmentContractsRepository, UtilityBillsRepository $utilityBillsRepository,TenancyAgreementsRepository $tenancyAgreementsRepository,
CriminalRecordCheckRepository $criminalRecordCheckRepository
)
{
$this->transactionRepository = $transactionRepository;
$this->servicesOfferedRepository = $servicesOfferedRepository;
$this->passportRepository = $passportRepository;
$this->birthDeathMarriageCertificatesRepository = $birthDeathMarriageCertificatesRepository;
$this->drivingLicenseRepository = $drivingLicenseRepository;
$this->medicalRepository = $medicalRepository;
$this->healthInsuranceRepository = $healthInsuranceRepository;
$this->schoolAttendanceCertificatesRepository = $schoolAttendanceCertificatesRepository;
$this->financialStatementsRepository = $financialStatementsRepository;
$this->employmentContractsRepository = $employmentContractsRepository;
$this->utilityBillsRepository = $utilityBillsRepository;
$this->tenancyAgreementsRepository = $tenancyAgreementsRepository;
$this->criminalRecordCheckRepository = $criminalRecordCheckRepository;
}
}