Qinvoice_Invoice - Version 0.1.2

Version Notes

First release

Download this release

Release Info

Developer Q-invoice
Extension Qinvoice_Invoice
Version 0.1.2
Comparing to
See all releases


Version 0.1.2

app/code/community/Qinvoice/Invoice/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Qinvoice_Invoice_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/community/Qinvoice/Invoice/Order/Observer.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ //class NameSpaceName_ModuleName_Model_ObserverDir_Observer
3
+ class Qinvoice_Invoice_Order_Observer
4
+ {
5
+ public function __contruct()
6
+ {
7
+
8
+ }
9
+
10
+ public function sendOnOrder($observer){
11
+ $order = $observer->getEvent()->getOrder();
12
+
13
+ // GETTING TRIGGER SETTING
14
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
15
+ $varPath = 'invoice_options/invoice/invoice_on_order';
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
+
20
+ if($varOnOrder == 1){
21
+ $this->createInvoiceForQinvoice($order->getId(), false);
22
+ }else{
23
+ return true;
24
+ }
25
+ }
26
+ /**
27
+ * Exports new orders to an xml file
28
+ * @param Varien_Event_Observer $observer
29
+ * @return Feed_Sales_Model_Order_Observer
30
+ */
31
+ public function sendOnPayment($observer){
32
+ // Gets called even when other payment method is choosen.
33
+
34
+ $order_ids = $observer->getEvent()->getOrderIds();
35
+ $order = $observer->getEvent()->getOrder();
36
+
37
+ // GETTING TRIGGER SETTING
38
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
39
+ $varPath = 'invoice_options/invoice/invoice_on_order';
40
+ $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
41
+ $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
42
+ $varOnOrder = $rowTwo['value'];
43
+
44
+ if($varOnOrder == 0){
45
+ $this->createInvoiceForQinvoice($order_ids[0], true);
46
+ }else{
47
+ return true;
48
+ }
49
+ }
50
+ public function createInvoiceForQinvoice($varOrderID,$ifPaid = false)
51
+ {
52
+ $paid = 0;
53
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
54
+ // GETTING ORDER ID
55
+ //$resultOne = $db->query("SELECT max(entity_id) as LastOrderID FROM sales_flat_order");
56
+ //$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
57
+
58
+ //$varOrderID = $rowOne['LastOrderID'];
59
+
60
+ $varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
61
+ // GETTING ORDER STATUS
62
+ $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 FROM sales_flat_order WHERE entity_id=".$varOrderID);
63
+ $rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
64
+
65
+
66
+ if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete' || $rowOne['total_paid'] == $rowOne['grand_total'])
67
+ {
68
+ $varStatus = 'Paid';
69
+ // GETTING API URL
70
+ $varURLPath = 'invoice_options/invoice/paid_remark';
71
+ $resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
72
+ $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
73
+ $paid_remark = $rowURL['value'];
74
+ $paid = 1;
75
+ }
76
+ else
77
+ {
78
+ if($ifPaid == true){
79
+ // cancel if invoice has to be paid
80
+ return;
81
+ }
82
+ $paid_remark = '';
83
+ $varStatus = 'Sent';
84
+ }
85
+
86
+ $result = $db->query("SELECT item_id, product_type, 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");
87
+
88
+ if(!$result) {
89
+ //return false;
90
+ }
91
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
92
+ $arrData[] = $row;
93
+ }
94
+ if(!$arrData) {
95
+ //return false;
96
+ }
97
+ //$comment = '';
98
+ //$comment = $data['comment_text'];
99
+ // getting po_number
100
+ $random_number = rand(0, pow(10, 7));
101
+
102
+ // GETTING API USERNAME
103
+ $varPath = 'invoice_options/invoice/api_username';
104
+ $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
105
+ $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
106
+ $username = $rowTwo['value'];
107
+
108
+ // GETTING API PASSWORD
109
+ $varPath = 'invoice_options/invoice/api_password';
110
+ $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
111
+ $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
112
+ $password = $rowTwo['value'];
113
+
114
+ // GETTING LAYOUT CODE
115
+ $varPath = 'invoice_options/invoice/layout_code';
116
+ $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
117
+ $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
118
+ $layout_code = $rowTwo['value'];
119
+
120
+
121
+ // GETTING CLIENT DETAILS
122
+ $resultThree = $db->query("SELECT firstname, lastname, company, email, telephone, street, city, region, postcode FROM sales_flat_order_address WHERE email='".$rowOne['customer_email']."'");
123
+ $rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
124
+
125
+ $invoice = new qinvoice($username,$password);
126
+
127
+ $invoice->companyname = $rowThree['firstname'].' '.$rowThree['lastname']; // Your customers company name
128
+ $invoice->contactname = $rowThree['firstname'].' '.$rowThree['lastname']; // Your customers contact name
129
+ $invoice->email = $rowOne['customer_email']; // Your customers emailaddress (invoice will be sent here)
130
+ $invoice->address = $rowThree['street']; // Self-explanatory
131
+ $invoice->zipcode = $rowThree['postcode']; // Self-explanatory
132
+ $invoice->city = $rowThree['city']; // Self-explanatory
133
+ $invoice->country = ''; // 2 character country code: NL for Netherlands, DE for Germany etc
134
+ $invoice->vat = ''; // Self-explanatory
135
+ $invoice->paid = $paid;
136
+
137
+ $varRemarkPath = 'invoice_options/invoice/invoice_remark';
138
+ $resultRemark = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varRemarkPath."'");
139
+ $rowRemark = $resultRemark->fetch(PDO::FETCH_ASSOC);
140
+ $invoice_remark = $rowRemark['value'];
141
+ $invoice->remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark) .' '. $paid_remark; // Self-explanatory
142
+
143
+ $varSendPath = 'invoice_options/invoice/send_mail';
144
+ $resultSend = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varSendPath."'");
145
+ $rowSend = $resultSend->fetch(PDO::FETCH_ASSOC);
146
+ $send_mail = $rowSend['value'];
147
+
148
+ $varLayoutPath = 'invoice_options/invoice/layout_code';
149
+ $resultLayout = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varLayoutPath."'");
150
+ $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
151
+ $invoice_layout = $rowLayout['value'];
152
+
153
+ $invoice->setLayout($invoice_layout);
154
+
155
+ $varTagPath = 'invoice_options/invoice/invoice_tag';
156
+ $resultTag = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varTagPath."'");
157
+ $rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
158
+ $invoice_tag = $rowTag['value'];
159
+
160
+ $invoice->send = $send_mail;
161
+
162
+ // OPTIONAL: Add tags
163
+ $invoice->addTag($rowOne['increment_id']);
164
+ $invoice->addTag($invoice_tag);
165
+ // $invoice->addTag('send: '. $send_mail);
166
+ // $invoice->addTag('paid: '. $paid .' '. $rowOne['total_paid']);
167
+
168
+
169
+ for($i=0;$i<count($arrData);$i++)
170
+ {
171
+ $arrItemOptions = unserialize($arrData[$i]['product_options']);
172
+
173
+ $varDescription = '';
174
+ if(@$arrItemOptions['options'])
175
+ {
176
+ for($k=0; $k <count($arrItemOptions['options']); $k++)
177
+ {
178
+ $varDescription .= $arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
179
+ }
180
+ }
181
+ else
182
+ if(@$arrItemOptions['attributes_info'])
183
+ {
184
+ for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
185
+ {
186
+ $varDescription .= $arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
187
+ }
188
+ }
189
+ else
190
+ {
191
+ $varDescription = "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
192
+ }
193
+ $params = array(
194
+ 'description' => $arrData[$i]['name'] ."\n". $varDescription,
195
+ 'price' => $arrData[$i]['base_price']*100,
196
+ 'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
197
+ 'discount' => trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')/$arrData[$i]['base_price'])*100,
198
+ 'quantity' => $arrData[$i]['qty_ordered']*100,
199
+ 'categories' => ''
200
+ );
201
+ //mail('casper@expertnetwork.nl', 'vat', $arrData[$i]['tax_percent']);
202
+ $invoice->addItem($params);
203
+
204
+ }
205
+ if($rowOne['shipping_amount'] > 0)
206
+ {
207
+ $params = array(
208
+ 'description' => trim($rowOne['shipping_description']),
209
+ 'price' => $rowOne['shipping_amount']*100,
210
+ 'vatpercentage' => ($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100,
211
+ 'discount' => 0,
212
+ 'quantity' => 100,
213
+ 'categories' => 'shipping'
214
+ );
215
+
216
+ $invoice->addItem($params);
217
+
218
+ }
219
+
220
+
221
+ $result = $invoice->sendRequest();
222
+ if($result == 1){
223
+ //notify_to_admin('Casper Mekel','casper@newday.sk','Invoice generated!');
224
+ }else{
225
+ //notify_to_admin('Casper Mekel','casper@newday.sk','Something went wrong!');
226
+ }
227
+ return true;
228
+
229
+
230
+ //$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
231
+
232
+ // GETTING SEND MAIL SETTING
233
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
234
+ $varPath = 'invoice_options/invoice/send_mail';
235
+ $resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
236
+ $rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
237
+ $varSendMailFlag = $rowTwo['value'];
238
+
239
+ if($varSendMailFlag && 1==2)
240
+ {
241
+ $xml = stripslashes($curlInvoiveResult);
242
+ $objXml = new SimpleXMLElement($xml);
243
+ $arrParamList = $this->objectsIntoArray($objXml);
244
+
245
+ if($arrParamList['@attributes']['status'] == '200')
246
+ {
247
+ $varInvoiceID = $arrParamList['invoice_id'];
248
+
249
+ $varSendInvoiceXml = '<?xml version="1.0" encoding="utf-8"?>
250
+ <request method="sendInvoiceMail">
251
+ <invoice_id>'.$varInvoiceID.'</invoice_id>
252
+ </request>';
253
+ $curlInvoiceSendResult = $this->sendCurlRequest($varSendInvoiceXml);
254
+
255
+ }
256
+
257
+ }
258
+ }
259
+
260
+ public function notify_to_admin($name, $email, $msg)
261
+ {
262
+ $varSubject = 'Qinvoice Notification';
263
+
264
+ //Mage::log($msg);
265
+
266
+ $mail = Mage::getModel('core/email');
267
+ $mail->setToName($name);
268
+ $mail->setToEmail($email);
269
+ $mail->setBody($msg);
270
+ $mail->setSubject($varSubject);
271
+ $mail->setFromEmail("support@qinvoice.com");
272
+ $mail->setFromName("Qinvoice Development");
273
+ $mail->setType('text');
274
+ $mail->send();
275
+ }
276
+ }
277
+
278
+ class qinvoice{
279
+
280
+ protected $gateway = '';
281
+ private $username;
282
+ private $password;
283
+
284
+ public $companyname;
285
+ public $contactname;
286
+ public $email;
287
+ public $address;
288
+ public $city;
289
+ public $country;
290
+ public $vatnumber;
291
+ public $remark;
292
+ public $paid;
293
+ public $send;
294
+
295
+ public $layout;
296
+
297
+ private $tags = array();
298
+ private $items = array();
299
+ private $files = array();
300
+ private $recurring;
301
+
302
+ function __construct($username, $password){
303
+ $this->username = $username;
304
+ $this->password = $password;
305
+ $this->recurring = 'none';
306
+
307
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
308
+
309
+ // GETTING API URL
310
+ $varURLPath = 'invoice_options/invoice/api_url';
311
+ $resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
312
+ $rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
313
+ $apiURL = $rowURL['value'];
314
+
315
+ $this->gateway = $apiURL;
316
+ }
317
+
318
+ public function addTag($tag){
319
+ $this->tags[] = $tag;
320
+ }
321
+
322
+ public function setLayout($code){
323
+ $this->layout = $code;
324
+ }
325
+
326
+ public function setRecurring($recurring){
327
+ $this->recurring = strtolower($recurring);
328
+ }
329
+
330
+ public function addItem($params){
331
+ $item['description'] = $params['description'];
332
+ $item['price'] = $params['price'];
333
+ $item['vatpercentage'] = $params['vatpercentage'];
334
+ $item['discount'] = $params['discount'];
335
+ $item['quantity'] = $params['quantity'];
336
+ $item['categories'] = $params['categories'];
337
+ $this->items[] = $item;
338
+ }
339
+
340
+ public function addFile($name, $url){
341
+ $this->files[] = array('url' => $url, 'name' => $name);
342
+ }
343
+
344
+ public function sendRequest() {
345
+ $content = "<?xml version='1.0' encoding='UTF-8'?>";
346
+ $content .= $this->buildXML();
347
+
348
+ $headers = array("Content-type: application/atom+xml");
349
+ $ch = curl_init();
350
+ curl_setopt($ch, CURLOPT_URL, $this->gateway );
351
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
352
+ curl_setopt($ch, CURLOPT_TIMEOUT, 120);
353
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
354
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
355
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
356
+ $data = curl_exec($ch);
357
+ if (curl_errno($ch)) {
358
+ print curl_error($ch);
359
+ } else {
360
+ curl_close($ch);
361
+ }
362
+ if($data == 1){
363
+ return true;
364
+ }else{
365
+ return false;
366
+ }
367
+
368
+ }
369
+
370
+ private function buildXML(){
371
+ $string = '<request>
372
+ <login mode="newInvoice">
373
+ <username>'.$this->username.'</username>
374
+ <password>'.$this->password.'</password>
375
+ </login>
376
+ <invoice>
377
+ <companyname>'. $this->companyname .'</companyname>
378
+ <contactname>'. $this->contactname .'</contactname>
379
+ <email>'. $this->email .'</email>
380
+ <address>'. $this->address .'</address>
381
+ <zipcode>'. $this->zipcode .'</zipcode>
382
+ <city>'. $this->city .'</city>
383
+ <country>'. $this->country .'</country>
384
+ <vat>'. $this->vatnumber .'</vat>
385
+ <recurring>'. $this->recurring .'</recurring>
386
+ <remark>'. $this->remark .'</remark>
387
+ <layout>'. $this->layout .'</layout>
388
+ <paid>'. $this->paid .'</paid>
389
+ <send>'. $this->send .'</send>
390
+ <tags>';
391
+ foreach($this->tags as $tag){
392
+ $string .= '<tag>'. $tag .'</tag>';
393
+ }
394
+
395
+ $string .= '</tags>
396
+ <items>';
397
+ foreach($this->items as $i){
398
+
399
+ $string .= '<item>
400
+ <quantity>'. $i['quantity'] .'</quantity>
401
+ <description>'. $i['description'] .'</description>
402
+ <price>'. $i['price'] .'</price>
403
+ <vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
404
+ <discount>'. $i['discount'] .'</discount>
405
+ <categories>'. $i['categories'] .'</categories>
406
+
407
+ </item>';
408
+ }
409
+
410
+ $string .= '</items>
411
+ <files>';
412
+ foreach($this->files as $f){
413
+ $string .= '<file url="'.$f['url'].'">'.$f['name'].'</file>';
414
+ }
415
+ $string .= '</files>
416
+ </invoice>
417
+ </request>';
418
+ return $string;
419
+ }
420
+ }
421
+
422
+ ?>
app/code/community/Qinvoice/Invoice/etc/config.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!-- app/code/local/Qinvoice/Invoice/etc/config.xml -->
3
+ <config>
4
+ <modules>
5
+ <Qinvoice_Invoice>
6
+ <version>0.1.0</version>
7
+ </Qinvoice_Invoice>
8
+ </modules>
9
+ <global>
10
+ <models>
11
+ <invoice>
12
+ <class>Qinvoice_Invoice</class>
13
+ </invoice>
14
+ </models>
15
+ <events>
16
+ <sales_order_place_after>
17
+ <observers>
18
+ <invoice>
19
+ <class>invoice/order_observer</class>
20
+ <method>sendOnOrder</method>
21
+ </invoice>
22
+ </observers>
23
+ </sales_order_place_after>
24
+ <checkout_onepage_controller_success_action>
25
+ <observers>
26
+ <invoice>
27
+ <class>invoice/order_observer</class>
28
+ <method>sendOnPayment</method>
29
+ </invoice>
30
+ </observers>
31
+ </checkout_onepage_controller_success_action>
32
+ </events>
33
+ <helpers>
34
+ <invoice>
35
+ <class>Qinvoice_Invoice_Helper</class>
36
+ </invoice>
37
+ </helpers>
38
+ </global>
39
+ <adminhtml>
40
+ <acl>
41
+ <resources>
42
+ <admin>
43
+ <children>
44
+ <system>
45
+ <children>
46
+ <config>
47
+ <children>
48
+ <invoice_options>
49
+ <title>Store Hello World Module Section</title>
50
+ </invoice_options>
51
+ </children>
52
+ </config>
53
+ </children>
54
+ </system>
55
+ </children>
56
+ </admin>
57
+ </resources>
58
+ </acl>
59
+ </adminhtml>
60
+
61
+ </config>
app/code/community/Qinvoice/Invoice/etc/configold.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <global>
4
+ <models>
5
+ <invoice>
6
+ <class>Qinvoice_Invoice</class>
7
+ </invoice>
8
+ </models>
9
+ <events>
10
+ <sales_order_place_after>
11
+ <observers>
12
+ <invoice_order_observer>
13
+ <type>singleton</type>
14
+ <class>invoice/order_observer</class>
15
+ <method>sendOrder</method>
16
+ </invoice_order_observer>
17
+ </observers>
18
+ </sales_order_place_after>
19
+ </events>
20
+
21
+ <helpers>
22
+ <invoice>
23
+ <class>Qinvoice_Invoice_Helper</class>
24
+ </invoice>
25
+ </helpers>
26
+ <blocks>
27
+ <adminhtml>
28
+ <rewrite>
29
+ <sales_order_grid>Qinvoice_Invoice_Block_Sales_Order_Grid</sales_order_grid>
30
+ </rewrite>
31
+ </adminhtml>
32
+ </blocks>
33
+ </global>
34
+ <frontend>
35
+ <routers>
36
+ <helloworld>
37
+ <args>
38
+ <modules>
39
+
40
+ </modules>
41
+ </args>
42
+ </helloworld>
43
+ </routers>
44
+ </frontend>
45
+ <adminhtml>
46
+ <acl>
47
+ <resources>
48
+ <admin>
49
+ <children>
50
+ <system>
51
+ <children>
52
+ <config>
53
+ <children>
54
+ <invoice_options>
55
+ <title>Store Hello World Module Section</title>
56
+ </invoice_options>
57
+ </children>
58
+ </config>
59
+ </children>
60
+ </system>
61
+ </children>
62
+ </admin>
63
+ </resources>
64
+ </acl>
65
+ </adminhtml>
66
+ </config>
app/code/community/Qinvoice/Invoice/etc/system.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <qinvoice translate="label" module="invoice">
5
+ <label>Qinvoice</label>
6
+ <sort_order>300</sort_order>
7
+ </qinvoice>
8
+ </tabs>
9
+ <sections>
10
+ <invoice_options translate="label" module="invoice">
11
+ <label>Qinvoice Configuration</label>
12
+ <tab>qinvoice</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <invoice translate="label">
20
+ <label>Qinvoice</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <api_url translate="label">
28
+ <label>API URL</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>1</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <comment><![CDATA[e.g. https://app.q-invoice.com/api/xml/1.0/]]></comment>
35
+ </api_url>
36
+ <api_username translate="label">
37
+ <label>API Username</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </api_username>
44
+ <api_password translate="label">
45
+ <label>API Password</label>
46
+ <frontend_type>password</frontend_type>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </api_password>
52
+ <layout_code translate="label">
53
+ <label>Layout Code</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>4</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ <comment><![CDATA[Optional]]></comment>
60
+ </layout_code>
61
+ <invoice_remark translate="label">
62
+ <label>Invoice remark</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>5</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ <comment><![CDATA[e.g. Order #{order_id}.]]></comment>
69
+ </invoice_remark>
70
+ <invoice_tag translate="label">
71
+ <label>Invoice tag</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>5</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <comment><![CDATA[Optional. e.g. Your webshop name.]]></comment>
78
+ </invoice_tag>
79
+ <paid_remark translate="label">
80
+ <label>Paid remark</label>
81
+ <frontend_type>text</frontend_type>
82
+ <sort_order>6</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ <comment><![CDATA[e.g. Your payment has been received.]]></comment>
87
+ </paid_remark>
88
+ <invoice_on_order translate="label">
89
+ <label>Generate invoice on order</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <sort_order>7</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ <comment><![CDATA[Yes: invoice for every order. No: invoice for every payment.]]></comment>
97
+ </invoice_on_order>
98
+ <send_mail translate="label">
99
+ <label>Send invoice to customer</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>8</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ <comment><![CDATA[Send email with invoice to customer.]]></comment>
107
+ </send_mail>
108
+ </fields>
109
+ </invoice>
110
+ </groups>
111
+ </invoice_options>
112
+ </sections>
113
+ </config>
app/etc/modules/Qinvoice_Invoice.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Qinvoice_Invoice>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Qinvoice_Invoice>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Qinvoice_Invoice</name>
4
+ <version>0.1.2</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Connect to q-invoice for sending and managing invoices</summary>
10
+ <description>Connect to q-invoice for sending and managing invoices</description>
11
+ <notes>First release</notes>
12
+ <authors><author><name>Q-invoice</name><user>q-invoice</user><email>info@q-invoice.com</email></author></authors>
13
+ <date>2013-07-16</date>
14
+ <time>12:57:01</time>
15
+ <contents><target name="magecommunity"><dir name="Qinvoice"><dir name="Invoice"><dir name="Helper"><file name="Data.php" hash="b17b2a7e7d551b9b24924d667759febb"/></dir><dir name="Order"><file name="Observer.php" hash="16bc431c2fb1c47f006ce7e0840683c5"/></dir><dir name="etc"><file name="config.xml" hash="dab71cf14d17e66a498adc4fe5e17f7d"/><file name="configold.xml" hash="190809fc9045610c7749b762b8568ced"/><file name="system.xml" hash="b8047d3ed2e8d3adcc12eb0b49ef25fc"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Invoice.xml" hash="9d385180e384df30730c917c54cef635"/></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>communicty</channel><min>1.6.0.0</min><max>1.7.0</max></package></required></dependencies>
18
+ </package>