1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
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 license@magentocommerce.com 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_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: require_once('CreateController.php');
28: /**
29: * Adminhtml sales order edit controller
30: *
31: * @category Mage
32: * @package Mage_Adminhtml
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Adminhtml_Sales_Order_EditController extends Mage_Adminhtml_Sales_Order_CreateController
36: {
37: /**
38: * Start edit order initialization
39: */
40: public function startAction()
41: {
42: $this->_getSession()->clear();
43: $orderId = $this->getRequest()->getParam('order_id');
44: $order = Mage::getModel('sales/order')->load($orderId);
45:
46: try {
47: if ($order->getId()) {
48: $this->_getSession()->setUseOldShippingMethod(true);
49: $this->_getOrderCreateModel()->initFromOrder($order);
50: $this->_redirect('*/*');
51: }
52: else {
53: $this->_redirect('*/sales_order/');
54: }
55: } catch (Mage_Core_Exception $e) {
56: Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
57: $this->_redirect('*/sales_order/view', array('order_id' => $orderId));
58: } catch (Exception $e) {
59: Mage::getSingleton('adminhtml/session')->addException($e, $e->getMessage());
60: $this->_redirect('*/sales_order/view', array('order_id' => $orderId));
61: }
62: }
63:
64: /**
65: * Index page
66: */
67: public function indexAction()
68: {
69: $this->_title($this->__('Sales'))->_title($this->__('Orders'))->_title($this->__('Edit Order'));
70: $this->loadLayout();
71:
72: $this->_initSession()
73: ->_setActiveMenu('sales/order')
74: ->renderLayout();
75: }
76:
77: /**
78: * Acl check for admin
79: *
80: * @return bool
81: */
82: protected function _isAllowed()
83: {
84: return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/edit');
85: }
86: }
87: