Asperience_Printorderline - Version 0.1.9

Version Notes

If you have ideas for improvements or find bugs, please send them to Jean-Sébastien Hederer at contact@asperience.fr, with ASPerience PrintOrderLine as part of the subject line.

Download this release

Release Info

Developer Jean-Sébastien Hederer
Extension Asperience_Printorderline
Version 0.1.9
Comparing to
See all releases


Code changes from version 0.1.8 to 0.1.9

app/code/community/Asperience/Printorderline/Model/Order/Pdf/Order.php CHANGED
@@ -5,6 +5,14 @@
5
  * @author ASPerience - www.asperience.fr
6
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
  */
 
 
 
 
 
 
 
 
8
 
9
  class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_Order_Pdf_Abstract
10
  {
@@ -35,51 +43,55 @@ class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_O
35
  $this->y -=10;
36
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
37
  $page->drawText(Mage::helper('printorderline')->__('Order'), 50, $this->y, 'UTF-8');
38
- $page->drawText(Mage::helper('printorderline')->__('Bill to informations'), 160, $this->y, 'UTF-8');
39
- $page->drawText(Mage::helper('printorderline')->__('Ship to informations'), 330, $this->y, 'UTF-8');
40
- $page->drawText(Mage::helper('printorderline')->__('Shipping and billing methods'), 500, $this->y, 'UTF-8');
41
  $page->drawText(Mage::helper('printorderline')->__('Totals'), 680, $this->y, 'UTF-8');
42
-
43
-
44
  foreach ($orders as $order) {
45
  //Data
46
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
47
 
48
- $lgMaxAdd = 50;
49
- $lgMaxMet = 50;
50
 
51
  //Payment method
52
- try {
53
- $paymentInfo = Mage::helper('payment')->getInfoBlock($order->getPayment())
54
- ->setIsSecureMode(true)
55
- ->toPdf();
56
- } catch (Exception $e) {
57
- $paymentInfo = $order->getPayment()->getMethod();
58
- }
59
- $payment = str_replace('{{pdf_row_separator}}', ' ', $paymentInfo);
60
- $payment = wordwrap($payment, $lgMaxMet, "|\n", 1);
61
- $payment = explode('|', $payment);
 
 
 
 
 
62
 
63
  //Shipping description
64
  $ShippingDesc = $order->getShippingDescription();
65
- $ShippingDesc = wordwrap($ShippingDesc, $lgMaxMet, "|\n", 1);
66
  $ShippingDesc = explode('|', $ShippingDesc);
67
 
68
  //Billing informations
69
  $billingAddress = $order->getBillingAddress();
70
  if($billingAddress) {
71
  $BillingCpn = $billingAddress->getCompany();
72
- $BillingCpn = wordwrap($BillingCpn, $lgMaxAdd, "|\n", 1);
73
- $BillingCpn = explode('|', $BillingCpn);
74
  } else {
75
  $BillingCpn = array();
76
  }
77
-
78
  //Shipping informations
79
  $shippingAddress = $order->getShippingAddress();
80
  if($shippingAddress) {
81
  $ShippingCpn = $shippingAddress->getCompany();
82
- $ShippingCpn = wordwrap($ShippingCpn, $lgMaxAdd, "|\n", 1);
83
  $ShippingCpn = explode('|', $ShippingCpn);
84
  } else {
85
  $ShippingCpn = array();
@@ -101,19 +113,21 @@ class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_O
101
  $billingAddressName = $billingAddress->getName();
102
  else
103
  $billingAddressName = '';
104
- $page->drawText($billingAddressName, 160, $this->y, 'UTF-8');
 
105
  if($shippingAddress)
106
  $shippingAddressName = $shippingAddress->getName();
107
  else
108
  $shippingAddressName = '';
109
- $page->drawText($shippingAddressName, 330, $this->y, 'UTF-8');
 
110
  $page->drawText(Mage::helper('printorderline')->__('Tax: ').$order->formatPriceTxt($order->getTaxAmount()), 680, $this->y, 'UTF-8');
111
  $page->drawText(Mage::helper('printorderline')->__('Ship: ').$order->formatPriceTxt($order->getShippingAmount()), 740, $this->y, 'UTF-8');
112
 
113
  $saveY = $this->y;
114
  foreach ($payment as $value){
115
  if (trim($value)!=='') {
116
- $page->drawText(strip_tags(trim($value)), 500, $saveY, 'UTF-8');
117
  $saveY-=10;
118
  }
119
  }
@@ -128,7 +142,7 @@ class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_O
128
  $saveY = $this->y;
129
  foreach ($BillingCpn as $value){
130
  if ($value!=='') {
131
- $page->drawText(strip_tags($value), 160, $saveY, 'UTF-8');
132
  $saveY -=10;
133
  }
134
  }
@@ -136,14 +150,14 @@ class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_O
136
  $saveY = $this->y;
137
  foreach ($ShippingCpn as $value){
138
  if ($value!=='') {
139
- $page->drawText(strip_tags($value), 330, $saveY, 'UTF-8');
140
  $saveY -=10;
141
  }
142
  }
143
  $saveY = $this->y;
144
  foreach ($ShippingDesc as $value){
145
  if ($value!=='') {
146
- $page->drawText(strip_tags($value), 500, $saveY, 'UTF-8');
147
  $saveY -=10;
148
  }
149
  }
@@ -168,9 +182,9 @@ class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_O
168
  $this->y -=10;
169
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
170
  $page->drawText(Mage::helper('printorderline')->__('Order'), 50, $this->y, 'UTF-8');
171
- $page->drawText(Mage::helper('printorderline')->__('Bill to informations'), 160, $this->y, 'UTF-8');
172
- $page->drawText(Mage::helper('printorderline')->__('Ship to informations'), 330, $this->y, 'UTF-8');
173
- $page->drawText(Mage::helper('printorderline')->__('Shipping and billing methods'), 500, $this->y, 'UTF-8');
174
  $page->drawText(Mage::helper('printorderline')->__('Totals'), 680, $this->y, 'UTF-8');
175
  }
176
  }
5
  * @author ASPerience - www.asperience.fr
6
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
7
  */
8
+ function getShortText($text,$length)
9
+ {
10
+ $temp = strip_tags(trim($text));
11
+ if(strlen($temp) > $length) {
12
+ $temp = substr($temp,0,$length-4)."...";
13
+ }
14
+ return $temp;
15
+ }
16
 
17
  class Asperience_Printorderline_Model_Order_Pdf_Order extends Mage_Sales_Model_Order_Pdf_Abstract
18
  {
43
  $this->y -=10;
44
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
45
  $page->drawText(Mage::helper('printorderline')->__('Order'), 50, $this->y, 'UTF-8');
46
+ $page->drawText(Mage::helper('printorderline')->__('Bill to informations'), 130, $this->y, 'UTF-8');
47
+ $page->drawText(Mage::helper('printorderline')->__('Ship to informations'), 290, $this->y, 'UTF-8');
48
+ $page->drawText(Mage::helper('printorderline')->__('Shipping and billing methods'), 450, $this->y, 'UTF-8');
49
  $page->drawText(Mage::helper('printorderline')->__('Totals'), 680, $this->y, 'UTF-8');
50
+
 
51
  foreach ($orders as $order) {
52
  //Data
53
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
54
 
55
+ $lgMaxAdd = 45;
56
+ $lgMaxMet = 72;
57
 
58
  //Payment method
59
+ $paymentInfo = Mage::helper('payment')->getInfoBlock($order->getPayment())
60
+ ->setIsSecureMode(true)
61
+ ->toPdf();
62
+ $payment = explode('{{pdf_row_separator}}', $paymentInfo);
63
+ $count = 0;
64
+ foreach ($payment as $key=>$value){
65
+ $temp = strip_tags(trim($value));
66
+ if ($temp=='' || $count > 0){
67
+ unset($payment[$key]);
68
+ } else {
69
+ $count += 1;
70
+ $payment[$key] = getShortText($temp,$lgMaxMet);
71
+ }
72
+ }
73
+ reset($payment);
74
 
75
  //Shipping description
76
  $ShippingDesc = $order->getShippingDescription();
77
+ $ShippingDesc = wordwrap($ShippingDesc, $lgMaxMet, "|\n", 1);
78
  $ShippingDesc = explode('|', $ShippingDesc);
79
 
80
  //Billing informations
81
  $billingAddress = $order->getBillingAddress();
82
  if($billingAddress) {
83
  $BillingCpn = $billingAddress->getCompany();
84
+ $BillingCpn = wordwrap($BillingCpn, $lgMaxAdd, "|\n", 1);
85
+ $BillingCpn = explode('|', $BillingCpn);
86
  } else {
87
  $BillingCpn = array();
88
  }
89
+
90
  //Shipping informations
91
  $shippingAddress = $order->getShippingAddress();
92
  if($shippingAddress) {
93
  $ShippingCpn = $shippingAddress->getCompany();
94
+ $ShippingCpn = wordwrap($ShippingCpn, $lgMaxAdd, "|\n", 1);
95
  $ShippingCpn = explode('|', $ShippingCpn);
96
  } else {
97
  $ShippingCpn = array();
113
  $billingAddressName = $billingAddress->getName();
114
  else
115
  $billingAddressName = '';
116
+ $page->drawText(getShortText($billingAddressName,$lgMaxAdd), 130, $this->y, 'UTF-8');
117
+
118
  if($shippingAddress)
119
  $shippingAddressName = $shippingAddress->getName();
120
  else
121
  $shippingAddressName = '';
122
+ $page->drawText(getShortText($shippingAddressName,$lgMaxAdd), 290, $this->y, 'UTF-8');
123
+
124
  $page->drawText(Mage::helper('printorderline')->__('Tax: ').$order->formatPriceTxt($order->getTaxAmount()), 680, $this->y, 'UTF-8');
125
  $page->drawText(Mage::helper('printorderline')->__('Ship: ').$order->formatPriceTxt($order->getShippingAmount()), 740, $this->y, 'UTF-8');
126
 
127
  $saveY = $this->y;
128
  foreach ($payment as $value){
129
  if (trim($value)!=='') {
130
+ $page->drawText(strip_tags(trim($value)), 450, $saveY, 'UTF-8');
131
  $saveY-=10;
132
  }
133
  }
142
  $saveY = $this->y;
143
  foreach ($BillingCpn as $value){
144
  if ($value!=='') {
145
+ $page->drawText(strip_tags($value), 130, $saveY, 'UTF-8');
146
  $saveY -=10;
147
  }
148
  }
150
  $saveY = $this->y;
151
  foreach ($ShippingCpn as $value){
152
  if ($value!=='') {
153
+ $page->drawText(strip_tags($value), 290, $saveY, 'UTF-8');
154
  $saveY -=10;
155
  }
156
  }
157
  $saveY = $this->y;
158
  foreach ($ShippingDesc as $value){
159
  if ($value!=='') {
160
+ $page->drawText(strip_tags($value), 450, $saveY, 'UTF-8');
161
  $saveY -=10;
162
  }
163
  }
182
  $this->y -=10;
183
  $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
184
  $page->drawText(Mage::helper('printorderline')->__('Order'), 50, $this->y, 'UTF-8');
185
+ $page->drawText(Mage::helper('printorderline')->__('Bill to informations'), 130, $this->y, 'UTF-8');
186
+ $page->drawText(Mage::helper('printorderline')->__('Ship to informations'), 290, $this->y, 'UTF-8');
187
+ $page->drawText(Mage::helper('printorderline')->__('Shipping and billing methods'), 450, $this->y, 'UTF-8');
188
  $page->drawText(Mage::helper('printorderline')->__('Totals'), 680, $this->y, 'UTF-8');
189
  }
190
  }
app/code/community/Asperience/Printorderline/etc/config.xml CHANGED
@@ -10,7 +10,7 @@
10
  <config>
11
  <modules>
12
  <Asperience_Printorderline>
13
- <version>0.1.6</version>
14
  </Asperience_Printorderline>
15
  </modules>
16
 
10
  <config>
11
  <modules>
12
  <Asperience_Printorderline>
13
+ <version>0.1.9</version>
14
  </Asperience_Printorderline>
15
  </modules>
16
 
package.xml CHANGED
@@ -1,20 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Asperience_Printorderline</name>
4
- <version>0.1.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Module allowing to print order lines in the back office.&#xD;
10
  </summary>
11
- <description>To have a summary of the orders, this module allows in the back office, to print a pdf with details of selected orders.&#xD;
12
  </description>
13
- <notes>If you have ideas for improvements or find bugs, please send them to Jean-S&#xE9;bastien Hederer at contact@asperience.fr, with Asperience_Printorderline as part of the subject line.</notes>
14
  <authors><author><name>Jean-S&#xE9;bastien Hederer</name><user>hedererjs</user><email>hedererjs@asperience.fr</email></author></authors>
15
- <date>2014-01-10</date>
16
- <time>22:38:44</time>
17
- <contents><target name="magecommunity"><dir name="Asperience"><dir name="Printorderline"><dir name="Helper"><file name="Data.php" hash="4973f68f8b95618a017857b21fa4d759"/></dir><dir name="Model"><file name="Observer.php" hash="750d022fe91669b990e5e4c1a518218d"/><dir name="Order"><dir name="Pdf"><file name="Order.php" hash="19f0cb10500136f8f985c14160f3a0f7"/></dir></dir></dir><dir name="controllers"><file name="OrderController.php" hash="129ff200233f74a9ddfdf3537e09059f"/></dir><dir name="etc"><file name="config.xml" hash="b89dafbef379eb619321fb40ec4deb69"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Asperience_Printorderline.xml" hash="a9d761fb2d923dfc1adf93541ce19dd8"/></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Asperience_Printorderline.csv" hash="3e9fa70b536a43ac59099a7b6f190798"/></dir><dir name="fr_FR"><file name="Asperience_Printorderline.csv" hash="13e4b52922b1ac0360b0328de12093da"/></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Asperience_Printorderline</name>
4
+ <version>0.1.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Module allowing to print order lines in the back office.&#xD;
10
  </summary>
11
+ <description> To have a summary of the orders, this module allows, with the back office, to print on pdf all the lines of selected orders.&#xD;
12
  </description>
13
+ <notes>If you have ideas for improvements or find bugs, please send them to Jean-S&#xE9;bastien Hederer at contact@asperience.fr, with ASPerience PrintOrderLine as part of the subject line.</notes>
14
  <authors><author><name>Jean-S&#xE9;bastien Hederer</name><user>hedererjs</user><email>hedererjs@asperience.fr</email></author></authors>
15
+ <date>2014-01-23</date>
16
+ <time>19:46:36</time>
17
+ <contents><target name="magecommunity"><dir name="Asperience"><dir name="Printorderline"><dir name="Helper"><file name="Data.php" hash="4973f68f8b95618a017857b21fa4d759"/></dir><dir name="Model"><file name="Observer.php" hash="750d022fe91669b990e5e4c1a518218d"/><dir name="Order"><dir name="Pdf"><file name="Order.php" hash="04fde40e483a49f2fe5f02b7f1fcf16e"/></dir></dir></dir><dir name="controllers"><file name="OrderController.php" hash="129ff200233f74a9ddfdf3537e09059f"/></dir><dir name="etc"><file name="config.xml" hash="9f3bf0bedcb0a23ab74ae3a7bbfd3f36"/></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Asperience_Printorderline.xml" hash="a9d761fb2d923dfc1adf93541ce19dd8"/></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Asperience_Printorderline.csv" hash="13e4b52922b1ac0360b0328de12093da"/></dir><dir name="en_US"><file name="Asperience_Printorderline.csv" hash="3e9fa70b536a43ac59099a7b6f190798"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>