Qinvoice_Connect - Version 1.0.5

Version Notes

Added support for custom table prefix

Download this release

Release Info

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


Code changes from version 1.0.4 to 1.0.5

app/code/community/Qinvoice/Connect/Model/Order/Observer.php CHANGED
@@ -13,7 +13,8 @@ class Qinvoice_Connect_Model_Order_Observer
13
  // GETTING TRIGGER SETTING
14
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
15
  $varPath = 'invoice_options/invoice/invoice_trigger';
16
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
17
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
18
  $varOnOrder = $rowTwo['value'];
19
 
@@ -31,7 +32,8 @@ class Qinvoice_Connect_Model_Order_Observer
31
  // GETTING TRIGGER SETTING
32
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
33
  $varPath = 'invoice_options/invoice/invoice_trigger';
34
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
35
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
36
  $varOnOrder = $rowTwo['value'];
37
 
@@ -50,7 +52,8 @@ class Qinvoice_Connect_Model_Order_Observer
50
  // GETTING TRIGGER SETTING
51
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
52
  $varPath = 'invoice_options/invoice/invoice_trigger';
53
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
54
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
55
  $varOnOrder = $rowTwo['value'];
56
 
@@ -74,7 +77,8 @@ class Qinvoice_Connect_Model_Order_Observer
74
  // GETTING TRIGGER SETTING
75
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
76
  $varPath = 'invoice_options/invoice/invoice_trigger';
77
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
78
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
79
  $varOnOrder = $rowTwo['value'];
80
 
@@ -96,7 +100,8 @@ class Qinvoice_Connect_Model_Order_Observer
96
 
97
  $varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
98
  // GETTING ORDER STATUS
99
- $resultOne = $db->query("SELECT entity_id, status, customer_email, base_currency_code, shipping_description, shipping_amount, shipping_tax_amount, increment_id, grand_total, total_paid, billing_address_id, shipping_address_id FROM sales_flat_order WHERE entity_id=".$varOrderID);
 
100
  $rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
101
 
102
 
@@ -105,7 +110,8 @@ class Qinvoice_Connect_Model_Order_Observer
105
  $varStatus = 'Paid';
106
  // GETTING API URL
107
  $varURLPath = 'invoice_options/invoice/paid_remark';
108
- $resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
 
109
  $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
110
  $paid_remark = $rowURL['value'];
111
  $paid = 1;
@@ -120,7 +126,8 @@ class Qinvoice_Connect_Model_Order_Observer
120
  $varStatus = 'Sent';
121
  }
122
 
123
- $result = $db->query("SELECT item_id, product_type, product_id, product_options, order_id, sku, name, description, qty_ordered, base_price, tax_percent, tax_amount, base_discount_amount FROM sales_flat_order_item WHERE order_id=".$varOrderID." AND parent_item_id IS NULL GROUP BY sku HAVING (order_id > 0) ORDER BY item_id desc");
 
124
 
125
 
126
  if(!$result) {
@@ -139,25 +146,29 @@ class Qinvoice_Connect_Model_Order_Observer
139
 
140
  // GETTING API USERNAME
141
  $varPath = 'invoice_options/invoice/api_username';
142
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
143
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
144
  $username = $rowTwo['value'];
145
 
146
  // GETTING API PASSWORD
147
  $varPath = 'invoice_options/invoice/api_password';
148
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
149
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
150
  $password = $rowTwo['value'];
151
 
152
  // GETTING LAYOUT CODE
153
  $varPath = 'invoice_options/invoice/layout_code';
154
- $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
 
155
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
156
  $layout_code = $rowTwo['value'];
157
 
158
 
159
  // GETTING CLIENT DETAILS
160
- $resultThree = $db->query("SELECT firstname, lastname, company, email, telephone, street, city, region, postcode, country_id, vat_id FROM sales_flat_order_address WHERE entity_id='".$rowOne['billing_address_id']."'");
 
161
  $rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
162
 
163
  $invoice = new qinvoice($username,$password);
@@ -172,7 +183,8 @@ class Qinvoice_Connect_Model_Order_Observer
172
  $invoice->country = $rowThree['country_id']; // 2 character country code: NL for Netherlands, DE for Germany etc
173
  $invoice->vatnumber = $rowThree['vat_id'];
174
 
175
- $resultFour = $db->query("SELECT firstname, lastname, company, email, telephone, street, city, region, postcode, country_id FROM sales_flat_order_address WHERE entity_id='".$rowOne['shipping_address_id']."'");
 
176
  $rowFour = $resultFour->fetch(PDO::FETCH_ASSOC);
177
 
178
  $invoice->delivery_address = $rowFour['street']; // Self-explanatory
@@ -184,25 +196,29 @@ class Qinvoice_Connect_Model_Order_Observer
184
  $invoice->paid = $paid;
185
 
186
  $varActionPath = 'invoice_options/invoice/save_relation';
187
- $resultAction = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varActionPath."'");
 
188
  $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
