public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $site = $this->site;
     $application = $this->application;
     $builder->add('sale_price', 'money', array('label' => 'Sale Price', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_amount', 'money', array('label' => 'Loan Amount', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_term', 'number', array('label' => 'Term (Years)', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 2)))->add('loan_type', 'choice', array('label' => 'Which type of loan are you applying for?', 'multiple' => false, 'choices' => $application->loanTypes, 'expanded' => true, 'multiple' => false))->add('status', 'choice', array('label' => 'Loan Status', 'choices' => $application->loanStatuses))->add('num_units', 'number', array('label' => 'Number of Units', 'required' => true, 'attr' => array('class' => 'span1')))->add('property_type', 'choice', array('choices' => $application->propertyTypes, 'empty_value' => 'Please select one'))->add('property_year_built', 'text', array('label' => 'Year Built', 'required' => false, 'attr' => array('class' => 'span2', 'maxlength' => 4)))->add('residency_type', 'choice', array('choices' => $application->residencyTypes, 'empty_value' => 'Please select one'))->add('title_company1', 'text', array('label' => 'Name #1', 'required' => false))->add('title_company2', 'text', array('label' => 'Name #2', 'required' => false))->add('has_realtor', 'choice', array('label' => 'Are you currently working with a Realtor?', 'choices' => array(0 => 'No', 1 => 'Yes'), 'multiple' => false, 'expanded' => true))->add('property_location', new PropertyLocationType($site), array('validation_groups' => array('step2')))->add('realtor_name', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_company', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_phone', 'text', array('attr' => array('class' => 'realtor-info-field phonenumber')))->add('borrower', new BorrowerType())->add('co_borrower', 'collection', array('type' => new BorrowerType(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_account', 'collection', array('type' => new AssetAccountType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_real_estate', 'collection', array('type' => new AssetRealEstateType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_other', 'collection', array('type' => new IncomeOtherType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_monthly', 'collection', array('type' => new IncomeMonthlyType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('agreement_one', 'checkbox', array('required' => true))->add('agreement_two', 'checkbox', array('required' => true))->add('agreement_three', 'checkbox', array('required' => true))->add('expense_housing', new ExpenseHousingType())->add('comments', 'textarea', array('attr' => array('class' => 'span3'), 'required' => false))->add('loan_officer', 'entity', array('label' => 'Are you working with a loan officer?', 'class' => 'SudouxMortgageBundle:LoanOfficer', 'property' => 'fullname', 'multiple' => false, 'empty_value' => 'Select a loan officer', 'required' => false, 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllBySiteType($site);
     }))->add('refinance_year_aquired', 'number', array('label' => 'Year Acquired', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 4)))->add('refinance_original_cost', 'money', array('label' => 'Original Cost', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_existing_liens', 'money', array('label' => 'Existing Liens', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_current_rate', 'text', array('label' => 'Current Rate', 'required' => true, 'attr' => array('class' => 'span1')))->add('refinance_current_loan_type', 'text', array('label' => 'Current Loan Type', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_current_lender', 'text', array('label' => 'Current Lender', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_purpose', 'choice', array('label' => 'Purpose of Refinance', 'choices' => $application->refinancePurposes, 'required' => true, 'empty_value' => 'Please select one'))->add('referral_source', 'entity', array('class' => 'Sudoux\\Cms\\FormBundle\\Entity\\ReferralSource', 'property' => 'name', 'required' => false, 'multiple' => true, 'expanded' => true, 'label' => 'Where did you hear about us?', 'attr' => array('class' => 'checkbox-group'), 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllActiveBySiteQuery($site);
     }))->add('no_property_location', 'checkbox', array('label' => 'I do not have a property yet', 'attr' => array('class' => ''), 'required' => false));
     $titleManner = $this->application->getTitleManner();
     if (isset($titleManner)) {
         $builder->add('title_manner', 'text', array('label' => 'Manner', 'required' => false));
     } else {
         $builder->add('title_manner', 'choice', array('label' => 'Manner', 'required' => false, 'choices' => $application->titleManners, 'empty_value' => 'Please select one', 'required' => false));
     }
     /*$group = $application->getMilestoneGroup();
             if(isset($group)) {
     			$builder->add('milestone', 'entity', array(
     				'label' => 'Loan Status',
     				'class' => 'SudouxMortgageBundle:LoanMilestone',
     				'property' => 'name',
     				'multiple' => false,
     				'empty_value' => 'Select a status',
     				'required' => false,
     				'query_builder' => function(EntityRepository $er) use ($group) {
     					return $er->findByMilestoneGroupQuery($group->getId());
     				}
     			));
     		}*/
 }
 protected function formatVantage(LoanApplication $application)
 {
     $site = $application->getSite();
     $a = new \stdClass();
     $coBorrowers = $application->getCoBorrower();
     $borrower = $application->getBorrower();
     $a->isCurrentlyEmployed = False;
     $a->coIsCurrentlyEmployed = False;
     $a->firstName = $borrower->getFirstName();
     $a->lastName = $borrower->getLastName();
     $a->address1 = $borrower->getLocation()->getLocation()->getAddress1();
     $a->address2 = $borrower->getLocation()->getLocation()->getAddress2();
     $a->city = $borrower->getLocation()->getLocation()->getCity();
     $a->state = $borrower->getLocation()->getLocation()->getState()->getAbbreviation();
     $a->zipcode = $borrower->getLocation()->getLocation()->getZipcode();
     $a->email = $borrower->getEmail();
     $a->phoneHome = $borrower->getPhoneHome();
     $a->phoneCell = $borrower->getPhoneMobile();
     $a->ssn = $borrower->getSsn();
     $a->dependants = $borrower->getDependentsNumber();
     $a->dependantsAges = $borrower->getDependentsAges();
     $a->yearsOfResidence = $borrower->getLocation()->getYearsAtLocation();
     $a->monthsOfResidence = $borrower->getLocation()->getMonthsAtLocation();
     $a->isRenting = !$borrower->getLocation()->getOwnResidence();
     $a->hasCoborrower = !$coBorrowers->isEmpty();
     $a->yearsOfSchool = $borrower->getYearsOfSchool();
     switch ($borrower->getMaritalStatus()) {
         case '0':
             $a->maritalStatus = 3;
             break;
         case '1':
             $a->maritalStatus = 1;
             break;
         case '2':
             $a->maritalStatus = 4;
             break;
         default:
             $a->maritalStatus = 0;
     }
     foreach ($borrower->getEmployment() as $job) {
         if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
             $a->isCurrentlyEmployed = True;
             $job->setCurrent(True);
             $a->employer = $job->getEmployerName();
             $a->employerPhone = $job->getEmployerPhone();
             $a->employerAddress1 = $job->getLocation()->getAddress1();
             $a->employerAddress2 = $job->getLocation()->getAddress2();
             $a->employerCity = $job->getLocation()->getCity();
             $a->employerState = $job->getLocation()->getState()->getAbbreviation();
             $a->employerZipCode = $job->getLocation()->getZipcode();
             $a->employmentYearsOnJob = $job->getTimeAtJob()->years;
             $a->employmentMonthsOnJob = $job->getTimeAtJob()->months;
             $a->employmentTitle = $job->getTitle();
         } else {
             $job->setCurrent(False);
         }
     }
     foreach ($coBorrowers as $coBorrower) {
         $a->coFirstName = $coBorrower->getFirstName();
         $a->coLastName = $coBorrower->getLastName();
         $a->coAddress1 = $coBorrower->getLocation()->getLocation()->getAddress1();
         $a->coAddress2 = $coBorrower->getLocation()->getLocation()->getAddress2();
         $a->coCity = $coBorrower->getLocation()->getLocation()->getCity();
         $a->coState = $coBorrower->getLocation()->getLocation()->getstate()->getAbbreviation();
         $a->coZip = $coBorrower->getLocation()->getLocation()->getZipcode();
         $a->coPhoneHome = $coBorrower->getPhoneHome();
         $a->coPhoneCell = $coBorrower->getPhoneMobile();
         $a->coSSN = $coBorrower->getSsn();
         $a->coEmail = $coBorrower->getEmail();
         $a->coDependants = $coBorrower->getDependentsNumber();
         $a->coDependantsAges = $coBorrower->getDependentsAges();
         $a->coYearsOfResidence = $coBorrower->getLocation()->getYearsAtLocation();
         $a->coMonthsOfResidence = $coBorrower->getLocation()->getMonthsAtLocation();
         $a->coIsRenting = !$coBorrower->getLocation()->getOwnResidence();
         foreach ($coBorrower->getEmployment() as $job) {
             if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
                 $a->coIsCurrentlyEmployed = True;
                 $job->setCurrent(True);
                 $a->CoEmployer = $job->getEmployerName();
                 $a->CoEmployerPhone = $job->getEmployerPhone();
                 $a->CoEmployerAddress1 = $job->getLocation()->getAddress1();
                 $a->CoEmployerAddress2 = $job->getLocation()->getAddress2();
                 $a->CoEmployerCity = $job->getLocation()->getCity();
                 $a->CoEmployerState = $job->getLocation()->getState()->getAbbreviation();
                 $a->CoEmployerZipCode = $job->getLocation()->getZipcode();
                 $a->CoEmploymentYearsOnJob = $job->getTimeAtJob()->years;
                 $a->CoEmploymentMonthsOnJob = $job->getTimeAtJob()->months;
                 $a->CoEmploymentTitle = $job->getTitle();
             } else {
                 $job->setCurrent(False);
             }
         }
         switch ($coBorrower->getMaritalStatus()) {
             case '0':
                 $a->coMaritalStatus = 3;
                 break;
             case '1':
                 $a->coMaritalStatus = 1;
                 break;
             case '2':
                 $a->coMaritalStatus = 4;
                 break;
             default:
                 $a->coMaritalStatus = 0;
         }
     }
     $a->loanAmount = $application->getLoanAmount();
     $a->propertyMarketValue = $application->getSalePrice();
     $a->propertyAddress1 = $application->getPropertyLocation()->getAddress1();
     $a->propertyAddress2 = $application->getPropertyLocation()->getAddress2();
     $a->propertyCity = $application->getPropertyLocation()->getCity();
     $a->propertyState = $application->getPropertyLocation()->getState()->getAbbreviation();
     $a->propertyZipCode = $application->getPropertyLocation()->getZipcode();
     $a->realEstateBrokerPhone = $application->getRealtorPhone();
     $a->propertyUse = $application->getResidencyType() + 1;
     $a->vendorLeadPrice = '$5.00';
     $a->vendorLeadId = $application->getId();
     $a->vendorId = $site->getSettings()->getLos()->getUsername();
     $a->vendorPassword = $site->getSettings()->getLos()->getPassword();
     $a->orgId = $site->getSettings()->getLos()->getLicenseKey();
     $a->customerIp = $ip = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
     $a->vendorWebProperty = $site->getPrimaryDomain()->getDomain();
     $a->vendorCampaign = $site->getSettings()->getLos()->getSettings();
     return $a;
 }
Example #3
0
 /**
  * 
  * @param LoanApplication $application
  * @param int $milestoneId
  * @param int $milestoneGroupId
  * @throws \Exception
  */
 public function setLoanMilestone(LoanApplication $application, $milestoneId, $milestoneGroupId)
 {
     try {
         $integrationSite = $this->losConnection->getSite();
         //print_r('Site ID: '. $integrationSite->getId() . ' | Milestone ID: '. $milestoneId . ' | Milestone Group ID: ' . $milestoneGroupId);
         $newMilestone = $this->em->getRepository('SudouxMortgageBundle:LoanMilestone')->findOneMilestoneByLosId($integrationSite, $milestoneId, $milestoneGroupId);
         //print_r('Milestone Name: ' . $newMilestone->getName());
         if (isset($newMilestone)) {
             // check for a change and send to the
             $currentMilestone = $application->getMilestone();
             if (isset($currentMilestone)) {
                 $sendNotifications = $application->getSite()->getSettings()->getInheritedSendMilestonesNotifications();
                 $user = $application->getUser();
                 if ($currentMilestone->getId() != $newMilestone->getId() && $sendNotifications && isset($user)) {
                     if ($user->hasRole('ROLE_MEMBER')) {
                         $email = new Email();
                         $email->setSubject("Your loan status has been updated");
                         $email->setMessage(sprintf("Your loan status for %s has been updated to %s.", $application->getPropertyLocation()->getAddress1(), $newMilestone->getName()));
                         $email->setRecipient($user->getEmail());
                         $email->setSite($application->getSite());
                         $application->addEmail($email);
                         $emailUtil = $this->container->get('sudoux.cms.message.email_util');
                         $emailUtil->logAndSend($email);
                     }
                 }
             }
             $application->setMilestone($newMilestone);
             $application->setMilestoneGroup($newMilestone->getMilestoneGroup());
         } else {
             $e = new \Exception("Milestone not found for loan " . $application->getId());
             $this->logger->crit($e->getMessage());
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
     }
 }
 /**
  * @param LoanApplication $application
  * @param $id
  * @return mixed
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function findOneByLosId(LoanApplication $application, $id)
 {
     $q = $this->createQueryBuilder('d')->where('l.loan = :loan_id')->andWhere('d.los_id = :id')->setParameter('id', $id)->setParameter('loan_id', $application->getId())->getQuery();
     return $q->getOneOrNullResult();
 }