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_Info extends Mage_Core_Block_Template
36: {
37: protected $_links = array();
38:
39: protected function _construct()
40: {
41: parent::_construct();
42: $this->setTemplate('sales/order/info.phtml');
43: }
44:
45: protected function _prepareLayout()
46: {
47: if ($headBlock = $this->getLayout()->getBlock('head')) {
48: $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId()));
49: }
50: $this->setChild(
51: 'payment_info',
52: $this->helper('payment')->getInfoBlock($this->getOrder()->getPayment())
53: );
54: }
55:
56: public function getPaymentInfoHtml()
57: {
58: return $this->getChildHtml('payment_info');
59: }
60:
61: 62: 63: 64: 65:
66: public function getOrder()
67: {
68: return Mage::registry('current_order');
69: }
70:
71: public function addLink($name, $path, $label)
72: {
73: $this->_links[$name] = new Varien_Object(array(
74: 'name' => $name,
75: 'label' => $label,
76: 'url' => empty($path) ? '' : Mage::getUrl($path, array('order_id' => $this->getOrder()->getId()))
77: ));
78: return $this;
79: }
80:
81: public function getLinks()
82: {
83: $this->checkLinks();
84: return $this->_links;
85: }
86:
87: private function checkLinks()
88: {
89: $order = $this->getOrder();
90: if (!$order->hasInvoices()) {
91: unset($this->_links['invoice']);
92: }
93: if (!$order->hasShipments()) {
94: unset($this->_links['shipment']);
95: }
96: if (!$order->hasCreditmemos()) {
97: unset($this->_links['creditmemo']);
98: }
99: }
100:
101: 102: 103: 104: 105: 106: 107:
108: public function getReorderUrl($order)
109: {
110: if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
111: return $this->getUrl('sales/guest/reorder', array('order_id' => $order->getId()));
112: }
113: return $this->getUrl('sales/order/reorder', array('order_id' => $order->getId()));
114: }
115:
116: 117: 118: 119: 120: 121: 122:
123: public function getPrintUrl($order)
124: {
125: if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
126: return $this->getUrl('sales/guest/print', array('order_id' => $order->getId()));
127: }
128: return $this->getUrl('sales/order/print', array('order_id' => $order->getId()));
129: }
130:
131: }
132: