1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34:
35: class Mage_Sales_Block_Order_Recent extends Mage_Core_Block_Template
36: {
37:
38: public function __construct()
39: {
40: parent::__construct();
41:
42:
43: $orders = Mage::getResourceModel('sales/order_collection')
44: ->addAttributeToSelect('*')
45: ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
46: ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
47: ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
48: ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
49: ->addAttributeToSort('created_at', 'desc')
50: ->setPageSize('5')
51: ->load()
52: ;
53:
54: $this->setOrders($orders);
55: }
56:
57: public function getViewUrl($order)
58: {
59: return $this->getUrl('sales/order/view', array('order_id' => $order->getId()));
60: }
61:
62: public function getTrackUrl($order)
63: {
64: return $this->getUrl('sales/order/track', array('order_id' => $order->getId()));
65: }
66:
67: protected function _toHtml()
68: {
69: if ($this->getOrders()->getSize() > 0) {
70: return parent::_toHtml();
71: }
72: return '';
73: }
74:
75: public function getReorderUrl($order)
76: {
77: return $this->getUrl('sales/order/reorder', array('order_id' => $order->getId()));
78: }
79: }
80: