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) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Adminhtml tagginf customers grid block
29: *
30: * @category Mage
31: * @package Mage_Adminhtml
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Adminhtml_Block_Tag_Grid_Customers extends Mage_Adminhtml_Block_Widget_Grid
35: {
36: protected function _prepareCollection()
37: {
38: //TODO: add full name logic
39: $collection = Mage::getResourceModel('tag_customer/collection')
40: ->addAttributeToSelect('firstname')
41: ->addAttributeToSelect('lastname')
42: // ->addAttributeToSelect('email')
43: // ->addAttributeToSelect('created_at')
44: // ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing')
45: // ->joinAttribute('billing_city', 'customer_address/city', 'default_billing')
46: // ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing')
47: // ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing')
48: // ->joinField('billing_country_name', 'directory/country_name', 'name', 'country_id=billing_country_id', array('language_code'=>'en'))
49: ;
50:
51: if ($productId = $this->getRequest()->getParam('product_id')) {
52: $collection->addProductFilter($productId);
53: }
54: if ($tagId = $this->getRequest()->getParam('tag_id')) {
55: $collection->addTagFilter($tagId);
56: }
57:
58: $this->setCollection($collection);
59:
60: return parent::_prepareCollection();
61: }
62:
63: protected function _prepareColumns()
64: {
65: $this->addColumn('entity_id', array(
66: 'header' =>Mage::helper('tag')->__('ID'),
67: 'width' => '40px',
68: 'align' =>'center',
69: 'sortable' =>true,
70: 'index' =>'entity_id'
71: ));
72: $this->addColumn('firstname', array(
73: 'header' =>Mage::helper('tag')->__('First Name'),
74: 'index' =>'firstname'
75: ));
76: $this->addColumn('lastname', array(
77: 'header' =>Mage::helper('tag')->__('Last Name'),
78: 'index' =>'lastname'
79: ));
80: // $this->addColumn('email', array(
81: // 'header' =>Mage::helper('tag')->__('Email'),
82: // 'align' =>'center',
83: // 'index' =>'email'
84: // ));
85: // $this->addColumn('Telephone', array(
86: // 'header' =>Mage::helper('tag')->__('Telephone'),
87: // 'align' =>'center',
88: // 'index' =>'billing_telephone'
89: // ));
90: // $this->addColumn('billing_postcode', array(
91: // 'header' =>Mage::helper('tag')->__('ZIP/Post Code'),
92: // 'index' =>'billing_postcode',
93: // ));
94: // $this->addColumn('billing_country_name', array(
95: // 'header' =>Mage::helper('tag')->__('Country'),
96: // #'filter' => 'adminhtml/customer_grid_filter_country',
97: // 'index' =>'billing_country_name',
98: // ));
99: // $this->addColumn('customer_since', array(
100: // 'header' =>Mage::helper('tag')->__('Customer Since'),
101: // 'type' => 'date',
102: // 'align' => 'center',
103: // #'format' => 'Y.m.d',
104: // 'index' =>'created_at',
105: // ));
106: $this->addColumn('tags', array(
107: 'header' => Mage::helper('tag')->__('Tags'),
108: 'index' => 'tags',
109: 'sortable' => false,
110: 'filter' => false,
111: 'renderer' => 'adminhtml/tag_grid_column_renderer_tags'
112: ));
113: $this->addColumn('action', array(
114: 'header' =>Mage::helper('tag')->__('Action'),
115: 'align' =>'center',
116: 'width' => '120px',
117: 'format' =>'<a href="'.$this->getUrl('*/*/products/customer_id/$entity_id').'">'.Mage::helper('tag')->__('View Products').'</a>',
118: 'filter' =>false,
119: 'sortable' =>false,
120: 'is_system' =>true
121: ));
122:
123: $this->setColumnFilter('entity_id')
124: ->setColumnFilter('email')
125: ->setColumnFilter('firstname')
126: ->setColumnFilter('lastname');
127:
128: // $this->addExportType('*/*/exportCsv', Mage::helper('tag')->__('CSV'));
129: // $this->addExportType('*/*/exportXml', Mage::helper('tag')->__('XML'));
130: return parent::_prepareColumns();
131: }
132:
133: protected function _addColumnFilterToCollection($column)
134: {
135: if ($this->getCollection() && $column->getFilter()->getValue()) {
136: $this->getCollection()->addAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition());
137: }
138: return $this;
139: }
140:
141: }
142: