Plumrocket_Auto_Invoice - Version 1.1.0

Version Notes

Added automated email sending while creating separate invoices.

Download this release

Release Info

Developer Plumrocket Team
Extension Plumrocket_Auto_Invoice
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.7 to 1.1.0

app/code/community/Plumrocket/AutoInvoice/Block/System/Config/Version.php CHANGED
@@ -59,7 +59,7 @@ class Plumrocket_AutoInvoice_Block_System_Config_Version extends Mage_Adminhtml_
59
 
60
  var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
61
  iframeDoc.open();
62
- iframeDoc.write("<html><body></body></html>");
63
  iframeDoc.close();
64
  iframeBody = iframeDoc.body;
65
 
59
 
60
  var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
61
  iframeDoc.open();
62
+ iframeDoc.write("<ht"+"ml><bo"+"dy></bo"+"dy></ht"+"ml>");
63
  iframeDoc.close();
64
  iframeBody = iframeDoc.body;
65
 
app/code/community/Plumrocket/AutoInvoice/Helper/Main.php CHANGED
@@ -7,10 +7,14 @@
7
  * This source file is subject to the End-user License Agreement
8
  * that is available through the world-wide-web at this URL:
9
  * http://wiki.plumrocket.net/wiki/EULA
10
- * If you are unable to obtain it through the world-wide-web, please
11
  * send an email to support@plumrocket.com so we can send you a copy immediately.
12
  *
13
- * @package Plumrocket_AutoInvoice
 
 
 
 
14
  * @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
15
  * @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
16
  */
@@ -19,97 +23,4 @@
19
  class Plumrocket_AutoInvoice_Helper_Main extends Mage_Core_Helper_Abstract
20
  {
21
 
22
- public function getAjaxUrl($route, $params = array())
23
- {
24
- $url = Mage::getUrl($route, $params);
25
- if (Mage::app()->getStore()->isCurrentlySecure()) {
26
- $url = str_replace('http://', 'https://', $url);
27
- } else {
28
- $url = str_replace('https://', 'http://', $url);
29
- }
30
-
31
- return $url;
32
- }
33
-
34
-
35
- protected function __addProduct($product, $request = null)
36
- {
37
- return $this->addProductAdvanced(
38
- $product,
39
- $request,
40
- Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL
41
- );
42
- }
43
-
44
-
45
- protected function __initOrder($orderIncrementId)
46
- {
47
- $order = Mage::getModel('sales/order');
48
-
49
- $order->loadByIncrementId($orderIncrementId);
50
-
51
- if (!$order->getId()) {
52
- $this->_fault('not_exists');
53
- }
54
-
55
- return $order;
56
- }
57
-
58
-
59
- public function __setOrder(Mage_Sales_Model_Order $order)
60
- {
61
- $this->_order = $order;
62
- $this->setOrderId($order->getId())
63
- ->setStoreId($order->getStoreId());
64
- return $this;
65
- }
66
-
67
-
68
- final public function getCustomerKey()
69
- {
70
- return implode('', array_map('ch'.
71
- 'r', explode('.', '53.51.50.52.49.51.50.50.49.51.102.100.50.57.55.54.101.54.56.51.51.57.102.55.53.102.49.57.100.54.49.98.51.51.49.56.99.53.57.48.57.49')
72
- ));
73
- }
74
-
75
-
76
- protected function __hold($orderIncrementId)
77
- {
78
- $order = $this->_initOrder($orderIncrementId);
79
-
80
- try {
81
- $order->hold();
82
- $order->save();
83
- } catch (Mage_Core_Exception $e) {
84
- $this->_fault('status_not_changed', $e->getMessage());
85
- }
86
-
87
- return true;
88
- }
89
-
90
-
91
- protected function __deleteItem($item)
92
- {
93
- if ($item->getId()) {
94
- $this->removeItem($item->getId());
95
- } else {
96
- $quoteItems = $this->getItemsCollection();
97
- $items = array($item);
98
- if ($item->getHasChildren()) {
99
- foreach ($item->getChildren() as $child) {
100
- $items[] = $child;
101
- }
102
- }
103
- foreach ($quoteItems as $key => $quoteItem) {
104
- foreach ($items as $item) {
105
- if ($quoteItem->compare($item)) {
106
- $quoteItems->removeItemByKey($key);
107
- }
108
- }
109
- }
110
- }
111
-
112
- return $this;
113
- }
114
-
115
- };
7
  * This source file is subject to the End-user License Agreement
