Version Notes
System Requirements
Your web server needs to have PHP’s cURL extension installed. If you are unsure about this, the easiest way to find out is just to proceed with this set up and see if it works. If it turns out that the cURL extension is not installed, you should ask your system administrator to rebuild PHP with this extension enabled.
You need to have Magento version 1.4.2.0 or higher
Download this release
Release Info
Developer | Magento Core Team |
Extension | Invoicera_Order_and_Invoice_Connector |
Version | 1.2.7 |
Comparing to | |
See all releases |
Code changes from version 1.2.6 to 1.2.7
- app/code/community/Invoicera/Ajax/controllers/SanController.php +716 -0
- app/code/community/Invoicera/Ajax/etc/config.xml +20 -0
- app/code/community/Invoicera/Invoice/Block/Sales/Order/Grid.php +171 -0
- app/code/community/Invoicera/Invoice/etc/config.xml +8 -1
- app/etc/modules/Invoicera_Invoice.xml +4 -20
- package.xml +4 -4
app/code/community/Invoicera/Ajax/controllers/SanController.php
ADDED
@@ -0,0 +1,716 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Invoicera_Ajax_SanController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
echo "Congratulations! Your ajax module is configured correctly.";
|
7 |
+
}
|
8 |
+
|
9 |
+
public function exportOrderAction()
|
10 |
+
{
|
11 |
+
$varAdminPath = Mage_Core_Model_Store::ADMIN_CODE;
|
12 |
+
$arrOrderID = $_POST['order_ids'];
|
13 |
+
$varOrderCount = count($arrOrderID);
|
14 |
+
if($varOrderCount > 0 && $varOrderCount < 21)
|
15 |
+
{
|
16 |
+
for($i=0; $i<$varOrderCount; $i++)
|
17 |
+
{
|
18 |
+
if($arrOrderID[$i] != '')
|
19 |
+
{
|
20 |
+
$this->createInvoiceFromOrderToInvoicera($arrOrderID[$i]);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
$varURL = str_replace('ajax', $varAdminPath, Mage::helper("adminhtml")->getUrl("*/sales_order"));
|
24 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Selected order(s) exported successfully.'));
|
25 |
+
header('location:'.$varURL);
|
26 |
+
die;
|
27 |
+
}
|
28 |
+
else
|
29 |
+
{
|
30 |
+
|
31 |
+
$varURL = str_replace('ajax', $varAdminPath, Mage::helper("adminhtml")->getUrl("*/sales_order"));
|
32 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('You cannot export more than 20 orders in a single request.'));
|
33 |
+
header('location:'.$varURL);
|
34 |
+
die;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
public function createInvoiceFromOrderToInvoicera($varOrderID)
|
40 |
+
{
|
41 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
42 |
+
|
43 |
+
$varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
|
44 |
+
// GETTING ORDER STATUS
|
45 |
+
$resultOne = $db->query("SELECT entity_id, status, customer_email, base_currency_code, shipping_description, shipping_amount, increment_id FROM sales_flat_order WHERE entity_id=".$varOrderID);
|
46 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
47 |
+
|
48 |
+
|
49 |
+
if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete')
|
50 |
+
{
|
51 |
+
$varStatus = 'Paid';
|
52 |
+
}
|
53 |
+
else
|
54 |
+
{
|
55 |
+
$varStatus = 'Sent';
|
56 |
+
}
|
57 |
+
|
58 |
+
$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);
|
59 |
+
|
60 |
+
if(!$result) {
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
64 |
+
$arrData[] = $row;
|
65 |
+
}
|
66 |
+
if(!$arrData) {
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
$comment = '';
|
70 |
+
//$comment = $data['comment_text'];
|
71 |
+
// getting po_number
|
72 |
+
$random_number = rand(0, pow(10, 7));
|
73 |
+
// GETTING INVOICE PREFIX
|
74 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
75 |
+
$varPath = 'invoice_options/invoice/invoice_prefix';
|
76 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
77 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
78 |
+
|
79 |
+
$varInvoicePrefix = $rowTwo['value'];
|
80 |
+
|
81 |
+
$invoiceListXml = '<?xml version="1.0" encoding="utf-8"?>
|
82 |
+
<request method="listInvoice">
|
83 |
+
<filter>
|
84 |
+
<invoice_number>'.$varInvoicePrefix.$rowOne['increment_id'].'</invoice_number>
|
85 |
+
<page>1</page>
|
86 |
+
<per_page_record>1</per_page_record>
|
87 |
+
</filter>
|
88 |
+
</request>';
|
89 |
+
$curlInvoiceListResult = $this->sendCurlRequest($invoiceListXml);
|
90 |
+
$xml = stripslashes($curlInvoiceListResult);
|
91 |
+
$objXml = new SimpleXMLElement($xml);
|
92 |
+
|
93 |
+
$arrInvoiceListParamList = $this->objectsIntoArray($objXml);
|
94 |
+
|
95 |
+
if($arrInvoiceListParamList['@attributes']['status'] == '400')
|
96 |
+
{
|
97 |
+
$clientListXml = '<?xml version="1.0" encoding="utf-8"?>
|
98 |
+
<request method="listClient">
|
99 |
+
<filter>
|
100 |
+
<client_email>'.$rowOne['customer_email'].'</client_email>
|
101 |
+
<page>1</page>
|
102 |
+
<per_page_record>10</per_page_record>
|
103 |
+
</filter>
|
104 |
+
</request>';
|
105 |
+
$curlClientListResult = $this->sendCurlRequest($clientListXml);
|
106 |
+
$xml = stripslashes($curlClientListResult);
|
107 |
+
$objXml = new SimpleXMLElement($xml);
|
108 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
109 |
+
|
110 |
+
$varClientID = 0;
|
111 |
+
if($arrParamList['@attributes']['status'] == '403')
|
112 |
+
{
|
113 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
114 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
115 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
116 |
+
$varMessage = "
|
117 |
+
Dear ".$rowAdmindata['Name']."
|
118 |
+
|
119 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
120 |
+
|
121 |
+
Regards
|
122 |
+
Invoicera Team";
|
123 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
124 |
+
}
|
125 |
+
if($arrParamList['@attributes']['status'] == '200' && $arrParamList['clients']['@attributes']['total'] == 1)
|
126 |
+
{
|
127 |
+
$varClientID = $arrParamList['clients']['client']['client_id'];
|
128 |
+
$varClientAddress = $arrParamList['clients']['client']['address'];
|
129 |
+
}
|
130 |
+
else
|
131 |
+
{
|
132 |
+
// GETTING CLIENT DETAILS
|
133 |
+
$resultThree = $db->query("SELECT firstname, country.iso3_code as CountryCode, lastname, company, email, telephone, concat_ws(',', street, city, region, postcode) as ClientAddress FROM sales_flat_order_address as sfoa LEFT JOIN directory_country as country ON sfoa.country_id = country.country_id WHERE parent_id='".$varOrderID."' AND address_type = 'billing'");
|
134 |
+
$rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
|
135 |
+
|
136 |
+
$clientCreateXml = '<?xml version="1.0" encoding="utf-8"?>
|
137 |
+
<request method="createClient">
|
138 |
+
<name>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</name>
|
139 |
+
<organization>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</organization>
|
140 |
+
<email>'.$rowOne['customer_email'].'</email>
|
141 |
+
<work_phone>'.$rowThree['telephone'].'</work_phone>
|
142 |
+
<address>'.$rowThree['ClientAddress'].'</address>
|
143 |
+
<currency>'.$varCurrenyCode.'</currency>
|
144 |
+
<country>'.$rowThree['CountryCode'].'</country>
|
145 |
+
</request>';
|
146 |
+
|
147 |
+
$curlClientResult = $this->sendCurlRequest($clientCreateXml);
|
148 |
+
$xml = stripslashes($curlClientResult);
|
149 |
+
$objXml = new SimpleXMLElement($xml);
|
150 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
151 |
+
|
152 |
+
if($arrParamList['@attributes']['status'] == '403')
|
153 |
+
{
|
154 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
155 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
156 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
157 |
+
$varMessage = "
|
158 |
+
Dear ".$rowAdmindata['Name']."
|
159 |
+
|
160 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
161 |
+
|
162 |
+
Regards
|
163 |
+
Invoicera Team";
|
164 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
165 |
+
}
|
166 |
+
|
167 |
+
if($arrParamList['@attributes']['status'] == '426')
|
168 |
+
{
|
169 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
170 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
171 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
172 |
+
$varMessage = "
|
173 |
+
Dear ".$rowAdmindata['Name']."
|
174 |
+
|
175 |
+
This is to notify you that now your orders can not be imported and saved as invoices into your Invoicera account as your Invoicera account has exceeded the client limit. Due to which, your customers who would make any order on your store now, would not be able to get an invoice from your Invoicera Account. To avoid this inconvenience, we would request you to upgrade your Invoicera account.
|
176 |
+
|
177 |
+
Please feel free to contact us in case you have any query.
|
178 |
+
|
179 |
+
Thanks & Regards,
|
180 |
+
Invoicera Team
|
181 |
+
|
182 |
+
http://www.invoicera.com/
|
183 |
+
You may also catch us over Twitter at http://www.twitter.com/invoicera";
|
184 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
185 |
+
}
|
186 |
+
if($arrParamList['@attributes']['status'] == '200')
|
187 |
+
{
|
188 |
+
$varClientID = $arrParamList['client_id'];
|
189 |
+
$varClientAddress = $rowThree['ClientAddress'];
|
190 |
+
}
|
191 |
+
}
|
192 |
+
if($varClientID)
|
193 |
+
{
|
194 |
+
|
195 |
+
// creating XML for creating invoice
|
196 |
+
$createInvoiceXML = '';
|
197 |
+
$createInvoiceXML .= '<?xml version="1.0" encoding="utf-8"?>
|
198 |
+
<request method="createInvoice">
|
199 |
+
<client>
|
200 |
+
<client_id>'.$varClientID.'</client_id>
|
201 |
+
<address>'.$varClientAddress.'</address>
|
202 |
+
</client>
|
203 |
+
<invoice_title>Order #'.$rowOne['increment_id'].'</invoice_title>
|
204 |
+
<number>'.$varInvoicePrefix.$rowOne['increment_id'].'</number>
|
205 |
+
<date>'.trim(substr($arrData[0]['created_at'], 0, 10)).'</date>
|
206 |
+
<due_date></due_date>
|
207 |
+
<schedule_date></schedule_date>
|
208 |
+
<po_number>'.trim($random_number).'</po_number>
|
209 |
+
<status>'.trim($varStatus).'</status>
|
210 |
+
<currency_code>'.trim($varCurrenyCode).'</currency_code>
|
211 |
+
<notes>'.$comment.'</notes>
|
212 |
+
<terms></terms>
|
213 |
+
<items>';
|
214 |
+
for($i=0;$i<count($arrData);$i++)
|
215 |
+
{
|
216 |
+
$arrItemOptions = unserialize($arrData[$i]['product_options']);
|
217 |
+
$varDescription = '';
|
218 |
+
|
219 |
+
if($arrItemOptions['bundle_options'])
|
220 |
+
{
|
221 |
+
foreach($arrItemOptions['bundle_options'] as $key=>$value)
|
222 |
+
{
|
223 |
+
$varDescription .= $value['label'].": ".$value['value'][0]['title']."\n";
|
224 |
+
}
|
225 |
+
}
|
226 |
+
else
|
227 |
+
if($arrItemOptions['options'])
|
228 |
+
{
|
229 |
+
for($k=0; $k <count($arrItemOptions['options']); $k++)
|
230 |
+
{
|
231 |
+
$varDescription .= $arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
|
232 |
+
}
|
233 |
+
}
|
234 |
+
else
|
235 |
+
if($arrItemOptions['attributes_info'])
|
236 |
+
{
|
237 |
+
for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
|
238 |
+
{
|
239 |
+
$varDescription .= $arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
|
240 |
+
}
|
241 |
+
}
|
242 |
+
else
|
243 |
+
{
|
244 |
+
$varDescription = "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
|
245 |
+
}
|
246 |
+
if($arrData[$i]['product_type'] == 'bundle' || $arrData[$i]['product_type'] == 'group')
|
247 |
+
{
|
248 |
+
$createInvoiceXML .='<item>
|
249 |
+
<name>'.trim($arrData[$i]['name']).'</name>
|
250 |
+
<type>Product</type>
|
251 |
+
<description>'.$varDescription.'</description>
|
252 |
+
<unit_cost>'.trim(number_format($arrData[$i]['base_price'], 2, '.', '')).'</unit_cost>
|
253 |
+
<quantity>1.00</quantity>
|
254 |
+
<discount>0.00</discount>
|
255 |
+
<discount_type>Fixed</discount_type>';
|
256 |
+
if($arrData[$i]['tax_percent'] > 0)
|
257 |
+
{
|
258 |
+
$createInvoiceXML .='
|
259 |
+
<tax1_name>Tax-1</tax1_name>
|
260 |
+
<tax1_percent>'.trim(number_format($arrData[$i]['tax_percent'], 2, '.', '')).'</tax1_percent>';
|
261 |
+
}
|
262 |
+
$createInvoiceXML .='
|
263 |
+
</item>';
|
264 |
+
}
|
265 |
+
else
|
266 |
+
{
|
267 |
+
$createInvoiceXML .='<item>
|
268 |
+
<name>'.trim($arrData[$i]['name']).'</name>
|
269 |
+
<type>Product</type>
|
270 |
+
<description>'.$varDescription.'</description>
|
271 |
+
<unit_cost>'.trim(number_format($arrData[$i]['base_price'], 2, '.', '')).'</unit_cost>
|
272 |
+
<quantity>'.trim(number_format($arrData[$i]['qty_ordered'], 2, '.', '')).'</quantity>
|
273 |
+
<discount>'.trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')).'</discount>
|
274 |
+
<discount_type>Fixed</discount_type>';
|
275 |
+
if($arrData[$i]['tax_percent'] > 0)
|
276 |
+
{
|
277 |
+
$createInvoiceXML .='
|
278 |
+
<tax1_name>Tax-1</tax1_name>
|
279 |
+
<tax1_percent>'.trim(number_format($arrData[$i]['tax_percent'], 2, '.', '')).'</tax1_percent>';
|
280 |
+
}
|
281 |
+
$createInvoiceXML .='
|
282 |
+
</item>';
|
283 |
+
}
|
284 |
+
}
|
285 |
+
$createInvoiceXML .= '</items>';
|
286 |
+
if($rowOne['shipping_amount'] > 0)
|
287 |
+
{
|
288 |
+
$createInvoiceXML .= '
|
289 |
+
<additional_charges>
|
290 |
+
<additional_charge>
|
291 |
+
<name>'.trim($rowOne['shipping_description']).'</name>
|
292 |
+
<type>Fixed</type>
|
293 |
+
<amount>'.trim($rowOne['shipping_amount']).'</amount>
|
294 |
+
</additional_charge>
|
295 |
+
</additional_charges>';
|
296 |
+
}
|
297 |
+
$createInvoiceXML .= '</request>';
|
298 |
+
$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
|
299 |
+
|
300 |
+
// GETTING SEND MAIL SETTING
|
301 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
302 |
+
$varPath = 'invoice_options/invoice/send_mail';
|
303 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
304 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
305 |
+
$varSendMailFlag = $rowTwo['value'];
|
306 |
+
|
307 |
+
if($varSendMailFlag)
|
308 |
+
{
|
309 |
+
$xml = stripslashes($curlInvoiveResult);
|
310 |
+
$objXml = new SimpleXMLElement($xml);
|
311 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
312 |
+
|
313 |
+
if($arrParamList['@attributes']['status'] == '200')
|
314 |
+
{
|
315 |
+
$varInvoiceID = $arrParamList['invoice_id'];
|
316 |
+
|
317 |
+
$varSendInvoiceXml = '<?xml version="1.0" encoding="utf-8"?>
|
318 |
+
<request method="sendInvoiceMail">
|
319 |
+
<invoice_id>'.$varInvoiceID.'</invoice_id>
|
320 |
+
</request>';
|
321 |
+
$curlInvoiceSendResult = $this->sendCurlRequest($varSendInvoiceXml);
|
322 |
+
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
public function exportInvoiceAction()
|
329 |
+
{
|
330 |
+
$varAdminPath = Mage_Core_Model_Store::ADMIN_CODE;
|
331 |
+
$arrInvoiceID = $_POST['invoice_ids'];
|
332 |
+
$varInvoiceCount = count($arrInvoiceID);
|
333 |
+
if($varInvoiceCount > 0 && $varInvoiceCount < 21)
|
334 |
+
{
|
335 |
+
for($i=0; $i<$varInvoiceCount; $i++)
|
336 |
+
{
|
337 |
+
if($arrInvoiceID[$i] != '')
|
338 |
+
{
|
339 |
+
$this->createInvoiceForInvoicera($arrInvoiceID[$i]);
|
340 |
+
}
|
341 |
+
}
|
342 |
+
$varURL = str_replace('ajax', $varAdminPath, Mage::helper("adminhtml")->getUrl("*/sales_invoice"));
|
343 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Selected invoce(s) exported successfully.'));
|
344 |
+
header('location:'.$varURL);
|
345 |
+
die;
|
346 |
+
}
|
347 |
+
else
|
348 |
+
{
|
349 |
+
|
350 |
+
$varURL = str_replace('ajax', $varAdminPath, Mage::helper("adminhtml")->getUrl("*/sales_invoice"));
|
351 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('You cannot export more than 20 invoices in a single request.'));
|
352 |
+
header('location:'.$varURL);
|
353 |
+
die;
|
354 |
+
}
|
355 |
+
|
356 |
+
}
|
357 |
+
|
358 |
+
public function createInvoiceForInvoicera($varInvoiceID)
|
359 |
+
{
|
360 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
361 |
+
|
362 |
+
$varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
|
363 |
+
// GETTING ORDER STATUS
|
364 |
+
$resultOne = $db->query("SELECT sfo.customer_email, sfo.base_currency_code, sfo.shipping_description, sfo.shipping_amount, sfo.increment_id FROM sales_flat_invoice as sfi INNER JOIN sales_flat_order AS sfo ON sfi.order_id = sfo.entity_id WHERE sfi.entity_id=".$varInvoiceID);
|
365 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
366 |
+
|
367 |
+
|
368 |
+
|
369 |
+
if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete')
|
370 |
+
{
|
371 |
+
$varStatus = 'Paid';
|
372 |
+
}
|
373 |
+
else
|
374 |
+
{
|
375 |
+
$varStatus = 'Sent';
|
376 |
+
}
|
377 |
+
|
378 |
+
$result = $db->query("SELECT sfoi.product_options, sfoi.product_type, sfii.sku, sfii.name, sfoi.description, sfii.qty, sfii.base_price, sfoi.tax_percent, sfoi.tax_amount, sfoi.base_discount_amount FROM sales_flat_invoice_item as sfii INNER JOIN sales_flat_order_item as sfoi ON sfii.order_item_id = sfoi.item_id WHERE sfii.parent_id=".$varInvoiceID." ");
|
379 |
+
|
380 |
+
if(!$result) {
|
381 |
+
return false;
|
382 |
+
}
|
383 |
+
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
384 |
+
$arrData[] = $row;
|
385 |
+
}
|
386 |
+
if(!$arrData) {
|
387 |
+
return false;
|
388 |
+
}
|
389 |
+
$comment = '';
|
390 |
+
//$comment = $data['comment_text'];
|
391 |
+
// getting po_number
|
392 |
+
$random_number = rand(0, pow(10, 7));
|
393 |
+
// GETTING INVOICE PREFIX
|
394 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
395 |
+
$varPath = 'invoice_options/invoice/invoice_prefix';
|
396 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
397 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
398 |
+
|
399 |
+
$varInvoicePrefix = $rowTwo['value'];
|
400 |
+
|
401 |
+
$invoiceListXml = '<?xml version="1.0" encoding="utf-8"?>
|
402 |
+
<request method="listInvoice">
|
403 |
+
<filter>
|
404 |
+
<invoice_number>'.$varInvoicePrefix.$rowOne['increment_id'].'</invoice_number>
|
405 |
+
<page>1</page>
|
406 |
+
<per_page_record>1</per_page_record>
|
407 |
+
</filter>
|
408 |
+
</request>';
|
409 |
+
$curlInvoiceListResult = $this->sendCurlRequest($invoiceListXml);
|
410 |
+
$xml = stripslashes($curlInvoiceListResult);
|
411 |
+
$objXml = new SimpleXMLElement($xml);
|
412 |
+
|
413 |
+
$arrInvoiceListParamList = $this->objectsIntoArray($objXml);
|
414 |
+
|
415 |
+
if($arrInvoiceListParamList['@attributes']['status'] == '400')
|
416 |
+
{
|
417 |
+
$clientListXml = '<?xml version="1.0" encoding="utf-8"?>
|
418 |
+
<request method="listClient">
|
419 |
+
<filter>
|
420 |
+
<client_email>'.$rowOne['customer_email'].'</client_email>
|
421 |
+
<page>1</page>
|
422 |
+
<per_page_record>10</per_page_record>
|
423 |
+
</filter>
|
424 |
+
</request>';
|
425 |
+
$curlClientListResult = $this->sendCurlRequest($clientListXml);
|
426 |
+
$xml = stripslashes($curlClientListResult);
|
427 |
+
$objXml = new SimpleXMLElement($xml);
|
428 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
429 |
+
|
430 |
+
$varClientID = 0;
|
431 |
+
if($arrParamList['@attributes']['status'] == '403')
|
432 |
+
{
|
433 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
434 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
435 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
436 |
+
$varMessage = "
|
437 |
+
Dear ".$rowAdmindata['Name']."
|
438 |
+
|
439 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
440 |
+
|
441 |
+
Regards
|
442 |
+
Invoicera Team";
|
443 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
444 |
+
}
|
445 |
+
if($arrParamList['@attributes']['status'] == '200' && $arrParamList['clients']['@attributes']['total'] == 1)
|
446 |
+
{
|
447 |
+
$varClientID = $arrParamList['clients']['client']['client_id'];
|
448 |
+
}
|
449 |
+
else
|
450 |
+
{
|
451 |
+
// GETTING CLIENT DETAILS
|
452 |
+
//$resultThree = $db->query("SELECT firstname, lastname, company, email, telephone, concat_ws(',', street, city, region, postcode) as ClientAddress FROM sales_flat_order_address WHERE email='".$rowOne['customer_email']."'");
|
453 |
+
|
454 |
+
$resultThree = $db->query("SELECT firstname, country.iso3_code as CountryCode, lastname, company, email, telephone, concat_ws(',', street, city, region, postcode) as ClientAddress FROM sales_flat_order_address as sfoa INNER JOIN directory_country as country ON sfoa.country_id = country.country_id WHERE email='".$rowOne['customer_email']."'");
|
455 |
+
$rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
|
456 |
+
|
457 |
+
$clientCreateXml = '<?xml version="1.0" encoding="utf-8"?>
|
458 |
+
<request method="createClient">
|
459 |
+
<name>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</name>
|
460 |
+
<organization>'.$rowThree['firstname'].' '.$rowThree['lastname'].'</organization>
|
461 |
+
<email>'.$rowOne['customer_email'].'</email>
|
462 |
+
<work_phone>'.$rowThree['telephone'].'</work_phone>
|
463 |
+
<address>'.$rowThree['ClientAddress'].'</address>
|
464 |
+
<currency>'.$varCurrenyCode.'</currency>
|
465 |
+
<country>'.$rowThree['CountryCode'].'</country>
|
466 |
+
</request>';
|
467 |
+
$curlClientResult = $this->sendCurlRequest($clientCreateXml);
|
468 |
+
$xml = stripslashes($curlClientResult);
|
469 |
+
$objXml = new SimpleXMLElement($xml);
|
470 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
471 |
+
|
472 |
+
if($arrParamList['@attributes']['status'] == '403')
|
473 |
+
{
|
474 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
475 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
476 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
477 |
+
$varMessage = "
|
478 |
+
Dear ".$rowAdmindata['Name']."
|
479 |
+
|
480 |
+
Invoicera API authentication failed. Please check your invoicera configuration.
|
481 |
+
|
482 |
+
Regards
|
483 |
+
Invoicera Team";
|
484 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
485 |
+
}
|
486 |
+
|
487 |
+
if($arrParamList['@attributes']['status'] == '426')
|
488 |
+
{
|
489 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
490 |
+
$resultAdminData = $db->query("SELECT concat_ws(' ', firstname, lastname) as Name, email FROM admin_user WHERE user_id = 1");
|
491 |
+
$rowAdmindata = $resultAdminData->fetch(PDO::FETCH_ASSOC);
|
492 |
+
$varMessage = "
|
493 |
+
Dear ".$rowAdmindata['Name']."
|
494 |
+
|
495 |
+
This is to notify you that now your orders can not be imported and saved as invoices into your Invoicera account as your Invoicera account has exceeded the client limit. Due to which, your customers who would make any order on your store now, would not be able to get an invoice from your Invoicera Account. To avoid this inconvenience, we would request you to upgrade your Invoicera account.
|
496 |
+
|
497 |
+
Please feel free to contact us in case you have any query.
|
498 |
+
|
499 |
+
Thanks & Regards,
|
500 |
+
Invoicera Team
|
501 |
+
|
502 |
+
http://www.invoicera.com/
|
503 |
+
You may also catch us over Twitter at http://www.twitter.com/invoicera";
|
504 |
+
$this->notify_to_admin($rowAdmindata['Name'], $rowAdmindata['email'], $varMessage);
|
505 |
+
}
|
506 |
+
if($arrParamList['@attributes']['status'] == '200')
|
507 |
+
{
|
508 |
+
$varClientID = $arrParamList['client_id'];
|
509 |
+
}
|
510 |
+
}
|
511 |
+
if($varClientID)
|
512 |
+
{
|
513 |
+
|
514 |
+
// creating XML for creating invoice
|
515 |
+
$createInvoiceXML = '';
|
516 |
+
$createInvoiceXML .= '<?xml version="1.0" encoding="utf-8"?>
|
517 |
+
<request method="createInvoice">
|
518 |
+
<client>
|
519 |
+
<client_id>'.$varClientID.'</client_id>
|
520 |
+
<address>'.$rowThree['ClientAddress'].'</address>
|
521 |
+
</client>
|
522 |
+
<invoice_title>Order #'.$rowOne['increment_id'].'</invoice_title>
|
523 |
+
<number>'.$varInvoicePrefix.$rowOne['increment_id'].'</number>
|
524 |
+
<date>'.trim(substr($arrData[0]['created_at'], 0, 10)).'</date>
|
525 |
+
<due_date></due_date>
|
526 |
+
<schedule_date></schedule_date>
|
527 |
+
<po_number>'.trim($random_number).'</po_number>
|
528 |
+
<status>'.trim($varStatus).'</status>
|
529 |
+
<currency_code>'.trim($varCurrenyCode).'</currency_code>
|
530 |
+
<notes>'.$comment.'</notes>
|
531 |
+
<terms></terms>
|
532 |
+
<items>';
|
533 |
+
for($i=0;$i<count($arrData);$i++)
|
534 |
+
{
|
535 |
+
$arrItemOptions = unserialize($arrData[$i]['product_options']);
|
536 |
+
$varDescription = '';
|
537 |
+
|
538 |
+
if($arrItemOptions['bundle_options'])
|
539 |
+
{
|
540 |
+
foreach($arrItemOptions['bundle_options'] as $key=>$value)
|
541 |
+
{
|
542 |
+
$varDescription .= $value['label'].": ".$value['value'][0]['title']."\n";
|
543 |
+
}
|
544 |
+
}
|
545 |
+
else
|
546 |
+
if($arrItemOptions['options'])
|
547 |
+
{
|
548 |
+
for($k=0; $k <count($arrItemOptions['options']); $k++)
|
549 |
+
{
|
550 |
+
$varDescription .= $arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
|
551 |
+
}
|
552 |
+
}
|
553 |
+
else
|
554 |
+
if($arrItemOptions['attributes_info'])
|
555 |
+
{
|
556 |
+
for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
|
557 |
+
{
|
558 |
+
$varDescription .= $arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
|
559 |
+
}
|
560 |
+
}
|
561 |
+
else
|
562 |
+
{
|
563 |
+
$varDescription = "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']);
|
564 |
+
}
|
565 |
+
if($arrData[$i]['product_type'] == 'bundle')
|
566 |
+
{
|
567 |
+
$createInvoiceXML .='<item>
|
568 |
+
<name>'.trim($arrData[$i]['name']).'</name>
|
569 |
+
<type>Product</type>
|
570 |
+
<description>'.$varDescription.'</description>
|
571 |
+
<unit_cost>0.00</unit_cost>
|
572 |
+
<quantity>0.00</quantity>
|
573 |
+
<discount>0.00</discount>
|
574 |
+
<discount_type>Fixed</discount_type>';
|
575 |
+
if($arrData[$i]['tax_percent'] > 0)
|
576 |
+
{
|
577 |
+
$createInvoiceXML .='
|
578 |
+
<tax1_name>Tax-1</tax1_name>
|
579 |
+
<tax1_percent>'.trim(number_format($arrData[$i]['tax_percent'], 2, '.', '')).'</tax1_percent>';
|
580 |
+
}
|
581 |
+
$createInvoiceXML .='
|
582 |
+
</item>';
|
583 |
+
}
|
584 |
+
else
|
585 |
+
{
|
586 |
+
$createInvoiceXML .='<item>
|
587 |
+
<name>'.trim($arrData[$i]['name']).'</name>
|
588 |
+
<type>Product</type>
|
589 |
+
<description>'.$varDescription.'</description>
|
590 |
+
<unit_cost>'.trim(number_format($arrData[$i]['base_price'], 2, '.', '')).'</unit_cost>
|
591 |
+
<quantity>'.trim(number_format($arrData[$i]['qty'], 2, '.', '')).'</quantity>
|
592 |
+
<discount>'.trim(number_format($arrData[$i]['base_discount_amount'], 2, '.', '')).'</discount>
|
593 |
+
<discount_type>Fixed</discount_type>';
|
594 |
+
if($arrData[$i]['tax_percent'] > 0)
|
595 |
+
{
|
596 |
+
$createInvoiceXML .='
|
597 |
+
<tax1_name>Tax-1</tax1_name>
|
598 |
+
<tax1_percent>'.trim(number_format($arrData[$i]['tax_percent'], 2, '.', '')).'</tax1_percent>';
|
599 |
+
}
|
600 |
+
$createInvoiceXML .='
|
601 |
+
</item>';
|
602 |
+
}
|
603 |
+
}
|
604 |
+
$createInvoiceXML .= '</items>';
|
605 |
+
if($rowOne['shipping_amount'] > 0)
|
606 |
+
{
|
607 |
+
$createInvoiceXML .= '
|
608 |
+
<additional_charges>
|
609 |
+
<additional_charge>
|
610 |
+
<name>'.trim($rowOne['shipping_description']).'</name>
|
611 |
+
<type>Fixed</type>
|
612 |
+
<amount>'.trim($rowOne['shipping_amount']).'</amount>
|
613 |
+
</additional_charge>
|
614 |
+
</additional_charges>';
|
615 |
+
}
|
616 |
+
$createInvoiceXML .= '</request>';
|
617 |
+
$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
|
618 |
+
|
619 |
+
// GETTING SEND MAIL SETTING
|
620 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
621 |
+
$varPath = 'invoice_options/invoice/send_mail';
|
622 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
623 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
624 |
+
$varSendMailFlag = $rowTwo['value'];
|
625 |
+
|
626 |
+
if($varSendMailFlag)
|
627 |
+
{
|
628 |
+
$xml = stripslashes($curlInvoiveResult);
|
629 |
+
$objXml = new SimpleXMLElement($xml);
|
630 |
+
$arrParamList = $this->objectsIntoArray($objXml);
|
631 |
+
|
632 |
+
if($arrParamList['@attributes']['status'] == '200')
|
633 |
+
{
|
634 |
+
$varInvoiceID = $arrParamList['invoice_id'];
|
635 |
+
|
636 |
+
$varSendInvoiceXml = '<?xml version="1.0" encoding="utf-8"?>
|
637 |
+
<request method="sendInvoiceMail">
|
638 |
+
<invoice_id>'.$varInvoiceID.'</invoice_id>
|
639 |
+
</request>';
|
640 |
+
$curlInvoiceSendResult = $this->sendCurlRequest($varSendInvoiceXml);
|
641 |
+
|
642 |
+
}
|
643 |
+
}
|
644 |
+
}
|
645 |
+
}
|
646 |
+
}
|
647 |
+
public function sendCurlRequest($xml)
|
648 |
+
{
|
649 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
650 |
+
// GETTING API TOKEN
|
651 |
+
$varPath = 'invoice_options/invoice/api_token';
|
652 |
+
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
653 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
654 |
+
$token = $rowTwo['value'];
|
655 |
+
|
656 |
+
// GETTING API URL
|
657 |
+
$varURLPath = 'invoice_options/invoice/api_url';
|
658 |
+
$resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
|
659 |
+
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
660 |
+
$apiURL = $rowURL['value'];
|
661 |
+
|
662 |
+
$ch = curl_init($apiURL);
|
663 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
664 |
+
curl_setopt($ch, CURLOPT_USERPWD, $token.':123');
|
665 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml_request='.$xml);
|
666 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
667 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
668 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
669 |
+
curl_setopt($ch, CURLOPT_USERAGENT, "Invoicera API tester 1.0");
|
670 |
+
$curlClientResult = curl_exec($ch);
|
671 |
+
curl_close ($ch);
|
672 |
+
return $curlClientResult;
|
673 |
+
}
|
674 |
+
|
675 |
+
public function objectsIntoArray($arrObjData, $arrSkipIndices = array())
|
676 |
+
{
|
677 |
+
$arrData = array();
|
678 |
+
|
679 |
+
// if input is object, convert into array
|
680 |
+
if (is_object($arrObjData)) {
|
681 |
+
$arrObjData = get_object_vars($arrObjData);
|
682 |
+
}
|
683 |
+
|
684 |
+
if (is_array($arrObjData)) {
|
685 |
+
foreach ($arrObjData as $index => $value) {
|
686 |
+
if (is_object($value) || is_array($value)) {
|
687 |
+
$value = $this->objectsIntoArray($value, $arrSkipIndices); // recursive call
|
688 |
+
}
|
689 |
+
if (in_array($index, $arrSkipIndices)) {
|
690 |
+
continue;
|
691 |
+
}
|
692 |
+
$arrData[$index] = $value;
|
693 |
+
}
|
694 |
+
}
|
695 |
+
return $arrData;
|
696 |
+
}
|
697 |
+
|
698 |
+
public function notify_to_admin($name, $email, $msg)
|
699 |
+
{
|
700 |
+
$varSubject = 'Invoicera Notification';
|
701 |
+
|
702 |
+
Mage::log($msg);
|
703 |
+
|
704 |
+
$mail = Mage::getModel('core/email');
|
705 |
+
$mail->setToName($name);
|
706 |
+
$mail->setToEmail($email);
|
707 |
+
$mail->setBody($msg);
|
708 |
+
$mail->setSubject($varSubject);
|
709 |
+
$mail->setFromEmail("support@invoicera.com");
|
710 |
+
$mail->setFromName("Invoicera Support");
|
711 |
+
$mail->setType('text');
|
712 |
+
$mail->send();
|
713 |
+
}
|
714 |
+
|
715 |
+
}
|
716 |
+
?>
|
app/code/community/Invoicera/Ajax/etc/config.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Invoicera_Ajax>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Invoicera_Ajax>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<ajax>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Invoicera_Ajax</module>
|
14 |
+
<frontName>ajax</frontName>
|
15 |
+
</args>
|
16 |
+
</ajax>
|
17 |
+
</routers>
|
18 |
+
</frontend>
|
19 |
+
</config>
|
20 |
+
|
app/code/community/Invoicera/Invoice/Block/Sales/Order/Grid.php
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Invoicera_Invoice_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('sales_order_grid');
|
8 |
+
$this->setUseAjax(true);
|
9 |
+
$this->setDefaultSort('created_at');
|
10 |
+
$this->setDefaultDir('DESC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Retrieve collection class
|
16 |
+
*
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getCollectionClass()
|
20 |
+
{
|
21 |
+
return 'sales/order_grid_collection';
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function _prepareCollection()
|
25 |
+
{
|
26 |
+
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
27 |
+
$this->setCollection($collection);
|
28 |
+
return parent::_prepareCollection();
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _prepareColumns()
|
32 |
+
{
|
33 |
+
|
34 |
+
$this->addColumn('real_order_id', array(
|
35 |
+
'header'=> Mage::helper('sales')->__('Order #'),
|
36 |
+
'width' => '80px',
|
37 |
+
'type' => 'text',
|
38 |
+
'index' => 'increment_id',
|
39 |
+
));
|
40 |
+
|
41 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
42 |
+
$this->addColumn('store_id', array(
|
43 |
+
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
|
44 |
+
'index' => 'store_id',
|
45 |
+
'type' => 'store',
|
46 |
+
'store_view'=> true,
|
47 |
+
'display_deleted' => true,
|
48 |
+
));
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->addColumn('created_at', array(
|
52 |
+
'header' => Mage::helper('sales')->__('Purchased On'),
|
53 |
+
'index' => 'created_at',
|
54 |
+
'type' => 'datetime',
|
55 |
+
'width' => '100px',
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->addColumn('billing_name', array(
|
59 |
+
'header' => Mage::helper('sales')->__('Bill to Name'),
|
60 |
+
'index' => 'billing_name',
|
61 |
+
));
|
62 |
+
|
63 |
+
$this->addColumn('shipping_name', array(
|
64 |
+
'header' => Mage::helper('sales')->__('Ship to Name'),
|
65 |
+
'index' => 'shipping_name',
|
66 |
+
));
|
67 |
+
|
68 |
+
$this->addColumn('base_grand_total', array(
|
69 |
+
'header' => Mage::helper('sales')->__('G.T. (Base)'),
|
70 |
+
'index' => 'base_grand_total',
|
71 |
+
'type' => 'currency',
|
72 |
+
'currency' => 'base_currency_code',
|
73 |
+
));
|
74 |
+
|
75 |
+
$this->addColumn('grand_total', array(
|
76 |
+
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
|
77 |
+
'index' => 'grand_total',
|
78 |
+
'type' => 'currency',
|
79 |
+
'currency' => 'order_currency_code',
|
80 |
+
));
|
81 |
+
|
82 |
+
$this->addColumn('status', array(
|
83 |
+
'header' => Mage::helper('sales')->__('Status'),
|
84 |
+
'index' => 'status',
|
85 |
+
'type' => 'options',
|
86 |
+
'width' => '70px',
|
87 |
+
'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
|
88 |
+
));
|
89 |
+
|
90 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
|
91 |
+
$this->addColumn('action',
|
92 |
+
array(
|
93 |
+
'header' => Mage::helper('sales')->__('Action'),
|
94 |
+
'width' => '50px',
|
95 |
+
'type' => 'action',
|
96 |
+
'getter' => 'getId',
|
97 |
+
'actions' => array(
|
98 |
+
array(
|
99 |
+
'caption' => Mage::helper('sales')->__('View'),
|
100 |
+
'url' => array('base'=>'*/sales_order/view'),
|
101 |
+
'field' => 'order_id'
|
102 |
+
)
|
103 |
+
),
|
104 |
+
'filter' => false,
|
105 |
+
'sortable' => false,
|
106 |
+
'index' => 'stores',
|
107 |
+
'is_system' => true,
|
108 |
+
));
|
109 |
+
}
|
110 |
+
$this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
|
111 |
+
|
112 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
|
113 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
|
114 |
+
|
115 |
+
return parent::_prepareColumns();
|
116 |
+
}
|
117 |
+
|
118 |
+
protected function _prepareMassaction()
|
119 |
+
{
|
120 |
+
$this->setMassactionIdField('entity_id');
|
121 |
+
$this->getMassactionBlock()->setFormFieldName('order_ids');
|
122 |
+
$this->getMassactionBlock()->setUseSelectAll(false);
|
123 |
+
|
124 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
125 |
+
$this->getMassactionBlock()->addItem('cancel_order', array(
|
126 |
+
'label'=> Mage::helper('sales')->__('Cancel'),
|
127 |
+
'url' => $this->getUrl('*/sales_order/massCancel'),
|
128 |
+
));
|
129 |
+
}
|
130 |
+
|
131 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
|
132 |
+
$this->getMassactionBlock()->addItem('hold_order', array(
|
133 |
+
'label'=> Mage::helper('sales')->__('Hold'),
|
134 |
+
'url' => $this->getUrl('*/sales_order/massHold'),
|
135 |
+
));
|
136 |
+
}
|
137 |
+
|
138 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
|
139 |
+
$this->getMassactionBlock()->addItem('unhold_order', array(
|
140 |
+
'label'=> Mage::helper('sales')->__('Unhold'),
|
141 |
+
'url' => $this->getUrl('*/sales_order/massUnhold'),
|
142 |
+
));
|
143 |
+
}
|
144 |
+
|
145 |
+
$this->getMassactionBlock()->addItem('pdfinvoices_order', array(
|
146 |
+
'label'=> Mage::helper('sales')->__('Print Invoices'),
|
147 |
+
'url' => $this->getUrl('*/sales_order/pdfinvoices'),
|
148 |
+
));
|
149 |
+
|
150 |
+
$this->getMassactionBlock()->addItem('pdfshipments_order', array(
|
151 |
+
'label'=> Mage::helper('sales')->__('Print Packingslips'),
|
152 |
+
'url' => $this->getUrl('*/sales_order/pdfshipments'),
|
153 |
+
));
|
154 |
+
|
155 |
+
$this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
|
156 |
+
'label'=> Mage::helper('sales')->__('Print Credit Memos'),
|
157 |
+
'url' => $this->getUrl('*/sales_order/pdfcreditmemos'),
|
158 |
+
));
|
159 |
+
|
160 |
+
$this->getMassactionBlock()->addItem('pdfdocs_order', array(
|
161 |
+
'label'=> Mage::helper('sales')->__('Print All'),
|
162 |
+
'url' => $this->getUrl('*/sales_order/pdfdocs'),
|
163 |
+
));
|
164 |
+
$this->getMassactionBlock()->addItem('export_to_invoicera', array(
|
165 |
+
'label'=> Mage::helper('sales')->__('Export to Invoicera'),
|
166 |
+
'url' => $this->getUrl('ajax/san/exportOrder'),
|
167 |
+
));
|
168 |
+
|
169 |
+
return $this;
|
170 |
+
}
|
171 |
+
}
|
app/code/community/Invoicera/Invoice/etc/config.xml
CHANGED
@@ -5,7 +5,14 @@
|
|
5 |
<invoice>
|
6 |
<class>Invoicera_Invoice_Helper</class>
|
7 |
</invoice>
|
8 |
-
</helpers>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</global>
|
10 |
<frontend>
|
11 |
<routers>
|
5 |
<invoice>
|
6 |
<class>Invoicera_Invoice_Helper</class>
|
7 |
</invoice>
|
8 |
+
</helpers>
|
9 |
+
<blocks>
|
10 |
+
<adminhtml>
|
11 |
+
<rewrite>
|
12 |
+
<sales_order_grid>Invoicera_Invoice_Block_Sales_Order_Grid</sales_order_grid>
|
13 |
+
</rewrite>
|
14 |
+
</adminhtml>
|
15 |
+
</blocks>
|
16 |
</global>
|
17 |
<frontend>
|
18 |
<routers>
|
app/etc/modules/Invoicera_Invoice.xml
CHANGED
@@ -1,29 +1,13 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Magento
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Phoenix
|
17 |
-
* @package Phoenix_Moneybookers
|
18 |
-
* @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
<config>
|
23 |
<modules>
|
24 |
<Invoicera_Invoice>
|
25 |
<active>true</active>
|
26 |
<codePool>community</codePool>
|
27 |
</Invoicera_Invoice>
|
|
|
|
|
|
|
|
|
28 |
</modules>
|
29 |
</config>
|
1 |
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Invoicera_Invoice>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
</Invoicera_Invoice>
|
8 |
+
<Invoicera_Ajax>
|
9 |
+
<active>true</active>
|
10 |
+
<codePool>community</codePool>
|
11 |
+
</Invoicera_Ajax>
|
12 |
</modules>
|
13 |
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Invoicera_Order_and_Invoice_Connector</name>
|
4 |
-
<version>1.2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -15,9 +15,9 @@ Your web server needs to have PHP’s cURL extension installed. If you are
|
|
15 |

|
16 |
You need to have Magento version 1.4.2.0 or higher</notes>
|
17 |
<authors><author><name>Sandeep Kumar</name><user>auto-converted</user><email>sandeep.kumar@mail.vinove.com</email></author></authors>
|
18 |
-
<date>2011-
|
19 |
-
<time>
|
20 |
-
<contents><target name="magecommunity"><dir name="Invoicera"><dir name="Invoice"><dir name="Helper"><file name="Data.php" hash="8bf2a13525f713b44269265b6c58231b"/></dir><dir name="controllers"><file name="OnepageController.php" hash="26049123934c70258003a878790c78e4"/></dir><dir name="etc"><file name="config.xml" hash="
|
21 |
<compatible/>
|
22 |
<dependencies/>
|
23 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Invoicera_Order_and_Invoice_Connector</name>
|
4 |
+
<version>1.2.7</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
15 |

|
16 |
You need to have Magento version 1.4.2.0 or higher</notes>
|
17 |
<authors><author><name>Sandeep Kumar</name><user>auto-converted</user><email>sandeep.kumar@mail.vinove.com</email></author></authors>
|
18 |
+
<date>2011-08-10</date>
|
19 |
+
<time>04:52:27</time>
|
20 |
+
<contents><target name="magecommunity"><dir name="Invoicera"><dir name="Ajax"><dir name="controllers"><file name="SanController.php" hash="e4342dc593f0c24c1d0a1d64085ee300"/></dir><dir name="etc"><file name="config.xml" hash="b5b99d6167dafb9b6d59fed8741e872e"/></dir></dir><dir name="Invoice"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="739048d50d42416805fd578142afc76c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8bf2a13525f713b44269265b6c58231b"/></dir><dir name="controllers"><file name="OnepageController.php" hash="26049123934c70258003a878790c78e4"/></dir><dir name="etc"><file name="config.xml" hash="dab3e3386a0ed5eba15455e53412cae0"/><file name="system.xml" hash="41f589f270aeb546bfb77f887b8aca7d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Invoicera_Invoice.xml" hash="10855dee7459f335cdb46f0d84eedd60"/></dir></target></contents>
|
21 |
<compatible/>
|
22 |
<dependencies/>
|
23 |
</package>
|