Qinvoice_Connect - Version 2.1.2

Version Notes

Fixed bug

Download this release

Release Info

Developer Casper Mekel
Extension Qinvoice_Connect
Version 2.1.2
Comparing to
See all releases


Code changes from version 2.1.1 to 2.1.2

app/code/community/Qinvoice/CHANGELOG CHANGED
@@ -1,9 +1,13 @@
1
  CHANGELOG
2
 
 
 
 
 
 
 
3
  v2.0.1
4
  - Added 'On complete' trigger
5
- - Added
6
-
7
 
8
  v1.1.4 - 2015/05/05
9
  - Updated for use with API v1.2 (backwards compatible with v1.1)
1
  CHANGELOG
2
 
3
+ v2.1.2
4
+ - Fixed bug
5
+
6
+ v2.1.1
7
+ - Added support for updating stock
8
+
9
  v2.0.1
10
  - Added 'On complete' trigger
 
 
11
 
12
  v1.1.4 - 2015/05/05
13
  - Updated for use with API v1.2 (backwards compatible with v1.1)
app/code/community/Qinvoice/Connect/Model/Order/Observer.php CHANGED
@@ -8,57 +8,60 @@ class Qinvoice_Connect_Model_Order_Observer
8
  }
9
  //
10
  public function qinvoiceCall(){
11
- if(Mage::app()->getRequest()->getParam('qc')){
12
 
 
13
 
14
- $data = explode("|", Mage::app()->getRequest()->getParam('qc_data'));
15
 
16
- $string = false;
17
- //print_r($data);
18
- foreach($data as $d){
19
- $values = explode("=", $d);
20
 
21
- switch($values[0]){
22
- case 'check':
23
- $check = $values[1];
24
- break;
25
- default:
26
- if($string != false){
27
- $string .= '|';
28
- }
29
- $string .= $values[0] .'='. $values[1];
30
- $params[$values[0]] = $values[1];
31
- break;
32
- }
33
-
34
- }
35
 
36
-
37
- $secret = Mage::getStoreConfig('invoice_options/invoice/webshop_secret','default');
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
- if(md5($string.$secret) != $check){
40
- exit('Incorrect checksum. Check your secret key.');
41
- return false;
42
- }
43
 
 
 
 
 
44
 
45
 
46
- switch(Mage::app()->getRequest()->getParam('qc')){
47
- case 'test':
48
- echo 'test ok';
49
- break;
50
- case 'stock':
51
- echo $this->updateStock($params);
52
- break;
53
- case 'export':
54
- echo $this->exportCatalog($params);
55
- break;
56
- case 'stores':
57
- echo $this->listStores();
58
- break;
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
- exit();
62
  }
63
  }
64
  public function updateStock($params){
@@ -194,9 +197,10 @@ class Qinvoice_Connect_Model_Order_Observer
194
 
195
  if($invoice_trigger == 'order'){
196
  $this->createInvoiceForQinvoice($order->getId(), false);
197
- }else{
198
- return true;
199
  }
 
 
 
200
  }
201
 
202
  public function sendOnPayment($observer){
@@ -210,9 +214,25 @@ class Qinvoice_Connect_Model_Order_Observer
210
 
211
  if($invoice_trigger == 'payment'){
212
  $this->createInvoiceForQinvoice($order_ids[0], true);
213
- }else{
214
- return true;
215
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
217
  public function createInvoiceForQinvoice($varOrderID,$ifPaid = false)
218
  {
@@ -659,7 +679,7 @@ class qinvoice{
659
  <login mode="newInvoice">
660
  <username><![CDATA['.$this->username.']]></username>
661
  <password><![CDATA['.$this->password.']]></password>
662
- <identifier><![CDATA[Magento_1.1.2]]></identifier>
663
  </login>
664
  <invoice>
665
  <companyname><![CDATA['. $this->companyname .']]></companyname>
8
  }
9
  //
10
  public function qinvoiceCall(){
 
11
 
12
+ if(Mage::app()->getRequest()->getParam('qc') > ''){
13
 
14
+ if(in_array(Mage::app()->getRequest()->getParam('qc'), array('test','stock','export','stores'))){
15
 
16
+ $data = explode("|", Mage::app()->getRequest()->getParam('qc_data'));
 
 
 
17
 
18
+ $string = false;
19
+ //print_r($data);
20
+ foreach($data as $d){
21
+ $values = explode("=", $d);
 
 
 
 
 
 
 
 
 
 
22
 
23
+ switch($values[0]){
24
+ case 'check':
25
+ $check = $values[1];
26
+ break;
27
+ default:
28
+ if($string != false){
29
+ $string .= '|';
30
+ }
31
+ $string .= $values[0] .'='. $values[1];
32
+ $params[$values[0]] = $values[1];
33
+ break;
34
+ }
35
+
36
+ }
37
 
38
+
39
+ $secret = Mage::getStoreConfig('invoice_options/invoice/webshop_secret','default');
 
 
40
 
41
+ if(md5($string.$secret) != $check){
42
+ exit('Incorrect checksum. Check your secret key.');
43
+ return false;
44
+ }
45
 
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ switch(Mage::app()->getRequest()->getParam('qc')){
49
+ case 'test':
50
+ echo 'test ok';
51
+ break;
52
+ case 'stock':
53
+ echo $this->updateStock($params);
54
+ break;
55
+ case 'export':
56
+ echo $this->exportCatalog($params);
57
+ break;
58
+ case 'stores':
59
+ echo $this->listStores();
60
+ break;
61
+
62
+ }
63
+ exit();
64
  }
 
65
  }
66
  }
67
  public function updateStock($params){
197
 
198
  if($invoice_trigger == 'order'){
199
  $this->createInvoiceForQinvoice($order->getId(), false);
 
 
200
  }
201
+ //else{
202
+ // return true;
203
+ // }
204
  }
205
 
206
  public function sendOnPayment($observer){
214
 
215
  if($invoice_trigger == 'payment'){
216
  $this->createInvoiceForQinvoice($order_ids[0], true);
217
+ }
218
+
219
+ // else{
220
+ // return true;
221
+ // }
222
+ }
223
+
224
+ public function orderStatusChange($observer){
225
+
226
+ // print_r($event);
227
+ $event = $observer->getEvent();
228
+ $order = $event->getOrder();
229
+
230
+ $invoice_trigger = Mage::getStoreConfig('invoice_options/invoice/invoice_trigger');
231
+ if($order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE && $invoice_trigger == 'complete'){
232
+ $this->createInvoiceForQinvoice($order->getId(), true);
233
+ }
234
+ // exit();
235
+
236
  }
237
  public function createInvoiceForQinvoice($varOrderID,$ifPaid = false)
238
  {
679
  <login mode="newInvoice">
680
  <username><![CDATA['.$this->username.']]></username>
681
  <password><![CDATA['.$this->password.']]></password>
682
+ <identifier><![CDATA[Magento_2.1.2]]></identifier>
683
  </login>
684
  <invoice>
685
  <companyname><![CDATA['. $this->companyname .']]></companyname>
app/code/community/Qinvoice/Connect/Model/Rewrite/Order.php CHANGED
@@ -23,49 +23,12 @@ class Qinvoice_Connect_Model_Rewrite_Order extends Mage_Sales_Model_Order{
23
  $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
24
  }
25
 
26
- Mage::log("Store ID: ". $this->getStoreId());
27
-
28
- $varActionPath = 'invoice_options/invoice/invoice_trigger';
29
- $trigger = Mage::getStoreConfig($varActionPath,$this->getStoreId());
30
-
31
- Mage::log("Config: ". $trigger);
32
-
33
-
34
- // GETTING TRIGGER SETTING
35
- $db = Mage::getSingleton('core/resource')->getConnection('core_write');
36
- $varPath = 'invoice_options/invoice/api_username';
37
- $prefix = Mage::getConfig()->getTablePrefix();
38
- $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
39
- $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
40
- $varOnOrder = $rowTwo['value'];
41
-
42
- if($varOnOrder == 'complete' && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
43
- $this->createInvoiceForQinvoice($order->getId(), false);
44
- }else{
45
- return true;
46
- }
47
-
48
- switch($state){
49
- case 'complete': // shipped?
50
- if($trigger == 'complete'){
51
- // send request
52
- }
53
- break;
54
- case 'processing': // after payment?
55
- if($trigger == 'payment'){
56
- // send request
57
- }
58
- // update invoice
59
- break;
60
- case 'new': // new order
61
- if($trigger == 'order'){
62
- // send request
63
- }
64
- break;
65
- }
66
 
67
  Mage::dispatchEvent('qinvoice_connect_order_status_change', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified));
68
- Mage::log("Qinvoice_Connect_Model_Rewrite_Order Changing order to STATE ".$state." STATUS ".$status);
 
 
69
  return $this;
70
  }
71
  }
23
  $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
24
  }
25
 
26
+ // echo 'hier';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  Mage::dispatchEvent('qinvoice_connect_order_status_change', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified));
29
+ // Mage::log("Qinvoice_Connect_Model_Rewrite_Order Changing order to STATE ".$state." STATUS ".$status);
30
+
31
+ // exit('exit');
32
  return $this;
33
  }