8
  * that is available through the world-wide-web at this URL:
9
  * http://wiki.plumrocket.net/wiki/EULA
10
+ * If you are unable to obtain it through the world-wide-web, please
11
  * send an email to support@plumrocket.com so we can send you a copy immediately.
12
  *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file
16
+ *
17
+ * @package Plumrocket_Auto_Invoice
18
  * @copyright Copyright (c) 2015 Plumrocket Inc. (http://www.plumrocket.com)
19
  * @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
20
  */
23
  class Plumrocket_AutoInvoice_Helper_Main extends Mage_Core_Helper_Abstract
24
  {
25
 
26
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Plumrocket/AutoInvoice/Model/Observer.php CHANGED
@@ -31,7 +31,7 @@ class Plumrocket_AutoInvoice_Model_Observer
31
  }
32
 
33
  $dateModel = Mage::getModel('core/date');
34
- $time = $dateModel->timestamp() - 60 * 60;
35
 
36
  $collection = Mage::getModel('sales/order')->getCollection()
37
  ->addFieldToFilter('main_table.created_at', array('gt' => $dateModel->gmtDate('Y-m-d H:i:s', $time)))
@@ -45,6 +45,9 @@ class Plumrocket_AutoInvoice_Model_Observer
45
  ->joinLeft( array('invoice' => $_resource->getTableName('sales/invoice')), 'invoice.order_id = main_table.entity_id', array())
46
  ->where('order_id IS NULL');
47
 
 
 
 
48
  foreach($collection as $order){
49
 
50
  if (!$_helper->moduleEnabled($order->getStoreId()) || !$_helper->sendInvoiceAfterOrderIsCreated($order->getStoreId())){
@@ -63,6 +66,7 @@ class Plumrocket_AutoInvoice_Model_Observer
63
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
64
 
65
  if ($invoice) {
 
66
  $invoice->setRequestedCaptureCase($_helper->getCaptureAmount($order->getStoreId()));
67
  $invoice->register();
68
  $invoice->getOrder()->setCustomerNoteNotify(false);
@@ -73,7 +77,7 @@ class Plumrocket_AutoInvoice_Model_Observer
73
  ->addObject($invoice->getOrder())
74
  ->save();
75
 
76
- $invoice->sendEmail(true);
77
 
78
  $order->addStatusHistoryComment('Auto Invoice: Order invoiced.', false)->save();
79
  }
@@ -104,6 +108,8 @@ class Plumrocket_AutoInvoice_Model_Observer
104
  return;
105
  }
106
 
 
 
107
  try{
108
 
109
  $qtys = array();
@@ -117,6 +123,7 @@ class Plumrocket_AutoInvoice_Model_Observer
117
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice($qtys);
118
 
119
  if ($invoice) {
 
120
  $invoice->setRequestedCaptureCase($_helper->getCaptureAmount($order->getStoreId()));
121
  $invoice->register();
122
  $invoice->getOrder()->setCustomerNoteNotify(false);
@@ -127,7 +134,7 @@ class Plumrocket_AutoInvoice_Model_Observer
127
  ->addObject($invoice->getOrder())
128
  ->save();
129
 
130
- $invoice->sendEmail(true);
131
 
132
  $order->addStatusHistoryComment('Auto Invoice: Order invoiced.', false)->save();
133
  }
@@ -138,4 +145,23 @@ class Plumrocket_AutoInvoice_Model_Observer
138
  }
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
31
  }
32
 
33
  $dateModel = Mage::getModel('core/date');
34
+ $time = $dateModel->timestamp() - 6 * 60 * 60;
35
 
36
  $collection = Mage::getModel('sales/order')->getCollection()
37
  ->addFieldToFilter('main_table.created_at', array('gt' => $dateModel->gmtDate('Y-m-d H:i:s', $time)))
45
  ->joinLeft( array('invoice' => $_resource->getTableName('sales/invoice')), 'invoice.order_id = main_table.entity_id', array())
46
  ->where('order_id IS NULL');
47
 
48
+
49
+ Mage::app()->loadArea('adminhtml');
50
+
51
  foreach($collection as $order){
52
 
53
  if (!$_helper->moduleEnabled($order->getStoreId()) || !$_helper->sendInvoiceAfterOrderIsCreated($order->getStoreId())){
66
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
67
 
68
  if ($invoice) {
69
+ Mage::register('current_invoice', $invoice);
70
  $invoice->setRequestedCaptureCase($_helper->getCaptureAmount($order->getStoreId()));
71
  $invoice->register();
72
  $invoice->getOrder()->setCustomerNoteNotify(false);
77
  ->addObject($invoice->getOrder())
78
  ->save();
79
 
80
+ //$invoice->sendEmail(true);
81
 
82
  $order->addStatusHistoryComment('Auto Invoice: Order invoiced.', false)->save();
83
  }
108
  return;
109
  }
110
 
111
+ Mage::app()->loadArea('adminhtml');
112
+
113
  try{
114
 
115
  $qtys = array();
123
  $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice($qtys);
124
 
125
  if ($invoice) {
126
+ Mage::register('current_invoice', $invoice);
127
  $invoice->setRequestedCaptureCase($_helper->getCaptureAmount($order->getStoreId()));
128
  $invoice->register();
129
  $invoice->getOrder()->setCustomerNoteNotify(false);
134
  ->addObject($invoice->getOrder())
135
  ->save();
136
 
137
+ //$invoice->sendEmail(true);
138
 
139
  $order->addStatusHistoryComment('Auto Invoice: Order invoiced.', false)->save();
140
  }
145
  }
146
  }
147
 
148
+ public function sendInvoiceEmail($observer)
149
+ {
150
+ if (!Mage::helper('autoinvoice')->moduleEnabled()){
151
+ return $this;
152
+ }
153
+
154
+ try {
155
+ $_invoice = $observer->getEvent()->getInvoice();
156
+ if ($_invoice->getEmailSent()){
157
+ return $this;
158
+ }
159
+ $_invoice->sendEmail();
160
+ } catch (Mage_Core_Exception $e) {
161
+ //echo $e->getMessage();
162
+ }
163
+
164
+ return $this;
165
+ }
166
+
167
  }
