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_History extends Mage_Core_Block_Template
00036 {
00037
00038 public function __construct()
00039 {
00040 parent::__construct();
00041 $this->setTemplate('sales/order/history.phtml');
00042
00043
00044 $orders = Mage::getResourceModel('sales/order_collection')
00045 ->addAttributeToSelect('*')
00046 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00047 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00048 ->addAttributeToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
00049 ->addAttributeToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
00050 ->addAttributeToSort('created_at', 'desc')
00051 ;
00052
00053 $this->setOrders($orders);
00054
00055 Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('sales')->__('My Orders'));
00056 }
00057
00058 protected function _prepareLayout()
00059 {
00060 parent::_prepareLayout();
00061
00062 $pager = $this->getLayout()->createBlock('page/html_pager', 'sales.order.history.pager')
00063 ->setCollection($this->getOrders());
00064 $this->setChild('pager', $pager);
00065 $this->getOrders()->load();
00066 return $this;
00067 }
00068
00069 public function getPagerHtml()
00070 {
00071 return $this->getChildHtml('pager');
00072 }
00073
00074 public function getViewUrl($order)
00075 {
00076 return $this->getUrl('*/*/view', array('order_id' => $order->getId()));
00077 }
00078
00079 public function getTrackUrl($order)
00080 {
00081 return $this->getUrl('*/*/track', array('order_id' => $order->getId()));
00082 }
00083
00084 public function getReorderUrl($order)
00085 {
00086 return $this->getUrl('*/*/reorder', array('order_id' => $order->getId()));
00087 }
00088
00089 public function getBackUrl()
00090 {
00091 return $this->getUrl('customer/account/');
00092 }
00093 }