Version Notes
Version number: 0.0.1 Stability: Stable Compatibility: 1.4.1.1, 1.4.2, 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7
Download this release
Release Info
Developer | khanh trieu nguyen le |
Extension | Officience_CustomerAttribute |
Version | 0.0.1 |
Comparing to | |
See all releases |
Version 0.0.1
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit.php +59 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Form.php +14 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/Main.php +264 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/Options.php +154 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/System.php +136 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tabs.php +35 -0
- app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Grid.php +87 -0
- app/code/community/Officience/CustomerAttribute/Block/Form/Edit.php +61 -0
- app/code/community/Officience/CustomerAttribute/Block/Form/Register.php +60 -0
- app/code/community/Officience/CustomerAttribute/Helper/Data.php +62 -0
- app/code/community/Officience/CustomerAttribute/Helper/Field.php +133 -0
- app/code/community/Officience/CustomerAttribute/Helper/Form.php +35 -0
- app/code/community/Officience/CustomerAttribute/Model/Customerattribute.php +52 -0
- app/code/community/Officience/CustomerAttribute/Model/Mysql4/Officustomerattribute.php +11 -0
- app/code/community/Officience/CustomerAttribute/Model/Mysql4/Officustomerattribute/Collection.php +9 -0
- app/code/community/Officience/CustomerAttribute/Model/Officustomerattribute.php +10 -0
- app/code/community/Officience/CustomerAttribute/controllers/AccountController.php +397 -0
- app/code/community/Officience/CustomerAttribute/controllers/Adminhtml/IndexController.php +363 -0
- app/code/community/Officience/CustomerAttribute/etc/config.xml +138 -0
- app/code/community/Officience/CustomerAttribute/sql/customerattribute_setup/mysql4-install-0.0.1.php +32 -0
- app/design/adminhtml/default/default/layout/Officience_customer_attribute.xml +33 -0
- app/design/adminhtml/default/default/template/customerattribute/grid.phtml +179 -0
- app/design/adminhtml/default/default/template/customerattribute/index.phtml +21 -0
- app/design/adminhtml/default/default/template/customerattribute/js.phtml +274 -0
- app/design/adminhtml/default/default/template/customerattribute/new/created.phtml +54 -0
- app/design/adminhtml/default/default/template/customerattribute/options.phtml +178 -0
- app/design/frontend/base/default/layout/Officience_customerattribute.xml +55 -0
- app/design/frontend/base/default/template/officience/customerattribute/form/edit.phtml +116 -0
- app/design/frontend/base/default/template/officience/customerattribute/form/field/items.phtml +47 -0
- app/design/frontend/base/default/template/officience/customerattribute/form/form.phtml +25 -0
- app/design/frontend/base/default/template/officience/customerattribute/form/register.phtml +184 -0
- app/etc/modules/Officience_CustomerAttribute.xml +29 -0
- package.xml +18 -0
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
4 |
+
|
5 |
+
protected function _prepareLayout() {
|
6 |
+
|
7 |
+
//$this->setChild('form', $this->getLayout()->createBlock($this->_blockGroup . '/' . $this->_mode . '_form'));
|
8 |
+
return parent::_prepareLayout();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function __construct() {
|
12 |
+
|
13 |
+
$this->_objectId = 'attribute_id';
|
14 |
+
$this->_controller = 'adminhtml';
|
15 |
+
$this->_blockGroup = 'customerattribute';
|
16 |
+
parent::__construct();
|
17 |
+
|
18 |
+
if ($this->getRequest()->getParam('popup')) {
|
19 |
+
$this->_removeButton('back');
|
20 |
+
$this->_addButton(
|
21 |
+
'close', array(
|
22 |
+
'label' => Mage::helper('catalog')->__('Close Window'),
|
23 |
+
'class' => 'cancel',
|
24 |
+
'onclick' => 'window.close()',
|
25 |
+
'level' => -1
|
26 |
+
)
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
|
31 |
+
|
32 |
+
if (!Mage::registry('entity_attribute')->getIsUserDefined()) {
|
33 |
+
$this->_removeButton('delete');
|
34 |
+
} else {
|
35 |
+
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));
|
36 |
+
$this->_updateButton('delete', 'onclick', "deleteConfirm(
|
37 |
+
'" . Mage::helper('adminhtml')->__('Are you sure you want to do this?') . "',
|
38 |
+
'" . $this->getUrl('*/*/delete/type/' . $this->getRequest()->getParam('type') . '/attribute_id/' . $this->getRequest()->getParam('attribute_id')
|
39 |
+
) . "')");
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getHeaderText() {
|
44 |
+
if (Mage::registry('entity_attribute')->getId()) {
|
45 |
+
return Mage::helper('customerattribute')->__('Edit %s Attribute "%s"', 'Customer', $this->htmlEscape(Mage::registry('entity_attribute')->getFrontendLabel()));
|
46 |
+
} else {
|
47 |
+
return Mage::helper('customerattribute')->__('New %s Attribute', 'Customer');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getValidationUrl() {
|
52 |
+
return $this->getUrl('*/*/validate', array('_current' => true));
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getSaveUrl() {
|
56 |
+
return $this->getUrl('*/*/save', array('_current' => true, 'back' => null));
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Form.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _prepareForm()
|
7 |
+
{
|
8 |
+
$form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
|
9 |
+
$form->setUseContainer(true);
|
10 |
+
$this->setForm($form);
|
11 |
+
return parent::_prepareForm();
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/Main.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Edit_Tab_Main extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
protected function _prepareForm() {
|
6 |
+
$model = Mage::registry('entity_attribute');
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form(array(
|
9 |
+
'id' => 'edit_form',
|
10 |
+
'action' => $this->getData('action'),
|
11 |
+
'method' => 'post'
|
12 |
+
));
|
13 |
+
|
14 |
+
$fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('customerattribute')->__('Attribute Properties'))
|
15 |
+
);
|
16 |
+
if ($model->getId()) {
|
17 |
+
$fieldset->addField('attribute_id', 'hidden', array(
|
18 |
+
'name' => 'attribute_id',
|
19 |
+
));
|
20 |
+
}
|
21 |
+
|
22 |
+
$this->_addElementTypes($fieldset);
|
23 |
+
|
24 |
+
$yesno = array(
|
25 |
+
array(
|
26 |
+
'value' => 0,
|
27 |
+
'label' => Mage::helper('customerattribute')->__('No')
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'value' => 1,
|
31 |
+
'label' => Mage::helper('customerattribute')->__('Yes')
|
32 |
+
));
|
33 |
+
|
34 |
+
$fieldset->addField('attribute_code', 'text', array(
|
35 |
+
'name' => 'attribute_code',
|
36 |
+
'label' => Mage::helper('customerattribute')->__('Attribute Code'),
|
37 |
+
'title' => Mage::helper('customerattribute')->__('Attribute Code'),
|
38 |
+
'note' => Mage::helper('customerattribute')->__('For internal use. Must be unique with no spaces'),
|
39 |
+
'class' => 'validate-code',
|
40 |
+
'required' => true,
|
41 |
+
));
|
42 |
+
|
43 |
+
$scopes = array(
|
44 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE => Mage::helper('customerattribute')->__('Store View'),
|
45 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE => Mage::helper('customerattribute')->__('Website'),
|
46 |
+
Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL => Mage::helper('customerattribute')->__('Global'),
|
47 |
+
);
|
48 |
+
|
49 |
+
if ($model->getAttributeCode() == 'status' || $model->getAttributeCode() == 'tax_class_id') {
|
50 |
+
unset($scopes[Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE]);
|
51 |
+
}
|
52 |
+
|
53 |
+
$fieldset->addField('is_global', 'select', array(
|
54 |
+
'name' => 'is_global',
|
55 |
+
'label' => Mage::helper('customerattribute')->__('Scope'),
|
56 |
+
'title' => Mage::helper('customerattribute')->__('Scope'),
|
57 |
+
'note' => Mage::helper('customerattribute')->__('Declare attribute value saving scope'),
|
58 |
+
'values' => $scopes
|
59 |
+
));
|
60 |
+
|
61 |
+
$inputTypes = array(
|
62 |
+
array(
|
63 |
+
'value' => 'text',
|
64 |
+
'label' => Mage::helper('customerattribute')->__('Text Field')
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'value' => 'textarea',
|
68 |
+
'label' => Mage::helper('customerattribute')->__('Text Area')
|
69 |
+
),
|
70 |
+
array(
|
71 |
+
'value' => 'date',
|
72 |
+
'label' => Mage::helper('customerattribute')->__('Date')
|
73 |
+
),
|
74 |
+
array(
|
75 |
+
'value' => 'multiselect',
|
76 |
+
'label' => Mage::helper('customerattribute')->__('Multiple Select')
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'value' => 'select',
|
80 |
+
'label' => Mage::helper('customerattribute')->__('Dropdown')
|
81 |
+
),
|
82 |
+
|
83 |
+
);
|
84 |
+
if ($this->getRequest()->getParam('type') === "catalog_category") {
|
85 |
+
$inputTypes[] = array(
|
86 |
+
'value' => 'image',
|
87 |
+
'label' => Mage::helper('customerattribute')->__('Image')
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
$response = new Varien_Object();
|
92 |
+
$response->setTypes(array());
|
93 |
+
//Mage::dispatchEvent('adminhtml_product_attribute_types', array('response'=>$response));
|
94 |
+
|
95 |
+
$_disabledTypes = array();
|
96 |
+
$_hiddenFields = array();
|
97 |
+
foreach ($response->getTypes() as $type) {
|
98 |
+
$inputTypes[] = $type;
|
99 |
+
if (isset($type['hide_fields'])) {
|
100 |
+
$_hiddenFields[$type['value']] = $type['hide_fields'];
|
101 |
+
}
|
102 |
+
if (isset($type['disabled_types'])) {
|
103 |
+
$_disabledTypes[$type['value']] = $type['disabled_types'];
|
104 |
+
}
|
105 |
+
}
|
106 |
+
Mage::register('attribute_type_hidden_fields', $_hiddenFields);
|
107 |
+
Mage::register('attribute_type_disabled_types', $_disabledTypes);
|
108 |
+
|
109 |
+
|
110 |
+
$fieldset->addField('frontend_input', 'select', array(
|
111 |
+
'name' => 'frontend_input',
|
112 |
+
'label' => Mage::helper('customerattribute')->__('Catalog Input Type for Store Owner'),
|
113 |
+
'title' => Mage::helper('customerattribute')->__('Catalog Input Type for Store Owner'),
|
114 |
+
'value' => 'text',
|
115 |
+
'values' => $inputTypes
|
116 |
+
));
|
117 |
+
/* * **** champs cach�s dans le formulaire ********* */
|
118 |
+
$fieldset->addField('entity_type_id', 'hidden', array(
|
119 |
+
'name' => 'entity_type_id',
|
120 |
+
'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId()
|
121 |
+
));
|
122 |
+
|
123 |
+
|
124 |
+
|
125 |
+
$fieldset->addField('is_user_defined', 'hidden', array(
|
126 |
+
'name' => 'is_user_defined',
|
127 |
+
'value' => 1
|
128 |
+
));
|
129 |
+
|
130 |
+
$fieldset->addField('attribute_set_id', 'hidden', array(
|
131 |
+
'name' => 'attribute_set_id',
|
132 |
+
'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId()
|
133 |
+
));
|
134 |
+
|
135 |
+
$fieldset->addField('attribute_group_id', 'hidden', array(
|
136 |
+
'name' => 'attribute_group_id',
|
137 |
+
'value' => Mage::getModel('eav/entity')->setType('Customer')->getTypeId()
|
138 |
+
));
|
139 |
+
|
140 |
+
/* * **************************************************** */
|
141 |
+
$fieldset->addField('is_unique', 'select', array(
|
142 |
+
'name' => 'is_unique',
|
143 |
+
'label' => Mage::helper('customerattribute')->__('Unique Value'),
|
144 |
+
'title' => Mage::helper('customerattribute')->__('Unique Value'),
|
145 |
+
'values' => $yesno,
|
146 |
+
));
|
147 |
+
|
148 |
+
$fieldset->addField('is_required', 'select', array(
|
149 |
+
'name' => 'is_required',
|
150 |
+
'label' => Mage::helper('customerattribute')->__('Values Required'),
|
151 |
+
'title' => Mage::helper('customerattribute')->__('Values Required'),
|
152 |
+
'values' => $yesno,
|
153 |
+
));
|
154 |
+
|
155 |
+
$fieldset->addField('frontend_class', 'select', array(
|
156 |
+
'name' => 'frontend_class',
|
157 |
+
'label' => Mage::helper('customerattribute')->__('Input Validation for Store Owner'),
|
158 |
+
'title' => Mage::helper('customerattribute')->__('Input Validation for Store Owner'),
|
159 |
+
'values' => array(
|
160 |
+
array(
|
161 |
+
'value' => '',
|
162 |
+
'label' => Mage::helper('customerattribute')->__('None')
|
163 |
+
),
|
164 |
+
array(
|
165 |
+
'value' => 'validate-number',
|
166 |
+
'label' => Mage::helper('customerattribute')->__('Decimal Number')
|
167 |
+
),
|
168 |
+
array(
|
169 |
+
'value' => 'validate-digits',
|
170 |
+
'label' => Mage::helper('customerattribute')->__('Integer Number')
|
171 |
+
),
|
172 |
+
array(
|
173 |
+
'value' => 'validate-email',
|
174 |
+
'label' => Mage::helper('customerattribute')->__('Email')
|
175 |
+
),
|
176 |
+
array(
|
177 |
+
'value' => 'validate-url',
|
178 |
+
'label' => Mage::helper('customerattribute')->__('Url')
|
179 |
+
),
|
180 |
+
array(
|
181 |
+
'value' => 'validate-alpha',
|
182 |
+
'label' => Mage::helper('customerattribute')->__('Letters')
|
183 |
+
),
|
184 |
+
array(
|
185 |
+
'value' => 'validate-alphanum',
|
186 |
+
'label' => Mage::helper('customerattribute')->__('Letters(a-zA-Z) or Numbers(0-9)')
|
187 |
+
),
|
188 |
+
)
|
189 |
+
));
|
190 |
+
|
191 |
+
// -----
|
192 |
+
// frontend properties fieldset
|
193 |
+
$fieldset = $form->addFieldset('front_fieldset', array('legend' => Mage::helper('customerattribute')->__('Frontend Properties')));
|
194 |
+
|
195 |
+
|
196 |
+
|
197 |
+
$fieldset->addField('position', 'text', array(
|
198 |
+
'name' => 'position',
|
199 |
+
'label' => Mage::helper('customerattribute')->__('Position'),
|
200 |
+
'title' => Mage::helper('customerattribute')->__('Position In Layered Navigation'),
|
201 |
+
'note' => Mage::helper('customerattribute')->__('Position of attribute in layered navigation block'),
|
202 |
+
'class' => 'validate-digits',
|
203 |
+
'value' => $model->getPosition()
|
204 |
+
));
|
205 |
+
|
206 |
+
/*
|
207 |
+
$fieldset->addField('sort_order', 'text', array(
|
208 |
+
'name' => 'sort_order',
|
209 |
+
'label' => Mage::helper('customerattribute')->__('Order'),
|
210 |
+
'title' => Mage::helper('customerattribute')->__('Order in form'),
|
211 |
+
'note' => Mage::helper('customerattribute')->__('order of attribute in form edit/create. Leave blank for form bottom.'),
|
212 |
+
'class' => 'validate-digits',
|
213 |
+
'value' => $model->getAttributeSetInfo()
|
214 |
+
));
|
215 |
+
*/
|
216 |
+
|
217 |
+
//Add to form
|
218 |
+
$fieldset = $form->addFieldset('used_in_forms', array('legend' => Mage::helper('customerattribute')->__('Used in forms')));
|
219 |
+
|
220 |
+
$fieldset->addField('adminhtml_customer', 'checkbox', array(
|
221 |
+
'label' => Mage::helper('customerattribute')->__('Admin customer'),
|
222 |
+
'checked' => (is_array($model->getUsedInForms()) && in_array('adminhtml_customer',$model->getUsedInForms())? true:false),
|
223 |
+
'name' => 'used_in_forms[]',
|
224 |
+
'class' => 'attribute-checkbox',
|
225 |
+
'value' => 'adminhtml_customer',
|
226 |
+
));
|
227 |
+
|
228 |
+
$fieldset->addField('customer_account_create', 'checkbox', array(
|
229 |
+
'label' => Mage::helper('customerattribute')->__('Customer Account Create'),
|
230 |
+
'checked' => (is_array($model->getUsedInForms()) && in_array('customer_account_create',$model->getUsedInForms())? true:false),
|
231 |
+
'name' => 'used_in_forms[]',
|
232 |
+
'class' => 'attribute-checkbox',
|
233 |
+
'value' => 'customer_account_create',
|
234 |
+
));
|
235 |
+
|
236 |
+
$fieldset->addField('customer_account_edit', 'checkbox', array(
|
237 |
+
'label' => Mage::helper('customerattribute')->__('Customer Account Edit'),
|
238 |
+
'checked' => (is_array($model->getUsedInForms()) && in_array('customer_account_edit',$model->getUsedInForms())? true:false),
|
239 |
+
'name' => 'used_in_forms[]',
|
240 |
+
'class' => 'attribute-checkbox',
|
241 |
+
'value' => 'customer_account_edit',
|
242 |
+
));
|
243 |
+
|
244 |
+
if ($model->getId()) {
|
245 |
+
$form->getElement('attribute_code')->setDisabled(1);
|
246 |
+
$form->getElement('frontend_input')->setDisabled(1);
|
247 |
+
|
248 |
+
if (isset($disableAttributeFields[$model->getAttributeCode()])) {
|
249 |
+
foreach ($disableAttributeFields[$model->getAttributeCode()] as $field) {
|
250 |
+
$form->getElement($field)->setDisabled(1);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
$form->addValues($model->getData());
|
256 |
+
|
257 |
+
|
258 |
+
|
259 |
+
$this->setForm($form);
|
260 |
+
|
261 |
+
return parent::_prepareForm();
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/Options.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setTemplate('customerattribute/options.phtml');
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _prepareLayout()
|
13 |
+
{
|
14 |
+
$this->setChild('delete_button',
|
15 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
16 |
+
->setData(array(
|
17 |
+
'label' => Mage::helper('catalog')->__('Delete'),
|
18 |
+
'class' => 'delete delete-option'
|
19 |
+
)));
|
20 |
+
|
21 |
+
$this->setChild('add_button',
|
22 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
23 |
+
->setData(array(
|
24 |
+
'label' => Mage::helper('catalog')->__('Add Option'),
|
25 |
+
'class' => 'add',
|
26 |
+
'id' => 'add_new_option_button'
|
27 |
+
)));
|
28 |
+
return parent::_prepareLayout();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getDeleteButtonHtml()
|
32 |
+
{
|
33 |
+
return $this->getChildHtml('delete_button');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getAddNewButtonHtml()
|
37 |
+
{
|
38 |
+
return $this->getChildHtml('add_button');
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getStores()
|
42 |
+
{
|
43 |
+
$stores = $this->getData('stores');
|
44 |
+
if (is_null($stores)) {
|
45 |
+
$stores = Mage::getModel('core/store')
|
46 |
+
->getResourceCollection()
|
47 |
+
->setLoadDefault(true)
|
48 |
+
->load();
|
49 |
+
$this->setData('stores', $stores);
|
50 |
+
}
|
51 |
+
return $stores;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getOptionValues()
|
55 |
+
{
|
56 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
57 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
58 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
59 |
+
$defaultValues = explode(',', $defaultValues);
|
60 |
+
} else {
|
61 |
+
$defaultValues = array();
|
62 |
+
}
|
63 |
+
|
64 |
+
switch ($attributeType) {
|
65 |
+
case 'select':
|
66 |
+
$inputType = 'radio';
|
67 |
+
break;
|
68 |
+
case 'multiselect':
|
69 |
+
$inputType = 'checkbox';
|
70 |
+
break;
|
71 |
+
default:
|
72 |
+
$inputType = '';
|
73 |
+
break;
|
74 |
+
}
|
75 |
+
|
76 |
+
$values = $this->getData('option_values');
|
77 |
+
if (is_null($values)) {
|
78 |
+
$values = array();
|
79 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
80 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
81 |
+
->setPositionOrder('desc', true)
|
82 |
+
->load();
|
83 |
+
|
84 |
+
foreach ($optionCollection as $option) {
|
85 |
+
$value = array();
|
86 |
+
if (in_array($option->getId(), $defaultValues)) {
|
87 |
+
$value['checked'] = 'checked="checked"';
|
88 |
+
} else {
|
89 |
+
$value['checked'] = '';
|
90 |
+
}
|
91 |
+
|
92 |
+
$value['intype'] = $inputType;
|
93 |
+
$value['id'] = $option->getId();
|
94 |
+
$value['sort_order'] = $option->getSortOrder();
|
95 |
+
foreach ($this->getStores() as $store) {
|
96 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
97 |
+
if (isset($storeValues[$option->getId()])) {
|
98 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
99 |
+
}
|
100 |
+
else {
|
101 |
+
$value['store'.$store->getId()] = '';
|
102 |
+
}
|
103 |
+
}
|
104 |
+
$values[] = new Varien_Object($value);
|
105 |
+
}
|
106 |
+
$this->setData('option_values', $values);
|
107 |
+
}
|
108 |
+
|
109 |
+
return $values;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getLabelValues()
|
113 |
+
{
|
114 |
+
$values = array();
|
115 |
+
$values[0] = $this->getAttributeObject()->getFrontend()->getLabel();
|
116 |
+
// it can be array and cause bug
|
117 |
+
$frontendLabel = $this->getAttributeObject()->getFrontend()->getLabel();
|
118 |
+
if (is_array($frontendLabel)) {
|
119 |
+
$frontendLabel = array_shift($frontendLabel);
|
120 |
+
}
|
121 |
+
$translations = Mage::getModel('core/translate_string')
|
122 |
+
->load(Mage_Catalog_Model_Entity_Attribute::MODULE_NAME.Mage_Core_Model_Translate::SCOPE_SEPARATOR.$frontendLabel)
|
123 |
+
->getStoreTranslations();
|
124 |
+
foreach ($this->getStores() as $store) {
|
125 |
+
if ($store->getId() != 0) {
|
126 |
+
$values[$store->getId()] = isset($translations[$store->getId()]) ? $translations[$store->getId()] : '';
|
127 |
+
}
|
128 |
+
}
|
129 |
+
return $values;
|
130 |
+
}
|
131 |
+
|
132 |
+
public function getStoreOptionValues($storeId)
|
133 |
+
{
|
134 |
+
$values = $this->getData('store_option_values_'.$storeId);
|
135 |
+
if (is_null($values)) {
|
136 |
+
$values = array();
|
137 |
+
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
138 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
139 |
+
->setStoreFilter($storeId, false)
|
140 |
+
->load();
|
141 |
+
foreach ($valuesCollection as $item) {
|
142 |
+
$values[$item->getId()] = $item->getValue();
|
143 |
+
}
|
144 |
+
$this->setData('store_option_values_'.$storeId, $values);
|
145 |
+
}
|
146 |
+
return $values;
|
147 |
+
}
|
148 |
+
|
149 |
+
public function getAttributeObject()
|
150 |
+
{
|
151 |
+
return Mage::registry('entity_attribute');
|
152 |
+
}
|
153 |
+
|
154 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tab/System.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Product attribute add/edit form system tab
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
|
35 |
+
class Officience_CustomerAttribute_Block_Edit_Tab_System extends Mage_Adminhtml_Block_Widget_Form
|
36 |
+
{
|
37 |
+
|
38 |
+
protected function _prepareForm()
|
39 |
+
{
|
40 |
+
$model = Mage::registry('entity_attribute');
|
41 |
+
|
42 |
+
$form = new Varien_Data_Form();
|
43 |
+
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('catalog')->__('System Properties')));
|
44 |
+
|
45 |
+
if ($model->getAttributeId()) {
|
46 |
+
$fieldset->addField('attribute_id', 'hidden', array(
|
47 |
+
'name' => 'attribute_id',
|
48 |
+
));
|
49 |
+
}
|
50 |
+
|
51 |
+
$yesno = array(
|
52 |
+
array(
|
53 |
+
'value' => 0,
|
54 |
+
'label' => Mage::helper('catalog')->__('No')
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'value' => 1,
|
58 |
+
'label' => Mage::helper('catalog')->__('Yes')
|
59 |
+
));
|
60 |
+
|
61 |
+
/*$fieldset->addField('attribute_model', 'text', array(
|
62 |
+
'name' => 'attribute_model',
|
63 |
+
'label' => Mage::helper('catalog')->__('Attribute Model'),
|
64 |
+
'title' => Mage::helper('catalog')->__('Attribute Model'),
|
65 |
+
));
|
66 |
+
|
67 |
+
$fieldset->addField('backend_model', 'text', array(
|
68 |
+
'name' => 'backend_model',
|
69 |
+
'label' => Mage::helper('catalog')->__('Backend Model'),
|
70 |
+
'title' => Mage::helper('catalog')->__('Backend Model'),
|
71 |
+
));*/
|
72 |
+
|
73 |
+
$fieldset->addField('backend_type', 'select', array(
|
74 |
+
'name' => 'backend_type',
|
75 |
+
'label' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
|
76 |
+
'title' => Mage::helper('catalog')->__('Data Type for Saving in Database'),
|
77 |
+
'options' => array(
|
78 |
+
'text' => Mage::helper('catalog')->__('Text'),
|
79 |
+
'varchar' => Mage::helper('catalog')->__('Varchar'),
|
80 |
+
'static' => Mage::helper('catalog')->__('Static'),
|
81 |
+
'datetime' => Mage::helper('catalog')->__('Datetime'),
|
82 |
+
'decimal' => Mage::helper('catalog')->__('Decimal'),
|
83 |
+
'int' => Mage::helper('catalog')->__('Integer'),
|
84 |
+
),
|
85 |
+
));
|
86 |
+
|
87 |
+
/*$fieldset->addField('backend_table', 'text', array(
|
88 |
+
'name' => 'backend_table',
|
89 |
+
'label' => Mage::helper('catalog')->__('Backend Table'),
|
90 |
+
'title' => Mage::helper('catalog')->__('Backend Table Title'),
|
91 |
+
));
|
92 |
+
|
93 |
+
$fieldset->addField('frontend_model', 'text', array(
|
94 |
+
'name' => 'frontend_model',
|
95 |
+
'label' => Mage::helper('catalog')->__('Frontend Model'),
|
96 |
+
'title' => Mage::helper('catalog')->__('Frontend Model'),
|
97 |
+
));*/
|
98 |
+
|
99 |
+
/*$fieldset->addField('is_visible', 'select', array(
|
100 |
+
'name' => 'is_visible',
|
101 |
+
'label' => Mage::helper('catalog')->__('Visible'),
|
102 |
+
'title' => Mage::helper('catalog')->__('Visible'),
|
103 |
+
'values' => $yesno,
|
104 |
+
));*/
|
105 |
+
|
106 |
+
/*$fieldset->addField('source_model', 'text', array(
|
107 |
+
'name' => 'source_model',
|
108 |
+
'label' => Mage::helper('catalog')->__('Source Model'),
|
109 |
+
'title' => Mage::helper('catalog')->__('Source Model'),
|
110 |
+
));*/
|
111 |
+
|
112 |
+
$fieldset->addField('is_global', 'select', array(
|
113 |
+
'name' => 'is_global',
|
114 |
+
'label' => Mage::helper('catalog')->__('Globally Editable'),
|
115 |
+
'title' => Mage::helper('catalog')->__('Globally Editable'),
|
116 |
+
'values'=> $yesno,
|
117 |
+
));
|
118 |
+
|
119 |
+
|
120 |
+
|
121 |
+
$form->setValues($model->getData());
|
122 |
+
|
123 |
+
if ($model->getAttributeId()) {
|
124 |
+
$form->getElement('backend_type')->setDisabled(1);
|
125 |
+
if ($model->getIsGlobal()) {
|
126 |
+
#$form->getElement('is_global')->setDisabled(1);
|
127 |
+
}
|
128 |
+
} else {
|
129 |
+
}
|
130 |
+
|
131 |
+
$this->setForm($form);
|
132 |
+
|
133 |
+
return parent::_prepareForm();
|
134 |
+
}
|
135 |
+
|
136 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Edit/Tabs.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('customerattribute_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('catalog')->__('Attribute Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$model = Mage::registry('entity_attribute');
|
17 |
+
|
18 |
+
$this->addTab('main', array(
|
19 |
+
'label' => Mage::helper('catalog')->__('Properties'),
|
20 |
+
'title' => Mage::helper('catalog')->__('Properties'),
|
21 |
+
'content' => $this->getLayout()->createBlock('customerattribute/adminhtml_edit_tab_main')->toHtml(),
|
22 |
+
'active' => true
|
23 |
+
));
|
24 |
+
|
25 |
+
|
26 |
+
$this->addTab('labels', array(
|
27 |
+
'label' => Mage::helper('catalog')->__('Manage Label / Options'),
|
28 |
+
'title' => Mage::helper('catalog')->__('Manage Label / Options'),
|
29 |
+
'content' => $this->getLayout()->createBlock('customerattribute/adminhtml_edit_tab_options')->toHtml(),
|
30 |
+
));
|
31 |
+
|
32 |
+
return parent::_beforeToHtml();
|
33 |
+
}
|
34 |
+
|
35 |
+
}
|
app/code/community/Officience/CustomerAttribute/Block/Adminhtml/Grid.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('customerattributegrid');
|
9 |
+
$this->setDefaultSort('attribute_code');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
$this->setTemplate('customerattribute/grid.phtml');
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _prepareCollection()
|
16 |
+
{
|
17 |
+
$collection = Mage::getResourceModel('eav/entity_attribute_collection')
|
18 |
+
->setEntityTypeFilter( Mage::getModel('eav/entity')->setType('customer')->getTypeId() )
|
19 |
+
->addFilter("is_visible", 1);
|
20 |
+
|
21 |
+
$this->setCollection($collection);
|
22 |
+
return parent::_prepareCollection();
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _prepareColumns()
|
27 |
+
{
|
28 |
+
$this->addColumn('attribute_code', array(
|
29 |
+
'header'=>Mage::helper('catalog')->__('Attribute Code'),
|
30 |
+
'sortable'=>true,
|
31 |
+
'index'=>'attribute_code'
|
32 |
+
));
|
33 |
+
|
34 |
+
$this->addColumn('frontend_label', array(
|
35 |
+
'header'=>Mage::helper('catalog')->__('Attribute Label'),
|
36 |
+
'sortable'=>true,
|
37 |
+
'index'=>'frontend_label'
|
38 |
+
));
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
$this->addColumn('is_required', array(
|
43 |
+
'header'=>Mage::helper('catalog')->__('Required'),
|
44 |
+
'sortable'=>true,
|
45 |
+
'index'=>'is_required',
|
46 |
+
'type' => 'options',
|
47 |
+
'options' => array(
|
48 |
+
'1' => Mage::helper('catalog')->__('Yes'),
|
49 |
+
'0' => Mage::helper('catalog')->__('No'),
|
50 |
+
),
|
51 |
+
'align' => 'center',
|
52 |
+
));
|
53 |
+
|
54 |
+
$this->addColumn('is_user_defined', array(
|
55 |
+
'header'=>Mage::helper('catalog')->__('System'),
|
56 |
+
'sortable'=>true,
|
57 |
+
'index'=>'is_user_defined',
|
58 |
+
'type' => 'options',
|
59 |
+
'align' => 'center',
|
60 |
+
'options' => array(
|
61 |
+
'0' => Mage::helper('catalog')->__('Yes'), // intended reverted use
|
62 |
+
'1' => Mage::helper('catalog')->__('No'), // intended reverted use
|
63 |
+
),
|
64 |
+
));
|
65 |
+
|
66 |
+
|
67 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('customerattribute')->__('CSV'));
|
68 |
+
$this->addExportType('*/*/exportXml', Mage::helper('customerattribute')->__('XML'));
|
69 |
+
|
70 |
+
return parent::_prepareColumns();
|
71 |
+
}
|
72 |
+
|
73 |
+
public function addNewButton(){
|
74 |
+
return $this->getButtonHtml(
|
75 |
+
Mage::helper('customerattribute')->__('New Attribute'), //label
|
76 |
+
"setLocation('".$this->getUrl('*/*/new')."')", //url
|
77 |
+
"scalable add" //classe css
|
78 |
+
);
|
79 |
+
}
|
80 |
+
public function getRowUrl($row)
|
81 |
+
{
|
82 |
+
return $this->getUrl('*/*/edit', array('attribute_id' => $row->getAttributeId()));
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Block/Form/Edit.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Form_Edit extends Mage_Customer_Block_Form_Edit {
|
4 |
+
|
5 |
+
public $AttributeCustomer = '';
|
6 |
+
|
7 |
+
public function getTitle() {
|
8 |
+
return $this->__('More Information');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getListAttribute() {
|
12 |
+
return Mage::helper('customerattribute/form')->getListForm('customer_account_edit');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function renderFieldType() {
|
16 |
+
return Mage::helper('customerattribute/field')->renderField(
|
17 |
+
$this->getTypeAttribute()
|
18 |
+
, $this->getAttributeField()
|
19 |
+
);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getAttributeField() {
|
23 |
+
$itemAttribute = $this->AttributeCustomer;
|
24 |
+
$customerInfo = $this->getCustomer()->getData();
|
25 |
+
$result = array(
|
26 |
+
"name" => $itemAttribute->getAttributeCode(),
|
27 |
+
"id" => $itemAttribute->getAttributeCode(),
|
28 |
+
"title" => $itemAttribute->getFrontendLabel(),
|
29 |
+
"is_required" => $itemAttribute->getIsRequired(),
|
30 |
+
"value" => $customerInfo[$itemAttribute->getAttributeCode()],
|
31 |
+
"frontend_class" => $itemAttribute->getFrontendClass(),
|
32 |
+
);
|
33 |
+
if (in_array($this->getTypeAttribute(), array('select', 'multiselect'))) {
|
34 |
+
$result['values'] = $itemAttribute->getSource()->getAllOptions();
|
35 |
+
}
|
36 |
+
return $result;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getFieldDefault() {
|
40 |
+
return Mage::Helper('customerattribute/field')->getFieldDeFault();
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getAttributeCode($itemsAttribute) {
|
44 |
+
return $this->AttributeCustomer->getAttributeCode();
|
45 |
+
}
|
46 |
+
|
47 |
+
public function setAttribute($attribute) {
|
48 |
+
$this->AttributeCustomer = $attribute;
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getTypeAttribute() {
|
52 |
+
return $this->AttributeCustomer->getFrontendInput();
|
53 |
+
}
|
54 |
+
|
55 |
+
public function getLabelAttribute() {
|
56 |
+
return $this->AttributeCustomer->getFrontendLabel();
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Block/Form/Register.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Block_Form_Register extends Mage_Customer_Block_Form_Register {
|
4 |
+
|
5 |
+
public $AttributeCustomer = '';
|
6 |
+
|
7 |
+
public function getListAttribute() {
|
8 |
+
return Mage::helper('customerattribute/form')->getListForm('customer_account_create');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function renderFieldType() {
|
12 |
+
return Mage::helper('customerattribute/field')->renderField(
|
13 |
+
$this->getTypeAttribute()
|
14 |
+
, $this->getAttributeField()
|
15 |
+
);
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getTitle() {
|
19 |
+
return $this->__('Account Infomation');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getAttributeField() {
|
23 |
+
$itemAttribute = $this->AttributeCustomer;
|
24 |
+
$result = array(
|
25 |
+
"name" => $itemAttribute->getAttributeCode(),
|
26 |
+
"id" => $itemAttribute->getAttributeCode(),
|
27 |
+
"title" => $itemAttribute->getFrontendLabel(),
|
28 |
+
"is_required" => $itemAttribute->getIsRequired(),
|
29 |
+
"value" => ($itemAttribute->getDefaultValue()?$itemAttribute->getDefaultValue():' '),
|
30 |
+
"frontend_class" => $itemAttribute->getFrontendClass(),
|
31 |
+
);
|
32 |
+
if (in_array($this->getTypeAttribute(), array('select', 'multiselect'))) {
|
33 |
+
$result['values'] = $itemAttribute->getSource()->getAllOptions();
|
34 |
+
}
|
35 |
+
return $result;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getFieldDefault() {
|
39 |
+
return Mage::Helper('customerattribute/field')->getFieldDeFault();
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getAttributeCode() {
|
43 |
+
return $this->AttributeCustomer->getAttributeCode();
|
44 |
+
}
|
45 |
+
|
46 |
+
public function setAttribute($attribute) {
|
47 |
+
$this->AttributeCustomer = $attribute;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getTypeAttribute() {
|
51 |
+
return $this->AttributeCustomer->getFrontendInput();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getLabelAttribute() {
|
55 |
+
return $this->AttributeCustomer->getFrontendLabel();
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
59 |
+
|
60 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Helper/Data.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Helper_Data extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Return information array of product attribute input types
|
7 |
+
* Only a small number of settings returned, so we won't break anything in current dataflow
|
8 |
+
* As soon as development process goes on we need to add there all possible settings
|
9 |
+
*
|
10 |
+
* @param string $inputType
|
11 |
+
* @return array
|
12 |
+
*/
|
13 |
+
public function getAttributeInputTypes($inputType = null) {
|
14 |
+
/**
|
15 |
+
* @todo specify there all relations for properties depending on input type
|
16 |
+
*/
|
17 |
+
$inputTypes = array(
|
18 |
+
'multiselect' => array(
|
19 |
+
'backend_model' => 'eav/entity_attribute_backend_array'
|
20 |
+
),
|
21 |
+
'boolean' => array(
|
22 |
+
'source_model' => 'eav/entity_attribute_source_boolean'
|
23 |
+
)
|
24 |
+
);
|
25 |
+
|
26 |
+
if (is_null($inputType)) {
|
27 |
+
return $inputTypes;
|
28 |
+
} else if (isset($inputTypes[$inputType])) {
|
29 |
+
return $inputTypes[$inputType];
|
30 |
+
}
|
31 |
+
return array();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Return default attribute source model by input type
|
36 |
+
*
|
37 |
+
* @param string $inputType
|
38 |
+
* @return string|null
|
39 |
+
*/
|
40 |
+
public function getAttributeSourceModelByInputType($inputType) {
|
41 |
+
$inputTypes = $this->getAttributeInputTypes();
|
42 |
+
if (!empty($inputTypes[$inputType]['source_model'])) {
|
43 |
+
return $inputTypes[$inputType]['source_model'];
|
44 |
+
}
|
45 |
+
return null;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Return default attribute backend model by input type
|
50 |
+
*
|
51 |
+
* @param string $inputType
|
52 |
+
* @return string|null
|
53 |
+
*/
|
54 |
+
public function getAttributeBackendModelByInputType($inputType)
|
55 |
+
{
|
56 |
+
$inputTypes = $this->getAttributeInputTypes();
|
57 |
+
if (!empty($inputTypes[$inputType]['backend_model'])) {
|
58 |
+
return $inputTypes[$inputType]['backend_model'];
|
59 |
+
}
|
60 |
+
return null;
|
61 |
+
}
|
62 |
+
}
|
app/code/community/Officience/CustomerAttribute/Helper/Field.php
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Helper_Field {
|
4 |
+
|
5 |
+
public function getFieldDeFault() {
|
6 |
+
return array('firstname',
|
7 |
+
'lastname',
|
8 |
+
'group_id',
|
9 |
+
'created_in',
|
10 |
+
'customer_work',
|
11 |
+
'website_id',
|
12 |
+
'email',
|
13 |
+
'prefix',
|
14 |
+
'middlename',
|
15 |
+
'taxvat',
|
16 |
+
'suffix',
|
17 |
+
'dob',
|
18 |
+
'gender',
|
19 |
+
'created_at');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function renderField($type, $attributes) {
|
23 |
+
$html = '';
|
24 |
+
if (in_array($type, array('boolean', 'text', 'date'))) {
|
25 |
+
$types = '';
|
26 |
+
if ($type == 'date') {
|
27 |
+
$types = 'text';
|
28 |
+
} else {
|
29 |
+
$types = $type;
|
30 |
+
}
|
31 |
+
$html.= '<input type="' . $types . '" ';
|
32 |
+
$html .= $this->setAttributeField($type, $attributes);
|
33 |
+
if ($type == 'date') {
|
34 |
+
$html .= ' style="width:120px !important;" ';
|
35 |
+
}
|
36 |
+
$html .= $this->classRequireField($type, $attributes);
|
37 |
+
$html .=' />';
|
38 |
+
if ($type == 'date') {
|
39 |
+
$idDate = ($attributes['id'] ? $attributes['id'] . '_trig' : '');
|
40 |
+
$html .= '<img id="' . $idDate . '" class="v-middle" style="" title="Select Date" alt="" src="' . (Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/base/default/images/calendar.gif') . '">';
|
41 |
+
$html .='<script type="text/javascript">
|
42 |
+
Calendar.setup({
|
43 |
+
inputField: "' . $attributes['id'] . '",
|
44 |
+
ifFormat: "' . Varien_Date::convertZendToStrFtime(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), true, false) . '",
|
45 |
+
showsTime: false,
|
46 |
+
button: "' . $idDate . '",
|
47 |
+
align: "Bl",
|
48 |
+
singleClick : true
|
49 |
+
});
|
50 |
+
|
51 |
+
</script>';
|
52 |
+
}
|
53 |
+
} elseif (in_array($type, array('select', 'multiselect'))) {
|
54 |
+
$html .= '<select';
|
55 |
+
if ($type == 'multiselect') {
|
56 |
+
$html .= ' multiple="multiple" ';
|
57 |
+
}
|
58 |
+
$html .= $this->setAttributeField($type, $attributes);
|
59 |
+
$html .= $this->classRequireField($type, $attributes);
|
60 |
+
$html .=" >";
|
61 |
+
$html .=$this->setValueFieldSelect($type, $attributes);
|
62 |
+
$html .= '</select>';
|
63 |
+
} elseif ($type == 'textarea') {
|
64 |
+
$html .='<textarea';
|
65 |
+
$html .= $this->setAttributeField($type, $attributes);
|
66 |
+
$html .= $this->classRequireField($type, $attributes);
|
67 |
+
$html .= '>';
|
68 |
+
$html .=$attributes['value'];
|
69 |
+
$html .='</textarea>';
|
70 |
+
}
|
71 |
+
return $html;
|
72 |
+
}
|
73 |
+
|
74 |
+
public function classRequireField($type, $attributes) {
|
75 |
+
$class = ' class = " ';
|
76 |
+
if ($type == 'text') {
|
77 |
+
$class .= ' input-text ';
|
78 |
+
}
|
79 |
+
$class .= ($attributes['is_required'] ? 'required-entry' : " ");
|
80 |
+
$class .= ' ' . ($attributes['frontend_class'] ? $attributes['frontend_class'] : ' ');
|
81 |
+
$class .= ' "';
|
82 |
+
return $class;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function setValueFieldSelect($type, $attributes) {
|
86 |
+
$html = '';
|
87 |
+
if ($type == 'multiselect') {
|
88 |
+
$arrValue = explode(',', $attributes['value']);
|
89 |
+
foreach ($attributes['values'] as $value) {
|
90 |
+
if ($value['label']) {
|
91 |
+
$html .='<option ';
|
92 |
+
if (in_array($value['value'], $arrValue)) {
|
93 |
+
$html.=' selected="selected" ';
|
94 |
+
}
|
95 |
+
$html .=' value="' . (($value['value'] != '') ? $value['value'] : '0') . '">';
|
96 |
+
$html .= $value['label'];
|
97 |
+
$html .= '</option>';
|
98 |
+
}
|
99 |
+
}
|
100 |
+
} else {
|
101 |
+
foreach ($attributes['values'] as $value) {
|
102 |
+
if ($value['label']) {
|
103 |
+
$html .='<option ';
|
104 |
+
if ($attributes['value'] == $value['value']) {
|
105 |
+
$html.=' selected="selected" ';
|
106 |
+
}
|
107 |
+
$html .=' value="' . (($value['value'] != '') ? $value['value'] : '0') . '">';
|
108 |
+
$html .= $value['label'];
|
109 |
+
$html .= '</option>';
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
return $html;
|
114 |
+
}
|
115 |
+
|
116 |
+
public function setAttributeField($type, $attributes) {
|
117 |
+
$html = '';
|
118 |
+
foreach ($attributes as $key => $attribute) {
|
119 |
+
if (!in_array($key, array('frontend_class', 'values', 'is_required'))) {
|
120 |
+
if (in_array($type, array('textarea', 'select', 'multiselect')) && in_array($key, array('value'))) {
|
121 |
+
|
122 |
+
continue;
|
123 |
+
}
|
124 |
+
|
125 |
+
$html.= ' ' . $key . '="' . ($attribute ? $attribute : '') . '" ';
|
126 |
+
}
|
127 |
+
}
|
128 |
+
return $html;
|
129 |
+
}
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Helper/Form.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Helper_Form extends Mage_Core_Helper_Abstract {
|
4 |
+
|
5 |
+
public function getListForm($form) {
|
6 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
|
7 |
+
$customerForm = Mage::getModel('customer/form')
|
8 |
+
->setFormCode($form);
|
9 |
+
$attributes = $customerForm->getAttributes();
|
10 |
+
} else {
|
11 |
+
$configs = Mage::getModel('customerattribute/officustomerattribute')->getCollection()
|
12 |
+
->addFieldToFilter('form_code', $form);
|
13 |
+
$arrForm = array();
|
14 |
+
foreach ($configs->getData() as $valueform) {
|
15 |
+
$arrForm[] = $valueform['attribute_code'];
|
16 |
+
}
|
17 |
+
$attributes = Mage::getResourceModel('customer/attribute_collection')
|
18 |
+
->setEntityTypeFilter(Mage::getModel('eav/entity')->setType('customer')->getTypeId())
|
19 |
+
->addVisibleFilter()
|
20 |
+
->addFieldToFilter('attribute_code', array('in' => $arrForm))
|
21 |
+
;
|
22 |
+
}
|
23 |
+
return $attributes;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getFormInput() {
|
27 |
+
return array(
|
28 |
+
'customer_account_create',
|
29 |
+
'customer_account_edit'
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Model/Customerattribute.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Model_CustomerAttribute extends Mage_Eav_Model_Entity_Attribute
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
|
9 |
+
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _beforeSave()
|
13 |
+
{
|
14 |
+
if ( $this->getFrontendInput()=="image"){
|
15 |
+
$this->setBackendModel('catalog/category_attribute_backend_image');
|
16 |
+
$this->setBackendType('varchar');
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( $this->getFrontendInput()=="date"){
|
20 |
+
$this->setBackendModel('eav/entity_attribute_backend_datetime');
|
21 |
+
$this->setBackendType('datetime');
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( $this->getFrontendInput()=="textarea" ){
|
25 |
+
|
26 |
+
$this->setBackendType('text');
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( $this->getFrontendInput()=="text" ){
|
30 |
+
|
31 |
+
$this->setBackendType('varchar');
|
32 |
+
}
|
33 |
+
|
34 |
+
if ( ($this->getFrontendInput()=="multiselect" || $this->getFrontendInput()=="select") ){
|
35 |
+
$this->setData('source_model', 'eav/entity_attribute_source_table');
|
36 |
+
$this->setBackendType('varchar');
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
if ($this->getFrontendInput()=="boolean"){
|
42 |
+
$this->setFrontendInput("select");
|
43 |
+
$this->setBackendType('int');
|
44 |
+
$this->setData('source_model', 'eav/entity_attribute_source_boolean');
|
45 |
+
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
return parent::_beforeSave();
|
50 |
+
}
|
51 |
+
}
|
52 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Model/Mysql4/Officustomerattribute.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Model_Mysql4_Officustomerattribute extends Mage_Core_Model_Mysql4_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
$this->_init('customerattribute/officustomerattribute', array('form_code','attribute_id'));
|
7 |
+
}
|
8 |
+
|
9 |
+
}
|
10 |
+
|
11 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Model/Mysql4/Officustomerattribute/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Officience_CustomerAttribute_Model_Mysql4_Officustomerattribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct() {
|
5 |
+
parent::_construct();
|
6 |
+
$this->_init('customerattribute/officustomerattribute');
|
7 |
+
}
|
8 |
+
}
|
9 |
+
?>
|
app/code/community/Officience/CustomerAttribute/Model/Officustomerattribute.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Model_Officustomerattribute extends Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('customerattribute/officustomerattribute');
|
8 |
+
}
|
9 |
+
}
|
10 |
+
?>
|
app/code/community/Officience/CustomerAttribute/controllers/AccountController.php
ADDED
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Customer/controllers/AccountController.php';
|
4 |
+
|
5 |
+
class Officience_CustomerAttribute_AccountController extends Mage_Customer_AccountController {
|
6 |
+
|
7 |
+
public function createPostAction() {
|
8 |
+
$session = $this->_getSession();
|
9 |
+
if ($session->isLoggedIn()) {
|
10 |
+
$this->_redirect('*/*/');
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
$session->setEscapeMessages(true); // prevent XSS injection in user input
|
14 |
+
|
15 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
|
16 |
+
|
17 |
+
if ($this->getRequest()->isPost()) {
|
18 |
+
$errors = array();
|
19 |
+
|
20 |
+
if (!$customer = Mage::registry('current_customer')) {
|
21 |
+
$customer = Mage::getModel('customer/customer')->setId(null);
|
22 |
+
}
|
23 |
+
|
24 |
+
/* @var $customerForm Mage_Customer_Model_Form */
|
25 |
+
$customerForm = Mage::getModel('customer/form');
|
26 |
+
$customerForm->setFormCode('customer_account_create')
|
27 |
+
->setEntity($customer);
|
28 |
+
|
29 |
+
$customerData = $customerForm->extractData($this->getRequest());
|
30 |
+
|
31 |
+
if ($this->getRequest()->getParam('is_subscribed', false)) {
|
32 |
+
$customer->setIsSubscribed(1);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Initialize customer group id
|
37 |
+
*/
|
38 |
+
$customer->getGroupId();
|
39 |
+
|
40 |
+
if ($this->getRequest()->getPost('create_address')) {
|
41 |
+
/* @var $address Mage_Customer_Model_Address */
|
42 |
+
$address = Mage::getModel('customer/address');
|
43 |
+
/* @var $addressForm Mage_Customer_Model_Form */
|
44 |
+
$addressForm = Mage::getModel('customer/form');
|
45 |
+
$addressForm->setFormCode('customer_register_address')
|
46 |
+
->setEntity($address);
|
47 |
+
|
48 |
+
$addressData = $addressForm->extractData($this->getRequest(), 'address', false);
|
49 |
+
$addressErrors = $addressForm->validateData($addressData);
|
50 |
+
if ($addressErrors === true) {
|
51 |
+
$address->setId(null)
|
52 |
+
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
53 |
+
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
|
54 |
+
$addressForm->compactData($addressData);
|
55 |
+
$customer->addAddress($address);
|
56 |
+
|
57 |
+
$addressErrors = $address->validate();
|
58 |
+
if (is_array($addressErrors)) {
|
59 |
+
$errors = array_merge($errors, $addressErrors);
|
60 |
+
}
|
61 |
+
} else {
|
62 |
+
$errors = array_merge($errors, $addressErrors);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
try {
|
67 |
+
$customerErrors = $customerForm->validateData($customerData);
|
68 |
+
if ($customerErrors !== true) {
|
69 |
+
$errors = array_merge($customerErrors, $errors);
|
70 |
+
} else {
|
71 |
+
$customerForm->compactData($customerData);
|
72 |
+
$customer->setPassword($this->getRequest()->getPost('password'));
|
73 |
+
$customer->setConfirmation($this->getRequest()->getPost('confirmation'));
|
74 |
+
$customerErrors = $customer->validate();
|
75 |
+
if (is_array($customerErrors)) {
|
76 |
+
$errors = array_merge($customerErrors, $errors);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$validationResult = count($errors) == 0;
|
81 |
+
|
82 |
+
if (true === $validationResult) {
|
83 |
+
$customer->save();
|
84 |
+
|
85 |
+
if ($customer->isConfirmationRequired()) {
|
86 |
+
$customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl());
|
87 |
+
$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
|
88 |
+
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
|
89 |
+
return;
|
90 |
+
} else {
|
91 |
+
$session->setCustomerAsLoggedIn($customer);
|
92 |
+
$url = $this->_welcomeCustomer($customer);
|
93 |
+
$this->_redirectSuccess($url);
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
98 |
+
if (is_array($errors)) {
|
99 |
+
foreach ($errors as $errorMessage) {
|
100 |
+
$session->addError($errorMessage);
|
101 |
+
}
|
102 |
+
} else {
|
103 |
+
$session->addError($this->__('Invalid customer data'));
|
104 |
+
}
|
105 |
+
}
|
106 |
+
} catch (Mage_Core_Exception $e) {
|
107 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
108 |
+
if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
|
109 |
+
$url = Mage::getUrl('customer/account/forgotpassword');
|
110 |
+
$message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
|
111 |
+
$session->setEscapeMessages(false);
|
112 |
+
} else {
|
113 |
+
$message = $e->getMessage();
|
114 |
+
}
|
115 |
+
$session->addError($message);
|
116 |
+
} catch (Exception $e) {
|
117 |
+
$session->setCustomerFormData($this->getRequest()->getPost())
|
118 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
123 |
+
} else {
|
124 |
+
if ($this->getRequest()->isPost()) {
|
125 |
+
$errors = array();
|
126 |
+
|
127 |
+
if (!$customer = Mage::registry('current_customer')) {
|
128 |
+
$customer = Mage::getModel('customer/customer')->setId(null);
|
129 |
+
}
|
130 |
+
|
131 |
+
$data = $this->_filterPostData($this->getRequest()->getPost());
|
132 |
+
$fields = Mage::getModel('customerattribute/officustomerattribute')->getCollection()
|
133 |
+
->addFieldToFilter('form_code', 'customer_account_create')
|
134 |
+
->getData();
|
135 |
+
foreach ($fields as $node) {
|
136 |
+
$attributeCode = $node['attribute_code'];
|
137 |
+
if (isset($data[$attributeCode])) {
|
138 |
+
if ($attributeCode == 'email') {
|
139 |
+
$data[$attributeCode] = trim($data[$attributeCode]);
|
140 |
+
}
|
141 |
+
$customer->setData($attributeCode, $data[$attributeCode]);
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
if ($this->getRequest()->getParam('is_subscribed', false)) {
|
146 |
+
$customer->setIsSubscribed(1);
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Initialize customer group id
|
151 |
+
*/
|
152 |
+
$customer->getGroupId();
|
153 |
+
|
154 |
+
if ($this->getRequest()->getPost('create_address')) {
|
155 |
+
$address = Mage::getModel('customer/address')
|
156 |
+
->setData($this->getRequest()->getPost())
|
157 |
+
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
|
158 |
+
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false))
|
159 |
+
->setId(null);
|
160 |
+
$customer->addAddress($address);
|
161 |
+
|
162 |
+
$errors = $address->validate();
|
163 |
+
if (!is_array($errors)) {
|
164 |
+
$errors = array();
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
try {
|
169 |
+
$validationCustomer = $customer->validate();
|
170 |
+
if (is_array($validationCustomer)) {
|
171 |
+
$errors = array_merge($validationCustomer, $errors);
|
172 |
+
}
|
173 |
+
$validationResult = count($errors) == 0;
|
174 |
+
|
175 |
+
if (true === $validationResult) {
|
176 |
+
$customer->save();
|
177 |
+
|
178 |
+
if ($customer->isConfirmationRequired()) {
|
179 |
+
$customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl());
|
180 |
+
$session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));
|
181 |
+
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure' => true)));
|
182 |
+
return;
|
183 |
+
} else {
|
184 |
+
$session->setCustomerAsLoggedIn($customer);
|
185 |
+
$url = $this->_welcomeCustomer($customer);
|
186 |
+
$this->_redirectSuccess($url);
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
} else {
|
190 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
191 |
+
if (is_array($errors)) {
|
192 |
+
foreach ($errors as $errorMessage) {
|
193 |
+
$session->addError($errorMessage);
|
194 |
+
}
|
195 |
+
} else {
|
196 |
+
$session->addError($this->__('Invalid customer data'));
|
197 |
+
}
|
198 |
+
}
|
199 |
+
} catch (Mage_Core_Exception $e) {
|
200 |
+
$session->setCustomerFormData($this->getRequest()->getPost());
|
201 |
+
if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
|
202 |
+
$url = Mage::getUrl('customer/account/forgotpassword');
|
203 |
+
$message = $this->__('There is already an account with this email address. If you are sure that it is your email address, <a href="%s">click here</a> to get your password and access your account.', $url);
|
204 |
+
$session->setEscapeMessages(false);
|
205 |
+
} else {
|
206 |
+
$message = $e->getMessage();
|
207 |
+
}
|
208 |
+
$session->addError($message);
|
209 |
+
} catch (Exception $e) {
|
210 |
+
$session->setCustomerFormData($this->getRequest()->getPost())
|
211 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
212 |
+
}
|
213 |
+
}
|
214 |
+
$this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
public function editPostAction() {
|
219 |
+
if (!$this->_validateFormKey()) {
|
220 |
+
return $this->_redirect('*/*/edit');
|
221 |
+
}
|
222 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
|
223 |
+
|
224 |
+
if ($this->getRequest()->isPost()) {
|
225 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
226 |
+
$customer = $this->_getSession()->getCustomer();
|
227 |
+
|
228 |
+
/** @var $customerForm Mage_Customer_Model_Form */
|
229 |
+
$customerForm = Mage::getModel('customer/form');
|
230 |
+
$customerForm->setFormCode('customer_account_edit')
|
231 |
+
->setEntity($customer);
|
232 |
+
|
233 |
+
$customerData = $customerForm->extractData($this->getRequest());
|
234 |
+
|
235 |
+
$errors = array();
|
236 |
+
$customerErrors = $customerForm->validateData($customerData);
|
237 |
+
if ($customerErrors !== true) {
|
238 |
+
$errors = array_merge($customerErrors, $errors);
|
239 |
+
} else {
|
240 |
+
$customerForm->compactData($customerData);
|
241 |
+
$errors = array();
|
242 |
+
|
243 |
+
// If password change was requested then add it to common validation scheme
|
244 |
+
if ($this->getRequest()->getParam('change_password')) {
|
245 |
+
$currPass = $this->getRequest()->getPost('current_password');
|
246 |
+
$newPass = $this->getRequest()->getPost('password');
|
247 |
+
$confPass = $this->getRequest()->getPost('confirmation');
|
248 |
+
|
249 |
+
$oldPass = $this->_getSession()->getCustomer()->getPasswordHash();
|
250 |
+
if (Mage::helper('core/string')->strpos($oldPass, ':')) {
|
251 |
+
list($_salt, $salt) = explode(':', $oldPass);
|
252 |
+
} else {
|
253 |
+
$salt = false;
|
254 |
+
}
|
255 |
+
|
256 |
+
if ($customer->hashPassword($currPass, $salt) == $oldPass) {
|
257 |
+
if (strlen($newPass)) {
|
258 |
+
/**
|
259 |
+
* Set entered password and its confirmation - they
|
260 |
+
* will be validated later to match each other and be of right length
|
261 |
+
*/
|
262 |
+
$customer->setPassword($newPass);
|
263 |
+
$customer->setConfirmation($confPass);
|
264 |
+
} else {
|
265 |
+
$errors[] = $this->__('New password field cannot be empty.');
|
266 |
+
}
|
267 |
+
} else {
|
268 |
+
$errors[] = $this->__('Invalid current password');
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
// Validate account and compose list of errors if any
|
273 |
+
$customerErrors = $customer->validate();
|
274 |
+
if (is_array($customerErrors)) {
|
275 |
+
$errors = array_merge($errors, $customerErrors);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
if (!empty($errors)) {
|
280 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
|
281 |
+
foreach ($errors as $message) {
|
282 |
+
$this->_getSession()->addError($message);
|
283 |
+
}
|
284 |
+
$this->_redirect('*/*/edit');
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
try {
|
289 |
+
$customer->setConfirmation(null);
|
290 |
+
$customer->save();
|
291 |
+
$this->_getSession()->setCustomer($customer)
|
292 |
+
->addSuccess($this->__('The account information has been saved.'));
|
293 |
+
|
294 |
+
$this->_redirect('customer/account');
|
295 |
+
return;
|
296 |
+
} catch (Mage_Core_Exception $e) {
|
297 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
298 |
+
->addError($e->getMessage());
|
299 |
+
} catch (Exception $e) {
|
300 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
301 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
$this->_redirect('*/*/edit');
|
306 |
+
} else {
|
307 |
+
|
308 |
+
|
309 |
+
if ($this->getRequest()->isPost()) {
|
310 |
+
$customer = Mage::getModel('customer/customer')
|
311 |
+
->setId($this->_getSession()->getCustomerId())
|
312 |
+
->setWebsiteId($this->_getSession()->getCustomer()->getWebsiteId());
|
313 |
+
|
314 |
+
|
315 |
+
$data = $this->_filterPostData($this->getRequest()->getPost());
|
316 |
+
$fields = Mage::getModel('customerattribute/officustomerattribute')->getCollection()
|
317 |
+
->addFieldToFilter('form_code', 'customer_account_edit')
|
318 |
+
->getData();
|
319 |
+
foreach ($fields as $node) {
|
320 |
+
$attributeCode = $node['attribute_code'];
|
321 |
+
if (isset($data[$attributeCode])) {
|
322 |
+
if ($attributeCode == 'email') {
|
323 |
+
$data[$attributeCode] = trim($data[$attributeCode]);
|
324 |
+
}
|
325 |
+
$customer->setData($attributeCode, $data[$attributeCode]);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
$errors = $customer->validate();
|
330 |
+
if (!is_array($errors)) {
|
331 |
+
$errors = array();
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* we would like to preserver the existing group id
|
336 |
+
*/
|
337 |
+
if ($this->_getSession()->getCustomerGroupId()) {
|
338 |
+
$customer->setGroupId($this->_getSession()->getCustomerGroupId());
|
339 |
+
}
|
340 |
+
|
341 |
+
if ($this->getRequest()->getParam('change_password')) {
|
342 |
+
$currPass = $this->getRequest()->getPost('current_password');
|
343 |
+
$newPass = $this->getRequest()->getPost('password');
|
344 |
+
$confPass = $this->getRequest()->getPost('confirmation');
|
345 |
+
|
346 |
+
if (empty($currPass) || empty($newPass) || empty($confPass)) {
|
347 |
+
$errors[] = $this->__('The password fields cannot be empty.');
|
348 |
+
}
|
349 |
+
|
350 |
+
if ($newPass != $confPass) {
|
351 |
+
$errors[] = $this->__('Please make sure your passwords match.');
|
352 |
+
}
|
353 |
+
|
354 |
+
$oldPass = $this->_getSession()->getCustomer()->getPasswordHash();
|
355 |
+
if (strpos($oldPass, ':')) {
|
356 |
+
list($_salt, $salt) = explode(':', $oldPass);
|
357 |
+
} else {
|
358 |
+
$salt = false;
|
359 |
+
}
|
360 |
+
|
361 |
+
if ($customer->hashPassword($currPass, $salt) == $oldPass) {
|
362 |
+
$customer->setPassword($newPass);
|
363 |
+
} else {
|
364 |
+
$errors[] = $this->__('Invalid current password');
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
if (!empty($errors)) {
|
369 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
|
370 |
+
foreach ($errors as $message) {
|
371 |
+
$this->_getSession()->addError($message);
|
372 |
+
}
|
373 |
+
$this->_redirect('*/*/edit');
|
374 |
+
return $this;
|
375 |
+
}
|
376 |
+
|
377 |
+
try {
|
378 |
+
$customer->save();
|
379 |
+
$this->_getSession()->setCustomer($customer)
|
380 |
+
->addSuccess($this->__('The account information has been saved.'));
|
381 |
+
|
382 |
+
$this->_redirect('customer/account');
|
383 |
+
return;
|
384 |
+
} catch (Mage_Core_Exception $e) {
|
385 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
386 |
+
->addError($e->getMessage());
|
387 |
+
} catch (Exception $e) {
|
388 |
+
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost())
|
389 |
+
->addException($e, $this->__('Cannot save the customer.'));
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
$this->_redirect('*/*/edit');
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
}
|
app/code/community/Officience/CustomerAttribute/controllers/Adminhtml/IndexController.php
ADDED
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Officience_CustomerAttribute_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
protected $_entityTypeId;
|
6 |
+
|
7 |
+
public function preDispatch() {
|
8 |
+
parent::preDispatch();
|
9 |
+
$this->_entityTypeId = Mage::getModel('eav/entity')->setType('Customer')->getTypeId();
|
10 |
+
}
|
11 |
+
|
12 |
+
protected function _initAction() {
|
13 |
+
$this->loadLayout()
|
14 |
+
->_setActiveMenu('customer/customer')
|
15 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Customer Attributes Manager'), Mage::helper('adminhtml')->__('Customer Attributes Manager'));
|
16 |
+
return $this;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function indexAction() {
|
20 |
+
$this->_initAction()->_addContent($this->getLayout()->createBlock('customerattribute/adminhtml_Grid'));
|
21 |
+
$this->renderLayout();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function newAction() {
|
25 |
+
$this->_forward('edit');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function editAction() {
|
29 |
+
$id = $this->getRequest()->getParam('attribute_id');
|
30 |
+
$model = Mage::getModel('eav/entity_attribute');
|
31 |
+
if ($id) {
|
32 |
+
$model->load($id);
|
33 |
+
|
34 |
+
if (!$model->getId()) {
|
35 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
36 |
+
Mage::helper('customerattribute')->__('This attribute no longer exists'));
|
37 |
+
$this->_redirect('*/*/');
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
+
// entity type check
|
42 |
+
if ($model->getEntityTypeId() != $this->_entityTypeId) {
|
43 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
44 |
+
Mage::helper('customerattribute')->__('This attribute cannot be edited.'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
+
//get Used in forms
|
50 |
+
if (version_compare(Mage::getVersion(), '1.4.2.0', '>=')) {
|
51 |
+
$config = Mage::getSingleton('eav/config')
|
52 |
+
->getAttribute('customer', $model->getAttributeCode());
|
53 |
+
$model->addData(array('used_in_forms' => $config->getUsedInForms()));
|
54 |
+
} else {
|
55 |
+
$config = Mage::getModel('customerattribute/officustomerattribute')->getCollection()
|
56 |
+
->addFieldToFilter('attribute_code', $model->getAttributeCode());
|
57 |
+
$arr_used_in_forms = array();
|
58 |
+
foreach ($config->getData() as $formfield) {
|
59 |
+
$arr_used_in_forms[] = $formfield['form_code'];
|
60 |
+
}
|
61 |
+
$model->addData(array('used_in_forms' => $arr_used_in_forms));
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// set entered data if was error when we do save
|
66 |
+
$data = Mage::getSingleton('adminhtml/session')->getAttributeData(true);
|
67 |
+
|
68 |
+
if (!empty($data)) {
|
69 |
+
$model->addData($data);
|
70 |
+
}
|
71 |
+
|
72 |
+
Mage::register('entity_attribute', $model);
|
73 |
+
|
74 |
+
$this->_initAction();
|
75 |
+
|
76 |
+
$this->_title($id ? $model->getName() : $this->__('New Attribute'));
|
77 |
+
|
78 |
+
$item = $id ? Mage::helper('customerattribute')->__('Edit Customer Attribute') : Mage::helper('customerattribute')->__('New Customer Attribute');
|
79 |
+
|
80 |
+
$this->_addBreadcrumb($item, $item);
|
81 |
+
|
82 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
83 |
+
|
84 |
+
$this
|
85 |
+
->_addContent($this->getLayout()->createBlock('customerattribute/adminhtml_edit'))
|
86 |
+
->_addLeft($this->getLayout()->createBlock('customerattribute/adminhtml_edit_tabs'))
|
87 |
+
;
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
$this->renderLayout();
|
92 |
+
}
|
93 |
+
|
94 |
+
public function validateAction() {
|
95 |
+
$response = new Varien_Object();
|
96 |
+
$response->setError(false);
|
97 |
+
$attributeCode = $this->getRequest()->getParam('attribute_code');
|
98 |
+
$attributeId = $this->getRequest()->getParam('attribute_id');
|
99 |
+
$attribute = Mage::getModel('eav/entity_attribute')
|
100 |
+
->loadByCode($this->_entityTypeId, $attributeCode);
|
101 |
+
|
102 |
+
|
103 |
+
if ($attribute->getId() && !$attributeId) {
|
104 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
105 |
+
Mage::helper('customerattribute')->__('Attribute with the same code already exists'));
|
106 |
+
$this->_initLayoutMessages('adminhtml/session');
|
107 |
+
$response->setError(true);
|
108 |
+
$response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
|
109 |
+
}
|
110 |
+
|
111 |
+
$this->getResponse()->setBody($response->toJson());
|
112 |
+
}
|
113 |
+
|
114 |
+
public function saveAction() {
|
115 |
+
|
116 |
+
$data = $this->getRequest()->getPost();
|
117 |
+
if ($data) {
|
118 |
+
/** @var $session Mage_Admin_Model_Session */
|
119 |
+
$session = Mage::getSingleton('adminhtml/session');
|
120 |
+
|
121 |
+
$redirectBack = $this->getRequest()->getParam('back', false);
|
122 |
+
/* @var $model Mage_Catalog_Model_Entity_Attribute */
|
123 |
+
$model = Mage::getModel('customerattribute/customerattribute');
|
124 |
+
/* @var $helper Mage_Catalog_Helper_Product */
|
125 |
+
$helper = Mage::helper('customerattribute');
|
126 |
+
|
127 |
+
$id = $this->getRequest()->getParam('attribute_id');
|
128 |
+
|
129 |
+
//validate attribute_code
|
130 |
+
if (isset($data['attribute_code'])) {
|
131 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
|
132 |
+
$validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^[a-z_]{1,255}$/'));
|
133 |
+
if (!$validatorAttrCode->isValid($data['attribute_code'])) {
|
134 |
+
$session->addError(
|
135 |
+
$helper->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'));
|
136 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
} else {
|
140 |
+
if (!preg_match('/^[a-z_]{1,255}$/', $data['attribute_code'])) {
|
141 |
+
$session->addError(
|
142 |
+
$helper->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'));
|
143 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
|
144 |
+
return;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
//validate frontend_input
|
151 |
+
if (isset($data['frontend_input'])) {
|
152 |
+
if (version_compare(Mage::getVersion(), '1.5.1', '>=')) {
|
153 |
+
/** @var $validatorInputType Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator */
|
154 |
+
$validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator');
|
155 |
+
if (!$validatorInputType->isValid($data['frontend_input'])) {
|
156 |
+
foreach ($validatorInputType->getMessages() as $message) {
|
157 |
+
$session->addError($message);
|
158 |
+
}
|
159 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
} else {
|
163 |
+
if (!in_array($data['frontend_input'], array('text', 'textarea', 'date', 'boolean', 'multiselect', 'select'))) {
|
164 |
+
$session->addError('Error1');
|
165 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
|
166 |
+
return;
|
167 |
+
}
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
if ($id) {
|
172 |
+
$model->load($id);
|
173 |
+
|
174 |
+
if (!$model->getId()) {
|
175 |
+
$session->addError(
|
176 |
+
Mage::helper('customerattribute')->__('This Attribute no longer exists'));
|
177 |
+
$this->_redirect('*/*/');
|
178 |
+
return;
|
179 |
+
}
|
180 |
+
|
181 |
+
// entity type check
|
182 |
+
if ($model->getEntityTypeId() != $this->_entityTypeId) {
|
183 |
+
$session->addError(
|
184 |
+
Mage::helper('customerattribute')->__('This attribute cannot be updated.'));
|
185 |
+
$session->setAttributeData($data);
|
186 |
+
$this->_redirect('*/*/');
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
+
$data['attribute_code'] = $model->getAttributeCode();
|
191 |
+
$data['is_user_defined'] = $model->getIsUserDefined();
|
192 |
+
$data['frontend_input'] = $model->getFrontendInput();
|
193 |
+
} else {
|
194 |
+
/**
|
195 |
+
* @todo add to helper and specify all relations for properties
|
196 |
+
*/
|
197 |
+
$data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']);
|
198 |
+
$data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']);
|
199 |
+
}
|
200 |
+
|
201 |
+
if (!isset($data['is_configurable'])) {
|
202 |
+
$data['is_configurable'] = 0;
|
203 |
+
}
|
204 |
+
if (!isset($data['is_filterable'])) {
|
205 |
+
$data['is_filterable'] = 0;
|
206 |
+
}
|
207 |
+
if (!isset($data['is_filterable_in_search'])) {
|
208 |
+
$data['is_filterable_in_search'] = 0;
|
209 |
+
}
|
210 |
+
|
211 |
+
if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
|
212 |
+
$data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
|
213 |
+
}
|
214 |
+
|
215 |
+
$defaultValueField = $model->getDefaultValueByInput($data['frontend_input']);
|
216 |
+
if ($defaultValueField) {
|
217 |
+
$data['default_value'] = $this->getRequest()->getParam($defaultValueField);
|
218 |
+
}
|
219 |
+
|
220 |
+
if (!isset($data['apply_to'])) {
|
221 |
+
$data['apply_to'] = array();
|
222 |
+
}
|
223 |
+
|
224 |
+
//filter
|
225 |
+
$data = $this->_filterPostData($data);
|
226 |
+
|
227 |
+
$model->addData($data);
|
228 |
+
|
229 |
+
if (!$id) {
|
230 |
+
$model->setEntityTypeId($this->_entityTypeId);
|
231 |
+
$model->setIsUserDefined(1);
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
if ($this->getRequest()->getParam('set') && $this->getRequest()->getParam('group')) {
|
236 |
+
// For creating product attribute on product page we need specify attribute set and group
|
237 |
+
$model->setAttributeSetId($this->getRequest()->getParam('set'));
|
238 |
+
$model->setAttributeGroupId($this->getRequest()->getParam('group'));
|
239 |
+
}
|
240 |
+
|
241 |
+
try {
|
242 |
+
$model->save();
|
243 |
+
$used_in_forms = $this->getRequest()->getParam('used_in_forms');
|
244 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
|
245 |
+
if ($model->getId() && is_array($used_in_forms)) {
|
246 |
+
Mage::getSingleton('eav/config')
|
247 |
+
->getAttribute('customer', $model->getAttributeCode())
|
248 |
+
->setData('used_in_forms', $used_in_forms)
|
249 |
+
->save();
|
250 |
+
}
|
251 |
+
} else {
|
252 |
+
if ($model->getId()) {
|
253 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
254 |
+
$condition = $connection->quoteInto('attribute_code = ?', $data['attribute_code']);
|
255 |
+
$table = Mage::getSingleton('core/resource')->getTableName('officustomerattribute');
|
256 |
+
$connection->delete($table, $condition);
|
257 |
+
foreach ($used_in_forms as $valueattr) {
|
258 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
|
259 |
+
$fields = array('form_code' => $valueattr, 'attribute_code' => $data['attribute_code']);
|
260 |
+
$connection->insert($table, $fields);
|
261 |
+
$connection->commit();
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
$session->addSuccess(
|
266 |
+
Mage::helper('customerattribute')->__('The product attribute has been saved.'));
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Clear translation cache because attribute labels are stored in translation
|
270 |
+
*/
|
271 |
+
Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
|
272 |
+
$session->setAttributeData(false);
|
273 |
+
if ($this->getRequest()->getParam('popup')) {
|
274 |
+
$this->_redirect('adminhtml/catalog_product/addAttribute', array(
|
275 |
+
'id' => $this->getRequest()->getParam('product'),
|
276 |
+
'attribute' => $model->getId(),
|
277 |
+
'_current' => true
|
278 |
+
));
|
279 |
+
} elseif ($redirectBack) {
|
280 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $model->getId(), '_current' => true));
|
281 |
+
} else {
|
282 |
+
$this->_redirect('*/*/', array());
|
283 |
+
}
|
284 |
+
return;
|
285 |
+
} catch (Exception $e) {
|
286 |
+
$session->addError($e->getMessage());
|
287 |
+
$session->setAttributeData($data);
|
288 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true));
|
289 |
+
return;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
$this->_redirect('*/*/');
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Filter post data
|
297 |
+
*
|
298 |
+
* @param array $data
|
299 |
+
* @return array
|
300 |
+
*/
|
301 |
+
protected function _filterPostData($data) {
|
302 |
+
if ($data) {
|
303 |
+
/** @var $helperCatalog Mage_Catalog_Helper_Data */
|
304 |
+
$helperCatalog = Mage::helper('customerattribute');
|
305 |
+
//labels
|
306 |
+
foreach ($data['frontend_label'] as & $value) {
|
307 |
+
if ($value) {
|
308 |
+
$value = $helperCatalog->stripTags($value);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
//options
|
312 |
+
if (!empty($data['option']['value'])) {
|
313 |
+
foreach ($data['option']['value'] as &$options) {
|
314 |
+
foreach ($options as &$label) {
|
315 |
+
$label = $helperCatalog->stripTags($label);
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
//default value
|
320 |
+
if (!empty($data['default_value'])) {
|
321 |
+
$data['default_value'] = $helperCatalog->stripTags($data['default_value']);
|
322 |
+
}
|
323 |
+
if (!empty($data['default_value_text'])) {
|
324 |
+
$data['default_value_text'] = $helperCatalog->stripTags($data['default_value_text']);
|
325 |
+
}
|
326 |
+
if (!empty($data['default_value_textarea'])) {
|
327 |
+
$data['default_value_textarea'] = $helperCatalog->stripTags($data['default_value_textarea']);
|
328 |
+
}
|
329 |
+
}
|
330 |
+
return $data;
|
331 |
+
}
|
332 |
+
|
333 |
+
public function deleteAction() {
|
334 |
+
if ($id = $this->getRequest()->getParam('attribute_id')) {
|
335 |
+
$model = Mage::getModel('customerattribute/customerattribute');
|
336 |
+
|
337 |
+
// entity type check
|
338 |
+
$model->load($id);
|
339 |
+
if ($model->getEntityTypeId() != $this->_entityTypeId) {
|
340 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
341 |
+
Mage::helper('customerattribute')->__('This attribute cannot be deleted.'));
|
342 |
+
$this->_redirect('*/*/');
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
|
346 |
+
try {
|
347 |
+
$model->delete();
|
348 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
349 |
+
Mage::helper('customerattribute')->__('The product attribute has been deleted.'));
|
350 |
+
$this->_redirect('*/*/');
|
351 |
+
return;
|
352 |
+
} catch (Exception $e) {
|
353 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
354 |
+
$this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id')));
|
355 |
+
return;
|
356 |
+
}
|
357 |
+
}
|
358 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
359 |
+
Mage::helper('customerattribute')->__('Unable to find an attribute to delete.'));
|
360 |
+
$this->_redirect('*/*/');
|
361 |
+
}
|
362 |
+
|
363 |
+
}
|
app/code/community/Officience/CustomerAttribute/etc/config.xml
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Officience_CustomerAttribute>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Officience_CustomerAttribute>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<layout>
|
10 |
+
<updates>
|
11 |
+
<customerattribute>
|
12 |
+
<file>officience_customerattribute.xml</file>
|
13 |
+
</customerattribute>
|
14 |
+
</updates>
|
15 |
+
</layout>
|
16 |
+
<routers>
|
17 |
+
<customerattribute>
|
18 |
+
<args>
|
19 |
+
<module>Officience_CustomerAttribute</module>
|
20 |
+
<frontName>customerattribute</frontName>
|
21 |
+
</args>
|
22 |
+
</customerattribute>
|
23 |
+
</routers>
|
24 |
+
</frontend>
|
25 |
+
<global>
|
26 |
+
<fieldsets>
|
27 |
+
<customer_account>
|
28 |
+
<prefix><create>1</create><update>1</update><name>1</name></prefix>
|
29 |
+
<firstname><create>1</create><update>1</update><name>1</name></firstname>
|
30 |
+
<middlename><create>1</create><update>1</update><name>1</name></middlename>
|
31 |
+
<lastname><create>1</create><update>1</update><name>1</name></lastname>
|
32 |
+
<suffix><create>1</create><update>1</update><name>1</name></suffix>
|
33 |
+
<email><create>1</create><update>1</update></email>
|
34 |
+
<password><create>1</create></password>
|
35 |
+
<confirmation><create>1</create></confirmation>
|
36 |
+
<dob><create>1</create><update>1</update></dob>
|
37 |
+
<taxvat><create>1</create><update>1</update></taxvat>
|
38 |
+
<gender><create>1</create><update>1</update></gender>
|
39 |
+
</customer_account>
|
40 |
+
</fieldsets>
|
41 |
+
<helpers>
|
42 |
+
<customerattribute>
|
43 |
+
<class>Officience_CustomerAttribute_Helper</class>
|
44 |
+
</customerattribute>
|
45 |
+
</helpers>
|
46 |
+
<models>
|
47 |
+
<customerattribute>
|
48 |
+
<class>Officience_CustomerAttribute_Model</class>
|
49 |
+
<resourceModel>customerattribute_mysql4</resourceModel>
|
50 |
+
</customerattribute>
|
51 |
+
<customerattribute_mysql4>
|
52 |
+
<class>Officience_CustomerAttribute_Model_Mysql4</class>
|
53 |
+
<entities>
|
54 |
+
<officustomerattribute>
|
55 |
+
<table>officustomerattribute</table>
|
56 |
+
</officustomerattribute>
|
57 |
+
</entities>
|
58 |
+
</customerattribute_mysql4>
|
59 |
+
</models>
|
60 |
+
<resources>
|
61 |
+
<customerattribute_setup>
|
62 |
+
<setup>
|
63 |
+
<module>Officience_CustomerAttribute</module>
|
64 |
+
</setup>
|
65 |
+
<connection>
|
66 |
+
<use>core_setup</use>
|
67 |
+
</connection>
|
68 |
+
</customerattribute_setup>
|
69 |
+
</resources>
|
70 |
+
<blocks>
|
71 |
+
<customerattribute>
|
72 |
+
<class>Officience_CustomerAttribute_Block</class>
|
73 |
+
</customerattribute>
|
74 |
+
<customer>
|
75 |
+
<rewrite>
|
76 |
+
<form_register>Officience_CustomerAttribute_Block_Form_Register</form_register>
|
77 |
+
</rewrite>
|
78 |
+
</customer>
|
79 |
+
<customer>
|
80 |
+
<rewrite>
|
81 |
+
<form_edit>Officience_CustomerAttribute_Block_Form_Edit</form_edit>
|
82 |
+
</rewrite>
|
83 |
+
</customer>
|
84 |
+
</blocks>
|
85 |
+
<rewrite>
|
86 |
+
<officience_customerattribute_account>
|
87 |
+
<from><![CDATA[#^/customer/account/#]]></from>
|
88 |
+
<to>/customerattribute/account/</to>
|
89 |
+
</officience_customerattribute_account>
|
90 |
+
</rewrite>
|
91 |
+
</global>
|
92 |
+
<admin>
|
93 |
+
<routers>
|
94 |
+
<customerattribute>
|
95 |
+
<use>admin</use>
|
96 |
+
<args>
|
97 |
+
<module>Officience_CustomerAttribute</module>
|
98 |
+
<frontName>customerattribute</frontName>
|
99 |
+
</args>
|
100 |
+
</customerattribute>
|
101 |
+
</routers>
|
102 |
+
</admin>
|
103 |
+
<adminhtml>
|
104 |
+
<menu>
|
105 |
+
<customer>
|
106 |
+
<children>
|
107 |
+
<customerattribute_adminhtml_index>
|
108 |
+
<title>Customer Attributes Manager</title>
|
109 |
+
<action>customerattribute/adminhtml_index</action>
|
110 |
+
<sort_order>12</sort_order>
|
111 |
+
</customerattribute_adminhtml_index>
|
112 |
+
</children>
|
113 |
+
</customer>
|
114 |
+
</menu>
|
115 |
+
<acl>
|
116 |
+
<resources>
|
117 |
+
<all>
|
118 |
+
<title>Allow Everything</title>
|
119 |
+
</all>
|
120 |
+
<admin>
|
121 |
+
<children>
|
122 |
+
<Officience_CustomerAttribute>
|
123 |
+
<title>Customer Attribute Module</title>
|
124 |
+
<sort_order>10</sort_order>
|
125 |
+
</Officience_CustomerAttribute>
|
126 |
+
</children>
|
127 |
+
</admin>
|
128 |
+
</resources>
|
129 |
+
</acl>
|
130 |
+
<layout>
|
131 |
+
<updates>
|
132 |
+
<attribute>
|
133 |
+
<file>officience_customer_attribute.xml</file>
|
134 |
+
</attribute>
|
135 |
+
</updates>
|
136 |
+
</layout>
|
137 |
+
</adminhtml>
|
138 |
+
</config>
|
app/code/community/Officience/CustomerAttribute/sql/customerattribute_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (version_compare(Mage::getVersion(), '1.4.2', '<')) {
|
4 |
+
$installer = $this;
|
5 |
+
$installer->startSetup();
|
6 |
+
$query = "";
|
7 |
+
$query .= "
|
8 |
+
CREATE TABLE IF NOT EXISTS {$this->getTable('officustomerattribute')}
|
9 |
+
(
|
10 |
+
`form_code` varchar(255) ,
|
11 |
+
`attribute_code` varchar(255),
|
12 |
+
PRIMARY KEY (`form_code`,`attribute_code`)
|
13 |
+
)ENGINE= InnoDB DEFAULT CHARSET = utf8;";
|
14 |
+
$fieldset = Mage::getConfig()->getFieldset('customer_account');
|
15 |
+
if (isset($fieldset)) {
|
16 |
+
foreach ($fieldset as $key => $value) {
|
17 |
+
if ($key) {
|
18 |
+
if ($value->is('update')) {
|
19 |
+
$query .= "Insert INTO {$this->getTable('officustomerattribute')} (`form_code`,`attribute_code`)
|
20 |
+
VALUES ('customer_account_edit','" . $key . "');";
|
21 |
+
}
|
22 |
+
if ($value->is('create')) {
|
23 |
+
$query .= "Insert INTO {$this->getTable('officustomerattribute')} (`form_code`,`attribute_code`)
|
24 |
+
VALUES ('customer_account_create','" . $key . "');";
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
29 |
+
$installer->run($query);
|
30 |
+
$installer->endSetup();
|
31 |
+
}
|
32 |
+
?>
|
app/design/adminhtml/default/default/layout/Officience_customer_attribute.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<!-- informations concernant la page d'accueil du module -->
|
4 |
+
<customerattribute_index>
|
5 |
+
<!-- informations concernant le block content -->
|
6 |
+
<reference name="content">
|
7 |
+
<block type="customerattribute/index" name="customerattribute" as="customerattribute" template="customerattribute/index.phtml" />
|
8 |
+
</reference>
|
9 |
+
</customerattribute_index>
|
10 |
+
|
11 |
+
|
12 |
+
<customerattribute_category>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="customerattribute/customerattributegrid" name="customerattributegrid" as="customerattributegrid" template="customerattribute/grid.phtml" />
|
15 |
+
</reference>
|
16 |
+
</customerattribute_category>
|
17 |
+
<customerattribute_customer>
|
18 |
+
<reference name="content">
|
19 |
+
<block type="customerattribute/customerattributegrid" name="customerattributegrid" as="customerattributegrid" template="customerattribute/grid.phtml" />
|
20 |
+
</reference>
|
21 |
+
</customerattribute_customer>
|
22 |
+
<customerattribute_address>
|
23 |
+
<reference name="content">
|
24 |
+
<block type="customerattribute/customerattributegrid" name="customerattributegrid" as="customerattributegrid" template="customerattribute/grid.phtml" />
|
25 |
+
</reference>
|
26 |
+
</customerattribute_address>
|
27 |
+
|
28 |
+
<customerattribute_edit>
|
29 |
+
<reference name="content">
|
30 |
+
<block type="customerattribute/customerattributeedit" name="customerattributeedit" as="customerattributeedit" template="customerattribute/options.phtml" />
|
31 |
+
</reference>
|
32 |
+
</customerattribute_edit>
|
33 |
+
</layout>
|
app/design/adminhtml/default/default/template/customerattribute/grid.phtml
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('customerattribute')->__('Manage attributes') ?></h3></td>
|
5 |
+
|
6 |
+
<td class="form-buttons"><?php echo $this->addNewButton()
|
7 |
+
?></td>
|
8 |
+
</tr>
|
9 |
+
</table>
|
10 |
+
</div>
|
11 |
+
<div>
|
12 |
+
|
13 |
+
<?php
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Template for Mage_Adminhtml_Block_Widget_Grid
|
17 |
+
*
|
18 |
+
* getId()
|
19 |
+
* getCollection()
|
20 |
+
* getColumns()
|
21 |
+
* getPagerVisibility()
|
22 |
+
* getVarNamePage()
|
23 |
+
*/
|
24 |
+
$numColumns = sizeof($this->getColumns());
|
25 |
+
?>
|
26 |
+
<?php if($this->getCollection()): ?>
|
27 |
+
<?php if($this->canDisplayContainer()): ?>
|
28 |
+
<?php if($this->getGridHeader()): ?>
|
29 |
+
<div class="content-header">
|
30 |
+
<table cellspacing="0">
|
31 |
+
<tr>
|
32 |
+
<td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
</div>
|
36 |
+
<?php endif ?>
|
37 |
+
|
38 |
+
<div id="<?php echo $this->getId() ?>">
|
39 |
+
<?php else: ?>
|
40 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
41 |
+
<?php endif; ?>
|
42 |
+
<?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
|
43 |
+
<table cellspacing="0" class="actions">
|
44 |
+
<tr>
|
45 |
+
<?php if($this->getPagerVisibility()): ?>
|
46 |
+
<td class="pager">
|
47 |
+
<?php echo $this->__('Page') ?>
|
48 |
+
|
49 |
+
<?php $_curPage = $this->getCollection()->getCurPage() ?>
|
50 |
+
<?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
|
51 |
+
<?php if($_curPage>1): ?>
|
52 |
+
<a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getId() ?>JsObject.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
|
53 |
+
<?php else: ?>
|
54 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getId() ?>JsObject.inputPage(event, '<?php echo $_lastPage ?>')"/>
|
58 |
+
|
59 |
+
<?php if($_curPage < $_lastPage): ?>
|
60 |
+
<a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getId() ?>JsObject.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
|
61 |
+
<?php else: ?>
|
62 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
|
63 |
+
<?php endif; ?>
|
64 |
+
|
65 |
+
<?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
|
66 |
+
<span class="separator">|</span>
|
67 |
+
<?php echo $this->__('View') ?>
|
68 |
+
<select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getId() ?>JsObject.loadByElement(this)">
|
69 |
+
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
|
70 |
+
<option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
|
71 |
+
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
|
72 |
+
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
|
73 |
+
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
|
74 |
+
</select>
|
75 |
+
<?php echo $this->__('per page') ?><span class="separator">|</span>
|
76 |
+
<?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
|
77 |
+
<span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
|
78 |
+
<?php if($this->getRssLists()): ?>
|
79 |
+
<?php foreach ($this->getRssLists() as $_rss): ?>
|
80 |
+
<span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
|
81 |
+
<?php endforeach ?>
|
82 |
+
<?php endif; ?>
|
83 |
+
</td>
|
84 |
+
<?php endif ?>
|
85 |
+
<?php if($this->getExportTypes()): ?>
|
86 |
+
<td class="export a-right">
|
87 |
+
<img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/> <?php echo $this->__('Export to:') ?>
|
88 |
+
<select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
|
89 |
+
<?php foreach ($this->getExportTypes() as $_type): ?>
|
90 |
+
<option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
|
91 |
+
<?php endforeach; ?>
|
92 |
+
</select>
|
93 |
+
<?php echo $this->getExportButtonHtml() ?>
|
94 |
+
</td>
|
95 |
+
<?php endif; ?>
|
96 |
+
<td class="filter-actions a-right">
|
97 |
+
<?php echo $this->getMainButtonsHtml() ?>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
</table>
|
101 |
+
<?php endif; ?>
|
102 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
103 |
+
<?php echo $this->getMassactionBlockHtml() ?>
|
104 |
+
<?php endif ?>
|
105 |
+
<div class="grid">
|
106 |
+
<div class="hor-scroll">
|
107 |
+
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
|
108 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
109 |
+
<col <?php echo $_column->getHtmlProperty() ?> />
|
110 |
+
<?php endforeach; ?>
|
111 |
+
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
|
112 |
+
<thead>
|
113 |
+
<?php if ($this->getHeadersVisibility()): ?>
|
114 |
+
<tr class="headings">
|
115 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
116 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
|
117 |
+
<?php endforeach; ?>
|
118 |
+
</tr>
|
119 |
+
<?php endif; ?>
|
120 |
+
<?php if ($this->getFilterVisibility()): ?>
|
121 |
+
<tr class="filter">
|
122 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
123 |
+
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
|
124 |
+
<?php endforeach; ?>
|
125 |
+
</tr>
|
126 |
+
<?php endif ?>
|
127 |
+
</thead>
|
128 |
+
<?php endif; ?>
|
129 |
+
<?php if ($this->getCountTotals()): ?>
|
130 |
+
<tfoot>
|
131 |
+
<tr>
|
132 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
133 |
+
<th class="<?php echo $_column->getCssProperty() ?>"><?php echo $_column->getRowField($_column->getGrid()->getTotals()) ?> </th>
|
134 |
+
<?php endforeach; ?>
|
135 |
+
</tr>
|
136 |
+
</tfoot>
|
137 |
+
<?php endif; ?>
|
138 |
+
<tbody>
|
139 |
+
<?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
|
140 |
+
<?php foreach ($this->getCollection() as $_index=>$_item): ?>
|
141 |
+
<tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
|
142 |
+
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
|
143 |
+
<td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>"><?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : ' ') ?></td>
|
144 |
+
<?php endforeach; ?>
|
145 |
+
</tr>
|
146 |
+
<?php endforeach; ?>
|
147 |
+
<?php elseif ($this->getEmptyText()): ?>
|
148 |
+
<tr>
|
149 |
+
<td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="100"><?php echo $this->getEmptyText() ?></td>
|
150 |
+
</tr>
|
151 |
+
<?php endif; ?>
|
152 |
+
</tbody>
|
153 |
+
</table>
|
154 |
+
</div>
|
155 |
+
</div>
|
156 |
+
<?php if($this->canDisplayContainer()): ?>
|
157 |
+
</div>
|
158 |
+
<script type="text/javascript">
|
159 |
+
//<![CDATA[
|
160 |
+
<?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
|
161 |
+
<?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
|
162 |
+
<?php if($this->getRowClickCallback()): ?>
|
163 |
+
<?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
|
164 |
+
<?php endif; ?>
|
165 |
+
<?php if($this->getCheckboxCheckCallback()): ?>
|
166 |
+
<?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
|
167 |
+
<?php endif; ?>
|
168 |
+
<?php if($this->getRowInitCallback()): ?>
|
169 |
+
<?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
|
170 |
+
<?php echo $this->getJsObjectName() ?>.rows.each(function(row){<?php echo $this->getRowInitCallback() ?>(<?php echo $this->getJsObjectName() ?>, row)});
|
171 |
+
<?php endif; ?>
|
172 |
+
<?php if($this->getMassactionBlock()->isAvailable()): ?>
|
173 |
+
<?php echo $this->getMassactionBlock()->getJavaScript() ?>
|
174 |
+
<?php endif ?>
|
175 |
+
//]]>
|
176 |
+
</script>
|
177 |
+
<?php endif; ?>
|
178 |
+
<?php endif ?>
|
179 |
+
</div>
|
app/design/adminhtml/default/default/template/customerattribute/index.phtml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('customerattribute')->__('Manage attributes') ?></h3></td>
|
5 |
+
<td class="a-right">
|
6 |
+
</td>
|
7 |
+
</tr>
|
8 |
+
</table>
|
9 |
+
</div>
|
10 |
+
<div>
|
11 |
+
<div align="center">
|
12 |
+
<h3 class="icon-head"><u><?php echo Mage::helper('customerattribute')->__('Choose attributes to manage') ?></u></h3>
|
13 |
+
<br/><br/>
|
14 |
+
<h3 class="icon-head">
|
15 |
+
<a href="<?php echo $this->getUrl('*');?>index/category/filter//"><?php echo Mage::helper('customerattribute')->__('Categories attributes') ?></a>
|
16 |
+
<br/>
|
17 |
+
<a href="<?php echo $this->getUrl('*');?>index/customer/filter//"><?php echo Mage::helper('customerattribute')->__('Customers attributes') ?></a>
|
18 |
+
<br/>
|
19 |
+
<a href="<?php echo $this->getUrl('*');?>index/address/filter//"><?php echo Mage::helper('customerattribute')->__('Customer\'s address attributes') ?></a></h3>
|
20 |
+
</div>
|
21 |
+
</div>
|
app/design/adminhtml/default/default/template/customerattribute/js.phtml
ADDED
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design_default
|
22 |
+
* @package Mage
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<script type="text/javascript">
|
28 |
+
function saveAndContinueEdit(){
|
29 |
+
editForm.submit($('edit_form').action+'back/edit/tab/' + product_attribute_tabsJsTabs.activeTab.id);
|
30 |
+
}
|
31 |
+
|
32 |
+
|
33 |
+
function toggleApplyVisibility(select) {
|
34 |
+
if ($(select).value == 1) {
|
35 |
+
$(select).next('select').removeClassName('no-display');
|
36 |
+
$(select).next('select').removeClassName('ignore-validate');
|
37 |
+
|
38 |
+
} else {
|
39 |
+
$(select).next('select').addClassName('no-display');
|
40 |
+
$(select).next('select').addClassName('ignore-validate');
|
41 |
+
var options = $(select).next('select').options;
|
42 |
+
for( var i=0; i < options.length; i++) {
|
43 |
+
options[i].selected = false;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
function checkOptionsPanelVisibility(){
|
49 |
+
if($('matage-options-panel')){
|
50 |
+
var panel = $('matage-options-panel');
|
51 |
+
if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect')){
|
52 |
+
panel.show();
|
53 |
+
}
|
54 |
+
else {
|
55 |
+
panel.hide();
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
function bindAttributeInputType()
|
61 |
+
{
|
62 |
+
checkOptionsPanelVisibility();
|
63 |
+
switchDefaultValueField();
|
64 |
+
checkIsConfigurableVisibility();
|
65 |
+
if($('frontend_input') && ($('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
|
66 |
+
if($('is_filterable')){
|
67 |
+
$('is_filterable').disabled = false;
|
68 |
+
}
|
69 |
+
if($('is_filterable_in_search')){
|
70 |
+
$('is_filterable_in_search').disabled = false;
|
71 |
+
}
|
72 |
+
if($('backend_type') && $('backend_type').options){
|
73 |
+
for(var i=0;i<$('backend_type').options.length;i++){
|
74 |
+
if($('backend_type').options[i].value=='int') $('backend_type').selectedIndex = i;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
else {
|
79 |
+
if($('is_filterable')){
|
80 |
+
$('is_filterable').selectedIndex=0;
|
81 |
+
$('is_filterable').disabled = true;
|
82 |
+
}
|
83 |
+
if($('is_filterable_in_search')){
|
84 |
+
$('is_filterable_in_search').disabled = true;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
switchIsFilterable();
|
88 |
+
}
|
89 |
+
|
90 |
+
function switchIsFilterable()
|
91 |
+
{
|
92 |
+
if ($('is_filterable')) {
|
93 |
+
if ($('is_filterable').selectedIndex == 0) {
|
94 |
+
$('position').disabled = true;
|
95 |
+
} else {
|
96 |
+
$('position').disabled = false;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
function disableApplyToValue(value)
|
102 |
+
{
|
103 |
+
var applyToSelect = $('apply_to');
|
104 |
+
for (i=0;i<applyToSelect.options.length;i++) {
|
105 |
+
if (value == applyToSelect.options[i].value) {
|
106 |
+
applyToSelect.options[i].disabled = true;
|
107 |
+
applyToSelect.options[i].selected = false;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
function switchDefaultValueField()
|
113 |
+
{
|
114 |
+
if (!$('frontend_input')) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
var currentValue = $('frontend_input').value;
|
119 |
+
|
120 |
+
var defaultValueTextVisibility = false;
|
121 |
+
var defaultValueTextareaVisibility = false;
|
122 |
+
var defaultValueDateVisibility = false;
|
123 |
+
var defaultValueYesnoVisibility = false;
|
124 |
+
var scopeVisibility = true;
|
125 |
+
|
126 |
+
switch (currentValue) {
|
127 |
+
case 'select':
|
128 |
+
optionDefaultInputType = 'radio';
|
129 |
+
break;
|
130 |
+
|
131 |
+
case 'multiselect':
|
132 |
+
optionDefaultInputType = 'checkbox';
|
133 |
+
break;
|
134 |
+
|
135 |
+
case 'date':
|
136 |
+
defaultValueDateVisibility = true;
|
137 |
+
break;
|
138 |
+
|
139 |
+
case 'boolean':
|
140 |
+
defaultValueYesnoVisibility = true;
|
141 |
+
break;
|
142 |
+
|
143 |
+
case 'textarea':
|
144 |
+
defaultValueTextareaVisibility = true;
|
145 |
+
break;
|
146 |
+
|
147 |
+
case 'media_image':
|
148 |
+
defaultValueTextVisibility = false;
|
149 |
+
break;
|
150 |
+
case 'price':
|
151 |
+
scopeVisibility = false;
|
152 |
+
default:
|
153 |
+
defaultValueTextVisibility = true;
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
|
157 |
+
var applyToSelect = $('apply_to');
|
158 |
+
switch (currentValue) {
|
159 |
+
<?php foreach (Mage::helper('catalog')->getAttributeDisabledTypes() as $type=>$disabled): ?>
|
160 |
+
case '<?php echo $type; ?>':
|
161 |
+
<?php foreach ($disabled as $one): ?>
|
162 |
+
disableApplyToValue('<?php echo $one; ?>');
|
163 |
+
<?php endforeach; ?>
|
164 |
+
break;
|
165 |
+
<?php endforeach; ?>
|
166 |
+
default:
|
167 |
+
for (i=0;i<applyToSelect.options.length;i++) {
|
168 |
+
applyToSelect.options[i].disabled = false;
|
169 |
+
}
|
170 |
+
break;
|
171 |
+
}
|
172 |
+
|
173 |
+
switch (currentValue) {
|
174 |
+
case 'media_image':
|
175 |
+
$('front_fieldset').previous().hide();
|
176 |
+
$('front_fieldset').hide();
|
177 |
+
|
178 |
+
setRowVisibility('is_required', false);
|
179 |
+
setRowVisibility('is_unique', false);
|
180 |
+
setRowVisibility('frontend_class', false);
|
181 |
+
break;
|
182 |
+
|
183 |
+
<?php foreach (Mage::helper('catalog')->getAttributeHiddenFields() as $type=>$fields): ?>
|
184 |
+
case '<?php echo $type; ?>':
|
185 |
+
<?php foreach ($fields as $one): ?>
|
186 |
+
<?php if ($one == '_front_fieldset'): ?>
|
187 |
+
$('front_fieldset').previous().hide();
|
188 |
+
$('front_fieldset').hide();
|
189 |
+
<?php elseif ($one == '_default_value'): ?>
|
190 |
+
defaultValueTextVisibility =
|
191 |
+
defaultValueTextareaVisibility =
|
192 |
+
defaultValueDateVisibility =
|
193 |
+
defaultValueYesnoVisibility = false;
|
194 |
+
<?php elseif ($one == '_scope'): ?>
|
195 |
+
scopeVisibility = false;
|
196 |
+
<?php else: ?>
|
197 |
+
setRowVisibility('<?php echo $one; ?>', false);
|
198 |
+
<?php endif; ?>
|
199 |
+
<?php endforeach; ?>
|
200 |
+
break;
|
201 |
+
<?php endforeach; ?>
|
202 |
+
|
203 |
+
default:
|
204 |
+
$('front_fieldset').previous().show();
|
205 |
+
$('front_fieldset').show();
|
206 |
+
setRowVisibility('is_required', true);
|
207 |
+
setRowVisibility('is_unique', true);
|
208 |
+
setRowVisibility('frontend_class', true);
|
209 |
+
setRowVisibility('is_configurable', true);
|
210 |
+
break;
|
211 |
+
}
|
212 |
+
|
213 |
+
setRowVisibility('default_value_text', defaultValueTextVisibility);
|
214 |
+
setRowVisibility('default_value_textarea', defaultValueTextareaVisibility);
|
215 |
+
setRowVisibility('default_value_date', defaultValueDateVisibility);
|
216 |
+
setRowVisibility('default_value_yesno', defaultValueYesnoVisibility);
|
217 |
+
setRowVisibility('is_global', scopeVisibility);
|
218 |
+
|
219 |
+
var elems = document.getElementsByName('default[]');
|
220 |
+
for (var i = 0; i < elems.length; i++) {
|
221 |
+
elems[i].type = optionDefaultInputType;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
function setRowVisibility(id, isVisible)
|
226 |
+
{
|
227 |
+
if ($(id)) {
|
228 |
+
var td = $(id).parentNode;
|
229 |
+
var tr = $(td.parentNode);
|
230 |
+
|
231 |
+
if (isVisible) {
|
232 |
+
tr.show();
|
233 |
+
} else {
|
234 |
+
tr.blur();
|
235 |
+
tr.hide();
|
236 |
+
}
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
function checkIsConfigurableVisibility()
|
241 |
+
{
|
242 |
+
if (!$('is_configurable') || !$('is_global') || !$('frontend_input')) return;
|
243 |
+
if ($F('is_global')==1 && $F('frontend_input')=='select') {
|
244 |
+
setRowVisibility('is_configurable', true);
|
245 |
+
} else {
|
246 |
+
setRowVisibility('is_configurable', false);
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
function updateRequriedOptions()
|
251 |
+
{
|
252 |
+
if ($F('frontend_input')=='select' && $F('is_required')==1) {
|
253 |
+
$('option-count-check').addClassName('required-options-count');
|
254 |
+
} else {
|
255 |
+
$('option-count-check').removeClassName('required-options-count');
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
if($('frontend_input')){
|
260 |
+
Event.observe($('frontend_input'), 'change', updateRequriedOptions);
|
261 |
+
Event.observe($('frontend_input'), 'change', bindAttributeInputType);
|
262 |
+
Event.observe($('is_global'), 'change', checkIsConfigurableVisibility);
|
263 |
+
}
|
264 |
+
|
265 |
+
if ($('is_filterable')) {
|
266 |
+
Event.observe($('is_filterable'), 'change', switchIsFilterable);
|
267 |
+
}
|
268 |
+
|
269 |
+
if ($('is_required')) {
|
270 |
+
Event.observe($('is_required'), 'change', updateRequriedOptions);
|
271 |
+
}
|
272 |
+
bindAttributeInputType();
|
273 |
+
|
274 |
+
</script>
|
app/design/adminhtml/default/default/template/customerattribute/new/created.phtml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design_default
|
22 |
+
* @package Mage
|
23 |
+
* @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<script type="text/javascript">
|
28 |
+
var added = false;
|
29 |
+
function addAttribute(closeAfter) {
|
30 |
+
if(window.opener!=null && !added) {
|
31 |
+
window.opener.Product.AttributesBridge.addAttributeRow(<?php echo $this->getAttributesBlockJson() ?>);
|
32 |
+
added = true;
|
33 |
+
}
|
34 |
+
|
35 |
+
if(closeAfter)
|
36 |
+
{
|
37 |
+
closeWindow();
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
function closeWindow()
|
42 |
+
{
|
43 |
+
if (window.opener) {
|
44 |
+
window.opener.focus();
|
45 |
+
}
|
46 |
+
window.close();
|
47 |
+
}
|
48 |
+
|
49 |
+
addAttribute(false);
|
50 |
+
setTimeout(closeWindow, 3000);
|
51 |
+
</script>
|
52 |
+
<div class="a-center">
|
53 |
+
<?php echo $this->getCloseButtonHtml() ?>
|
54 |
+
</div>
|
app/design/adminhtml/default/default/template/customerattribute/options.phtml
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Attribute otions control
|
4 |
+
*
|
5 |
+
* @see Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
|
6 |
+
*/
|
7 |
+
?>
|
8 |
+
<div>
|
9 |
+
<ul class="messages">
|
10 |
+
<li class="notice-msg">
|
11 |
+
<ul>
|
12 |
+
<li><?php echo Mage::helper('catalog')->__('If you do not specify an option value for a store then the default value will be used.') ?></li>
|
13 |
+
</ul>
|
14 |
+
</li>
|
15 |
+
</ul>
|
16 |
+
</div>
|
17 |
+
|
18 |
+
<div class="entity-edit">
|
19 |
+
<div class="entry-edit-head">
|
20 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Titles (Size, Color, etc.)') ?></h4>
|
21 |
+
</div>
|
22 |
+
<div class="box">
|
23 |
+
<div class="hor-scroll">
|
24 |
+
<table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
|
25 |
+
<tr>
|
26 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
27 |
+
<th><?php echo $_store->getName() ?></th>
|
28 |
+
<?php endforeach; ?>
|
29 |
+
</tr>
|
30 |
+
<tr>
|
31 |
+
<?php $_labels = $this->getLabelValues() ?>
|
32 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
33 |
+
<td>
|
34 |
+
<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()]) ?>" />
|
35 |
+
</td>
|
36 |
+
<?php endforeach; ?>
|
37 |
+
</tr>
|
38 |
+
</table>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
<br/>
|
43 |
+
<div class="entity-edit" id="matage-options-panel">
|
44 |
+
<div class="entry-edit-head">
|
45 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Options (values of your attribute)') ?></h4>
|
46 |
+
</div>
|
47 |
+
<div class="box">
|
48 |
+
<div class="hor-scroll">
|
49 |
+
<table class="dynamic-grid" cellspacing="0" cellpadding="0">
|
50 |
+
<tr id="attribute-options-table">
|
51 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
52 |
+
<th><?php echo $_store->getName() ?></th>
|
53 |
+
<?php endforeach; ?>
|
54 |
+
<th><?php echo Mage::helper('catalog')->__('Position') ?></th>
|
55 |
+
<th class="nobr a-center"><?php echo Mage::helper('catalog')->__('Is Default') ?></th>
|
56 |
+
<th><?php echo $this->getAddNewButtonHtml() ?></th>
|
57 |
+
</tr>
|
58 |
+
<tr class="no-display template" id="row-template">
|
59 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
60 |
+
<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" /></td>
|
61 |
+
<?php endforeach; ?>
|
62 |
+
<td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" /></td>
|
63 |
+
<td><input class="input-radio" type="radio" name="default[]" value="{{id}}" /></td>
|
64 |
+
<td class="a-left">
|
65 |
+
<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
|
66 |
+
<?php echo $this->getDeleteButtonHtml() ?>
|
67 |
+
</td>
|
68 |
+
</tr>
|
69 |
+
</table>
|
70 |
+
</div>
|
71 |
+
<input type="hidden" id="option-count-check" value="" />
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
<script type="text/javascript">
|
75 |
+
//<![CDATA[
|
76 |
+
var optionDefaultInputType = 'radio';
|
77 |
+
|
78 |
+
// IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
|
79 |
+
var templateText =
|
80 |
+
'<tr class="option-row">'+
|
81 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
82 |
+
'<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" /><\/td>'+
|
83 |
+
<?php endforeach; ?>
|
84 |
+
'<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}"><\/td>'+
|
85 |
+
'<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} /><\/td>'+
|
86 |
+
'<td class="a-left">'+
|
87 |
+
'<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
|
88 |
+
'<?php echo $this->getDeleteButtonHtml() ?>'+
|
89 |
+
'<\/td>'+
|
90 |
+
'<\/tr>';
|
91 |
+
|
92 |
+
var attributeOption = {
|
93 |
+
table : $('attribute-options-table'),
|
94 |
+
templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
|
95 |
+
templateText : templateText,
|
96 |
+
itemCount : 0,
|
97 |
+
totalItems : 0,
|
98 |
+
add : function(data) {
|
99 |
+
this.template = new Template(this.templateText, this.templateSyntax);
|
100 |
+
if(!data.id){
|
101 |
+
data = {};
|
102 |
+
data.id = 'option_'+this.itemCount;
|
103 |
+
}
|
104 |
+
if (!data.intype)
|
105 |
+
data.intype = optionDefaultInputType;
|
106 |
+
|
107 |
+
Element.insert(this.table, {after: this.template.evaluate(data)});
|
108 |
+
this.bindRemoveButtons();
|
109 |
+
this.itemCount++;
|
110 |
+
this.totalItems++;
|
111 |
+
this.updateItemsCountField();
|
112 |
+
},
|
113 |
+
remove : function(event){
|
114 |
+
var element = $(Event.findElement(event, 'tr')); // !!! Button already
|
115 |
+
// have table parent in safari
|
116 |
+
// Safari workaround
|
117 |
+
element.ancestors().each(function(parentItem){
|
118 |
+
if (parentItem.hasClassName('option-row')) {
|
119 |
+
element = parentItem;
|
120 |
+
throw $break;
|
121 |
+
} else if (parentItem.hasClassName('box')) {
|
122 |
+
throw $break;
|
123 |
+
}
|
124 |
+
});
|
125 |
+
|
126 |
+
|
127 |
+
if(element){
|
128 |
+
var elementFlags = element.getElementsByClassName('delete-flag');
|
129 |
+
if(elementFlags[0]){
|
130 |
+
elementFlags[0].value=1;
|
131 |
+
}
|
132 |
+
|
133 |
+
element.addClassName('no-display');
|
134 |
+
element.addClassName('template');
|
135 |
+
element.hide();
|
136 |
+
this.totalItems--;
|
137 |
+
this.updateItemsCountField();
|
138 |
+
}
|
139 |
+
},
|
140 |
+
updateItemsCountField: function() {
|
141 |
+
if (this.totalItems > 0) {
|
142 |
+
$('option-count-check').value = '1';
|
143 |
+
} else {
|
144 |
+
$('option-count-check').value = '';
|
145 |
+
}
|
146 |
+
},
|
147 |
+
bindRemoveButtons : function(){
|
148 |
+
var buttons = $$('.delete-option');
|
149 |
+
for(var i=0;i<buttons.length;i++){
|
150 |
+
if(!$(buttons[i]).binded){
|
151 |
+
$(buttons[i]).binded = true;
|
152 |
+
Event.observe(buttons[i], 'click', this.remove.bind(this));
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
158 |
+
if($('row-template')){
|
159 |
+
$('row-template').remove();
|
160 |
+
}
|
161 |
+
attributeOption.bindRemoveButtons();
|
162 |
+
|
163 |
+
if($('add_new_option_button')){
|
164 |
+
Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
|
165 |
+
}
|
166 |
+
Validation.addAllThese([
|
167 |
+
['required-option', '<?php echo Mage::helper('catalog')->__('Failed') ?>', function(v) {
|
168 |
+
return !Validation.get('IsEmpty').test(v);
|
169 |
+
}]]);
|
170 |
+
Validation.addAllThese([
|
171 |
+
['required-options-count', '<?php echo Mage::helper('catalog')->__('Options is required') ?>', function(v) {
|
172 |
+
return !Validation.get('IsEmpty').test(v);
|
173 |
+
}]]);
|
174 |
+
<?php foreach ($this->getOptionValues() as $_value): ?>
|
175 |
+
attributeOption.add(<?php echo $_value->toJson() ?>);
|
176 |
+
<?php endforeach; ?>
|
177 |
+
//]]>
|
178 |
+
</script>
|
app/design/frontend/base/default/layout/Officience_customerattribute.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<customer_account_create>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem">
|
6 |
+
<type>js_css</type>
|
7 |
+
<name>calendar/calendar-win2k-1.css</name>
|
8 |
+
<params/>
|
9 |
+
</action>
|
10 |
+
<action method="addItem">
|
11 |
+
<type>js</type>
|
12 |
+
<name>calendar/calendar.js</name>
|
13 |
+
</action>
|
14 |
+
<action method="addItem">
|
15 |
+
<type>js</type>
|
16 |
+
<name>calendar/calendar-setup.js</name>
|
17 |
+
</action>
|
18 |
+
</reference>
|
19 |
+
<block name="customer_form_register">
|
20 |
+
<action method="setTemplate">
|
21 |
+
<template>officience/customerattribute/form/register.phtml</template>
|
22 |
+
</action>
|
23 |
+
<block type="customerattribute/form_register" name="attribute.customer.register" as="attribute_customer_register" template="officience/customerattribute/form/field/items.phtml" />
|
24 |
+
</block>
|
25 |
+
<reference name="before_body_end">
|
26 |
+
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
|
27 |
+
</reference>
|
28 |
+
</customer_account_create>
|
29 |
+
<customer_account_edit>
|
30 |
+
<reference name="head">
|
31 |
+
<action method="addItem">
|
32 |
+
<type>js_css</type>
|
33 |
+
<name>calendar/calendar-win2k-1.css</name>
|
34 |
+
<params/>
|
35 |
+
</action>
|
36 |
+
<action method="addItem">
|
37 |
+
<type>js</type>
|
38 |
+
<name>calendar/calendar.js</name>
|
39 |
+
</action>
|
40 |
+
<action method="addItem">
|
41 |
+
<type>js</type>
|
42 |
+
<name>calendar/calendar-setup.js</name>
|
43 |
+
</action>
|
44 |
+
</reference>
|
45 |
+
<block name="customer_edit">
|
46 |
+
<action method="setTemplate">
|
47 |
+
<template>officience/customerattribute/form/edit.phtml</template>
|
48 |
+
</action>
|
49 |
+
<block type="customerattribute/form_edit" name="attribute.customer.edit" as="attribute_customer_edit" template="officience/customerattribute/form/field/items.phtml" />
|
50 |
+
</block>
|
51 |
+
<reference name="before_body_end">
|
52 |
+
<block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
|
53 |
+
</reference>
|
54 |
+
</customer_account_edit>
|
55 |
+
</layout>
|
app/design/frontend/base/default/template/officience/customerattribute/form/edit.phtml
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<div class="page-title">
|
28 |
+
<h1><?php echo $this->__('Edit Account Information') ?></h1>
|
29 |
+
</div>
|
30 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
31 |
+
<form action="<?php echo $this->getUrl('customer/account/editPost') ?>" method="post" id="form-validate">
|
32 |
+
<div class="fieldset">
|
33 |
+
<?php echo $this->getBlockHtml('formkey')?>
|
34 |
+
<h2 class="legend"><?php echo $this->__('Account Information') ?></h2>
|
35 |
+
<ul class="form-list">
|
36 |
+
<li class="fields">
|
37 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getCustomer())->toHtml() ?>
|
38 |
+
</li>
|
39 |
+
<li>
|
40 |
+
<label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
41 |
+
<div class="input-box">
|
42 |
+
<input type="text" name="email" id="email" value="<?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text required-entry validate-email" />
|
43 |
+
</div>
|
44 |
+
</li>
|
45 |
+
|
46 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
47 |
+
<?php if ($_dob->isEnabled()): ?>
|
48 |
+
<li><?php echo $_dob->setDate($this->getCustomer()->getDob())->toHtml() ?></li>
|
49 |
+
<?php endif ?>
|
50 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
51 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
52 |
+
<li><?php echo $_taxvat->setTaxvat($this->getCustomer()->getTaxvat())->toHtml() ?></li>
|
53 |
+
<?php endif ?>
|
54 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
55 |
+
<?php if ($_gender->isEnabled()): ?>
|
56 |
+
<li><?php echo $_gender->setGender($this->getCustomer()->getGender())->toHtml() ?></li>
|
57 |
+
<?php endif ?>
|
58 |
+
<li class="control">
|
59 |
+
<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>
|
60 |
+
</li>
|
61 |
+
</ul>
|
62 |
+
</div>
|
63 |
+
<div class="fieldset" style="display:none;">
|
64 |
+
<h2 class="legend"><?php echo $this->__('Change Password') ?></h2>
|
65 |
+
<ul class="form-list">
|
66 |
+
<li>
|
67 |
+
<label for="current_password" class="required"><em>*</em><?php echo $this->__('Current Password') ?></label>
|
68 |
+
<div class="input-box">
|
69 |
+
<input type="password" title="<?php echo $this->__('Current Password') ?>" class="input-text" name="current_password" id="current_password" />
|
70 |
+
</div>
|
71 |
+
</li>
|
72 |
+
<li class="fields">
|
73 |
+
<div class="field">
|
74 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('New Password') ?></label>
|
75 |
+
<div class="input-box">
|
76 |
+
<input type="password" title="<?php echo $this->__('New Password') ?>" class="input-text validate-password" name="password" id="password" />
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
<div class="field">
|
80 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm New Password') ?></label>
|
81 |
+
<div class="input-box">
|
82 |
+
<input type="password" title="<?php echo $this->__('Confirm New Password') ?>" class="input-text validate-cpassword" name="confirmation" id="confirmation" />
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
</li>
|
86 |
+
</ul>
|
87 |
+
</div>
|
88 |
+
<?php echo $this->getChildHtml('attribute_customer_edit'); ?>
|
89 |
+
<div class="buttons-set">
|
90 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
91 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
92 |
+
<button type="submit" title="<?php echo $this->__('Save') ?>" class="button"><span><span><?php echo $this->__('Save') ?></span></span></button>
|
93 |
+
</div>
|
94 |
+
</form>
|
95 |
+
<script type="text/javascript">
|
96 |
+
//<![CDATA[
|
97 |
+
var dataForm = new VarienForm('form-validate', true);
|
98 |
+
function setPasswordForm(arg){
|
99 |
+
if(arg){
|
100 |
+
$('current_password').up(3).show();
|
101 |
+
$('current_password').addClassName('required-entry');
|
102 |
+
$('password').addClassName('required-entry');
|
103 |
+
$('confirmation').addClassName('required-entry');
|
104 |
+
|
105 |
+
}else{
|
106 |
+
$('current_password').up(3).hide();
|
107 |
+
$('current_password').removeClassName('required-entry');
|
108 |
+
$('password').removeClassName('required-entry');
|
109 |
+
$('confirmation').removeClassName('required-entry');
|
110 |
+
}
|
111 |
+
}
|
112 |
+
<?php if($this->getCustomer()->getChangePassword()): ?>
|
113 |
+
setPasswordForm(true);
|
114 |
+
<?php endif; ?>
|
115 |
+
//]]>
|
116 |
+
</script>
|
app/design/frontend/base/default/template/officience/customerattribute/form/field/items.phtml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $fieldDefault = $this->getFieldDefault(); ?>
|
2 |
+
<?php $attribute = $this->getListAttribute(); ?>
|
3 |
+
<?php foreach ($attribute as $itemsAttribute): ?>
|
4 |
+
<?php $this->setAttribute($itemsAttribute); ?>
|
5 |
+
<?php $attributeCode = $this->getAttributeCode(); ?>
|
6 |
+
<?php if (!in_array($attributeCode, $fieldDefault)): ?>
|
7 |
+
<?php $active = 1; ?>
|
8 |
+
<?php ?>
|
9 |
+
<?php continue; ?>
|
10 |
+
<?php endif; ?>
|
11 |
+
<?php endforeach; ?>
|
12 |
+
<?php if ($active): ?>
|
13 |
+
<div class="fieldset">
|
14 |
+
<h2 class="legend"><?php echo $this->getTitle() ?></h2>
|
15 |
+
<ul class="form-list">
|
16 |
+
<?php $count = 0; ?>
|
17 |
+
<?php foreach ($attribute as $itemsAttribute): ?>
|
18 |
+
<?php $this->setAttribute($itemsAttribute); ?>
|
19 |
+
<?php $attributeCode = $this->getAttributeCode(); ?>
|
20 |
+
<?php if (!in_array($attributeCode, $fieldDefault)): ?>
|
21 |
+
<?php if ($count == 0): ?><li><?php endif; ?>
|
22 |
+
<div class="field">
|
23 |
+
<?php $required = $itemsAttribute->getIsRequired(); ?>
|
24 |
+
<label for="<?php echo $attributeCode; ?>" class="<?php echo $required ? 'required' : '' ?>" ><?php echo $this->getLabelAttribute(); ?>
|
25 |
+
<?php if ($required): ?>
|
26 |
+
<em>*</em>
|
27 |
+
<?php endif; ?>
|
28 |
+
</label>
|
29 |
+
|
30 |
+
<div class="input-box">
|
31 |
+
<?php echo $this->renderFieldType(); ?>
|
32 |
+
</div>
|
33 |
+
</div>
|
34 |
+
<?php $count++; ?>
|
35 |
+
<?php if ($count == 2): ?> </li>
|
36 |
+
<?php
|
37 |
+
$count = 0;
|
38 |
+
endif;
|
39 |
+
?>
|
40 |
+
<?php endif; ?>
|
41 |
+
<?php endforeach; ?>
|
42 |
+
<?php if ($count > 0): ?>
|
43 |
+
</li>
|
44 |
+
<?php endif; ?>
|
45 |
+
</ul>
|
46 |
+
</div>
|
47 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/officience/customerattribute/form/form.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="field">
|
2 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
3 |
+
<div class="input-box">
|
4 |
+
<?php $inputType = $this->getTypleInput(); ?>
|
5 |
+
<?php if ($inputType == 'text'): ?>
|
6 |
+
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
|
7 |
+
<?php elseif ($inputType == 'textarea'): ?>
|
8 |
+
<textarea id="" class="">
|
9 |
+
|
10 |
+
</textarea>
|
11 |
+
<?php elseif ($inputType == 'date'): ?>
|
12 |
+
|
13 |
+
<?php elseif ($inputType == 'boolean'): ?>
|
14 |
+
<input type="checkbox" id="" name="" />
|
15 |
+
<?php elseif ($inputType == 'multiselect'): ?>
|
16 |
+
<select multiple="multiple" id="" class="" name="">
|
17 |
+
<option></option>
|
18 |
+
</select>
|
19 |
+
<?php elseif ($inputType == 'select'): ?>
|
20 |
+
<select id="" class="" name="">
|
21 |
+
<option></option>
|
22 |
+
</select>
|
23 |
+
<?php endif; ?>
|
24 |
+
</div>
|
25 |
+
</div>
|
app/design/frontend/base/default/template/officience/customerattribute/form/register.phtml
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* Create account form template
|
30 |
+
*
|
31 |
+
* @see Mage_Customer_Block_Form_Register
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<div class="account-create">
|
35 |
+
<div class="page-title">
|
36 |
+
<h1><?php echo $this->__('Create an Account') ?></h1>
|
37 |
+
</div>
|
38 |
+
<?php echo $this->getChildHtml('form_fields_before') ?>
|
39 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
40 |
+
<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">
|
41 |
+
<div class="fieldset">
|
42 |
+
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
|
43 |
+
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
|
44 |
+
<h2 class="legend"><?php echo $this->__('Personal Information') ?></h2>
|
45 |
+
<ul class="form-list">
|
46 |
+
<li class="fields">
|
47 |
+
<?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->toHtml() ?>
|
48 |
+
</li>
|
49 |
+
<li>
|
50 |
+
<label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
51 |
+
<div class="input-box">
|
52 |
+
<input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
|
53 |
+
</div>
|
54 |
+
</li>
|
55 |
+
<?php if ($this->isNewsletterEnabled()): ?>
|
56 |
+
<li class="control">
|
57 |
+
<div class="input-box">
|
58 |
+
<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" />
|
59 |
+
</div>
|
60 |
+
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
|
61 |
+
</li>
|
62 |
+
<?php endif ?>
|
63 |
+
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
|
64 |
+
<?php if ($_dob->isEnabled()): ?>
|
65 |
+
<li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
|
66 |
+
<?php endif ?>
|
67 |
+
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
|
68 |
+
<?php if ($_taxvat->isEnabled()): ?>
|
69 |
+
<li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
|
70 |
+
<?php endif ?>
|
71 |
+
<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
|
72 |
+
<?php if ($_gender->isEnabled()): ?>
|
73 |
+
<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>
|
74 |
+
<?php endif ?>
|
75 |
+
</ul>
|
76 |
+
</div>
|
77 |
+
<?php if ($this->getShowAddressFields()): ?>
|
78 |
+
<div class="fieldset">
|
79 |
+
<input type="hidden" name="create_address" value="1" />
|
80 |
+
<h2 class="legend"><?php echo $this->__('Address Information') ?></h2>
|
81 |
+
<ul class="form-list">
|
82 |
+
<li class="fields">
|
83 |
+
<div class="field">
|
84 |
+
<label for="company"><?php echo $this->__('Company') ?></label>
|
85 |
+
<div class="input-box">
|
86 |
+
<input type="text" name="company" id="company" value="<?php echo $this->htmlEscape($this->getFormData()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
|
87 |
+
</div>
|
88 |
+
</div>
|
89 |
+
<div class="field">
|
90 |
+
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
91 |
+
<div class="input-box">
|
92 |
+
<input type="text" name="telephone" id="telephone" value="<?php echo $this->htmlEscape($this->getFormData()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" />
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
</li>
|
96 |
+
<li class="wide">
|
97 |
+
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
|
98 |
+
<div class="input-box">
|
99 |
+
<input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text required-entry" />
|
100 |
+
</div>
|
101 |
+
</li>
|
102 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
103 |
+
<li class="wide">
|
104 |
+
<div class="input-box">
|
105 |
+
<input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getFormData()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text" />
|
106 |
+
</div>
|
107 |
+
</li>
|
108 |
+
<?php endfor ?>
|
109 |
+
<li class="fields">
|
110 |
+
<div class="field">
|
111 |
+
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
112 |
+
<div class="input-box">
|
113 |
+
<input type="text" name="city" value="<?php echo $this->htmlEscape($this->getFormData()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text required-entry" id="city" />
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
<div class="field">
|
117 |
+
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
118 |
+
<div class="input-box">
|
119 |
+
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
|
120 |
+
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
121 |
+
</select>
|
122 |
+
<script type="text/javascript">
|
123 |
+
//<![CDATA[
|
124 |
+
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
|
125 |
+
//]]>
|
126 |
+
</script>
|
127 |
+
<input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
</li>
|
131 |
+
<li class="fields">
|
132 |
+
<div class="field">
|
133 |
+
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
134 |
+
<div class="input-box">
|
135 |
+
<input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getFormData()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
|
136 |
+
</div>
|
137 |
+
</div>
|
138 |
+
<div class="field">
|
139 |
+
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
140 |
+
<div class="input-box">
|
141 |
+
<?php echo $this->getCountryHtmlSelect() ?>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
</li>
|
145 |
+
</ul>
|
146 |
+
<input type="hidden" name="default_billing" value="1" />
|
147 |
+
<input type="hidden" name="default_shipping" value="1" />
|
148 |
+
</div>
|
149 |
+
<?php endif; ?>
|
150 |
+
<div class="fieldset">
|
151 |
+
<h2 class="legend"><?php echo $this->__('Login Information') ?></h2>
|
152 |
+
<ul class="form-list">
|
153 |
+
<li class="fields">
|
154 |
+
<div class="field">
|
155 |
+
<label for="password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
|
156 |
+
<div class="input-box">
|
157 |
+
<input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
|
158 |
+
</div>
|
159 |
+
</div>
|
160 |
+
<div class="field">
|
161 |
+
<label for="confirmation" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
|
162 |
+
<div class="input-box">
|
163 |
+
<input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
</li>
|
167 |
+
</ul>
|
168 |
+
</div>
|
169 |
+
<?php echo $this->getChildHtml('attribute_customer_register') ?>
|
170 |
+
<div class="buttons-set">
|
171 |
+
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
|
172 |
+
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>" class="back-link"><small>« </small><?php echo $this->__('Back') ?></a></p>
|
173 |
+
<button type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('Submit') ?></span></span></button>
|
174 |
+
</div>
|
175 |
+
</form>
|
176 |
+
<script type="text/javascript">
|
177 |
+
//<![CDATA[
|
178 |
+
var dataForm = new VarienForm('form-validate', true);
|
179 |
+
<?php if ($this->getShowAddressFields()): ?>
|
180 |
+
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
|
181 |
+
<?php endif; ?>
|
182 |
+
//]]>
|
183 |
+
</script>
|
184 |
+
</div>
|
app/etc/modules/Officience_CustomerAttribute.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Officience
|
17 |
+
* @package Offi_CustomerAttributesManagement
|
18 |
+
* @copyright
|
19 |
+
* @license
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<modules>
|
24 |
+
<Officience_CustomerAttribute>
|
25 |
+
<active>true</active>
|
26 |
+
<codePool>community</codePool>
|
27 |
+
</Officience_CustomerAttribute>
|
28 |
+
</modules>
|
29 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Officience_CustomerAttribute</name>
|
4 |
+
<version>0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>A customer attributes manager extension which can collect customer's information smarter</summary>
|
10 |
+
<description>A customer attributes manager extension which can collect customer's information smarter</description>
|
11 |
+
<notes>Version number: 0.0.1 Stability: Stable Compatibility: 1.4.1.1, 1.4.2, 1.5, 1.6, 1.6.1, 1.6.2.0, 1.7</notes>
|
12 |
+
<authors><author><name>khanh trieu nguyen le</name><user>khanhtrieu</user><email>trieu181989@gmail.com</email></author></authors>
|
13 |
+
<date>2013-11-12</date>
|
14 |
+
<time>07:56:37</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Officience"><dir name="CustomerAttribute"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><file name="Form.php" hash="6b875f8a9750f4b573abd4eceea6e083"/><dir name="Tab"><file name="Main.php" hash="8d5e03d95cc7adbe178ec1e7da3efcb2"/><file name="Options.php" hash="0a8dfefef9e698afb761df934fb33ca4"/><file name="System.php" hash="be7e1c3506300d4b370f53dd168c6922"/></dir><file name="Tabs.php" hash="64a21d181ad60b3834d57cf83596c789"/></dir><file name="Edit.php" hash="8130297329fcd3c36776c1e37acfc974"/><file name="Grid.php" hash="45a081a30518628be63883cedc13a7b8"/></dir><dir name="Form"><file name="Edit.php" hash="b016ea4f9b25911fa990fea9b16cd62a"/><file name="Login.php" hash="defee1c6dcb61d6b5bb8092f816d8a4b"/><file name="Register.php" hash="1ffb66a4bc8ec0fc59187e8d3c1f6b30"/></dir></dir><dir name="Helper"><file name="Data.php" hash="02aa837a7599ee47283e347ab3b8f696"/><file name="Field.php" hash="82ae447a693dbb3b04d3b427776b9bb6"/><file name="Form.php" hash="eecbc599ed30192c553c28c923f59e3c"/></dir><dir name="Model"><file name="Customerattribute.php" hash="e5d8cf942bc3f23cdd293c5efaee651a"/><dir name="Mysql4"><dir name="Officustomerattribute"><file name="Collection.php" hash="4ab8fc19984ae6f31a7afbd56297f68e"/></dir><file name="Officustomerattribute.php" hash="1d7162ec76969dfd81fbebee971bb22b"/></dir><file name="Officustomerattribute.php" hash="d2a6040739ebaf1c9cb860bdc5d86a7d"/></dir><dir name="controllers"><file name="AccountController.php" hash="d61c3720fcd80c818a7663dce403347b"/><dir name="Adminhtml"><file name="IndexController.php" hash="8e3eaca45fe85b71272aea7a650accc8"/></dir></dir><dir name="etc"><file name="config.xml" hash="d32aee819181fe37fd2ca3c75057c995"/></dir><dir name="sql"><dir name="customerattribute_setup"><file name="mysql4-install-0.0.1.php" hash="9c79d132026ec38578a1252f71035f26"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="Officience_customer_attribute.xml" hash="dd4f9e01fe78c8cb686bd6ba6d6b52f2"/></dir><dir name="template"><dir name="customerattribute"><file name="grid.phtml" hash="6019c918f3e62fca8dea75c7870fefaf"/><file name="index.phtml" hash="d9d4ac780915862dfc27106934df0c05"/><file name="js.phtml" hash="ceaf55fd2d77b197df0e4205e0cd7b14"/><dir name="new"><file name="created.phtml" hash="6221466a0afd2af66521244391f000d1"/></dir><file name="options.phtml" hash="cfa077b54985e1f4687d2d42f0cd266a"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="Officience_customerattribute.xml" hash="f619aceb69c2d7448d7c723ed222bdee"/></dir><dir name="template"><dir name="officience"><dir name="customerattribute"><dir name="form"><file name="edit.phtml" hash="8badf2cd8661e2fc05ee211b9d5271ac"/><dir name="field"><file name="items.phtml" hash="b8df108d16dc23d5eb3159f5cfc82fdf"/></dir><file name="form.phtml" hash="163d34054403361402b056d81ddb0a40"/><dir name="register"><file name="items.phtml" hash="defee1c6dcb61d6b5bb8092f816d8a4b"/></dir><file name="register.phtml" hash="e3a00f0005533f3cf3f9e84ccb63de95"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Officience_CustomerAttribute.xml" hash="4b5bb41f38c6520c3205198fe421337e"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|