app/code/community/Plumrocket/AutoInvoice/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Plumrocket_AutoInvoice>
5
- <version>1.0.7</version>
6
  </Plumrocket_AutoInvoice>
7
  </modules>
8
  <global>
@@ -32,6 +32,15 @@
32
  </autoinvoice_sales_order_shipment_save_after>
33
  </observers>
34
  </sales_order_shipment_save_after>
 
 
 
 
 
 
 
 
 
35
  </events>
36
  </global>
37
  <crontab>
2
  <config>
3
  <modules>
4
  <Plumrocket_AutoInvoice>
5
+ <version>1.1.0</version>
6
  </Plumrocket_AutoInvoice>
7
  </modules>
8
  <global>
32
  </autoinvoice_sales_order_shipment_save_after>
33
  </observers>
34
  </sales_order_shipment_save_after>
35
+ <sales_order_invoice_save_after>
36
+ <observers>
37
+ <autoinvoice_sales_order_invoice_save_after>
38
+ <type>model</type>
39
+ <class>autoinvoice/observer</class>
40
+ <method>sendInvoiceEmail</method>
41
+ </autoinvoice_sales_order_invoice_save_after>
42
+ </observers>
43
+ </sales_order_invoice_save_after>
44
  </events>
45
  </global>
46
  <crontab>
app/etc/modules/Plumrocket_AutoInvoice.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Plumrocket_AutoInvoice>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>1.0.7</version>
8
  <wiki>http://wiki.plumrocket.com/wiki/Magento_Auto_Invoice_v1.x_Extension</wiki>
9
  <name>Plumrocket Auto Invoice</name>
10
  <depends>
4
  <Plumrocket_AutoInvoice>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>1.1.0</version>
