Clarion_Customerattribute - Version 1.0.0

Version Notes

First stable release of extesion customer attribute.

Download this release

Release Info

Developer Clarion Tech
Extension Clarion_Customerattribute
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (24) hide show
  1. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute.php +28 -0
  2. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit.php +85 -0
  3. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Form.php +25 -0
  4. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Main/Abstract.php +204 -0
  5. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Options/Abstract.php +197 -0
  6. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Main.php +72 -0
  7. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Options.php +11 -0
  8. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tabs.php +42 -0
  9. app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Grid.php +153 -0
  10. app/code/community/Clarion/Customerattribute/Helper/Customerattribute.php +158 -0
  11. app/code/community/Clarion/Customerattribute/Helper/Data.php +153 -0
  12. app/code/community/Clarion/Customerattribute/Model/Customerattribute.php +15 -0
  13. app/code/community/Clarion/Customerattribute/controllers/Adminhtml/CustomerattributeController.php +362 -0
  14. app/code/community/Clarion/Customerattribute/etc/adminhtml.xml +53 -0
  15. app/code/community/Clarion/Customerattribute/etc/config.xml +123 -0
  16. app/design/adminhtml/default/default/layout/clarion_customerattribute.xml +22 -0
  17. app/design/adminhtml/default/default/template/clarion_customerattribute/attribute/edit/js.phtml +7 -0
  18. app/design/adminhtml/default/default/template/clarion_customerattribute/attribute/js.phtml +330 -0
  19. app/design/adminhtml/default/default/template/clarion_customerattribute/attribute/options.phtml +205 -0
  20. app/design/frontend/base/default/layout/clarion_customerattribute.xml +44 -0
  21. app/design/frontend/base/default/template/clarion/customerattribute/form/edit.phtml +186 -0
  22. app/design/frontend/base/default/template/clarion/customerattribute/form/register.phtml +252 -0
  23. app/etc/modules/Clarion_Customerattribute.xml +16 -0
  24. package.xml +20 -0
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Grid container file
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ *
9
+ */
10
+ class Clarion_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 clarion_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 = 'clarion_customerattribute';
22
+
23
+ $this->_headerText = Mage::helper('clarion_customerattribute')->__('Manage Attributes ');
24
+ $this->_addButtonLabel = Mage::helper('clarion_customerattribute')->__('Add New Attribute');
25
+
26
+ parent::__construct();
27
+ }
28
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute edit block
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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 ‘clarion_customerattribute/adminhtml_customerattribute_edit_form’.
26
+ */
27
+ $this->_blockGroup = 'clarion_customerattribute';
28
+ $this->_controller = 'adminhtml_customerattribute';
29
+
30
+ parent::__construct();
31
+
32
+ $this->_updateButton('save', 'label', Mage::helper('clarion_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('clarion_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
+ $this->_formScripts[] = "
52
+ function saveAndContinueEdit(){
53
+ editForm.submit($('edit_form').action+'back/edit/');
54
+ }
55
+ ";
56
+ */
57
+ }
58
+
59
+ /**
60
+ * This function return’s the Text to display as the form header.
61
+ */
62
+ public function getHeaderText()
63
+ {
64
+ if (Mage::registry('customerattribute_data')->getId()) {
65
+ $frontendLabel = Mage::registry('customerattribute_data')->getFrontendLabel();
66
+ if (is_array($frontendLabel)) {
67
+ $frontendLabel = $frontendLabel[0];
68
+ }
69
+ return Mage::helper('clarion_customerattribute')->__('Edit Customer Attribute "%s"', $this->escapeHtml($frontendLabel));
70
+ }
71
+ else {
72
+ return Mage::helper('clarion_customerattribute')->__('New Customer Attribute');
73
+ }
74
+ }
75
+
76
+ public function getValidationUrl()
77
+ {
78
+ return $this->getUrl('*/*/validate', array('_current'=>true));
79
+ }
80
+
81
+ public function getSaveUrl()
82
+ {
83
+ return $this->getUrl('*/'.$this->_controller.'/save', array('_current'=>true, 'back'=>null));
84
+ }
85
+ }
app/code/community/Clarion/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 Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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 surrounding <form> tags
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Main/Abstract.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute add/edit form main tab
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ abstract class Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Abstract 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 Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Abstract
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('clarion_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 Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Abstract
157
+ */
158
+ protected function _initFormValues()
159
+ {
160
+ // Mage::dispatchEvent('adminhtml_block_eav_attribute_edit_form_init', array('form' => $this->getForm()));
161
+ $this->getForm()
162
+ ->addValues($this->getAttributeObject()->getData());
163
+ return parent::_initFormValues();
164
+ }
165
+
166
+ /**
167
+ * This method is called before rendering HTML
168
+ *
169
+ * @return Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Abstract
170
+ */
171
+ protected function _beforeToHtml()
172
+ {
173
+ parent::_beforeToHtml();
174
+ $attributeObject = $this->getAttributeObject();
175
+ if ($attributeObject->getId()) {
176
+ $form = $this->getForm();
177
+ $disableAttributeFields = Mage::helper('clarion_customerattribute')
178
+ ->getAttributeLockedFields($attributeObject->getEntityType()->getEntityTypeCode());
179
+ if (isset($disableAttributeFields[$attributeObject->getAttributeCode()])) {
180
+ foreach ($disableAttributeFields[$attributeObject->getAttributeCode()] as $field) {
181
+ if ($elm = $form->getElement($field)) {
182
+ $elm->setDisabled(1);
183
+ $elm->setReadonly(1);
184
+ }
185
+ }
186
+ }
187
+ }
188
+ return $this;
189
+ }
190
+
191
+ /**
192
+ * Processing block html after rendering
193
+ * Adding js block to the end of this block
194
+ *
195
+ * @param string $html
196
+ * @return string
197
+ */
198
+ protected function _afterToHtml($html)
199
+ {
200
+ $jsScripts = $this->getLayout()
201
+ ->createBlock('eav/adminhtml_attribute_edit_js')->toHtml();
202
+ return $html.$jsScripts;
203
+ }
204
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Options/Abstract.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *Product attribute add/edit form options tab
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ *
9
+ */
10
+ abstract class Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Options_Abstract extends Mage_Adminhtml_Block_Widget
11
+ {
12
+
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setTemplate('clarion_customerattribute/attribute/options.phtml');
17
+ }
18
+
19
+ /**
20
+ * Preparing layout, adding buttons
21
+ *
22
+ * @return Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
23
+ */
24
+ protected function _prepareLayout()
25
+ {
26
+ $this->setChild('delete_button',
27
+ $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setData(array(
29
+ 'label' => Mage::helper('eav')->__('Delete'),
30
+ 'class' => 'delete delete-option'
31
+ )));
32
+
33
+ $this->setChild('add_button',
34
+ $this->getLayout()->createBlock('adminhtml/widget_button')
35
+ ->setData(array(
36
+ 'label' => Mage::helper('eav')->__('Add Option'),
37
+ 'class' => 'add',
38
+ 'id' => 'add_new_option_button'
39
+ )));
40
+ return parent::_prepareLayout();
41
+ }
42
+
43
+ /**
44
+ * Retrieve HTML of delete button
45
+ *
46
+ * @return string
47
+ */
48
+ public function getDeleteButtonHtml()
49
+ {
50
+ return $this->getChildHtml('delete_button');
51
+ }
52
+
53
+ /**
54
+ * Retrieve HTML of add button
55
+ *
56
+ * @return string
57
+ */
58
+ public function getAddNewButtonHtml()
59
+ {
60
+ return $this->getChildHtml('add_button');
61
+ }
62
+
63
+ /**
64
+ * Retrieve stores collection with default store
65
+ *
66
+ * @return Mage_Core_Model_Mysql4_Store_Collection
67
+ */
68
+ public function getStores()
69
+ {
70
+ $stores = $this->getData('stores');
71
+ if (is_null($stores)) {
72
+ $stores = Mage::getModel('core/store')
73
+ ->getResourceCollection()
74
+ ->setLoadDefault(true)
75
+ ->load();
76
+ $this->setData('stores', $stores);
77
+ }
78
+ return $stores;
79
+ }
80
+
81
+ /**
82
+ * Retrieve attribute option values if attribute input type select or multiselect
83
+ *
84
+ * @return array
85
+ */
86
+ public function getOptionValues()
87
+ {
88
+ $attributeType = $this->getAttributeObject()->getFrontendInput();
89
+ $defaultValues = $this->getAttributeObject()->getDefaultValue();
90
+ if ($attributeType == 'select' || $attributeType == 'multiselect') {
91
+ $defaultValues = explode(',', $defaultValues);
92
+ } else {
93
+ $defaultValues = array();
94
+ }
95
+
96
+ switch ($attributeType) {
97
+ case 'select':
98
+ $inputType = 'radio';
99
+ break;
100
+ case 'multiselect':
101
+ $inputType = 'checkbox';
102
+ break;
103
+ default:
104
+ $inputType = '';
105
+ break;
106
+ }
107
+
108
+ $values = $this->getData('option_values');
109
+ if (is_null($values)) {
110
+ $values = array();
111
+ $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
112
+ ->setAttributeFilter($this->getAttributeObject()->getId())
113
+ ->setPositionOrder('desc', true)
114
+ ->load();
115
+
116
+ $helper = Mage::helper('core');
117
+ foreach ($optionCollection as $option) {
118
+ $value = array();
119
+ if (in_array($option->getId(), $defaultValues)) {
120
+ $value['checked'] = 'checked="checked"';
121
+ } else {
122
+ $value['checked'] = '';
123
+ }
124
+
125
+ $value['intype'] = $inputType;
126
+ $value['id'] = $option->getId();
127
+ $value['sort_order'] = $option->getSortOrder();
128
+ foreach ($this->getStores() as $store) {
129
+ $storeValues = $this->getStoreOptionValues($store->getId());
130
+ $value['store' . $store->getId()] = isset($storeValues[$option->getId()])
131
+ ? $helper->escapeHtml($storeValues[$option->getId()]) : '';
132
+ }
133
+ $values[] = new Varien_Object($value);
134
+ }
135
+ $this->setData('option_values', $values);
136
+ }
137
+
138
+ return $values;
139
+ }
140
+
141
+ /**
142
+ * Retrieve frontend labels of attribute for each store
143
+ *
144
+ * @return array
145
+ */
146
+ public function getLabelValues()
147
+ {
148
+ $values = array();
149
+ $values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
150
+ // it can be array and cause bug
151
+ $frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
152
+ if (is_array($frontendLabel)) {
153
+ $frontendLabel = array_shift($frontendLabel);
154
+ }
155
+ $storeLabels = $this->getAttributeObject()->getStoreLabels();
156
+ foreach ($this->getStores() as $store) {
157
+ if ($store->getId() != 0) {
158
+ $values[$store->getId()] = isset($storeLabels[$store->getId()]) ? $storeLabels[$store->getId()] : '';
159
+ }
160
+ }
161
+ return $values;
162
+ }
163
+
164
+ /**
165
+ * Retrieve attribute option values for given store id
166
+ *
167
+ * @param integer $storeId
168
+ * @return array
169
+ */
170
+ public function getStoreOptionValues($storeId)
171
+ {
172
+ $values = $this->getData('store_option_values_'.$storeId);
173
+ if (is_null($values)) {
174
+ $values = array();
175
+ $valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
176
+ ->setAttributeFilter($this->getAttributeObject()->getId())
177
+ ->setStoreFilter($storeId, false)
178
+ ->load();
179
+ foreach ($valuesCollection as $item) {
180
+ $values[$item->getId()] = $item->getValue();
181
+ }
182
+ $this->setData('store_option_values_'.$storeId, $values);
183
+ }
184
+ return $values;
185
+ }
186
+
187
+ /**
188
+ * Retrieve attribute object from registry
189
+ *
190
+ * @return Mage_Eav_Model_Entity_Attribute_Abstract
191
+ */
192
+ public function getAttributeObject()
193
+ {
194
+ return Mage::registry('customerattribute_data');
195
+ }
196
+
197
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Main.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute add/edit form main tab
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+
10
+ class Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tab_Main extends Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Main_Abstract
11
+ {
12
+
13
+ /**
14
+ * Preparing default form elements for editing attribute
15
+ *
16
+ * @return Clarion_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('clarion_customerattribute')->__('Frontend Properties')));
29
+ $fieldset->addField('sort_order', 'text', array(
30
+ 'name' => 'sort_order',
31
+ 'label' => Mage::helper('clarion_customerattribute')->__('Sort Order'),
32
+ 'title' => Mage::helper('clarion_customerattribute')->__('Sort Order'),
33
+ 'note' => Mage::helper('clarion_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('clarion_customerattribute')->__('Show on the Customer Account Create Page'),
44
+ 'title' => Mage::helper('clarion_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('clarion_customerattribute')->__('Show on the Customer Account Edit Page'),
52
+ 'title' => Mage::helper('clarion_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('clarion_customerattribute')->__('Show on the Admin Manage Customers'),
60
+ 'title' => Mage::helper('clarion_customerattribute')->__('Show on the Admin Manage Customers'),
61
+ 'note' => Mage::helper('clarion_customerattribute')->__('Show on the Admin Manage Customers Add and Edit customer Page'),
62
+ ));
63
+
64
+ // define field dependencies
65
+ /*
66
+ $this->setChild('form_after', $this->getLayout()->createBlock('adminhtml/widget_form_element_dependence')
67
+ ->addFieldMap("frontend_input", 'frontend_input_type')
68
+ );
69
+ */
70
+ return $this;
71
+ }
72
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tab/Options.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Product attribute add/edit form options tab
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Tab_Options extends Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Options_Abstract
10
+ {
11
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Edit/Tabs.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customer attribute edit page tabs
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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('clarion_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('clarion_customerattribute')->__('Properties'),
27
+ 'title' => Mage::helper('clarion_customerattribute')->__('Properties'),
28
+ 'content' => $this->getLayout()->createBlock('clarion_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('clarion_customerattribute')->__('Manage Label / Options'),
36
+ 'title' => Mage::helper('clarion_customerattribute')->__('Manage Label / Options'),
37
+ 'content' => $this->getLayout()->createBlock('clarion_customerattribute/adminhtml_customerattribute_edit_tab_options')->toHtml(),
38
+ ));
39
+
40
+ return parent::_beforeToHtml();
41
+ }
42
+ }
app/code/community/Clarion/Customerattribute/Block/Adminhtml/Customerattribute/Grid.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute grid block
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ *
9
+ */
10
+ class Clarion_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 Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Grid
44
+ */
45
+ protected function _prepareCollection()
46
+ {
47
+ $collection = Mage::getResourceModel('customer/attribute_collection');
48
+ //->addVisibleFilter();
49
+ //echo "<pre>" . ($collection->getSelect());
50
+ $this->setCollection($collection);
51
+ return parent::_prepareCollection();
52
+ }
53
+
54
+ /**
55
+ * Prepare default grid column
56
+ *
57
+ * @return Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Grid
58
+ */
59
+ protected function _prepareColumns()
60
+ {
61
+ /**
62
+ * ‘id’ an unique id for column
63
+ * ‘header’ is the name of the column
64
+ * ‘index’ is the field from our collection. This ‘id’ column needs to be
65
+ * present in our collection’s models.
66
+ */
67
+
68
+ $yesno = Mage::getModel('adminhtml/system_config_source_yesno')->toArray();
69
+
70
+ $this->addColumn('attribute_code', array(
71
+ 'header'=>Mage::helper('clarion_customerattribute')->__('Attribute Code'),
72
+ 'sortable'=>true,
73
+ 'index'=>'attribute_code'
74
+ ));
75
+
76
+ $this->addColumn('frontend_label', array(
77
+ 'header'=>Mage::helper('clarion_customerattribute')->__('Attribute Label'),
78
+ 'sortable'=>true,
79
+ 'index'=>'frontend_label'
80
+ ));
81
+
82
+ $this->addColumn('is_required', array(
83
+ 'header'=>Mage::helper('clarion_customerattribute')->__('Required'),
84
+ 'sortable'=>true,
85
+ 'index'=>'is_required',
86
+ 'type' => 'options',
87
+ 'options' => $yesno,
88
+ 'align' => 'center',
89
+ ));
90
+
91
+ $this->addColumn('is_user_defined', array(
92
+ 'header'=>Mage::helper('eav')->__('System'),
93
+ 'sortable'=>true,
94
+ 'index'=>'is_user_defined',
95
+ 'type' => 'options',
96
+ 'align' => 'center',
97
+ 'options' => array(
98
+ '0' => Mage::helper('eav')->__('Yes'), // intended reverted use
99
+ '1' => Mage::helper('eav')->__('No'), // intended reverted use
100
+ ),
101
+ ));
102
+
103
+ $this->addColumn('is_visible', array(
104
+ 'header' => Mage::helper('clarion_customerattribute')->__('Visible on Frontend'),
105
+ 'index' => 'is_visible',
106
+ 'width'=>'100px',
107
+ 'type' => 'options',
108
+ 'options' => $yesno,
109
+ ));
110
+
111
+ $this->addColumn('sort_order', array(
112
+ 'header'=>Mage::helper('clarion_customerattribute')->__('Sort Order'),
113
+ 'sortable'=>true,
114
+ 'width'=>'100px',
115
+ 'index'=>'sort_order'
116
+ ));
117
+
118
+ /**
119
+ * Adding Different Options To Grid Rows
120
+ */
121
+ $this->addColumn('action',
122
+ array(
123
+ 'header' => Mage::helper('clarion_customerattribute')->__('Action'),
124
+ 'type' => 'action',
125
+ 'getter' => 'getId',
126
+ 'actions' => array(
127
+ array(
128
+ 'caption' => Mage::helper('clarion_customerattribute')->__('Edit'),
129
+ 'url' => array('base'=> '*/*/edit'),
130
+ 'field' => 'attribute_id'
131
+ )
132
+ ),
133
+ 'filter' => false,
134
+ 'sortable' => false,
135
+ 'index' => 'stores',
136
+ 'is_system' => true,
137
+ ));
138
+
139
+ return parent::_prepareColumns();
140
+ }
141
+
142
+ /**
143
+ * Row click url.
144
+ * when user click on any rows of the grid it goes to a specific URL.
145
+ * URL is of the editAction of your controller and it passed the row’s id as a parameter.
146
+ * @param object $row Data row object
147
+ * @return string
148
+ */
149
+ public function getRowUrl($row)
150
+ {
151
+ return $this->getUrl('*/*/edit', array('attribute_id' => $row->getId()));
152
+ }
153
+ }
app/code/community/Clarion/Customerattribute/Helper/Customerattribute.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute helper
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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('clarion_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
+ //print $collection->getSelect();
85
+ return $collection;
86
+ }
87
+
88
+ /**
89
+ * check is attribute is for customer account create
90
+ *
91
+ * @return boolean
92
+ */
93
+ public function isAttribureForCustomerAccountCreate($attributeCode)
94
+ {
95
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
96
+ $usedInForms = $attribute->getUsedInForms();
97
+ if (in_array('customer_account_create', $usedInForms)) {
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+
103
+ /**
104
+ * check is attribute is for customer account edit
105
+ *@param varchar $attributeCode attribute code
106
+ * @return boolean
107
+ */
108
+ public function isAttribureForCustomerAccountEdit($attributeCode)
109
+ {
110
+ $attribute = Mage::getSingleton('eav/config')->getAttribute('customer', $attributeCode);
111
+ $usedInForms = $attribute->getUsedInForms();
112
+ if (in_array('customer_account_edit', $usedInForms)) {
113
+ return true;
114
+ }
115
+ return false;
116
+ }
117
+
118
+ /**
119
+ * Get store id
120
+ *
121
+ * @return int Store id
122
+ */
123
+ public function getStoreId()
124
+ {
125
+ return Mage::app()->getStore()->getId();;
126
+ }
127
+
128
+ /**
129
+ * Get default value for date attribute
130
+ *
131
+ * @param int $timestamp timestamp
132
+ * @return date formated date
133
+ */
134
+ public function getDefaultValueForDate($timestamp)
135
+ {
136
+ if(empty($timestamp)) {
137
+ return;
138
+ }
139
+
140
+ return date('m-d-Y', $timestamp);
141
+ }
142
+
143
+ /**
144
+ * Get formated date for customer
145
+ *
146
+ * @param int $date date
147
+ * @return date formated date
148
+ */
149
+ public function getFormattedDate($date)
150
+ {
151
+ if(empty($date)) {
152
+ return;
153
+ }
154
+
155
+ return date('m-d-Y', strtotime($date));
156
+ }
157
+
158
+ }
app/code/community/Clarion/Customerattribute/Helper/Data.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute data helper
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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/Clarion/Customerattribute/Model/Customerattribute.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute Model
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_Customerattribute_Model_Customerattribute extends Mage_Customer_Model_Attribute
10
+ {
11
+ protected function _construct(){
12
+ parent::_construct();
13
+ }
14
+ }
15
+ ?>
app/code/community/Clarion/Customerattribute/controllers/Adminhtml/CustomerattributeController.php ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Manage Customer Attribute controller file
4
+ *
5
+ * @category Clarion
6
+ * @package Clarion_Customerattribute
7
+ * @author Clarion Magento Team
8
+ */
9
+ class Clarion_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('clarion_customerattribute')->__('Customer'), Mage::helper('clarion_customerattribute')->__('Customer'))
36
+ ->_addBreadcrumb(
37
+ Mage::helper('clarion_customerattribute')->__('Manage Customer Attributes'),
38
+ Mage::helper('clarion_customerattribute')->__('Manage Customer Attributes'))
39
+ ;
40
+ }
41
+ return $this;
42
+ }
43
+ /**
44
+ * Index action method
45
+ */
46
+ public function indexAction()
47
+ {
48
+ $this->_initAction()
49
+ ->renderLayout();
50
+ }
51
+
52
+ /**
53
+ * Code to display the form
54
+ *
55
+ * The main form container gets added to the content and the tabs block gets added to left.
56
+ */
57
+ public function newAction()
58
+ {
59
+ // the same form is used to create and edit
60
+ $this->_forward('edit');
61
+ }
62
+
63
+ /**
64
+ * Edit Customer Attribute
65
+ */
66
+ public function editAction()
67
+ {
68
+ $id = $this->getRequest()->getParam('attribute_id');
69
+ $model = Mage::getModel('clarion_customerattribute/customerattribute')
70
+ ->setEntityTypeId($this->_entityTypeId);
71
+
72
+ // 2. Initial checking
73
+ if ($id) {
74
+ $model->load($id);
75
+ if (! $model->getId()) {
76
+ Mage::getSingleton('adminhtml/session')->addError(
77
+ Mage::helper('clarion_customerattribute')->__('This employee no longer exists.'));
78
+ $this->_redirect('*/*/');
79
+ return;
80
+ }
81
+ }
82
+
83
+ // entity type check
84
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
85
+ Mage::getSingleton('adminhtml/session')->addError(
86
+ Mage::helper('catalog')->__('This attribute cannot be edited.'));
87
+ $this->_redirect('*/*/');
88
+ return;
89
+ }
90
+
91
+ // Sets the window title
92
+ $this->_title($id ? $model->getFrontendLabel() : $this->__('New Attribute'));
93
+
94
+ // 3. Set entered data if was error when we do save
95
+ $data = Mage::getSingleton('adminhtml/session')->getCustomerattributeData(true);
96
+ if (! empty($data)) {
97
+ $model->setData($data);
98
+ }
99
+
100
+ // print_r($model->getUsedInForms());
101
+ //print_r($model->getData());
102
+ // exit;
103
+
104
+ // 4. Register model to use later in blocks
105
+ Mage::register('customerattribute_data', $model);
106
+
107
+ // 5. Build edit form
108
+ $this->_initAction()
109
+ ->_addBreadcrumb(
110
+ $id ? Mage::helper('clarion_customerattribute')->__('Edit Customer Attribute')
111
+ : Mage::helper('clarion_customerattribute')->__('New Customer Attribute'),
112
+ $id ? Mage::helper('clarion_customerattribute')->__('Edit Customer Attribute')
113
+ : Mage::helper('clarion_customerattribute')->__('New Customer Attribute'));
114
+
115
+ $this->_addContent($this->getLayout()->createBlock('clarion_customerattribute/adminhtml_customerattribute_edit'))
116
+ ->_addLeft($this->getLayout()->createBlock('clarion_customerattribute/adminhtml_customerattribute_edit_tabs'));
117
+
118
+ $this->getLayout()->getBlock('clarion_customerattribute_edit_js')
119
+ ->setIsPopup((bool)$this->getRequest()->getParam('popup'));
120
+
121
+ $this->renderLayout();
122
+ }
123
+
124
+ public function validateAction()
125
+ {
126
+ $response = new Varien_Object();
127
+ $response->setError(false);
128
+
129
+ $attributeCode = $this->getRequest()->getParam('attribute_code');
130
+ $attributeId = $this->getRequest()->getParam('attribute_id');
131
+ $attribute = Mage::getModel('clarion_customerattribute/customerattribute')
132
+ ->loadByCode($this->_entityTypeId, $attributeCode);
133
+
134
+ if ($attribute->getId() && !$attributeId) {
135
+ Mage::getSingleton('adminhtml/session')->addError(
136
+ Mage::helper('clarion_customerattribute')->__('Attribute with the same code already exists'));
137
+ $this->_initLayoutMessages('adminhtml/session');
138
+ $response->setError(true);
139
+ $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
140
+ }
141
+
142
+ $this->getResponse()->setBody($response->toJson());
143
+ }
144
+
145
+ /**
146
+ * Filter post data
147
+ *
148
+ * @param array $data
149
+ * @return array
150
+ */
151
+ protected function _filterPostData($data)
152
+ {
153
+ if ($data) {
154
+ /** @var $helperCustomerattribute Clarion_Customerattribute_Helper_Data */
155
+ $helperCustomerattribute = Mage::helper('clarion_customerattribute');
156
+ //labels
157
+ foreach ($data['frontend_label'] as & $value) {
158
+ if ($value) {
159
+ $value = $helperCustomerattribute->stripTags($value);
160
+ }
161
+ }
162
+ }
163
+ return $data;
164
+ }
165
+
166
+ /**
167
+ *
168
+ * Save customer attributes
169
+ */
170
+ public function saveAction()
171
+ {
172
+ $data = $this->getRequest()->getPost();
173
+ if ($data) {
174
+ /** @var $session Mage_Admin_Model_Session */
175
+ $session = Mage::getSingleton('adminhtml/session');
176
+
177
+ $redirectBack = $this->getRequest()->getParam('back', false);
178
+ /* @var $model Clarion_Customerattribute_Model_Customerattribute */
179
+ $model = Mage::getModel('clarion_customerattribute/customerattribute');
180
+ /* @var $helper Mage_Catalog_Helper_Product */
181
+ $helper = Mage::helper('clarion_customerattribute/customerattribute');
182
+
183
+ $id = $this->getRequest()->getParam('attribute_id');
184
+
185
+ //validate attribute_code
186
+ if (isset($data['attribute_code'])) {
187
+ $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z][a-z_0-9]{1,254}$/'));
188
+ if (!$validatorAttrCode->isValid($data['attribute_code'])) {
189
+ $session->addError(
190
+ Mage::helper('clarion_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.')
191
+ );
192
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
193
+ return;
194
+ }
195
+ }
196
+
197
+
198
+ //validate frontend_input
199
+ if (isset($data['frontend_input'])) {
200
+ /** @var $validatorInputType Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator */
201
+ $validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator');
202
+ if (!$validatorInputType->isValid($data['frontend_input'])) {
203
+ foreach ($validatorInputType->getMessages() as $message) {
204
+ $session->addError($message);
205
+ }
206
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
207
+ return;
208
+ }
209
+ }
210
+
211
+ if ($id) {
212
+ $model->load($id);
213
+
214
+ if (!$model->getId()) {
215
+ $session->addError(
216
+ Mage::helper('clarion_customerattribute')->__('This Attribute no longer exists'));
217
+ $this->_redirect('*/*/');
218
+ return;
219
+ }
220
+
221
+ // entity type check
222
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
223
+ $session->addError(
224
+ Mage::helper('clarion_customerattribute')->__('This attribute cannot be updated.'));
225
+ $session->setCustomerattributeData($data);
226
+ $this->_redirect('*/*/');
227
+ return;
228
+ }
229
+
230
+ $data['attribute_code'] = $model->getAttributeCode();
231
+ $data['is_user_defined'] = $model->getIsUserDefined();
232
+ $data['frontend_input'] = $model->getFrontendInput();
233
+ } else {
234
+ /**
235
+ * @todo add to helper and specify all relations for properties
236
+ */
237
+ $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
238
+ $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
239
+ }
240
+
241
+ $usedInForms = array();
242
+
243
+
244
+ if (isset($data['customer_account_create'])&& $data['customer_account_create'] == 1) {
245
+ $usedInForms[] = 'customer_account_create';
246
+ }
247
+
248
+ if (isset($data['customer_account_edit'])&& $data['customer_account_edit'] == 1) {
249
+ $usedInForms[] = 'customer_account_edit';
250
+ }
251
+
252
+ if (isset($data['adminhtml_customer'])&& $data['adminhtml_customer'] == 1) {
253
+ $usedInForms[] = 'adminhtml_customer';
254
+ }
255
+
256
+ $data['used_in_forms'] = $usedInForms;
257
+
258
+ if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
259
+ $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
260
+ }
261
+
262
+ $defaultValueField = $model->getDefaultValueByInput($data['frontend_input']);
263
+ if ($defaultValueField) {
264
+ $data['default_value'] = $this->getRequest()->getParam($defaultValueField);
265
+ }
266
+
267
+ //filter
268
+ $data = $this->_filterPostData($data);
269
+ //print_r($data);
270
+ //exit;
271
+ $model->addData($data);
272
+
273
+ if (!$id) {
274
+ $model->setEntityTypeId($this->_entityTypeId);
275
+ $model->setIsUserDefined(1);
276
+ }
277
+
278
+ try {
279
+ $model->save();
280
+ $session->addSuccess(
281
+ Mage::helper('clarion_customerattribute')->__('The customer attribute has been saved.'));
282
+
283
+ /**
284
+ * Clear translation cache because attribute labels are stored in translation
285
+ */
286
+ Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
287
+ $session->setCustomerattributeData(false);
288
+ if ($redirectBack) {
289
+ $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current'=>true));
290
+ } else {
291
+ $this->_redirect('*/*/', array());
292
+ }
293
+ return;
294
+ } catch (Exception $e) {
295
+ $session->addError($e->getMessage());
296
+ $session->setCustomerattributeData($data);
297
+ $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
298
+ return;
299
+ }
300
+ }
301
+ $this->_redirect('*/*/');
302
+ }
303
+
304
+ /**
305
+ * Delete customer attribute
306
+ *
307
+ * @return null
308
+ */
309
+ public function deleteAction()
310
+ {
311
+ if ($id = $this->getRequest()->getParam('attribute_id')) {
312
+ $model = Mage::getModel('clarion_customerattribute/customerattribute');
313
+
314
+ // entity type check
315
+ $model->load($id);
316
+
317
+ if ($model->getEntityTypeId() != $this->_entityTypeId) {
318
+ Mage::getSingleton('adminhtml/session')->addError(
319
+ Mage::helper('clarion_customerattribute')->__('This attribute cannot be deleted.'));
320
+ $this->_redirect('*/*/');
321
+ return;
322
+ }
323
+
324
+ try {
325
+ $model->delete();
326
+ Mage::getSingleton('adminhtml/session')->addSuccess(
327
+ Mage::helper('clarion_customerattribute')->__('The customer attribute has been deleted.'));
328
+ $this->_redirect('*/*/');
329
+ return;
330
+ }
331
+ catch (Exception $e) {
332
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
333
+ $this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id')));
334
+ return;
335
+ }
336
+ }
337
+ Mage::getSingleton('adminhtml/session')->addError(
338
+ Mage::helper('clarion_customerattribute')->__('Unable to find an attribute to delete.'));
339
+ $this->_redirect('*/*/');
340
+ }
341
+
342
+ /**
343
+ * Check the permission to run it
344
+ *
345
+ * @return boolean
346
+ */
347
+ protected function _isAllowed()
348
+ {
349
+ switch ($this->getRequest()->getActionName()) {
350
+ case 'new':
351
+ case 'save':
352
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute/save');
353
+ break;
354
+ case 'delete':
355
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute/delete');
356
+ break;
357
+ default:
358
+ return Mage::getSingleton('admin/session')->isAllowed('customer/customer_attribute');
359
+ break;
360
+ }
361
+ }
362
+ }
app/code/community/Clarion/Customerattribute/etc/adminhtml.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * Configuration file for admin menu and access permission
5
+ *
6
+ * @category Mage
7
+ * @package Clarion_Customerattribute
8
+ * @author Clarion Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <customer>
14
+ <children>
15
+ <customer_attribute translate="title" module="clarion_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="clarion_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
+ </children>
50
+ </admin>
51
+ </resources>
52
+ </acl>
53
+ </config>
app/code/community/Clarion/Customerattribute/etc/config.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Configuration file
5
+ *
6
+ * @category Mage
7
+ * @package Clarion_Customerattribute
8
+ * @author Clarion Magento Team
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Clarion_Customerattribute>
14
+ <version>0.1.0</version>
15
+ </Clarion_Customerattribute>
16
+ </modules>
17
+
18
+ <global>
19
+ <models>
20
+ <clarion_customerattribute>
21
+ <class>Clarion_Customerattribute_Model</class>
22
+ </clarion_customerattribute>
23
+ </models>
24
+ <helpers>
25
+ <clarion_customerattribute>
26
+ <class>Clarion_Customerattribute_Helper</class>
27
+ </clarion_customerattribute>
28
+ </helpers>
29
+ <blocks>
30
+ <clarion_customerattribute>
31
+ <class>Clarion_Customerattribute_Block</class>
32
+ </clarion_customerattribute>
33
+ </blocks>
34
+ <!--
35
+ <eav_attributes>
36
+ <customer>
37
+
38
+ <sku>
39
+ <code>sku</code>
40
+ <locked_fields>
41
+ <is_global/>
42
+ <is_unique/>
43
+ </locked_fields>
44
+ </sku>
45
+ <url_key>
46
+ <code>url_key</code>
47
+ <locked_fields>
48
+ <is_unique/>
49
+ </locked_fields>
50
+ </url_key>
51
+ <status>
52
+ <code>status</code>
53
+ <locked_fields>
54
+ <is_configurable/>
55
+ <is_filterable/>
56
+ <is_filterable_in_search/>
57
+ </locked_fields>
58
+ </status>
59
+ <visibility>
60
+ <code>visibility</code>
61
+ <locked_fields>
62
+ <is_configurable/>
63
+ <is_filterable/>
64
+ <is_filterable_in_search/>
65
+ </locked_fields>
66
+ </visibility>
67
+
68
+ </customer>
69
+ </eav_attributes>
70
+
71
+ <eav_frontendclasses>
72
+
73
+ </eav_frontendclasses>
74
+ -->
75
+ </global>
76
+
77
+ <frontend>
78
+ <layout>
79
+ <updates>
80
+ <clarion_customerattribute>
81
+ <file>clarion_customerattribute.xml</file>
82
+ </clarion_customerattribute>
83
+ </updates>
84
+ </layout>
85
+ </frontend>
86
+
87
+ <adminhtml>
88
+ <layout>
89
+ <updates>
90
+ <clarion_customerattribute>
91
+ <file>clarion_customerattribute.xml</file>
92
+ </clarion_customerattribute>
93
+ </updates>
94
+ </layout>
95
+ </adminhtml>
96
+
97
+ <admin>
98
+ <routers>
99
+ <adminhtml>
100
+ <args>
101
+ <modules>
102
+ <clarion_customerattribute after="Mage_Adminhtml">Clarion_Customerattribute_Adminhtml</clarion_customerattribute>
103
+ </modules>
104
+ </args>
105
+ </adminhtml>
106
+ </routers>
107
+ </admin>
108
+ <!-- Clarion_Customerattribute_Adminhtml indicates the path of the admin controller-->
109
+ <default>
110
+ <general>
111
+ <validator_data>
112
+ <input_types>
113
+ <text>text</text>
114
+ <textarea>textarea</textarea>
115
+ <date>date</date>
116
+ <boolean>boolean</boolean>
117
+ <multiselect>multiselect</multiselect>
118
+ <select>select</select>
119
+ </input_types>
120
+ </validator_data>
121
+ </general>
122
+ </default>
123
+ </config>
app/design/adminhtml/default/default/layout/clarion_customerattribute.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <!--
3
+ /**
4
+ * @category design
5
+ * @package default_default
6
+ * @author Clarion Magento Team
7
+ */
8
+ -->
9
+
10
+ <layout version="0.1.0">
11
+ <adminhtml_customerattribute_index>
12
+ <reference name="content">
13
+ <block type="clarion_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="clarion_customerattribute_edit_js" template="clarion_customerattribute/attribute/js.phtml"></block>
20
+ </reference>
21
+ </adminhtml_customerattribute_edit>
22
+ </layout>
app/design/adminhtml/default/default/template/clarion_customerattribute/attribute/edit/js.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category design
4
+ * @package default_default
5
+ * @author Clarion Magento Team
6
+ */
7
+ ?>
app/design/adminhtml/default/default/template/clarion_customerattribute/attribute/js.phtml ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category design
4
+ * @package default_default
5
+ * @author Clarion 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('clarion_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('clarion_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/clarion_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 Clarion Magento Team
8
+ */
9
+ ?>
10
+ <?php
11
+ /**
12
+ * @see Clarion_Customerattribute_Block_Adminhtml_Customerattribute_Edit_Options_Abstract
13
+ * @var $this Clarion_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/clarion_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 Clarion 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>clarion/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>clarion/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/clarion/customerattribute/form/edit.phtml ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create account form template
4
+ *
5
+ * @category design
6
+ * @package base_default
7
+ * @author Clarion 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 echo $this->getMessagesBlock()->getGroupedHtml() ?>
21
+ <form action="<?php echo $this->getUrl('customer/account/editPost') ?>" method="post" id="form-validate" autocomplete="off">
22
+ <div class="fieldset">
23
+ <?php echo $this->getBlockHtml('formkey')?>
24
+ <h2 class="legend"><?php echo $this->__('Account Information') ?></h2>
25
+ <ul class="form-list">
26
+ <li class="fields">
27
+ <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getCustomer())->toHtml() ?>
28
+ </li>
29
+ <li>
30
+ <label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
31
+ <div class="input-box">
32
+ <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" />
33
+ </div>
34
+ </li>
35
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
36
+ <?php if ($_dob->isEnabled()): ?>
37
+ <li><?php echo $_dob->setDate($this->getCustomer()->getDob())->toHtml() ?></li>
38
+ <?php endif ?>
39
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
40
+ <?php if ($_taxvat->isEnabled()): ?>
41
+ <li><?php echo $_taxvat->setTaxvat($this->getCustomer()->getTaxvat())->toHtml() ?></li>
42
+ <?php endif ?>
43
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
44
+ <?php if ($_gender->isEnabled()): ?>
45
+ <li><?php echo $_gender->setGender($this->getCustomer()->getGender())->toHtml() ?></li>
46
+ <?php endif ?>
47
+ <li class="control">
48
+ <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>
49
+ </li>
50
+ </ul>
51
+ </div>
52
+ <div class="fieldset" style="display:none;">
53
+ <h2 class="legend"><?php echo $this->__('Change Password') ?></h2>
54
+ <ul class="form-list">
55
+ <li>
56
+ <label for="current_password" class="required"><em>*</em><?php echo $this->__('Current Password') ?></label>
57
+ <div class="input-box">
58
+ <!-- This is a dummy hidden field to trick firefox from auto filling the password -->
59
+ <input type="text" class="input-text no-display" name="dummy" id="dummy" />
60
+ <input type="password" title="<?php echo $this->__('Current Password') ?>" class="input-text" name="current_password" id="current_password" />
61
+ </div>
62
+ </li>
63
+ <li class="fields">
64
+ <div class="field">
65
+ <label for="password" class="required"><em>*</em><?php echo $this->__('New Password') ?></label>
66
+ <div class="input-box">
67
+ <input type="password" title="<?php echo $this->__('New Password') ?>" class="input-text validate-password" name="password" id="password" />
68
+ </div>
69
+ </div>
70
+ <div class="field">
71
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm New Password') ?></label>
72
+ <div class="input-box">
73
+ <input type="password" title="<?php echo $this->__('Confirm New Password') ?>" class="input-text validate-cpassword" name="confirmation" id="confirmation" />
74
+ </div>
75
+ </div>
76
+ </li>
77
+ </ul>
78
+ </div>
79
+ <!-- custom attributes -->
80
+ <?php $attributeCollection = $this->helper('clarion_customerattribute/customerattribute')->getUserDefinedAttribures(); ?>
81
+ <?php if($attributeCollection->count() > 0) : ?>
82
+
83
+ <div class="fieldset">
84
+ <h2 class="legend"><?php echo $this->__('Additional Information') ?></h2>
85
+
86
+ <!-- For all user defined attributes -->
87
+ <?php foreach($attributeCollection as $attribute):?>
88
+ <!-- For all user defined attributes which are set for customer edit account -->
89
+ <?php if($this->helper('clarion_customerattribute/customerattribute')->isAttribureForCustomerAccountEdit($attribute->getAttributeCode())):?>
90
+
91
+ <?php $frontEndLabel = $attribute->getStoreLabel($this->helper('clarion_customerattribute/customerattribute')->getStoreId()); ?>
92
+ <?php $getAttributeCodeFunction = "get" . str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute->getAttributeCode()))); ?>
93
+ <?php $fieldRequiredClass = ($attribute->getIsRequired()) ? 'required-entry' : '' ?>
94
+ <?php $fieldFrontendClass = ($attribute->getFrontendClass()) ? $attribute->getFrontendClass() : '' ?>
95
+ <?php $fieldValue = $this->escapeHtml($this->getCustomer()->$getAttributeCodeFunction()); ?>
96
+ <ul class="form-list">
97
+ <li class="fields">
98
+ <div class="field">
99
+ <label for="<?php echo $attribute->getAttributeCode(); ?>" <?php if($attribute->getIsRequired()):?>class="required"><em>*</em> <?php else :?>><?php endif;?><?php echo $this->__($frontEndLabel) ?></label>
100
+ <div class="input-box">
101
+
102
+ <?php if($attribute->getFrontendInput()== 'text'):?>
103
+ <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 ;?>" />
104
+
105
+ <?php elseif($attribute->getFrontendInput()== 'textarea'):?>
106
+ <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>
107
+
108
+ <?php elseif($attribute->getFrontendInput()== 'date'):?>
109
+ <input type="text" style="width:110px !important;" class=" input-text <?php echo $fieldRequiredClass; ?> " title="<?php echo $this->__($frontEndLabel); ?>" value="<?php echo $this->helper('clarion_customerattribute/customerattribute')->getFormattedDate($fieldValue); ?>" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>">
110
+ <img style="" title="Select Date" id="<?php echo $attribute->getAttributeCode(); ?>_trig" class="v-middle" alt="" src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>">
111
+ <script type="text/javascript">
112
+ //&lt;![CDATA[
113
+ Calendar.setup({
114
+ inputField: "<?php echo $attribute->getAttributeCode(); ?>",
115
+ ifFormat: "%m-%d-%Y",
116
+ showsTime: false,
117
+ button: "<?php echo $attribute->getAttributeCode(); ?>_trig",
118
+ align: "Bl",
119
+ singleClick : true
120
+ });
121
+ //]]&gt;
122
+ </script>
123
+
124
+ <?php elseif($attribute->getFrontendInput()== 'boolean'):?>
125
+ <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; ?>>
126
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
127
+ <?php foreach ($options as $option):?>
128
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
129
+ <?php endforeach;?>
130
+ </select>
131
+
132
+ <?php elseif($attribute->getFrontendInput()== 'select'):?>
133
+ <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; ?>>
134
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
135
+ <?php foreach ($options as $option):?>
136
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
137
+ <?php endforeach;?>
138
+ </select>
139
+
140
+ <?php elseif($attribute->getFrontendInput()== 'multiselect'):?>
141
+ <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; ?> ">
142
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
143
+ <?php foreach ($options as $option):?>
144
+ <option value="<?php echo $option['value'] ?>"<?php if (in_array($option['value'], explode(',', $fieldValue))) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
145
+ <?php endforeach;?>
146
+ </select>
147
+
148
+ <?php endif;?>
149
+ </div>
150
+ </div>
151
+ </li>
152
+ </ul>
153
+ <?php endif;?>
154
+ <?php endforeach;?>
155
+ </div>
156
+ <?php endif; ?>
157
+
158
+ <div class="buttons-set">
159
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
160
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
161
+ <button type="submit" title="<?php echo $this->__('Save') ?>" class="button"><span><span><?php echo $this->__('Save') ?></span></span></button>
162
+ </div>
163
+ </form>
164
+ <script type="text/javascript">
165
+ //<![CDATA[
166
+ var dataForm = new VarienForm('form-validate', true);
167
+ function setPasswordForm(arg){
168
+ if(arg){
169
+ $('current_password').up(3).show();
170
+ $('current_password').addClassName('required-entry');
171
+ $('password').addClassName('required-entry');
172
+ $('confirmation').addClassName('required-entry');
173
+
174
+ }else{
175
+ $('current_password').up(3).hide();
176
+ $('current_password').removeClassName('required-entry');
177
+ $('password').removeClassName('required-entry');
178
+ $('confirmation').removeClassName('required-entry');
179
+ }
180
+ }
181
+
182
+ <?php if($this->getCustomer()->getChangePassword()): ?>
183
+ setPasswordForm(true);
184
+ <?php endif; ?>
185
+ //]]>
186
+ </script>
app/design/frontend/base/default/template/clarion/customerattribute/form/register.phtml ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create account form template
4
+ *
5
+ * @category design
6
+ * @package base_default
7
+ * @author Clarion 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 /* Extensions placeholder */ ?>
24
+ <?php echo $this->getChildHtml('customer.form.register.extra')?>
25
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
26
+ <div class="fieldset">
27
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
28
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
29
+ <h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
30
+ <ul class="form-list">
31
+ <li class="fields">
32
+ <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml() ?>
33
+ </li>
34
+ <li>
35
+ <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
36
+ <div class="input-box">
37
+ <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" />
38
+ </div>
39
+ </li>
40
+ <?php if ($this->isNewsletterEnabled()): ?>
41
+ <li class="control">
42
+ <div class="input-box">
43
+ <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" />
44
+ </div>
45
+ <label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
46
+ <?php /* Extensions placeholder */ ?>
47
+ <?php echo $this->getChildHtml('customer.form.register.newsletter')?>
48
+ </li>
49
+ <?php endif ?>
50
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
51
+ <?php if ($_dob->isEnabled()): ?>
52
+ <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
53
+ <?php endif ?>
54
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
55
+ <?php if ($_taxvat->isEnabled()): ?>
56
+ <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
57
+ <?php endif ?>
58
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
59
+ <?php if ($_gender->isEnabled()): ?>
60
+ <li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
61
+ <?php endif ?>
62
+ </ul>
63
+ </div>
64
+ <!-- custom attributes -->
65
+ <?php $attributeCollection = $this->helper('clarion_customerattribute/customerattribute')->getUserDefinedAttribures(); ?>
66
+ <?php if($attributeCollection->count() > 0) : ?>
67
+
68
+ <div class="fieldset">
69
+ <h2 class="legend"><?php echo $this->__('Additional Information') ?></h2>
70
+
71
+ <!-- For all user defined attributes -->
72
+ <?php foreach($attributeCollection as $attribute):?>
73
+ <!-- For all user defined attributes which are set for customer create account -->
74
+ <?php if($this->helper('clarion_customerattribute/customerattribute')->isAttribureForCustomerAccountCreate($attribute->getAttributeCode())):?>
75
+
76
+ <?php $frontEndLabel = $attribute->getStoreLabel($this->helper('clarion_customerattribute/customerattribute')->getStoreId()); ?>
77
+ <?php $getAttributeCodeFunction = "get" . str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute->getAttributeCode()))); ?>
78
+ <?php $fieldRequiredClass = ($attribute->getIsRequired()) ? 'required-entry' : '' ?>
79
+ <?php $fieldFrontendClass = ($attribute->getFrontendClass()) ? $attribute->getFrontendClass() : '' ?>
80
+ <?php $fieldValue = ($this->getFormData()->$getAttributeCodeFunction()) ? ($this->getFormData()->$getAttributeCodeFunction()) : $attribute->getDefaultValue() ?>
81
+ <ul class="form-list">
82
+ <li class="fields">
83
+ <div class="field">
84
+ <label for="<?php echo $attribute->getAttributeCode(); ?>" <?php if($attribute->getIsRequired()):?>class="required"><em>*</em> <?php else :?>><?php endif;?><?php echo $this->__($frontEndLabel) ?></label>
85
+ <div class="input-box">
86
+
87
+ <?php if($attribute->getFrontendInput()== 'text'):?>
88
+ <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 ;?>" />
89
+
90
+ <?php elseif($attribute->getFrontendInput()== 'textarea'):?>
91
+ <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>
92
+
93
+ <?php elseif($attribute->getFrontendInput()== 'date'):?>
94
+ <input type="text" style="width:110px !important;" class=" input-text <?php echo $fieldRequiredClass; ?> " title="<?php echo $this->__($frontEndLabel); ?>" value="<?php echo $this->helper('clarion_customerattribute/customerattribute')->getDefaultValueForDate($fieldValue);?>" id="<?php echo $attribute->getAttributeCode(); ?>" name="<?php echo $attribute->getAttributeCode(); ?>">
95
+ <img style="" title="Select Date" id="<?php echo $attribute->getAttributeCode(); ?>_trig" class="v-middle" alt="" src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>">
96
+ <script type="text/javascript">
97
+ //&lt;![CDATA[
98
+ Calendar.setup({
99
+ inputField: "<?php echo $attribute->getAttributeCode(); ?>",
100
+ ifFormat: "%m-%d-%Y",
101
+ showsTime: false,
102
+ button: "<?php echo $attribute->getAttributeCode(); ?>_trig",
103
+ align: "Bl",
104
+ singleClick : true
105
+ });
106
+ //]]&gt;
107
+ </script>
108
+
109
+ <?php elseif($attribute->getFrontendInput()== 'boolean'):?>
110
+ <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; ?>>
111
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
112
+ <?php foreach ($options as $option):?>
113
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
114
+ <?php endforeach;?>
115
+ </select>
116
+
117
+ <?php elseif($attribute->getFrontendInput()== 'select'):?>
118
+ <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; ?>>
119
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
120
+ <?php foreach ($options as $option):?>
121
+ <option value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $fieldValue) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
122
+ <?php endforeach;?>
123
+ </select>
124
+
125
+ <?php elseif($attribute->getFrontendInput()== 'multiselect'):?>
126
+ <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; ?> ">
127
+ <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute($attribute->getAttributeCode())->getSource()->getAllOptions();?>
128
+ <?php foreach ($options as $option):?>
129
+ <option value="<?php echo $option['value'] ?>"<?php if (in_array($option['value'], explode(',', $fieldValue))) echo ' selected="selected"' ?>><?php echo $option['label'] ?></option>
130
+ <?php endforeach;?>
131
+ </select>
132
+
133
+ <?php endif;?>
134
+ </div>
135
+ </div>
136
+ </li>
137
+ </ul>
138
+ <?php endif;?>
139
+ <?php endforeach;?>
140
+ </div>
141
+ <?php endif; ?>
142
+
143
+ <?php if($this->getShowAddressFields()): ?>
144
+ <div class="fieldset">
145
+ <input type="hidden" name="create_address" value="1" />
146
+ <h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
147
+ <ul class="form-list">
148
+ <li class="fields">
149
+ <div class="field">
150
+ <label for="company"><?php echo $this->__('Company') ?></label>
151
+ <div class="input-box">
152
+ <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') ?>" />
153
+ </div>
154
+ </div>
155
+ <div class="field">
156
+ <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
157
+ <div class="input-box">
158
+ <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') ?>" />
159
+ </div>
160
+ </div>
161
+ </li>
162
+ <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
163
+ <li class="wide">
164
+ <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
165
+ <div class="input-box">
166
+ <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 ?>" />
167
+ </div>
168
+ </li>
169
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
170
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
171
+ <li class="wide">
172
+ <div class="input-box">
173
+ <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 ?>" />
174
+ </div>
175
+ </li>
176
+ <?php endfor; ?>
177
+ <li class="fields">
178
+ <div class="field">
179
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
180
+ <div class="input-box">
181
+ <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" />
182
+ </div>
183
+ </div>
184
+ <div class="field">
185
+ <label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
186
+ <div class="input-box">
187
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
188
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
189
+ </select>
190
+ <script type="text/javascript">
191
+ //<![CDATA[
192
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
193
+ //]]>
194
+ </script>
195
+ <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;" />
196
+ </div>
197
+ </div>
198
+ </li>
199
+ <li class="fields">
200
+ <div class="field">
201
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
202
+ <div class="input-box">
203
+ <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') ?>" />
204
+ </div>
205
+ </div>
206
+ <div class="field">
207
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
208
+ <div class="input-box">
209
+ <?php echo $this->getCountryHtmlSelect() ?>
210
+ </div>
211
+ </div>
212
+ </li>
213
+ </ul>
214
+ <input type="hidden" name="default_billing" value="1" />
215
+ <input type="hidden" name="default_shipping" value="1" />
216
+ </div>
217
+ <?php endif; ?>
218
+ <div class="fieldset">
219
+ <h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
220
+ <ul class="form-list">
221
+ <li class="fields">
222
+ <div class="field">
223
+ <label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
224
+ <div class="input-box">
225
+ <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
226
+ </div>
227
+ </div>
228
+ <div class="field">
229
+ <label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
230
+ <div class="input-box">
231
+ <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
232
+ </div>
233
+ </div>
234
+ </li>
235
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
236
+ </ul>
237
+ </div>
238
+ <div class="buttons-set">
239
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
240
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
241
+ <button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
242
+ </div>
243
+ </form>
244
+ <script type="text/javascript">
245
+ //<![CDATA[
246
+ var dataForm = new VarienForm('form-validate', true);
247
+ <?php if($this->getShowAddressFields()): ?>
248
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
249
+ <?php endif; ?>
250
+ //]]>
251
+ </script>
252
+ </div>
app/etc/modules/Clarion_Customerattribute.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Clarion
5
+ * @package Clarion_Customerattribute
6
+ * @author Clarion Magento Team
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Clarion_Customerattribute>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ </Clarion_Customerattribute>
15
+ </modules>
16
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Clarion_Customerattribute</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer Attribute Management</summary>
10
+ <description>By using Customer attributes extension we can create additional fields on the customer&#xD;
11
+ account create page, customer account edit page and admin manage customers. So the we &#xD;
12
+ can collect business-related and personal information needed from the customers.</description>
13
+ <notes>First stable release of extesion customer attribute.</notes>
14
+ <authors><author><name>Clarion Tech</name><user>Clariontech</user><email>magento@clariontechnologies.co.in</email></author></authors>
15
+ <date>2014-05-14</date>
16
+ <time>10:27:11</time>
17
+ <contents><target name="magecommunity"><dir name="Clarion"><dir name="Customerattribute"><dir name="Block"><dir name="Adminhtml"><dir name="Customerattribute"><dir name="Edit"><file name="Form.php" hash="c6bd2ea2aa06a01edd37728aeb529bda"/><dir name="Main"><file name="Abstract.php" hash="dab888a3d87d5a8a82ef14a5efef0820"/></dir><dir name="Options"><file name="Abstract.php" hash="0d6ccf3be9eb84f4881d31f4353496a2"/></dir><dir name="Tab"><file name="Main.php" hash="36c9decca79bb8c6151367cd61d17c7d"/><file name="Options.php" hash="cc6db2e20c980421439d49845fc25533"/></dir><file name="Tabs.php" hash="dcc8f3ff46ed6ae664354c60eb0d2d88"/></dir><file name="Edit.php" hash="836646be9ab4f4bfa03677cbb8dd4508"/><file name="Grid.php" hash="d1a1a997c3e4d934c9414d2c00c32946"/></dir><file name="Customerattribute.php" hash="0ded2a954d9a1b4e8f2aba494fc25b21"/></dir></dir><dir name="Helper"><file name="Customerattribute.php" hash="2869c8d8ae5a8c646bcef6c7eac11648"/><file name="Data.php" hash="80b69f61049d6d3239145dbe097c886f"/></dir><dir name="Model"><file name="Customerattribute.php" hash="beb54d45f64cefd2f9f116d11a7b7660"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerattributeController.php" hash="c0d925f6792aa6eaf472d7d61210c65b"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="78912661cc9744715913c485f27e04d0"/><file name="config.xml" hash="8d9a595d9763d4f52535540ae227f333"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="clarion_customerattribute.xml" hash="4806a3e68728cecee221a2e478867db8"/></dir><dir name="template"><dir name="clarion_customerattribute"><dir name="attribute"><dir name="edit"><file name="js.phtml" hash="c2bb9abf760078323856c16d98227fe0"/></dir><file name="js.phtml" hash="57f2621a2f0bb947c2513c8502a5d34c"/><file name="options.phtml" hash="2b9079749dd8338ffadf9f71dd1c3864"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="clarion_customerattribute.xml" hash="f739a94ef200cb88e70ffb99e8cced16"/></dir><dir name="template"><dir name="clarion"><dir name="customerattribute"><dir name="form"><file name="edit.phtml" hash="21d3868f54f40d92d10beeb224f7d359"/><file name="register.phtml" hash="00b2ac54a13080a01d901e4802b50853"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Clarion_Customerattribute.xml" hash="3ada0a4914bfa2d418ce81613bd9f2d8"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>