Form.php 5.92 KB
<?php
/**
 * @package  anc_album
 * @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_Album_Block_Adminhtml_Albums_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

	protected function _prepareForm() {

		if (Mage::registry('anc_album')) {
			$data = Mage::registry('anc_album')->getData();
		} else {
			$data = array();
		}
		$varParam = $this->getRequest()->getParams();
		$form = new Varien_Data_Form();
		$this->setForm($form);
		
		$fieldset = $form->addFieldset('anc_album', array('name' => 'name')); //Mage::helper('news')->__('news information')));

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

		$fieldset->addField('comment', 'textarea', array(
			'label' => Mage::helper('anc_album/data')->__('Comment'),
//			'class' => 'required-entry',
//			'required' => true,
			'name' => 'comment',
		));
		$fieldset->addField('url_rewrite', 'text', array(
			'label' => Mage::helper('anc_album/data')->__('url_rewrite'),
//			'class' => 'required-entry',
//			'required' => true,
			'name' => 'url_rewrite',
		));
		
		if($varParam['kind']==='users'|| $data['customer_id'] > 0 ){
			$fieldset->addField('customer_id', 'text', array(
			'label' => Mage::helper('anc_album/data')->__('Customer Id'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'customer_id',
			));
		}
		


		$fieldset->addField('isplaylist', 'radios', array(
			'label' => Mage::helper('anc_album/data')->__('Playlist'),
			'name' => 'isplaylist',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));


		$fieldset->addField('iscategory', 'radios', array(
			'label' => Mage::helper('anc_album/data')->__('Kategorie'),
			'name' => 'iscategory',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('categoryshowinproductselection', 'radios', array(
			'label' => Mage::helper('anc_album/data')->__('Zeige in Produktauswahl'),
			'name' => 'categoryshowinproductselection',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));


		$arrayoptions = array('0' => 'Standard Album');
		$arrayoptions['1'] = 'Gutscheinecken Album';

		if (array_key_exists('isadvertising', $varParam)) {
			$var_advertising = $varParam['isadvertising'];
		}

		$fieldset->addField('isadvertising', 'select', array(
			'label' => Mage::helper('anc_album/data')->__('Typ'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'isadvertising',
			'onclick' => "",
			'onchange' => "",
			'value' => $var_advertising,
			'values' => $arrayoptions,
			'disabled' => false,
			'readonly' => false,
		));
		


		$varurlimages = $this->getUrl('image/adminhtml_image/list', array(
			'target' => '_blank',
			'albumid' => $data['entity_id'],
//            'type'=> 'text',  
				)
		);



		$varurltexts = $this->getUrl('text/adminhtml_text/list', array(
			'albumid' => $data['entity_id'],
//            'type'=> 'text',  
		));

		$arrayurl=array('albumid'=>$data['entity_id']);
		
		if($data['ncright_id']>0){
			$arrayurl['id']=$data['ncright_id'];
		}
		
		$varurlrights = $this->getUrl('lib/adminhtml_ncrights/edit', $arrayurl
		);

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

		$fieldset->addType('ancbutton','Anc_Album_Lib_Varien_Data_Form_Element_ExtendedLabel');
		if($varParam['id']){
			$fieldset->addField('myimage', 'ancbutton', array(
			   'label'         => 'Bilder verwalten',
			   'name'          => 'mycustom_element',
			   'required'      => false,
			   'value'     => $varurlimages,
			   'bold'      =>  true,
			   'label_style'   =>  'font-weight: bold;color:red;',
		   ));

			 $fieldset->addField('my_rights', 'ancbutton', array(
			   'label'         => 'Rechte verwalten',
			   'name'          => 'mycustom_element',
			   'required'      => false,
			   'value'     => $varurlrights,
			   'bold'      =>  true,
			   'label_style'   =>  'font-weight: bold;color:red;',
		   ));
		   $fieldset->addField('my_texts', 'ancbutton', array(
			   'label'         => 'Texte verwalten',
			   'name'          => 'mycustom_element',
			   'required'      => false,
			   'value'     => $varurltexts,
			   'bold'      =>  true,
			   'label_style'   =>  'font-weight: bold;color:red;',
		   ));
		}
		 if (!empty($data)) {
			$form->addValues($data);
		}


		return parent::_prepareForm();
	}

}