Form.php 3.95 KB
<?php

/**
 * @package magento
 * @subpackage AncPricepercustomer
 *
 * @author netz.coop code[at]netz.coop
 *
 * @license http://www.gnu.org/licenses/gpl-3.0.de.html GNU GENERAL PUBLIC LICENSE VERSION 3
 * @copyright (C) 2015 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_Pricespercustomer_Block_Adminhtml_Pricespercustomer_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {

    protected function _prepareForm() {

        $this->setChild('backButton', $this->getLayout()->createBlock('adminhtml/widget_button')
                        ->setData(array(
                            'label' => Mage::helper('adminhtml')->__('Back'),
                            'onclick' => 'window.location.href=\'' . $this->getUrl('customer/edit/') . '\'',
                            'class' => 'back'
                        ))
        );
        $form = new Varien_Data_Form(array(
            'id' => 'edit_form',
            'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
            'method' => 'post',
            'enctype' => 'multipart/form-data'
        ));
        $form->setUseContainer(true);
        $this->setForm($form);
        if (Mage::getSingleton('adminhtml/session')->getFormData()) {
            $data = Mage::getSingleton('adminhtml/session')->getFormData();
            Mage::getSingleton('adminhtml/session')->setFormData(null);
        } elseif (Mage::registry('pricespercustomer_data')) {
            $data = Mage::registry('pricespercustomer_data')->getData();
        }
        $fieldset = $form->addFieldset('pricespercustomer_form', array('legend' => Mage::helper('pricespercustomer')->__('customer prices information')));
        $actionname = $this->getRequest()->getActionName();
        if ($actionname == 'new') {
            $form->setValues($data);
        }
        $fieldset->addField('customer_id', 'text', array(
            'label' => Mage::helper('pricespercustomer')->__('customer id'),
            'required' => false,
            'name' => 'customer_id',
            'value' => $this->getRequest()->getParam('customerid'),
        ));
        $fieldset->addField('product_id', 'text', array(
            'label' => Mage::helper('pricespercustomer')->__('product id'),
            'required' => false,
            'name' => 'product_id',
            'title' => 'Produkt ID',
        ));
        $fieldset->addField('price_adjustment', 'text', array(
            'label' => Mage::helper('pricespercustomer')->__('Price'),
            'required' => false,
            'name' => 'price_adjustment',
            'title' => '0.00',
        ));
        $fieldset->addField('price_adjustment_type', 'select', array(
            'label' => Mage::helper('pricespercustomer')->__('pricetyp'),
            'required' => false,
            'name' => 'price_adjustment_type',
            'values' => array('1' => array(
                    'value' => 'fix',
                    'label' => 'Fix'
                ),
            )
        ));
        if ($actionname == 'edit') {
            $fieldset->addField('created_at', 'text', array(
                'label' => Mage::helper('pricespercustomer')->__('created'),
                'required' => false,
                'name' => 'created_at',
            ));
        }
        if ($actionname == 'edit') {
            $form->setValues($data);
        }
        return parent::_prepareForm();
    }

}