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
00035 class Mage_Sales_Block_Order_Recent extends Mage_Core_Block_Template
00036 {
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041
00042
00043 $orders = Mage::getResourceModel('sales/order_collection')
00044 ->addAttributeToSelect('*')
00045 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00046 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00047 ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
00048 ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
00049 ->addAttributeToSort('created_at', 'desc')
00050 ->setPageSize('5')
00051 ->load()
00052 ;
00053
00054 $this->setOrders($orders);
00055 }
00056
00057 public function getViewUrl($order)
00058 {
00059 return $this->getUrl('sales/order/view', array('order_id' => $order->getId()));
00060 }
00061
00062 public function getTrackUrl($order)
00063 {
00064 return $this->getUrl('sales/order/track', array('order_id' => $order->getId()));
00065 }
00066
00067 protected function _toHtml()
00068 {
00069 if ($this->getOrders()->getSize() > 0) {
00070 return parent::_toHtml();
00071 }
00072 return '';
00073 }
00074
00075 public function getReorderUrl($order)
00076 {
00077 return $this->getUrl('sales/order/reorder', array('order_id' => $order->getId()));
00078 }
00079 }