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 billing agreement view
29: *
30: * @author Magento Core Team <core@magentocommerce.com>
31: */
32: class Mage_Sales_Block_Adminhtml_Billing_Agreement_View extends Mage_Adminhtml_Block_Widget_Form_Container
33: {
34: /**
35: * Initialize view container
36: *
37: */
38: public function __construct()
39: {
40: $this->_objectId = 'agreement';
41: $this->_controller = 'adminhtml_billing_agreement';
42: $this->_mode = 'view';
43: $this->_blockGroup = 'sales';
44:
45: parent::__construct();
46:
47: if (!$this->_isAllowed('sales/billing_agreement/actions/manage')) {
48: $this->_removeButton('delete');
49: }
50: $this->_removeButton('reset');
51: $this->_removeButton('save');
52: $this->setId('billing_agreement_view');
53:
54: $this->_addButton('back', array(
55: 'label' => Mage::helper('adminhtml')->__('Back'),
56: 'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
57: 'class' => 'back',
58: ), -1);
59:
60: if ($this->_getBillingAgreement()->canCancel() && $this->_isAllowed('sales/billing_agreement/actions/manage')) {
61: $this->_addButton('cancel', array(
62: 'label' => Mage::helper('adminhtml')->__('Cancel'),
63: 'onclick' => "confirmSetLocation('{$this->__('Are you sure you want to do this?')}', '{$this->_getCancelUrl()}')",
64: 'class' => 'cancel',
65: ), -1);
66: }
67: }
68:
69: /**
70: * Retrieve header text
71: *
72: * @return string
73: */
74: public function getHeaderText()
75: {
76: return $this->__('Billing Agreement #%s', $this->_getBillingAgreement()->getReferenceId());
77: }
78:
79: /**
80: * Retrieve cancel billing agreement url
81: *
82: * @return string
83: */
84: protected function _getCancelUrl()
85: {
86: return $this->getUrl('*/*/cancel', array('agreement' => $this->_getBillingAgreement()->getAgreementId()));
87: }
88:
89: /**
90: * Retrieve billing agreement model
91: *
92: * @return Mage_Sales_Model_Billing_Agreement
93: */
94: protected function _getBillingAgreement()
95: {
96: return Mage::registry('current_billing_agreement');
97: }
98:
99: /**
100: * Check current user permissions for specified action
101: *
102: * @param string $action
103: * @return bool
104: */
105: protected function _isAllowed($action)
106: {
107: return Mage::getSingleton('admin/session')->isAllowed($action);
108: }
109: }
110: