00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Customer_Edit_Tab_View
00035 extends Mage_Adminhtml_Block_Template
00036 implements Mage_Adminhtml_Block_Widget_Tab_Interface
00037 {
00038
00039 protected $_customer;
00040
00041 protected $_customerLog;
00042
00043 public function getCustomer()
00044 {
00045 if (!$this->_customer) {
00046 $this->_customer = Mage::registry('current_customer');
00047 }
00048 return $this->_customer;
00049 }
00050
00051 public function getGroupName()
00052 {
00053 if ($groupId = $this->getCustomer()->getGroupId()) {
00054 return Mage::getModel('customer/group')
00055 ->load($groupId)
00056 ->getCustomerGroupCode();
00057 }
00058 }
00059
00060 public function getCustomerLog()
00061 {
00062 if (!$this->_customerLog) {
00063 $this->_customerLog = Mage::getModel('log/customer')
00064 ->load($this->getCustomer()->getId());
00065
00066 }
00067 return $this->_customerLog;
00068 }
00069
00070 public function getCreateDate()
00071 {
00072 $date = Mage::app()->getLocale()->date($this->getCustomer()->getCreatedAtTimestamp());
00073 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
00074 }
00075
00076 public function getStoreCreateDate()
00077 {
00078 $date = Mage::app()->getLocale()->storeDate(
00079 $this->getCustomer()->getStoreId(),
00080 $this->getCustomer()->getCreatedAtTimestamp(),
00081 true
00082 );
00083 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
00084 }
00085
00086 public function getStoreCreateDateTimezone()
00087 {
00088 return Mage::app()->getStore($this->getCustomer()->getStoreId())
00089 ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
00090 }
00091
00092 public function getLastLoginDate()
00093 {
00094 if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
00095 $date = Mage::app()->getLocale()->date($date);
00096 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
00097 }
00098 return Mage::helper('customer')->__('Never');
00099 }
00100
00101 public function getStoreLastLoginDate()
00102 {
00103 if ($date = $this->getCustomerLog()->getLoginAtTimestamp()) {
00104 $date = Mage::app()->getLocale()->storeDate(
00105 $this->getCustomer()->getStoreId(),
00106 $date,
00107 true
00108 );
00109 return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
00110 }
00111 return Mage::helper('customer')->__('Never');
00112 }
00113
00114 public function getStoreLastLoginDateTimezone()
00115 {
00116 return Mage::app()->getStore($this->getCustomer()->getStoreId())
00117 ->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
00118 }
00119
00120 public function getCurrentStatus()
00121 {
00122 $log = $this->getCustomerLog();
00123 if ($log->getLogoutAt() ||
00124 strtotime(now())-strtotime($log->getLastVisitAt())>Mage_Log_Model_Visitor::getOnlineMinutesInterval()*60) {
00125 return Mage::helper('customer')->__('Offline');
00126 }
00127 return Mage::helper('customer')->__('Online');
00128 }
00129
00130 public function getIsConfirmedStatus()
00131 {
00132 $this->getCustomer();
00133 if (!$this->_customer->getConfirmation()) {
00134 return Mage::helper('customer')->__('Confirmed');
00135 }
00136 if ($this->_customer->isConfirmationRequired()) {
00137 return Mage::helper('customer')->__('Not confirmed, cannot login');
00138 }
00139 return Mage::helper('customer')->__('Not confirmed, can login');
00140 }
00141
00142 public function getCreatedInStore()
00143 {
00144 return Mage::app()->getStore($this->getCustomer()->getStoreId())->getName();
00145 }
00146
00147 public function getStoreId()
00148 {
00149 return $this->getCustomer()->getStoreId();
00150 }
00151
00152 public function getBillingAddressHtml()
00153 {
00154 $html = '';
00155 if ($address = $this->getCustomer()->getPrimaryBillingAddress()) {
00156 $html = $address->format('html');
00157 }
00158 else {
00159 $html = Mage::helper('customer')->__("Customer doesn't have primary billing address");
00160 }
00161 return $html;
00162 }
00163
00164 public function getAccordionHtml()
00165 {
00166 return $this->getChildHtml('accordion');
00167 }
00168
00169 public function getSalesHtml()
00170 {
00171 return $this->getChildHtml('sales');
00172 }
00173
00174 public function getTabLabel()
00175 {
00176 return Mage::helper('customer')->__('Customer View');
00177 }
00178
00179 public function getTabTitle()
00180 {
00181 return Mage::helper('customer')->__('Customer View');
00182 }
00183
00184 public function canShowTab()
00185 {
00186 if (Mage::registry('current_customer')->getId()) {
00187 return true;
00188 }
00189 return false;
00190 }
00191
00192 public function isHidden()
00193 {
00194 if (Mage::registry('current_customer')->getId()) {
00195 return false;
00196 }
00197 return true;
00198 }
00199
00200 }