Form.php
3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?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();
}
}