BusinessKing_ProductFieldsPermission - Version 1.0.0.1

Version Notes

Stable version release

Download this release

Release Info

Developer Magento Core Team
Extension BusinessKing_ProductFieldsPermission
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

Files changed (19) hide show
  1. app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php +150 -0
  2. app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Inventory.php +31 -0
  3. app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Price/Tier.php +61 -0
  4. app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Websites.php +31 -0
  5. app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Product/Fields.php +142 -0
  6. app/code/local/BusinessKing/ProductFieldsPermission/Helper/Data.php +12 -0
  7. app/code/local/BusinessKing/ProductFieldsPermission/Model/Mysql4/Product/Fields.php +45 -0
  8. app/code/local/BusinessKing/ProductFieldsPermission/Model/Product/Fields.php +29 -0
  9. app/code/local/BusinessKing/ProductFieldsPermission/Model/Resource/Eav/Mysql4/Setup.php +12 -0
  10. app/code/local/BusinessKing/ProductFieldsPermission/controllers/Adminhtml/AjaxController.php +62 -0
  11. app/code/local/BusinessKing/ProductFieldsPermission/controllers/Adminhtml/Product/FieldsController.php +69 -0
  12. app/code/local/BusinessKing/ProductFieldsPermission/etc/config.xml +111 -0
  13. app/code/local/BusinessKing/ProductFieldsPermission/sql/productfieldspermission_setup/mysql4-install-0.1.0.php +27 -0
  14. app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/price/tier.phtml +169 -0
  15. app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/tab/inventory.phtml +241 -0
  16. app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/websites.phtml +106 -0
  17. app/design/adminhtml/default/default/template/productfieldspermission/product/fields.phtml +126 -0
  18. app/etc/modules/BusinessKing_ProductFieldsPermission.xml +9 -0
  19. package.xml +18 -0