34
  }
app/code/community/Qinvoice/Connect/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
- <version>2.1.1</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
@@ -39,11 +39,11 @@
39
  </controller_front_init_before>
40
  <qinvoice_connect_order_status_change>
41
  <observers>
42
- <qinvoice_connect_model_rewrite>
43
  <type>singleton</type>
44
- <class>modelrewrite/observer</class>
45
- <method>changeStateOrder</method>
46
- </qinvoice_connect_model_rewrite>
47
  </observers>
48
  </qinvoice_connect_order_status_change>
49
 
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
+ <version>2.1.2</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
39
  </controller_front_init_before>
40
  <qinvoice_connect_order_status_change>
41
  <observers>
42
+ <connect>
43
  <type>singleton</type>
44
+ <class>invoice/order_observer</class>
45
+ <method>orderStatusChange</method>
46
+ </connect>
47
  </observers>
48
  </qinvoice_connect_order_status_change>
49
 
app/code/community/Qinvoice/Connect/etc/config_old.xml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!-- app/code/local/Qinvoice/Connect/etc/config.xml -->
3
+ <config>
4
+ <modules>
5
+ <Qinvoice_Connect>
6
+ <version>2.1.1</version>
7
+ </Qinvoice_Connect>
8
+ </modules>
9
+ <global>
10
+ <blocks>
11
+ <invoice>
12
+ <class>Qinvoice_Connect_Block</class>
13
+ </invoice>
14
+ <invoice_adminhtml>
15
+ <class>Qinvoice_Connect_Block_Adminhtml</class>
16
+ </invoice_adminhtml>
17
+ </blocks>
18
+ <models>
19
+ <invoice>
20
+ <class>Qinvoice_Connect_Model</class>
21
+ </invoice>
22
+ <sales>
23
+ <rewrite>
24
+ <order>Qinvoice_Connect_Model_Rewrite_Order</order>
25
+ </rewrite>
26
+ </sales>
27
+ <modelrewrite>
28
+ <class>Qinvoice_Connect_Model_Rewrite</class>
29
+ </modelrewrite>
30
+ </models>
31
+ <events>
32
+ <controller_front_init_before>
33
+ <observers>
34
+ <connect>
35
+ <class>invoice/order_observer</class>
36
+ <method>qinvoiceCall</method>
37
+ </connect>
38
+ </observers>
39
+ </controller_front_init_before>
40
+ <qinvoice_connect_order_status_change>
41
+ <observers>
42
+ <connect>
43
+ <class>invoice/order_observer</class>
44
+ <method>orderStatusChange</method>
45
+ </connect>
46
+ </observers>
47
+ </qinvoice_connect_order_status_change>
48
+
49
+ <sales_order_place_after>
50
+ <observers>
51
+ <connect>
52
+ <class>invoice/order_observer</class>
53
+ <method>sendOnOrder</method>
54
+ </connect>
55
+ </observers>
56
+ </sales_order_place_after>
57
+
58
+ <sales_order_payment_pay>
59
+ <observers>
60
+ <connect>
61
+ <class>invoice/order_observer</class>
62
+ <method>sendOnPayment</method>
63
+ </connect>
64
+ </observers>
65
+ </sales_order_payment_pay>
66
+ </events>
67
+ <helpers>
68
+ <invoice>
69
+ <class>Qinvoice_Connect_Helper</class>
70
+ </invoice>
71
+ </helpers>
72
+ </global>
73
+ <adminhtml>
74
+ <acl>
75
+ <resources>
76
+ <admin>
77
+ <children>
78
+ <system>
79
+ <children>
80
+ <config>
81
+ <children>
82
+ <invoice_options>
83
+ <title>Store Hello World Module Section</title>
84
+ </invoice_options>
85
+ </children>
86
+ </config>
87
+ </children>
88
+ </system>
89
+ </children>
90
+ </admin>
91
+ </resources>
92
+ </acl>
93
+ </adminhtml>
94
+
95
+ </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Qinvoice_Connect</name>
4
- <version>2.1.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automatically generate and send PDF invoices for every order to your customers through q-invoice.com</summary>
10
  <description>Invoices can be generated upon a successful payment or order and will be added to your administration. Q-invoice offers you the freedom to run multiple webshops or venues but still have your bookkeeping together at one place. Generate invoices in a layout of your choosing for maximal recognition, upload bankstatements and process payment with the click of your mouse. www.q-invoice.com</description>
