Magebeam_GetOrderBack - Version 0.1.0

Version Notes

Public release

Download this release

Release Info

Developer Magebeam
Extension Magebeam_GetOrderBack
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Magebeam/GetOrderBack/Helper/Data.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magebeam Get Order Back data helper
4
+ *
5
+ * @category Magebeam
6
+ * @package Magebeam_GetOrderBack
7
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Magebeam_GetOrderBack_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ /**
13
+ * Returns boolean flag: true if "UnCancel" action is allowed for order, false if not
14
+ *
15
+ * @return bool
16
+ */
17
+ public function isAllowedOrderUnCancelAction()
18
+ {
19
+ return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/uncancel');
20
+ }
21
+
22
+ /**
23
+ * UnCancels order
24
+ *
25
+ * @param int $orderId Order id
26
+ *
27
+ * @return bool True if order has been unCanceled, false otherwise
28
+ */
29
+ public function unCancelOrder($orderId)
30
+ {
31
+ $unCanceler = Mage::getSingleton('magebeam_getorderback/unCanceler');
32
+ return $unCanceler->unCancelOrder($orderId);
33
+ }
34
+ }
app/code/community/Magebeam/GetOrderBack/Model/Observer.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magebeam Get Order Back observer
4
+ *
5
+ * @category Magebeam
6
+ * @package Magebeam_GetOrderBack
7
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Magebeam_GetOrderBack_Model_Observer
11
+ {
12
+ /**
13
+ * Adds "UnCancel" button to order view page
14
+ *
15
+ * @param Varien_Event_Observer $event Event object
16
+ *
17
+ * @return Magebeam_GetOrderBack_Model_Observer
18
+ */
19
+ public function addUnCancelOrderButton(Varien_Event_Observer $event)
20
+ {
21
+ /** @var Mage_Adminhtml_Block_Sales_Order_View $block */
22
+ $block = $event->getBlock();
23
+ if ($block->getId() != 'sales_order_view') {
24
+ return $this;
25
+ }
26
+ $this->_addUnCancelOrderButton($block);
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * Adds "UnCancel" button to order view page
32
+ *
33
+ * @param Mage_Adminhtml_Block_Sales_Order_View $orderViewBlock Order view block
34
+ *
35
+ * @return Magebeam_GetOrderBack_Model_Observer
36
+ *
37
+ */
38
+ protected function _addUnCancelOrderButton($orderViewBlock)
39
+ {
40
+ $order = $orderViewBlock->getOrder();
41
+ if (!$order->getId() || $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
42
+ return $this;
43
+ }
44
+ if (Mage::helper('magebeam_getorderback')->isAllowedOrderUnCancelAction()) {
45
+ $orderViewBlock->addButton('uncancel', array(
46
+ 'label' => Mage::helper('magebeam_getorderback')->__('UnCancel'),
47
+ 'class' => 'go',
48
+ 'onclick' => 'deleteConfirm(\''. Mage::helper('adminhtml')->__('Are you sure you want to do this?')
49
+ .'\', \'' . $orderViewBlock->getUrl('*/*/unCancel', array('order_id' => $order->getId())) . '\')',
50
+ ));
51
+ }
52
+ return $this;
53
+ }
54
+ }
app/code/community/Magebeam/GetOrderBack/Model/UnCanceler.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magebeam Get Order Back
4
+ *
5
+ * @category Magebeam
6
+ * @package Magebeam_GetOrderBack
7
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Magebeam_GetOrderBack_Model_UnCanceler extends Mage_Core_Model_Abstract
11
+ {
12
+ /**
13
+ * UnCancels order
14
+ *
15
+ * @param int $orderId Order id to unCancel
16
+ *
17
+ * @return bool True if order successfully unCanceled, false otherwise
18
+ */
19
+ public function unCancelOrder($orderId)
20
+ {
21
+ /** @var Mage_Sales_Model_Order $order */
22
+ $order = Mage::getModel('sales/order')->load($orderId);
23
+ if (!$order->getId()) {
24
+ return false;
25
+ }
26
+ $order->setState(
27
+ Mage_Sales_Model_Order::STATE_HOLDED,
28
+ Mage_Sales_Model_Order::STATE_HOLDED,
29
+ Mage::helper('magebeam_getorderback')->__('The order has been uncancelled.')
30
+ );
31
+ $order->save();
32
+ /** @var $item Mage_Sales_Model_Order_Item */
33
+ foreach ($order->getAllItems() as $item) {
34
+ $item->setQtyCanceled(0);
35
+ $item->save();
36
+ }
37
+ $order = Mage::getModel('sales/order')->load($order->getId());
38
+ return $order->getState() == Mage_Sales_Model_Order::STATE_HOLDED;
39
+ }
40
+ }
app/code/community/Magebeam/GetOrderBack/controllers/Adminhtml/Sales/OrderController.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magebeam Get Order Back order controller
4
+ *
5
+ * @category Magebeam
6
+ * @package Magebeam_GetOrderBack
7
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
8
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
9
+ */
10
+ class Magebeam_GetOrderBack_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+ /**
13
+ * Order id param name
14
+ */
15
+ const PARAM_ORDER_ID = 'order_id';
16
+
17
+ /**
18
+ * UnCancel order action
19
+ */
20
+ public function unCancelAction()
21
+ {
22
+ $orderId = $this->getRequest()->getParam(self::PARAM_ORDER_ID);
23
+ $isOrderUnCanceled = Mage::helper('magebeam_getorderback')->unCancelOrder($orderId);
24
+ if ($isOrderUnCanceled) {
25
+ $this->_getSession()->addSuccess(
26
+ $this->__('The order has been uncancelled.')
27
+ );
28
+ } else {
29
+ $this->_getSession()->addError(
30
+ Mage::helper('sales')->__('This order no longer exists.')
31
+ );
32
+ }
33
+ $this->_redirect('*/sales_order/index');
34
+ }
35
+ }
app/code/community/Magebeam/GetOrderBack/etc/adminhtml.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magebeam
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this package
15
+ * to newer versions in the future.
16
+ *
17
+ * @category Magebeam
18
+ * @package Magebeam_OrderDeleter
19
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <acl>
25
+ <resources>
26
+ <admin>
27
+ <children>
28
+ <sales>
29
+ <children>
30
+ <order>
31
+ <children>
32
+ <actions>
33
+ <children>
34
+ <uncancel translate="title"><title>UnCancel</title></uncancel>
35
+ </children>
36
+ </actions>
37
+ </children>
38
+ </order>
39
+ </children>
40
+ </sales>
41
+ </children>
42
+ </admin>
43
+ </resources>
44
+ </acl>
45
+ </config>
app/code/community/Magebeam/GetOrderBack/etc/config.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magebeam
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this package
15
+ * to newer versions in the future.
16
+ *
17
+ * @category Magebeam
18
+ * @package Magebeam_GetOrderBack
19
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Magebeam_GetOrderBack>
26
+ <version>0.1.1</version>
27
+ </Magebeam_GetOrderBack>
28
+ </modules>
29
+ <global>
30
+ <blocks>
31
+ <magebeam_getorderback>
32
+ <class>Magebeam_GetOrderBack_Block</class>
33
+ </magebeam_getorderback>
34
+ </blocks>
35
+ <models>
36
+ <magebeam_getorderback>
37
+ <class>Magebeam_GetOrderBack_Model</class>
38
+ </magebeam_getorderback>
39
+ </models>
40
+ <helpers>
41
+ <magebeam_getorderback>
42
+ <class>Magebeam_GetOrderBack_Helper</class>
43
+ </magebeam_getorderback>
44
+ </helpers>
45
+ </global>
46
+ <adminhtml>
47
+ <events>
48
+ <adminhtml_widget_container_html_before>
49
+ <observers>
50
+ <magebeam_getorderback>
51
+ <class>magebeam_getorderback/observer</class>
52
+ <method>addUnCancelOrderButton</method>
53
+ </magebeam_getorderback>
54
+ </observers>
55
+ </adminhtml_widget_container_html_before>
56
+ </events>
57
+ <translate>
58
+ <modules>
59
+ <Magebeam_OrderDeleter>
60
+ <files>
61
+ <default>Magebeam_GetOrderBack.csv</default>
62
+ </files>
63
+ </Magebeam_OrderDeleter>
64
+ </modules>
65
+ </translate>
66
+ </adminhtml>
67
+ <admin>
68
+ <routers>
69
+ <adminhtml>
70
+ <use>admin</use>
71
+ <args>
72
+ <modules>
73
+ <Magebeam_GetOrderBack after="Mage_Adminhtml">Magebeam_GetOrderBack_Adminhtml</Magebeam_GetOrderBack>
74
+ </modules>
75
+ </args>
76
+ </adminhtml>
77
+ </routers>
78
+ </admin>
79
+ </config>
app/etc/modules/Magebeam_GetOrderBack.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magebeam
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * It is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this package
15
+ * to newer versions in the future.
16
+ *
17
+ * @category Magebeam
18
+ * @package Magebeam_GetOrderBack
19
+ * @copyright Copyright (c) 2012 Magebeam (http://www.magebeam.com)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Magebeam_GetOrderBack>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </Magebeam_GetOrderBack>
29
+ </modules>
30
+ </config>
app/locale/en_US/Magebeam_GetOrderBack.csv ADDED
@@ -0,0 +1,2 @@
 
 
1
+ "UnCancel","UnCancel"
2
+ "The order has been uncancelled.","The order has been uncancelled."
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Magebeam_GetOrderBack</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>&lt;strong&gt;Magebeam Get Order Back&lt;/strong&gt; gives the store owner ability to uncancel any accidentally canceled order.</summary>
10
+ <description>&lt;strong&gt;Magebeam Get Order Back&lt;/strong&gt; is small but useful utility that can uncancel any accidentally canceled order in back office from order edit page.</description>
11
+ <notes>Public release</notes>
12
+ <authors><author><name>Magebeam</name><user>magebeam</user><email>team@magebeam.com</email></author></authors>
13
+ <date>2013-02-21</date>
14
+ <time>07:51:02</time>
15
+ <contents><target name="magecommunity"><dir name="Magebeam"><dir name="GetOrderBack"><dir name="Helper"><file name="Data.php" hash="f2fc83ac05f6af413a7ca462e17a5988"/></dir><dir name="Model"><file name="Observer.php" hash="f9865559cc67b4f33e1002d0e54dbef1"/><file name="UnCanceler.php" hash="8864631d81555b76be7ce9f590f06f8a"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Sales"><file name="OrderController.php" hash="6cb7011674a568a5042facbea2b0edd4"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e18b4918b3be7a25634e0469bf93a309"/><file name="config.xml" hash="8f6a55bafab7f2c38ab33c2e504c6a7c"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magebeam_GetOrderBack.xml" hash="c3fb3b3c479f7336dc0b836ed197473a"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Magebeam_GetOrderBack.csv" hash="8799633a014c94466f1331b8f7628fd6"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>