1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Customer_Edit_Tab_View
35: extends Mage_Adminhtml_Block_Template
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38:
39: protected $_customer;
40:
41: protected $_customerLog;
42:
43: public function getCustomer()
44: {
45: if (!$this->_customer) {
46: $this->_customer = Mage::registry('current_customer');
47: }
48: return $this->_customer;
49: }
50:
51: public function getGroupName()
52: {
53: if ($groupId = $this->getCustomer()->getGroupId()) {
54: return Mage::getModel('customer/group')
55: ->load($groupId)
56: ->getCustomerGroupCode();
57: }
58: }
59:
60: 61: 62: 63: 64:
65: public function getCustomerLog()
66: {
67: if (!$this->_customerLog) {
68: $this->_customerLog = Mage::getModel('log/customer')
69: ->loadByCustomer($this->getCustomer()->getId());
70: }
71: return $this->_customerLog;
72: }
73:
74: 75: 76: 77: 78:
79: public function getCreateDate()
80: {
81: return Mage::helper('core')->formatDate($this->getCustomer()->getCreatedAtTimestamp(),
82: Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
83: }
84:
85: public function getStoreCreateDate()
86: {
87: $date = Mage::app()->getLocale()->storeDate(
88: $this->getCustomer()->getStoreId(),
89: $this->getCustomer()->getCreatedAtTimestamp(),
90: true
91: );
92: return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
93: }
94:
95: public function getStoreCreateDateTimezone()
96: {
97: return Mage::app()->getStore($this->getCustomer()->getStoreId())
98: ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
99: }
100:
101: 102: 103: 104: 105:
106: public function getLastLoginDate()
107: {
108: $date = $this->getCustomerLog()->getLoginAtTimestamp();
109: if ($date) {
110: return Mage::helper('core')->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
111: }
112: return Mage::helper('customer')->__('Never');
113: }
114:
115: public function getStoreLastLoginDate()
116: {
117: if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
118: $date = Mage::app()->getLocale()->storeDate(
119: $this->getCustomer()->getStoreId(),
120: $date,
121: true
122: );
123: return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
124: }
125: return Mage::helper('customer')->__('Never');
126: }
127:
128: public function getStoreLastLoginDateTimezone()
129: {
130: return Mage::app()->getStore($this->getCustomer()->getStoreId())
131: ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
132: }
133:
134: public function getCurrentStatus()
135: {
136: $log = $this->getCustomerLog();
137: if ($log->getLogoutAt() ||
138: strtotime(now())-strtotime($log->getLastVisitAt())>Mage_Log_Model_Visitor::getOnlineMinutesInterval()*60) {
139: return Mage::helper('customer')->__('Offline');
140: }
141: return Mage::helper('customer')->__('Online');
142: }
143:
144: public function getIsConfirmedStatus()
145: {
146: $this->getCustomer();
147: if (!$this->_customer->getConfirmation()) {
148: return Mage::helper('customer')->__('Confirmed');
149: }
150: if ($this->_customer->isConfirmationRequired()) {
151: return Mage::helper('customer')->__('Not confirmed, cannot login');
152: }
153: return Mage::helper('customer')->__('Not confirmed, can login');
154: }
155:
156: public function getCreatedInStore()
157: {
158: return Mage::app()->getStore($this->getCustomer()->getStoreId())->getName();
159: }
160:
161: public function getStoreId()
162: {
163: return $this->getCustomer()->getStoreId();
164: }
165:
166: public function getBillingAddressHtml()
167: {
168: $html = '';
169: if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
170: $html = $address->format('html');
171: }
172: else {
173: $html = Mage::helper('customer')->__('The customer does not have default billing address.');
174: }
175: return $html;
176: }
177:
178: public function getAccordionHtml()
179: {
180: return $this->getChildHtml('accordion');
181: }
182:
183: public function getSalesHtml()
184: {
185: return $this->getChildHtml('sales');
186: }
187:
188: public function getTabLabel()
189: {
190: return Mage::helper('customer')->__('Customer View');
191: }
192:
193: public function getTabTitle()
194: {
195: return Mage::helper('customer')->__('Customer View');
196: }
197:
198: public function canShowTab()
199: {
200: if (Mage::registry('current_customer')->getId()) {
201: return true;
202: }
203: return false;
204: }
205:
206: public function isHidden()
207: {
208: if (Mage::registry('current_customer')->getId()) {
209: return false;
210: }
211: return true;
212: }
213:
214: }
215: