_abbrTitles = [ 'AGI Deductions' => [ 'en' => App_Wizard_View::renderAbbr('AGI') . ' ' . $this->translate('Deductions'), 'es' => null ], 'only those from page 1 of IRS Form 1040' => [ 'en' => $this->translate('only those from page 1 of') . ' ' . App_Wizard_View::renderAbbr('IRS') . ' ' . $this->translate('Form 1040'), 'es' => null ] ]; return $this; } protected function _prepareLanguageAbbrTitle($title) { return ($this->_abbrTitles[$title][CURRENT_LANGUAGE]) ?: $this->translate($title); } protected function _initElements() { $this->_initLanguageAbbrTitles(); $this->addElement( 'numeric', 'wages', array( 'label' => $this->translate('Wages') . $this->_addLabelDescription($this->translate('before taxes, but after pretax deductions')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'selfEmployment', array( 'label' => $this->translate('Self-Employment') . $this->_addLabelDescription($this->translate('proceeds minus expenses')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'socialSecurity', array( 'label' => $this->translate('Social Security') . $this->_addLabelDescription( $this->translate('include all, even nontaxable amounts; do not include') . ' ' . App_Wizard_View::renderAbbr('SSI') ), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'rentalIncome', array( 'label' => $this->translate('Rental Income') . $this->_addLabelDescription($this->translate('proceeds minus expenses')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'retirementOrPension', array( 'label' => 'Retirement/Pension', 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'unemployment', array( 'label' => 'Unemployment', 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'interestOrDividends', array( 'label' => $this->translate('Interest/Dividends') . $this->_addLabelDescription($this->translate('all, including nontaxable amounts')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'scholarshipsOrGrants', array( 'label' => $this->translate('Scholarships/Grants') . $this->_addLabelDescription($this->translate('if taxable')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'spousalSupport', array( 'label' => 'Spousal Support', 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addElement( 'numeric', 'otherTaxableIncome', array( 'label' => $this->translate('Other Taxable Income') . $this->_addLabelDescription($this->translate('any other taxable income')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $elements = array('wages', 'selfEmployment', 'socialSecurity', 'rentalIncome', 'retirementOrPension', 'unemployment', 'interestOrDividends', 'scholarshipsOrGrants', 'spousalSupport', 'otherTaxableIncome'); $this->addDisplayGroup($elements, 'enterIncome', array('legend' => $this->translate('Enter Income'))); $this->addElement( 'numeric', 'agiDeductions', array( 'label' => $this->_prepareLanguageAbbrTitle('AGI Deductions') . $this->_addLabelDescription( $this->_prepareLanguageAbbrTitle('only those from page 1 of IRS Form 1040')), 'negative' => false, 'prepend' => '$', 'required' => false ) ); $this->addDisplayGroup( array('agiDeductions'), 'enterDeductions', array('legend' => $this->translate('Enter Deductions')) ); $smarty = $this->getDoc()->getSmarty(); $notesContent = $smarty->fetch('Wizard/income-calculator-notes.tpl'); $this->addElement('html', 'notes', array('value' => $notesContent, 'decorators' => $this->elementDecorators)); $this->addElement( 'numeric', 'totalIncome', array( 'label' => 'TOTAL Income', 'prepend' => '$', 'required' => false, 'attribs' => array( 'disabled' => true ) ) ); $this->addDisplayGroup(array('notes', 'totalIncome'), 'notesAndTotal'); array_push($elements, 'agiDeductions'); $this->_setEscapeLabelDecorator($elements); return $this; } protected function _addLabelDescription($description) { return ' ' . $description . ''; } protected function _setEscapeLabelDecorator($elements) { foreach($elements as $element) { $this->getElement($element)->getDecorator('Label')->setOption('escape', false); } return $this; } protected function _initButtons() { parent::_initButtons(); $this->getElement('btnSubmit')->setLabel('Continue'); $this->getElement('btnSubmit')->setAttrib('class', 'btn btn-primary btn-submit'); $this->getElement('btnCancel')->setAttrib('class', 'btn btn-cancel'); $this->addDisplayGroup(array('btnCancel', 'btnSubmit'), 'submitGroup'); return $this; } public function render(\Zend_View_Interface $view = null) { /** @var $doc \App_Doc_Site */ $doc = \Zend_Registry::get('doc'); $doc->addScript('js/app/income-calculator-form.js'); $options = array( 'formId' => 'income-calculator-form', 'incrementElementsSelector' => '#income-calculator-form-fieldset-enterIncome :input', 'decrementElementsSelector' => '#income-calculator-form-fieldset-enterDeductions :input', 'resultElementId' => 'totalIncome' ); $doc->addInitObject('app.IncomeCalculator', array($options)); return parent::render($view); } }