/** * Create important information subform * @todo the questions in subform-importantinformation.phtml are currently hard coded and should be pulled out of the DB/model * * @return void */ public function init() { // Invoke the previous claims manager $claimsManager = new Manager_Insurance_PreviousClaims(); // Create array of claim types $claimDescriptions = array('' => 'Please select...'); $claimDescriptionsObj = $claimsManager->getPreviousClaimTypes(Model_Insurance_ProductNames::TENANTCONTENTSPLUS); foreach ($claimDescriptionsObj as $claimDescriptionObj) { $claimTypeId = $claimDescriptionObj->getClaimTypeID(); $claimDescriptions[$claimTypeId] = $claimDescriptionObj->getClaimTypeText(); } // Add declaration question 1 element $this->addElement('radio', 'declaration1', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 1', 'notEmptyInvalid' => 'Please select an answer for declaration question 1')))))); // Add conditional details for Q1 $this->addElement('textarea', 'declaration1_details', array('label' => 'Please provide details', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter details for declaration question 1')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-ctfilter' => 'yes', 'class' => 'declarationAnswer form-control'))); // Add declaration question 2 element $this->addElement('radio', 'declaration2', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 2', 'notEmptyInvalid' => 'Please select an answer for declaration question 2')))))); $this->addElement('hidden', 'claim_confirm', array('label' => '', 'required' => false, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must add the claim to complete this step', 'notEmptyInvalid' => 'You must add the claim to complete this step')))))); // Add conditional details for Q2 // Add claim type element $this->addElement('select', 'claim_type', array('label' => 'Type of claim', 'required' => false, 'multiOptions' => $claimDescriptions, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim type', 'notEmptyInvalid' => 'Please select your claim type')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'class' => 'form-control'))); $this->addElement('select', 'claim_month', array('label' => 'Month of claim', 'required' => false, 'multiOptions' => array('' => 'Please select...', '01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim month', 'notEmptyInvalid' => 'Please select your claim month')))), 'attribs' => array('class' => 'form-control'))); $claimYears = array('' => 'Please select...'); $nowYear = date('Y'); for ($i = $nowYear; $i >= $nowYear - 5; $i--) { $claimYears[$i] = $i; } $this->addElement('select', 'claim_year', array('label' => 'Year of claim', 'required' => false, 'multiOptions' => $claimYears, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim year', 'notEmptyInvalid' => 'Please select your claim year')))), 'attribs' => array('class' => 'form-control'))); $this->addElement('text', 'claim_value', array('required' => false, 'attribs' => array('class' => 'currency'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the claim value', 'notEmptyInvalid' => 'Please enter the claim value'))), array('GreaterThan', true, array('min' => 0, 'messages' => 'Claim value must be above zero'))), 'attribs' => array('class' => 'form-control'))); // Add declaration question 3 element $this->addElement('radio', 'declaration3', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 3', 'notEmptyInvalid' => 'Please select an answer for declaration question 3')))))); // Add conditional details for Q3 $this->addElement('textarea', 'declaration3_details', array('label' => 'Please provide details', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter details for declaration question 3')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-ctfilter' => 'yes', 'class' => 'declarationAnswer form-control'))); // Add declaration question 4 element $this->addElement('radio', 'declaration4', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 4', 'notEmptyInvalid' => 'Please select an answer for declaration question 4')))))); // Add conditional details for Q4 $this->addElement('textarea', 'declaration4_details', array('label' => 'Please provide details', 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter details for declaration question 4')))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-ctfilter' => 'yes', 'class' => 'declarationAnswer form-control'))); // Add declaration confirmation element $this->addElement('radio', 'declaration_confirmation', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for the confirmation statement', 'notEmptyInvalid' => 'Please select an answer for the confirmation statement'))), array('Identical', true, array('token' => 'yes', 'messages' => array('notSame' => 'Please agree to the confirmation statement')))))); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/important-information.phtml')))); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); // Grab view and add the declarations JavaScript into the page head $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'); $view->headScript()->appendFile('/assets/tenants-insurance-quote/js/declarations.js', 'text/javascript'); }
public function init() { //Claim type element. $this->addElement('select', 'claim_type', array('label' => 'Type of claim:', 'required' => true, 'multiOptions' => array('' => self::PLEASE_SELECT), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim type', 'notEmptyInvalid' => 'Please select your claim type')))), 'attribs' => array('class' => 'form-control'))); $claimsManager = new Manager_Insurance_PreviousClaims(); $claimTypeObjects = $claimsManager->getPreviousClaimTypes(Model_Insurance_ProductNames::LANDLORDSPLUS); $claimTypeList = array(); $claimTypeList[''] = self::PLEASE_SELECT; foreach ($claimTypeObjects as $claimType) { $id = $claimType->getClaimTypeID(); $text = $claimType->getClaimTypeText(); $claimTypeList[$id] = $text; } //Add the claim types. $claimTypesSelect = $this->getElement('claim_type'); $claimTypesSelect->setMultiOptions($claimTypeList); //Claim month element. $this->addElement('select', 'claim_month', array('label' => 'Month of claim:', 'required' => true, 'multiOptions' => array('' => self::PLEASE_SELECT, '01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'), 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim month', 'notEmptyInvalid' => 'Please select your claim month')))), 'attribs' => array('class' => 'form-control'))); $claimYears = array('' => self::PLEASE_SELECT); $nowYear = date('Y'); for ($i = $nowYear; $i >= $nowYear - 5; $i--) { $claimYears[$i] = $i; } $this->addElement('select', 'claim_year', array('label' => 'Year of claim:', 'required' => true, 'multiOptions' => $claimYears, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select your claim year', 'notEmptyInvalid' => 'Please select your claim year')))), 'attribs' => array('class' => 'form-control'))); $this->addElement('text', 'claim_value', array('label' => 'Value of claim:', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter the claim value', 'notEmptyInvalid' => 'Please enter the claim value'))), array('GreaterThan', true, array('min' => 0, 'messages' => 'Claim value must be above zero'))), 'attribs' => array('data-required' => 'required', 'data-validate' => 'validate', 'data-type' => 'currency', 'class' => 'currency form-control'))); // Add a filter suitable for currency input - this strips anything non-digit and non-decimal point such as pound // symbols and commas $claimValue = $this->getElement('claim_value'); $claimValue->addFilter('callback', function ($v) { return preg_replace('/[^\\d\\.]/', '', $v); }); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/claims-dialog.phtml')))); // Clear the default dt and dd element decorators $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); }
/** * Helper function for generating claims history summary HTML fragment * * @return string */ public function yourClaims() { $output = ''; $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); // Invoke previous claims manager $claimsManager = new Manager_Insurance_PreviousClaims(); // Fetch all claims $claimData = $claimsManager->getPreviousClaims($pageSession->CustomerRefNo); // Fetch claim descriptions $claimDescriptionsObj = $claimsManager->getPreviousClaimTypes(Model_Insurance_ProductNames::TENANTCONTENTSPLUS); // Transform object array into a somewhat more usefully indexed descriptions array $claimDescriptions = array(); foreach ($claimDescriptionsObj as $claimDescriptionObj) { $claimDescriptions[$claimDescriptionObj->getClaimTypeID()] = $claimDescriptionObj->getClaimTypeText(); } if (count($claimData) > 0) { $output .= '<table class="table table-bordered table-condensed table-possessions">'; // Container with indent $output .= " <tr>\n"; // Line container with bottom edge $output .= " <th>Claims you have added to your policy</th>\n"; $output .= " <th>Value</th>\n"; $output .= " <th></th>\n"; $output .= " </tr>\n"; foreach ($claimData as $key => $claim) { $output .= " <tr>\n"; // Line container with bottom edge $output .= " <td class=\"description\">" . $claimDescriptions[$claim->getClaimType()->getClaimTypeID()] . '<br />Date: ' . $claim->getClaimMonth() . '/' . $claim->getClaimYear() . "</td>\n"; $output .= " <td class=\"price\">£" . number_format($claim->getClaimValue()->getValue()) . "</td>\n"; $output .= " <td><a id=\"removeClaim{$key}\" href=\"#\" onclick=\"removeClaimClick({$key}); return false;\" class=\"tertiary-colour\">Remove claim</a></td>\n"; $output .= " </tr>\n"; } $output .= '</table>'; } return $output; }
/** * Create important information subform * @todo the questions in subform-importantinformation.phtml are currently hard coded and should be pulled out of the DB/model * * @return void */ public function init() { // Invoke the previous claims manager $claimsManager = new Manager_Insurance_PreviousClaims(); // Create array of claim types $claimDescriptions = array('' => '--- please select ---'); $claimDescriptionsObj = $claimsManager->getPreviousClaimTypes(Model_Insurance_ProductNames::LANDLORDSPLUS); foreach ($claimDescriptionsObj as $claimDescriptionObj) { $claimTypeId = $claimDescriptionObj->getClaimTypeID(); $claimDescriptions[$claimTypeId] = $claimDescriptionObj->getClaimTypeText(); } // Add declaration question 1 element $this->addElement('radio', 'declaration1', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 1', 'notEmptyInvalid' => 'Please select an answer for declaration question 1')))))); // Add declaration question 2 element $this->addElement('radio', 'declaration2', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 2', 'notEmptyInvalid' => 'Please select an answer for declaration question 2')))))); // Add declaration question 3 element $this->addElement('radio', 'declaration3', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 2b', 'notEmptyInvalid' => 'Please select an answer for declaration question 2b')))))); // Add declaration question 4 element $this->addElement('radio', 'declaration4', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 2c', 'notEmptyInvalid' => 'Please select an answer for declaration question 2c')))))); // Add declaration question 5 element $this->addElement('radio', 'declaration5', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 2d', 'notEmptyInvalid' => 'Please select an answer for declaration question 2d')))))); // Add declaration question 6 element $this->addElement('radio', 'declaration6', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 3', 'notEmptyInvalid' => 'Please select an answer for declaration question 3')))))); // Add declaration question 7 element $this->addElement('radio', 'declaration7', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 4', 'notEmptyInvalid' => 'Please select an answer for declaration question 4')))))); // Add declaration question 8 element $this->addElement('radio', 'declaration8', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 5', 'notEmptyInvalid' => 'Please select an answer for declaration question 5')))))); // Add declaration question 9 element $this->addElement('radio', 'declaration9', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 6', 'notEmptyInvalid' => 'Please select an answer for declaration question 6')))))); // Add declaration question 10 element $this->addElement('radio', 'declaration10', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 7', 'notEmptyInvalid' => 'Please select an answer for declaration question 7')))))); // Add declaration question 11 element $this->addElement('radio', 'declaration11', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 8', 'notEmptyInvalid' => 'Please select an answer for declaration question 8')))))); // Add declaration question 12 element $this->addElement('radio', 'declaration12', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 9', 'notEmptyInvalid' => 'Please select an answer for declaration question 9')))))); // Add declaration question 13 element $this->addElement('radio', 'declaration13', array('label' => '', 'required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for declaration question 10', 'notEmptyInvalid' => 'Please select an answer for declaration question 10')))))); /****** ***/ $this->addElement('hidden', 'additionCheck1', array('required' => false)); $this->addElement('hidden', 'additionCheck2', array('required' => false)); $this->addElement('hidden', 'additionCheck3', array('required' => false)); $this->addElement('hidden', 'additionCheck4', array('required' => false)); $this->addElement('hidden', 'additionCheck5', array('required' => false)); $this->addElement('hidden', 'additionCheck6', array('required' => false)); $this->addElement('hidden', 'additionCheck7', array('required' => false)); $this->addElement('hidden', 'additionCheck8', array('required' => false)); $this->addElement('hidden', 'additionCheck9', array('required' => false)); $this->addElement('hidden', 'additionCheck10', array('required' => false)); $this->addElement('hidden', 'additionCheck11', array('required' => false)); $this->addElement('hidden', 'additionCheck12', array('required' => false)); $this->addElement('hidden', 'additionCheck13', array('required' => false)); /***** ****/ // Add declaration confirmation element $this->addElement('radio', 'declaration_confirmation', array('required' => true, 'multiOptions' => array('yes' => 'Yes', 'no' => 'No'), 'separator' => '', 'label_placement' => 'prepend', 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select an answer for the confirmation statement', 'notEmptyInvalid' => 'Please select an answer for the confirmation statement'))), array('Identical', true, array('token' => 'yes', 'messages' => array('notSame' => 'Please agree to the confirmation statement')))))); // Set custom subform decorator $this->setDecorators(array(array('ViewScript', array('viewScript' => 'portfolio-insurance-quote/subforms/important-information.phtml')))); // Strip all tags to prevent XSS errors $this->setElementFilters(array('StripTags')); $this->setElementDecorators(array(array('ViewHelper', array('escape' => false)), array('Label', array('escape' => false)))); // Grab view and add the declarations JavaScript into the page head $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'); /* $view->headScript()->appendFile( '/assets/cms/js/portfolio-insurance-quote/declarations.js', 'text/javascript' );*/ }
public function removePreviousClaimAction() { $request = $this->getRequest(); $postData = $request->getPost(); $refNo = $postData['refNo']; $month = $postData['month']; $year = $postData['year']; $value = $postData['value']; $typeId = $postData['typeId']; //Remove the previous claim identified by the id if (!empty($refNo)) { $claimsManager = new Manager_Insurance_PreviousClaims(); //Build a PreviousClaim object to pass to the PreviousClaims manager //to delete. $previousClaim = new Model_Insurance_PreviousClaim(); $previousClaim->setRefno($refNo); $previousClaim->setClaimMonth($month); $previousClaim->setClaimYear($year); $value = new Zend_Currency(array('value' => $value, 'precision' => 2)); $previousClaim->setClaimValue($value); $previousClaimTypes = $claimsManager->getPreviousClaimTypes(); foreach ($previousClaimTypes as $claimType) { if ($typeId == $claimType->getClaimTypeID()) { $previousClaim->setClaimType($claimType); break; } } //Finally, remove the previous claim. $claimsManager->removePreviousClaim($previousClaim); } $claimsArray = $claimsManager->getPreviousClaims($refNo); $model = array(); if (!empty($claimsArray)) { foreach ($claimsArray as $claim) { $model[] = array('claim' => $claim); } } $return = array(); $return['html'] = $this->view->partialLoop('partials/claims-list.phtml', $model); $return['success'] = true; echo Zend_Json::encode($return); }