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_Sales_Order_View_Tab_History
00035 extends Mage_Adminhtml_Block_Template
00036 implements Mage_Adminhtml_Block_Widget_Tab_Interface
00037 {
00038 protected function _construct()
00039 {
00040 parent::_construct();
00041 $this->setTemplate('sales/order/view/tab/history.phtml');
00042 }
00043
00044
00045
00046
00047
00048
00049 public function getOrder()
00050 {
00051 return Mage::registry('current_order');
00052 }
00053
00054
00055
00056
00057
00058 public function getFullHistory(){
00059 $order = $this->getOrder();
00060
00061 $_fullHistory = array();
00062 foreach ($order->getAllStatusHistory() as $_history){
00063 $_fullHistory[$_history->getEntityId()] =
00064 $this->_prepareHistoryItem(
00065 $_history->getStatusLabel(),
00066 $_history->getIsCustomerNotified(),
00067 $_history->getCreatedAtDate());
00068 }
00069
00070 foreach ($order->getCreditmemosCollection() as $_memo){
00071 $_fullHistory[$_memo->getEntityId()] =
00072 $this->_prepareHistoryItem($this->__('Credit Memo #%s created', $_memo->getIncrementId()),
00073 $_memo->getEmailSent(), $_memo->getCreatedAtDate());
00074
00075 foreach ($_memo->getCommentsCollection() as $_comment){
00076 $_fullHistory[$_comment->getEntityId()] =
00077 $this->_prepareHistoryItem($this->__('Credit Memo #%s comment added', $_memo->getIncrementId()),
00078 $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
00079 }
00080 }
00081
00082 foreach ($order->getShipmentsCollection() as $_shipment){
00083 $_fullHistory[$_shipment->getEntityId()] =
00084 $this->_prepareHistoryItem($this->__('Shipment #%s created', $_shipment->getIncrementId()),
00085 $_shipment->getEmailSent(), $_shipment->getCreatedAtDate());
00086
00087 foreach ($_shipment->getCommentsCollection() as $_comment){
00088 $_fullHistory[$_comment->getEntityId()] =
00089 $this->_prepareHistoryItem($this->__('Shipment #%s comment added', $_shipment->getIncrementId()),
00090 $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
00091 }
00092 }
00093
00094 foreach ($order->getInvoiceCollection() as $_invoice){
00095 $_fullHistory[$_invoice->getEntityId()] =
00096 $this->_prepareHistoryItem($this->__('Invoice #%s created', $_invoice->getIncrementId()),
00097 $_invoice->getEmailSent(), $_invoice->getCreatedAtDate());
00098
00099 foreach ($_invoice->getCommentsCollection() as $_comment){
00100 $_fullHistory[$_comment->getEntityId()] =
00101 $this->_prepareHistoryItem($this->__('Invoice #%s comment added', $_invoice->getIncrementId()),
00102 $_comment->getIsCustomerNotified(), $_comment->getCreatedAtDate(), $_comment->getComment());
00103 }
00104 }
00105
00106 foreach ($order->getTracksCollection() as $_track){
00107 $_fullHistory[$_track->getEntityId()] =
00108 $this->_prepareHistoryItem($this->__('Tracking number %s for %s assigned', $_track->getNumber(), $_track->getTitle()),
00109 false, $_track->getCreatedAtDate());
00110 }
00111
00112 krsort($_fullHistory);
00113 return $_fullHistory;
00114 }
00115
00116 protected function _prepareHistoryItem($label, $notified, $created, $comment = '')
00117 {
00118 return array(
00119 'title' => $label,
00120 'notified' => $notified,
00121 'comment' => $comment,
00122 'created_at' => $created
00123 );
00124 }
00125
00126
00127
00128
00129 public function getTabLabel()
00130 {
00131 return Mage::helper('sales')->__('Comments History');
00132 }
00133
00134 public function getTabTitle()
00135 {
00136 return Mage::helper('sales')->__('Order History');
00137 }
00138
00139 public function getTabClass()
00140 {
00141 return 'ajax only';
00142 }
00143
00144 public function getClass()
00145 {
00146 return $this->getTabClass();
00147 }
00148
00149 public function getTabUrl()
00150 {
00151 return $this->getUrl('*/*/commentsHistory', array('_current' => true));
00152 }
00153
00154 public function canShowTab()
00155 {
00156 return true;
00157 }
00158
00159 public function isHidden()
00160 {
00161 return false;
00162 }
00163 }