customerattributes - Version 1.0.1

Version Notes

Fixed Minor Bugs

Download this release

Release Info

Developer Zestard
Extension customerattributes
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (25) hide show
  1. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute.php +28 -0
  2. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit.php +78 -0
  3. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Form.php +25 -0
  4. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Main/Main.php +203 -0
  5. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Main.php +66 -0
  6. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Options.php +195 -0
  7. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tabs.php +42 -0
  8. app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Grid.php +151 -0
  9. app/code/community/Zestard/Customerattribute/Helper/Customerattribute.php +172 -0
  10. app/code/community/Zestard/Customerattribute/Helper/Data.php +153 -0
  11. app/code/community/Zestard/Customerattribute/Model/Customerattribute.php +15 -0
  12. app/code/community/Zestard/Customerattribute/controllers/Adminhtml/CustomerattributeController.php +359 -0
  13. app/code/community/Zestard/Customerattribute/etc/adminhtml.xml +64 -0
  14. app/code/community/Zestard/Customerattribute/etc/config.xml +100 -0
  15. app/code/community/Zestard/Customerattribute/etc/system.xml +38 -0
  16. app/design/adminhtml/default/default/layout/zestard_customerattribute.xml +22 -0
  17. app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/edit/js.phtml +7 -0
  18. app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/js.phtml +330 -0
  19. app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/options.phtml +205 -0
  20. app/design/frontend/base/default/layout/zestard_customerattribute.xml +44 -0
  21. app/design/frontend/base/default/template/zestard/customerattribute/form/edit.phtml +233 -0
  22. app/design/frontend/base/default/template/zestard/customerattribute/form/register.phtml +295 -0
  23. app/etc/modules/Zestard_Customerattribute.xml +16 -0
  24. app/locale/en_US/Zestard_Customerattribute.csv +25 -0
  25. package.xml +18 -0
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Grid container file
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ *
9
+ */
10
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute extends Mage_Adminhtml_Block_Widget_Grid_Container
11
+ {
12
+ public function __construct()
13
+ {
14
+ /*both these variables tell magento the location of our Grid.php(grid block) file.
15
+ * $this->_blockGroup.'/' . $this->_controller . '_grid'
16
+ * i.e zestard_Customerattribute/adminhtml_customerattribute_grid
17
+ * $_blockGroup - is your module's name.
18
+ * $_controller - is the path to your grid block.
19
+ */
20
+ $this->_controller = 'adminhtml_customerattribute';
21
+ $this->_blockGroup = 'zestard_customerattribute';
22
+
23
+ $this->_headerText = Mage::helper('zestard_customerattribute')->__('Manage Attributes ');
24
+ $this->_addButtonLabel = Mage::helper('zestard_customerattribute')->__('Add New Attribute');
25
+
26
+ parent::__construct();
27
+ }
28
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute edit block
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ /**
14
+ * This variable is used in the form URL’s.
15
+ * This variable has the forms entity primary key, e.g the delete button URL would be
16
+ * module/controller/action/$this->_objectid/3
17
+ */
18
+ $this->_objectId = 'attribute_id';
19
+
20
+ /*
21
+ * There two variables are very important, these variables are used to find FORM tags php file.
22
+ * i.e the path of the form tags php file should be
23
+ * {$this->_blockGroup . ‘/’ . $this->_controller . ‘_’ . $this->_mode . ‘_form’}.
24
+ * The value of $this->_mode by default is ‘edit’. So the path of the php file which contains
25
+ * the form tag in our case would be ‘zestard_customerattribute/adminhtml_customerattribute_edit_form’.
26
+ */
27
+ $this->_blockGroup = 'zestard_customerattribute';
28
+ $this->_controller = 'adminhtml_customerattribute';
29
+
30
+ parent::__construct();
31
+
32
+ $this->_updateButton('save', 'label', Mage::helper('zestard_customerattribute')->__('Save Attribute'));
33
+ $this->_updateButton('save', 'onclick', 'saveAttribute()');
34
+
35
+ if (! Mage::registry('customerattribute_data')->getIsUserDefined()) {
36
+ $this->_removeButton('delete');
37
+ } else {
38
+ $this->_updateButton('delete', 'label', Mage::helper('zestard_customerattribute')->__('Delete Attribute'));
39
+ }
40
+
41
+ $this->_addButton(
42
+ 'saveandcontinue',
43
+ array(
44
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
45
+ 'onclick' => 'saveAndContinueEdit()',
46
+ 'class' => 'save',
47
+ ),
48
+ 100
49
+ );
50
+ }
51
+
52
+ /**
53
+ * This function return’s the Text to display as the form header.
54
+ */
55
+ public function getHeaderText()
56
+ {
57
+ if (Mage::registry('customerattribute_data')->getId()) {
58
+ $frontendLabel = Mage::registry('customerattribute_data')->getFrontendLabel();
59
+ if (is_array($frontendLabel)) {
60
+ $frontendLabel = $frontendLabel[0];
61
+ }
62
+ return Mage::helper('zestard_customerattribute')->__('Edit Customer Attribute "%s"', $this->escapeHtml($frontendLabel));
63
+ }
64
+ else {
65
+ return Mage::helper('zestard_customerattribute')->__('New Customer Attribute');
66
+ }
67
+ }
68
+
69
+ public function getValidationUrl()
70
+ {
71
+ return $this->getUrl('*/*/validate', array('_current'=>true));
72
+ }
73
+
74
+ public function getSaveUrl()
75
+ {
76
+ return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null));
77
+ }
78
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Form.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute add/edit form block
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(array(
14
+ 'id' => 'edit_form',
15
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
16
+ 'method' => 'post',
17
+ 'enctype' => 'multipart/form-data'
18
+ )
19
+ );
20
+
21
+ $form->setUseContainer(true); // form renderer to output the
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Main/Main.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute add/edit form main tab
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Main extends Mage_Adminhtml_Block_Widget_Form
10
+ {
11
+ protected $_attribute = null;
12
+
13
+ public function setAttributeObject($attribute)
14
+ {
15
+ $this->_attribute = $attribute;
16
+ return $this;
17
+ }
18
+
19
+ public function getAttributeObject()
20
+ {
21
+ if (null === $this->_attribute) {
22
+ return Mage::registry('customerattribute_data');
23
+ }
24
+ return $this->_attribute;
25
+ }
26
+
27
+ /**
28
+ * Preparing default form elements for editing attribute
29
+ *
30
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Main
31
+ */
32
+ protected function _prepareForm()
33
+ {
34
+ $attributeObject = $this->getAttributeObject();
35
+
36
+ $form = new Varien_Data_Form(array(
37
+ 'id' => 'edit_form',
38
+ 'action' => $this->getData('action'),
39
+ 'method' => 'post'
40
+ ));
41
+
42
+ $fieldset = $form->addFieldset('base_fieldset',
43
+ array('legend'=>Mage::helper('eav')->__('Attribute Properties'))
44
+ );
45
+ if ($attributeObject->getAttributeId()) {
46
+ $fieldset->addField('attribute_id', 'hidden', array(
47
+ 'name' => 'attribute_id',
48
+ ));
49
+ }
50
+
51
+ $this->_addElementTypes($fieldset);
52
+
53
+ $yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
54
+
55
+ $validateClass = sprintf('validate-code validate-length maximum-length-%d',
56
+ Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH);
57
+ $fieldset->addField('attribute_code', 'text', array(
58
+ 'name' => 'attribute_code',
59
+ 'label' => Mage::helper('eav')->__('Attribute Code'),
60
+ 'title' => Mage::helper('eav')->__('Attribute Code'),
61
+ 'note' => Mage::helper('eav')->__('For internal use. Must be unique with no spaces. Maximum length of attribute code must be less then %s symbols', Mage_Eav_Model_Entity_Attribute::ATTRIBUTE_CODE_MAX_LENGTH),
62
+ 'class' => $validateClass,
63
+ 'required' => true,
64
+ ));
65
+
66
+ $inputTypes = Mage::getModel('eav/adminhtml_system_config_source_inputtype')->toOptionArray();
67
+
68
+ $fieldset->addField('frontend_input', 'select', array(
69
+ 'name' => 'frontend_input',
70
+ 'label' => Mage::helper('eav')->__('Customer Input Type'),
71
+ 'title' => Mage::helper('eav')->__('Customer Input Type'),
72
+ 'value' => 'text',
73
+ 'values'=> $inputTypes
74
+ ));
75
+
76
+ $fieldset->addField('default_value_text', 'text', array(
77
+ 'name' => 'default_value_text',
78
+ 'label' => Mage::helper('eav')->__('Default Value'),
79
+ 'title' => Mage::helper('eav')->__('Default Value'),
80
+ 'value' => $attributeObject->getDefaultValue(),
81
+ ));
82
+
83
+ $fieldset->addField('default_value_yesno', 'select', array(
84
+ 'name' => 'default_value_yesno',
85
+ 'label' => Mage::helper('eav')->__('Default Value'),
86
+ 'title' => Mage::helper('eav')->__('Default Value'),
87
+ 'values' => $yesno,
88
+ 'value' => $attributeObject->getDefaultValue(),
89
+ ));
90
+
91
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
92
+ $fieldset->addField('default_value_date', 'date', array(
93
+ 'name' => 'default_value_date',
94
+ 'label' => Mage::helper('eav')->__('Default Value'),
95
+ 'title' => Mage::helper('eav')->__('Default Value'),
96
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
97
+ 'value' => $attributeObject->getDefaultValue(),
98
+ 'format' => $dateFormatIso
99
+ ));
100
+
101
+ $fieldset->addField('default_value_textarea', 'textarea', array(
102
+ 'name' => 'default_value_textarea',
103
+ 'label' => Mage::helper('eav')->__('Default Value'),
104
+ 'title' => Mage::helper('eav')->__('Default Value'),
105
+ 'value' => $attributeObject->getDefaultValue(),
106
+ ));
107
+
108
+ $fieldset->addField('is_visible', 'select', array(
109
+ 'name' => 'is_visible',
110
+ 'label' => Mage::helper('eav')->__('Visible on Frontend'),
111
+ 'title' => Mage::helper('eav')->__('Visible on Frontend)'),
112
+ 'note' => Mage::helper('eav')->__('Display attribute on the frontend'),
113
+ 'values' => $yesno,
114
+ 'value' => '1',
115
+ ));
116
+
117
+ $fieldset->addField('is_unique', 'select', array(
118
+ 'name' => 'is_unique',
119
+ 'label' => Mage::helper('eav')->__('Unique Value'),
120
+ 'title' => Mage::helper('eav')->__('Unique Value (not shared with other customers)'),
121
+ 'note' => Mage::helper('eav')->__('Not shared with other customers'),
122
+ 'values' => $yesno,
123
+ ));
124
+
125
+ $fieldset->addField('is_required', 'select', array(
126
+ 'name' => 'is_required',
127
+ 'label' => Mage::helper('eav')->__('Values Required'),
128
+ 'title' => Mage::helper('eav')->__('Values Required'),
129
+ 'values' => $yesno,
130
+ ));
131
+
132
+
133
+ $fieldset->addField('frontend_class', 'select', array(
134
+ 'name' => 'frontend_class',
135
+ 'label' => Mage::helper('eav')->__('Input Validation'),
136
+ 'title' => Mage::helper('eav')->__('Input Validation'),
137
+ 'values'=> Mage::helper('zestard_customerattribute')->getFrontendClasses($attributeObject->getEntityType()->getEntityTypeCode())
138
+ ));
139
+
140
+ if ($attributeObject->getId()) {
141
+ $form->getElement('attribute_code')->setDisabled(1);
142
+ $form->getElement('frontend_input')->setDisabled(1);
143
+ if (!$attributeObject->getIsUserDefined()) {
144
+ $form->getElement('is_unique')->setDisabled(1);
145
+ }
146
+ }
147
+
148
+ $this->setForm($form);
149
+
150
+ return parent::_prepareForm();
151
+ }
152
+
153
+ /**
154
+ * Initialize form fileds values
155
+ *
156
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Main
157
+ */
158
+ protected function _initFormValues()
159
+ {
160
+ $this->getForm()
161
+ ->addValues($this->getAttributeObject()->getData());
162
+ return parent::_initFormValues();
163
+ }
164
+
165
+ /**
166
+ * This method is called before rendering HTML
167
+ *
168
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Main
169
+ */
170
+ protected function _beforeToHtml()
171
+ {
172
+ parent::_beforeToHtml();
173
+ $attributeObject = $this->getAttributeObject();
174
+ if ($attributeObject->getId()) {
175
+ $form = $this->getForm();
176
+ $disableAttributeFields = Mage::helper('zestard_customerattribute')
177
+ ->getAttributeLockedFields($attributeObject->getEntityType()->getEntityTypeCode());
178
+ if (isset($disableAttributeFields[$attributeObject->getAttributeCode()])) {
179
+ foreach ($disableAttributeFields[$attributeObject->getAttributeCode()] as $field) {
180
+ if ($elm = $form->getElement($field)) {
181
+ $elm->setDisabled(1);
182
+ $elm->setReadonly(1);
183
+ }
184
+ }
185
+ }
186
+ }
187
+ return $this;
188
+ }
189
+
190
+ /**
191
+ * Processing block html after rendering
192
+ * Adding js block to the end of this block
193
+ *
194
+ * @param string $html
195
+ * @return string
196
+ */
197
+ protected function _afterToHtml($html)
198
+ {
199
+ $jsScripts = $this->getLayout()
200
+ ->createBlock('eav/adminhtml_attribute_edit_js')->toHtml();
201
+ return $html.$jsScripts;
202
+ }
203
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Main.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute add/edit form main tab
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+
10
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tab_Main extends Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Main
11
+ {
12
+
13
+ /**
14
+ * Preparing default form elements for editing attribute
15
+ *
16
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tab_Main
17
+ */
18
+ protected function _prepareForm()
19
+ {
20
+ parent::_prepareForm();
21
+ $attributeObject = $this->getAttributeObject();
22
+ /* @var $form Varien_Data_Form */
23
+ $form = $this->getForm();
24
+ /* @var $fieldset Varien_Data_Form_Element_Fieldset */
25
+ $fieldset = $form->getElement('base_fieldset');
26
+
27
+ // frontend properties fieldset
28
+ $fieldset = $form->addFieldset('front_fieldset', array('legend'=>Mage::helper('zestard_customerattribute')->__('Frontend Properties')));
29
+ $fieldset->addField('sort_order', 'text', array(
30
+ 'name' => 'sort_order',
31
+ 'label' => Mage::helper('zestard_customerattribute')->__('Sort Order'),
32
+ 'title' => Mage::helper('zestard_customerattribute')->__('Sort Order'),
33
+ 'note' => Mage::helper('zestard_customerattribute')->__('The order to display attribute on the frontend'),
34
+ 'class' => 'validate-digits',
35
+ ));
36
+
37
+ $usedInForms = $attributeObject->getUsedInForms();
38
+
39
+ $fieldset->addField('customer_account_create', 'checkbox', array(
40
+ 'name' => 'customer_account_create',
41
+ 'checked' => in_array('customer_account_create', $usedInForms) ? true : false,
42
+ 'value' => '1',
43
+ 'label' => Mage::helper('zestard_customerattribute')->__('Show on the Customer Account Create Page'),
44
+ 'title' => Mage::helper('zestard_customerattribute')->__('Show on the Customer Account Create Page'),
45
+ ));
46
+
47
+ $fieldset->addField('customer_account_edit', 'checkbox', array(
48
+ 'name' => 'customer_account_edit',
49
+ 'checked' => in_array('customer_account_edit', $usedInForms) ? true : false,
50
+ 'value' => '1',
51
+ 'label' => Mage::helper('zestard_customerattribute')->__('Show on the Customer Account Edit Page'),
52
+ 'title' => Mage::helper('zestard_customerattribute')->__('Show on the Customer Account Edit Page'),
53
+ ));
54
+
55
+ $fieldset->addField('adminhtml_customer', 'checkbox', array(
56
+ 'name' => 'adminhtml_customer',
57
+ 'checked' => in_array('adminhtml_customer', $usedInForms) ? true : false,
58
+ 'value' => '1',
59
+ 'label' => Mage::helper('zestard_customerattribute')->__('Show on the Admin Manage Customers'),
60
+ 'title' => Mage::helper('zestard_customerattribute')->__('Show on the Admin Manage Customers'),
61
+ 'note' => Mage::helper('zestard_customerattribute')->__('Show on the Admin Manage Customers Add and Edit customer Page'),
62
+ ));
63
+
64
+ return $this;
65
+ }
66
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Options.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product attribute add/edit form options tab
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setTemplate('zestard_customerattribute/attribute/options.phtml');
15
+ }
16
+
17
+ /**
18
+ * Preparing layout, adding buttons
19
+ *
20
+ * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
21
+ */
22
+ protected function _prepareLayout()
23
+ {
24
+ $this->setChild('delete_button',
25
+ $this->getLayout()->createBlock('adminhtml/widget_button')
26
+ ->setData(array(
27
+ 'label' => Mage::helper('eav')->__('Delete'),
28
+ 'class' => 'delete delete-option'
29
+ )));
30
+
31
+ $this->setChild('add_button',
32
+ $this->getLayout()->createBlock('adminhtml/widget_button')
33
+ ->setData(array(
34
+ 'label' => Mage::helper('eav')->__('Add Option'),
35
+ 'class' => 'add',
36
+ 'id' => 'add_new_option_button'
37
+ )));
38
+ return parent::_prepareLayout();
39
+ }
40
+
41
+ /**
42
+ * Retrieve HTML of delete button
43
+ *
44
+ * @return string
45
+ */
46
+ public function getDeleteButtonHtml()
47
+ {
48
+ return $this->getChildHtml('delete_button');
49
+ }
50
+
51
+ /**
52
+ * Retrieve HTML of add button
53
+ *
54
+ * @return string
55
+ */
56
+ public function getAddNewButtonHtml()
57
+ {
58
+ return $this->getChildHtml('add_button');
59
+ }
60
+
61
+ /**
62
+ * Retrieve stores collection with default store
63
+ *
64
+ * @return Mage_Core_Model_Mysql4_Store_Collection
65
+ */
66
+ public function getStores()
67
+ {
68
+ $stores = $this->getData('stores');
69
+ if (is_null($stores)) {
70
+ $stores = Mage::getModel('core/store')
71
+ ->getResourceCollection()
72
+ ->setLoadDefault(true)
73
+ ->load();
74
+ $this->setData('stores', $stores);
75
+ }
76
+ return $stores;
77
+ }
78
+
79
+ /**
80
+ * Retrieve attribute option values if attribute input type select or multiselect
81
+ *
82
+ * @return array
83
+ */
84
+ public function getOptionValues()
85
+ {
86
+ $attributeType = $this->getAttributeObject()->getFrontendInput();
87
+ $defaultValues = $this->getAttributeObject()->getDefaultValue();
88
+ if ($attributeType == 'select' || $attributeType == 'multiselect') {
89
+ $defaultValues = explode(',', $defaultValues);
90
+ } else {
91
+ $defaultValues = array();
92
+ }
93
+
94
+ switch ($attributeType) {
95
+ case 'select':
96
+ $inputType = 'radio';
97
+ break;
98
+ case 'multiselect':
99
+ $inputType = 'checkbox';
100
+ break;
101
+ default:
102
+ $inputType = '';
103
+ break;
104
+ }
105
+
106
+ $values = $this->getData('option_values');
107
+ if (is_null($values)) {
108
+ $values = array();
109
+ $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
110
+ ->setAttributeFilter($this->getAttributeObject()->getId())
111
+ ->setPositionOrder('desc', true)
112
+ ->load();
113
+
114
+ $helper = Mage::helper('core');
115
+ foreach ($optionCollection as $option) {
116
+ $value = array();
117
+ if (in_array($option->getId(), $defaultValues)) {
118
+ $value['checked'] = 'checked="checked"';
119
+ } else {
120
+ $value['checked'] = '';
121
+ }
122
+
123
+ $value['intype'] = $inputType;
124
+ $value['id'] = $option->getId();
125
+ $value['sort_order'] = $option->getSortOrder();
126
+ foreach ($this->getStores() as $store) {
127
+ $storeValues = $this->getStoreOptionValues($store->getId());
128
+ $value['store' . $store->getId()] = isset($storeValues[$option->getId()])
129
+ ? $helper->escapeHtml($storeValues[$option->getId()]) : '';
130
+ }
131
+ $values[] = new Varien_Object($value);
132
+ }
133
+ $this->setData('option_values', $values);
134
+ }
135
+
136
+ return $values;
137
+ }
138
+
139
+ /**
140
+ * Retrieve frontend labels of attribute for each store
141
+ *
142
+ * @return array
143
+ */
144
+ public function getLabelValues()
145
+ {
146
+ $values = array();
147
+ $values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
148
+ // it can be array and cause bug
149
+ $frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
150
+ if (is_array($frontendLabel)) {
151
+ $frontendLabel = array_shift($frontendLabel);
152
+ }
153
+ $storeLabels = $this->getAttributeObject()->getStoreLabels();
154
+ foreach ($this->getStores() as $store) {
155
+ if ($store->getId() != 0) {
156
+ $values[$store->getId()] = isset($storeLabels[$store->getId()]) ? $storeLabels[$store->getId()] : '';
157
+ }
158
+ }
159
+ return $values;
160
+ }
161
+
162
+ /**
163
+ * Retrieve attribute option values for given store id
164
+ *
165
+ * @param integer $storeId
166
+ * @return array
167
+ */
168
+ public function getStoreOptionValues($storeId)
169
+ {
170
+ $values = $this->getData('store_option_values_'.$storeId);
171
+ if (is_null($values)) {
172
+ $values = array();
173
+ $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
174
+ ->setAttributeFilter($this->getAttributeObject()->getId())
175
+ ->setStoreFilter($storeId, false)
176
+ ->load();
177
+ foreach ($valuesCollection as $item) {
178
+ $values[$item->getId()] = $item->getValue();
179
+ }
180
+ $this->setData('store_option_values_'.$storeId, $values);
181
+ }
182
+ return $values;
183
+ }
184
+
185
+ /**
186
+ * Retrieve attribute object from registry
187
+ *
188
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract
189
+ */
190
+ public function getAttributeObject()
191
+ {
192
+ return Mage::registry('customerattribute_data');
193
+ }
194
+
195
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tabs.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute edit page tabs
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
10
+ {
11
+
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ $this->setId('customerattribute_tabs');
16
+ $this->setDestElementId('edit_form'); // this should be same as the form id define above
17
+ $this->setTitle(Mage::helper('zestard_customerattribute')->__('Attribute Information'));
18
+ }
19
+
20
+ /**
21
+ * Specified customer attribute edit page tabs
22
+ */
23
+ protected function _beforeToHtml()
24
+ {
25
+ $this->addTab('main', array(
26
+ 'label' => Mage::helper('zestard_customerattribute')->__('Properties'),
27
+ 'title' => Mage::helper('zestard_customerattribute')->__('Properties'),
28
+ 'content' => $this->getLayout()->createBlock('zestard_customerattribute/adminhtml_customerattribute_edit_tab_main')->toHtml(),
29
+ 'active' => true
30
+ ));
31
+
32
+ $model = Mage::registry('customerattribute_data');
33
+
34
+ $this->addTab('labels', array(
35
+ 'label' => Mage::helper('zestard_customerattribute')->__('Manage Label / Options'),
36
+ 'title' => Mage::helper('zestard_customerattribute')->__('Manage Label / Options'),
37
+ 'content' => $this->getLayout()->createBlock('zestard_customerattribute/adminhtml_customerattribute_edit_tab_options')->toHtml(),
38
+ ));
39
+
40
+ return parent::_beforeToHtml();
41
+ }
42
+ }
app/code/community/Zestard/Customerattribute/Block/Adminhtml/Customerattribute/Grid.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute grid block
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ *
9
+ */
10
+ class Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Grid extends Mage_Adminhtml_Block_Widget_Grid
11
+ {
12
+ public function __construct()
13
+ {
14
+ parent::__construct();
15
+ /** This set’s the ID of our grid i.e the html id attribute of the <div>.
16
+ * If you’re using multiple grids in a page then id needs to be unique.
17
+ */
18
+ $this->setId('CustomerattributeGrid');
19
+
20
+ /**
21
+ * This tells which sorting column to use in our grid. Which column
22
+ * should be used for default sorting
23
+ */
24
+ $this->setDefaultSort('attribute_code');
25
+
26
+ /**
27
+ * The default sorting order, ascending or descending
28
+ */
29
+ $this->setDefaultDir('ASC');
30
+
31
+ /**
32
+ * this basically sets your grid operations in session. Example, if we
33
+ * were on page2 of grid or we had searched something on grid when
34
+ * refreshing or coming back to the page, the grid operations will
35
+ * still be there. It won’t revert back to its default form.
36
+ */
37
+ // $this->setSaveParametersInSession(true);
38
+ }
39
+
40
+ /**
41
+ * Prepare customer attributes grid collection object
42
+ *
43
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Grid
44
+ */
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getResourceModel('customer/attribute_collection');
48
+ $this->setCollection($collection);
49
+ return parent::_prepareCollection();
50
+ }
51
+
52
+ /**
53
+ * Prepare default grid column
54
+ *
55
+ * @return Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Grid
56
+ */
57
+ protected function _prepareColumns()
58
+ {
59
+ /**
60
+ * ‘id’ an unique id for column
61
+ * ‘header’ is the name of the column
62
+ * ‘index’ is the field from our collection. This ‘id’ column needs to be
63
+ * present in our collection’s models.
64
+ */
65
+
66
+ $yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toArray();
67
+
68
+ $this->addColumn('attribute_code', array(
69
+ 'header'=>Mage::helper('zestard_customerattribute')->__('Attribute Code'),
70
+ 'sortable'=>true,
71
+ 'index'=>'attribute_code'
72
+ ));
73
+
74
+ $this->addColumn('frontend_label', array(
75
+ 'header'=>Mage::helper('zestard_customerattribute')->__('Attribute Label'),
76
+ 'sortable'=>true,
77
+ 'index'=>'frontend_label'
78
+ ));
79
+
80
+ $this->addColumn('is_required', array(
81
+ 'header'=>Mage::helper('zestard_customerattribute')->__('Required'),
82
+ 'sortable'=>true,
83
+ 'index'=>'is_required',
84
+ 'type' => 'options',
85
+ 'options' => $yesno,
86
+ 'align' => 'center',
87
+ ));
88
+
89
+ $this->addColumn('is_user_defined', array(
90
+ 'header'=>Mage::helper('eav')->__('System'),
91
+ 'sortable'=>true,
92
+ 'index'=>'is_user_defined',
93
+ 'type' => 'options',
94
+ 'align' => 'center',
95
+ 'options' => array(
96
+ '0' => Mage::helper('eav')->__('Yes'), // intended reverted use
97
+ '1' => Mage::helper('eav')->__('No'), // intended reverted use
98
+ ),
99
+ ));
100
+
101
+ $this->addColumn('is_visible', array(
102
+ 'header' => Mage::helper('zestard_customerattribute')->__('Visible on Frontend'),
103
+ 'index' => 'is_visible',
104
+ 'width'=>'100px',
105
+ 'type' => 'options',
106
+ 'options' => $yesno,
107
+ ));
108
+
109
+ $this->addColumn('sort_order', array(
110
+ 'header'=>Mage::helper('zestard_customerattribute')->__('Sort Order'),
111
+ 'sortable'=>true,
112
+ 'width'=>'100px',
113
+ 'index'=>'sort_order'
114
+ ));
115
+
116
+ /**
117
+ * Adding Different Options To Grid Rows
118
+ */
119
+ $this->addColumn('action',
120
+ array(
121
+ 'header' => Mage::helper('zestard_customerattribute')->__('Action'),
122
+ 'type' => 'action',
123
+ 'getter' => 'getId',
124
+ 'actions' => array(
125
+ array(
126
+ 'caption' => Mage::helper('zestard_customerattribute')->__('Edit'),
127
+ 'url' => array('base'=> '*/*/edit'),
128
+ 'field' => 'attribute_id'
129
+ )
130
+ ),
131
+ 'filter' => false,
132
+ 'sortable' => false,
133
+ 'index' => 'stores',
134
+ 'is_system' => true,
135
+ ));
136
+
137
+ return parent::_prepareColumns();
138
+ }
139
+
140
+ /**
141
+ * Row click url.
142
+ * when user click on any rows of the grid it goes to a specific URL.
143
+ * URL is of the editAction of your controller and it passed the row’s id as a parameter.
144
+ * @param object $row Data row object
145
+ * @return string
146
+ */
147
+ public function getRowUrl($row)
148
+ {
149
+ return $this->getUrl('*/*/edit', array('attribute_id' => $row->getId()));
150
+ }
151
+ }
app/code/community/Zestard/Customerattribute/Helper/Customerattribute.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute helper
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Helper_Customerattribute extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * Return information array of product attribute input types
13
+ * Only a small number of settings returned, so we won't break anything in current dataflow
14
+ * As soon as development process goes on we need to add there all possible settings
15
+ *
16
+ * @param string $inputType
17
+ * @return array
18
+ */
19
+ public function getAttributeInputTypes($inputType = null)
20
+ {
21
+ /**
22
+ * @todo specify there all relations for properties depending on input type
23
+ */
24
+ $inputTypes = array(
25
+ 'multiselect' => array(
26
+ 'backend_model' => 'eav/entity_attribute_backend_array',
27
+ 'source_model' => 'eav/entity_attribute_source_table'
28
+ ),
29
+ 'boolean' => array(
30
+ 'source_model' => 'eav/entity_attribute_source_boolean'
31
+ )
32
+ );
33
+
34
+ if (is_null($inputType)) {
35
+ return $inputTypes;
36
+ } else if (isset($inputTypes[$inputType])) {
37
+ return $inputTypes[$inputType];
38
+ }
39
+ return array();
40
+ }
41
+
42
+ /**
43
+ * Return default attribute backend model by input type
44
+ *
45
+ * @param string $inputType
46
+ * @return string|null
47
+ */
48
+ public function getAttributeBackendModelByInputType($inputType)
49
+ {
50
+ $inputTypes = $this->getAttributeInputTypes();
51
+ if (!empty($inputTypes[$inputType]['backend_model'])) {
52
+ return $inputTypes[$inputType]['backend_model'];
53
+ }
54
+ return null;
55
+ }
56
+
57
+ /**
58
+ * Return default attribute source model by input type
59
+ *
60
+ * @param string $inputType
61
+ * @return string|null
62
+ */
63
+ public function getAttributeSourceModelByInputType($inputType)
64
+ {
65
+ $inputTypes = $this->getAttributeInputTypes();
66
+ if (!empty($inputTypes[$inputType]['source_model'])) {
67
+ return $inputTypes[$inputType]['source_model'];
68
+ }
69
+ return null;
70
+ }
71
+
72
+ /**
73
+ * Return user defined attributes attributs
74
+ *
75
+ * @return $collection
76
+ */
77
+ public function getUserDefinedAttribures()
78
+ {
79
+ $collection = Mage::getModel('zestard_customerattribute/customerattribute')
80
+ ->setEntityTypeId(Mage::getModel('eav/entity')->setType(Mage::getModel('eav/config')->getEntityType('customer'))->getTypeId())->getCollection()
81
+ ->addVisibleFilter()
82
+ ->addFilter('is_user_defined', 1)
83
+ ->addOrder('sort_order', 'ASC');
84
+
85
+ return $collection;
86
+ }
87
+
88
+ public function isVisible($code)
89
+ {
90
+ $collection = Mage::getModel('zestard_customerattribute/customerattribute')->getCollection()
91
+ ->addFieldToFilter('attribute_code',$code)
92
+ ->addFieldToFilter('is_visible',1);
93
+
94
+ $isVisible = $collection->getFirstItem()->getIsVisible();
95
+
96
+ if($isVisible == 1)
97
+ return 1;
98
+ else
99
+ return 0;
100
+ }
101
+
102
+ /**
103
+ * check is attribute is for customer account create
104
+ *
105
+ * @return boolean
106
+ */
107
+ public function isAttribureForCustomerAccountCreate($attributeCode)
108
+ {
109
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
110
+ $usedInForms = $attribute->getUsedInForms();
111
+ if (in_array('customer_account_create', $usedInForms)) {
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+
117
+ /**
118
+ * check is attribute is for customer account edit
119
+ *@param varchar $attributeCode attribute code
120
+ * @return boolean
121
+ */
122
+ public function isAttribureForCustomerAccountEdit($attributeCode)
123
+ {
124
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
125
+ $usedInForms = $attribute->getUsedInForms();
126
+ if (in_array('customer_account_edit', $usedInForms)) {
127
+ return true;
128
+ }
129
+ return false;
130
+ }
131
+
132
+ /**
133
+ * Get store id
134
+ *
135
+ * @return int Store id
136
+ */
137
+ public function getStoreId()
138
+ {
139
+ return Mage::app()->getStore()->getId();;
140
+ }
141
+
142
+ /**
143
+ * Get default value for date attribute
144
+ *
145
+ * @param int $timestamp timestamp
146
+ * @return date formated date
147
+ */
148
+ public function getDefaultValueForDate($timestamp)
149
+ {
150
+ if(empty($timestamp)) {
151
+ return;
152
+ }
153
+
154
+ return date('m-d-Y', $timestamp);
155
+ }
156
+
157
+ /**
158
+ * Get formated date for customer
159
+ *
160
+ * @param int $date date
161
+ * @return date formated date
162
+ */
163
+ public function getFormattedDate($date)
164
+ {
165
+ if(empty($date)) {
166
+ return;
167
+ }
168
+
169
+ return date('m-d-Y', strtotime($date));
170
+ }
171
+
172
+ }
app/code/community/Zestard/Customerattribute/Helper/Data.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute data helper
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+ /**
12
+ * XML path to input types validator data in config
13
+ */
14
+ const XML_PATH_VALIDATOR_DATA_INPUT_TYPES = 'general/validator_data/input_types';
15
+
16
+ protected $_attributesLockedFields = array();
17
+
18
+ protected $_entityTypeFrontendClasses = array();
19
+
20
+ /**
21
+ * Return default frontend classes value labal array
22
+ *
23
+ * @return array
24
+ */
25
+ protected function _getDefaultFrontendClasses()
26
+ {
27
+ return array(
28
+ array(
29
+ 'value' => '',
30
+ 'label' => Mage::helper('eav')->__('None')
31
+ ),
32
+ array(
33
+ 'value' => 'validate-number',
34
+ 'label' => Mage::helper('eav')->__('Decimal Number')
35
+ ),
36
+ array(
37
+ 'value' => 'validate-digits',
38
+ 'label' => Mage::helper('eav')->__('Integer Number')
39
+ ),
40
+ array(
41
+ 'value' => 'validate-email',
42
+ 'label' => Mage::helper('eav')->__('Email')
43
+ ),
44
+ array(
45
+ 'value' => 'validate-url',
46
+ 'label' => Mage::helper('eav')->__('URL')
47
+ ),
48
+ array(
49
+ 'value' => 'validate-alpha',
50
+ 'label' => Mage::helper('eav')->__('Letters')
51
+ ),
52
+ array(
53
+ 'value' => 'validate-alphanum',
54
+ 'label' => Mage::helper('eav')->__('Letters (a-z, A-Z) or Numbers (0-9)')
55
+ )
56
+ );
57
+ }
58
+
59
+ /**
60
+ * Return merged default and entity type frontend classes value label array
61
+ *
62
+ * @param string $entityTypeCode
63
+ * @return array
64
+ */
65
+ public function getFrontendClasses($entityTypeCode)
66
+ {
67
+ $_defaultClasses = $this->_getDefaultFrontendClasses();
68
+ if (isset($this->_entityTypeFrontendClasses[$entityTypeCode])) {
69
+ return array_merge(
70
+ $_defaultClasses,
71
+ $this->_entityTypeFrontendClasses[$entityTypeCode]
72
+ );
73
+ }
74
+ $_entityTypeClasses = Mage::app()->getConfig()
75
+ ->getNode('global/eav_frontendclasses/' . $entityTypeCode);
76
+ if ($_entityTypeClasses) {
77
+ foreach ($_entityTypeClasses->children() as $item) {
78
+ $this->_entityTypeFrontendClasses[$entityTypeCode][] = array(
79
+ 'value' => (string)$item->value,
80
+ 'label' => (string)$item->label
81
+ );
82
+ }
83
+ return array_merge(
84
+ $_defaultClasses,
85
+ $this->_entityTypeFrontendClasses[$entityTypeCode]
86
+ );
87
+ }
88
+ return $_defaultClasses;
89
+ }
90
+
91
+ /**
92
+ * Retrieve attributes locked fields to edit
93
+ *
94
+ * @param string $entityTypeCode
95
+ * @return array
96
+ */
97
+ public function getAttributeLockedFields($entityTypeCode)
98
+ {
99
+ if (!$entityTypeCode) {
100
+ return array();
101
+ }
102
+ if (isset($this->_attributesLockedFields[$entityTypeCode])) {
103
+ return $this->_attributesLockedFields[$entityTypeCode];
104
+ }
105
+ $_data = Mage::app()->getConfig()->getNode('global/eav_attributes/' . $entityTypeCode);
106
+ if ($_data) {
107
+ foreach ($_data->children() as $attribute) {
108
+ $this->_attributesLockedFields[$entityTypeCode][(string)$attribute->code] =
109
+ array_keys($attribute->locked_fields->asArray());
110
+ }
111
+ return $this->_attributesLockedFields[$entityTypeCode];
112
+ }
113
+ return array();
114
+ }
115
+
116
+ /**
117
+ * Get input types validator data
118
+ *
119
+ * @return array
120
+ */
121
+ public function getInputTypesValidatorData()
122
+ {
123
+ return Mage::getStoreConfig(self::XML_PATH_VALIDATOR_DATA_INPUT_TYPES);
124
+ }
125
+
126
+ /**
127
+ * Retrieve attribute hidden fields
128
+ *
129
+ * @return array
130
+ */
131
+ public function getAttributeHiddenFields()
132
+ {
133
+ if (Mage::registry('attribute_type_hidden_fields')) {
134
+ return Mage::registry('attribute_type_hidden_fields');
135
+ } else {
136
+ return array();
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Retrieve attribute disabled types
142
+ *
143
+ * @return array
144
+ */
145
+ public function getAttributeDisabledTypes()
146
+ {
147
+ if (Mage::registry('attribute_type_disabled_types')) {
148
+ return Mage::registry('attribute_type_disabled_types');
149
+ } else {
150
+ return array();
151
+ }
152
+ }
153
+ }
app/code/community/Zestard/Customerattribute/Model/Customerattribute.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute Model
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Model_Customerattribute extends Mage_Customer_Model_Attribute
10
+ {
11
+ protected function _construct(){
12
+ parent::_construct();
13
+ }
14
+ }
15
+ ?>
app/code/community/Zestard/Customerattribute/controllers/Adminhtml/CustomerattributeController.php ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute controller file
4
+ *
5
+ * @category Zestard
6
+ * @package Zestard_Customerattribute
7
+ * @author Zestard Magento Team
8
+ */
9
+ class Zestard_Customerattribute_Adminhtml_CustomerattributeController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ protected $_entityTypeId;
12
+
13
+ public function preDispatch()
14
+ {
15
+ parent::preDispatch();
16
+ $this->_entityTypeId = Mage::getModel('eav/entity')->setType(Mage::getModel('eav/config')->getEntityType('customer'))->getTypeId();
17
+ }
18
+
19
+ /**
20
+ * Init actions
21
+ *
22
+ */
23
+ protected function _initAction()
24
+ {
25
+ // load layout, set active menu and breadcrumbs
26
+ $this->_title($this->__('Customer'))
27
+ ->_title($this->__('Attributes'))
28
+ ->_title($this->__('Manage Attributes'));
29
+
30
+ if($this->getRequest()->getParam('popup')) {
31
+ $this->loadLayout('popup');
32
+ } else {
33
+ $this->loadLayout()
34
+ ->_setActiveMenu('customer/customer_attribure')
35
+ ->_addBreadcrumb(Mage::helper('zestard_customerattribute')->__('Customer'), Mage::helper('zestard_customerattribute')->__('Customer'))
36
+ ->_addBreadcrumb(
37
+ Mage::helper('zestard_customerattribute')->__('Manage Customer Attributes'),
38
+ Mage::helper('zestard_customerattribute')->__('Manage Customer Attributes'))
39
+ ;
40
+ }
41
+ return $this;
42
+ }
43
+ /**
44
+ * Index action method
45
+ */
46
+ public function indexAction()
47
+ {
48
+
49
+ $this->_initAction()
50
+ ->renderLayout();
51
+ }
52
+
53
+ /**
54
+ * Code to display the form
55
+ *
56
+ * The main form container gets added to the content and the tabs block gets added to left.
57
+ */
58
+ public function newAction()
59
+ {
60
+ // the same form is used to create and edit
61
+ $this->_forward('edit');
62
+ }
63
+
64
+ /**
65
+ * Edit Customer Attribute
66
+ */
67
+ public function editAction()
68
+ {
69
+ $id = $this->getRequest()->getParam('attribute_id');
70
+ $model = Mage::getModel('zestard_customerattribute/customerattribute')
71
+ ->setEntityTypeId($this->_entityTypeId);
72
+
73
+ // 2. Initial checking
74
+ if ($id) {
75
+ $model->load($id);
76
+ if (! $model->getId()) {
77
+ Mage::getSingleton('adminhtml/session')->addError(
78
+ Mage::helper('zestard_customerattribute')->__('This employee no longer exists.'));
79
+ $this->_redirect('*/*/');
80
+ return;
81
+ }
82
+ }
83
+
84
+ // entity type check
85
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
86
+ Mage::getSingleton('adminhtml/session')->addError(
87
+ Mage::helper('catalog')->__('This attribute cannot be edited.'));
88
+ $this->_redirect('*/*/');
89
+ return;
90
+ }
91
+
92
+ // Sets the window title
93
+ $this->_title($id ? $model->getFrontendLabel() : $this->__('New Attribute'));
94
+
95
+ // 3. Set entered data if was error when we do save
96
+ $data = Mage::getSingleton('adminhtml/session')->getCustomerattributeData(true);
97
+ if (! empty($data)) {
98
+ $model->setData($data);
99
+ }
100
+
101
+ // 4. Register model to use later in blocks
102
+ Mage::register('customerattribute_data', $model);
103
+
104
+ // 5. Build edit form
105
+ $this->_initAction()
106
+ ->_addBreadcrumb(
107
+ $id ? Mage::helper('zestard_customerattribute')->__('Edit Customer Attribute')
108
+ : Mage::helper('zestard_customerattribute')->__('New Customer Attribute'),
109
+ $id ? Mage::helper('zestard_customerattribute')->__('Edit Customer Attribute')
110
+ : Mage::helper('zestard_customerattribute')->__('New Customer Attribute'));
111
+
112
+ $this->_addContent($this->getLayout()->createBlock('zestard_customerattribute/adminhtml_customerattribute_edit'))
113
+ ->_addLeft($this->getLayout()->createBlock('zestard_customerattribute/adminhtml_customerattribute_edit_tabs'));
114
+
115
+ $this->getLayout()->getBlock('zestard_customerattribute_edit_js')
116
+ ->setIsPopup((bool)$this->getRequest()->getParam('popup'));
117
+
118
+ $this->renderLayout();
119
+ }
120
+
121
+ public function validateAction()
122
+ {
123
+ $response = new Varien_Object();
124
+ $response->setError(false);
125
+
126
+ $attributeCode = $this->getRequest()->getParam('attribute_code');
127
+ $attributeId = $this->getRequest()->getParam('attribute_id');
128
+ $attribute = Mage::getModel('zestard_customerattribute/customerattribute')
129
+ ->loadByCode($this->_entityTypeId, $attributeCode);
130
+
131
+ if ($attribute->getId() && !$attributeId) {
132
+ Mage::getSingleton('adminhtml/session')->addError(
133
+ Mage::helper('zestard_customerattribute')->__('Attribute with the same code already exists'));
134
+ $this->_initLayoutMessages('adminhtml/session');
135
+ $response->setError(true);
136
+ $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
137
+ }
138
+
139
+ $this->getResponse()->setBody($response->toJson());
140
+ }
141
+
142
+ /**
143
+ * Filter post data
144
+ *
145
+ * @param array $data
146
+ * @return array
147
+ */
148
+ protected function _filterPostData($data)
149
+ {
150
+ if ($data) {
151
+ /** @var $helperCustomerattribute Zestard_Customerattribute_Helper_Data */
152
+ $helperCustomerattribute = Mage::helper('zestard_customerattribute');
153
+ //labels
154
+ foreach ($data['frontend_label'] as & $value) {
155
+ if ($value) {
156
+ $value = $helperCustomerattribute->stripTags($value);
157
+ }
158
+ }
159
+ }
160
+ return $data;
161
+ }
162
+
163
+ /**
164
+ *
165
+ * Save customer attributes
166
+ */
167
+ public function saveAction()
168
+ {
169
+ $data = $this->getRequest()->getPost();
170
+ if ($data) {
171
+ /** @var $session Mage_Admin_Model_Session */
172
+ $session = Mage::getSingleton('adminhtml/session');
173
+
174
+ $redirectBack = $this->getRequest()->getParam('back', false);
175
+ /* @var $model Zestard_Customerattribute_Model_Customerattribute */
176
+ $model = Mage::getModel('zestard_customerattribute/customerattribute');
177
+ /* @var $helper Mage_Catalog_Helper_Product */
178
+ $helper = Mage::helper('zestard_customerattribute/customerattribute');
179
+
180
+ $id = $this->getRequest()->getParam('attribute_id');
181
+
182
+ //validate attribute_code
183
+ if (isset($data['attribute_code'])) {
184
+ $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
185
+ if (!$validatorAttrCode->isValid($data['attribute_code'])) {
186
+ $session->addError(
187
+ Mage::helper('zestard_customerattribute')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.')
188
+ );
189
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
190
+ return;
191
+ }
192
+ }
193
+
194
+
195
+ //validate frontend_input
196
+ if (isset($data['frontend_input'])) {
197
+ /** @var $validatorInputType Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator */
198
+ $validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator');
199
+ if (!$validatorInputType->isValid($data['frontend_input'])) {
200
+ foreach ($validatorInputType->getMessages() as $message) {
201
+ $session->addError($message);
202
+ }
203
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
204
+ return;
205
+ }
206
+ }
207
+
208
+ if ($id) {
209
+ $model->load($id);
210
+
211
+ if (!$model->getId()) {
212
+ $session->addError(
213
+ Mage::helper('zestard_customerattribute')->__('This Attribute no longer exists'));
214
+ $this->_redirect('*/*/');
215
+ return;
216
+ }
217
+
218
+ // entity type check
219
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
220
+ $session->addError(
221
+ Mage::helper('zestard_customerattribute')->__('This attribute cannot be updated.'));
222
+ $session->setCustomerattributeData($data);
223
+ $this->_redirect('*/*/');
224
+ return;
225
+ }
226
+
227
+ $data['attribute_code'] = $model->getAttributeCode();
228
+ $data['is_user_defined'] = $model->getIsUserDefined();
229
+ $data['frontend_input'] = $model->getFrontendInput();
230
+ } else {
231
+ /**
232
+ * @todo add to helper and specify all relations for properties
233
+ */
234
+ $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
235
+ $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
236
+ }
237
+
238
+ $usedInForms = array();
239
+
240
+
241
+ if (isset($data['customer_account_create'])&& $data['customer_account_create'] == 1) {
242
+ $usedInForms[] = 'customer_account_create';
243
+ }
244
+
245
+ if (isset($data['customer_account_edit'])&& $data['customer_account_edit'] == 1) {
246
+ $usedInForms[] = 'customer_account_edit';
247
+ }
248
+
249
+ if (isset($data['adminhtml_customer'])&& $data['adminhtml_customer'] == 1) {
250
+ $usedInForms[] = 'adminhtml_customer';
251
+ }
252
+
253
+ $data['used_in_forms'] = $usedInForms;
254
+
255
+ if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
256
+ $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
257
+ }
258
+
259
+ $defaultValueField = $model->getDefaultValueByInput($data['frontend_input']);
260
+ if ($defaultValueField) {
261
+ $data['default_value'] = $this->getRequest()->getParam($defaultValueField);
262
+ }
263
+
264
+ //filter
265
+ $data = $this->_filterPostData($data);
266
+ //print_r($data);
267
+ //exit;
268
+ $model->addData($data);
269
+
270
+ if (!$id) {
271
+ $model->setEntityTypeId($this->_entityTypeId);
272
+ $model->setIsUserDefined(1);
273
+ }
274
+
275
+ try {
276
+ $model->save();
277
+ $session->addSuccess(
278
+ Mage::helper('zestard_customerattribute')->__('The customer attribute has been saved.'));
279
+
280
+ /**
281
+ * Clear translation cache because attribute labels are stored in translation
282
+ */
283
+ Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
284
+ $session->setCustomerattributeData(false);
285
+ if ($redirectBack) {
286
+ $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current'=>true));
287
+ } else {
288
+ $this->_redirect('*/*/', array());
289
+ }
290
+ return;
291
+ } catch (Exception $e) {
292
+ $session->addError($e->getMessage());
293
+ $session->setCustomerattributeData($data);
294
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
295
+ return;
296
+ }
297
+ }
298
+ $this->_redirect('*/*/');
299
+ }
300
+
301
+ /**
302
+ * Delete customer attribute
303
+ *
304
+ * @return null
305
+ */
306
+ public function deleteAction()
307
+ {
308
+ if ($id = $this->getRequest()->getParam('attribute_id')) {
309
+ $model = Mage::getModel('zestard_customerattribute/customerattribute');
310
+
311
+ // entity type check
312
+ $model->load($id);
313
+
314
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
315
+ Mage::getSingleton('adminhtml/session')->addError(
316
+ Mage::helper('zestard_customerattribute')->__('This attribute cannot be deleted.'));
317
+ $this->_redirect('*/*/');
318
+ return;
319
+ }
320
+
321
+ try {
322
+ $model->delete();
323
+ Mage::getSingleton('adminhtml/session')->addSuccess(
324
+ Mage::helper('zestard_customerattribute')->__('The customer attribute has been deleted.'));
325
+ $this->_redirect('*/*/');
326
+ return;
327
+ }
328
+ catch (Exception $e) {
329
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
330
+ $this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id')));
331
+ return;
332
+ }
333
+ }
334
+ Mage::getSingleton('adminhtml/session')->addError(
335
+ Mage::helper('zestard_customerattribute')->__('Unable to find an attribute to delete.'));
336
+ $this->_redirect('*/*/');
337
+ }
338
+
339
+ /**
340
+ * Check the permission to run it
341
+ *
342
+ * @return boolean
343
+ */
344
+ protected function _isAllowed()
345
+ {
346
+ switch ($this->getRequest()->getActionName()) {
347
+ case 'new':
348
+ case 'save':
349
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute/save');
350
+ break;
351
+ case 'delete':
352
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute/delete');
353
+ break;
354
+ default:
355
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute');
356
+ break;
357
+ }
358
+ }
359
+ }
app/code/community/Zestard/Customerattribute/etc/adminhtml.xml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * Configuration file for admin menu and access permission
5
+ *
6
+ * @category Mage
7
+ * @package Zestard_Customerattribute
8
+ * @author Zestard Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <customer>
14
+ <children>
15
+ <customer_attribute translate="title" module="zestard_customerattribute">
16
+ <title>Manage Attributes</title>
17
+ <sort_order>601</sort_order>
18
+ <action>adminhtml/customerattribute</action>
19
+ </customer_attribute>
20
+ </children>
21
+ </customer>
22
+ </menu>
23
+ <!-- Aceess permission for the node admin/customer/customer_attribute-->
24
+ <acl>
25
+ <resources>
26
+ <all>
27
+ <title>Allow Everything</title>
28
+ </all>
29
+ <admin>
30
+ <children>
31
+ <customer>
32
+ <children>
33
+ <customer_attribute translate="title" module="zestard_customerattribute">
34
+ <title>Manage Attributes</title>
35
+ <sort_order>601</sort_order>
36
+ <children>
37
+ <save translate="title">
38
+ <title>Save Attribute</title>
39
+ <sort_order>0</sort_order>
40
+ </save>
41
+ <delete translate="title">
42
+ <title>Delete Attribute</title>
43
+ <sort_order>0</sort_order>
44
+ </delete>
45
+ </children>
46
+ </customer_attribute>
47
+ </children>
48
+ </customer>
49
+ <system>
50
+ <children>
51
+ <config>
52
+ <children>
53
+ <zestard>
54
+ <title>Zestard Extension</title>
55
+ </zestard>
56
+ </children>
57
+ </config>
58
+ </children>
59
+ </system>
60
+ </children>
61
+ </admin>
62
+ </resources>
63
+ </acl>
64
+ </config>
app/code/community/Zestard/Customerattribute/etc/config.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Configuration file
5
+ *
6
+ * @category Mage
7
+ * @package Zestard_Customerattribute
8
+ * @author Zestard Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Zestard_Customerattribute>
14
+ <version>0.1.0</version>
15
+ </Zestard_Customerattribute>
16
+ </modules>
17
+
18
+ <global>
19
+ <models>
20
+ <zestard_customerattribute>
21
+ <class>Zestard_Customerattribute_Model</class>
22
+ </zestard_customerattribute>
23
+ </models>
24
+ <helpers>
25
+ <zestard_customerattribute>
26
+ <class>Zestard_Customerattribute_Helper</class>
27
+ </zestard_customerattribute>
28
+ </helpers>
29
+ <blocks>
30
+ <zestard_customerattribute>
31
+ <class>Zestard_Customerattribute_Block</class>
32
+ </zestard_customerattribute>
33
+ </blocks>
34
+ </global>
35
+
36
+ <frontend>
37
+ <layout>
38
+ <updates>
39
+ <zestard_customerattribute>
40
+ <file>zestard_customerattribute.xml</file>
41
+ </zestard_customerattribute>
42
+ </updates>
43
+ </layout>
44
+ <translate>
45
+ <modules>
46
+ <zestard_customerattribute>
47
+ <files>
48
+ <default>Zestard_Customerattribute.csv</default>
49
+ </files>
50
+ </zestard_customerattribute>
51
+ </modules>
52
+ </translate>
53
+ </frontend>
54
+
55
+ <adminhtml>
56
+ <layout>
57
+ <updates>
58
+ <zestard_customerattribute>
59
+ <file>zestard_customerattribute.xml</file>
60
+ </zestard_customerattribute>
61
+ </updates>
62
+ </layout>
63
+ <translate>
64
+ <modules>
65
+ <zestard_customerattribute>
66
+ <files>
67
+ <default>zestard_customerattribute.csv</default>
68
+ </files>
69
+ </zestard_customerattribute>
70
+ </modules>
71
+ </translate>
72
+ </adminhtml>
73
+
74
+ <admin>
75
+ <routers>
76
+ <adminhtml>
77
+ <args>
78
+ <modules>
79
+ <zestard_customerattribute after="Mage_Adminhtml">Zestard_Customerattribute_Adminhtml</zestard_customerattribute>
80
+ </modules>
81
+ </args>
82
+ </adminhtml>
83
+ </routers>
84
+ </admin>
85
+ <!-- Zestard_Customerattribute_Adminhtml indicates the path of the admin controller-->
86
+ <default>
87
+ <general>
88
+ <validator_data>
89
+ <input_types>
90
+ <text>text</text>
91
+ <textarea>textarea</textarea>
92
+ <date>date</date>
93
+ <boolean>boolean</boolean>
94
+ <multiselect>multiselect</multiselect>
95
+ <select>select</select>
96
+ </input_types>
97
+ </validator_data>
98
+ </general>
99
+ </default>
100
+ </config>
app/code/community/Zestard/Customerattribute/etc/system.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <zestard translate="label" module="zestard_customerattribute">
5
+ <label>Customer Attribute</label>
6
+ <sort_order>100</sort_order>
7
+ </zestard>
8
+ </tabs>
9
+ <sections>
10
+ <customerattribute_logo translate="label" module="zestard_customerattribute">
11
+ <label>
12
+ <![CDATA[
13
+ <div style="position: absolute;width: 220px;display: inline-block;">
14
+ <a style="text-align:left;padding-left: 15px;" onclick="redirectSite(event,this)"><img id="zestard_block" src="" alt="" style="height:24px" border="0"/></a>
15
+ </div>&nbsp;
16
+ <script>
17
+ function redirectSite(event,obj){
18
+ event.preventDefault();
19
+ event.stopPropagation();
20
+ window.open("http://www.zestard.com/", '_blank');
21
+ }
22
+ document.observe('dom:loaded', function() {
23
+ var n = SKIN_URL.indexOf("adminhtml");
24
+ $('zestard_block').src = SKIN_URL.substring(0, n) + "adminhtml/default/default/images/customerattribute/zestard-logo.png";
25
+
26
+ });
27
+ </script>
28
+ ]]>
29
+ </label>
30
+ <tab>zestard</tab>
31
+ <sort_order>1000</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <class>zestard-logo-config</class>
36
+ </customerattribute_logo>
37
+ </sections>
38
+ </config>
app/design/adminhtml/default/default/layout/zestard_customerattribute.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * @category design
5
+ * @package default_default
6
+ * @author Zestard Magento Team
7
+ */
8
+ -->
9
+
10
+ <layout version="0.1.0">
11
+ <adminhtml_customerattribute_index>
12
+ <reference name="content">
13
+ <block type="zestard_customerattribute/adminhtml_customerattribute" name="customerattribute.grid.container" />
14
+ </reference>
15
+ </adminhtml_customerattribute_index>
16
+
17
+ <adminhtml_customerattribute_edit>
18
+ <reference name="js">
19
+ <block type="adminhtml/template" name="zestard_customerattribute_edit_js" template="zestard_customerattribute/attribute/js.phtml"></block>
20
+ </reference>
21
+ </adminhtml_customerattribute_edit>
22
+ </layout>
app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/edit/js.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category design
4
+ * @package default_default
5
+ * @author Zestard Magento Team
6
+ */
7
+ ?>
app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/js.phtml ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category design
4
+ * @package default_default
5
+ * @author Zestard Magento Team
6
+ */
7
+ ?>
8
+ <script type="text/javascript">
9
+ //<![CDATA[
10
+ function saveAndContinueEdit(){
11
+ disableElements('save');
12
+ var activeTab = customerattribute_tabsJsTabs.activeTab.id;
13
+ if (editForm.submit($('edit_form').action+'back/edit/tab/' + activeTab) == false) {
14
+ enableElements('save');
15
+ }
16
+ varienGlobalEvents.attachEventHandler('formValidateAjaxComplete', function (){
17
+ enableElements('save');
18
+ });
19
+ }
20
+
21
+ function saveAttribute(){
22
+ disableElements('save');
23
+ if (editForm.submit() == false){
24
+ enableElements('save');
25
+ }
26
+ varienGlobalEvents.attachEventHandler('formValidateAjaxComplete', function (){
27
+ enableElements('save');
28
+ });
29
+ }
30
+
31
+ function toggleApplyVisibility(select) {
32
+ if ($(select).value == 1) {
33
+ $(select).next('select').removeClassName('no-display');
34
+ $(select).next('select').removeClassName('ignore-validate');
35
+
36
+ } else {
37
+ $(select).next('select').addClassName('no-display');
38
+ $(select).next('select').addClassName('ignore-validate');
39
+ var options = $(select).next('select').options;
40
+ for( var i=0; i < options.length; i++) {
41
+ options[i].selected = false;
42
+ }
43
+ }
44
+ }
45
+
46
+ function checkOptionsPanelVisibility(){
47
+ if($('matage-options-panel')){
48
+ var panel = $('matage-options-panel');
49
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect')){
50
+ panel.show();
51
+ }
52
+ else {
53
+ panel.hide();
54
+ }
55
+ }
56
+ }
57
+
58
+ function bindAttributeInputType()
59
+ {
60
+ checkOptionsPanelVisibility();
61
+ switchDefaultValueField();
62
+ //checkIsConfigurableVisibility();
63
+ if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
64
+ if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){
65
+ $('is_filterable').disabled = false;
66
+ }
67
+ if($('is_filterable_in_search') && !$('is_filterable_in_search').getAttribute('readonly')){
68
+ $('is_filterable_in_search').disabled = false;
69
+ }
70
+ if($('backend_type') && $('backend_type').options){
71
+ for(var i=0;i<$('backend_type').options.length;i++){
72
+ if($('backend_type').options[i].value=='int') $('backend_type').selectedIndex = i;
73
+ }
74
+ }
75
+ }
76
+ else {
77
+ if($('is_filterable')){
78
+ $('is_filterable').selectedIndex=0;
79
+ $('is_filterable').disabled = true;
80
+ }
81
+ if($('is_filterable_in_search')){
82
+ $('is_filterable_in_search').disabled = true;
83
+ }
84
+ }
85
+
86
+ if ($('frontend_input') && ($('frontend_input').value=='multiselect'
87
+ || $('frontend_input').value=='gallery'
88
+ || $('frontend_input').value=='textarea')) {
89
+ if ($('used_for_sort_by')) {
90
+ $('used_for_sort_by').disabled = true;
91
+ }
92
+ }
93
+ else {
94
+ if ($('used_for_sort_by') && !$('used_for_sort_by').getAttribute('readonly')) {
95
+ $('used_for_sort_by').disabled = false;
96
+ }
97
+ }
98
+
99
+ // setRowVisibility('is_wysiwyg_enabled', false);
100
+ // setRowVisibility('is_html_allowed_on_front', false);
101
+
102
+ switch ($('frontend_input').value) {
103
+ case 'textarea':
104
+ /*
105
+ setRowVisibility('is_wysiwyg_enabled', true);
106
+ if($('is_wysiwyg_enabled').value == '0'){
107
+ setRowVisibility('is_html_allowed_on_front', true);
108
+ $('is_html_allowed_on_front').disabled = false;
109
+ }
110
+ */
111
+ $('frontend_class').value = '';
112
+ $('frontend_class').disabled = true;
113
+
114
+ break;
115
+ case 'text':
116
+ /*
117
+ setRowVisibility('is_html_allowed_on_front', true);
118
+ $('is_html_allowed_on_front').disabled = false;
119
+
120
+ if (!$('frontend_class').getAttribute('readonly')) {
121
+ $('frontend_class').disabled = false;
122
+ }
123
+ */
124
+ $('frontend_class').disabled = false;
125
+ break;
126
+ case 'select':
127
+ case 'multiselect':
128
+ /*
129
+ setRowVisibility('is_html_allowed_on_front', true);
130
+ $('is_html_allowed_on_front').disabled = false;
131
+ */
132
+ $('frontend_class').disabled = true;
133
+ break;
134
+ default:
135
+ $('frontend_class').value = '';
136
+ $('frontend_class').disabled = true;
137
+ }
138
+
139
+ //switchIsFilterable();
140
+ }
141
+
142
+ function switchIsFilterable()
143
+ {
144
+ if ($('is_filterable')) {
145
+ if ($('is_filterable').selectedIndex == 0) {
146
+ $('position').disabled = true;
147
+ } else {
148
+ if (!$('position').getAttribute('readonly')){
149
+ $('position').disabled = false;
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ function disableApplyToValue(value)
156
+ {
157
+ var applyToSelect = $('apply_to');
158
+ for (i=0;i<applyToSelect.options.length;i++) {
159
+ if (value == applyToSelect.options[i].value) {
160
+ applyToSelect.options[i].disabled = true;
161
+ applyToSelect.options[i].selected = false;
162
+ }
163
+ }
164
+ }
165
+
166
+ function switchDefaultValueField()
167
+ {
168
+ if (!$('frontend_input')) {
169
+ return;
170
+ }
171
+
172
+ var currentValue = $('frontend_input').value;
173
+
174
+ var defaultValueTextVisibility = false;
175
+ var defaultValueTextareaVisibility = false;
176
+ var defaultValueDateVisibility = false;
177
+ var defaultValueYesnoVisibility = false;
178
+ //var scopeVisibility = true;
179
+ //alert(currentValue);
180
+ switch (currentValue) {
181
+ case 'select':
182
+ optionDefaultInputType = 'radio';
183
+ break;
184
+
185
+ case 'multiselect':
186
+ optionDefaultInputType = 'checkbox';
187
+ break;
188
+
189
+ case 'date':
190
+ defaultValueDateVisibility = true;
191
+ break;
192
+
193
+ case 'boolean':
194
+ defaultValueYesnoVisibility = true;
195
+ break;
196
+
197
+ case 'textarea':
198
+ defaultValueTextareaVisibility = true;
199
+ break;
200
+
201
+ case 'media_image':
202
+ defaultValueTextVisibility = false;
203
+ break;
204
+ case 'price':
205
+ scopeVisibility = false;
206
+ default:
207
+ defaultValueTextVisibility = true;
208
+ break;
209
+ }
210
+
211
+ // var applyToSelect = $('apply_to');
212
+ switch (currentValue) {
213
+ <?php foreach (Mage::helper('zestard_customerattribute')->getAttributeDisabledTypes() as $type=>$disabled): ?>
214
+ case '<?php echo $type; ?>':
215
+ <?php foreach ($disabled as $one): ?>
216
+ //disableApplyToValue('<?php echo $one; ?>');
217
+ <?php endforeach; ?>
218
+ break;
219
+ <?php endforeach; ?>
220
+ default:
221
+ /*
222
+ for (i=0;i<applyToSelect.options.length;i++) {
223
+ applyToSelect.options[i].disabled = false;
224
+ }
225
+ */
226
+ break;
227
+ }
228
+
229
+ switch (currentValue) {
230
+ case 'media_image':
231
+ $('front_fieldset').previous().hide();
232
+ $('front_fieldset').hide();
233
+
234
+ setRowVisibility('is_required', false);
235
+ setRowVisibility('is_unique', false);
236
+ setRowVisibility('frontend_class', false);
237
+ break;
238
+
239
+ <?php foreach (Mage::helper('zestard_customerattribute')->getAttributeHiddenFields() as $type=>$fields): ?>
240
+ case '<?php echo $type; ?>':
241
+ <?php foreach ($fields as $one): ?>
242
+ <?php if ($one == '_front_fieldset'): ?>
243
+ $('front_fieldset').previous().hide();
244
+ $('front_fieldset').hide();
245
+ <?php elseif ($one == '_default_value'): ?>
246
+ defaultValueTextVisibility =
247
+ defaultValueTextareaVisibility =
248
+ defaultValueDateVisibility =
249
+ defaultValueYesnoVisibility = false;
250
+ <?php elseif ($one == '_scope'): ?>
251
+ scopeVisibility = false;
252
+ <?php else: ?>
253
+ setRowVisibility('<?php echo $one; ?>', false);
254
+ <?php endif; ?>
255
+ <?php endforeach; ?>
256
+ break;
257
+ <?php endforeach; ?>
258
+
259
+ default:
260
+ $('front_fieldset').previous().show();
261
+ $('front_fieldset').show();
262
+ setRowVisibility('is_required', true);
263
+ setRowVisibility('is_unique', true);
264
+ setRowVisibility('frontend_class', true);
265
+ // setRowVisibility('is_configurable', true);
266
+ break;
267
+ }
268
+
269
+ setRowVisibility('default_value_text', defaultValueTextVisibility);
270
+ setRowVisibility('default_value_textarea', defaultValueTextareaVisibility);
271
+ setRowVisibility('default_value_date', defaultValueDateVisibility);
272
+ setRowVisibility('default_value_yesno', defaultValueYesnoVisibility);
273
+ // setRowVisibility('is_global', scopeVisibility);
274
+
275
+ var elems = document.getElementsByName('default[]');
276
+ for (var i = 0; i < elems.length; i++) {
277
+ elems[i].type = optionDefaultInputType;
278
+ }
279
+ }
280
+
281
+ function setRowVisibility(id, isVisible)
282
+ {
283
+ if ($(id)) {
284
+ var td = $(id).parentNode;
285
+ var tr = $(td.parentNode);
286
+
287
+ if (isVisible) {
288
+ tr.show();
289
+ } else {
290
+ tr.blur();
291
+ tr.hide();
292
+ }
293
+ }
294
+ }
295
+
296
+ function checkIsConfigurableVisibility()
297
+ {
298
+ if (!$('is_configurable') || !$('is_global') || !$('frontend_input')) return;
299
+ if ($F('is_global')==1 && $F('frontend_input')=='select') {
300
+ setRowVisibility('is_configurable', true);
301
+ } else {
302
+ setRowVisibility('is_configurable', false);
303
+ }
304
+ }
305
+
306
+ function updateRequriedOptions()
307
+ {
308
+ if ($F('frontend_input')=='select' && $F('is_required')==1) {
309
+ $('option-count-check').addClassName('required-options-count');
310
+ } else {
311
+ $('option-count-check').removeClassName('required-options-count');
312
+ }
313
+ }
314
+
315
+ if($('frontend_input')){
316
+ Event.observe($('frontend_input'), 'change', updateRequriedOptions);
317
+ Event.observe($('frontend_input'), 'change', bindAttributeInputType);
318
+ //Event.observe($('is_global'), 'change', checkIsConfigurableVisibility);
319
+ }
320
+ /*
321
+ if ($('is_filterable')) {
322
+ Event.observe($('is_filterable'), 'change', switchIsFilterable);
323
+ }
324
+ */
325
+ if ($('is_required')) {
326
+ Event.observe($('is_required'), 'change', updateRequriedOptions);
327
+ }
328
+ bindAttributeInputType();
329
+ //]]>
330
+ </script>
app/design/adminhtml/default/default/template/zestard_customerattribute/attribute/options.phtml ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Attribute options control
4
+ *
5
+ * @category design
6
+ * @package default_default
7
+ * @author Zestard Magento Team
8
+ */
9
+ ?>
10
+ <?php
11
+ /**
12
+ * @see Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Options_Abstract
13
+ * @var $this Zestard_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Options_Abstract
14
+ */
15
+ ?>
16
+ <div>
17
+ <ul class="messages">
18
+ <li class="notice-msg">
19
+ <ul>
20
+ <li><?php echo $this->__('If you do not specify an option value for a specific store view then the default (Admin) value will be used.') ?></li>
21
+ </ul>
22
+ </li>
23
+ </ul>
24
+ </div>
25
+
26
+ <div class="entity-edit">
27
+ <div class="entry-edit-head">
28
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Manage Titles (Size, Color, etc.)') ?></h4>
29
+ </div>
30
+ <div class="box">
31
+ <div class="hor-scroll">
32
+ <table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
33
+ <tr>
34
+ <?php foreach ($this->getStores() as $_store): ?>
35
+ <th><?php echo $_store->getName() ?></th>
36
+ <?php endforeach; ?>
37
+ </tr>
38
+ <tr>
39
+ <?php $_labels = $this->getLabelValues() ?>
40
+ <?php foreach ($this->getStores() as $_store): ?>
41
+ <td>
42
+ <input class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" name="frontend_label[<?php echo $_store->getId() ?>]" value="<?php echo $this->htmlEscape($_labels[$_store->getId()]) ?>"<?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/>
43
+ </td>
44
+ <?php endforeach; ?>
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ <br/>
51
+ <div class="entity-edit" id="matage-options-panel">
52
+ <div class="entry-edit-head">
53
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Manage Options (values of your attribute)') ?></h4>
54
+ </div>
55
+ <div class="box">
56
+ <div class="hor-scroll">
57
+ <table class="dynamic-grid" cellspacing="0" cellpadding="0">
58
+ <tr id="attribute-options-table">
59
+ <?php foreach ($this->getStores() as $_store): ?>
60
+ <th><?php echo $_store->getName() ?></th>
61
+ <?php endforeach; ?>
62
+ <th><?php echo $this->__('Position') ?></th>
63
+ <th class="nobr a-center"><?php echo $this->__('Is Default') ?></th>
64
+ <th>
65
+ <?php if (!$this->getReadOnly()):?>
66
+ <?php echo $this->getAddNewButtonHtml() ?>
67
+ <?php endif;?>
68
+ </th>
69
+ </tr>
70
+ <tr class="no-display template" id="row-template">
71
+ <?php foreach ($this->getStores() as $_store): ?>
72
+ <td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
73
+ <?php endforeach; ?>
74
+ <td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
75
+ <td><input class="input-radio" type="radio" name="default[]" value="{{id}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
76
+ <td class="a-left">
77
+ <input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
78
+ <?php if (!$this->getReadOnly()):?>
79
+ <?php echo $this->getDeleteButtonHtml() ?>
80
+ <?php endif;?>
81
+ </td>
82
+ </tr>
83
+ </table>
84
+ </div>
85
+ <input type="hidden" id="option-count-check" value="" />
86
+ </div>
87
+ </div>
88
+ <script type="text/javascript">
89
+ //<![CDATA[
90
+ var optionDefaultInputType = 'radio';
91
+
92
+ // IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
93
+ var templateText =
94
+ '<tr class="option-row">'+
95
+ <?php foreach ($this->getStores() as $_store): ?>
96
+ '<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
97
+ <?php endforeach; ?>
98
+ '<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
99
+ '<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
100
+ '<td class="a-left" id="delete_button_container_{{id}}">'+
101
+ '<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
102
+ <?php if (!$this->getReadOnly()):?>
103
+ '<?php echo $this->getDeleteButtonHtml() ?>'+
104
+ <?php endif;?>
105
+ '<\/td>'+
106
+ '<\/tr>';
107
+
108
+ var attributeOption = {
109
+ table : $('attribute-options-table'),
110
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
111
+ templateText : templateText,
112
+ itemCount : 0,
113
+ totalItems : 0,
114
+ isReadOnly: <?php echo (int)$this->getReadOnly(); ?>,
115
+ add : function(data) {
116
+ this.template = new Template(this.templateText, this.templateSyntax);
117
+ var isNewOption = false;
118
+ if(!data.id){
119
+ data = {};
120
+ data.id = 'option_'+this.itemCount;
121
+ isNewOption = true;
122
+ }
123
+ if (!data.intype)
124
+ data.intype = optionDefaultInputType;
125
+ Element.insert(this.table, {after: this.template.evaluate(data)});
126
+ if (isNewOption && !this.isReadOnly) {
127
+ this.enableNewOptionDeleteButton(data.id);
128
+ }
129
+ this.bindRemoveButtons();
130
+ this.itemCount++;
131
+ this.totalItems++;
132
+ this.updateItemsCountField();
133
+ },
134
+ remove : function(event){
135
+ var element = $(Event.findElement(event, 'tr')); // !!! Button already
136
+ // have table parent in safari
137
+ // Safari workaround
138
+ element.ancestors().each(function(parentItem){
139
+ if (parentItem.hasClassName('option-row')) {
140
+ element = parentItem;
141
+ throw $break;
142
+ } else if (parentItem.hasClassName('box')) {
143
+ throw $break;
144
+ }
145
+ });
146
+
147
+
148
+ if(element){
149
+ var elementFlags = element.getElementsByClassName('delete-flag');
150
+ if(elementFlags[0]){
151
+ elementFlags[0].value=1;
152
+ }
153
+
154
+ element.addClassName('no-display');
155
+ element.addClassName('template');
156
+ element.hide();
157
+ this.totalItems--;
158
+ this.updateItemsCountField();
159
+ }
160
+ },
161
+ updateItemsCountField: function() {
162
+ if (this.totalItems > 0) {
163
+ $('option-count-check').value = '1';
164
+ } else {
165
+ $('option-count-check').value = '';
166
+ }
167
+ },
168
+ enableNewOptionDeleteButton: function(id) {
169
+ $$('#delete_button_container_' + id + ' button').each(function(button) {
170
+ button.enable();
171
+ button.removeClassName('disabled');
172
+ });
173
+ },
174
+ bindRemoveButtons : function(){
175
+ var buttons = $$('.delete-option');
176
+ for(var i=0;i<buttons.length;i++){
177
+ if(!$(buttons[i]).binded){
178
+ $(buttons[i]).binded = true;
179
+ Event.observe(buttons[i], 'click', this.remove.bind(this));
180
+ }
181
+ }
182
+ }
183
+
184
+ }
185
+ if($('row-template')){
186
+ $('row-template').remove();
187
+ }
188
+ attributeOption.bindRemoveButtons();
189
+
190
+ if($('add_new_option_button')){
191
+ Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
192
+ }
193
+ Validation.addAllThese([
194
+ ['required-option', '<?php echo $this->__('Failed') ?>', function(v) {
195
+ return !Validation.get('IsEmpty').test(v);
196
+ }]]);
197
+ Validation.addAllThese([
198
+ ['required-options-count', '<?php echo $this->__('Options is required') ?>', function(v) {
199
+ return !Validation.get('IsEmpty').test(v);
200
+ }]]);
201
+ <?php foreach ($this->getOptionValues() as $_value): ?>
202
+ attributeOption.add(<?php echo $_value->toJson() ?>);
203
+ <?php endforeach; ?>
204
+ //]]>
205
+ </script>
app/design/frontend/base/default/layout/zestard_customerattribute.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Customer Attribute frontend layout file
5
+ *
6
+ * @category design
7
+ * @package base_default
8
+ * @author Zestard Magento Team
9
+ */
10
+ -->
11
+ <layout version="0.1.0">
12
+
13
+ <customer_account_create translate="label">
14
+ <reference name="head">
15
+ <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/></action>
16
+ <action method="addItem"><type>js</type><name>calendar/calendar.js</name></action>
17
+ <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name></action>
18
+ </reference>
19
+
20
+ <reference name="customer_form_register">
21
+ <action method="setTemplate"><template>zestard/customerattribute/form/register.phtml</template></action>
22
+ </reference>
23
+
24
+ <reference name="before_body_end">
25
+ <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
26
+ </reference>
27
+ </customer_account_create>
28
+
29
+ <customer_account_edit translate="label">
30
+ <reference name="head">
31
+ <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/></action>
32
+ <action method="addItem"><type>js</type><name>calendar/calendar.js</name></action>
33
+ <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name></action>
34
+ </reference>
35
+
36
+ <block name="customer_edit">
37
+ <action method="setTemplate"><template>zestard/customerattribute/form/edit.phtml</template></action>
38
+ </block>
39
+
40
+ <reference name="before_body_end">
41
+ <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
42
+ </reference>
43
+ </customer_account_edit>
44
+ </layout>
app/design/frontend/base/default/template/zestard/customerattribute/form/edit.phtml ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create account form template
4
+ *
5
+ * @category design
6
+ * @package base_default
7
+ * @author Zestard Magento Team
8
+ */
9
+ ?>
10
+ <?php
11
+ /**
12
+ * edit account form template
13
+ *
14
+ * @var $this Mage_Customer_Block_form_edit
15
+ */
16
+ ?>
17
+ <div class="page-title">
18
+ <h1><?php echo $this->__('Edit Account Information') ?></h1>
19
+ </div>
20
+ <?php $helper = $this->helper('zestard_customerattribute/customerattribute'); ?>
21
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
22
+ <form action="<?php echo $this->getUrl('customer/account/editPost') ?>" method="post" id="form-validate" autocomplete="off">
23
+ <div class="fieldset">
24
+ <?php echo $this->getBlockHtml('formkey')?>
25
+ <h2 class="legend"><?php echo $this->__('Account Information') ?></h2>
26
+ <ul class="form-list">
27
+ <?php if ($helper->isAttribureForCustomerAccountEdit('firstname') && $helper->isVisible('firstname')) : ?>
28
+ <li class="fields">
29
+ <div class="field name-firstname">
30
+ <label for="firstname" class="required"><em>*</em><?php echo $this->__('First Name') ?>
31
+ </label>
32
+ <div class="input-box">
33
+ <input type="text" id="firstname" name="firstname"
34
+ value="<?php echo $this->escapeHtml($this->getCustomer()->getFirstname()) ?>"
35
+ title="<?php echo $this->__('firstname'); ?>" maxlength="255" class="input-text" />
36
+ </div>
37
+ </div>
38
+ </li>
39
+ <?php endif; ?>
40
+
41
+ <?php if ($helper->isAttribureForCustomerAccountEdit('middlename') && $helper->isVisible('middlename')) : ?>
42
+ <li class="fields">
43
+ <div class="field name-middlename">
44
+ <label for="middlename"><?php echo $this->__('Middle Name') ?>
45
+ </label>
46
+ <div class="input-box">
47
+ <input type="text" id="middlename" name="middlename"
48
+ value="<?php echo $this->escapeHtml($this->getCustomer()->getMiddlename()) ?>"
49
+ title="<?php echo $this->__('middlename'); ?>" maxlength="255" class="input-text" />
50
+ </div>
51
+ </div>
52
+ </li>
53
+ <?php endif; ?>
54
+
55
+ <?php if ($helper->isAttribureForCustomerAccountEdit('lastname') && $helper->isVisible('lastname')) : ?>
56
+ <li class="fields">
57
+ <div class="field name-lastname">
58
+ <label for="lastname" class="required"><em>*</em><?php echo $this->__('Last Name') ?>
59
+ </label>
60
+ <div class="input-box">
61
+ <input type="text" id="lastname" name="lastname"
62
+ value="<?php echo $this->escapeHtml($this->getCustomer()->getLastname()) ?>"
63
+ title="<?php echo $this->__('lastname'); ?>" maxlength="255" class="input-text" />
64
+ </div>
65
+ </div>
66
+ </li>
67
+ <?php endif; ?>
68
+ <?php if ($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit('email')) : ?>
69
+ <li>
70
+ <label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
71
+ <div class="input-box">
72
+ <input type="text" name="email" id="email" value="<?php echo $this->escapeHtml($this->getCustomer()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text required-entry validate-email" />
73
+ </div>
74
+ </li>
75
+ <?php endif ?>
76
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
77
+ <?php if ($_dob->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit('dob')): ?>
78
+ <li><?php echo $_dob->setDate($this->getCustomer()->getDob())->toHtml() ?></li>
79
+ <?php endif ?>
80
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
81
+ <?php if ($_taxvat->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit('taxvat')): ?>
82
+ <li><?php echo $_taxvat->setTaxvat($this->getCustomer()->getTaxvat())->toHtml() ?></li>
83
+ <?php endif ?>
84
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
85
+ <?php if ($_gender->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit('gender')): ?>
86
+ <li><?php echo $_gender->setGender($this->getCustomer()->getGender())->toHtml() ?></li>
87
+ <?php endif ?>
88
+ <li class="control">
89
+ <input type="checkbox" name="change_password" id="change_password" value="1" onclick="setPasswordForm(this.checked)" title="<?php echo $this->__('Change Password') ?>"<?php if($this->getCustomer()->getChangePassword()==1): ?> checked="checked"<?php endif; ?> class="checkbox" /><label for="change_password"><?php echo $this->__('Change Password') ?></label>
90
+ </li>
91
+ </ul>
92
+ </div>
93
+ <div class="fieldset" style="display:none;">
94
+ <h2 class="legend"><?php echo $this->__('Change Password') ?></h2>
95
+ <ul class="form-list">
96
+ <li>
97
+ <label for="current_password" class="required"><em>*</em><?php echo $this->__('Current Password') ?></label>
98
+ <div class="input-box">
99
+ <!-- This is a dummy hidden field to trick firefox from auto filling the password -->
100
+ <input type="text" class="input-text no-display" name="dummy" id="dummy" />
101
+ <input type="password" title="<?php echo $this->__('Current Password') ?>" class="input-text" name="current_password" id="current_password" />
102
+ </div>
103
+ </li>
104
+ <li class="fields">
105
+ <div class="field">
106
+ <label for="password" class="required"><em>*</em><?php echo $this->__('New Password') ?></label>
107
+ <div class="input-box">
108
+ <input type="password" title="<?php echo $this->__('New Password') ?>" class="input-text validate-password" name="password" id="password" />
109
+ </div>
110
+ </div>
111
+ <div class="field">
112
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm New Password') ?></label>
113
+ <div class="input-box">
114
+ <input type="password" title="<?php echo $this->__('Confirm New Password') ?>" class="input-text validate-cpassword" name="confirmation" id="confirmation" />
115
+ </div>
116
+ </div>
117
+ </li>
118
+ </ul>
119
+ </div>
120
+ <!-- custom attributes -->
121
+ <?php $attributeCollection = $this->helper('zestard_customerattribute/customerattribute')->getUserDefinedAttribures()->setOrder('sort_order', 'ASC'); ?>
122
+
123
+ <?php if($attributeCollection->count() > 0) : ?>
124
+
125
+ <div class="fieldset">
126
+ <?php foreach($attributeCollection as $attribute):?>
127
+ <?php if($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit($attribute->getAttributeCode())): ?>
128
+ <h2 class="legend"><?php echo $this->__('Additional Information') ?></h2>
129
+ <?php break; ?>
130
+ <?php endif;?>
131
+ <?php endforeach;?>
132
+
133
+ <!-- For all user defined attributes -->
134
+ <?php foreach($attributeCollection as $attribute):?>
135
+ <!-- For all user defined attributes which are set for customer edit account -->
136
+ <?php if($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit($attribute->getAttributeCode())):?>
137
+
138
+ <?php $frontEndLabel = $attribute->getStoreLabel($this->helper('zestard_customerattribute/customerattribute')->getStoreId()); ?>
139
+ <?php $getAttributeCodeFunction = "get" . str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute->getAttributeCode()))); ?>
140
+ <?php $fieldRequiredClass = ($attribute->getIsRequired()) ? 'required-entry' : '' ?>
141
+ <?php $fieldFrontendClass = ($attribute->getFrontendClass()) ? $attribute->getFrontendClass() : '' ?>
142
+ <?php $fieldValue = $this->escapeHtml($this->getCustomer()->$getAttributeCodeFunction()); ?>
143
+ <ul class="form-list">
144
+ <li class="fields">
145
+ <div class="field">
146
+ <label for="<?php echo $attribute->getAttributeCode(); ?>" <?php if($attribute->getIsRequired()):?>class="required"><em>*</em> <?php else :?>><?php endif;?><?php echo $this->__($frontEndLabel) ?></label>
147
+ <div class="input-box">
148
+
149
+ <?php if($attribute->getFrontendInput()== 'text'):?>
150
+ <input type="text" name="<?php echo $attribute->getAttributeCode(); ?>" id="<?php echo $attribute->getAttributeCode(); ?>" value="<?php echo $fieldValue; ?>" title="<?php echo $this->__($frontEndLabel); ?>" class="input-text <?php echo $fieldRequiredClass; ?> <?php echo $fieldFrontendClass ;?>" />
151
+
152
+ <?php elseif($attribute->getFrontendInput()== 'textarea'):?>
153
+ <textarea class=" textarea <?php echo $fieldRequiredClass; ?> <?php echo $fieldFrontendClass ;?>" cols="15" rows="2" title="<?php echo $this->__($frontEndLabel); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" id="<?php echo $attribute->getAttributeCode(); ?>"><?php echo $fieldValue; ?></textarea>
154
+
155
+ <?php elseif($attribute->getFrontendInput()== 'date'):?>
156
+ <input type="text" style="width:110px !important;" class=" input-text <?php echo $fieldRequiredClass; ?> " title="<?php echo $this->__($frontEndLabel); ?>" value="<?php echo $this->helper('zestard_customerattribute/customerattribute')->getFormattedDate($fieldValue); ?>" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>">
157
+ <img style="" title="Select Date" id="<?php echo $attribute->getAttributeCode(); ?>_trig" class="v-middle" alt="" src="<?php echo $this->getSkinUrl('images/zestard/customerattribute/grid-cal.gif') ?>">
158
+ <script type="text/javascript">
159
+ //&lt;![CDATA[
160
+ Calendar.setup({
161
+ inputField: "<?php echo $attribute->getAttributeCode(); ?>",
162
+ ifFormat: "%m-%d-%Y",
163
+ showsTime: false,
164
+ button: "<?php echo $attribute->getAttributeCode(); ?>_trig",
165
+ align: "Bl",
166
+ singleClick : true
167
+ });
168
+ //]]&gt;
169
+ </script>
170
+
171
+ <?php elseif($attribute->getFrontendInput()== 'boolean'):?>
172
+ <select id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" title="<?php echo $this->__($frontEndLabel); ?>"<?php if ($attribute->getIsRequired()):?> class="validate-select required-entry "<?php endif; ?>>
173
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
174
+ <?php foreach ($options as $option):?>
175
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
176
+ <?php endforeach;?>
177
+ </select>
178
+
179
+ <?php elseif($attribute->getFrontendInput()== 'select'):?>
180
+ <select id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" title="<?php echo $this->__($frontEndLabel); ?>"<?php if ($attribute->getIsRequired()):?> class="validate-select required-entry "<?php endif; ?>>
181
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
182
+ <?php foreach ($options as $option):?>
183
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
184
+ <?php endforeach;?>
185
+ </select>
186
+
187
+ <?php elseif($attribute->getFrontendInput()== 'multiselect'):?>
188
+ <select multiple="multiple" size="5" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>[]" title="<?php echo $this->__($frontEndLabel); ?>" class=" multiselect <?php if ($attribute->getIsRequired()):?> validate-select required-entry<?php endif; ?> ">
189
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
190
+ <?php foreach ($options as $option):?>
191
+ <option value="<?php echo $option['value'] ?>"<?php if (in_array($option['value'], explode(',', $fieldValue))) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
192
+ <?php endforeach;?>
193
+ </select>
194
+
195
+ <?php endif;?>
196
+ </div>
197
+ </div>
198
+ </li>
199
+ </ul>
200
+ <?php endif;?>
201
+ <?php endforeach;?>
202
+ </div>
203
+ <?php endif; ?>
204
+
205
+ <div class="buttons-set">
206
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
207
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
208
+ <button type="submit" title="<?php echo $this->__('Save') ?>" class="button"><span><span><?php echo $this->__('Save') ?></span></span></button>
209
+ </div>
210
+ </form>
211
+ <script type="text/javascript">
212
+ //<![CDATA[
213
+ var dataForm = new VarienForm('form-validate', true);
214
+ function setPasswordForm(arg){
215
+ if(arg){
216
+ $('current_password').up(3).show();
217
+ $('current_password').addClassName('required-entry');
218
+ $('password').addClassName('required-entry');
219
+ $('confirmation').addClassName('required-entry');
220
+
221
+ }else{
222
+ $('current_password').up(3).hide();
223
+ $('current_password').removeClassName('required-entry');
224
+ $('password').removeClassName('required-entry');
225
+ $('confirmation').removeClassName('required-entry');
226
+ }
227
+ }
228
+
229
+ <?php if($this->getCustomer()->getChangePassword()): ?>
230
+ setPasswordForm(true);
231
+ <?php endif; ?>
232
+ //]]>
233
+ </script>
app/design/frontend/base/default/template/zestard/customerattribute/form/register.phtml ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create account form template
4
+ *
5
+ * @category design
6
+ * @package base_default
7
+ * @author Zestard Magento Team
8
+ */
9
+ ?>
10
+ <?php
11
+ /**
12
+ * Create account form template
13
+ *
14
+ * @var $this Mage_Customer_Block_Form_Register
15
+ */
16
+ ?>
17
+ <div class="account-create">
18
+ <div class="page-title">
19
+ <h1><?php echo $this->__('Create an Account') ?></h1>
20
+ </div>
21
+ <?php echo $this->getChildHtml('form_fields_before')?>
22
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
23
+ <?php $helper = $this->helper('zestard_customerattribute/customerattribute'); ?>
24
+ <?php /* Extensions placeholder */ ?>
25
+ <?php echo $this->getChildHtml('customer.form.register.extra')?>
26
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
27
+ <div class="fieldset">
28
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
29
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
30
+ <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
31
+ <h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
32
+ <ul class="form-list">
33
+ <?php if ($helper->isAttribureForCustomerAccountCreate('firstname') && $helper->isVisible('firstname')) : ?>
34
+ <li class="fields">
35
+ <div class="field name-firstname">
36
+ <label for="firstname" class="required"><em>*</em><?php echo $this->__('First Name') ?>
37
+ </label>
38
+ <div class="input-box">
39
+ <input type="text" id="firstname" name="firstname"
40
+ title="<?php echo $this->__('firstname'); ?>" maxlength="255" class="input-text" />
41
+ </div>
42
+ </div>
43
+ </li>
44
+ <?php endif; ?>
45
+
46
+ <?php if ($helper->isAttribureForCustomerAccountCreate('middlename') && $helper->isVisible('middlename')) : ?>
47
+ <li class="fields">
48
+ <div class="field name-middlename">
49
+ <label for="middlename"><?php echo $this->__('Middle Name') ?>
50
+ </label>
51
+ <div class="input-box">
52
+ <input type="text" id="middlename" name="middlename"
53
+ title="<?php echo $this->__('middlename'); ?>" maxlength="255" class="input-text" />
54
+ </div>
55
+ </div>
56
+ </li>
57
+ <?php endif; ?>
58
+
59
+ <?php if ($helper->isAttribureForCustomerAccountCreate('lastname') && $helper->isVisible('lastname')) : ?>
60
+ <li class="fields">
61
+ <div class="field name-lastname">
62
+ <label for="lastname" class="required"><em>*</em><?php echo $this->__('Last Name') ?>
63
+ </label>
64
+ <div class="input-box">
65
+ <input type="text" id="lastname" name="lastname"
66
+ title="<?php echo $this->__('lastname'); ?>" maxlength="255" class="input-text" />
67
+ </div>
68
+ </div>
69
+ </li>
70
+ <?php endif; ?>
71
+ <?php if ($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate('email')) : ?>
72
+ <li>
73
+ <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
74
+ <div class="input-box">
75
+ <input type="text" name="email" id="email_address" value="<?php echo $this->escapeHtml($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
76
+ </div>
77
+ </li>
78
+ <?php endif; ?>
79
+ <?php if ($this->isNewsletterEnabled()): ?>
80
+ <li class="control">
81
+ <div class="input-box">
82
+ <input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed"<?php if($this->getFormData()->getIsSubscribed()): ?> checked="checked"<?php endif; ?> class="checkbox" />
83
+ </div>
84
+ <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
85
+ <?php /* Extensions placeholder */ ?>
86
+ <?php echo $this->getChildHtml('customer.form.register.newsletter')?>
87
+ </li>
88
+ <?php endif; ?>
89
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
90
+ <?php if ($_dob->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate('dob')) : ?>
91
+ <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
92
+ <?php endif ?>
93
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
94
+ <?php if ($_taxvat->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate('taxvat')): ?>
95
+ <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
96
+ <?php endif ?>
97
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
98
+ <?php if ($_gender->isEnabled() && $this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate('gender')): ?>
99
+ <li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
100
+ <?php endif ?>
101
+ </ul>
102
+ </div>
103
+ <!-- custom attributes -->
104
+ <?php $attributeCollection = $this->helper('zestard_customerattribute/customerattribute')->getUserDefinedAttribures()->setOrder('sort_order', 'ASC'); ?>
105
+ <?php if($attributeCollection->count() > 0) : ?>
106
+
107
+ <div class="fieldset">
108
+ <?php foreach($attributeCollection as $attribute):?>
109
+ <?php if($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate($attribute->getAttributeCode())): ?>
110
+ <h2 class="legend"><?php echo $this->__('Additional Information') ?></h2>
111
+ <?php break; ?>
112
+ <?php endif;?>
113
+ <?php endforeach;?>
114
+ <!-- For all user defined attributes -->
115
+ <?php foreach($attributeCollection as $attribute):?>
116
+ <!-- For all user defined attributes which are set for customer create account -->
117
+ <?php if($this->helper('zestard_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate($attribute->getAttributeCode())):?>
118
+
119
+ <?php $frontEndLabel = $attribute->getStoreLabel($this->helper('zestard_customerattribute/customerattribute')->getStoreId()); ?>
120
+ <?php $getAttributeCodeFunction = "get" . str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute->getAttributeCode()))); ?>
121
+ <?php $fieldRequiredClass = ($attribute->getIsRequired()) ? 'required-entry' : '' ?>
122
+ <?php $fieldFrontendClass = ($attribute->getFrontendClass()) ? $attribute->getFrontendClass() : '' ?>
123
+ <?php $fieldValue = ($this->getFormData()->$getAttributeCodeFunction()) ? ($this->getFormData()->$getAttributeCodeFunction()) : $attribute->getDefaultValue() ?>
124
+ <ul class="form-list">
125
+ <li class="fields">
126
+ <div class="field">
127
+ <label for="<?php echo $attribute->getAttributeCode(); ?>" <?php if($attribute->getIsRequired()):?>class="required"><em>*</em> <?php else :?>><?php endif;?><?php echo $this->__($frontEndLabel) ?></label>
128
+ <div class="input-box">
129
+
130
+ <?php if($attribute->getFrontendInput()== 'text'):?>
131
+ <input type="text" name="<?php echo $attribute->getAttributeCode(); ?>" id="<?php echo $attribute->getAttributeCode(); ?>" value="<?php echo $this->escapeHtml($fieldValue); ?>" title="<?php echo $this->__($frontEndLabel); ?>" class="input-text <?php echo $fieldRequiredClass; ?> <?php echo $fieldFrontendClass ;?>" />
132
+
133
+ <?php elseif($attribute->getFrontendInput()== 'textarea'):?>
134
+ <textarea class=" textarea <?php echo $fieldRequiredClass; ?> <?php echo $fieldFrontendClass ;?>" cols="15" rows="2" title="<?php echo $this->__($frontEndLabel); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" id="<?php echo $attribute->getAttributeCode(); ?>"><?php echo $this->escapeHtml($fieldValue); ?></textarea>
135
+
136
+ <?php elseif($attribute->getFrontendInput()== 'date'):?>
137
+ <input type="text" style="width:110px !important;" class=" input-text <?php echo $fieldRequiredClass; ?> " title="<?php echo $this->__($frontEndLabel); ?>" value="<?php echo $this->helper('zestard_customerattribute/customerattribute')->getDefaultValueForDate($fieldValue);?>" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>">
138
+ <img style="" title="Select Date" id="<?php echo $attribute->getAttributeCode(); ?>_trig" class="v-middle" alt="" src="<?php echo $this->getSkinUrl('images/zestard/customerattribute/grid-cal.gif') ?>">
139
+ <script type="text/javascript">
140
+ //&lt;![CDATA[
141
+ Calendar.setup({
142
+ inputField: "<?php echo $attribute->getAttributeCode(); ?>",
143
+ ifFormat: "%m-%d-%Y",
144
+ showsTime: false,
145
+ button: "<?php echo $attribute->getAttributeCode(); ?>_trig",
146
+ align: "Bl",
147
+ singleClick : true
148
+ });
149
+ //]]&gt;
150
+ </script>
151
+
152
+ <?php elseif($attribute->getFrontendInput()== 'boolean'):?>
153
+ <select id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" title="<?php echo $this->__($frontEndLabel); ?>"<?php if ($attribute->getIsRequired()):?> class="validate-select required-entry "<?php endif; ?>>
154
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
155
+ <?php foreach ($options as $option):?>
156
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
157
+ <?php endforeach;?>
158
+ </select>
159
+
160
+ <?php elseif($attribute->getFrontendInput()== 'select'):?>
161
+ <select id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>" title="<?php echo $this->__($frontEndLabel); ?>"<?php if ($attribute->getIsRequired()):?> class="validate-select required-entry "<?php endif; ?>>
162
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
163
+ <?php foreach ($options as $option):?>
164
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
165
+ <?php endforeach;?>
166
+ </select>
167
+
168
+ <?php elseif($attribute->getFrontendInput()== 'multiselect'):?>
169
+ <select multiple="multiple" size="5" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>[]" title="<?php echo $this->__($frontEndLabel); ?>" class=" multiselect <?php if ($attribute->getIsRequired()):?> validate-select required-entry<?php endif; ?> ">
170
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
171
+ <?php foreach ($options as $option):?>
172
+ <option value="<?php echo $option['value'] ?>"<?php if (in_array($option['value'], explode(',', $fieldValue))) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
173
+ <?php endforeach;?>
174
+ </select>
175
+
176
+ <?php endif;?>
177
+ </div>
178
+ </div>
179
+ </li>
180
+ </ul>
181
+ <?php endif;?>
182
+ <?php endforeach;?>
183
+ </div>
184
+ <?php endif; ?>
185
+
186
+ <?php if($this->getShowAddressFields()): ?>
187
+ <div class="fieldset">
188
+ <input type="hidden" name="create_address" value="1" />
189
+ <h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
190
+ <ul class="form-list">
191
+ <li class="fields">
192
+ <div class="field">
193
+ <label for="company"><?php echo $this->__('Company') ?></label>
194
+ <div class="input-box">
195
+ <input type="text" name="company" id="company" value="<?php echo $this->escapeHtml($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
196
+ </div>
197
+ </div>
198
+ <div class="field">
199
+ <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
200
+ <div class="input-box">
201
+ <input type="text" name="telephone" id="telephone" value="<?php echo $this->escapeHtml($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" />
202
+ </div>
203
+ </div>
204
+ </li>
205
+ <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
206
+ <li class="wide">
207
+ <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
208
+ <div class="input-box">
209
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
210
+ </div>
211
+ </li>
212
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
213
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
214
+ <li class="wide">
215
+ <div class="input-box">
216
+ <input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
217
+ </div>
218
+ </li>
219
+ <?php endfor; ?>
220
+ <li class="fields">
221
+ <div class="field">
222
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
223
+ <div class="input-box">
224
+ <input type="text" name="city" value="<?php echo $this->escapeHtml($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
225
+ </div>
226
+ </div>
227
+ <div class="field">
228
+ <label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
229
+ <div class="input-box">
230
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
231
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
232
+ </select>
233
+ <script type="text/javascript">
234
+ //<![CDATA[
235
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
236
+ //]]>
237
+ </script>
238
+ <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
239
+ </div>
240
+ </div>
241
+ </li>
242
+ <li class="fields">
243
+ <div class="field">
244
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
245
+ <div class="input-box">
246
+ <input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
247
+ </div>
248
+ </div>
249
+ <div class="field">
250
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
251
+ <div class="input-box">
252
+ <?php echo $this->getCountryHtmlSelect() ?>
253
+ </div>
254
+ </div>
255
+ </li>
256
+ </ul>
257
+ <input type="hidden" name="default_billing" value="1" />
258
+ <input type="hidden" name="default_shipping" value="1" />
259
+ </div>
260
+ <?php endif; ?>
261
+ <div class="fieldset">
262
+ <h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
263
+ <ul class="form-list">
264
+ <li class="fields">
265
+ <div class="field">
266
+ <label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
267
+ <div class="input-box">
268
+ <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
269
+ </div>
270
+ </div>
271
+ <div class="field">
272
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
273
+ <div class="input-box">
274
+ <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
275
+ </div>
276
+ </div>
277
+ </li>
278
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
279
+ </ul>
280
+ </div>
281
+ <div class="buttons-set">
282
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
283
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
284
+ <button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
285
+ </div>
286
+ </form>
287
+ <script type="text/javascript">
288
+ //<![CDATA[
289
+ var dataForm = new VarienForm('form-validate', true);
290
+ <?php if($this->getShowAddressFields()): ?>
291
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
292
+ <?php endif; ?>
293
+ //]]>
294
+ </script>
295
+ </div>
app/etc/modules/Zestard_Customerattribute.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Zestard
5
+ * @package Zestard_Customerattribute
6
+ * @author Zestard Magento Team
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Zestard_Customerattribute>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ </Zestard_Customerattribute>
15
+ </modules>
16
+ </config>
app/locale/en_US/Zestard_Customerattribute.csv ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Create an Account","Create an Account"
2
+ "Personal Information","Personal Information"
3
+ "First Name","First Name"
4
+ "Middle Name/Initial","Middle Name/Initial"
5
+ "Last NAME","Last NAME"
6
+ "Email Address","Email Address"
7
+ "Sign Up for Newsletter","Sign Up for Newsletter"
8
+ "Login Information","Login Information"
9
+ "Password","Password"
10
+ "Confirm Password","Confirm Password"
11
+ "Back","Back"
12
+ "Submit","Submit"
13
+ "Required Fields",Required Fields"
14
+ "Account","Account"
15
+ "Cart","Cart"
16
+ "Search entire store here...","Search entire store here..."
17
+ "Company","Company"
18
+ "Quick Links","Quick Links"
19
+ "My Account","My Account"
20
+ "Orders and Returns","Orders and Returns"
21
+ "Newsletter","Newsletter"
22
+ "Subscribe","Subscribe"
23
+ "Additional Information","Additional Information"
24
+
25
+
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>customerattributes</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer Attributes - Extra Fields for Registration Form</summary>
10
+ <description>Customer Attributes Extension enables new attributes / fields for user account and registration form.</description>
11
+ <notes>Fixed Minor Bugs</notes>
12
+ <authors><author><name>Zestard</name><user>ZestardTech</user><email>support@zestard.com</email></author></authors>
13
+ <date>2016-02-09</date>
14
+ <time>08:11:22</time>
15
+ <contents><target name="magecommunity"><dir name="Zestard"><dir name="Customerattribute"><dir name="Block"><dir name="Adminhtml"><dir name="Customerattribute"><dir name="Edit"><file name="Form.php" hash="0e5df55f204957f826ba6f1542d6e8f5"/><dir name="Main"><file name="Main.php" hash="4b35830b5d0d6ed9fc02db7071ba984f"/></dir><dir name="Tab"><file name="Main.php" hash="db2a5af35b9ee8d39ac0cba7621cbed4"/><file name="Options.php" hash="5135192c7f2b702852af3fe1ae9fc2c8"/></dir><file name="Tabs.php" hash="d6023d7e956decafeb04c56f0666988e"/></dir><file name="Edit.php" hash="b3f246bc7593c40553f76f9beddaa668"/><file name="Grid.php" hash="c1417d3f42174887587af34bac4e3a5a"/></dir><file name="Customerattribute.php" hash="6df15f8555dacef3f6cc6abf0f3bdef7"/></dir></dir><dir name="Helper"><file name="Customerattribute.php" hash="c720b896b175ad03e99ddd1ed00f567c"/><file name="Data.php" hash="6e894c0ad40f395c28fb5b3e07982d45"/></dir><dir name="Model"><file name="Customerattribute.php" hash="0564fc37e6f7d5f2c5231bce6bbc1058"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerattributeController.php" hash="75bbd96ae3585211369818baeb729cb2"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="1728163be18e6e4030c1e0e6693117aa"/><file name="config.xml" hash="fab318c2068b0654eb57dd49db570f3d"/><file name="system.xml" hash="c7ab3a10792599dceb589e9f69170ff1"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zestard_Customerattribute.xml" hash="2a3b7e19557c6cea18ed7be60c74f400"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Zestard_Customerattribute.csv" hash="a05ae84bc72da444a5addcaeddc87214"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="zestard_customerattribute.xml" hash="9de70754c0090431b17733b91229fb67"/></dir><dir name="template"><dir name="zestard_customerattribute"><dir name="attribute"><dir name="edit"><file name="js.phtml" hash="fff761885c2abceed7b877995f134ed3"/></dir><file name="js.phtml" hash="c9575f8311bfb04b82da374d0c18f3a9"/><file name="options.phtml" hash="59270f751fdf85875a9fb7d42b5e9fba"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="zestard_customerattribute.xml" hash="8a2cff0d6b9124a2572e399d890a5444"/></dir><dir name="template"><dir name="zestard"><dir name="customerattribute"><dir name="form"><file name="edit.phtml" hash="4f585c75c6fd261624524ff88ee5a5b4"/><file name="register.phtml" hash="523dbff5d4184a7bc7df684c34ca40b2"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>