1. <?php
  2. /**
  3. * Magento Enterprise Edition
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Magento Enterprise Edition License
  8. * that is bundled with this package in the file LICENSE_EE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://www.magentocommerce.com/license/enterprise-edition
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to [email protected] so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Sales
  23. * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://www.magentocommerce.com/license/enterprise-edition
  25. */
  26. /**
  27. * Sales order history block
  28. *
  29. * @category Mage
  30. * @package Mage_Sales
  31. * @author Magento Core Team <[email protected]>
  32. */
  33. class Mage_Sales_Block_Order_History extends Mage_Core_Block_Template
  34. {
  35. public function __construct()
  36. {
  37. parent::__construct();
  38. $this->setTemplate('sales/order/history.phtml');
  39. $orders = Mage::getResourceModel('sales/order_collection')
  40. ->addFieldToSelect('*')
  41. ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
  42. ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
  43. ->setOrder('created_at', 'desc')
  44. ;
  45. $this->setOrders($orders);
  46. Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('root')->setHeaderTitle(Mage::helper('sales')->__('My Orders'));
  47. }
  48. protected function _prepareLayout()
  49. {
  50. parent::_prepareLayout();
  51. $pager = $this->getLayout()->createBlock('page/html_pager', 'sales.order.history.pager')
  52. ->setCollection($this->getOrders());
  53. $this->setChild('pager', $pager);
  54. $this->getOrders()->load();
  55. return $this;
  56. }
  57. public function getPagerHtml()
  58. {
  59. return $this->getChildHtml('pager');
  60. }
  61. public function getViewUrl($order)
  62. {
  63. return $this->getUrl('*/*/view', array('order_id' => $order->getId()));
  64. }
  65. public function getTrackUrl($order)
  66. {
  67. return $this->getUrl('*/*/track', array('order_id' => $order->getId()));
  68. }
  69. public function getReorderUrl($order)
  70. {
  71. return $this->getUrl('*/*/reorder', array('order_id' => $order->getId()));
  72. }
  73. public function getBackUrl()
  74. {
  75. return $this->getUrl('customer/account/');
  76. }
  77. }
Comments powered by Disqus