11
- <notes>Fixed issue with multiple products same SKU, different custom option</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
- <date>2016-10-06</date>
14
- <time>16:56:24</time>
15
- <contents><target name="magecommunity"><dir name="Qinvoice"><file name="CHANGELOG" hash="f3fe0ee8957ad7362fe0961114678243"/><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Webshopsecret.php" hash="2157af67cdcf51307bde5efe5cee46d2"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.Boerdereike.php" hash="141eebc8865ff9c7e231d85df1432e96"/><file name="Observer.max4home.php" hash="1f9b754b2184c0079a0d53ecc2d3fdd8"/><file name="Observer.php" hash="b7828acc3cf5bef0f76e74a098e56255"/></dir><dir name="Rewrite"><file name="Observer.php" hash="769e4618f69697b8e3ccddbb9b446fea"/><file name="Order.php" hash="a56c5c21b08c783b2a1435d21d0b2d40"/></dir><dir name="Source"><file name="Attribute.php" hash="72f35ffb8cd873d2c5e1e448ff4bf4e2"/><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Method.php" hash="ac6891fc7e403250b24f5b0f2d6199bc"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="366ba803beda9471e48d5d6da3baa20a"/></dir></dir><dir name="Module"><dir name="Block"><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><dir name="etc"><file name="config.xml" hash="46d4577f78a57d533c5292ab74dac0ec"/><file name="system.xml" hash="ed502b22f018d096417f47e62dbc31a8"/></dir><file name="readme.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Connect.xml" hash="fbedefa4e926092705c6941ad28f51f8"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Qinvoice_Connect</name>
4
+ <version>2.1.2</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Automatically generate and send PDF invoices for every order to your customers through q-invoice.com</summary>
10
  <description>Invoices can be generated upon a successful payment or order and will be added to your administration. Q-invoice offers you the freedom to run multiple webshops or venues but still have your bookkeeping together at one place. Generate invoices in a layout of your choosing for maximal recognition, upload bankstatements and process payment with the click of your mouse. www.q-invoice.com</description>
