public function set_from_input($_INPUT = array(), $pre = '') { try { $c_new = new CT1_Cashflows(); if (count($_INPUT) > 0) { foreach ($_INPUT as $i) { if (is_array($i)) { $c = new CT1_Cashflow(); $a = $this->annuity_type($i); $a->set_from_input($i); $c->set_annuity($a); $c->set_rate_per_year($i['rate_per_year']); $c->set_effective_time($i['effective_time']); $c_new->add_object($c); } } $this->set_objects($c_new->get_objects()); $this->class = $c_new->class; return true; } else { return false; } } catch (Exception $e) { throw new Exception(wfMessage('fm-exception-in')->text() . __FILE__ . ": " . $e->getMessage()); } }
/** * Get array of parameters for form to add a new cashflow * * @return array * * @access private */ private function get_add_cashflow() { $a_e = new CT1_Annuity_Escalating(); $a_i = new CT1_Annuity_Increasing(); $c_e = new CT1_Cashflow(0, 0, $a_e); $c_i = new CT1_Cashflow(0, 0, $a_i); $parameters = array(); $parameters['single_payment'] = array('name' => 'single_payment', 'label' => wfMessage('fm-single_payment')->text()); $parameters_c = array_merge($c_e->get_parameters(), $c_i->get_parameters()); $parameters = array_merge($parameters, $parameters_c); $valid_options = array_merge($c_e->get_valid_options(), $c_i->get_valid_options()); $valid_options['single_payment'] = array('type' => boolean); $valid_options['consider_increasing'] = array('type' => boolean); $parameters['consider_increasing'] = array('name' => 'consider_increasing', 'label' => wfMessage('fm-consider_increasing')->text()); foreach (array('value', 'delta', 'escalation_delta') as $p) { unset($parameters[$p]); unset($valid_options[$p]); } $values = array_merge($c_e->get_values(), $c_i->get_values()); $form = array(); $form['method'] = 'GET'; $form['parameters'] = $parameters; $form['valid_options'] = $valid_options; $form['request'] = 'add_cashflow'; $form['render'] = 'HTML'; $form['introduction'] = wfMessage('fm-add-a-cashflow')->text(); $form['submit'] = wfMessage('fm-add')->text(); $form['exclude'] = array("i_effective"); $form['values'] = $values; $form['hidden'] = $this->get_hidden_cashflow_fields(); return $form; }