Creare_MassLandscapeShippingLabel - Version 1.0.0

Version Notes

To be tested on <1.4 and 1.6>

Download this release

Release Info

Developer E-Commerce Web Design
Extension Creare_MassLandscapeShippingLabel
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Creare/MassLandscapeShippingLabel/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Creare_MassLandscapeShippingLabel_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
4
+ {
5
+
6
+ protected function _prepareMassaction()
7
+ {
8
+ $this->setMassactionIdField('entity_id');
9
+ $this->getMassactionBlock()->setFormFieldName('order_ids');
10
+ $this->getMassactionBlock()->setUseSelectAll(false);
11
+
12
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
13
+ $this->getMassactionBlock()->addItem('cancel_order', array(
14
+ 'label'=> Mage::helper('sales')->__('Cancel'),
15
+ 'url' => $this->getUrl('*/sales_order/massCancel'),
16
+ ));
17
+ }
18
+
19
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
20
+ $this->getMassactionBlock()->addItem('hold_order', array(
21
+ 'label'=> Mage::helper('sales')->__('Hold'),
22
+ 'url' => $this->getUrl('*/sales_order/massHold'),
23
+ ));
24
+ }
25
+
26
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
27
+ $this->getMassactionBlock()->addItem('unhold_order', array(
28
+ 'label'=> Mage::helper('sales')->__('Unhold'),
29
+ 'url' => $this->getUrl('*/sales_order/massUnhold'),
30
+ ));
31
+ }
32
+
33
+ $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
34
+ 'label'=> Mage::helper('sales')->__('Print Invoices'),
35
+ 'url' => $this->getUrl('*/sales_order/pdfinvoices'),
36
+ ));
37
+
38
+ $this->getMassactionBlock()->addItem('pdfshipments_order', array(
39
+ 'label'=> Mage::helper('sales')->__('Print Packingslips'),
40
+ 'url' => $this->getUrl('*/sales_order/pdfshipments'),
41
+ ));
42
+
43
+ $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
44
+ 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
45
+ 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
46
+ ));
47
+
48
+ $this->getMassactionBlock()->addItem('pdfdocs_order', array(
49
+ 'label'=> Mage::helper('sales')->__('Print All'),
50
+ 'url' => $this->getUrl('*/sales_order/pdfdocs'),
51
+ ));
52
+
53
+ //$this->getMassactionBlock()->addItem('print_shipping_label', array(
54
+ // 'label'=> Mage::helper('sales')->__('Print Shipping Labels'),
55
+ // 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
56
+ //));
57
+
58
+ $this->getMassactionBlock()->addItem('mass_landscape_shipping_label', array(
59
+ 'label'=> Mage::helper('sales')->__('Print Landscape Shipping Labels'),
60
+ 'url' => $this->getUrl('creareadmin/masslandscapeshippinglabel/massLandscapeShippingLabel'),
61
+ ));
62
+
63
+ return $this;
64
+ }
65
+ }
app/code/local/Creare/MassLandscapeShippingLabel/Block/View/Masslandscapeshippinglabel.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Creare_MassLandscapeShippingLabel_Block_View_Masslandscapeshippinglabel extends Mage_Adminhtml_Block_Sales_Order_View
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->_addButton('landscape_shipping', array(
10
+ 'label' => Mage::helper('sales')->__('Print Landscape Shipping Label'),
11
+ 'onclick' => 'setLocation(\'' . $this->getLandscapeShippingLabelUrl() . '\')',
12
+ ));
13
+ }
14
+
15
+ public function getLandscapeShippingLabelUrl()
16
+ {
17
+ return $this->getUrl('creareadmin/masslandscapeshippinglabel/singleLandscapeShippingLabel');
18
+ }
19
+
20
+ }
app/code/local/Creare/MassLandscapeShippingLabel/controllers/MasslandscapeshippinglabelController.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once("Mage/Adminhtml/controllers/Sales/ShipmentController.php");
3
+ class Creare_MassLandscapeShippingLabel_MasslandscapeshippinglabelController extends Mage_Adminhtml_Controller_Sales_Shipment
4
+ {
5
+
6
+ private function array_mpop($array, $iterate)
7
+ {
8
+ if(!is_array($array) && is_int($iterate))
9
+ return false;
10
+
11
+ while(($iterate--)!=false)
12
+ array_pop($array);
13
+ return $array;
14
+ }
15
+
16
+ public function singleLandscapeShippingLabelAction()
17
+ {
18
+ $request = $this->getRequest();
19
+
20
+ $ids = $request->getParam('order_id');
21
+
22
+ $pdfarray = array();
23
+
24
+ $order = Mage::getModel('sales/order')->load($ids);
25
+
26
+ $shipaddr= trim($order->getShippingAddress()->getFormated(true));
27
+ $splitx=explode("\n",$shipaddr);
28
+ $split=explode("<br/>",$shipaddr);
29
+
30
+ foreach($split as $sp):
31
+ if(stristr($sp,"<br />")){
32
+ $temp = explode("<br />", $sp);
33
+ foreach($temp as $t){
34
+ $pdfarray[$i]["addr"][] .= $t;
35
+ }
36
+ } else {
37
+ $pdfarray[$i]["addr"][] = $sp;
38
+ }
39
+ endforeach;
40
+
41
+ $pdf = new Zend_Pdf();
42
+
43
+ foreach($pdfarray as $pdfarr):
44
+
45
+ $temp = $this->array_mpop($pdfarr["addr"], 2);
46
+
47
+ $page = $pdf->newPage('255:82:');
48
+
49
+ $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 13);
50
+
51
+ $i = 70;
52
+
53
+ foreach($temp as $addy){
54
+ $page->drawText(trim(strtoupper($addy)), 5,$i, 'UTF-8');
55
+ $i = $i-13;
56
+ }
57
+
58
+ $pdf->pages[] = $page;
59
+
60
+ endforeach;
61
+
62
+ $pdfData = $pdf->render();
63
+
64
+ $this->_prepareDownloadResponse('Order('.$ids.')-ShippingLabel-'.date('d-m-Y-H-i-s').'.pdf', $pdf->render(), 'application/pdf');
65
+
66
+ }
67
+
68
+ public function massLandscapeShippingLabelAction()
69
+ {
70
+ $request = $this->getRequest();
71
+
72
+ $ids = $request->getParam('order_ids');
73
+
74
+ if(!$ids){
75
+ $ids = array($request->getParam('order_id'));
76
+ }
77
+
78
+ $pdfarray = array();
79
+
80
+ for($i=0;$i<count($ids);$i++):
81
+
82
+ $order = Mage::getModel('sales/order')->load($ids[$i]);
83
+
84
+ $shipaddr= trim($order->getShippingAddress()->getFormated(true));
85
+ $splitx=explode("\n",$shipaddr);
86
+ $split=explode("<br/>",$shipaddr);
87
+
88
+ foreach($split as $sp):
89
+ if(stristr($sp,"<br />")){
90
+ $temp = explode("<br />", $sp);
91
+ foreach($temp as $t){
92
+ $pdfarray[$i]["addr"][] .= $t;
93
+ }
94
+ } else {
95
+ $pdfarray[$i]["addr"][] = $sp;
96
+ }
97
+ endforeach;
98
+
99
+ endfor;
100
+
101
+ $pdf = new Zend_Pdf();
102
+
103
+ foreach($pdfarray as $pdfarr):
104
+
105
+ $temp = $this->array_mpop($pdfarr["addr"], 2);
106
+
107
+ $page = $pdf->newPage('255:82:');
108
+
109
+ $page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 13);
110
+
111
+ $i = 70;
112
+
113
+ foreach($temp as $addy){
114
+ $page->drawText(trim(strtoupper($addy)), 5,$i, 'UTF-8');
115
+ $i = $i-13;
116
+ }
117
+
118
+ $pdf->pages[] = $page;
119
+
120
+ endforeach;
121
+
122
+ $pdfData = $pdf->render();
123
+
124
+ $this->_prepareDownloadResponse('ShippingLabels-'.date('d-m-Y-H-i-s').'.pdf', $pdf->render(), 'application/pdf');
125
+
126
+ }
127
+
128
+ }
app/code/local/Creare/MassLandscapeShippingLabel/etc/config.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Creare_MassLandscapeShippingLabel>
5
+ <version>0.1.0</version>
6
+ </Creare_MassLandscapeShippingLabel>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <adminhtml>
11
+ <rewrite>
12
+ <sales_order_grid>Creare_MassLandscapeShippingLabel_Block_Sales_Order_Grid</sales_order_grid>
13
+ </rewrite>
14
+ <rewrite>
15
+ <sales_order_view>Creare_MassLandscapeShippingLabel_Block_View_Masslandscapeshippinglabel</sales_order_view>
16
+ </rewrite>
17
+ </adminhtml>
18
+ </blocks>
19
+ </global>
20
+ <admin>
21
+ <routers>
22
+ <creare_masslandscapeshippinglabel>
23
+ <use>admin</use>
24
+ <args>
25
+ <module>Creare_MassLandscapeShippingLabel</module>
26
+ <frontName>creareadmin</frontName>
27
+ </args>
28
+ </creare_masslandscapeshippinglabel>
29
+ <adminhtml>
30
+ <args>
31
+ <modules>
32
+ <creare_masslandscapeshippinglabel before="Mage_Adminhtml">Creare_MassLandscapeShippingLabel</creare_masslandscapeshippinglabel>
33
+ </modules>
34
+ </args>
35
+ </adminhtml>
36
+ </routers>
37
+ </admin>
38
+ </config>
app/etc/modules/Creare_MassLandscapeShippingLabel.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <config>
3
+ <modules>
4
+ <Creare_MassLandscapeShippingLabel>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Creare_MassLandscapeShippingLabel>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Creare_MassLandscapeShippingLabel</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Just a small extension that allows you to mass-print shipping labels for your orders (also adds the shipping label button to the order view page).</summary>
10
+ <description>Check the orders that you wish to print and then select the correct option from the actions menu.&#xD;
11
+ &#xD;
12
+ No setup necessary, install and start printing PDF shipping labels.&#xD;
13
+ &#xD;
14
+ - Added to actions dropdown on order list page&#xD;
15
+ - Added button to order view page</description>
16
+ <notes>To be tested on &lt;1.4 and 1.6&gt;</notes>
17
+ <authors><author><name>E-Commerce Web Design</name><user>EcommerceWD</user><email>dev@e-commercewebdesign.co.uk</email></author></authors>
18
+ <date>2011-09-20</date>
19
+ <time>10:08:12</time>
20
+ <contents><target name="mageetc"><dir name="modules"><file name="Creare_MassLandscapeShippingLabel.xml" hash="adfa113329713ade12fd02e4d0e707c7"/></dir></target><target name="magelocal"><dir name="Creare"><dir name="MassLandscapeShippingLabel"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="3f3700eb1b44e375c626bfe11f9b8295"/></dir></dir><dir name="View"><file name="Masslandscapeshippinglabel.php" hash="868e0ddac6061b4063033023b34ca4dc"/></dir></dir><dir name="controllers"><file name="MasslandscapeshippinglabelController.php" hash="a2bc55d99e869833693d6670749db99b"/></dir><dir name="etc"><file name="config.xml" hash="2fe1e4267a21a958b1d484b190284b1b"/></dir></dir></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>