189
  $save_relation = $rowAction['value'];
190
 
191
  $invoice->saverelation = $save_relation;
192
 
193
  $varRemarkPath = 'invoice_options/invoice/invoice_remark';
194
- $resultRemark = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varRemarkPath."'");
 
195
  $rowRemark = $resultRemark->fetch(PDO::FETCH_ASSOC);
196
  $invoice_remark = $rowRemark['value'];
197
  $invoice->remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark) .' '. $paid_remark; // Self-explanatory
198
 
199
  $varActionPath = 'invoice_options/invoice/invoice_action';
200
- $resultAction = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varActionPath."'");
 
201
  $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
202
  $invoice_action = $rowAction['value'];
203
 
204
  $varLayoutPath = 'invoice_options/invoice/layout_code';
205
- $resultLayout = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varLayoutPath."'");
 
206
  $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
207
  $invoice_layout = $rowLayout['value'];
208
 
@@ -225,7 +241,8 @@ class Qinvoice_Connect_Model_Order_Observer
225
  $invoice->setLayout($invoice_layout);
226
 
227
  $varTagPath = 'invoice_options/invoice/invoice_tag';
228
- $resultTag = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varTagPath."'");
 
229
  $rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
230
  $invoice_tag = $rowTag['value'];
231
 
@@ -366,7 +383,8 @@ class qinvoice{
366
 
367
  // GETTING API URL
368
  $varURLPath = 'invoice_options/invoice/api_url';
369
- $resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
 
370
  $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
371
  $apiURL = $rowURL['value'];
372
 
13
  // GETTING TRIGGER SETTING
14
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
15
  $varPath = 'invoice_options/invoice/invoice_trigger';
16
+ $prefix = Mage::getConfig()->getTablePrefix();
17
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
18
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
19
  $varOnOrder = $rowTwo['value'];
20
 
32
  // GETTING TRIGGER SETTING
33
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
34
  $varPath = 'invoice_options/invoice/invoice_trigger';
35
+ $prefix = Mage::getConfig()->getTablePrefix();
36
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
37
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
38
  $varOnOrder = $rowTwo['value'];
39
 
52
  // GETTING TRIGGER SETTING
53
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
54
  $varPath = 'invoice_options/invoice/invoice_trigger';
55
+ $prefix = Mage::getConfig()->getTablePrefix();
56
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
57
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
58
  $varOnOrder = $rowTwo['value'];
59
 
77
  // GETTING TRIGGER SETTING
78
  $db = Mage::getSingleton('core/resource')->getConnection('core_write');
79
  $varPath = 'invoice_options/invoice/invoice_trigger';
80
+ $prefix = Mage::getConfig()->getTablePrefix();
81
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
82
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
83
  $varOnOrder = $rowTwo['value'];
84
 
100
 
101
  $varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
102
  // GETTING ORDER STATUS
103
+ $prefix = Mage::getConfig()->getTablePrefix();
104
+ $resultOne = $db->query("SELECT entity_id, status, customer_email, base_currency_code, shipping_description, shipping_amount, shipping_tax_amount, increment_id, grand_total, total_paid, billing_address_id, shipping_address_id FROM {$prefix}sales_flat_order WHERE entity_id=".$varOrderID);
105
  $rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
106
 
107
 
110
  $varStatus = 'Paid';
111
  // GETTING API URL
112
  $varURLPath = 'invoice_options/invoice/paid_remark';
113
+ $prefix = Mage::getConfig()->getTablePrefix();
114
+ $resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
115
  $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
116
  $paid_remark = $rowURL['value'];
117
  $paid = 1;
126
  $varStatus = 'Sent';
127
  }
128
 
129
+ $prefix = Mage::getConfig()->getTablePrefix();
130
+ $result = $db->query("SELECT item_id, product_type, product_id, product_options, order_id, sku, name, description, qty_ordered, base_price, tax_percent, tax_amount, base_discount_amount FROM {$prefix}sales_flat_order_item WHERE order_id=".$varOrderID." AND parent_item_id IS NULL GROUP BY sku HAVING (order_id > 0) ORDER BY item_id desc");
131
 
132
 