app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product attributes tab
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes
10
+ {
11
+ protected function _prepareForm()
12
+ {
13
+ if ($group = $this->getGroup()) {
14
+ $form = new Varien_Data_Form();
15
+ /**
16
+ * Initialize product object as form property
17
+ * for using it in elements generation
18
+ */
19
+ $form->setDataObject(Mage::registry('product'));
20
+
21
+ $fieldset = $form->addFieldset('group_fields'.$group->getId(),
22
+ array('legend'=>Mage::helper('catalog')->__($group->getAttributeGroupName()))
23
+ );
24
+
25
+ $attributes = $this->getGroupAttributes();
26
+
27
+ $this->_setProductFieldset($attributes, $fieldset, array('gallery'));
28
+
29
+ if ($tierPrice = $form->getElement('tier_price')) {
30
+ $tierPrice->setRenderer(
31
+ $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier')
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Add new attribute button if not image tab
37
+ */
38
+ if (!$form->getElement('media_gallery')
39
+ && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
40
+ $headerBar = $this->getLayout()->createBlock(
41
+ 'adminhtml/catalog_product_edit_tab_attributes_create'
42
+ );
43
+
44
+ $headerBar->getConfig()
45
+ ->setTabId('group_' . $group->getId())
46
+ ->setGroupId($group->getId())
47
+ ->setStoreId($form->getDataObject()->getStoreId())
48
+ ->setAttributeSetId($form->getDataObject()->getAttributeSetId())
49
+ ->setTypeId($form->getDataObject()->getTypeId())
50
+ ->setProductId($form->getDataObject()->getId());
51
+
52
+ $fieldset->setHeaderBar(
53
+ $headerBar->toHtml()
54
+ );
55
+ }
56
+
57
+ if ($form->getElement('meta_description')) {
58
+ $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
59
+ }
60
+
61
+ $values = Mage::registry('product')->getData();
62
+ /**
63
+ * Set attribute default values for new product
64
+ */
65
+ if (!Mage::registry('product')->getId()) {
66
+ foreach ($attributes as $attribute) {
67
+ if (!isset($values[$attribute->getAttributeCode()])) {
68
+ $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
69
+ }
70
+ }
71
+ }
72
+
73
+ Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form'=>$form));
74
+
75
+ $form->addValues($values);
76
+ $form->setFieldNameSuffix('product');
77
+ $this->setForm($form);
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Set Product Fieldset to Form
83
+ *
84
+ * @param array $attributes attributes that are to be added
85
+ * @param Varien_Data_Form_Element_Fieldset $fieldset
86
+ * @param array $exclude attributes that should be skipped
87
+ */
88
+ protected function _setProductFieldset($attributes, $fieldset, $exclude=array())
89
+ {
90
+ $this->_addElementTypes($fieldset);
91
+ foreach ($attributes as $attribute) {
92
+ /* @var $attribute Mage_Eav_Model_Entity_Attribute */
93
+ if (!$attribute || !$attribute->getIsVisible()) {
94
+ continue;
95
+ }
96
+ if ( ($inputType = $attribute->getFrontend()->getInputType())
97
+ && !in_array($attribute->getAttributeCode(), $exclude)
98
+ && ('media_image' != $inputType)
99
+ )
100
+ {
101
+
102
+ $fieldType = $inputType;
103
+ $rendererClass = $attribute->getFrontend()->getInputRendererClass();
104
+ if (!empty($rendererClass)) {
105
+ $fieldType = $inputType . '_' . $attribute->getAttributeCode();
106
+ $fieldset->addType($fieldType, $rendererClass);
107
+ }
108
+
109
+ $currentUser = Mage::getSingleton('admin/session')->getUser();
110
+ $currentRole = $currentUser->getRole();
111
+ $roleId = $currentRole->getId();
112
+ $attributeId = $attribute->getAttributeId();
113
+ $isReadOnly = Mage::getModel('productfieldspermission/product_fields')->checkReadOnlyField($roleId, $attributeId);
114
+
115
+ if ($isReadOnly) {
116
+ $configuration = array(
117
+ 'name' => $attribute->getAttributeCode(),
118
+ 'label' => __($attribute->getFrontend()->getLabel()),
119
+ 'class' => $attribute->getFrontend()->getClass(),
120
+ 'required' => $attribute->getIsRequired(),
121
+ 'note' => $attribute->getNote(),
122
+ 'disabled' => 'disabled',
123
+ );
124
+ }
125
+ else {
126
+ $configuration = array(
127
+ 'name' => $attribute->getAttributeCode(),
128
+ 'label' => __($attribute->getFrontend()->getLabel()),
129
+ 'class' => $attribute->getFrontend()->getClass(),
130
+ 'required' => $attribute->getIsRequired(),
131
+ 'note' => $attribute->getNote(),
132
+ );
133
+ }
134
+ $element = $fieldset->addField($attribute->getAttributeCode(), $fieldType,
135
+ $configuration
136
+ )
137
+ ->setEntityAttribute($attribute);
138
+
139
+ $element->setAfterElementHtml($this->_getAdditionalElementHtml($element));
140
+
141
+ if ($inputType == 'select' || $inputType == 'multiselect') {
142
+ $element->setValues($attribute->getSource()->getAllOptions(true, true));
143
+ } elseif ($inputType == 'date') {
144
+ $element->setImage($this->getSkinUrl('images/grid-cal.gif'));
145
+ $element->setFormat(Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Inventory.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product inventory data
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Inventory extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Inventory
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setTemplate('productfieldspermission/catalog/product/edit/tab/inventory.phtml');
15
+ }
16
+
17
+ public function getPermission()
18
+ {
19
+ $currentUser = Mage::getSingleton('admin/session')->getUser();
20
+ $currentRole = $currentUser->getRole();
21
+ $roleId = $currentRole->getId();
22
+ $isReadOnly = Mage::getModel('productfieldspermission/product_fields')->checkReadOnlyField($roleId, 0, 'inventory_tab');
23
+ if($isReadOnly) {
24
+ $permission = false;
25
+ }
26
+ else {
27
+ $permission = true;
28
+ }
29
+ return $permission;
30
+ }
31
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Price/Tier.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ProductFieldsPermission Adminhtml tier pricing item renderer
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Price_Tier extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->setTemplate('productfieldspermission/catalog/product/edit/price/tier.phtml');
14
+ }
15
+
16
+ protected function _prepareLayout()
17
+ {
18
+ parent::_prepareLayout();
19
+ $isReadOnly = $this->isReadOnly();
20
+ if ($isReadOnly) {
21
+ $onclick = '';
22
+ }
23
+ else {
24
+ $onclick = 'tierPriceControl.addItem()';
25
+ }
26
+ $this->setChild('add_button',
27
+ $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setData(array(
29
+ 'label' => Mage::helper('catalog')->__('Add Tier'),
30
+ 'onclick' => $onclick,
31
+ 'class' => 'add'
32
+ )));
33
+ return $this;
34
+ }
35
+
36
+ public function getPermission()
37
+ {
38
+ $isReadOnly = $this->isReadOnly();
39
+ if($isReadOnly) {
40
+ $permission = false;
41
+ }
42
+ else {
43
+ $permission = true;
44
+ }
45
+ return $permission;
46
+ }
47
+
48
+ public function isReadOnly()
49
+ {
50
+ $currentUser = Mage::getSingleton('admin/session')->getUser();
51
+ $currentRole = $currentUser->getRole();
52
+ $roleId = $currentRole->getId();
53
+
54
+ $attributeId = Mage::getResourceModel('eav/entity_attribute')
55
+ ->getIdByCode('catalog_product', 'tier_price');
56
+
57
+ $isReadOnly = Mage::getModel('productfieldspermission/product_fields')->checkReadOnlyField($roleId, $attributeId);
58
+
59
+ return $isReadOnly;
60
+ }
61
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Catalog/Product/Edit/Tab/Websites.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product Stores(Websites) tab
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Websites extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Websites
10
+ {
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setTemplate('productfieldspermission/catalog/product/edit/websites.phtml');
15
+ }
16
+
17
+ public function getPermission()
18
+ {
19
+ $currentUser = Mage::getSingleton('admin/session')->getUser();
20
+ $currentRole = $currentUser->getRole();
21
+ $roleId = $currentRole->getId();
22
+ $isReadOnly = Mage::getModel('productfieldspermission/product_fields')->checkReadOnlyField($roleId, 0, 'websites_tab');
23
+ if($isReadOnly) {
24
+ $permission = false;
25
+ }
26
+ else {
27
+ $permission = true;
28
+ }
29
+ return $permission;
30
+ }
31
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Block/Adminhtml/Product/Fields.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Product fields content block
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Block_Adminhtml_Product_Fields extends Mage_Adminhtml_Block_Template
10
+ {
11
+ protected function _construct()
12
+ {
13
+ $this->setTemplate('productfieldspermission/product/fields.phtml');
14
+ }
15
+
16
+ /**
17
+ * Retrieve Session Form Key
18
+ *
19
+ * @return string
20
+ */
21
+ public function getFormKey()
22
+ {
23
+ return Mage::getSingleton('core/session')->getFormKey();
24
+ }
25
+
26
+ public function getRoles()
27
+ {
28
+ return Mage::getModel("admin/roles")->getCollection();
29
+ }
30
+
31
+ public function getGroups()
32
+ {
33
+ $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
34
+ ->load();
35
+
36
+ return $groupCollection;
37
+ }
38
+
39
+ public function getProductsAttributes()
40
+ {
41
+ $allAttributes = array();
42
+ $i = 0;
43
+ /*$groups = $this->getGroups();
44
+
45
+ $productSimple = Mage::getModel('catalog/product')
46
+ ->setTypeId('simple')
47
+ ->setAttributeSetId(4);
48
+ $productGrouped = Mage::getModel('catalog/product')
49
+ ->setTypeId('grouped')
50
+ ->setAttributeSetId(4);
51
+ $productConfigurable = Mage::getModel('catalog/product')
52
+ ->setTypeId('configurable')
53
+ ->setAttributeSetId(4);
54
+ $productVirtual = Mage::getModel('catalog/product')
55
+ ->setTypeId('virtual')
56
+ ->setAttributeSetId(4);
57
+ $productBundle = Mage::getModel('catalog/product')
58
+ ->setTypeId('bundle')
59
+ ->setAttributeSetId(4);
60
+ $productDownloadable = Mage::getModel('catalog/product')
61
+ ->setTypeId('downloadable')
62
+ ->setAttributeSetId(4);
63
+
64
+ if (count($groups) > 0) {
65
+ foreach ($groups as $group) {
66
+ $attributes = $productSimple->getAttributes($group->getId(), true);
67
+ foreach ($attributes as $attribute) {
68
+ if (!$attribute || !$attribute->getIsVisible()) {
69
+ continue;
70
+ }
71
+ $allAttributes[$i++] = $attribute;
72
+ }
73
+ $attributes = $productGrouped->getAttributes($group->getId(), true);
74
+ foreach ($attributes as $attribute) {
75
+ if (!$attribute || !$attribute->getIsVisible()) {
76
+ continue;
77
+ }
78
+ if (!in_array($attribute, $allAttributes)) {
79
+ $allAttributes[$i++] = $attribute;
80
+ }
81
+ }
82
+ $attributes = $productConfigurable->getAttributes($group->getId(), true);
83
+ foreach ($attributes as $attribute) {
84
+ if (!$attribute || !$attribute->getIsVisible()) {
85
+ continue;
86
+ }
87
+ if (!in_array($attribute, $allAttributes)) {
88
+ $allAttributes[$i++] = $attribute;
89
+ }
90
+ }
91
+ $attributes = $productVirtual->getAttributes($group->getId(), true);
92
+ foreach ($attributes as $attribute) {
93
+ if (!$attribute || !$attribute->getIsVisible()) {
94
+ continue;
95
+ }
96
+ if (!in_array($attribute, $allAttributes)) {
97
+ $allAttributes[$i++] = $attribute;
98
+ }
99
+ }
100
+ $attributes = $productBundle->getAttributes($group->getId(), true);
101
+ foreach ($attributes as $attribute) {
102
+ if (!$attribute || !$attribute->getIsVisible()) {
103
+ continue;
104
+ }
105
+ if (!in_array($attribute, $allAttributes)) {
106
+ $allAttributes[$i++] = $attribute;
107
+ }
108
+ }
109
+ $attributes = $productDownloadable->getAttributes($group->getId(), true);
110
+ foreach ($attributes as $attribute) {
111
+ if (!$attribute || !$attribute->getIsVisible()) {
112
+ continue;
113
+ }
114
+ if (!in_array($attribute, $allAttributes)) {
115
+ $allAttributes[$i++] = $attribute;
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return $allAttributes;*/
121
+
122
+ $entityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product');
123
+ $entityTypeId = $entityType->getId();
124
+
125
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
126
+ ->setAttributeSetFilter($entityTypeId)
127
+ ->addFieldToFilter('attribute_code', array('neq'=>'thumbnail'))
128
+ ->addFieldToFilter('attribute_code', array('neq'=>'image'))
129
+ ->addFieldToFilter('attribute_code', array('neq'=>'small_image'))
130
+ ->addFieldToFilter('attribute_code', array('neq'=>'image_label'))
131
+ ->addFieldToFilter('attribute_code', array('neq'=>'small_image_label'))
132
+ ->addFieldToFilter('attribute_code', array('neq'=>'gallery'))
133
+ ->load();
134
+ foreach ($attributes as $attribute) {
135
+ if (!$attribute) { //|| !$attribute->getIsVisible()
136
+ continue;
137
+ }
138
+ $allAttributes[$i++] = $attribute;
139
+ }
140
+ return $allAttributes;
141
+ }
142
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Helper/Data.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ProductFieldsPermission module base helper
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Helper_Data extends Mage_Core_Helper_Abstract
10
+ {
11
+
12
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Model/Mysql4/Product/Fields.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BusinessKing_ProductFieldsPermission_Model_Mysql4_Product_fields extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('eav/attribute', 'attribute_id');
8
+ }
9
+
10
+ public function setReadOnlyFields($data)
11
+ {
12
+ $write = $this->_getWriteAdapter();
13
+ $write->insert($this->getTable('productfieldspermission/role_attributes'), $data);
14
+ }
15
+
16
+ public function removeReadOnlyFields($roleId)
17
+ {
18
+ $write = $this->_getWriteAdapter();
19
+ $write->delete($this->getTable('productfieldspermission/role_attributes'), 'role_id = '.$roleId);
20
+ }
21
+
22
+ public function getAttributes($roleId)
23
+ {
24
+ $read = $this->_getReadAdapter();
25
+ $select = $read->select()
26
+ ->from($this->getTable('productfieldspermission/role_attributes'))
27
+ ->where('role_id = ?', $roleId);
28
+
29
+ return $read->fetchAll($select);
30
+ }
31
+
32
+ public function checkReadOnlyField($roleId, $attributeId, $tabName = '')
33
+ {
34
+ $read = $this->_getReadAdapter();
35
+ $condition = "role_id = ".$roleId." AND attribute_id = ".$attributeId;
36
+ if (!empty($tabName)) {
37
+ $condition .= " AND tab_name = '".$tabName."'";
38
+ }
39
+ $select = $read->select()
40
+ ->from($this->getTable('productfieldspermission/role_attributes'), 'role_id')
41
+ ->where($condition);
42
+
43
+ return $read->fetchOne($select);
44
+ }
45
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Model/Product/Fields.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BusinessKing_ProductFieldsPermission_Model_Product_Fields extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('productfieldspermission/product_fields');
8
+ }
9
+
10
+ public function setReadOnlyFields($data)
11
+ {
12
+ Mage::getResourceModel('productfieldspermission/product_fields')->setReadOnlyFields($data);
13
+ }
14
+
15
+ public function removeReadOnlyFields($roleId)
16
+ {
17
+ Mage::getResourceModel('productfieldspermission/product_fields')->removeReadOnlyFields($roleId);
18
+ }
19
+
20
+ public function getAttributes($roleId)
21
+ {
22
+ return Mage::getResourceModel('productfieldspermission/product_fields')->getAttributes($roleId);
23
+ }
24
+
25
+ public function checkReadOnlyField($roleId, $attributeId, $tabName = '')
26
+ {
27
+ return Mage::getResourceModel('productfieldspermission/product_fields')->checkReadOnlyField($roleId, $attributeId, $tabName);
28
+ }
29
+ }
app/code/local/BusinessKing/ProductFieldsPermission/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ProductFieldsPermission entity setup
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
10
+ {
11
+
12
+ }
app/code/local/BusinessKing/ProductFieldsPermission/controllers/Adminhtml/AjaxController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Limit Pricing ajax controller
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Adminhtml_AjaxController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ public function indexAction()
12
+ {
13
+ $roleId = $this->getRequest()->getPost('role');
14
+ $allAttributes = array('inventory_tab' => false, 'websites_tab' => false);
15
+ if (empty($roleId)) {
16
+ $roleAttributes = array();
17
+ }
18
+ else {
19
+ $attributes = Mage::getModel('productfieldspermission/product_fields')->getAttributes($roleId);
20
+ $roleAttributes = array();
21
+ if (count($attributes) > 0) {
22
+ foreach ($attributes as $attribute) {
23
+ if ($attribute['tab_name']=="inventory_tab") {
24
+ $allAttributes['inventory_tab'] = true;
25
+ }
26
+ elseif ($attribute['tab_name']=="websites_tab") {
27
+ $allAttributes['websites_tab'] = true;
28
+ }
29
+ else {
30
+ $roleAttributes[] = $attribute['attribute_id'];
31
+ }
32
+ }
33
+ }
34
+ }
35
+ $i = 0;
36
+ $entityType = Mage::getModel('eav/entity_type')->loadByCode('catalog_product');
37
+ $entityTypeId = $entityType->getId();
38
+
39
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
40
+ ->setAttributeSetFilter($entityTypeId)
41
+ ->addFieldToFilter('attribute_code', array('neq'=>'thumbnail'))
42
+ ->addFieldToFilter('attribute_code', array('neq'=>'image'))
43
+ ->addFieldToFilter('attribute_code', array('neq'=>'small_image'))
44
+ ->addFieldToFilter('attribute_code', array('neq'=>'image_label'))
45
+ ->addFieldToFilter('attribute_code', array('neq'=>'small_image_label'))
46
+ ->addFieldToFilter('attribute_code', array('neq'=>'gallery'))
47
+ ->load();
48
+ foreach ($attributes as $attribute) {
49
+ if (!$attribute) { //|| !$attribute->getIsVisible()
50
+ continue;
51
+ }
52
+ $attributeId = $attribute->getId();
53
+ if (in_array($attributeId, $roleAttributes)) {
54
+ $allAttributes[$i++] = true;
55
+ }
56
+ else {
57
+ $allAttributes[$i++] = false;
58
+ }
59
+ }
60
+ $this->getResponse()->setBody(Zend_Json::encode($allAttributes));
61
+ }
62
+ }
app/code/local/BusinessKing/ProductFieldsPermission/controllers/Adminhtml/Product/FieldsController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Limit product fields admin controller
5
+ *
6
+ * @category BusinessKing
7
+ * @package BusinessKing_ProductFieldsPermission
8
+ */
9
+ class BusinessKing_ProductFieldsPermission_Adminhtml_Product_FieldsController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ public function _initAction()
12
+ {
13
+ $this->loadLayout()
14
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Product Fields'), Mage::helper('adminhtml')->__('Manage Product Fields'));
15
+ return $this;
16
+ }
17
+
18
+ public function indexAction()
19
+ {
20
+ $this->_initAction()
21
+ ->_setActiveMenu('product/fields')
22
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manage Product Fields Permission'), Mage::helper('adminhtml')->__('Manage Product Fields Permission'))
23
+ ->_addContent($this->getLayout()->createBlock('productfieldspermission/adminhtml_product_fields'))
24
+ ->renderLayout();
25
+ }
26
+
27
+ public function saveAction()
28
+ {
29
+ $role = $this->getRequest()->getPost('role');
30
+ $attributes = $this->getRequest()->getPost('attribute');
31
+ Mage::getModel('productfieldspermission/product_fields')->removeReadOnlyFields($role);
32
+ if (count($attributes) > 0) {
33
+ foreach ($attributes as $attribute) {
34
+ $data = array(
35
+ 'role_id' => $role,
36
+ 'attribute_id' => $attribute,
37
+ 'tab_name' => ''
38
+ );
39
+ Mage::getModel('productfieldspermission/product_fields')->setReadOnlyFields($data);
40
+ }
41
+ }
42
+ $inventoryTab = $this->getRequest()->getPost('inventory_tab');
43
+ if ($inventoryTab) {
44
+ $data = array(
45
+ 'role_id' => $role,
46
+ 'attribute_id' => 0,
47
+ 'tab_name' => 'inventory_tab'
48
+ );
49
+ Mage::getModel('productfieldspermission/product_fields')->setReadOnlyFields($data);
50
+ }
51
+ $websitesTab = $this->getRequest()->getPost('websites_tab');
52
+ if ($websitesTab) {
53
+ $data = array(
54
+ 'role_id' => $role,
55
+ 'attribute_id' => 0,
56
+ 'tab_name' => 'websites_tab'
57
+ );
58
+ Mage::getModel('productfieldspermission/product_fields')->setReadOnlyFields($data);
59
+ }
60
+
61
+ Mage::getSingleton('checkout/session')->setData('productFields', Mage::helper('adminhtml')->__('Product fields permission saved successfully.'));
62
+ $this->_redirect('*/*/index');
63
+ }
64
+
65
+ protected function _isAllowed()
66
+ {
67
+ return Mage::getSingleton('admin/session')->isAllowed('product/fields');
68
+ }
69
+ }
app/code/local/BusinessKing/ProductFieldsPermission/etc/config.xml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <BusinessKing_ProductFieldsPermission>
5
+ <version>0.1.0</version>
6
+ </BusinessKing_ProductFieldsPermission>
7
+ </modules>
8
+
9
+ <global>
10
+ <blocks>
11
+ <productfieldspermission>
12
+ <class>BusinessKing_ProductFieldsPermission_Block</class>
13
+ </productfieldspermission>
14
+ <adminhtml>
15
+ <rewrite>
16
+ <catalog_product_edit_tab_attributes>BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Attributes</catalog_product_edit_tab_attributes>
17
+ <catalog_product_edit_tab_price_tier>BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Price_Tier</catalog_product_edit_tab_price_tier>
18
+ <catalog_product_edit_tab_websites>BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Websites</catalog_product_edit_tab_websites>
19
+ <catalog_product_edit_tab_inventory>BusinessKing_ProductFieldsPermission_Block_Adminhtml_Catalog_Product_Edit_Tab_Inventory</catalog_product_edit_tab_inventory>
20
+ </rewrite>
21
+ </adminhtml>
22
+ </blocks>
23
+ <helpers>
24
+ <productfieldspermission>
25
+ <class>BusinessKing_ProductFieldsPermission_Helper</class>
26
+ </productfieldspermission>
27
+ </helpers>
28
+ <models>
29
+ <productfieldspermission>
30
+ <class>BusinessKing_ProductFieldsPermission_Model</class>
31
+ <resourceModel>productfieldspermission_mysql4</resourceModel>
32
+ </productfieldspermission>
33
+ <productfieldspermission_mysql4>
34
+ <class>BusinessKing_ProductFieldsPermission_Model_Mysql4</class>
35
+ <entities>
36
+ <role_attributes>
37
+ <table>role_attributes</table>
38
+ </role_attributes>
39
+ </entities>
40
+ </productfieldspermission_mysql4>
41
+ </models>
42
+ <resources>
43
+ <productfieldspermission_setup>
44
+ <setup>
45
+ <module>BusinessKing_ProductFieldsPermission</module>
46
+ <class>BusinessKing_ProductFieldsPermission_Model_Resource_Eav_Mysql4_Setup</class>
47
+ </setup>
48
+ <connection>
49
+ <use>core_setup</use>
50
+ </connection>
51
+ </productfieldspermission_setup>
52
+ <productfieldspermission_write>
53
+ <connection>
54
+ <use>core_write</use>
55
+ </connection>
56
+ </productfieldspermission_write>
57
+ <productfieldspermission_read>
58
+ <connection>
59
+ <use>core_read</use>
60
+ </connection>
61
+ </productfieldspermission_read>
62
+ </resources>
63
+ </global>
64
+
65
+ <adminhtml>
66
+ <menu>
67
+ <product translate="title" module="adminhtml">
68
+ <title>Product</title>
69
+ <sort_order>100</sort_order>
70
+ <children>
71
+ <fields translate="title">
72
+ <title>Manage Fields</title>
73
+ <action>productfieldspermission/adminhtml_product_fields</action>
74
+ <sort_order>10</sort_order>
75
+ </fields>
76
+ </children>
77
+ </product>
78
+ </menu>
79
+ <acl>
80
+ <resources>
81
+ <admin translate="title" module="adminhtml">
82
+ <children>
83
+ <product translate="title" module="adminhtml">
84
+ <title>Product</title>
85
+ <sort_order>110</sort_order>
86
+ <children>
87
+ <fields translate="title">
88
+ <title>Manage Fields</title>
89
+ <sort_order>10</sort_order>
90
+ </fields>
91
+ </children>
92
+ </product>
93
+ </children>
94
+ </admin>
95
+ </resources>
96
+ </acl>
97
+ </adminhtml>
98
+
99
+ <admin>
100
+ <routers>
101
+ <productfieldspermission>
102
+ <use>admin</use>
103
+ <args>
104
+ <module>BusinessKing_ProductFieldsPermission</module>
105
+ <frontName>productfieldspermission</frontName>
106
+ </args>
107
+ </productfieldspermission>
108
+ </routers>
109
+ </admin>
110
+
111
+ </config>
app/code/local/BusinessKing/ProductFieldsPermission/sql/productfieldspermission_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category BusinessKing
4
+ * @package BusinessKing_ProductFieldsPermission
5
+ */
6
+
7
+ $installer = $this;
8
+ /* @var $installer Mage_Eav_Model_Entity_Setup */
9
+
10
+ $installer->startSetup();
11
+
12
+ $installer->run("
13
+
14
+ -- DROP TABLE IF EXISTS `{$this->getTable('role_attributes')}`;
15
+
16
+ CREATE TABLE `{$this->getTable('role_attributes')}` (
17
+ `role_id` INTEGER UNSIGNED NOT NULL,
18
+ `attribute_id` INTEGER UNSIGNED NOT NULL DEFAULT 0,
19
+ `tab_name` VARCHAR(45) NOT NULL,
20
+ PRIMARY KEY (`role_id`,`attribute_id`,`tab_name`),
21
+ KEY `ROLE` (`role_id`),
22
+ CONSTRAINT `ROLE` FOREIGN KEY (`role_id`) REFERENCES {$this->getTable('admin_role')} (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE
23
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
24
+
25
+ ");
26
+
27
+ $installer->endSetup();
app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/price/tier.phtml ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php $permission = $this->getPermission() ?>
3
+ <?php $_htmlId = $this->getElement()->getHtmlId() ?>
4
+ <?php $_htmlClass = $this->getElement()->getClass() ?>
5
+ <?php $_htmlName = $this->getElement()->getName() ?>
6
+ <?php $_multiWebsite= $this->isMultiWebsites(); ?>
7
+
8
+ <script type="text/javascript">
9
+ function checkPermission(permission, index, website, group)
10
+ {
11
+ if(!permission) {
12
+ $('tier_price_row_'+index+'_website_div').hide();
13
+ $('tier_price_row_'+index+'_website_value').value = website;
14
+ $('tier_price_row_'+index+'_website_value').disabled = true;
15
+ $('tier_price_row_'+index+'_website_div_value').show();
16
+
17
+ $('tier_price_row_'+index+'_cust_group_div').hide();
18
+ $('tier_price_row_'+index+'_cust_group_value').value = group;
19
+ $('tier_price_row_'+index+'_cust_group_value').disabled = true;
20
+ $('tier_price_row_'+index+'_cust_group_div_value').show();
21
+
22
+ $('tier_price_row_'+index+'_qty_div').hide();
23
+ $('tier_price_row_'+index+'_qty_value').value = $('tier_price_row_'+index+'_qty').value;
24
+ $('tier_price_row_'+index+'_qty_value').disabled = true;
25
+ $('tier_price_row_'+index+'_qty_div_value').show();
26
+
27
+ $('tier_price_row_'+index+'_price_div').hide();
28
+ $('tier_price_row_'+index+'_price_value').value = $('tier_price_row_'+index+'_price').value;
29
+ $('tier_price_row_'+index+'_price_value').disabled = true;
30
+ $('tier_price_row_'+index+'_price_div_value').show();
31
+ }
32
+ }
33
+ </script>
34
+
35
+ <tr>
36
+ <td class="label"><?php echo $this->getElement()->getLabel() ?></td>
37
+ <td colspan="10" class="grid tier">
38
+ <table cellspacing="0" class="data border" id="tiers_table">
39
+ <?php if ($_multiWebsite): ?>
40
+ <col width="135" />
41
+ <?php endif; ?>
42
+ <col width="120" />
43
+ <col width="95" />
44
+ <col />
45
+ <?php if($permission): ?>
46
+ <col width="75" />
47
+ <?php endif; ?>
48
+ <thead>
49
+ <tr class="headings">
50
+ <th <?php if (!$_multiWebsite): ?>style="display:none"<?php endif; ?>><?php echo Mage::helper('sales')->__('Website') ?></th>
51
+ <th><?php echo Mage::helper('catalog')->__('Customer Group') ?></th>
52
+ <th><?php echo Mage::helper('catalog')->__('Qty') ?></th>
53
+ <th><?php echo $this->getPriceColumnHeader(Mage::helper('catalog')->__('Price')) ?></th>
54
+ <?php if($permission): ?>
55
+ <th class="last"><?php echo Mage::helper('catalog')->__('Action') ?></th>
56
+ <?php endif; ?>
57
+ </tr>
58
+ <tr id="<?php echo $_htmlId ?>_add_template" class="template no-display">
59
+ <td <?php if (!$_multiWebsite): ?>style="display:none"<?php endif; ?>>
60
+ <div id="tier_price_row___index___website_div">
61
+ <select disabled="no-template" class="<?php echo $_htmlClass ?> required-entry" name="<?php echo $_htmlName ?>[__index__][website_id]" id="tier_price_row___index___website">
62
+ <?php foreach ($this->getWebsites() as $_websiteId => $_info): ?>
63
+ <option value="<?php echo $_websiteId ?>"><?php echo $_info['name'] ?><?php if (!empty($_info['currency'])): ?> [<?php echo $_info['currency'] ?>]<?php endif; ?></option>
64
+ <?php endforeach ?>
65
+ </select>
66
+ </div>
67
+ <div id="tier_price_row___index___website_div_value" style="display:none">
68
+ <select disabled="no-template" class="<?php echo $_htmlClass ?> " id="tier_price_row___index___website_value">
69
+ <?php foreach ($this->getWebsites() as $_websiteId => $_info): ?>
70
+ <option value="<?php echo $_websiteId ?>"><?php echo $_info['name'] ?><?php if (!empty($_info['currency'])): ?> [<?php echo $_info['currency'] ?>]<?php endif; ?></option>
71
+ <?php endforeach ?>
72
+ </select>
73
+ </div>
74
+ </td>
75
+ <td>
76
+ <div id="tier_price_row___index___cust_group_div">
77
+ <select disabled="no-template" class="<?php echo $_htmlClass ?> custgroup required-entry" name="<?php echo $_htmlName ?>[__index__][cust_group]" id="tier_price_row___index___cust_group">
78
+ <?php foreach ($this->getCustomerGroups() as $_groupId=>$_groupName): ?>
79
+ <option value="<?php echo $_groupId ?>"><?php echo htmlspecialchars($_groupName) ?></option>
80
+ <?php endforeach ?>
81
+ </select>
82
+ </div>
83
+ <div id="tier_price_row___index___cust_group_div_value" style="display:none">
84
+ <select disabled="no-template" class="<?php echo $_htmlClass ?> custgroup" id="tier_price_row___index___cust_group_value">
85
+ <?php foreach ($this->getCustomerGroups() as $_groupId=>$_groupName): ?>
86
+ <option value="<?php echo $_groupId ?>"><?php echo htmlspecialchars($_groupName) ?></option>
87
+ <?php endforeach ?>
88
+ </select>
89
+ </div>
90
+ </td>
91
+ <td class="nobr">
92
+ <div id="tier_price_row___index___qty_div">
93
+ <input disabled="no-template" class="<?php echo $_htmlClass ?> qty required-entry validate-greater-than-zero" type="text" name="<?php echo $_htmlName ?>[__index__][price_qty]" value="'#{qty}'" id="tier_price_row___index___qty" /> <small class="nobr"><?php echo Mage::helper('catalog')->__('and above')?></small>
94
+ </div>
95
+ <div id="tier_price_row___index___qty_div_value" style="display:none">
96
+ <input disabled="no-template" class="<?php echo $_htmlClass ?> qty validate-greater-than-zero" type="text" value="'#{qty}'" id="tier_price_row___index___qty_value" /> <small class="nobr"><?php echo Mage::helper('catalog')->__('and above')?></small>
97
+ </div>
98
+ </td>
99
+ <td>
100
+ <div id="tier_price_row___index___price_div">
101
+ <input disabled="no-template" class="<?php echo $_htmlClass ?> required-entry validate-greater-than-zero" type="text" name="<?php echo $_htmlName ?>[__index__][price]" value="'#{price}'" id="tier_price_row___index___price" />
102
+ </div>
103
+ <div id="tier_price_row___index___price_div_value" style="display:none">
104
+ <input disabled="no-template" class="<?php echo $_htmlClass ?> validate-greater-than-zero" type="text" value="'#{price}'" id="tier_price_row___index___price_value" />
105
+ </div>
106
+ </td>
107
+ <?php if($permission): ?>
108
+ <td class="last">
109
+ <input type="hidden" name="<?php echo $_htmlName ?>[__index__][delete]" class="delete" disabled="no-template" value="" /><button title="Delete Tier" class="scalable delete icon-btn delete-product-option" onclick="tierPriceControl.deleteItem(event);return false"><span>Delete</span></button>
110
+ </td>
111
+ <?php endif; ?>
112
+ </tr>
113
+ </thead>
114
+ <tfoot>
115
+ <tr>
116
+ <td <?php if (!$_multiWebsite): ?>style="display:none"<?php endif; ?>></td>
117
+ <td colspan="4" class="a-right"><?php echo $this->getAddButtonHtml() ?></td>
118
+ </tr>
119
+ </tfoot>
120
+ <tbody id="<?php echo $_htmlId ?>_container">
121
+ </tbody>
122
+ </table>
123
+
124
+ <script type="text/javascript">
125
+ //<![CDATA[
126
+ var tierPriceControl = {
127
+ template : new Template('<tr>' + $('<?php echo $_htmlId ?>_add_template').innerHTML.replace(/__index__/g, '#{index}').replace(/ disabled="?no-template"?/g, '').replace(/ disabled/g, '').replace(/="'([^']*)'"/g, '="$1"') + '</tr>'),
128
+ itemsCount : 0,
129
+ deleteButton: false,
130
+ addItem : function () {
131
+ var data = {};
132
+ data.website_id = 0;
133
+ data.group = '<?php echo $this->getDefaultCustomerGroup() ?>';
134
+ data.qty = '';
135
+ data.price = '';
136
+ data.index = this.itemsCount++;
137
+ if(arguments.length == 4) {
138
+ data.website_id = arguments[0];
139
+ data.group = arguments[1];
140
+ data.qty = arguments[2];
141
+ data.price = arguments[3];
142
+ }
143
+ Element.insert($('<?php echo $_htmlId ?>_container'), {'bottom':this.template.evaluate(data)});
144
+ $('tier_price_row_'+data.index+'_cust_group').value = data.group;
145
+ $('tier_price_row_'+data.index+'_website').value = data.website_id;
146
+
147
+ var index = data.index;
148
+ var website = data.website_id;
149
+ var group = data.group;
150
+ checkPermission('<?php echo $permission ?>', index, website, group);
151
+ },
152
+ deleteItem : function(event) {
153
+ var tr = Event.findElement(event, 'tr');
154
+ if (tr) {
155
+ Element.select(tr, '.delete').each(function(elem){elem.value='1'});
156
+ Element.select(tr, ['input', 'select']).each(function(elem){elem.hide()});
157
+ Element.hide(tr);
158
+ Element.addClassName(tr, 'no-display template');
159
+ }
160
+ }
161
+ }
162
+ <?php foreach ($this->getValues() as $_item): ?>
163
+ tierPriceControl.addItem('<?php echo $_item['website_id'] ?>', '<?php echo $_item['cust_group'] ?>', '<?php echo $_item['price_qty']*1 ?>','<?php echo sprintf('%.2f', $_item['price']) ?>');
164
+ <?php endforeach; ?>
165
+ //]]>
166
+ </script>
167
+ </td>
168
+ </tr>
169
+
app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/tab/inventory.phtml ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 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/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php $permission = $this->getPermission() ?>
28
+
29
+ <div class="entry-edit">
30
+ <div class="entry-edit-head">
31
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Inventory') ?></h4>
32
+ </div>
33
+ <fieldset>
34
+
35
+ <legend><?php echo Mage::helper('catalog')->__('Inventory') ?></legend>
36
+ <table cellspacing="0" class="form-list" id="table_cataloginventory">
37
+ <tr>
38
+ <td class="label">
39
+ <label for="inventory_manage_stock"><?php echo Mage::helper('catalog')->__('Manage Stock') ?></label>
40
+ </td>
41
+ <td class="value">
42
+ <select id="inventory_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][manage_stock]" class="select" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?>>
43
+ <option value="1"><?php echo Mage::helper('catalog')->__('Yes') ?></option>
44
+ <option value="0"<?php if ($this->getConfigFieldValue('manage_stock') == 0): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('No') ?></option>
45
+ </select>
46
+ <input type="hidden" id="inventory_manage_stock_default" value="<?php echo $this->getDefaultConfigValue('manage_stock'); ?>" />
47
+ <?php $_checked = ($this->getFieldValue('use_config_manage_stock') || $this->IsNew()) ? 'checked="checked"' : '' ?>
48
+
49
+ <?php if($permission): ?>
50
+ <input type="checkbox" id="inventory_use_config_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_manage_stock]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
51
+ <?php else: ?>
52
+ <span style="display:none">
53
+ <input type="checkbox" id="inventory_use_config_manage_stock" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_manage_stock]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
54
+ </span>
55
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" disabled="disabled" />
56
+ <?php endif; ?>
57
+
58
+ <label for="inventory_use_config_manage_stock" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
59
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_manage_stock'), $('inventory_use_config_manage_stock').parentNode);</script>
60
+ </td>
61
+ <td class="value scope-label">
62
+ <?php echo Mage::helper('catalog')->__('[GLOBAL]') ?>
63
+ </td>
64
+ </tr>
65
+
66
+ <?php if(!$this->getProduct()->isComposite()): ?>
67
+ <tr>
68
+ <td class="label"><label for="inventory_qty"><?php echo Mage::helper('catalog')->__('Qty') ?><span class="required">*</span></label></td>
69
+ <td class="value"><input type="text" class="input-text required-entry validate-number" id="inventory_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][qty]" value="<?php echo $this->getFieldValue('qty')*1 ?>" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?> />
70
+ </td>
71
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
72
+ </tr>
73
+
74
+ <tr>
75
+ <td class="label"><label for="inventory_min_qty"><?php echo Mage::helper('catalog')->__('Qty for Item\'s Status to become Out of Stock') ?></label></td>
76
+ <td class="value"><input type="text" class="input-text validate-number" id="inventory_min_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][min_qty]" value="<?php echo $this->getFieldValue('min_qty')*1 ?>" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?> />
77
+
78
+ <?php $_checked = ($this->getFieldValue('use_config_min_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
79
+
80
+ <?php if($permission): ?>
81
+ <input type="checkbox" id="inventory_use_config_min_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" />
82
+ <?php else: ?>
83
+ <span style="display:none">
84
+ <input type="checkbox" id="inventory_use_config_min_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" />
85
+ </span>
86
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" disabled="disabled" />
87
+ <?php endif; ?>
88
+
89
+ <label for="inventory_use_config_min_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
90
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_min_qty'), $('inventory_use_config_min_qty').parentNode);</script></td>
91
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
92
+ </tr>
93
+
94
+ <tr>
95
+ <td class="label"><label for="inventory_min_sale_qty"><?php echo Mage::helper('catalog')->__('Minimum Qty Allowed in Shopping Cart') ?></label></td>
96
+ <td class="value"><input type="text" class="input-text validate-number" id="inventory_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][min_sale_qty]" value="<?php echo $this->getFieldValue('min_sale_qty')*1 ?>" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?> />
97
+
98
+ <?php $_checked = ($this->getFieldValue('use_config_min_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
99
+
100
+ <?php if($permission): ?>
101
+ <input type="checkbox" id="inventory_use_config_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
102
+ <?php else: ?>
103
+ <span style="display:none">
104
+ <input type="checkbox" id="inventory_use_config_min_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_min_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
105
+ </span>
106
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" disabled="disabled" />
107
+ <?php endif; ?>
108
+
109
+ <label for="inventory_use_config_min_sale_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
110
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_min_sale_qty'), $('inventory_use_config_min_sale_qty').parentNode);</script></td>
111
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
112
+ </tr>
113
+
114
+ <tr>
115
+ <td class="label"><label for="inventory_max_sale_qty"><?php echo Mage::helper('catalog')->__('Maximum Qty Allowed in Shopping Cart') ?></label></td>
116
+ <td class="value"><input type="text" class="input-text validate-number" id="inventory_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][max_sale_qty]" value="<?php echo $this->getFieldValue('max_sale_qty')*1 ?>" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?> />
117
+
118
+ <?php $_checked = ($this->getFieldValue('use_config_max_sale_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
119
+
120
+ <?php if($permission): ?>
121
+ <input type="checkbox" id="inventory_use_config_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_max_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
122
+ <?php else: ?>
123
+ <span style="display:none">
124
+ <input type="checkbox" id="inventory_use_config_max_sale_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_max_sale_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
125
+ </span>
126
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" disabled="disabled" />
127
+ <?php endif; ?>
128
+
129
+ <label for="inventory_use_config_max_sale_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
130
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_max_sale_qty'), $('inventory_use_config_max_sale_qty').parentNode);</script></td>
131
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
132
+ </tr>
133
+
134
+ <tr>
135
+ <td class="label"><label for="inventory_is_qty_decimal"><?php echo Mage::helper('catalog')->__('Qty Uses Decimals') ?></label></td>
136
+ <td class="value"><select id="inventory_is_qty_decimal" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_qty_decimal]" class="select" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?>>
137
+ <option value="0"><?php echo Mage::helper('catalog')->__('No') ?></option>
138
+ <option value="1"<?php if($this->getFieldValue('is_qty_decimal')==1): ?> selected="selected"<?php endif; ?>><?php echo Mage::helper('catalog')->__('Yes') ?></option>
139
+ </select>
140
+ </td>
141
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
142
+ </tr>
143
+
144
+ <tr>
145
+ <td class="label"><label for="inventory_backorders"><?php echo Mage::helper('catalog')->__('Backorders') ?></label></td>
146
+ <td class="value"><select id="inventory_backorders" name="<?php echo $this->getFieldSuffix() ?>[stock_data][backorders]" class="select" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?>>
147
+ <?php foreach ($this->getBackordersOption() as $option): ?>
148
+ <?php $_selected = ($option['value'] == $this->getFieldValue('backorders')) ? 'selected="selected"' : '' ?>
149
+ <option value="<?php echo $option['value'] ?>" <?php echo $_selected ?>><?php echo $option['label'] ?></option>
150
+ <?php endforeach; ?>
151
+ </select>
152
+
153
+ <?php $_checked = ($this->getFieldValue('use_config_backorders') || $this->IsNew()) ? 'checked="checked"' : '' ?>
154
+
155
+ <?php if($permission): ?>
156
+ <input type="checkbox" id="inventory_use_config_backorders" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_backorders]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
157
+ <?php else: ?>
158
+ <span style="display:none">
159
+ <input type="checkbox" id="inventory_use_config_backorders" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_backorders]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
160
+ </span>
161
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" disabled="disabled" />
162
+ <?php endif; ?>
163
+
164
+ <label for="inventory_use_config_backorders" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
165
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_backorders'), $('inventory_use_config_backorders').parentNode);</script></td>
166
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
167
+ </tr>
168
+ <tr>
169
+ <td class="label"><label for="inventory_notify_stock_qty"><?php echo Mage::helper('catalog')->__('Notify for Quantity Below') ?></label></td>
170
+ <td class="value"><input type="text" class="input-text validate-number" id="inventory_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][notify_stock_qty]" value="<?php echo $this->getFieldValue('notify_stock_qty')*1 ?>" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?> />
171
+
172
+ <?php $_checked = ($this->getFieldValue('use_config_notify_stock_qty') || $this->IsNew()) ? 'checked="checked"' : '' ?>
173
+
174
+ <?php if($permission): ?>
175
+ <input type="checkbox" id="inventory_use_config_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_notify_stock_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
176
+ <?php else: ?>
177
+ <span style="display:none">
178
+ <input type="checkbox" id="inventory_use_config_notify_stock_qty" name="<?php echo $this->getFieldSuffix() ?>[stock_data][use_config_notify_stock_qty]" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" />
179
+ </span>
180
+ <input type="checkbox" id="" name="" value="1" <?php echo $_checked ?> onclick="toggleValueElements(this, this.parentNode);" class="checkbox" disabled="disabled" />
181
+ <?php endif; ?>
182
+
183
+ <label for="inventory_use_config_notify_stock_qty" class="normal"><?php echo Mage::helper('catalog')->__('Use Config Settings') ?></label>
184
+ <script type="text/javascript">toggleValueElements($('inventory_use_config_notify_stock_qty'), $('inventory_use_config_notify_stock_qty').parentNode);</script></td>
185
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
186
+ </tr>
187
+ <?php endif; ?>
188
+ <tr>
189
+ <td class="label"><label for="inventory_stock_availability"><?php echo Mage::helper('catalog')->__('Stock Availability') ?></label></td>
190
+ <td class="value"><select id="inventory_stock_availability" name="<?php echo $this->getFieldSuffix() ?>[stock_data][is_in_stock]" class="select" <?php echo (!$permission) ? 'disabled="disabled"' : '' ?>>
191
+ <?php foreach ($this->getStockOption() as $option): ?>
192
+ <?php $_selected = ($option['value'] == $this->getFieldValue('is_in_stock')) ? 'selected="selected"' : '' ?>
193
+ <option value="<?php echo $option['value'] ?>" <?php echo $_selected ?>><?php echo $option['label'] ?></option>
194
+ <?php endforeach; ?>
195
+ </select>
196
+ </td>
197
+ <td class="value scope-label"><?php echo Mage::helper('catalog')->__('[GLOBAL]') ?></td>
198
+ </tr>
199
+ </table>
200
+ <script type="text/javascript">
201
+ //<![CDATA[
202
+ var cataloginventoryNotManagestockFields = {
203
+ inventory_min_sale_qty: true,
204
+ inventory_max_sale_qty: true
205
+ };
206
+ function changeManageStockOption()
207
+ {
208
+ $$('#table_cataloginventory tr').each(manageStockEach);
209
+ return true;
210
+ }
211
+ function manageStockEach(el)
212
+ {
213
+ if ($('inventory_use_config_manage_stock').checked) {
214
+ var manageStock = $('inventory_manage_stock_default').value;
215
+ }
216
+ else {
217
+ var manageStock = $('inventory_manage_stock').value;
218
+ }
219
+ if (el == $('inventory_manage_stock').up(1)) {
220
+ return;
221
+ }
222
+ for(field in cataloginventoryNotManagestockFields) {
223
+ if ($(field) && ($(field).up(1) == el)) {
224
+ return;
225
+ }
226
+ }
227
+ if (manageStock == 1) {
228
+ el.show();
229
+ }
230
+ else {
231
+ el.hide();
232
+ }
233
+ return;
234
+ }
235
+ Event.observe($('inventory_manage_stock'), 'change', changeManageStockOption);
236
+ Event.observe($('inventory_use_config_manage_stock'), 'change', changeManageStockOption);
237
+ changeManageStockOption();
238
+ //]]>
239
+ </script>
240
+ </fieldset>
241
+ </div>
app/design/adminhtml/default/default/template/productfieldspermission/catalog/product/edit/websites.phtml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <?php $permission = $this->getPermission() ?>
28
+
29
+ <div class="entry-edit">
30
+ <div class="entry-edit-head">
31
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Product In Websites') ?></h4>
32
+ </div>
33
+ <fieldset id="grop_fields">
34
+ <?php if($this->getProductId()): ?>
35
+ <ul class="messages">
36
+ <li class="notice-msg">
37
+ <ul>
38
+ <li><?php echo Mage::helper('catalog')->__("Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></li>
39
+ </ul>
40
+ </li>
41
+ </ul>
42
+ <?php endif; ?>
43
+ <?php foreach ($this->getWebsiteCollection() as $_website): ?>
44
+ <div>
45
+ <div class="website-name">
46
+ <?php if($permission): ?>
47
+ <input name="product[website_ids][]" value="<?php echo $_website->getId() ?>" class="checkbox website-checkbox" id="product_website_<?php echo $_website->getId() ?>" type="checkbox"<?php if($this->hasWebsite($_website->getId())): ?> checked<?php endif; ?>/>
48
+ <?php else: ?>
49
+ <span style="display:none">
50
+ <input name="product[website_ids][]" value="<?php echo $_website->getId() ?>" class="checkbox website-checkbox" id="product_website_<?php echo $_website->getId() ?>" type="checkbox"<?php if($this->hasWebsite($_website->getId())): ?> checked<?php endif; ?>/>
51
+ </span>
52
+ <input class="checkbox website-checkbox" type="checkbox" <?php if($this->hasWebsite($_website->getId())): ?> checked<?php endif; ?> disabled="disabled" />
53
+ <?php endif; ?>
54
+ <big><strong><label for="product_website_<?php echo $_website->getId() ?>"><?php echo $_website->getName() ?></label></strong></big>
55
+ </div>
56
+ <div class="webiste-groups" id="product_website_<?php echo $_website->getId() ?>_data">
57
+ <?php foreach ($this->getGroupCollection($_website) as $_group): ?>
58
+ <h4><?php echo $_group->getName() ?></h4>
59
+ <div class="group-stores">
60
+ <table>
61
+ <?php foreach ($this->getStoreCollection($_group) as $_store): ?>
62
+ <tr>
63
+ <td><?php echo $_store->getName() ?></td>
64
+ <td>
65
+ <?php if($this->getWebsites() && !$this->hasWebsite($_website->getId())): ?>
66
+ <span class="website-<?php echo $_website->getId() ?>-select" style="display:none">
67
+ <?php echo Mage::helper('catalog')->__('(Copy data from: %s)', $this->getChooseFromStoreHtml($_store)) ?>
68
+ </span>
69
+ <?php endif; ?>
70
+ </td>
71
+ </tr>
72
+ <?php endforeach; ?>
73
+ </table>
74
+ </div>
75
+ <?php endforeach; ?>
76
+ </div>
77
+ </div>
78
+ <?php endforeach; ?>
79
+ </fieldset>
80
+ </div>
81
+ <script type="text/javascript">
82
+ //<![CDATA[
83
+ var productWebsiteCheckboxes = $$('.website-checkbox');
84
+
85
+ for(var i=0;i<productWebsiteCheckboxes.length;i++){
86
+ Event.observe(productWebsiteCheckboxes[i], 'click', toggleStoreFromChoosers);
87
+ }
88
+
89
+ function toggleStoreFromChoosers(event){
90
+ var element = Event.element(event);
91
+ var selects = $('product_website_'+element.value+'_data').getElementsBySelector('select');
92
+ var selectBlocks = $('product_website_'+element.value+'_data').getElementsByClassName('website-'+element.value+'-select');
93
+ for (var i=0; i<selects.length; i++) {
94
+ selects[i].disabled=!element.checked;
95
+ }
96
+ for (var i=0; i<selectBlocks.length; i++) {
97
+ if (element.checked) {
98
+ selectBlocks[i].show();
99
+ }
100
+ else {
101
+ selectBlocks[i].hide();
102
+ }
103
+ }
104
+ }
105
+ //]]>
106
+ </script>
app/design/adminhtml/default/default/template/productfieldspermission/product/fields.phtml ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php $attributes = $this->getProductsAttributes() ?>
3
+ <?php $roles = $this->getRoles() ?>
4
+ <div class="content-header">
5
+ <h3><?php echo $this->__('Manage Product Fields Permission') ?></h3>
6
+ </div>
7
+ <form method="post" action="<?php echo $this->getUrl('productfieldspermission/adminhtml_product_fields/save') ?>" id="formProductFields" name="formProductFields">
8
+ <input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
9
+ <?php $message = Mage::getSingleton('checkout/session')->getData('productFields') ?>
10
+ <?php if(!empty($message)): ?>
11
+ <ul class="messages">
12
+ <li class="success-msg"><?php echo $message ?></li>
13
+ </ul>
14
+ <?php Mage::getSingleton('checkout/session')->setData('productFields', ''); ?>
15
+ <?php endif; ?>
16
+
17
+ <div align="right">
18
+ <button class="scalable save" onclick="javascript: return validate();" type="submit">
19
+ <span><?php echo $this->__('Make Read Only') ?></span>
20
+ </button>
21
+ </div>
22
+ <div class="grid">
23
+ <table class="data">
24
+ <?php if(count($attributes)>0): ?>
25
+ <thead>
26
+ <tr class="filter">
27
+ <th>
28
+ <input type="checkbox" id="select-all" title="select-deselect all" onclick="javascript: selectCheckBoxes('<?php echo count($attributes) ?>');" />
29
+ </th>
30
+ <th>
31
+ <?php echo $this->__('Role') ?>&nbsp;:&nbsp;
32
+ <select id="role" name="role" onchange="javascript: setRole(this.value,'<?php echo count($attributes) ?>');" style="width:250px;">
33
+ <option value="">-- <?php echo $this->__('Select Role') ?> --</option>
34
+ <?php if(count($roles)>0): ?>
35
+ <?php foreach($roles as $role): ?>
36
+ <option value="<?php echo $role->getId() ?>"><?php echo $role->getRoleName() ?></option>
37
+ <?php endforeach; ?>
38
+ <?php endif; ?>
39
+ </select>
40
+ </th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ <?php $i = 0; ?>
45
+ <?php foreach ($attributes as $attribute): ?>
46
+ <tr>
47
+ <td>
48
+ <input type="checkbox" id="chk_<?php echo $i++ ?>" name="attribute[<?php echo $attribute->getAttributeId() ?>]" value="<?php echo $attribute->getAttributeId() ?>" />
49
+ </td>
50
+ <td>
51
+ <?php echo $this->__($attribute->getFrontend()->getLabel())." (".$attribute->getAttributeCode().")" ?>
52
+ </td>
53
+ </tr>
54
+ <?php endforeach; ?>
55
+ <tr>
56
+ <td>
57
+ <input type="checkbox" id="chk_inventory_tab" name="inventory_tab" value="1" />
58
+ </td>
59
+ <td>
60
+ <?php echo $this->__('Inventory ')." (inventory_tab)" ?>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ <input type="checkbox" id="chk_websites_tab" name="websites_tab" value="1" />
66
+ </td>
67
+ <td>
68
+ <?php echo $this->__('Websites ')." (websites_tab)" ?>
69
+ </td>
70
+ </tr>
71
+ <?php endif; ?>
72
+ </tbody>
73
+ </table>
74
+ </div>
75
+ </form>
76
+
77
+ <script type="text/javascript">
78
+ function validate()
79
+ {
80
+ var role = $('role').value;
81
+ if(role=="") {
82
+ alert('Please select the role');
83
+ return false;
84
+ }
85
+ else {
86
+ return true;
87
+ }
88
+ }
89
+ function setRole(role, count)
90
+ {
91
+ var i;
92
+ var url = '<?php echo $this->getUrl('productfieldspermission/adminhtml_ajax') ?>';
93
+ new Ajax.Request(url, {
94
+ method:'post',
95
+ parameters: {role: role },
96
+ onComplete: function(transport){
97
+ var response = transport.responseText.evalJSON(true);
98
+ for(i=0;i<count;i++) {
99
+ $('chk_'+i).checked = response[i];
100
+ }
101
+ $('chk_inventory_tab').checked = response['inventory_tab'];
102
+ $('chk_websites_tab').checked = response['websites_tab'];
103
+ $('select-all').checked = false;
104
+ }
105
+ });
106
+ }
107
+ function selectCheckBoxes(count)
108
+ {
109
+ var i, chk = $('select-all').checked;
110
+ if(chk) {
111
+ for(i=0;i<count;i++) {
112
+ $('chk_'+i).checked = true;
113
+ }
114
+ $('chk_inventory_tab').checked = true;
115
+ $('chk_websites_tab').checked = true;
116
+ }
117
+ else {
118
+ for(i=0;i<count;i++) {
119
+ $('chk_'+i).checked = false;
120
+ }
121
+ $('chk_inventory_tab').checked = false;
122
+ $('chk_websites_tab').checked = false;
123
+ }
124
+ }
125
+ </script>
126
+
app/etc/modules/BusinessKing_ProductFieldsPermission.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <config>
3
+ <modules>
4
+ <BusinessKing_ProductFieldsPermission>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </BusinessKing_ProductFieldsPermission>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>BusinessKing_ProductFieldsPermission</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/OSL-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Product Fields Permission</summary>
10
+ <description>This extension provides the ability to give the permission to edit only selected product fields/attributes.</description>
11
+ <notes>Stable version release</notes>
12
+ <authors><author><name>Business King</name><user>auto-converted</user><email>inquiry@businessapplicationking.com</email></author></authors>
13
+ <date>2012-03-29</date>
14
+ <time>11:30:31</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="productfieldspermission"><dir name="catalog"><dir name="product"><dir name="edit"><file name="websites.phtml" hash="33ed8761bfe2f4dde507d60832a601c9"/><dir name="price"><file name="tier.phtml" hash="b9c3791db3df30898456bcb4475cf4fe"/></dir><dir name="tab"><file name="inventory.phtml" hash="74e9dd86f20b84ec5138514b49099ca1"/></dir></dir></dir></dir><dir name="product"><file name="fields.phtml" hash="ddc83ab6805813e73a6ebb4ffe5915a7"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="BusinessKing"><dir name="ProductFieldsPermission"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Attributes.php" hash="b8921dd56bfe4b9d5aa2c93ee764ecde"/><file name="Inventory.php" hash="658377ef59281beb60efed891018f5a3"/><file name="Websites.php" hash="c9663ae869a1e3fb0e54902596616ec0"/><dir name="Price"><file name="Tier.php" hash="eda863afe71eca8bf57fcc9e17a2ad71"/></dir></dir></dir></dir></dir><dir name="Product"><file name="Fields.php" hash="5ff57d4dd46179ff9cc2d55e4269f63b"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="94c5ad6559a77dd02ea416b9fec858b3"/><dir name="Product"><file name="FieldsController.php" hash="b6348dfbc2aa73bdd5c996c79919a0cf"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="06605905912582424cf1748774af08c4"/></dir><dir name="Helper"><file name="Data.php" hash="10c7b38d93b0bd34e5fb478c1993d604"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Product"><file name="Fields.php" hash="6a846c449baad2922f13ab3d9c22981e"/></dir></dir><dir name="Product"><file name="Fields.php" hash="53a3c93c56a848b26e325da71ed9b965"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="5c744df05a13f235779e0bf511786f75"/></dir></dir></dir></dir><dir name="sql"><dir name="productfieldspermission_setup"><file name="mysql4-install-0.1.0.php" hash="0c9c40621ea760b47b61eb05c4577317"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BusinessKing_ProductFieldsPermission.xml" hash="702acb880d453b51a756feb29a1a057b"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>