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_Sales
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 customer billing agreement tab
29: *
30: * @author Magento Core Team <core@magentocommerce.com>
31: */
32: class Mage_Sales_Block_Adminhtml_Customer_Edit_Tab_Agreement
33: extends Mage_Sales_Block_Adminhtml_Billing_Agreement_Grid
34: implements Mage_Adminhtml_Block_Widget_Tab_Interface
35: {
36: /**
37: * Columns, that should be removed from grid
38: *
39: * @var array
40: */
41: protected $_columnsToRemove = array('customer_email', 'customer_firstname', 'customer_lastname');
42:
43: /**
44: * Disable filters and paging
45: *
46: */
47: public function __construct()
48: {
49: parent::__construct();
50: $this->setId('customer_edit_tab_agreements');
51: }
52:
53: /**
54: * Return Tab label
55: *
56: * @return string
57: */
58: public function getTabLabel()
59: {
60: return $this->__('Billing Agreements');
61: }
62:
63: /**
64: * Return Tab title
65: *
66: * @return string
67: */
68: public function getTabTitle()
69: {
70: return $this->__('Billing Agreements');
71: }
72:
73: /**
74: * Can show tab in tabs
75: *
76: * @return boolean
77: */
78: public function canShowTab()
79: {
80: $customer = Mage::registry('current_customer');
81: return (bool)$customer->getId();
82: }
83:
84: /**
85: * Tab is hidden
86: *
87: * @return boolean
88: */
89: public function isHidden()
90: {
91: return false;
92: }
93:
94: public function getGridUrl()
95: {
96: return $this->getUrl('*/sales_billing_agreement/customerGrid', array('_current'=>true));
97: }
98:
99: /**
100: * Defines after which tab, this tab should be rendered
101: *
102: * @return string
103: */
104: public function getAfter()
105: {
106: return 'orders';
107: }
108:
109: /**
110: * Prepare collection for grid
111: *
112: * @return Mage_Sales_Block_Adminhtml_Customer_Edit_Tab_Agreement
113: */
114: protected function _prepareCollection()
115: {
116: $collection = Mage::getResourceModel('sales/billing_agreement_collection')
117: ->addFieldToFilter('customer_id', Mage::registry('current_customer')->getId())
118: ->setOrder('created_at');
119: $this->setCollection($collection);
120: return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
121: }
122:
123: /**
124: * Remove some columns and make other not sortable
125: *
126: * @return Mage_Adminhtml_Block_Widget_Grid
127: */
128: protected function _prepareColumns()
129: {
130: $result = parent::_prepareColumns();
131:
132: foreach ($this->_columns as $key => $value) {
133: if (in_array($key, $this->_columnsToRemove)) {
134: unset($this->_columns[$key]);
135: }
136: }
137: return $result;
138: }
139: }
140: