Form.php 7.75 KB
<?php
/**
 * @package  anc_lib 
 * @category magento
 * @mailto	code [at] netz.coop
 * @author	netz.coop eG* 
 * @copyright (c) 2014, netz.coop eG
 * 
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */ 

class Anc_Lib_Block_Adminhtml_Timetables_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

	protected function _prepareForm() {

		$arrayhour = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23');
		$arraymin = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29',
			'30' => '30', '31' => '31', '32' => '32', '33' => '33', '34' => '34', '35' => '35', '36' => '36', '37' => '37', '38' => '38', '39' => '39', '40' => '40', '41' => '41', '42' => '42', '43' => '43', '44' => '44', '44' => '45', '46' => '46', '47' => '47', '48' => '48', '49' => '49', '50' => '50', '51' => '51', '52' => '52', '53' => '53', '54' => '54', '55' => '55', '56' => '56', '57' => '57', '58' => '58', '59' => '59');


		if (Mage::registry('anc_timetable')) {
			$data = Mage::registry('anc_timetable')->getData();
		} else {
			$data = array();
		}

		$form = new Varien_Data_Form();
		$this->setForm($form);
		$fieldset = $form->addFieldset('anc_timetable', array('name' => 'name')); //Mage::helper('news')->__('news information')));

		$fieldset->addField('name', 'text', array(
			'label' => Mage::helper('anc_lib/data')->__('Name'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'name',
		));

		$fieldset->addField('comment', 'textarea', array(
			'label' => Mage::helper('anc_lib/data')->__('Comment'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'comment',
		));

		$fieldset->addField('start', 'date', array(
			'label' => Mage::helper('anc_lib/data')->__('Start'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'start',
			'tabindex' => 1,
			'image' => $this->getSkinUrl('images/grid-cal.gif'),
			'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
		));
		$fieldset->addField('stop', 'date', array(
			'label' => Mage::helper('anc_lib/data')->__('Stop'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stop',
			'tabindex' => 1,
			'image' => $this->getSkinUrl('images/grid-cal.gif'),
			'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
		));


		$fieldset->addField('starthour', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('Starthour'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'starthour',
			'onclick' => "",
			'onchange' => "",
			'values' => $arrayhour,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('stophour', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('stophour'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stophour',
			'onclick' => "",
			'onchange' => "",
			'values' => $arrayhour,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('startmin', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('startmin'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'startmin',
			'onclick' => "",
			'onchange' => "",
//          'value'  => '1',
			'values' => $arraymin,
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 2
		));
		$fieldset->addField('stopmin', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('stopmin'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stopmin',
			'onclick' => "",
			'onchange' => "",
			'values' => $arraymin,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('monday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('monday'),
			'name' => 'monday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('tuesday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('tuesday'),
			'name' => 'tuesday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('wednesday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('wednesday'),
			'name' => 'wednesday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('thursday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('thursday'),
			'name' => 'thursday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('friday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('friday'),
			'name' => 'friday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('saturday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('saturday'),
			'name' => 'saturday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('sunday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('sunday'),
			'name' => 'sunday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));

		/**
		 * Setzen der Hidden Id für Admin muss über den $data array erfolgen da sonst Magento für neue Elemente 0 setzt
		 */
		$data['admin_user_id'] = $admin = Mage::getSingleton('admin/session')->getUser()->getId();
		$fieldset->addField('admin_user_id', 'hidden', array('name' => 'admin_user_id'));

		$form->setValues($data);

		return parent::_prepareForm();
	}

}