_renderMode = $renderMode; return $this; } public function getRenderMode() { return $this->_renderMode; } public function setIsValidationRender($value) { $this->_isValidationRender = $value; return $this; } public function getIsValidationRender() { return $this->_isValidationRender; } public function setDependentIndex($dependentIndex) { $this->_dependentIndex = $dependentIndex; return $this; } public function getDependentIndex() { if (null === $this->_dependentIndex) { throw new Qs_Exception_EmptyPropertyException($this, '_dependentIndex'); } return $this->_dependentIndex; } public function setDependentElementName($name) { $this->_dependentElementName = $name; return $this; } public function getDependentElementName() { if (null === $this->_dependentElementName) { throw new Qs_Exception_EmptyPropertyException($this, '_dependentElementName'); } return $this->_dependentElementName; } public function setDependentElementLabel($label) { $this->_dependentElementLabel = $label; return $this; } public function getDependentElementLabel() { if (null === $this->_dependentElementLabel) { $this->_dependentElementLabel = ucfirst($this->getDependentElementName()); } return $this->_dependentElementLabel; } public function setDependentCount($count) { $this->_dependentCount = $count; return $this; } public function getDependentCount() { return $this->_dependentCount; } protected function _initLanguageAbbrTitles() { $this->_abbrTitles = [ 'US citizen' => [ 'en' => App_Wizard_View::renderAbbr('US') . $this->translate(' citizen'), 'es' => null ], 'MN resident' => [ 'en' => App_Wizard_View::renderAbbr('MN') . $this->translate(' resident'), 'es' => null ], 'ZIP code' => [ 'en' => App_Wizard_View::renderAbbr('ZIP') . $this->translate(' code'), 'es' => null ], 'Are you lawfully present in the US' => [ 'en' => $this->translate('Are you lawfully present in the ') . App_Wizard_View::renderAbbr('US'), 'es' => null ], 'When you entered the US, did you enter as a Refugee or an Asylee' => [ 'en' => $this->translate('When you entered the ') . App_Wizard_View::renderAbbr('US') . $this->translate(', did you enter as a Refugee or an Asylee'), 'es' => null ], ]; return $this; } protected function _initElements() { $this->_initLanguageAbbrTitles(); if (self::RENDER_MODE_DEPENDENT == $this->_renderMode) { $this->_hasButtons = false; $this->_addDependentElements( $this->getDependentElementName(), $this->getDependentElementLabel(), $this->getDependentIndex(), null, $this->getDependentCount() ); } else { parent::_initElements(); $method = '_addElementsStep' . $this->_step; $this->$method(); } return $this; } public function loadDefaultDecorators() { if (self::RENDER_MODE_DEPENDENT === $this->getRenderMode()) { if (false == $this->loadDefaultDecoratorsIsDisabled() && null == $this->getDecorators()) { $this->addDecorator('FormElements'); } } else { parent::loadDefaultDecorators(); } return $this; } protected function _addElementsStep1() { $this->addElement( 'numeric', 'applicantsCount', array( 'label' => 'How many people are applying for coverage?', 'required' => true, 'precision' => 0, 'negative' => false, 'onchange' => "return Qs_Form_Element_MultiText.addInCount('applicants', $(this).val())" ) ); $this->getElement('applicantsCount')->addValidator('GreaterThan', true, array(0)); $this->getElement('applicantsCount')->getValidator('GreaterThan')->setMessage( $this->translate('Value must be greater than zero'), Zend_Validate_GreaterThan::NOT_GREATER ); $this->addElement( 'multiText', 'applicants', array( 'label' => 'Please name the applicants so we can keep things organized for you:', 'isNumering' => false, 'hasAddLink' => false, 'deleteText' => $this->translate('delete'), 'itemsCount' => $this->_applicantsCount ) ); if ((null === ($applicantsCount = Qs_Request::getPostValue('applicantsCount')) || $applicantsCount > 0)) { $this->getElement('applicants')->setRequired(true)->addValidator( 'NotEmpty', true, array('messages' => ($applicantsCount > 1) ? 'These fields are required' : self::IS_EMPTY_MSG ) ); $validatorOptions = array( 'data' => $this->_getData('applicants') ); $this->getElement('applicants')->addValidator(new App_Wizard_Validate_Unique($validatorOptions), true); } $this->addFormRule(array($this, 'validateFormStep1')); return $this; } protected function _prepareLanguageAbbrTitle($title) { return ($this->_abbrTitles[$title][CURRENT_LANGUAGE]) ?: $this->translate($title); } protected function _addElementsStep2() { $this->addElement( 'radio', 'isUSCitizen', array( 'label' => $this->translate('Are you a ') . $this->_renderTip($this->_prepareLanguageAbbrTitle('US citizen'), 'isUSCitizen') . '?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->_addSameForAllElement('isUSCitizen'); $this->addElement( 'radio', 'isEligibleMedicare', array( 'label' => $this->translate('Are you eligible for ') . $this->_renderTip($this->translate('Medicare'), 'isEligibleMedicare') . '?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->_addSameForAllElement('isEligibleMedicare'); $this->addElement( 'radio', 'isMnResident', array( 'label' => $this->translate('Are you a ') . $this->_renderTip($this->_prepareLanguageAbbrTitle('MN resident'), 'isMnResident') . '?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->_addSameForAllElement('isMnResident'); $this->addElement( 'radio', 'isAmericanIndian', array( 'label' => 'Are you an American Indian?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->_addSameForAllElement('isAmericanIndian'); $this->addElement( 'zip', 'zip', array( 'label' => $this->translate('What is your ') . $this->_prepareLanguageAbbrTitle('ZIP code') . '?', 'required' => true, 'class' => 'zip' ) ); $this->getElement('zip')->getDecorator('Label')->setOption('escape', false); $this->_addSameForAllElement('zip'); $this->addElement( 'date', 'birth', array( 'label' => 'What is your date of birth?', 'required' => true, 'description' => 'use this format: mm/dd/yyyy', 'yearRange' => 'c-100:c', 'tooltipErrorStatus' => false ) ); $this->addElement( 'radio', 'gender', array( 'label' => $this->translate('What is your gender?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('male' => 'Male', 'female' => 'Female'), 'separator' => '', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->addElement( 'radio', 'pregnancyStatus', array( 'label' => $this->translate('What is your pregnancy status?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array( 'currently' => 'Currently Pregnant', 'recently' => $this->_renderTip($this->translate('Recently Pregnant'), 'pregnancyStatus'), 'not' => 'Not Pregnant' ), 'separator' => '', 'attribs' => array('label_class' => 'radiolabel'), 'escape' => false ) ); $this->addElement( 'numeric', 'pregnancyChildren', array( 'label' => $this->translate('How many children are expected with the pregnancy?') . ' ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('pregnancyChildren')->getDecorator('Label')->setOption('escape', false); $this->addElement( 'numeric', 'annualIncome', array( 'label' => $this->translate('What is your ') . $this->_renderTip($this->translate('annual income'), 'annualIncome') . $this->translate(' before taxes?') . ' ' . Qs\Html::renderRequired(), 'negative' => false, 'prepend' => '$' ) ); $this->getElement('annualIncome')->getDecorator('Label') ->setOption('escape', false) ->setOption( 'htmlAfterLabel', '

' . $this->translate('Do not include the income of tax dependents who are not independently required to file taxes') . '

' .'' . $this->_renderTip( 'calculator' . $this->translate('Advanced Income Calculator'), 'annualIncomeCalculator', 'calc_popup') . '' ); $this->addElement( 'numeric', 'monthlyIncome', array( 'label' => $this->translate('What is your current monthly income before taxes?') . ' ' . Qs\Html::renderRequired(), 'negative' => false, 'prepend' => '$' ) ); $this->getElement('monthlyIncome')->getDecorator('Label')->setOption('escape', false); $this->addDisplayGroup( array( 'isUSCitizen', 'isUSCitizen' . self::SAME_FOR_ALL, 'isMnResident', 'isMnResident' . self::SAME_FOR_ALL, 'isAmericanIndian', 'isAmericanIndian' . self::SAME_FOR_ALL, 'birth', 'annualIncome', 'monthlyIncome' ), 'leftColumn' ); $this->addDisplayGroup( array( 'isEligibleMedicare', 'isEligibleMedicare' . self::SAME_FOR_ALL, 'zip', 'zip' . self::SAME_FOR_ALL, 'gender', 'pregnancyStatus', 'pregnancyChildren' ), 'rightColumn' ); $this->addFormRule(array($this, 'validateFormStep2')); return $this; } protected function _addElementsStep3() { $this->addElement( 'radio', 'isLawfully', array( 'label' => $this->_prepareLanguageAbbrTitle('Are you lawfully present in the US') . '?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->addElement( 'select', 'immigrationStatus', array( 'label' => $this->translate('Please indicate your immigration status:') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array( '' => '-- Select One --', 'lawful' => 'Lawful Permanent Resident (I have a Green Card)', 'studentOrWorker' => 'Student Visa or Worker Visa', 'refugeeOrAsylee' => 'Refugee or Asylee', 'u-visa' => 'Crime Victim (U-Visa)', 't-visa' => 'Trafficking Victim / T-Visa', 'vawa' => 'Battered Noncitizen (VAWA)', 'daca' => 'Deferred Action for Childhood Arrivals (DACA)', 'other' => 'Other Status' ) ) ); $this->getElement('immigrationStatus')->getDecorator('Label')->setOption('escape', false); $this->addElement( 'radio', 'isStatusLongerFiveYear', array( 'label' => $this->translate('Have you had that status for five years or longer?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel'), 'escape' => false ) ); $this->addElement( 'radio', 'isEnterAsRefugeeOrAsylee', array( 'label' => $this->_prepareLanguageAbbrTitle('When you entered the US, did you enter as a Refugee or an Asylee') . '?' . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel'), 'escape' => false ) ); $this->addFormRule(array($this, 'validateFormStep3')); return $this; } protected function _addElementsStep5() { $this->addElement( 'select', 'insuranceSituation', array( 'label' => 'Please choose the option which best describes your situation with health insurance' . ' offered by an employer (either an employer of yours or someone in your family):', 'required' => true, 'multiOptions' => array( '' => '-- Select One --', 'haveUse' => 'I have health insurance from an employer', 'haveNotUse' => 'An employer offers me health insurance that I am eligible for, but I decided ' . 'not to take it', 'notHaveNotUse' => 'No employer offers me health insurance' ) ) ); $this->_addSameForAllElement('insuranceSituation'); $this->addElement( 'numeric', 'monthlyPremium', array( 'label' => $this->translate('What would the monthly premium be to cover only the employee ' . 'on the lowest-cost plan offered?') . ' ' . Qs\Html::renderRequired(), 'negative' => false, 'prepend' => '$' ) ); $this->getElement('monthlyPremium')->getDecorator('Label')->setOption('escape', false); $this->_addSameForAllElement('monthlyPremium'); $this->addElement( 'radio', 'isInsuranceOfferMin', array( 'label' => $this->translate('Does the insurance ') . $this->_renderTip($this->translate('provide'), 'isInsuranceOfferMin') . $this->translate(' minimum value?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel'), ) ); $this->_addSameForAllElement('isInsuranceOfferMin'); $this->addFormRule(array($this, 'validateFormStep5')); return $this; } protected function _addElementsStep4() { /* if Applicant Age >= minAge */ $applicantIndex = (isset($this->_applicantIndex)) ? $this->_applicantIndex : $this->_getData('applicantIndex'); $isAge = App_Wizard_View::checkApplicantAge( $this->_getStorageData(2, $applicantIndex)['birth'], App_Settings_Obj::get('minAge')); if ($isAge) { $this->addElement( 'radio', 'isMarried', array( 'label' => 'Are you married?', 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'required' => true, 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->_addDependentElements('spouse', 'Spouse'); $this->addElement( 'radio', 'isLivingTogether', array( 'label' => $this->translate('Do you live with your spouse?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); } $this->addElement( 'select', 'taxFilingStatus', array( 'label' => 'What is your tax filing status?', 'required' => true, 'multiOptions' => array( '' => '-- Select One --', 'filer' => 'Tax Filer', 'dependent' => 'Tax Dependent', 'noTaxNoDependent' => 'Neither Tax Filer nor Tax Dependent' ) ) ); if ($isAge) { $this->addElement( 'radio', 'spouseFilingStatus', array( 'label' => $this->translate('What is your filing status with your spouse?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array( 'jointly' => 'Jointly', 'separately' => 'Separately' ), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); } $this->addElement( 'radio', 'isChildOrSpouseTaxFiler', array( 'label' => $this->translate('Are you the child or spouse of the Tax Filer who claims you as a Tax Dependent?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->addElement( 'radio', 'isChildLivesUnmarriedParents', array( 'label' => $this->translate('Are you a child who lives with both parents who are unmarried?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->addElement( 'radio', 'isChildNoncustodialParent', array( 'label' => $this->translate('Are you a child claimed by a noncustodial parent?') . ' ' . Qs\Html::renderRequired(), 'multiOptions' => array('y' => 'Yes', 'n' => 'No'), 'separator' => ' ', 'attribs' => array('label_class' => 'radiolabel') ) ); $this->addElement( 'numeric', 'siblingsCount', array( 'label' => $this->translate('How many siblings live with you?') . ' ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('siblingsCount')->getDecorator('Label')->setOption('escape', false); $this->_addDependentElements('sibling', 'Sibling', 0, 'siblingsCount'); $this->addElement( 'numeric', 'parentsCount', array( 'label' => $this->translate('How many parents live with you?') . ' ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('parentsCount')->getDecorator('Label')->setOption('escape', false); $this->_addDependentElements('parent', 'Parent', 0, 'parentsCount'); $this->addElement( 'numeric', 'childrenCount', array( 'label' => $this->translate('How many children do you have') . ((!$this->_isApplicantAge($applicantIndex)) ? $this->translate(' (18 years of age or younger)') : '') . '? ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('childrenCount')->getDecorator('Label')->setOption('escape', false); $this->_addDependentElements('child', 'Child', 0, 'childrenCount'); $this->addElement( 'numeric', 'dependentsCount', array( 'label' => $this->translate('How many dependents do you claim?') . ' ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('dependentsCount')->getDecorator('Label') ->setOption('escape', false) ->setOption( 'htmlBeforeLabel', '

' . $this->translate('If you file with a spouse, do not include the spouse as a dependent.') . '

' ); $this->_addDependentElements('dependent', 'Dependent', 0, 'dependentsCount'); $this->addElement( 'numeric', 'filersCount', array( 'label' => $this->translate('How many filers claim you as dependent?') . ' ' . Qs\Html::renderRequired(), 'required' => false, 'precision' => 0, 'negative' => false, ) ); $this->getElement('filersCount')->getDecorator('Label')->setOption('escape', false); $this->_addDependentElements('filer', 'Filer', 0, 'filersCount'); $this->addElement( 'numeric', 'filersDependentsCount', array( 'label' => $this->translate('How many total dependents do those filers claim?') . ' ' . Qs\Html::renderRequired(), 'precision' => 0, 'negative' => false, ) ); $this->getElement('filersDependentsCount')->getDecorator('Label')->setOption('escape', false); $this->_addDependentElements('filersDependent', 'Dependent', 0, 'filersDependentsCount'); $this->addFormRule(array($this, 'validateFormStep4')); return $this; } protected function _addElementsStep6() { $this->addElement('html', 'debugInfo'); return $this; } protected function _addSameForAllElement($prefix) { if (count($this->_getApplicants()) > 1 && $this->_applicantIndex == 0) { /* show only for first applicant */ $this->addElement( 'checkbox', $prefix . self::SAME_FOR_ALL, array( 'label' => 'Same for all applicants', 'decoration' => 'simple', ) ); } return $this; } /** * Get Applicants list for DependentElement by element name * @param string $name * @return array */ protected function _getDependentApplicants($name) { $applicants = $this->_getApplicants(); if ($name == 'spouse') { $applicants = $this->_prepareSpouseList($applicants); } if ($name != 'filersDependent') { /* remove current applicant from list if element name not filersDependent*/ unset($applicants[$this->_applicantIndex]); } $applicants = $applicants + $this->_prepareAdditionalPersons(); return $applicants; } /** * Only applicants whose age >= minAge * @param array $applicants * @return array */ protected function _prepareSpouseList(array $applicants) { foreach (array_keys($applicants) as $applicantIndex) { $applicantAge = App_Wizard_View::getApplicantAge($this->_getStorageData(2, $applicantIndex)['birth']); if (isset($applicantAge) && $applicantAge < App_Settings_Obj::get('minAge')) { unset($applicants[$applicantIndex]); } } return $applicants; } /** * get Additional Persons just from previous forms * @return array */ protected function _prepareAdditionalPersons() { $result = array(); foreach ($this->_getAdditionalPersons() as $key => $person) { if ($person['applicantIndex'] < $this->_applicantIndex) { $result[self::NEW_PERSON_PREFIX . $person['name']] = $person['name']; } } asort($result); return $result; } protected function _addDependentElements($name = 'spouse', $label = 'Spouse', $startIndex = 0, $countElementName = null, $count = 1) { $applicants = $this->_getDependentApplicants($name); if ($name == 'spouse' || self::RENDER_MODE_DEPENDENT == $this->_renderMode) { $elementCount = $count; } else { if ($this->_isValidationRender) { $elementCount = $this->_getData($countElementName); } else { $storageData = $this->_getStorageData($this->_step, $this->_applicantIndex); $storageElementCount = (isset($storageData[$countElementName])) ? $storageData[$countElementName] : null; $elementCount = ($storageElementCount) ? $storageElementCount : $count; } } for ($i = $startIndex; $i < $startIndex + $elementCount; $i++) { if ($name != 'spouse') { $elementNameSuffix = '_' . $i; $attributeNameSuffix = '_' . $i; } else { $elementNameSuffix = ''; $attributeNameSuffix = ''; } $this->addElement( 'select', $name . 'Id' . $elementNameSuffix, array( 'required' => false, 'multiOptions' => array('' => 'Choose ' . $label) + $applicants + array('new' => 'Add ' . $label), 'attribs' => array('name' => $name . 'Id' . $attributeNameSuffix), ) ); $this->getElement($name . 'Id' . $elementNameSuffix)->getDecorator('Label')->setTagOption('class', 'hidden'); $this->addElement( 'text', 'new' . ucfirst($name) . $elementNameSuffix, array( 'label' => 'Name', 'required' => false, 'attribs' => array('name' => 'new' . ucfirst($name) . $attributeNameSuffix) ) ); $this->addDisplayGroup( array($name . 'Id' . $elementNameSuffix, 'new' . ucfirst($name) . $elementNameSuffix), $name . 'FirstRow' . $elementNameSuffix, array('class' => 'inline-fields') ); $this->addElement( 'numeric', $name . 'AnnualIncome' . $elementNameSuffix, array( 'label' => ($name != 'spouse') ? $this->_renderTip($this->translate('Annual income'), 'annualIncome') : 'Annual income', 'negative' => false, 'prepend' => '$', 'required' => false, 'attribs' => array('name' => $name . 'AnnualIncome' . $attributeNameSuffix) ) ); $this->getElement($name . 'AnnualIncome' . $elementNameSuffix)->getDecorator('Label') ->setOption('escape', false); $this->addElement( 'numeric', $name . 'MonthlyIncome' . $elementNameSuffix, array( 'label' => 'Monthly income', 'negative' => false, 'prepend' => '$', 'required' => false, 'attribs' => array('name' => $name . 'MonthlyIncome' . $attributeNameSuffix) ) ); $this->addDisplayGroup( array($name . 'AnnualIncome' . $elementNameSuffix, $name . 'MonthlyIncome' . $elementNameSuffix), $name . 'SecondRow' . $elementNameSuffix, array('class' => 'inline-fields') ); } return $this; } protected function _renderTip($linkText, $hintName, $idAttrib = null) { $html = ''; if ($linkText && $hintName) { $tipContent = htmlspecialchars(App_Hint_Obj::getHintByName($hintName)); if ($tipContent) { $idAttrib = ($idAttrib) ? 'id="' . $idAttrib . '" ': ' '; $html = '' . $linkText . ''; } } return $html; } /** * @param array $data * @return array|bool */ public function validateFormStep1(array $data) { $errors = array(); return (!$errors) ? true : $errors; } /** * @param array $data * @return array|bool */ public function validateFormStep2(array $data) { $errors = array(); if (!isset($data['isUSCitizen'])) { $errors['isUSCitizen'] = self::IS_EMPTY_MSG; } if (!isset($data['isMnResident'])) { $errors['isMnResident'] = self::IS_EMPTY_MSG; } if (!isset($data['isAmericanIndian'])) { $errors['isAmericanIndian'] = self::IS_EMPTY_MSG; } if (!isset($data['isEligibleMedicare'])) { $errors['isEligibleMedicare'] = self::IS_EMPTY_MSG; } if ($data['zip']) { if (true !== ($result = (new App_BenchmarkPlans_Obj())->validateZip($data['zip']))) { $errors['zip'] = $result; } } $DateFormat = new \Zend\Validator\Date(array('format' => 'Y-m-d')); if($data['birth'] && !($DateFormat->isValid($data['birth']))){ $errors['birth'] = 'Date is in wrong format'; } else { $isIncomeAge = App_Wizard_View::checkApplicantAge($data['birth'], App_Settings_Obj::get('minIncomeAge')); if ($isIncomeAge) { if (empty($data['annualIncome'])) { $errors['annualIncome'] = self::IS_EMPTY_MSG; } if (empty($data['monthlyIncome'])) { $errors['monthlyIncome'] = self::IS_EMPTY_MSG; } } $isAge = App_Wizard_View::checkApplicantAge($data['birth'], App_Settings_Obj::get('minAge')); if (!isset($data['gender']) && $isAge ) { $errors['gender'] = self::IS_EMPTY_MSG; } if (isset($data['gender']) && $data['gender'] == 'female' && $isAge) { if (!isset($data['pregnancyStatus'])) { $errors['pregnancyStatus'] = self::IS_EMPTY_MSG; } elseif ($data['pregnancyStatus'] == 'currently' && !isset($data['pregnancyChildren'])) { $errors['pregnancyChildren'] = self::IS_EMPTY_MSG; } } } return (!$errors) ? true : $errors; } /** * @param array $data * @return array|bool */ public function validateFormStep3(array $data) { $errors = array(); $pregnancyStatus = $this->_getStorageData(2, $this->_applicantIndex)['pregnancyStatus']; $applicantAge = App_Wizard_View::getApplicantAge($this->_getStorageData(2, $this->_applicantIndex)['birth']); if (isset($data['isLawfully']) && $data['isLawfully'] == 'y' && !$data['immigrationStatus']) { $errors['immigrationStatus'] = self::IS_EMPTY_MSG; } if ('currently' != $pregnancyStatus && 'recently' != $pregnancyStatus && $applicantAge >= 21 && isset($data['immigrationStatus']) && ($data['immigrationStatus'] == 'lawful' || $data['immigrationStatus'] == 'vawa') && !$data['isStatusLongerFiveYear'] ) { $errors['isStatusLongerFiveYear'] = self::IS_EMPTY_MSG; } if (isset($data['isStatusLongerFiveYear']) && $data['isStatusLongerFiveYear'] == 'n' && !$data['isEnterAsRefugeeOrAsylee'] ) { $errors['isEnterAsRefugeeOrAsylee'] = self::IS_EMPTY_MSG; } return (!$errors) ? true : $errors; } /** * @param array $data * @return array|bool */ public function validateFormStep5(array $data) { $errors = array(); if ($data['insuranceSituation'] == 'haveNotUse' && !$data['monthlyPremium']) { $errors['monthlyPremium'] = self::IS_EMPTY_MSG; } $sessionData = $_SESSION['App_Wizard_View']['wizardData']; if (isset($data['monthlyPremium']) && $data['monthlyPremium']) { $resultInsuranceOffer = App_Wizard_View::checkInsuranceOffer( $data['monthlyPremium'], (new App_Wizard_Processing($sessionData))->getIncomeAPTC($this->_applicantIndex) ); if (false == $resultInsuranceOffer && empty($data['isInsuranceOfferMin'])) { $errors['isInsuranceOfferMin'] = self::IS_EMPTY_MSG; } } return (!$errors) ? true : $errors; } /** * @param array $data * @return array|bool */ public function validateFormStep4(array $data) { $errors = array(); $isAge = $this->_isApplicantAge($data['applicantIndex']); if (isset($data['isMarried']) && $data['isMarried'] == 'y') { $this->_validateDependentElement($errors, $data, 'spouse'); if (!$data['isLivingTogether']) { $errors['isLivingTogether'] = self::IS_EMPTY_MSG; } } if (isset($data['taxFilingStatus'])) { if ($data['taxFilingStatus'] == 'filer'){ if (isset($data['isMarried']) && $data['isMarried'] == 'y' && !$data['spouseFilingStatus']) { $errors['spouseFilingStatus'] = self::IS_EMPTY_MSG; } if ($data['dependentsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'dependent', $data['dependentsCount']); } } elseif ($data['taxFilingStatus'] == 'dependent') { if (!$data['isChildOrSpouseTaxFiler']) { $errors['isChildOrSpouseTaxFiler'] = self::IS_EMPTY_MSG; } elseif ($data['isChildOrSpouseTaxFiler'] == 'n') { if ($isAge) { if ($data['childrenCount'] > 0) { $this->_validateDependentElement($errors, $data, 'child', $data['childrenCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } else { if ($data['siblingsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'sibling', $data['siblingsCount']); } if ($data['parentsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'parent', $data['parentsCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } } elseif ($data['isChildOrSpouseTaxFiler'] == 'y') { if ($isAge) { if ($data['childrenCount'] > 0) { $this->_validateDependentElement($errors, $data, 'child', $data['childrenCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } else { if (!$data['isChildLivesUnmarriedParents']) { $errors['isChildLivesUnmarriedParents'] = self::IS_EMPTY_MSG; } elseif ($data['isChildLivesUnmarriedParents'] == 'y') { if ($data['siblingsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'sibling', $data['siblingsCount']); } if ($data['parentsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'parent', $data['parentsCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } elseif ($data['isChildLivesUnmarriedParents'] == 'n') { if (!$data['isChildNoncustodialParent']) { $errors['isChildNoncustodialParent'] = self::IS_EMPTY_MSG; } elseif ($data['isChildNoncustodialParent'] == 'y') { if ($data['siblingsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'sibling', $data['siblingsCount']); } if ($data['parentsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'parent', $data['parentsCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } elseif ($data['isChildNoncustodialParent'] == 'n') { if ($data['dependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'dependent', $data['dependentsCount']); } if ($data['filersCount'] > 0) { $this->_validateDependentElement($errors, $data, 'filer', $data['filersCount']); } if ($data['filersDependentsCount'] > 0) { $this->_validateDependentElement( $errors, $data, 'filersDependent', $data['filersDependentsCount']); } } } } } } elseif ($data['taxFilingStatus'] == 'noTaxNoDependent') { if ($isAge) { if ($data['childrenCount'] > 0) { $this->_validateDependentElement($errors, $data, 'child', $data['childrenCount']); } } else { if ($data['siblingsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'sibling', $data['siblingsCount']); } if ($data['parentsCount'] > 0) { $this->_validateDependentElement($errors, $data, 'parent', $data['parentsCount']); } if ($data['childrenCount'] > 0) { $this->_validateDependentElement($errors, $data, 'child', $data['childrenCount']); } } } } return (!$errors) ? true : $errors; } public function _validateDependentElement(&$errors, $data, $name, $count = 1) { for ($i = 0; $i < $count; $i++) { $elementNameSuffix = ($name != 'spouse') ? '_' . $i : ''; if ($data[$name . 'Id' . $elementNameSuffix] == '') { $errors[$name . 'Id' . $elementNameSuffix] = self::IS_EMPTY_MSG; } elseif (isset($data[$name . 'Id' . $elementNameSuffix]) && $data[$name . 'Id' . $elementNameSuffix] == 'new' ) { if ($data['new' . ucfirst($name) . $elementNameSuffix] == '') { $errors['new' . ucfirst($name) . $elementNameSuffix] = self::IS_EMPTY_MSG; } else { if ($data['new' . ucfirst($name) . $elementNameSuffix]) { if ($data[$name . 'AnnualIncome' . $elementNameSuffix] == '') { $errors[$name . 'AnnualIncome' . $elementNameSuffix] = self::IS_EMPTY_MSG; } if ($data[$name . 'MonthlyIncome' . $elementNameSuffix] == '') { $errors[$name . 'MonthlyIncome' . $elementNameSuffix] = self::IS_EMPTY_MSG; } } } } } return $this; } }