PageRenderTime 35ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/magento/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php

https://bitbucket.org/jit_bec/shopifine
PHP | 214 lines | 144 code | 24 blank | 46 comment | 12 complexity | 41c5ae6f7bbdfa16eaef03e91e706cdd MD5 | raw file
Possible License(s): LGPL-3.0
  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. * Customer account form block
  28. *
  29. * @category Mage
  30. * @package Mage_Adminhtml
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Adminhtml_Block_Customer_Edit_Tab_View
  34. extends Mage_Adminhtml_Block_Template
  35. implements Mage_Adminhtml_Block_Widget_Tab_Interface
  36. {
  37. protected $_customer;
  38. protected $_customerLog;
  39. public function getCustomer()
  40. {
  41. if (!$this->_customer) {
  42. $this->_customer = Mage::registry('current_customer');
  43. }
  44. return $this->_customer;
  45. }
  46. public function getGroupName()
  47. {
  48. if ($groupId = $this->getCustomer()->getGroupId()) {
  49. return Mage::getModel('customer/group')
  50. ->load($groupId)
  51. ->getCustomerGroupCode();
  52. }
  53. }
  54. /**
  55. * Load Customer Log model
  56. *
  57. * @return Mage_Log_Model_Customer
  58. */
  59. public function getCustomerLog()
  60. {
  61. if (!$this->_customerLog) {
  62. $this->_customerLog = Mage::getModel('log/customer')
  63. ->loadByCustomer($this->getCustomer()->getId());
  64. }
  65. return $this->_customerLog;
  66. }
  67. /**
  68. * Get customer creation date
  69. *
  70. * @return string
  71. */
  72. public function getCreateDate()
  73. {
  74. return Mage::helper('core')->formatDate($this->getCustomer()->getCreatedAtTimestamp(),
  75. Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
  76. }
  77. public function getStoreCreateDate()
  78. {
  79. $date = Mage::app()->getLocale()->storeDate(
  80. $this->getCustomer()->getStoreId(),
  81. $this->getCustomer()->getCreatedAtTimestamp(),
  82. true
  83. );
  84. return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
  85. }
  86. public function getStoreCreateDateTimezone()
  87. {
  88. return Mage::app()->getStore($this->getCustomer()->getStoreId())
  89. ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
  90. }
  91. /**
  92. * Get customer last login date
  93. *
  94. * @return string
  95. */
  96. public function getLastLoginDate()
  97. {
  98. $date = $this->getCustomerLog()->getLoginAtTimestamp();
  99. if ($date) {
  100. return Mage::helper('core')->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
  101. }
  102. return Mage::helper('customer')->__('Never');
  103. }
  104. public function getStoreLastLoginDate()
  105. {
  106. if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
  107. $date = Mage::app()->getLocale()->storeDate(
  108. $this->getCustomer()->getStoreId(),
  109. $date,
  110. true
  111. );
  112. return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
  113. }
  114. return Mage::helper('customer')->__('Never');
  115. }
  116. public function getStoreLastLoginDateTimezone()
  117. {
  118. return Mage::app()->getStore($this->getCustomer()->getStoreId())
  119. ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
  120. }
  121. public function getCurrentStatus()
  122. {
  123. $log = $this->getCustomerLog();
  124. if ($log->getLogoutAt() ||
  125. strtotime(now())-strtotime($log->getLastVisitAt())>Mage_Log_Model_Visitor::getOnlineMinutesInterval()*60) {
  126. return Mage::helper('customer')->__('Offline');
  127. }
  128. return Mage::helper('customer')->__('Online');
  129. }
  130. public function getIsConfirmedStatus()
  131. {
  132. $this->getCustomer();
  133. if (!$this->_customer->getConfirmation()) {
  134. return Mage::helper('customer')->__('Confirmed');
  135. }
  136. if ($this->_customer->isConfirmationRequired()) {
  137. return Mage::helper('customer')->__('Not confirmed, cannot login');
  138. }
  139. return Mage::helper('customer')->__('Not confirmed, can login');
  140. }
  141. public function getCreatedInStore()
  142. {
  143. return Mage::app()->getStore($this->getCustomer()->getStoreId())->getName();
  144. }
  145. public function getStoreId()
  146. {
  147. return $this->getCustomer()->getStoreId();
  148. }
  149. public function getBillingAddressHtml()
  150. {
  151. $html = '';
  152. if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
  153. $html = $address->format('html');
  154. }
  155. else {
  156. $html = Mage::helper('customer')->__('The customer does not have default billing address.');
  157. }
  158. return $html;
  159. }
  160. public function getAccordionHtml()
  161. {
  162. return $this->getChildHtml('accordion');
  163. }
  164. public function getSalesHtml()
  165. {
  166. return $this->getChildHtml('sales');
  167. }
  168. public function getTabLabel()
  169. {
  170. return Mage::helper('customer')->__('Customer View');
  171. }
  172. public function getTabTitle()
  173. {
  174. return Mage::helper('customer')->__('Customer View');
  175. }
  176. public function canShowTab()
  177. {
  178. if (Mage::registry('current_customer')->getId()) {
  179. return true;
  180. }
  181. return false;
  182. }
  183. public function isHidden()
  184. {
  185. if (Mage::registry('current_customer')->getId()) {
  186. return false;
  187. }
  188. return true;
  189. }
  190. }