public function init()
 {
     parent::init();
     if (!$this->getHmHomeId()) {
         throw new Exception();
     }
     $element = new Zend_Form_Element_Select('year');
     $element->setLabel('Jaar')->setRequired(true)->addMultiOption('', '...');
     $percentages = Model_Hm_Day_Percentage::findAllByHomeId($this->_hmHomeId)->execute(null, Doctrine_Core::HYDRATE_ARRAY);
     $availableYears = new Model_Hm_AvailableYears($percentages, 5);
     foreach ($availableYears->toArray() as $year) {
         $element->addMultiOption($year, $year);
     }
     $this->addElement($element);
     $elements[] = 'year';
     for ($i = 1; $i <= 7; $i++) {
         $elementName = $this->_labelTemplates[$i];
         $elements[] = 'day_' . $i;
         $element = new Zend_Form_Element_Text('day_' . $i);
         $element->setLabel($elementName)->setRequired(true)->setAttribs(array('maxlength' => 6))->setValidators(array(array('float'), array('stringLength', false, array('max' => 6))));
         $this->addElement($element);
     }
     $this->addDisplayGroup($elements, 'days', array('legend' => 'Percentage'));
     $element = new Zend_Form_Element_Submit('submit_percentageday');
     $element->setLabel('Verwerken')->setAttrib('class', 'submit');
     $this->addElement($element);
     $this->addDisplayGroup(array('submit_percentageday'), 'submit', array('class' => 'submit'));
     $this->bhvkDecorators();
     $this->bhvkDecorateSubmitElement($this->getElement('submit_percentageday'));
 }
 public function isValid($value)
 {
     if (Model_Hm_Day_Percentage::isNew($this->_hmHomeId, $value)) {
         return true;
     }
     $this->_error(self::EXISTS);
     return false;
 }
 public function adminAction()
 {
     // data
     $hid = $this->_getParam('hid');
     $weekPercentages = Model_Hm_Week_Percentage::findAllByHomeId($hid)->execute();
     $dayPercentages = Model_Hm_Day_Percentage::findAllByHomeId($hid)->execute();
     // view
     $this->view->weekPercentages = $weekPercentages;
     $this->view->dayPercentages = $dayPercentages;
     $this->view->layout()->setLayout('submenu');
 }