11
+ <notes>Fixed bug</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
+ <date>2016-10-13</date>
14
+ <time>20:01:49</time>
15
+ <contents><target name="magecommunity"><dir name="Qinvoice"><file name="CHANGELOG" hash="a5b219d5eacdccb828a227a4467afa46"/><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Webshopsecret.php" hash="2157af67cdcf51307bde5efe5cee46d2"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.Boerdereike.php" hash="141eebc8865ff9c7e231d85df1432e96"/><file name="Observer.max4home.php" hash="1f9b754b2184c0079a0d53ecc2d3fdd8"/><file name="Observer.php" hash="70c3b68728422bd55f821a6c66db6339"/></dir><dir name="Rewrite"><file name="Observer.php" hash="769e4618f69697b8e3ccddbb9b446fea"/><file name="Order.php" hash="1206763b6090a7136fe869b474935c51"/></dir><dir name="Source"><file name="Attribute.php" hash="72f35ffb8cd873d2c5e1e448ff4bf4e2"/><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Method.php" hash="ac6891fc7e403250b24f5b0f2d6199bc"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="366ba803beda9471e48d5d6da3baa20a"/></dir></dir><dir name="Module"><dir name="Block"><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><dir name="etc"><file name="config.xml" hash="f069ed25a278c173cb2223e1303dfd22"/><file name="config_old.xml" hash="dcd8c91d7d5e48154ebe900336d13cab"/><file name="system.xml" hash="ed502b22f018d096417f47e62dbc31a8"/></dir><file name="readme.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Connect.xml" hash="fbedefa4e926092705c6941ad28f51f8"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
18
  </package>