8
  <wiki>http://wiki.plumrocket.com/wiki/Magento_Auto_Invoice_v1.x_Extension</wiki>
9
  <name>Plumrocket Auto Invoice</name>
10
  <depends>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Plumrocket_Auto_Invoice</name>
4
- <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://wiki.plumrocket.net/wiki/EULA">End-user License Agreement</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Plumrocket Auto Invoice is a convenient Magento payment processing module that was designed to generate invoice automatically.</summary>
10
  <description>Plumrocket Auto Invoice is a convenient Magento payment processing module that was designed to generate invoice automatically. After a client confirms his order the system will send the invoice automatically thus allowing website admin to avoid manual processing of payment transactions.</description>
11
- <notes>Improved integration with other Plumrocket Extensions</notes>
12
  <authors><author><name>Plumrocket Team</name><user>plumrocket</user><email>support@plumrocket.com</email></author></authors>
13
- <date>2015-02-11</date>
14
- <time>10:01:15</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Plumrocket_AutoInvoice.xml" hash="eb5916d213ee70bbaf0e879d87c5d33a"/></dir></target><target name="magecommunity"><dir name="Plumrocket"><dir name="AutoInvoice"><dir name="Block"><dir name="System"><dir name="Config"><file name="Version.php" hash="97dc3d035a1585684a162c500a44d082"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a95ccea81b14cca001f89e1da4750ace"/><file name="Main.php" hash="797f9ff141f2a4ae91c802d16d389f7a"/></dir><dir name="Model"><file name="Observer.php" hash="186098e7ac5355dd8ff25f1056e3010a"/><dir name="System"><dir name="Config"><dir name="Source"><file name="CaptureAmount.php" hash="28a27588ddd56fbbab43f09e31a9bac8"/><file name="SendInvoice.php" hash="8d19c278d460f27a0d23e2fa8b9d072f"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e45a29110a7ea4ed9e26535cca2f47a4"/><file name="config.xml" hash="d1e1fae5c10221128763c3f26c5b714e"/><file name="system.xml" hash="fd42373f949ccad34b233f61cf31479b"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Plumrocket_Base</name><channel>community</channel><min>1.0.3</min><max></max></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Plumrocket_Auto_Invoice</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://wiki.plumrocket.net/wiki/EULA">End-user License Agreement</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Plumrocket Auto Invoice is a convenient Magento payment processing module that was designed to generate invoice automatically.</summary>
10
  <description>Plumrocket Auto Invoice is a convenient Magento payment processing module that was designed to generate invoice automatically. After a client confirms his order the system will send the invoice automatically thus allowing website admin to avoid manual processing of payment transactions.</description>
11
+ <notes>Added automated email sending while creating separate invoices.</notes>
12
  <authors><author><name>Plumrocket Team</name><user>plumrocket</user><email>support@plumrocket.com</email></author></authors>
13
+ <date>2016-03-18</date>
14
+ <time>10:02:23</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Plumrocket_AutoInvoice.xml" hash="19002966d54dd644d1b01d67a9d8d7d3"/></dir></target><target name="magecommunity"><dir name="Plumrocket"><dir name="AutoInvoice"><dir name="Block"><dir name="System"><dir name="Config"><file name="Version.php" hash="1f60ec9ef1680266bd639c41a7802177"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a95ccea81b14cca001f89e1da4750ace"/><file name="Main.php" hash="283bdec0fceed57707c86908631e9a2d"/></dir><dir name="Model"><file name="Observer.php" hash="21041cfb6c59ca3d75df3218a239c1a5"/><dir name="System"><dir name="Config"><dir name="Source"><file name="CaptureAmount.php" hash="28a27588ddd56fbbab43f09e31a9bac8"/><file name="SendInvoice.php" hash="8d19c278d460f27a0d23e2fa8b9d072f"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e45a29110a7ea4ed9e26535cca2f47a4"/><file name="config.xml" hash="daab0e2ac4f2b6b5482f2d59dcca6949"/><file name="system.xml" hash="fd42373f949ccad34b233f61cf31479b"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Plumrocket_Base</name><channel>community</channel><min/><max/></package></required></dependencies>
18
  </package>