Version Notes
Fixed minor bugs.
Download this release
Release Info
Developer | WebCreta |
Extension | Webcreta_Prevnext |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
app/code/local/Webcreta/Prevnext/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webcreta_Prevnext_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Webcreta/Prevnext/Model/Prevnext.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Webcreta_Prevnext_Model_Prevnext extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('prevnext/prevnext');
|
9 |
+
|
10 |
+
}
|
11 |
+
|
12 |
+
public function adminhtmlWidgetContainerHtmlBefore(Varien_Event_Observer $observer)
|
13 |
+
{
|
14 |
+
$enable = Mage::getStoreConfig('webcreta/webcreta_group/webcreta_order_select',Mage::app()->getStore());
|
15 |
+
|
16 |
+
if($enable == 1){
|
17 |
+
$block = $observer->getBlock();
|
18 |
+
$orderId = Mage::app()->getRequest()->getParam('order_id');
|
19 |
+
|
20 |
+
if(isset($orderId) && !empty($orderId)){
|
21 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
22 |
+
$sql = "select entity_id from sales_flat_order where entity_id < $orderId order by entity_id desc limit 1;";
|
23 |
+
$nextRows = $connection->fetchRow($sql);
|
24 |
+
|
25 |
+
$nextOrderId = $nextRows['entity_id'];
|
26 |
+
|
27 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
28 |
+
$sql = "select entity_id from sales_flat_order where entity_id > $orderId order by entity_id asc limit 1;";
|
29 |
+
$prevRows = $connection->fetchRow($sql);
|
30 |
+
// echo "<pre>";print_r($prevRows);die;
|
31 |
+
$prevOrderId = $prevRows['entity_id'];
|
32 |
+
}
|
33 |
+
|
34 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
|
35 |
+
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
|
36 |
+
if(isset($nextOrderId) && !empty($nextOrderId)){
|
37 |
+
$prevUrl = Mage::helper("adminhtml")->getUrl("*/sales_order/view",array('order_id'=>$nextOrderId));
|
38 |
+
$block->addButton('Prev', array(
|
39 |
+
'label' => Mage::helper('core')->__('Prev'),
|
40 |
+
'onclick' => "setLocation('{$prevUrl}')",
|
41 |
+
));
|
42 |
+
}
|
43 |
+
|
44 |
+
if(isset($prevOrderId) && !empty($prevOrderId)){
|
45 |
+
$nextUrl = Mage::helper("adminhtml")->getUrl("*/sales_order/view",array('order_id'=>$prevOrderId));
|
46 |
+
$block->addButton('Next', array(
|
47 |
+
'label' => Mage::helper('core')->__('Next'),
|
48 |
+
'onclick' => "setLocation('{$nextUrl}')",
|
49 |
+
));
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
public function adminhtmlWidgetContainerHtmlBeforecustomer(Varien_Event_Observer $observer)
|
59 |
+
{
|
60 |
+
|
61 |
+
$enable = Mage::getStoreConfig('webcreta/webcreta_group/webcreta_customer_select',Mage::app()->getStore());
|
62 |
+
|
63 |
+
if($enable == 1){
|
64 |
+
|
65 |
+
$block = $observer->getBlock();
|
66 |
+
$custId = Mage::app()->getRequest()->getParam('id');
|
67 |
+
|
68 |
+
if(isset($custId) && !empty($custId)){
|
69 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
70 |
+
$sql = "select entity_id from customer_entity where entity_id < $custId order by entity_id desc limit 1;";
|
71 |
+
$nextRows = $connection->fetchRow($sql);
|
72 |
+
|
73 |
+
$nextCustId = $nextRows['entity_id'];
|
74 |
+
|
75 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
76 |
+
$sql = "select entity_id from customer_entity where entity_id > $custId order by entity_id asc limit 1;";
|
77 |
+
$prevRows = $connection->fetchRow($sql);
|
78 |
+
// echo "<pre>";print_r($prevRows);die;
|
79 |
+
$prevCustId = $prevRows['entity_id'];
|
80 |
+
}
|
81 |
+
|
82 |
+
if ($block instanceof Mage_Adminhtml_Block_Customer_Edit) {
|
83 |
+
if ($block instanceof Mage_Adminhtml_Block_Customer_Edit) {
|
84 |
+
if(isset($nextCustId) && !empty($nextCustId)){
|
85 |
+
$prevUrl = Mage::helper("adminhtml")->getUrl("*/customer/edit",array('id'=>$nextCustId));
|
86 |
+
$block->addButton('Prev', array(
|
87 |
+
'label' => Mage::helper('core')->__('Prev'),
|
88 |
+
'onclick' => "setLocation('{$prevUrl}')",
|
89 |
+
));
|
90 |
+
}
|
91 |
+
|
92 |
+
if(isset($prevCustId) && !empty($prevCustId)){
|
93 |
+
$nextUrl = Mage::helper("adminhtml")->getUrl("*/customer/edit",array('id'=>$prevCustId));
|
94 |
+
$block->addButton('Next', array(
|
95 |
+
'label' => Mage::helper('core')->__('Next'),
|
96 |
+
'onclick' => "setLocation('{$nextUrl}')",
|
97 |
+
));
|
98 |
+
}
|
99 |
+
}
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
public function adminhtmlWidgetContainerHtmlBeforeproduct(Varien_Event_Observer $observer)
|
108 |
+
{
|
109 |
+
$enable = Mage::getStoreConfig('webcreta/webcreta_group/webcreta_product_select',Mage::app()->getStore());
|
110 |
+
|
111 |
+
if($enable == 1){
|
112 |
+
$layout = Mage::app()->getLayout();
|
113 |
+
$productEditBlock = $layout->getBlock('product_edit');
|
114 |
+
$block = $observer->getBlock();
|
115 |
+
$proId = Mage::app()->getRequest()->getParam('id');
|
116 |
+
//echo "<pre>";print_r($custId);die;
|
117 |
+
$saveAndContinueButton = $productEditBlock->getChild('save_and_edit_button');
|
118 |
+
|
119 |
+
if(isset($proId) && !empty($proId)){
|
120 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
121 |
+
$sql = "select entity_id from catalog_product_entity where entity_id > $proId order by entity_id asc limit 1;";
|
122 |
+
$nextRows = $connection->fetchRow($sql);
|
123 |
+
$nextProId = $nextRows['entity_id'];
|
124 |
+
|
125 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
126 |
+
$sql = "select entity_id from catalog_product_entity where entity_id < $proId order by entity_id desc limit 1;";
|
127 |
+
$prevRows = $connection->fetchRow($sql);
|
128 |
+
$prevProId = $prevRows['entity_id'];
|
129 |
+
}
|
130 |
+
|
131 |
+
$container = $layout->createBlock('core/text_list', 'button_container');
|
132 |
+
$container->append($saveAndContinueButton);
|
133 |
+
// Create new button
|
134 |
+
|
135 |
+
if(isset($prevProId) && !empty($prevProId)){
|
136 |
+
$prevUrl = Mage::helper("adminhtml")->getUrl("*/catalog_product/edit",array('id'=>$prevProId));
|
137 |
+
$next = $layout->createBlock('adminhtml/widget_button')
|
138 |
+
->setData(array(
|
139 |
+
'label' => Mage::helper('prevnext')->__('Prev'),
|
140 |
+
'onclick' => "setLocation('{$prevUrl}')",
|
141 |
+
'class' => 'save'
|
142 |
+
));
|
143 |
+
$container->append($next);
|
144 |
+
}
|
145 |
+
|
146 |
+
if(isset($nextProId) && !empty($nextProId)){
|
147 |
+
$nextUrl = Mage::helper("adminhtml")->getUrl("*/catalog_product/edit",array('id'=>$nextProId));
|
148 |
+
$prev = $layout->createBlock('adminhtml/widget_button')
|
149 |
+
->setData(array(
|
150 |
+
'label' => Mage::helper('prevnext')->__('Next'),
|
151 |
+
'onclick' => "setLocation('{$nextUrl}')",
|
152 |
+
'class' => 'save'
|
153 |
+
));
|
154 |
+
$container->append($prev);
|
155 |
+
}
|
156 |
+
|
157 |
+
// Create a container that will gather existing "Save and Continue Edit" button and the new button
|
158 |
+
|
159 |
+
|
160 |
+
// Append existing "Save and Continue Edit" button and the new button to the container
|
161 |
+
|
162 |
+
|
163 |
+
// Replace the existing "Save and Continue Edit" button with our container
|
164 |
+
$productEditBlock->setChild('save_and_edit_button', $container);
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
}
|
app/code/local/Webcreta/Prevnext/etc/config.xml
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Webcreta_Prevnext>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Webcreta_Prevnext>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<prevnext>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Webcreta_Prevnext</module>
|
14 |
+
<frontName>prevnext</frontName>
|
15 |
+
</args>
|
16 |
+
</prevnext>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<prevnext>
|
21 |
+
<file>prevnext.xml</file>
|
22 |
+
</prevnext>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<prevnext>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Webcreta_Prevnext</module>
|
32 |
+
<frontName>prevnext</frontName>
|
33 |
+
</args>
|
34 |
+
</prevnext>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<acl>
|
39 |
+
<resources>
|
40 |
+
<all>
|
41 |
+
<title>Allow Everything</title>
|
42 |
+
</all>
|
43 |
+
<admin>
|
44 |
+
<children>
|
45 |
+
<system>
|
46 |
+
<children>
|
47 |
+
<config>
|
48 |
+
<children>
|
49 |
+
<webcreta>
|
50 |
+
<title>webcreta - All</title>
|
51 |
+
</webcreta>
|
52 |
+
</children>
|
53 |
+
</config>
|
54 |
+
</children>
|
55 |
+
</system>
|
56 |
+
</children>
|
57 |
+
</admin>
|
58 |
+
</resources>
|
59 |
+
</acl>
|
60 |
+
<layout>
|
61 |
+
<updates>
|
62 |
+
<prevnext>
|
63 |
+
<file>prevnext.xml</file>
|
64 |
+
</prevnext>
|
65 |
+
</updates>
|
66 |
+
</layout>
|
67 |
+
</adminhtml>
|
68 |
+
<global>
|
69 |
+
<events>
|
70 |
+
<adminhtml_widget_container_html_before><!-- identifier of the event we want to catch -->
|
71 |
+
<observers>
|
72 |
+
<prevnext><!-- identifier of the event handler -->
|
73 |
+
<class>Webcreta_Prevnext_Model_Prevnext</class><!-- observers class alias -->
|
74 |
+
<type>model</type><!-- class method call type; valid are model, object and singleton -->
|
75 |
+
<method>adminhtmlWidgetContainerHtmlBefore</method><!-- observer's method to be called -->
|
76 |
+
<args></args> <!-- additional arguments passed to observer -->
|
77 |
+
</prevnext>
|
78 |
+
</observers>
|
79 |
+
</adminhtml_widget_container_html_before>
|
80 |
+
<adminhtml_widget_container_html_before><!-- identifier of the event we want to catch -->
|
81 |
+
<observers>
|
82 |
+
<custprevnext><!-- identifier of the event handler -->
|
83 |
+
<class>Webcreta_Prevnext_Model_Prevnext</class><!-- observers class alias -->
|
84 |
+
<type>model</type><!-- class method call type; valid are model, object and singleton -->
|
85 |
+
<method>adminhtmlWidgetContainerHtmlBeforecustomer</method><!-- observer's method to be called -->
|
86 |
+
<args></args> <!-- additional arguments passed to observer -->
|
87 |
+
</custprevnext>
|
88 |
+
</observers>
|
89 |
+
</adminhtml_widget_container_html_before>
|
90 |
+
<controller_action_layout_render_before_adminhtml_catalog_product_edit>
|
91 |
+
<observers>
|
92 |
+
<proprevnext>
|
93 |
+
<class>Webcreta_Prevnext_Model_Prevnext</class>
|
94 |
+
<method>adminhtmlWidgetContainerHtmlBeforeproduct</method>
|
95 |
+
</proprevnext>
|
96 |
+
</observers>
|
97 |
+
</controller_action_layout_render_before_adminhtml_catalog_product_edit>
|
98 |
+
</events>
|
99 |
+
|
100 |
+
<helpers>
|
101 |
+
<prevnext>
|
102 |
+
<class>Webcreta_Prevnext_Helper</class>
|
103 |
+
</prevnext>
|
104 |
+
</helpers>
|
105 |
+
</global>
|
106 |
+
</config>
|
app/code/local/Webcreta/Prevnext/etc/system.xml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<webcreta translate="label" module="prevnext">
|
5 |
+
<label>Webcreta Prevnext</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</webcreta>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<webcreta translate="label" module="prevnext">
|
11 |
+
<label>Webcreta Prevnext Settings</label>
|
12 |
+
<tab>webcreta</tab>
|
13 |
+
<sort_order>1000</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
|
18 |
+
<groups>
|
19 |
+
<webcreta_group translate="label" module="prevnext">
|
20 |
+
<label>Webcreta Prevnext Options</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1000</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
|
27 |
+
<fields>
|
28 |
+
<webcreta_product_select translate="label">
|
29 |
+
<label>Webcreta Product Prevnext Enable</label>
|
30 |
+
<frontend_type>select</frontend_type>
|
31 |
+
<sort_order>90</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
36 |
+
</webcreta_product_select>
|
37 |
+
|
38 |
+
<webcreta_order_select translate="label">
|
39 |
+
<label>Webcreta Order Prevnext Enable</label>
|
40 |
+
<frontend_type>select</frontend_type>
|
41 |
+
<sort_order>100</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
46 |
+
</webcreta_order_select>
|
47 |
+
|
48 |
+
<webcreta_customer_select translate="label">
|
49 |
+
<label>Webcreta Customer Prevnext Enable</label>
|
50 |
+
<frontend_type>select</frontend_type>
|
51 |
+
<sort_order>110</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>1</show_in_store>
|
55 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
56 |
+
</webcreta_customer_select>
|
57 |
+
</fields>
|
58 |
+
</webcreta_group>
|
59 |
+
</groups>
|
60 |
+
</webcreta>
|
61 |
+
</sections>
|
62 |
+
</config>
|
app/etc/modules/Webcreta_Prevnext.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Webcreta_Prevnext>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Webcreta_Prevnext>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Webcreta_Prevnext</name>
|
4 |
+
<version>1.0.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>This extension adds a Previous and Next button to your Magento Admin Panel. It allows jump from one product to another and same for Orders ans coustomers in backend.</summary>
|
10 |
+
<description>There are multiple Orders,Products and Customers in your Magento Admin Panel. While editing you need to go back to overview page and
|
11 |
+
detail page. With this extension you don't have to go back on overview page and pick the another item. You just have to click on Previous Next button for easily navigate to edit Orders, Products and Customers on detail page.</description>
|
12 |
+
<notes>Fixed minor bugs.</notes>
|
13 |
+
<authors><author><name>Webcreta</name><user>Webcreta</user><email>webcreta@gmail.com</email></author></authors>
|
14 |
+
<date>2016-12-28</date>
|
15 |
+
<time>06:41:55</time>
|
16 |
+
<contents><target name="magelocal"><dir name="Webcreta"><dir name="Prevnext"><dir name="Helper"><file name="Data.php" hash="a88436cd96744edb8c4e73ec05915429"/></dir><dir name="Model"><file name="Prevnext.php" hash="2899444065216883f912b6798d220ad7"/></dir><dir name="etc"><file name="config.xml" hash="b0b5ecb2ca3ef628e78bec63d5cd0a89"/><file name="system.xml" hash="f665fd4ee8e4b083dabff112ee122f4e"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webcreta_Prevnext.xml" hash="e2f52bf816f5fc0f413eaeab812188e9"/></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|