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_Rss_Block_Order_Status extends Mage_Core_Block_Template
00035 {
00036 protected function _construct()
00037 {
00038
00039
00040
00041 $this->setCacheKey('rss_order_status_'.$this->getRequest()->getParam('data'));
00042 $this->setCacheLifetime(600);
00043 }
00044
00045 protected function _toHtml()
00046 {
00047 $rssObj = Mage::getModel('rss/rss');
00048 $order = Mage::registry('current_order');
00049 $title = Mage::helper('rss')->__('Order # %s Notification(s)',$order->getIncrementId());
00050 $newurl = Mage::getUrl('sales/order/view',array('order_id' => $order->getId()));
00051 $data = array('title' => $title,
00052 'description' => $title,
00053 'link' => $newurl,
00054 'charset' => 'UTF-8',
00055 );
00056 $rssObj->_addHeader($data);
00057 $resourceModel = Mage::getResourceModel('rss/order');
00058 $results = $resourceModel->getAllCommentCollection($order->getId());
00059 $entityTypes = $resourceModel->getEntityTypeIdsToTypes();
00060 $incrementIds = $resourceModel->getEntityIdsToIncrementIds();
00061 if($results){
00062 foreach($results as $result){
00063 $urlAppend = 'view';
00064 $type = $entityTypes[$result['entity_type_id']];
00065 if($type && $type!='order'){
00066 $urlAppend = $type;
00067 }
00068 $title = Mage::helper('rss')->__('Details for %s #%s', ucwords($type), $incrementIds[$result['parent_id']]);
00069
00070 $description = '<p>'.
00071 Mage::helper('rss')->__('Notified Date: %s<br/>',$this->formatDate($result['created_at'])).
00072 Mage::helper('rss')->__('Comment: %s<br/>',$result['comment']).
00073 '</p>'
00074 ;
00075 $url = Mage::getUrl('sales/order/'.$urlAppend,array('order_id' => $order->getId()));
00076 $data = array(
00077 'title' => $title,
00078 'link' => $url,
00079 'description' => $description,
00080 );
00081 $rssObj->_addEntry($data);
00082 }
00083 }
00084 $title = Mage::helper('rss')->__('Order #%s created at %s', $order->getIncrementId(), $this->formatDate($order->getCreatedAt()));
00085 $url = Mage::getUrl('sales/order/view',array('order_id' => $order->getId()));
00086 $description = '<p>'.
00087 Mage::helper('rss')->__('Current Status: %s<br/>',$order->getStatusLabel()).
00088 Mage::helper('rss')->__('Total: %s<br/>',$order->formatPrice($order->getGrandTotal())).
00089 '</p>'
00090 ;
00091 $data = array(
00092 'title' => $title,
00093 'link' => $url,
00094 'description' => $description,
00095 );
00096 $rssObj->_addEntry($data);
00097 return $rssObj->createRssXml();
00098 }
00099 }