133
  if(!$result) {
146
 
147
  // GETTING API USERNAME
148
  $varPath = 'invoice_options/invoice/api_username';
149
+ $prefix = Mage::getConfig()->getTablePrefix();
150
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
151
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
152
  $username = $rowTwo['value'];
153
 
154
  // GETTING API PASSWORD
155
  $varPath = 'invoice_options/invoice/api_password';
156
+ $prefix = Mage::getConfig()->getTablePrefix();
157
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
158
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
159
  $password = $rowTwo['value'];
160
 
161
  // GETTING LAYOUT CODE
162
  $varPath = 'invoice_options/invoice/layout_code';
163
+ $prefix = Mage::getConfig()->getTablePrefix();
164
+ $resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
165
  $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
166
  $layout_code = $rowTwo['value'];
167
 
168
 
169
  // GETTING CLIENT DETAILS
170
+ $prefix = Mage::getConfig()->getTablePrefix();
171
+ $resultThree = $db->query("SELECT firstname, lastname, company, email, telephone, street, city, region, postcode, country_id, vat_id FROM {$prefix}sales_flat_order_address WHERE entity_id='".$rowOne['billing_address_id']."'");
172
  $rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
173
 
174
  $invoice = new qinvoice($username,$password);
183
  $invoice->country = $rowThree['country_id']; // 2 character country code: NL for Netherlands, DE for Germany etc
184
  $invoice->vatnumber = $rowThree['vat_id'];
185
 
186
+ $prefix = Mage::getConfig()->getTablePrefix();
187
+ $resultFour = $db->query("SELECT firstname, lastname, company, email, telephone, street, city, region, postcode, country_id FROM {$prefix}sales_flat_order_address WHERE entity_id='".$rowOne['shipping_address_id']."'");
188
  $rowFour = $resultFour->fetch(PDO::FETCH_ASSOC);
189
 
190
  $invoice->delivery_address = $rowFour['street']; // Self-explanatory
196
  $invoice->paid = $paid;
197
 
198
  $varActionPath = 'invoice_options/invoice/save_relation';
199
+ $prefix = Mage::getConfig()->getTablePrefix();
200
+ $resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
201
  $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
202
  $save_relation = $rowAction['value'];
203
 
204
  $invoice->saverelation = $save_relation;
205
 
206
  $varRemarkPath = 'invoice_options/invoice/invoice_remark';
207
+ $prefix = Mage::getConfig()->getTablePrefix();
208
+ $resultRemark = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varRemarkPath."'");
209
  $rowRemark = $resultRemark->fetch(PDO::FETCH_ASSOC);
210
  $invoice_remark = $rowRemark['value'];
211
  $invoice->remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark) .' '. $paid_remark; // Self-explanatory
212
 
213
  $varActionPath = 'invoice_options/invoice/invoice_action';
214
+ $prefix = Mage::getConfig()->getTablePrefix();
215
+ $resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
216
  $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
217
  $invoice_action = $rowAction['value'];
218
 
219
  $varLayoutPath = 'invoice_options/invoice/layout_code';
220
+ $prefix = Mage::getConfig()->getTablePrefix();
221
+ $resultLayout = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varLayoutPath."'");
222
  $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
223
  $invoice_layout = $rowLayout['value'];
224
 
241
  $invoice->setLayout($invoice_layout);
242
 
243
  $varTagPath = 'invoice_options/invoice/invoice_tag';
244
+ $prefix = Mage::getConfig()->getTablePrefix();
245
+ $resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
246
  $rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
247
  $invoice_tag = $rowTag['value'];
248
 
383
 
384
  // GETTING API URL
385
  $varURLPath = 'invoice_options/invoice/api_url';
386
+ $prefix = Mage::getConfig()->getTablePrefix();
387
+ $resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
388
  $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
389
  $apiURL = $rowURL['value'];
390
 
app/code/community/Qinvoice/Connect/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
- <version>1.0.4</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
3
  <config>
4
  <modules>
5
  <Qinvoice_Connect>
6
+ <version>1.0.5</version>
7
  </Qinvoice_Connect>
8
  </modules>
9
  <global>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Qinvoice_Connect</name>
4
- <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connects to q-invoice for sending invoices.</summary>
10
  <description>Manage your financial adminstration with q-invoice. All orders are invoiced through q-invoice and automatically added to your administration.</description>
11
- <notes>Added CDATA tags for products and invoice details</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
- <date>2013-11-27</date>
14
- <time>11:51:22</time>
15
- <contents><target name="magecommunity"><dir name="Qinvoice"><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.php" hash="b33157d7ab843fc0a6537e4930fc0be8"/></dir><dir name="Source"><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="e65427cc9773baaedae2b3897c7bf28a"/></dir></dir><dir name="etc"><file name="config.xml" hash="3e71db5013f78a2e01f4bff30521c561"/><file name="system.xml" hash="7559f766d615a0fa291eaa2c2a85912c"/></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>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0</max></package><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>1.0.5</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Connects to q-invoice for sending invoices.</summary>
10
  <description>Manage your financial adminstration with q-invoice. All orders are invoiced through q-invoice and automatically added to your administration.</description>
11
+ <notes>Added support for custom table prefix</notes>
12
  <authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
13
+ <date>2013-12-06</date>
14
+ <time>00:05:49</time>
15
+ <contents><target name="magecommunity"><dir name="Qinvoice"><dir name="Connect"><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.php" hash="b4126d400791cc7325d3520af5442481"/></dir><dir name="Source"><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="e65427cc9773baaedae2b3897c7bf28a"/></dir></dir><dir name="etc"><file name="config.xml" hash="701b42e28b54e95475ef30400702383c"/><file name="system.xml" hash="7559f766d615a0fa291eaa2c2a85912c"/></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>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0</max></package><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
18
  </package>