Version Notes
Fixed issue with multiple products same SKU, different custom option
Download this release
Release Info
| Developer | Casper Mekel |
| Extension | Qinvoice_Connect |
| Version | 2.1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.3 to 2.1.1
- app/code/community/Qinvoice/CHANGELOG +10 -0
- app/code/community/Qinvoice/Connect/Block/Adminhtml/System/Config/Form/Field/Webshopsecret.php +16 -0
- app/code/community/Qinvoice/Connect/Model/Order/Observer.Boerdereike.php +2 -0
- app/code/community/Qinvoice/Connect/Model/Order/Observer.max4home.php +724 -0
- app/code/community/Qinvoice/Connect/Model/Order/Observer.php +183 -108
- app/code/community/Qinvoice/Connect/Model/Rewrite/Observer.php +748 -0
- app/code/community/Qinvoice/Connect/Model/Rewrite/Order.php +73 -0
- app/code/community/Qinvoice/Connect/Model/Source/Trigger.php +2 -2
- app/code/community/Qinvoice/Connect/Module/Block/Webshop_Secret_Renderer.php +10 -0
- app/code/community/Qinvoice/Connect/Module/Webshop_Secret_Renderer.php +10 -0
- app/code/community/Qinvoice/Connect/etc/config.xml +35 -1
- app/code/community/Qinvoice/Connect/etc/system.xml +12 -2
- app/code/community/Qinvoice/Invoice/Order/Observer.php +0 -440
- package.xml +5 -5
app/code/community/Qinvoice/CHANGELOG
CHANGED
|
@@ -1,5 +1,15 @@
|
|
| 1 |
CHANGELOG
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
v1.1.3 - 2015/02/26
|
| 4 |
- Fixed issue with multiple products same SKU, different custom option
|
| 5 |
|
| 1 |
CHANGELOG
|
| 2 |
|
| 3 |
+
v2.0.1
|
| 4 |
+
- Added 'On complete' trigger
|
| 5 |
+
- Added
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
v1.1.4 - 2015/05/05
|
| 9 |
+
- Updated for use with API v1.2 (backwards compatible with v1.1)
|
| 10 |
+
- Added functionality to store resource ID after creation
|
| 11 |
+
- Added functionality to update invoice with payment
|
| 12 |
+
|
| 13 |
v1.1.3 - 2015/02/26
|
| 14 |
- Fixed issue with multiple products same SKU, different custom option
|
| 15 |
|
app/code/community/Qinvoice/Connect/Block/Adminhtml/System/Config/Form/Field/Webshopsecret.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Qinvoice_Connect_Block_Adminhtml_System_Config_Form_Field_Webshopsecret extends Mage_Adminhtml_Block_System_Config_Form_Field{
|
| 4 |
+
protected function _getElementHtml($element) {
|
| 5 |
+
if ($element->getValue() == '' || 1==1) {
|
| 6 |
+
$store = Mage::app()->getStore();
|
| 7 |
+
$value = md5( $store->getName() . $store->getHomeUrl() );
|
| 8 |
+
$element->setValue( $value );
|
| 9 |
+
Mage::getConfig()->saveConfig('invoice_options/invoice/webshop_secret', $value, 'default');
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
$element->setDisabled('disabled');
|
| 13 |
+
return parent::_getElementHtml($element);
|
| 14 |
+
}
|
| 15 |
+
}
|
| 16 |
+
?>
|
app/code/community/Qinvoice/Connect/Model/Order/Observer.Boerdereike.php
CHANGED
|
@@ -224,6 +224,8 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 224 |
$d_date->setDate($delivery_date[0], $delivery_date[1], $delivery_date[2]);
|
| 225 |
$delivery_date = $d_date->format('l d-m-Y');
|
| 226 |
|
|
|
|
|
|
|
| 227 |
$invoice_remark = $rowRemark['value'];
|
| 228 |
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 229 |
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
| 224 |
$d_date->setDate($delivery_date[0], $delivery_date[1], $delivery_date[2]);
|
| 225 |
$delivery_date = $d_date->format('l d-m-Y');
|
| 226 |
|
| 227 |
+
$invoice->addTag($delivery_date);
|
| 228 |
+
|
| 229 |
$invoice_remark = $rowRemark['value'];
|
| 230 |
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 231 |
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
app/code/community/Qinvoice/Connect/Model/Order/Observer.max4home.php
ADDED
|
@@ -0,0 +1,724 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
//class NameSpaceName_ModuleName_Model_ObserverDir_Observer
|
| 3 |
+
class Qinvoice_Connect_Model_Order_Observer
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
//parent::__construct();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function sendOnComplete($observer){
|
| 11 |
+
return false;
|
| 12 |
+
$order = $observer->getEvent()->getOrder();
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
// GETTING TRIGGER SETTING
|
| 17 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 18 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 19 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 20 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 21 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 22 |
+
$varOnOrder = $rowTwo['value'];
|
| 23 |
+
|
| 24 |
+
if($varOnOrder == 'complete' && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
|
| 25 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 26 |
+
}else{
|
| 27 |
+
return true;
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public function sendOnShip($observer){
|
| 32 |
+
return false;
|
| 33 |
+
$shipment = $observer->getEvent()->getShipment();
|
| 34 |
+
|
| 35 |
+
$order = $shipment->getOrder();
|
| 36 |
+
|
| 37 |
+
// GETTING TRIGGER SETTING
|
| 38 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 39 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 40 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 41 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 42 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 43 |
+
$varOnOrder = $rowTwo['value'];
|
| 44 |
+
|
| 45 |
+
if($varOnOrder == 'ship'){
|
| 46 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 47 |
+
}else{
|
| 48 |
+
return true;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function sendOnOrder($observer){
|
| 53 |
+
$order = $observer->getEvent()->getOrder();
|
| 54 |
+
|
| 55 |
+
// GETTING TRIGGER SETTING
|
| 56 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 57 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 58 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 59 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 60 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 61 |
+
$varOnOrder = $rowTwo['value'];
|
| 62 |
+
|
| 63 |
+
if($varOnOrder == 'order'){
|
| 64 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 65 |
+
}else{
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
public function sendOnPayment($observer){
|
| 71 |
+
// Gets called even when other payment method is choosen.
|
| 72 |
+
|
| 73 |
+
$order_ids = $observer->getEvent()->getOrderIds();
|
| 74 |
+
$order = $observer->getEvent()->getOrder();
|
| 75 |
+
|
| 76 |
+
// GETTING TRIGGER SETTING
|
| 77 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 78 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 79 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 80 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 81 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 82 |
+
$varOnOrder = $rowTwo['value'];
|
| 83 |
+
|
| 84 |
+
if($varOnOrder == 'payment'){
|
| 85 |
+
$this->createInvoiceForQinvoice($order_ids[0], true);
|
| 86 |
+
}else{
|
| 87 |
+
return true;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
public function createInvoiceForQinvoice($varOrderID,$ifPaid = false)
|
| 91 |
+
{
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
$paid = 0;
|
| 95 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 96 |
+
// GETTING ORDER ID
|
| 97 |
+
//$resultOne = $db->query("SELECT max(entity_id) as LastOrderID FROM sales_flat_order");
|
| 98 |
+
//$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
| 99 |
+
|
| 100 |
+
//$varOrderID = $rowOne['LastOrderID'];
|
| 101 |
+
|
| 102 |
+
$varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
|
| 103 |
+
// GETTING ORDER STATUS
|
| 104 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 105 |
+
$resultOne = $db->query("SELECT entity_id, status, customer_email, coupon_code, base_currency_code, shipping_description, shipping_amount, shipping_tax_amount, increment_id, grand_total, total_paid, billing_address_id, shipping_address_id, customer_taxvat, base_subtotal FROM {$prefix}sales_flat_order WHERE entity_id=".$varOrderID);
|
| 106 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete' || $rowOne['total_paid'] == $rowOne['grand_total'])
|
| 110 |
+
{
|
| 111 |
+
$varStatus = 'Paid';
|
| 112 |
+
// GETTING API URL
|
| 113 |
+
$varURLPath = 'invoice_options/invoice/paid_remark';
|
| 114 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 115 |
+
$resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 116 |
+
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 117 |
+
$paid_remark = $rowURL['value'];
|
| 118 |
+
$paid = 1;
|
| 119 |
+
}
|
| 120 |
+
else
|
| 121 |
+
{
|
| 122 |
+
if($ifPaid == true){
|
| 123 |
+
// cancel if invoice has to be paid
|
| 124 |
+
return;
|
| 125 |
+
}
|
| 126 |
+
$paid_remark = '';
|
| 127 |
+
$varStatus = 'Sent';
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 131 |
+
$result = $db->query("SELECT item_id, product_type, product_id, product_options, order_id, sku, name, description, qty_ordered, base_price, original_price, tax_percent, tax_amount, base_discount_amount FROM {$prefix}sales_flat_order_item WHERE order_id=".$varOrderID." AND parent_item_id IS NULL HAVING (order_id > 0) ORDER BY item_id desc");
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
if(!$result) {
|
| 135 |
+
//return false;
|
| 136 |
+
}
|
| 137 |
+
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
| 138 |
+
$arrData[] = $row;
|
| 139 |
+
}
|
| 140 |
+
if(!$arrData) {
|
| 141 |
+
//return false;
|
| 142 |
+
}
|
| 143 |
+
//$comment = '';
|
| 144 |
+
//$comment = $data['comment_text'];
|
| 145 |
+
// getting po_number
|
| 146 |
+
$random_number = rand(0, pow(10, 7));
|
| 147 |
+
|
| 148 |
+
// GETTING API USERNAME
|
| 149 |
+
$varPath = 'invoice_options/invoice/api_username';
|
| 150 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 151 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 152 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 153 |
+
$username = $rowTwo['value'];
|
| 154 |
+
|
| 155 |
+
// GETTING API PASSWORD
|
| 156 |
+
$varPath = 'invoice_options/invoice/api_password';
|
| 157 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 158 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 159 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 160 |
+
$password = $rowTwo['value'];
|
| 161 |
+
|
| 162 |
+
// GETTING LAYOUT CODE
|
| 163 |
+
$varPath = 'invoice_options/invoice/layout_code';
|
| 164 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 165 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 166 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 167 |
+
$layout_code = $rowTwo['value'];
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
// GETTING CLIENT DETAILS
|
| 171 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 172 |
+
$resultThree = $db->query("SELECT * FROM {$prefix}sales_flat_order_address WHERE entity_id='".$rowOne['billing_address_id']."'");
|
| 173 |
+
$rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
|
| 174 |
+
|
| 175 |
+
$invoice = new qinvoice($username,$password);
|
| 176 |
+
|
| 177 |
+
$invoice->companyname = $rowThree['company']; // Your customers company name
|
| 178 |
+
$invoice->firstname = $rowThree['firstname']; // Your customers contact name
|
| 179 |
+
$invoice->lastname = $rowThree['lastname']; // Your customers contact name
|
| 180 |
+
$invoice->email = $rowOne['customer_email']; // Your customers emailaddress (invoice will be sent here)
|
| 181 |
+
$invoice->phone = $rowThree['telephone'];
|
| 182 |
+
$invoice->address = $rowThree['street']; // Self-explanatory
|
| 183 |
+
$invoice->zipcode = $rowThree['postcode']; // Self-explanatory
|
| 184 |
+
$invoice->city = $rowThree['city']; // Self-explanatory
|
| 185 |
+
$invoice->country = $rowThree['country_id']; // 2 character country code: NL for Netherlands, DE for Germany etc
|
| 186 |
+
$invoice->vatnumber = strlen($rowThree['vat_id']) > 3 ? $rowThree['vat_id'] : $rowOne['customer_taxvat'];
|
| 187 |
+
|
| 188 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 189 |
+
$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']."'");
|
| 190 |
+
$rowFour = $resultFour->fetch(PDO::FETCH_ASSOC);
|
| 191 |
+
|
| 192 |
+
$invoice->delivery_companyname = $rowFour['company']; // Your customers company name
|
| 193 |
+
$invoice->delivery_firstname = $rowFour['firstname']; // Your customers contact name
|
| 194 |
+
$invoice->delivery_lastname = $rowFour['lastname']; // Your customers contact name
|
| 195 |
+
$invoice->delivery_address = $rowFour['street']; // Self-explanatory
|
| 196 |
+
$invoice->delivery_zipcode = $rowFour['postcode']; // Self-explanatory
|
| 197 |
+
$invoice->delivery_city = $rowFour['city']; // Self-explanatory
|
| 198 |
+
$invoice->delivery_country = $rowFour['country_id'];
|
| 199 |
+
$invoice->delivery_phone = $rowFour['telephone'];
|
| 200 |
+
$invoice->delivery_email = $rowFour['email'];
|
| 201 |
+
|
| 202 |
+
$invoice->vat = ''; // Self-explanatory
|
| 203 |
+
$invoice->paid = $paid;
|
| 204 |
+
|
| 205 |
+
$varActionPath = 'invoice_options/invoice/save_relation';
|
| 206 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 207 |
+
|
| 208 |
+
$resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
|
| 209 |
+
$rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
|
| 210 |
+
$save_relation = $rowAction['value'];
|
| 211 |
+
|
| 212 |
+
$invoice->saverelation = $save_relation;
|
| 213 |
+
|
| 214 |
+
$varRemarkPath = 'invoice_options/invoice/invoice_remark';
|
| 215 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 216 |
+
$resultRemark = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varRemarkPath."'");
|
| 217 |
+
$rowRemark = $resultRemark->fetch(PDO::FETCH_ASSOC);
|
| 218 |
+
|
| 219 |
+
$order_id = $rowOne['increment_id'];
|
| 220 |
+
$invoice_remark = $rowRemark['value'];
|
| 221 |
+
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 222 |
+
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
| 223 |
+
|
| 224 |
+
$order2 = Mage::getModel('sales/order')->load($order_id);
|
| 225 |
+
|
| 226 |
+
$checkout = Mage::getSingleton('checkout/type_onepage')->getCheckout();
|
| 227 |
+
$dd_data = $checkout->getAmastyDeliveryDate();
|
| 228 |
+
|
| 229 |
+
if(method_exists($order2, 'deliverydate') ){
|
| 230 |
+
|
| 231 |
+
$dd_comment = $dd_data['comment'];
|
| 232 |
+
$invoice_remark = str_replace('{dd_comment}',$dd_comment,$invoice_remark);
|
| 233 |
+
|
| 234 |
+
$dd_date = $dd_data['date'];
|
| 235 |
+
$invoice_remark = str_replace('{dd_date}',$dd_date,$invoice_remark);
|
| 236 |
+
|
| 237 |
+
$dd_time = $dd_data['time'];
|
| 238 |
+
$invoice_remark = str_replace('{dd_time}',$dd_time,$invoice_remark);
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
//$dd = explode("-",$order->deliverydate('date'));
|
| 242 |
+
//$invoice->delivery_date = $order2->deliverydate('date'); //$dd[2].'-'. $dd[1].'-'. $dd[0];
|
| 243 |
+
$invoice->delivery_date = $dd_data['date'];
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
$invoice->addTag($dd_data['date']);
|
| 247 |
+
if(strlen($dd_time) > 6){
|
| 248 |
+
$invoice->addTag($dd_data['time']);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
// $payment_method_code = $order2->getPayment()->getMethodInstance()->getCode();
|
| 252 |
+
// $invoice->addTag($payment_method_code);
|
| 253 |
+
// $invoice->addTag($order2->getShippingDescription());
|
| 254 |
+
|
| 255 |
+
//$payment = $order2->getPayment();
|
| 256 |
+
//$invoice->addTag($payment->getMethod());
|
| 257 |
+
$invoice->addTag(Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod());
|
| 258 |
+
$invoice->addTag(Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getTitle());
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
//$invoice->addTag(Mage::getSingleton('checkout/session')->getQuote()->getInvoiceFee());
|
| 262 |
+
|
| 263 |
+
|
| 264 |
+
$invoice->remark = $invoice_remark ."\n". $paid_remark;
|
| 265 |
+
|
| 266 |
+
$varActionPath = 'invoice_options/invoice/invoice_action';
|
| 267 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 268 |
+
$resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
|
| 269 |
+
$rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
|
| 270 |
+
$invoice_action = $rowAction['value'];
|
| 271 |
+
|
| 272 |
+
$varLayoutPath = 'invoice_options/invoice/layout_code';
|
| 273 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 274 |
+
$resultLayout = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varLayoutPath."'");
|
| 275 |
+
$rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
|
| 276 |
+
$invoice_layout = $rowLayout['value'];
|
| 277 |
+
|
| 278 |
+
$varCalculationmethodPath = 'invoice_options/invoice/calculation_method';
|
| 279 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 280 |
+
$resultCalculationmethod = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varCalculationmethodPath."'");
|
| 281 |
+
$rowCalculationmethod = $resultCalculationmethod->fetch(PDO::FETCH_ASSOC);
|
| 282 |
+
$invoice_calculationmethod = $rowCalculationmethod['value'];
|
| 283 |
+
|
| 284 |
+
$invoice->calculation_method = $invoice_calculationmethod;
|
| 285 |
+
|
| 286 |
+
$invoice_layout_s = @unserialize($invoice_layout);
|
| 287 |
+
if ($invoice_layout_s !== false) {
|
| 288 |
+
// serialized
|
| 289 |
+
$invoice_layout = @unserialize($invoice_layout);
|
| 290 |
+
if(isset($invoice_layout[$rowFour['country_id']])){
|
| 291 |
+
$invoice_layout = @$invoice_layout[$rowFour['country_id']];
|
| 292 |
+
}else{
|
| 293 |
+
$invoice_layout = @$invoice_layout['default'];
|
| 294 |
+
}
|
| 295 |
+
} else {
|
| 296 |
+
// not serialized
|
| 297 |
+
$invoice_layout = $invoice_layout;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
$invoice->setLayout($invoice_layout);
|
| 301 |
+
|
| 302 |
+
$varTagPath = 'invoice_options/invoice/invoice_tag';
|
| 303 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 304 |
+
$resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 305 |
+
$rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 306 |
+
$invoice_tag = $rowTag['value'];
|
| 307 |
+
|
| 308 |
+
$varTagPath = 'invoice_options/invoice/product_attributes';
|
| 309 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 310 |
+
$resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 311 |
+
$pa_array = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
$invoice->action = $invoice_action;
|
| 315 |
+
|
| 316 |
+
// OPTIONAL: Add tags
|
| 317 |
+
$invoice->addTag($rowOne['increment_id']);
|
| 318 |
+
$invoice->addTag($invoice_tag);
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($varOrderID);
|
| 323 |
+
$store_id = $order->getStoreId();
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
| 327 |
+
$attributeArray = array();
|
| 328 |
+
|
| 329 |
+
foreach($attributes as $attribute){
|
| 330 |
+
$attributeArray[$attribute->getData('attribute_code')] = $attribute->getData('frontend_label');
|
| 331 |
+
// $attributeArray[] = array(
|
| 332 |
+
// 'label' => $attribute->getData('frontend_label'),
|
| 333 |
+
// 'value' => $attribute->getData('attribute_code')
|
| 334 |
+
// );
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
//print_r($order);
|
| 339 |
+
|
| 340 |
+
for($i=0;$i<count($arrData);$i++)
|
| 341 |
+
{
|
| 342 |
+
$category = '';
|
| 343 |
+
$_productId = $arrData[$i]['product_id'];
|
| 344 |
+
$_product = Mage::getModel('catalog/product')->load($_productId);
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
$category = $_product->getData('qinvoice_category');
|
| 348 |
+
$productcode = $_product->getData('qinvoice_productcode');
|
| 349 |
+
|
| 350 |
+
$arrItemOptions = unserialize($arrData[$i]['product_options']);
|
| 351 |
+
|
| 352 |
+
$varDescription = '';
|
| 353 |
+
|
| 354 |
+
//print_r();
|
| 355 |
+
|
| 356 |
+
$product_attributes = explode(",",$pa_array['value']);
|
| 357 |
+
foreach($product_attributes as $pa){
|
| 358 |
+
if(isset($_product[$pa]))
|
| 359 |
+
{
|
| 360 |
+
$varDescription .= "\n". $attributeArray[$pa] .': '. $_product[$pa];
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
if(@$arrItemOptions['options'])
|
| 366 |
+
{
|
| 367 |
+
for($k=0; $k <count($arrItemOptions['options']); $k++)
|
| 368 |
+
{
|
| 369 |
+
$varDescription .= "\n".$arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
|
| 370 |
+
}
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
if(@$arrItemOptions['attributes_info'])
|
| 374 |
+
{
|
| 375 |
+
for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
|
| 376 |
+
{
|
| 377 |
+
$varDescription .= "\n".$arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
if(@$arrItemOptions['bundle_options'])
|
| 382 |
+
{
|
| 383 |
+
foreach($arrItemOptions['bundle_options'] as $option){
|
| 384 |
+
foreach($option['value'] as $value){
|
| 385 |
+
$varDescription .= "\n".'['. $option['label'] .'] '. $value['qty'] .' x '. $value['title'];
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
$params = array(
|
| 396 |
+
'code' => $productcode,
|
| 397 |
+
'description' => "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']) . $varDescription,
|
| 398 |
+
'price' => $arrData[$i]['base_price']*100,
|
| 399 |
+
//'price_incl' => ((($arrData[$i]['base_price']*$arrData[$i]['qty_ordered'])+$arrData[$i]['tax_amount'])/$arrData[$i]['qty_ordered'])*100,
|
| 400 |
+
'price_incl' => $arrData[$i]['original_price']*100,
|
| 401 |
+
'price_vat' => ($arrData[$i]['tax_amount']/$arrData[$i]['qty_ordered'])*100,
|
| 402 |
+
'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
|
| 403 |
+
'discount' => 0,
|
| 404 |
+
'quantity' => $arrData[$i]['qty_ordered']*100,
|
| 405 |
+
'categories' => $category
|
| 406 |
+
);
|
| 407 |
+
|
| 408 |
+
$invoice->addItem($params);
|
| 409 |
+
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
if($rowOne['shipping_amount'] > 0)
|
| 413 |
+
{
|
| 414 |
+
$params = array(
|
| 415 |
+
'code' => 'SHPMNT',
|
| 416 |
+
'description' => trim($rowOne['shipping_description']),
|
| 417 |
+
'price' => $rowOne['shipping_amount']*100,
|
| 418 |
+
'price_incl' => $rowOne['shipping_incl_tax']*100,
|
| 419 |
+
'price_vat' => $rowOne['shipping_tax_amount']*100,
|
| 420 |
+
'vatpercentage' => round(($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100)*100,
|
| 421 |
+
'discount' => 0,
|
| 422 |
+
'quantity' => 100,
|
| 423 |
+
'categories' => 'shipping'
|
| 424 |
+
);
|
| 425 |
+
|
| 426 |
+
$invoice->addItem($params);
|
| 427 |
+
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
// $order = Mage::getModel('sales/order')->loadByIncrementId($varOrderID);
|
| 433 |
+
|
| 434 |
+
// $orderDetails = $order->getData();
|
| 435 |
+
|
| 436 |
+
$couponCode = $rowOne['coupon_code'];
|
| 437 |
+
//echo $couponCode;
|
| 438 |
+
//print_r($order);
|
| 439 |
+
// $couponCode = $orderDetails['coupon_code'];
|
| 440 |
+
|
| 441 |
+
if($couponCode > ''){
|
| 442 |
+
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
|
| 443 |
+
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
|
| 444 |
+
//var_dump($oRule->getData());
|
| 445 |
+
|
| 446 |
+
$ruleData = $oRule->getData();
|
| 447 |
+
|
| 448 |
+
$discount = $ruleData['discount_amount'];
|
| 449 |
+
$params = array(
|
| 450 |
+
'code' => 'DSCNT',
|
| 451 |
+
'description' => $couponCode,
|
| 452 |
+
// 'price' => ($rowOne['base_subtotal'] * ($discount/100))*100,
|
| 453 |
+
// 'price_incl' => ($rowOne['base_subtotal'] * ($discount/100))*100,
|
| 454 |
+
'price' => $discount*100,
|
| 455 |
+
'price_incl' => $discount*100,
|
| 456 |
+
'price_vat' => 0,
|
| 457 |
+
'vatpercentage' => 0,
|
| 458 |
+
'discount' => 0,
|
| 459 |
+
'quantity' => -100,
|
| 460 |
+
'categories' => 'discount'
|
| 461 |
+
);
|
| 462 |
+
|
| 463 |
+
$invoice->addItem($params);
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
$invoice_fee = Mage::getSingleton('checkout/session')->getQuote()->getInvoiceFee();
|
| 467 |
+
if($invoice_fee > 0){
|
| 468 |
+
$price_incl = $invoice_fee*100;
|
| 469 |
+
$price = ($invoice_fee/121)*100;
|
| 470 |
+
|
| 471 |
+
$params = array(
|
| 472 |
+
'code' => 'FEE',
|
| 473 |
+
'description' => 'Betalingstoeslag',
|
| 474 |
+
'price' => $price,
|
| 475 |
+
'price_incl' => $price_incl,
|
| 476 |
+
'price_vat' => $price_incl - $price,
|
| 477 |
+
'vatpercentage' => 2100,
|
| 478 |
+
'discount' => 0,
|
| 479 |
+
'quantity' => 100,
|
| 480 |
+
'categories' => 'fee'
|
| 481 |
+
);
|
| 482 |
+
|
| 483 |
+
$invoice->addItem($params);
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
|
| 487 |
+
// $coupon = Mage::getModel('salesrule/rule');
|
| 488 |
+
// $couponCollection = $coupon->getCollection();
|
| 489 |
+
// foreach($couponCollection as $c){
|
| 490 |
+
// print_r($c);
|
| 491 |
+
// echo 'Code:'.$c->getCode().'--->Discount Amount:'.$c->getDiscountAmount().'<br />';
|
| 492 |
+
|
| 493 |
+
// $params = array(
|
| 494 |
+
// 'code' => 'DSCNT',
|
| 495 |
+
// 'description' => $c->getCode(),
|
| 496 |
+
// 'price' => $rowOne['base_subtotal'] * ($c->getDiscountAmount()/100),
|
| 497 |
+
// 'price_incl' => $rowOne['base_subtotal'] * ($c->getDiscountAmount()/100),
|
| 498 |
+
// 'price_vat' => 0,
|
| 499 |
+
// 'vatpercentage' => 0,
|
| 500 |
+
// 'discount' => 0,
|
| 501 |
+
// 'quantity' => -100,
|
| 502 |
+
// 'categories' => 'discount'
|
| 503 |
+
// );
|
| 504 |
+
|
| 505 |
+
// $invoice->addItem($params);
|
| 506 |
+
|
| 507 |
+
// }
|
| 508 |
+
|
| 509 |
+
$result = $invoice->sendRequest();
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
if($result != 1){
|
| 513 |
+
$this->notify_admin('Qinvoice Connect Error','Could not send invoice for order '. $order_id);
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
return true;
|
| 517 |
+
|
| 518 |
+
|
| 519 |
+
//$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
|
| 520 |
+
}
|
| 521 |
+
public function notify_admin($subject,$msg)
|
| 522 |
+
{
|
| 523 |
+
$varSubject = 'Qinvoice Notification';
|
| 524 |
+
|
| 525 |
+
Mage::log($subject .': '. $msg);
|
| 526 |
+
|
| 527 |
+
$mail = Mage::getModel('core/email');
|
| 528 |
+
$mail->setToName(Mage::getStoreConfig('trans_email/ident_general/name') );
|
| 529 |
+
$mail->setToEmail(Mage::getStoreConfig('trans_email/ident_general/email') );
|
| 530 |
+
$mail->setBody($msg);
|
| 531 |
+
$mail->setSubject($subject);
|
| 532 |
+
$mail->setFromEmail("support@qinvoice.com");
|
| 533 |
+
$mail->setFromName("Qinvoice Support");
|
| 534 |
+
$mail->setType('text');
|
| 535 |
+
$mail->send();
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
class qinvoice{
|
| 544 |
+
|
| 545 |
+
protected $gateway = '';
|
| 546 |
+
private $username;
|
| 547 |
+
private $password;
|
| 548 |
+
|
| 549 |
+
public $companyname;
|
| 550 |
+
public $firstname;
|
| 551 |
+
public $lastname;
|
| 552 |
+
public $email;
|
| 553 |
+
public $address;
|
| 554 |
+
public $zipcode;
|
| 555 |
+
public $city;
|
| 556 |
+
public $country;
|
| 557 |
+
public $delivery_companyname;
|
| 558 |
+
public $delivery_firstname;
|
| 559 |
+
public $delivery_lastname;
|
| 560 |
+
public $delivery_address;
|
| 561 |
+
public $delivery_zipcode;
|
| 562 |
+
public $delivery_city;
|
| 563 |
+
public $delivery_country;
|
| 564 |
+
public $delivery_phone;
|
| 565 |
+
public $delivery_email;
|
| 566 |
+
public $delivery_date;
|
| 567 |
+
public $vatnumber;
|
| 568 |
+
public $remark;
|
| 569 |
+
public $paid;
|
| 570 |
+
public $saverelation = false;
|
| 571 |
+
public $action;
|
| 572 |
+
|
| 573 |
+
public $layout;
|
| 574 |
+
|
| 575 |
+
private $tags = array();
|
| 576 |
+
private $items = array();
|
| 577 |
+
private $files = array();
|
| 578 |
+
private $recurring;
|
| 579 |
+
|
| 580 |
+
function __construct($username, $password){
|
| 581 |
+
$this->username = $username;
|
| 582 |
+
$this->password = $password;
|
| 583 |
+
$this->recurring = 'none';
|
| 584 |
+
|
| 585 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 586 |
+
|
| 587 |
+
// GETTING API URL
|
| 588 |
+
$varURLPath = 'invoice_options/invoice/api_url';
|
| 589 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 590 |
+
$resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 591 |
+
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 592 |
+
$apiURL = $rowURL['value'];
|
| 593 |
+
|
| 594 |
+
$this->gateway = $apiURL;
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
public function addTag($tag){
|
| 598 |
+
$this->tags[] = $tag;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
public function setLayout($code){
|
| 602 |
+
$this->layout = $code;
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
+
public function setRecurring($recurring){
|
| 606 |
+
$this->recurring = strtolower($recurring);
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
public function addItem($params){
|
| 610 |
+
$item['code'] = (isset($params['code']) ? $params['code'] : "");
|
| 611 |
+
$item['description'] = $params['description'];
|
| 612 |
+
$item['price'] = $params['price'];
|
| 613 |
+
$item['price_incl'] = $params['price_incl'];
|
| 614 |
+
$item['price_vat'] = $params['price_vat'];
|
| 615 |
+
$item['vatpercentage'] = $params['vatpercentage'];
|
| 616 |
+
$item['discount'] = $params['discount'];
|
| 617 |
+
$item['quantity'] = $params['quantity'];
|
| 618 |
+
$item['categories'] = $params['categories'];
|
| 619 |
+
$this->items[] = $item;
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
public function addFile($name, $url){
|
| 623 |
+
$this->files[] = array('url' => $url, 'name' => $name);
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
public function sendRequest() {
|
| 627 |
+
$content = "<?xml version='1.0' encoding='UTF-8'?>";
|
| 628 |
+
$content .= $this->buildXML();
|
| 629 |
+
|
| 630 |
+
$headers = array("Content-type: application/atom+xml");
|
| 631 |
+
$ch = curl_init();
|
| 632 |
+
curl_setopt($ch, CURLOPT_URL, $this->gateway );
|
| 633 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 634 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
| 635 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
| 636 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
| 637 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
| 638 |
+
$data = curl_exec($ch);
|
| 639 |
+
if (curl_errno($ch)) {
|
| 640 |
+
print curl_error($ch);
|
| 641 |
+
} else {
|
| 642 |
+
curl_close($ch);
|
| 643 |
+
}
|
| 644 |
+
if($data == 1){
|
| 645 |
+
return true;
|
| 646 |
+
}else{
|
| 647 |
+
return false;
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
private function buildXML(){
|
| 653 |
+
$string = '<request>
|
| 654 |
+
<login mode="newInvoice">
|
| 655 |
+
<username><![CDATA['.$this->username.']]></username>
|
| 656 |
+
<password><![CDATA['.$this->password.']]></password>
|
| 657 |
+
<identifier><![CDATA[Magento_1.1.2]]></identifier>
|
| 658 |
+
</login>
|
| 659 |
+
<invoice>
|
| 660 |
+
<companyname><![CDATA['. $this->companyname .']]></companyname>
|
| 661 |
+
<firstname><![CDATA['. $this->firstname .']]></firstname>
|
| 662 |
+
<lastname><![CDATA['. $this->lastname .']]></lastname>
|
| 663 |
+
<email><![CDATA['. $this->email .']]></email>
|
| 664 |
+
<phone><![CDATA['. $this->phone .']]></phone>
|
| 665 |
+
<address><![CDATA['. $this->address .']]></address>
|
| 666 |
+
<zipcode><![CDATA['. $this->zipcode .']]></zipcode>
|
| 667 |
+
<city><![CDATA['. $this->city .']]></city>
|
| 668 |
+
<country><![CDATA['. $this->country .']]></country>
|
| 669 |
+
|
| 670 |
+
<delivery_companyname><![CDATA['. $this->delivery_companyname .']]></delivery_companyname>
|
| 671 |
+
<delivery_firstname><![CDATA['. $this->delivery_firstname .']]></delivery_firstname>
|
| 672 |
+
<delivery_lastname><![CDATA['. $this->delivery_lastname .']]></delivery_lastname>
|
| 673 |
+
<delivery_address><![CDATA['. $this->delivery_address .']]></delivery_address>
|
| 674 |
+
<delivery_zipcode><![CDATA['. $this->delivery_zipcode .']]></delivery_zipcode>
|
| 675 |
+
<delivery_city><![CDATA['. $this->delivery_city .']]></delivery_city>
|
| 676 |
+
<delivery_country><![CDATA['. $this->delivery_country .']]></delivery_country>
|
| 677 |
+
<delivery_phone><![CDATA['. $this->delivery_phone .']]></delivery_phone>
|
| 678 |
+
<delivery_email><![CDATA['. $this->delivery_email .']]></delivery_email>
|
| 679 |
+
<delivery_date><![CDATA['. $this->delivery_date .']]></delivery_date>
|
| 680 |
+
|
| 681 |
+
<vat><![CDATA['. $this->vatnumber .']]></vat>
|
| 682 |
+
<recurring><![CDATA['. $this->recurring .']]></recurring>
|
| 683 |
+
<remark><![CDATA['. $this->remark .']]></remark>
|
| 684 |
+
<layout><![CDATA['. $this->layout .']]></layout>
|
| 685 |
+
<paid><![CDATA['. $this->paid .']]></paid>
|
| 686 |
+
<action><![CDATA['. $this->action .']]></action>
|
| 687 |
+
<saverelation><![CDATA['. $this->saverelation .']]></saverelation>
|
| 688 |
+
<calculation_method><![CDATA['. $this->calculation_method .']]></calculation_method>
|
| 689 |
+
<tags>';
|
| 690 |
+
foreach($this->tags as $tag){
|
| 691 |
+
$string .= '<tag><![CDATA['. $tag .']]></tag>';
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
$string .= '</tags>
|
| 695 |
+
<items>';
|
| 696 |
+
foreach($this->items as $i){
|
| 697 |
+
|
| 698 |
+
$string .= '<item>
|
| 699 |
+
<code><![CDATA['. $i['code'] .']]></code>
|
| 700 |
+
<quantity><![CDATA['. $i['quantity'] .']]></quantity>
|
| 701 |
+
<description><![CDATA['. $i['description'] .']]></description>
|
| 702 |
+
<price>'. $i['price'] .'</price>
|
| 703 |
+
<price_incl>'. $i['price_incl'] .'</price_incl>
|
| 704 |
+
<price_vat>'. $i['price_vat'] .'</price_vat>
|
| 705 |
+
<vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
|
| 706 |
+
<discount>'. $i['discount'] .'</discount>
|
| 707 |
+
<categories><![CDATA['. $i['categories'] .']]></categories>
|
| 708 |
+
|
| 709 |
+
</item>';
|
| 710 |
+
}
|
| 711 |
+
|
| 712 |
+
$string .= '</items>
|
| 713 |
+
<files>';
|
| 714 |
+
foreach($this->files as $f){
|
| 715 |
+
$string .= '<file url="'.$f['url'].'">'.$f['name'].'</file>';
|
| 716 |
+
}
|
| 717 |
+
$string .= '</files>
|
| 718 |
+
</invoice>
|
| 719 |
+
</request>';
|
| 720 |
+
return $string;
|
| 721 |
+
}
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
?>
|
app/code/community/Qinvoice/Connect/Model/Order/Observer.php
CHANGED
|
@@ -6,22 +6,164 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 6 |
{
|
| 7 |
//parent::__construct();
|
| 8 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
public function sendOnComplete($observer){
|
| 11 |
return false;
|
| 12 |
$order = $observer->getEvent()->getOrder();
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
// GETTING TRIGGER SETTING
|
| 17 |
-
$
|
| 18 |
-
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 19 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 20 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 21 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 22 |
-
$varOnOrder = $rowTwo['value'];
|
| 23 |
|
| 24 |
-
if($
|
| 25 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 26 |
}else{
|
| 27 |
return true;
|
|
@@ -35,14 +177,9 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 35 |
$order = $shipment->getOrder();
|
| 36 |
|
| 37 |
// GETTING TRIGGER SETTING
|
| 38 |
-
$
|
| 39 |
-
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 40 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 41 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 42 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 43 |
-
$varOnOrder = $rowTwo['value'];
|
| 44 |
|
| 45 |
-
if($
|
| 46 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 47 |
}else{
|
| 48 |
return true;
|
|
@@ -53,14 +190,9 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 53 |
$order = $observer->getEvent()->getOrder();
|
| 54 |
|
| 55 |
// GETTING TRIGGER SETTING
|
| 56 |
-
$
|
| 57 |
-
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 58 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 59 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 60 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 61 |
-
$varOnOrder = $rowTwo['value'];
|
| 62 |
|
| 63 |
-
if($
|
| 64 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 65 |
}else{
|
| 66 |
return true;
|
|
@@ -74,14 +206,9 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 74 |
$order = $observer->getEvent()->getOrder();
|
| 75 |
|
| 76 |
// GETTING TRIGGER SETTING
|
| 77 |
-
$
|
| 78 |
-
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 79 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 80 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 81 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 82 |
-
$varOnOrder = $rowTwo['value'];
|
| 83 |
|
| 84 |
-
if($
|
| 85 |
$this->createInvoiceForQinvoice($order_ids[0], true);
|
| 86 |
}else{
|
| 87 |
return true;
|
|
@@ -110,11 +237,7 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 110 |
{
|
| 111 |
$varStatus = 'Paid';
|
| 112 |
// GETTING API URL
|
| 113 |
-
$
|
| 114 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 115 |
-
$resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 116 |
-
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 117 |
-
$paid_remark = $rowURL['value'];
|
| 118 |
$paid = 1;
|
| 119 |
}
|
| 120 |
else
|
|
@@ -146,26 +269,13 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 146 |
$random_number = rand(0, pow(10, 7));
|
| 147 |
|
| 148 |
// GETTING API USERNAME
|
| 149 |
-
$
|
| 150 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 151 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 152 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 153 |
-
$username = $rowTwo['value'];
|
| 154 |
|
| 155 |
// GETTING API PASSWORD
|
| 156 |
-
$
|
| 157 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 158 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 159 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 160 |
-
$password = $rowTwo['value'];
|
| 161 |
|
| 162 |
// GETTING LAYOUT CODE
|
| 163 |
-
$
|
| 164 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 165 |
-
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 166 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 167 |
-
$layout_code = $rowTwo['value'];
|
| 168 |
-
|
| 169 |
|
| 170 |
// GETTING CLIENT DETAILS
|
| 171 |
$prefix = Mage::getConfig()->getTablePrefix();
|
|
@@ -178,7 +288,7 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 178 |
$invoice->firstname = $rowThree['firstname']; // Your customers contact name
|
| 179 |
$invoice->lastname = $rowThree['lastname']; // Your customers contact name
|
| 180 |
$invoice->email = $rowOne['customer_email']; // Your customers emailaddress (invoice will be sent here)
|
| 181 |
-
$invoice->phone = $
|
| 182 |
$invoice->address = $rowThree['street']; // Self-explanatory
|
| 183 |
$invoice->zipcode = $rowThree['postcode']; // Self-explanatory
|
| 184 |
$invoice->city = $rowThree['city']; // Self-explanatory
|
|
@@ -200,76 +310,43 @@ class Qinvoice_Connect_Model_Order_Observer
|
|
| 200 |
$invoice->vat = ''; // Self-explanatory
|
| 201 |
$invoice->paid = $paid;
|
| 202 |
|
| 203 |
-
$
|
| 204 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 205 |
-
|
| 206 |
-
$resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
|
| 207 |
-
$rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
|
| 208 |
-
$save_relation = $rowAction['value'];
|
| 209 |
-
|
| 210 |
$invoice->saverelation = $save_relation;
|
| 211 |
|
| 212 |
-
$
|
| 213 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 214 |
-
$resultRemark = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varRemarkPath."'");
|
| 215 |
-
$rowRemark = $resultRemark->fetch(PDO::FETCH_ASSOC);
|
| 216 |
-
|
| 217 |
$order_id = $rowOne['increment_id'];
|
| 218 |
-
$invoice_remark = $rowRemark['value'];
|
| 219 |
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 220 |
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
| 221 |
|
| 222 |
$invoice->remark = $invoice_remark ."\n". $paid_remark;
|
| 223 |
|
| 224 |
-
$
|
| 225 |
-
$
|
| 226 |
-
|
| 227 |
-
$
|
| 228 |
-
$
|
| 229 |
-
|
| 230 |
-
$varLayoutPath = 'invoice_options/invoice/layout_code';
|
| 231 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 232 |
-
$resultLayout = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varLayoutPath."'");
|
| 233 |
-
$rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
|
| 234 |
-
$invoice_layout = $rowLayout['value'];
|
| 235 |
-
|
| 236 |
-
$varCalculationmethodPath = 'invoice_options/invoice/calculation_method';
|
| 237 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 238 |
-
$resultCalculationmethod = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varCalculationmethodPath."'");
|
| 239 |
-
$rowCalculationmethod = $resultCalculationmethod->fetch(PDO::FETCH_ASSOC);
|
| 240 |
-
$invoice_calculationmethod = $rowCalculationmethod['value'];
|
| 241 |
-
|
| 242 |
-
$invoice->calculation_method = $invoice_calculationmethod;
|
| 243 |
|
| 244 |
-
$
|
| 245 |
-
if ($
|
| 246 |
// serialized
|
| 247 |
-
$
|
| 248 |
-
if(isset($
|
| 249 |
-
$
|
| 250 |
}else{
|
| 251 |
-
$
|
| 252 |
}
|
| 253 |
} else {
|
| 254 |
// not serialized
|
| 255 |
-
$
|
| 256 |
}
|
| 257 |
|
| 258 |
-
$invoice->setLayout($
|
| 259 |
|
| 260 |
-
$
|
| 261 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 262 |
-
$resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 263 |
-
$rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 264 |
-
$invoice_tag = $rowTag['value'];
|
| 265 |
|
| 266 |
-
$
|
| 267 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 268 |
-
$resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 269 |
-
$pa_array = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 270 |
-
|
| 271 |
|
| 272 |
-
|
| 273 |
|
| 274 |
// OPTIONAL: Add tags
|
| 275 |
$invoice->addTag($rowOne['increment_id']);
|
|
@@ -500,6 +577,7 @@ class qinvoice{
|
|
| 500 |
public $remark;
|
| 501 |
public $paid;
|
| 502 |
public $action;
|
|
|
|
| 503 |
|
| 504 |
public $layout;
|
| 505 |
|
|
@@ -516,11 +594,7 @@ class qinvoice{
|
|
| 516 |
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 517 |
|
| 518 |
// GETTING API URL
|
| 519 |
-
$
|
| 520 |
-
$prefix = Mage::getConfig()->getTablePrefix();
|
| 521 |
-
$resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 522 |
-
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 523 |
-
$apiURL = $rowURL['value'];
|
| 524 |
|
| 525 |
$this->gateway = $apiURL;
|
| 526 |
}
|
|
@@ -612,6 +686,7 @@ class qinvoice{
|
|
| 612 |
<layout><![CDATA['. $this->layout .']]></layout>
|
| 613 |
<paid><![CDATA['. $this->paid .']]></paid>
|
| 614 |
<action><![CDATA['. $this->action .']]></action>
|
|
|
|
| 615 |
<calculation_method><![CDATA['. $this->calculation_method .']]></calculation_method>
|
| 616 |
<tags>';
|
| 617 |
foreach($this->tags as $tag){
|
| 6 |
{
|
| 7 |
//parent::__construct();
|
| 8 |
}
|
| 9 |
+
//
|
| 10 |
+
public function qinvoiceCall(){
|
| 11 |
+
if(Mage::app()->getRequest()->getParam('qc')){
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
$data = explode("|", Mage::app()->getRequest()->getParam('qc_data'));
|
| 15 |
+
|
| 16 |
+
$string = false;
|
| 17 |
+
//print_r($data);
|
| 18 |
+
foreach($data as $d){
|
| 19 |
+
$values = explode("=", $d);
|
| 20 |
+
|
| 21 |
+
switch($values[0]){
|
| 22 |
+
case 'check':
|
| 23 |
+
$check = $values[1];
|
| 24 |
+
break;
|
| 25 |
+
default:
|
| 26 |
+
if($string != false){
|
| 27 |
+
$string .= '|';
|
| 28 |
+
}
|
| 29 |
+
$string .= $values[0] .'='. $values[1];
|
| 30 |
+
$params[$values[0]] = $values[1];
|
| 31 |
+
break;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
$secret = Mage::getStoreConfig('invoice_options/invoice/webshop_secret','default');
|
| 38 |
+
|
| 39 |
+
if(md5($string.$secret) != $check){
|
| 40 |
+
exit('Incorrect checksum. Check your secret key.');
|
| 41 |
+
return false;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
switch(Mage::app()->getRequest()->getParam('qc')){
|
| 47 |
+
case 'test':
|
| 48 |
+
echo 'test ok';
|
| 49 |
+
break;
|
| 50 |
+
case 'stock':
|
| 51 |
+
echo $this->updateStock($params);
|
| 52 |
+
break;
|
| 53 |
+
case 'export':
|
| 54 |
+
echo $this->exportCatalog($params);
|
| 55 |
+
break;
|
| 56 |
+
case 'stores':
|
| 57 |
+
echo $this->listStores();
|
| 58 |
+
break;
|
| 59 |
+
|
| 60 |
+
}
|
| 61 |
+
exit();
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
public function updateStock($params){
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
if($params['sku'] == '' || $params['sku'] == '0'){
|
| 69 |
+
exit('SKU is missing');
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $params['sku']);
|
| 75 |
+
|
| 76 |
+
if(!$_product->getId() > 0){
|
| 77 |
+
exit('Product not found: '. $sku);
|
| 78 |
+
return false;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
|
| 84 |
+
|
| 85 |
+
if ($stock->getId() > 0 and $stock->getManageStock()) {
|
| 86 |
+
$stock->setQty($params['qty']);
|
| 87 |
+
$stock->setIsInStock((int)($params['qty'] > 0));
|
| 88 |
+
if(!$stock->save()){
|
| 89 |
+
exit('Error updating stock');
|
| 90 |
+
}else{
|
| 91 |
+
exit('Success');
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
public function listStores(){
|
| 98 |
+
foreach(Mage::getSingleton('adminhtml/system_store')->getStoresStructure() as $store){
|
| 99 |
+
// $store_array[] =
|
| 100 |
+
}
|
| 101 |
+
echo '<pre>';
|
| 102 |
+
print_r(Mage::getSingleton('adminhtml/system_store')->getStoresStructure());
|
| 103 |
+
echo '</pre>';
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
public function exportCatalog($params){
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
//echo '<h1>'. $params['store_id'] .'</h1>';
|
| 110 |
+
if($params['store_id'] == null || !isset($params['store_id'])){
|
| 111 |
+
$store_id = 'default';
|
| 112 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
|
| 113 |
+
}else{
|
| 114 |
+
$store_id = $params['store_id'];
|
| 115 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->setStoreId($params['store_id']);
|
| 116 |
+
}
|
| 117 |
+
//Magento does not load all attributes by default
|
| 118 |
+
//Add as many as you like
|
| 119 |
+
$products->addAttributeToSelect('name');
|
| 120 |
+
$products->addAttributeToSelect('price');
|
| 121 |
+
$products->addAttributeToSelect('special_price');
|
| 122 |
+
foreach($products as $product) {
|
| 123 |
+
|
| 124 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
| 125 |
+
$request = $taxCalculation->getRateRequest(null, null, null, Mage::app()->getStore($store_id) );
|
| 126 |
+
$taxClassId = $product->getTaxClassId();
|
| 127 |
+
$vat_percent = $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
| 128 |
+
|
| 129 |
+
$tier_prices = array();
|
| 130 |
+
//$product_data = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->sku);
|
| 131 |
+
$tier_prices = ($product->getTierPrice());
|
| 132 |
+
foreach ($tier_prices as $tp) {
|
| 133 |
+
$tp_array[$tp['price_qty']] = $tp['price'];
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
| 138 |
+
$products_array[] = array(
|
| 139 |
+
'entity_id' => $product['entity_id'],
|
| 140 |
+
'sku' => $product['sku'],
|
| 141 |
+
'name' => $product['name'],
|
| 142 |
+
'price' => $product['price'],
|
| 143 |
+
'weight' => $product['weight'],
|
| 144 |
+
'thumbnail' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $product['thumbnail'],
|
| 145 |
+
'special_price' => $product['special_price'],
|
| 146 |
+
'stock' => $stock->getQty(),
|
| 147 |
+
'min_stock' => $stock->getMinQty(),
|
| 148 |
+
'vat' => $vat_percent*100,
|
| 149 |
+
'tier_prices' => $tp_array
|
| 150 |
+
);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
//echo count($products_array);
|
| 154 |
+
echo json_encode($products_array);
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
}
|
| 158 |
|
| 159 |
public function sendOnComplete($observer){
|
| 160 |
return false;
|
| 161 |
$order = $observer->getEvent()->getOrder();
|
| 162 |
|
|
|
|
|
|
|
| 163 |
// GETTING TRIGGER SETTING
|
| 164 |
+
$invoice_trigger = Mage::getStoreConfig('invoice_options/invoice/invoice_trigger');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
+
if($invoice_trigger == 'complete' && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
|
| 167 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 168 |
}else{
|
| 169 |
return true;
|
| 177 |
$order = $shipment->getOrder();
|
| 178 |
|
| 179 |
// GETTING TRIGGER SETTING
|
| 180 |
+
$invoice_trigger = Mage::getStoreConfig('invoice_options/invoice/invoice_trigger');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
+
if($invoice_trigger == 'ship'){
|
| 183 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 184 |
}else{
|
| 185 |
return true;
|
| 190 |
$order = $observer->getEvent()->getOrder();
|
| 191 |
|
| 192 |
// GETTING TRIGGER SETTING
|
| 193 |
+
$invoice_trigger = Mage::getStoreConfig('invoice_options/invoice/invoice_trigger');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
+
if($invoice_trigger == 'order'){
|
| 196 |
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 197 |
}else{
|
| 198 |
return true;
|
| 206 |
$order = $observer->getEvent()->getOrder();
|
| 207 |
|
| 208 |
// GETTING TRIGGER SETTING
|
| 209 |
+
$invoice_trigger = Mage::getStoreConfig('invoice_options/invoice/invoice_trigger');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
|
| 211 |
+
if($invoice_trigger == 'payment'){
|
| 212 |
$this->createInvoiceForQinvoice($order_ids[0], true);
|
| 213 |
}else{
|
| 214 |
return true;
|
| 237 |
{
|
| 238 |
$varStatus = 'Paid';
|
| 239 |
// GETTING API URL
|
| 240 |
+
$paid_remark = Mage::getStoreConfig('invoice_options/invoice/paid_remark');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
$paid = 1;
|
| 242 |
}
|
| 243 |
else
|
| 269 |
$random_number = rand(0, pow(10, 7));
|
| 270 |
|
| 271 |
// GETTING API USERNAME
|
| 272 |
+
$username = Mage::getStoreConfig('invoice_options/invoice/api_username');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
|
| 274 |
// GETTING API PASSWORD
|
| 275 |
+
$password = Mage::getStoreConfig('invoice_options/invoice/api_password');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
|
| 277 |
// GETTING LAYOUT CODE
|
| 278 |
+
$layout_code = Mage::getStoreConfig('invoice_options/invoice/layout_code');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
// GETTING CLIENT DETAILS
|
| 281 |
$prefix = Mage::getConfig()->getTablePrefix();
|
| 288 |
$invoice->firstname = $rowThree['firstname']; // Your customers contact name
|
| 289 |
$invoice->lastname = $rowThree['lastname']; // Your customers contact name
|
| 290 |
$invoice->email = $rowOne['customer_email']; // Your customers emailaddress (invoice will be sent here)
|
| 291 |
+
$invoice->phone = $rowThree['telephone'];
|
| 292 |
$invoice->address = $rowThree['street']; // Self-explanatory
|
| 293 |
$invoice->zipcode = $rowThree['postcode']; // Self-explanatory
|
| 294 |
$invoice->city = $rowThree['city']; // Self-explanatory
|
| 310 |
$invoice->vat = ''; // Self-explanatory
|
| 311 |
$invoice->paid = $paid;
|
| 312 |
|
| 313 |
+
$save_relation = Mage::getStoreConfig('invoice_options/invoice/save_relation');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
$invoice->saverelation = $save_relation;
|
| 315 |
|
| 316 |
+
$invoice_remark = Mage::getStoreConfig('invoice_options/invoice/invoice_remark');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
$order_id = $rowOne['increment_id'];
|
|
|
|
| 318 |
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 319 |
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
| 320 |
|
| 321 |
$invoice->remark = $invoice_remark ."\n". $paid_remark;
|
| 322 |
|
| 323 |
+
$invoice_action = Mage::getStoreConfig('invoice_options/invoice/invoice_action');
|
| 324 |
+
$invoice->action = $invoice_action;
|
| 325 |
+
|
| 326 |
+
$calculation_method = Mage::getStoreConfig('invoice_options/invoice/calculation_method');
|
| 327 |
+
$invoice->calculation_method = $calculation_method;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
+
$layout_code_s = @unserialize($layout_code);
|
| 330 |
+
if ($layout_code_s !== false) {
|
| 331 |
// serialized
|
| 332 |
+
$layout_code = @unserialize($layout_code);
|
| 333 |
+
if(isset($layout_code[$rowFour['country_id']])){
|
| 334 |
+
$layout_code = @$layout_code[$rowFour['country_id']];
|
| 335 |
}else{
|
| 336 |
+
$layout_code = @$layout_code['default'];
|
| 337 |
}
|
| 338 |
} else {
|
| 339 |
// not serialized
|
| 340 |
+
$layout_code = $layout_code;
|
| 341 |
}
|
| 342 |
|
| 343 |
+
$invoice->setLayout($layout_code);
|
| 344 |
|
| 345 |
+
$invoice_tag = Mage::getStoreConfig('invoice_options/invoice/invoice_tag');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
+
$pa_array = Mage::getStoreConfig('invoice_options/invoice/product_attributes');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
|
| 349 |
+
|
| 350 |
|
| 351 |
// OPTIONAL: Add tags
|
| 352 |
$invoice->addTag($rowOne['increment_id']);
|
| 577 |
public $remark;
|
| 578 |
public $paid;
|
| 579 |
public $action;
|
| 580 |
+
public $saverelation = false;
|
| 581 |
|
| 582 |
public $layout;
|
| 583 |
|
| 594 |
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 595 |
|
| 596 |
// GETTING API URL
|
| 597 |
+
$apiURL = Mage::getStoreConfig('invoice_options/invoice/api_url');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 598 |
|
| 599 |
$this->gateway = $apiURL;
|
| 600 |
}
|
| 686 |
<layout><![CDATA['. $this->layout .']]></layout>
|
| 687 |
<paid><![CDATA['. $this->paid .']]></paid>
|
| 688 |
<action><![CDATA['. $this->action .']]></action>
|
| 689 |
+
<saverelation><![CDATA['. $this->saverelation .']]></saverelation>
|
| 690 |
<calculation_method><![CDATA['. $this->calculation_method .']]></calculation_method>
|
| 691 |
<tags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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
//class NameSpaceName_ModuleName_Model_ObserverDir_Observer
|
| 3 |
+
class Qinvoice_Connect_Model_Order_Observer
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
//parent::__construct();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function sendOnComplete($observer){
|
| 11 |
+
return false;
|
| 12 |
+
$order = $observer->getEvent()->getOrder();
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
// GETTING TRIGGER SETTING
|
| 17 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 18 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 19 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 20 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 21 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 22 |
+
$varOnOrder = $rowTwo['value'];
|
| 23 |
+
|
| 24 |
+
if($varOnOrder == 'complete' && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
|
| 25 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 26 |
+
}else{
|
| 27 |
+
return true;
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public function changeStateOrder($observer){
|
| 32 |
+
Mage::log('changeStateOrder');
|
| 33 |
+
$order = $observer->getEvent()->getOrder();
|
| 34 |
+
|
| 35 |
+
mail('caspermekel@gmail.com','changeStateOrder',$order->getStatus());
|
| 36 |
+
if($order->getStatus() == "processing_paid"){
|
| 37 |
+
$this->autoInvoicing($order);
|
| 38 |
+
}
|
| 39 |
+
else if($order->getStatus() == "processing_shipped"){
|
| 40 |
+
$this->autoShipment($order);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// use your necessary ifs
|
| 44 |
+
$this->sendTransactionalEmail($order);
|
| 45 |
+
|
| 46 |
+
return $this;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
private function getSetting($varPath, $store_id = 0){
|
| 50 |
+
if($store_id > 0){
|
| 51 |
+
$scope = 'stores';
|
| 52 |
+
$scope_id = $store_id;
|
| 53 |
+
}else{
|
| 54 |
+
$scope = 'default';
|
| 55 |
+
$scope_id = 0;
|
| 56 |
+
}
|
| 57 |
+
//$varPath = 'invoice_options/invoice/layout_code';
|
| 58 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 59 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 60 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 61 |
+
return $rowTwo['value'];
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function sendOnShip($observer){
|
| 65 |
+
return false;
|
| 66 |
+
$shipment = $observer->getEvent()->getShipment();
|
| 67 |
+
|
| 68 |
+
$order = $shipment->getOrder();
|
| 69 |
+
|
| 70 |
+
// GETTING TRIGGER SETTING
|
| 71 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 72 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 73 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 74 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 75 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 76 |
+
$varOnOrder = $rowTwo['value'];
|
| 77 |
+
|
| 78 |
+
if($varOnOrder == 'ship'){
|
| 79 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 80 |
+
}else{
|
| 81 |
+
return true;
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
public function sendOnOrder($observer){
|
| 86 |
+
$order = $observer->getEvent()->getOrder();
|
| 87 |
+
|
| 88 |
+
// GETTING TRIGGER SETTING
|
| 89 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 90 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 91 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 92 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 93 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 94 |
+
$varOnOrder = $rowTwo['value'];
|
| 95 |
+
|
| 96 |
+
if($varOnOrder == 'order'){
|
| 97 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 98 |
+
}else{
|
| 99 |
+
return true;
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
public function sendOnPayment($observer){
|
| 104 |
+
// Gets called even when other payment method is choosen.
|
| 105 |
+
|
| 106 |
+
$order_ids = $observer->getEvent()->getOrderIds();
|
| 107 |
+
$order = $observer->getEvent()->getOrder();
|
| 108 |
+
|
| 109 |
+
// GETTING TRIGGER SETTING
|
| 110 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 111 |
+
$varPath = 'invoice_options/invoice/invoice_trigger';
|
| 112 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 113 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 114 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 115 |
+
$varOnOrder = $rowTwo['value'];
|
| 116 |
+
|
| 117 |
+
if($varOnOrder == 'payment'){
|
| 118 |
+
$this->createInvoiceForQinvoice($order->getId(), true);
|
| 119 |
+
}else{
|
| 120 |
+
// update existing
|
| 121 |
+
//if($order->getInvoiceID())
|
| 122 |
+
|
| 123 |
+
//echo $order->getQinvoiceId();
|
| 124 |
+
mail('casper@q-invoice.com','Invoice order id',$order->getQinvoiceId());
|
| 125 |
+
mail('caspermekel@gmail.com','Invoice order id',$order->getQinvoiceId());
|
| 126 |
+
return true;
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
public function createInvoiceForQinvoice($varOrderID,$ifPaid = false)
|
| 131 |
+
{
|
| 132 |
+
$paid = 0;
|
| 133 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 134 |
+
// GETTING ORDER ID
|
| 135 |
+
//$resultOne = $db->query("SELECT max(entity_id) as LastOrderID FROM sales_flat_order");
|
| 136 |
+
//$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
| 137 |
+
|
| 138 |
+
//$varOrderID = $rowOne['LastOrderID'];
|
| 139 |
+
|
| 140 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($varOrderID);
|
| 141 |
+
|
| 142 |
+
$store_id = $order->getStoreId();
|
| 143 |
+
|
| 144 |
+
$varCurrenyCode = Mage::app()->getStore()->getCurrentCurrency()->getCode();
|
| 145 |
+
// GETTING ORDER STATUS
|
| 146 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 147 |
+
$resultOne = $db->query("SELECT * FROM {$prefix}sales_flat_order WHERE entity_id= '".$varOrderID ."'");
|
| 148 |
+
$rowOne = $resultOne->fetch(PDO::FETCH_ASSOC);
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
if($rowOne['status'] == 'processing' || $rowOne['status'] == 'complete' || $rowOne['total_paid'] == $rowOne['grand_total'])
|
| 152 |
+
{
|
| 153 |
+
$varStatus = 'Paid';
|
| 154 |
+
// GETTING API URL
|
| 155 |
+
$varURLPath = 'invoice_options/invoice/paid_remark';
|
| 156 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 157 |
+
$resultURL = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 158 |
+
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 159 |
+
$paid_remark = $rowURL['value'];
|
| 160 |
+
$paid = 1;
|
| 161 |
+
}
|
| 162 |
+
else
|
| 163 |
+
{
|
| 164 |
+
if($ifPaid == true){
|
| 165 |
+
// cancel if invoice has to be paid
|
| 166 |
+
return;
|
| 167 |
+
}
|
| 168 |
+
$paid_remark = '';
|
| 169 |
+
$varStatus = 'Sent';
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 173 |
+
$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 HAVING (order_id > 0) ORDER BY item_id desc");
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
if(!$result) {
|
| 177 |
+
//return false;
|
| 178 |
+
}
|
| 179 |
+
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
| 180 |
+
$arrData[] = $row;
|
| 181 |
+
}
|
| 182 |
+
if(!$arrData) {
|
| 183 |
+
//return false;
|
| 184 |
+
}
|
| 185 |
+
//$comment = '';
|
| 186 |
+
//$comment = $data['comment_text'];
|
| 187 |
+
// getting po_number
|
| 188 |
+
$random_number = rand(0, pow(10, 7));
|
| 189 |
+
|
| 190 |
+
// GETTING API USERNAME
|
| 191 |
+
$varPath = 'invoice_options/invoice/api_username';
|
| 192 |
+
$username = Mage::getStoreConfig($varPath,$store_id);
|
| 193 |
+
|
| 194 |
+
// GETTING API PASSWORD
|
| 195 |
+
$varPath = 'invoice_options/invoice/api_password';
|
| 196 |
+
$password = Mage::getStoreConfig($varPath,$store_id);
|
| 197 |
+
|
| 198 |
+
// GETTING LAYOUT CODE
|
| 199 |
+
$varPath = 'invoice_options/invoice/layout_code';
|
| 200 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 201 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 202 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 203 |
+
$layout_code = $rowTwo['value'];
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
// GETTING CLIENT DETAILS
|
| 207 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 208 |
+
$resultThree = $db->query("SELECT * FROM {$prefix}sales_flat_order_address WHERE entity_id='".$rowOne['billing_address_id']."'");
|
| 209 |
+
$rowThree = $resultThree->fetch(PDO::FETCH_ASSOC);
|
| 210 |
+
|
| 211 |
+
$invoice = new qinvoice($username,$password);
|
| 212 |
+
|
| 213 |
+
$invoice->companyname = $rowThree['company']; // Your customers company name
|
| 214 |
+
$invoice->firstname = $rowThree['firstname']; // Your customers contact name
|
| 215 |
+
$invoice->lastname = $rowThree['lastname']; // Your customers contact name
|
| 216 |
+
$invoice->email = $rowOne['customer_email']; // Your customers emailaddress (invoice will be sent here)
|
| 217 |
+
|
| 218 |
+
$invoice->address = $rowThree['street']; // Self-explanatory
|
| 219 |
+
$invoice->zipcode = $rowThree['postcode']; // Self-explanatory
|
| 220 |
+
$invoice->city = $rowThree['city']; // Self-explanatory
|
| 221 |
+
$invoice->country = $rowThree['country_id']; // 2 character country code: NL for Netherlands, DE for Germany etc
|
| 222 |
+
$invoice->vatnumber = strlen($rowThree['vat_id']) > 3 ? $rowThree['vat_id'] : $rowOne['customer_taxvat'];
|
| 223 |
+
|
| 224 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 225 |
+
$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']."'");
|
| 226 |
+
$rowFour = $resultFour->fetch(PDO::FETCH_ASSOC);
|
| 227 |
+
|
| 228 |
+
$invoice->delivery_companyname = $rowFour['company']; // Your customers company name
|
| 229 |
+
$invoice->delivery_firstname = $rowFour['firstname']; // Your customers contact name
|
| 230 |
+
$invoice->delivery_lastname = $rowFour['lastname']; // Your customers contact name
|
| 231 |
+
$invoice->delivery_address = $rowFour['street']; // Self-explanatory
|
| 232 |
+
$invoice->delivery_zipcode = $rowFour['postcode']; // Self-explanatory
|
| 233 |
+
$invoice->delivery_city = $rowFour['city']; // Self-explanatory
|
| 234 |
+
$invoice->delivery_country = $rowFour['country_id'];
|
| 235 |
+
$invoice->phone = $rowFour['telephone'];
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
$invoice->vat = ''; // Self-explanatory
|
| 239 |
+
$invoice->paid = $paid;
|
| 240 |
+
|
| 241 |
+
// $varActionPath = ;
|
| 242 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 243 |
+
// $resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
|
| 244 |
+
// $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
|
| 245 |
+
|
| 246 |
+
$varActionPath = 'invoice_options/invoice/save_relation';
|
| 247 |
+
$configValue = Mage::getStoreConfig($varActionPath,Mage::app()->getStore());
|
| 248 |
+
$save_relation = $configValue;
|
| 249 |
+
|
| 250 |
+
// $save_relation = $this->getSetting('invoice_options/invoice/save_relation', $store_id);
|
| 251 |
+
$invoice->saverelation = $save_relation;
|
| 252 |
+
|
| 253 |
+
// $varRemarkPath = 'invoice_options/invoice/invoice_remark';
|
| 254 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 255 |
+
// $resultRemark = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varRemarkPath."'");
|
| 256 |
+
// $rowRemark = $this->getSetting('invoice_options/invoice/invoice_remark', $store_id);
|
| 257 |
+
|
| 258 |
+
$varActionPath = 'invoice_options/invoice/invoice_remark';
|
| 259 |
+
$configValue = Mage::getStoreConfig($varActionPath,Mage::app()->getStore());
|
| 260 |
+
$rowRemark = $configValue;
|
| 261 |
+
|
| 262 |
+
$order_id = $rowOne['increment_id'];
|
| 263 |
+
$invoice_remark = $rowRemark['value'];
|
| 264 |
+
$invoice_remark = str_replace('{order_id}',$rowOne['increment_id'],$invoice_remark);
|
| 265 |
+
$invoice_remark = str_replace('{shipping_description}',$rowOne['shipping_description'],$invoice_remark);
|
| 266 |
+
|
| 267 |
+
$invoice->remark = $invoice_remark ."\n". $paid_remark;
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
$varActionPath = 'invoice_options/invoice/invoice_action';
|
| 272 |
+
$configValue = Mage::getStoreConfig($varActionPath,Mage::app()->getStore());
|
| 273 |
+
$invoice_action = $configValue;
|
| 274 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 275 |
+
// $resultAction = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varActionPath."'");
|
| 276 |
+
// $rowAction = $resultAction->fetch(PDO::FETCH_ASSOC);
|
| 277 |
+
// $invoice_action = $rowAction['value'];
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
$varLayoutPath = 'invoice_options/invoice/layout_code';
|
| 281 |
+
$configValue = Mage::getStoreConfig($varLayoutPath,Mage::app()->getStore());
|
| 282 |
+
$invoice_layout = $configValue;
|
| 283 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 284 |
+
// $resultLayout = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varLayoutPath."'");
|
| 285 |
+
// $rowLayout = $resultLayout->fetch(PDO::FETCH_ASSOC);
|
| 286 |
+
// $invoice_layout = $rowLayout['value'];
|
| 287 |
+
|
| 288 |
+
$varCalculationmethodPath = 'invoice_options/invoice/calculation_method';
|
| 289 |
+
$configValue = Mage::getStoreConfig($varCalculationmethodPath,Mage::app()->getStore());
|
| 290 |
+
$invoice_calculationmethod = $configValue;
|
| 291 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 292 |
+
// $resultCalculationmethod = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varCalculationmethodPath."'");
|
| 293 |
+
// $rowCalculationmethod = $resultCalculationmethod->fetch(PDO::FETCH_ASSOC);
|
| 294 |
+
// $invoice_calculationmethod = $rowCalculationmethod['value'];
|
| 295 |
+
|
| 296 |
+
$invoice->calculation_method = $invoice_calculationmethod;
|
| 297 |
+
|
| 298 |
+
$invoice_layout_s = @unserialize($invoice_layout);
|
| 299 |
+
if ($invoice_layout_s !== false) {
|
| 300 |
+
// serialized
|
| 301 |
+
$invoice_layout = @unserialize($invoice_layout);
|
| 302 |
+
if(isset($invoice_layout[$rowFour['country_id']])){
|
| 303 |
+
$invoice_layout = @$invoice_layout[$rowFour['country_id']];
|
| 304 |
+
}else{
|
| 305 |
+
$invoice_layout = @$invoice_layout['default'];
|
| 306 |
+
}
|
| 307 |
+
} else {
|
| 308 |
+
// not serialized
|
| 309 |
+
$invoice_layout = $invoice_layout;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
$invoice->setLayout($invoice_layout);
|
| 313 |
+
|
| 314 |
+
$varTagPath = 'invoice_options/invoice/invoice_tag';
|
| 315 |
+
$configValue = Mage::getStoreConfig($varTagPath,Mage::app()->getStore());
|
| 316 |
+
$invoice_tag = $configValue;
|
| 317 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 318 |
+
// $resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 319 |
+
// $rowTag = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 320 |
+
// $invoice_tag = $rowTag['value'];
|
| 321 |
+
|
| 322 |
+
$varAttributePath = 'invoice_options/invoice/product_attributes';
|
| 323 |
+
$configValue = Mage::getStoreConfig($varAttributePath,Mage::app()->getStore());
|
| 324 |
+
$pa_array = $configValue;
|
| 325 |
+
// $prefix = Mage::getConfig()->getTablePrefix();
|
| 326 |
+
// $resultTag = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varTagPath."'");
|
| 327 |
+
// $pa_array = $resultTag->fetch(PDO::FETCH_ASSOC);
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
$invoice->action = $invoice_action;
|
| 331 |
+
|
| 332 |
+
// OPTIONAL: Add tags
|
| 333 |
+
$invoice->addTag($rowOne['increment_id']);
|
| 334 |
+
$invoice->addTag($invoice_tag);
|
| 335 |
+
// $invoice->addTag('send: '. $send_mail);
|
| 336 |
+
// $invoice->addTag('paid: '. $paid .' '. $rowOne['total_paid']);
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
| 343 |
+
$attributeArray = array();
|
| 344 |
+
|
| 345 |
+
foreach($attributes as $attribute){
|
| 346 |
+
$attributeArray[$attribute->getData('attribute_code')] = $attribute->getData('frontend_label');
|
| 347 |
+
// $attributeArray[] = array(
|
| 348 |
+
// 'label' => $attribute->getData('frontend_label'),
|
| 349 |
+
// 'value' => $attribute->getData('attribute_code')
|
| 350 |
+
// );
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
//print_r($order);
|
| 355 |
+
|
| 356 |
+
for($i=0;$i<count($arrData);$i++)
|
| 357 |
+
{
|
| 358 |
+
$category = '';
|
| 359 |
+
$_productId = $arrData[$i]['product_id'];
|
| 360 |
+
$_product = Mage::getModel('catalog/product')->load($_productId);
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
$category = $_product->getData('qinvoice_category');
|
| 364 |
+
$productcode = $_product->getData('qinvoice_productcode');
|
| 365 |
+
|
| 366 |
+
$arrItemOptions = unserialize($arrData[$i]['product_options']);
|
| 367 |
+
|
| 368 |
+
$varDescription = '';
|
| 369 |
+
|
| 370 |
+
//print_r();
|
| 371 |
+
|
| 372 |
+
$product_attributes = explode(",",$pa_array['value']);
|
| 373 |
+
foreach($product_attributes as $pa){
|
| 374 |
+
if(isset($_product[$pa]))
|
| 375 |
+
{
|
| 376 |
+
$varDescription .= "\n". $attributeArray[$pa] .': '. $_product[$pa];
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
if(@$arrItemOptions['options'])
|
| 382 |
+
{
|
| 383 |
+
for($k=0; $k <count($arrItemOptions['options']); $k++)
|
| 384 |
+
{
|
| 385 |
+
$varDescription .= "\n".$arrItemOptions['options'][$k]['label'].": ".$arrItemOptions['options'][$k]['print_value']."\n";
|
| 386 |
+
}
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
if(@$arrItemOptions['attributes_info'])
|
| 390 |
+
{
|
| 391 |
+
for($k=0; $k <count($arrItemOptions['attributes_info']); $k++)
|
| 392 |
+
{
|
| 393 |
+
$varDescription .= "\n".$arrItemOptions['attributes_info'][$k]['label'].": ".$arrItemOptions['attributes_info'][$k]['value']."\n";
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
if(@$arrItemOptions['bundle_options'])
|
| 398 |
+
{
|
| 399 |
+
foreach($arrItemOptions['bundle_options'] as $option){
|
| 400 |
+
foreach($option['value'] as $value){
|
| 401 |
+
$varDescription .= "\n".'['. $option['label'] .'] '. $value['qty'] .' x '. $value['title'];
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
$params = array(
|
| 412 |
+
'code' => $productcode,
|
| 413 |
+
'description' => "[".$arrData[$i]['sku']."] ".trim($arrData[$i]['name']) . $varDescription,
|
| 414 |
+
'price' => $arrData[$i]['base_price']*100,
|
| 415 |
+
//'price_incl' => ((($arrData[$i]['base_price']*$arrData[$i]['qty_ordered'])+$arrData[$i]['tax_amount'])/$arrData[$i]['qty_ordered'])*100,
|
| 416 |
+
'price_incl' => round(((($arrData[$i]['base_price']*$arrData[$i]['qty_ordered'])+$arrData[$i]['tax_amount'])/$arrData[$i]['qty_ordered'])*100),
|
| 417 |
+
'price_vat' => ($arrData[$i]['tax_amount']/$arrData[$i]['qty_ordered'])*100,
|
| 418 |
+
'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
|
| 419 |
+
'discount' => 0,
|
| 420 |
+
'quantity' => $arrData[$i]['qty_ordered']*100,
|
| 421 |
+
'categories' => $category
|
| 422 |
+
);
|
| 423 |
+
|
| 424 |
+
$invoice->addItem($params);
|
| 425 |
+
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
if($rowOne['shipping_amount'] > 0)
|
| 429 |
+
{
|
| 430 |
+
$params = array(
|
| 431 |
+
'code' => 'SHPMNT',
|
| 432 |
+
'description' => trim($rowOne['shipping_description']),
|
| 433 |
+
'price' => $rowOne['shipping_amount']*100,
|
| 434 |
+
'price_incl' => $rowOne['shipping_incl_tax']*100,
|
| 435 |
+
'price_vat' => $rowOne['shipping_tax_amount']*100,
|
| 436 |
+
'vatpercentage' => round(($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100)*100,
|
| 437 |
+
'discount' => 0,
|
| 438 |
+
'quantity' => 100,
|
| 439 |
+
'categories' => 'shipping'
|
| 440 |
+
);
|
| 441 |
+
|
| 442 |
+
$invoice->addItem($params);
|
| 443 |
+
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
// $order = Mage::getModel('sales/order')->loadByIncrementId($varOrderID);
|
| 447 |
+
|
| 448 |
+
// $orderDetails = $order->getData();
|
| 449 |
+
|
| 450 |
+
$couponCode = $rowOne['coupon_code'];
|
| 451 |
+
//echo $couponCode;
|
| 452 |
+
//print_r($order);
|
| 453 |
+
// $couponCode = $orderDetails['coupon_code'];
|
| 454 |
+
|
| 455 |
+
if($couponCode > ''){
|
| 456 |
+
$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
|
| 457 |
+
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
|
| 458 |
+
var_dump($oRule->getData());
|
| 459 |
+
|
| 460 |
+
$ruleData = $oRule->getData();
|
| 461 |
+
|
| 462 |
+
$discount = $ruleData['discount_amount'];
|
| 463 |
+
$params = array(
|
| 464 |
+
'code' => 'DSCNT',
|
| 465 |
+
'description' => $couponCode,
|
| 466 |
+
'price' => ($rowOne['base_subtotal'] * ($discount/100))*100,
|
| 467 |
+
'price_incl' => ($rowOne['base_subtotal'] * ($discount/100))*100,
|
| 468 |
+
'price_vat' => 0,
|
| 469 |
+
'vatpercentage' => 0,
|
| 470 |
+
'discount' => 0,
|
| 471 |
+
'quantity' => -100,
|
| 472 |
+
'categories' => 'discount'
|
| 473 |
+
);
|
| 474 |
+
|
| 475 |
+
$invoice->addItem($params);
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
// $coupon = Mage::getModel('salesrule/rule');
|
| 480 |
+
// $couponCollection = $coupon->getCollection();
|
| 481 |
+
// foreach($couponCollection as $c){
|
| 482 |
+
// print_r($c);
|
| 483 |
+
// echo 'Code:'.$c->getCode().'--->Discount Amount:'.$c->getDiscountAmount().'<br />';
|
| 484 |
+
|
| 485 |
+
// $params = array(
|
| 486 |
+
// 'code' => 'DSCNT',
|
| 487 |
+
// 'description' => $c->getCode(),
|
| 488 |
+
// 'price' => $rowOne['base_subtotal'] * ($c->getDiscountAmount()/100),
|
| 489 |
+
// 'price_incl' => $rowOne['base_subtotal'] * ($c->getDiscountAmount()/100),
|
| 490 |
+
// 'price_vat' => 0,
|
| 491 |
+
// 'vatpercentage' => 0,
|
| 492 |
+
// 'discount' => 0,
|
| 493 |
+
// 'quantity' => -100,
|
| 494 |
+
// 'categories' => 'discount'
|
| 495 |
+
// );
|
| 496 |
+
|
| 497 |
+
// $invoice->addItem($params);
|
| 498 |
+
|
| 499 |
+
// }
|
| 500 |
+
|
| 501 |
+
$result = $invoice->sendRequest(); // holds invoice ID
|
| 502 |
+
|
| 503 |
+
$order->setQinvoiceId($result);
|
| 504 |
+
// echo $order->getQinvoiceID();
|
| 505 |
+
|
| 506 |
+
// echo '<Br />';
|
| 507 |
+
|
| 508 |
+
// echo Mage::getStoreConfig($varActionPath);
|
| 509 |
+
$order->save();
|
| 510 |
+
|
| 511 |
+
//print_r($order);
|
| 512 |
+
|
| 513 |
+
if(!is_numeric($result)){
|
| 514 |
+
$this->notify_admin('Qinvoice Connect Error','Could not send invoice for order '. $order_id);
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
//die('hier');
|
| 518 |
+
return true;
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
}
|
| 522 |
+
public function notify_admin($subject,$msg)
|
| 523 |
+
{
|
| 524 |
+
$varSubject = 'Qinvoice Notification';
|
| 525 |
+
|
| 526 |
+
Mage::log($subject .': '. $msg);
|
| 527 |
+
|
| 528 |
+
$mail = Mage::getModel('core/email');
|
| 529 |
+
$mail->setToName(Mage::getStoreConfig('trans_email/ident_general/name') );
|
| 530 |
+
$mail->setToEmail(Mage::getStoreConfig('trans_email/ident_general/email') );
|
| 531 |
+
$mail->setBody($msg);
|
| 532 |
+
$mail->setSubject($subject);
|
| 533 |
+
$mail->setFromEmail("support@qinvoice.com");
|
| 534 |
+
$mail->setFromName("Qinvoice Support");
|
| 535 |
+
$mail->setType('text');
|
| 536 |
+
$mail->send();
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
class qDocumentRequest extends qApi{
|
| 545 |
+
|
| 546 |
+
|
| 547 |
+
public $companyname;
|
| 548 |
+
public $firstname;
|
| 549 |
+
public $lastname;
|
| 550 |
+
public $email;
|
| 551 |
+
public $address;
|
| 552 |
+
public $zipcode;
|
| 553 |
+
public $city;
|
| 554 |
+
public $country;
|
| 555 |
+
public $delivery_companyname;
|
| 556 |
+
public $delivery_firstname;
|
| 557 |
+
public $delivery_lastname;
|
| 558 |
+
public $delivery_address;
|
| 559 |
+
public $delivery_zipcode;
|
| 560 |
+
public $delivery_city;
|
| 561 |
+
public $delivery_country;
|
| 562 |
+
public $vatnumber;
|
| 563 |
+
public $remark;
|
| 564 |
+
public $action;
|
| 565 |
+
|
| 566 |
+
public $layout;
|
| 567 |
+
|
| 568 |
+
private $tags = array();
|
| 569 |
+
private $items = array();
|
| 570 |
+
private $files = array();
|
| 571 |
+
private $recurring;
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
public function addTag($tag){
|
| 575 |
+
$this->tags[] = $tag;
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
public function setLayout($code){
|
| 579 |
+
$this->layout = $code;
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
public function setRecurring($recurring){
|
| 583 |
+
$this->recurring = strtolower($recurring);
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
public function addItem($params){
|
| 587 |
+
$item['code'] = (isset($params['code']) ? $params['code'] : "");
|
| 588 |
+
$item['description'] = $params['description'];
|
| 589 |
+
$item['price'] = $params['price'];
|
| 590 |
+
$item['price_incl'] = $params['price_incl'];
|
| 591 |
+
$item['price_vat'] = $params['price_vat'];
|
| 592 |
+
$item['vatpercentage'] = $params['vatpercentage'];
|
| 593 |
+
$item['discount'] = $params['discount'];
|
| 594 |
+
$item['quantity'] = $params['quantity'];
|
| 595 |
+
$item['categories'] = $params['categories'];
|
| 596 |
+
$this->items[] = $item;
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
public function addFile($name, $url){
|
| 600 |
+
$this->files[] = array('url' => $url, 'name' => $name);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
private function buildXML($mode){
|
| 604 |
+
$string = '<request>
|
| 605 |
+
<login mode="'. $mode .'">
|
| 606 |
+
<username><![CDATA['.$this->username.']]></username>
|
| 607 |
+
<password><![CDATA['.$this->password.']]></password>
|
| 608 |
+
<identifier><![CDATA[Magento_Rewrite.201]]></identifier>
|
| 609 |
+
<invoice_id><![CDATA['.$this->invoice_id.']]></invoice_id>
|
| 610 |
+
</login>
|
| 611 |
+
<document>
|
| 612 |
+
<companyname><![CDATA['. $this->companyname .']]></companyname>
|
| 613 |
+
<firstname><![CDATA['. $this->firstname .']]></firstname>
|
| 614 |
+
<lastname><![CDATA['. $this->lastname .']]></lastname>
|
| 615 |
+
<email><![CDATA['. $this->email .']]></email>
|
| 616 |
+
<phone><![CDATA['. $this->phone .']]></phone>
|
| 617 |
+
<address><![CDATA['. $this->address .']]></address>
|
| 618 |
+
<zipcode><![CDATA['. $this->zipcode .']]></zipcode>
|
| 619 |
+
<city><![CDATA['. $this->city .']]></city>
|
| 620 |
+
<country><![CDATA['. $this->country .']]></country>
|
| 621 |
+
|
| 622 |
+
<delivery_companyname><![CDATA['. $this->delivery_companyname .']]></delivery_companyname>
|
| 623 |
+
<delivery_firstname><![CDATA['. $this->delivery_firstname .']]></delivery_firstname>
|
| 624 |
+
<delivery_lastname><![CDATA['. $this->delivery_lastname .']]></delivery_lastname>
|
| 625 |
+
<delivery_address><![CDATA['. $this->delivery_address .']]></delivery_address>
|
| 626 |
+
<delivery_zipcode><![CDATA['. $this->delivery_zipcode .']]></delivery_zipcode>
|
| 627 |
+
<delivery_city><![CDATA['. $this->delivery_city .']]></delivery_city>
|
| 628 |
+
<delivery_country><![CDATA['. $this->delivery_country .']]></delivery_country>
|
| 629 |
+
|
| 630 |
+
<vat><![CDATA['. $this->vatnumber .']]></vat>
|
| 631 |
+
<recurring><![CDATA['. $this->recurring .']]></recurring>
|
| 632 |
+
<remark><![CDATA['. $this->remark .']]></remark>
|
| 633 |
+
<layout><![CDATA['. $this->layout .']]></layout>
|
| 634 |
+
<action><![CDATA['. $this->action .']]></action>
|
| 635 |
+
<calculation_method><![CDATA['. $this->calculation_method .']]></calculation_method>
|
| 636 |
+
<tags>';
|
| 637 |
+
foreach($this->tags as $tag){
|
| 638 |
+
$string .= '<tag><![CDATA['. $tag .']]></tag>';
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
$string .= '</tags>
|
| 642 |
+
<items>';
|
| 643 |
+
foreach($this->items as $i){
|
| 644 |
+
|
| 645 |
+
$string .= '<item>
|
| 646 |
+
<code><![CDATA['. $i['code'] .']]></code>
|
| 647 |
+
<quantity><![CDATA['. $i['quantity'] .']]></quantity>
|
| 648 |
+
<description><![CDATA['. $i['description'] .']]></description>
|
| 649 |
+
<price>'. $i['price'] .'</price>
|
| 650 |
+
<price_incl>'. $i['price_incl'] .'</price_incl>
|
| 651 |
+
<price_vat>'. $i['price_vat'] .'</price_vat>
|
| 652 |
+
<vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
|
| 653 |
+
<discount>'. $i['discount'] .'</discount>
|
| 654 |
+
<categories><![CDATA['. $i['categories'] .']]></categories>
|
| 655 |
+
|
| 656 |
+
</item>';
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
$string .= '</items>
|
| 660 |
+
<files>';
|
| 661 |
+
foreach($this->files as $f){
|
| 662 |
+
$string .= '<file url="'.$f['url'].'">'.$f['name'].'</file>';
|
| 663 |
+
}
|
| 664 |
+
$string .= '</files>
|
| 665 |
+
</document>
|
| 666 |
+
</request>';
|
| 667 |
+
return $string;
|
| 668 |
+
}
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
class qPaymentRequest extends qApi{
|
| 672 |
+
|
| 673 |
+
public $method;
|
| 674 |
+
public $amount;
|
| 675 |
+
public $date;
|
| 676 |
+
|
| 677 |
+
private function buildXML(){
|
| 678 |
+
$string = '<request>
|
| 679 |
+
<login mode="addPayment">
|
| 680 |
+
<username><![CDATA['.$this->username.']]></username>
|
| 681 |
+
<password><![CDATA['.$this->password.']]></password>
|
| 682 |
+
<identifier><![CDATA[Magento_Rewrite.201]]></identifier>
|
| 683 |
+
<invoice_id><![CDATA['.$this->invoice_id.']]></invoice_id>
|
| 684 |
+
</login>
|
| 685 |
+
<payment>
|
| 686 |
+
<amount><![CDATA['.$this->amount.']]></amount>
|
| 687 |
+
<method><![CDATA['.$this->method.']]></method>
|
| 688 |
+
<date><![CDATA['.$this->date.']]></date>
|
| 689 |
+
</payment>
|
| 690 |
+
</request>';
|
| 691 |
+
}
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
class qApi{
|
| 695 |
+
|
| 696 |
+
protected $gateway = '';
|
| 697 |
+
private $username;
|
| 698 |
+
private $password;
|
| 699 |
+
|
| 700 |
+
function __construct($username, $password, $store_id){
|
| 701 |
+
$this->username = $username;
|
| 702 |
+
$this->password = $password;
|
| 703 |
+
$this->recurring = 'none';
|
| 704 |
+
|
| 705 |
+
$varPath = 'invoice_options/invoice/api_url';
|
| 706 |
+
$this->gateway = Mage::getStoreConfig($varPath,$store_id);
|
| 707 |
+
}
|
| 708 |
+
|
| 709 |
+
public function addItem($params){
|
| 710 |
+
$item['code'] = (isset($params['code']) ? $params['code'] : "");
|
| 711 |
+
$item['description'] = $params['description'];
|
| 712 |
+
$item['price'] = $params['price'];
|
| 713 |
+
$item['price_incl'] = $params['price_incl'];
|
| 714 |
+
$item['price_vat'] = $params['price_vat'];
|
| 715 |
+
$item['vatpercentage'] = $params['vatpercentage'];
|
| 716 |
+
$item['discount'] = $params['discount'];
|
| 717 |
+
$item['quantity'] = $params['quantity'];
|
| 718 |
+
$item['categories'] = $params['categories'];
|
| 719 |
+
$this->items[] = $item;
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
public function sendRequest() {
|
| 723 |
+
$content = "<?xml version='1.0' encoding='UTF-8'?>";
|
| 724 |
+
$content .= $this->buildXML();
|
| 725 |
+
|
| 726 |
+
$headers = array("Content-type: application/atom+xml");
|
| 727 |
+
$ch = curl_init();
|
| 728 |
+
curl_setopt($ch, CURLOPT_URL, $this->gateway );
|
| 729 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 730 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
| 731 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
| 732 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
| 733 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
| 734 |
+
$data = curl_exec($ch);
|
| 735 |
+
if (curl_errno($ch)) {
|
| 736 |
+
print curl_error($ch);
|
| 737 |
+
} else {
|
| 738 |
+
curl_close($ch);
|
| 739 |
+
}
|
| 740 |
+
if($data == 1){
|
| 741 |
+
return true;
|
| 742 |
+
}else{
|
| 743 |
+
return false;
|
| 744 |
+
}
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
}
|
| 748 |
+
?>
|
app/code/community/Qinvoice/Connect/Model/Rewrite/Order.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Qinvoice_Connect_Model_Rewrite_Order extends Mage_Sales_Model_Order{
|
| 4 |
+
public function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false){
|
| 5 |
+
// attempt to set the specified state
|
| 6 |
+
// tenta definir o status especificado
|
| 7 |
+
if ($shouldProtectState) {
|
| 8 |
+
if ($this->isStateProtected($state)) {
|
| 9 |
+
Mage::throwException(
|
| 10 |
+
Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state)
|
| 11 |
+
);
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
$this->setData('state', $state);
|
| 15 |
+
|
| 16 |
+
// add status history
|
| 17 |
+
if ($status) {
|
| 18 |
+
if ($status === true) {
|
| 19 |
+
$status = $this->getConfig()->getStateDefaultStatus($state);
|
| 20 |
+
}
|
| 21 |
+
$this->setStatus($status);
|
| 22 |
+
$history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
|
| 23 |
+
$history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
Mage::log("Store ID: ". $this->getStoreId());
|
| 27 |
+
|
| 28 |
+
$varActionPath = 'invoice_options/invoice/invoice_trigger';
|
| 29 |
+
$trigger = Mage::getStoreConfig($varActionPath,$this->getStoreId());
|
| 30 |
+
|
| 31 |
+
Mage::log("Config: ". $trigger);
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
// GETTING TRIGGER SETTING
|
| 35 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 36 |
+
$varPath = 'invoice_options/invoice/api_username';
|
| 37 |
+
$prefix = Mage::getConfig()->getTablePrefix();
|
| 38 |
+
$resultTwo = $db->query("SELECT value FROM {$prefix}core_config_data WHERE path LIKE '".$varPath."'");
|
| 39 |
+
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 40 |
+
$varOnOrder = $rowTwo['value'];
|
| 41 |
+
|
| 42 |
+
if($varOnOrder == 'complete' && $order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
|
| 43 |
+
$this->createInvoiceForQinvoice($order->getId(), false);
|
| 44 |
+
}else{
|
| 45 |
+
return true;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
switch($state){
|
| 49 |
+
case 'complete': // shipped?
|
| 50 |
+
if($trigger == 'complete'){
|
| 51 |
+
// send request
|
| 52 |
+
}
|
| 53 |
+
break;
|
| 54 |
+
case 'processing': // after payment?
|
| 55 |
+
if($trigger == 'payment'){
|
| 56 |
+
// send request
|
| 57 |
+
}
|
| 58 |
+
// update invoice
|
| 59 |
+
break;
|
| 60 |
+
case 'new': // new order
|
| 61 |
+
if($trigger == 'order'){
|
| 62 |
+
// send request
|
| 63 |
+
}
|
| 64 |
+
break;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
Mage::dispatchEvent('qinvoice_connect_order_status_change', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified));
|
| 68 |
+
Mage::log("Qinvoice_Connect_Model_Rewrite_Order Changing order to STATE ".$state." STATUS ".$status);
|
| 69 |
+
return $this;
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
?>
|
app/code/community/Qinvoice/Connect/Model/Source/Trigger.php
CHANGED
|
@@ -5,8 +5,8 @@ class Qinvoice_Connect_Model_Source_Trigger
|
|
| 5 |
{
|
| 6 |
return array(
|
| 7 |
array('value' => 'order', 'label' =>'On every order'),
|
| 8 |
-
array('value' => 'payment', 'label' => 'Only on successful payment')
|
| 9 |
-
|
| 10 |
);
|
| 11 |
}
|
| 12 |
}
|
| 5 |
{
|
| 6 |
return array(
|
| 7 |
array('value' => 'order', 'label' =>'On every order'),
|
| 8 |
+
array('value' => 'payment', 'label' => 'Only on successful payment'),
|
| 9 |
+
array('value' => 'complete', 'label' => 'When order is marked complete')
|
| 10 |
);
|
| 11 |
}
|
| 12 |
}
|
app/code/community/Qinvoice/Connect/Module/Block/Webshop_Secret_Renderer.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Qinvoice_Connect_Module_Block_Webshop_Secret_Renderer extends Mage_Adminhtml_Block_System_Config_Form_Field{
|
| 3 |
+
protected function _getElementHtml($element) {
|
| 4 |
+
if (1==1) {
|
| 5 |
+
$element->setDisabled('disabled');
|
| 6 |
+
}
|
| 7 |
+
return parent::_getElementHtml($element);
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
?>
|
app/code/community/Qinvoice/Connect/Module/Webshop_Secret_Renderer.php
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Qinvoice_Connect_Module_Block_Webshop_Secret_Renderer extends Mage_Adminhtml_Block_System_Config_Form_Field{
|
| 3 |
+
protected function _getElementHtml($element) {
|
| 4 |
+
if (1==1) {
|
| 5 |
+
$element->setDisabled('disabled');
|
| 6 |
+
}
|
| 7 |
+
return parent::_getElementHtml($element);
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
?>
|
app/code/community/Qinvoice/Connect/etc/config.xml
CHANGED
|
@@ -3,16 +3,50 @@
|
|
| 3 |
<config>
|
| 4 |
<modules>
|
| 5 |
<Qinvoice_Connect>
|
| 6 |
-
<version>1.1
|
| 7 |
</Qinvoice_Connect>
|
| 8 |
</modules>
|
| 9 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
<models>
|
| 11 |
<invoice>
|
| 12 |
<class>Qinvoice_Connect_Model</class>
|
| 13 |
</invoice>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
</models>
|
| 15 |
<events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
<sales_order_place_after>
|
| 17 |
<observers>
|
| 18 |
<connect>
|
| 3 |
<config>
|
| 4 |
<modules>
|
| 5 |
<Qinvoice_Connect>
|
| 6 |
+
<version>2.1.1</version>
|
| 7 |
</Qinvoice_Connect>
|
| 8 |
</modules>
|
| 9 |
<global>
|
| 10 |
+
<blocks>
|
| 11 |
+
<invoice>
|
| 12 |
+
<class>Qinvoice_Connect_Block</class>
|
| 13 |
+
</invoice>
|
| 14 |
+
<invoice_adminhtml>
|
| 15 |
+
<class>Qinvoice_Connect_Block_Adminhtml</class>
|
| 16 |
+
</invoice_adminhtml>
|
| 17 |
+
</blocks>
|
| 18 |
<models>
|
| 19 |
<invoice>
|
| 20 |
<class>Qinvoice_Connect_Model</class>
|
| 21 |
</invoice>
|
| 22 |
+
<sales>
|
| 23 |
+
<rewrite>
|
| 24 |
+
<order>Qinvoice_Connect_Model_Rewrite_Order</order>
|
| 25 |
+
</rewrite>
|
| 26 |
+
</sales>
|
| 27 |
+
<modelrewrite>
|
| 28 |
+
<class>Qinvoice_Connect_Model_Rewrite</class>
|
| 29 |
+
</modelrewrite>
|
| 30 |
</models>
|
| 31 |
<events>
|
| 32 |
+
<controller_front_init_before>
|
| 33 |
+
<observers>
|
| 34 |
+
<connect>
|
| 35 |
+
<class>invoice/order_observer</class>
|
| 36 |
+
<method>qinvoiceCall</method>
|
| 37 |
+
</connect>
|
| 38 |
+
</observers>
|
| 39 |
+
</controller_front_init_before>
|
| 40 |
+
<qinvoice_connect_order_status_change>
|
| 41 |
+
<observers>
|
| 42 |
+
<qinvoice_connect_model_rewrite>
|
| 43 |
+
<type>singleton</type>
|
| 44 |
+
<class>modelrewrite/observer</class>
|
| 45 |
+
<method>changeStateOrder</method>
|
| 46 |
+
</qinvoice_connect_model_rewrite>
|
| 47 |
+
</observers>
|
| 48 |
+
</qinvoice_connect_order_status_change>
|
| 49 |
+
|
| 50 |
<sales_order_place_after>
|
| 51 |
<observers>
|
| 52 |
<connect>
|
app/code/community/Qinvoice/Connect/etc/system.xml
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
<tabs>
|
| 4 |
-
<qinvoice translate="label" module="
|
| 5 |
<label>Qinvoice Connect</label>
|
| 6 |
<sort_order>300</sort_order>
|
| 7 |
</qinvoice>
|
| 8 |
</tabs>
|
| 9 |
<sections>
|
| 10 |
-
<invoice_options translate="label" module="
|
| 11 |
<label>Qinvoice Configuration</label>
|
| 12 |
<tab>qinvoice</tab>
|
| 13 |
<frontend_type>text</frontend_type>
|
|
@@ -135,6 +135,16 @@
|
|
| 135 |
<show_in_store>1</show_in_store>
|
| 136 |
<comment><![CDATA[Select one or more attributes to show on product line]]></comment>
|
| 137 |
</product_attributes>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
</fields>
|
| 139 |
</invoice>
|
| 140 |
</groups>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<config>
|
| 3 |
<tabs>
|
| 4 |
+
<qinvoice translate="label" module="invoice">
|
| 5 |
<label>Qinvoice Connect</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>
|
| 135 |
<show_in_store>1</show_in_store>
|
| 136 |
<comment><![CDATA[Select one or more attributes to show on product line]]></comment>
|
| 137 |
</product_attributes>
|
| 138 |
+
<webshop_secret translate="label">
|
| 139 |
+
<label>Webshop secret</label>
|
| 140 |
+
<frontend_type>text</frontend_type>
|
| 141 |
+
<frontend_model>invoice_adminhtml/system_config_form_field_webshopsecret</frontend_model>
|
| 142 |
+
<sort_order>12</sort_order>
|
| 143 |
+
<show_in_default>1</show_in_default>
|
| 144 |
+
<show_in_website>1</show_in_website>
|
| 145 |
+
<show_in_store>1</show_in_store>
|
| 146 |
+
<comment><![CDATA[e.g. Your secret key. Used for stock synchronisation.]]></comment>
|
| 147 |
+
</webshop_secret>
|
| 148 |
</fields>
|
| 149 |
</invoice>
|
| 150 |
</groups>
|
app/code/community/Qinvoice/Invoice/Order/Observer.php
DELETED
|
@@ -1,440 +0,0 @@
|
|
| 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 |
-
|
| 194 |
-
$price = $arrData[$i]['base_price'];
|
| 195 |
-
$price_incl = round(((($arrData[$i]['base_price']*$arrData[$i]['qty_ordered'])+$arrData[$i]['tax_amount'])/$arrData[$i]['qty_ordered']));
|
| 196 |
-
$price_vat = ($arrData[$i]['tax_amount']/$arrData[$i]['qty_ordered']);
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
$discount = 0;
|
| 200 |
-
if($invoice->calculation_method == 'incl'){
|
| 201 |
-
// calculate discount over gross price
|
| 202 |
-
$discount = ($arrData[$i]['base_discount_amount']/($price_incl*$arrData[$i]['qty_ordered']))*100;
|
| 203 |
-
}else{
|
| 204 |
-
// calculate discount over net price
|
| 205 |
-
$discount = ($arrData[$i]['base_discount_amount']/($price*$arrData[$i]['qty_ordered']))*100;
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
$params = array(
|
| 210 |
-
'description' => $arrData[$i]['name'] ."\n". $varDescription,
|
| 211 |
-
'price' => $price*100,
|
| 212 |
-
'price_incl' => $price_incl*100,
|
| 213 |
-
'price_vat' => $price_vat*100,
|
| 214 |
-
'vatpercentage' => trim(number_format($arrData[$i]['tax_percent'],2,'.', ''))*100,
|
| 215 |
-
'discount' => $discount*100,
|
| 216 |
-
'quantity' => $arrData[$i]['qty_ordered']*100,
|
| 217 |
-
'categories' => ''
|
| 218 |
-
);
|
| 219 |
-
//mail('casper@expertnetwork.nl', 'vat', $arrData[$i]['tax_percent']);
|
| 220 |
-
$invoice->addItem($params);
|
| 221 |
-
|
| 222 |
-
}
|
| 223 |
-
if($rowOne['shipping_amount'] > 0)
|
| 224 |
-
{
|
| 225 |
-
$params = array(
|
| 226 |
-
'description' => trim($rowOne['shipping_description']),
|
| 227 |
-
'price' => $rowOne['shipping_amount']*100,
|
| 228 |
-
'vatpercentage' => ($rowOne['shipping_tax_amount']/$rowOne['shipping_amount'])*100,
|
| 229 |
-
'discount' => 0,
|
| 230 |
-
'quantity' => 100,
|
| 231 |
-
'categories' => 'shipping'
|
| 232 |
-
);
|
| 233 |
-
|
| 234 |
-
$invoice->addItem($params);
|
| 235 |
-
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
$result = $invoice->sendRequest();
|
| 240 |
-
if($result == 1){
|
| 241 |
-
//notify_to_admin('Casper Mekel','casper@newday.sk','Invoice generated!');
|
| 242 |
-
}else{
|
| 243 |
-
//notify_to_admin('Casper Mekel','casper@newday.sk','Something went wrong!');
|
| 244 |
-
}
|
| 245 |
-
return true;
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
//$curlInvoiveResult = $this->sendCurlRequest($createInvoiceXML);
|
| 249 |
-
|
| 250 |
-
// GETTING SEND MAIL SETTING
|
| 251 |
-
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 252 |
-
$varPath = 'invoice_options/invoice/send_mail';
|
| 253 |
-
$resultTwo = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varPath."'");
|
| 254 |
-
$rowTwo = $resultTwo->fetch(PDO::FETCH_ASSOC);
|
| 255 |
-
$varSendMailFlag = $rowTwo['value'];
|
| 256 |
-
|
| 257 |
-
if($varSendMailFlag && 1==2)
|
| 258 |
-
{
|
| 259 |
-
$xml = stripslashes($curlInvoiveResult);
|
| 260 |
-
$objXml = new SimpleXMLElement($xml);
|
| 261 |
-
$arrParamList = $this->objectsIntoArray($objXml);
|
| 262 |
-
|
| 263 |
-
if($arrParamList['@attributes']['status'] == '200')
|
| 264 |
-
{
|
| 265 |
-
$varInvoiceID = $arrParamList['invoice_id'];
|
| 266 |
-
|
| 267 |
-
$varSendInvoiceXml = '<?xml version="1.0" encoding="utf-8"?>
|
| 268 |
-
<request method="sendInvoiceMail">
|
| 269 |
-
<invoice_id>'.$varInvoiceID.'</invoice_id>
|
| 270 |
-
</request>';
|
| 271 |
-
$curlInvoiceSendResult = $this->sendCurlRequest($varSendInvoiceXml);
|
| 272 |
-
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
}
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
public function notify_to_admin($name, $email, $msg)
|
| 279 |
-
{
|
| 280 |
-
$varSubject = 'Qinvoice Notification';
|
| 281 |
-
|
| 282 |
-
//Mage::log($msg);
|
| 283 |
-
|
| 284 |
-
$mail = Mage::getModel('core/email');
|
| 285 |
-
$mail->setToName($name);
|
| 286 |
-
$mail->setToEmail($email);
|
| 287 |
-
$mail->setBody($msg);
|
| 288 |
-
$mail->setSubject($varSubject);
|
| 289 |
-
$mail->setFromEmail("support@qinvoice.com");
|
| 290 |
-
$mail->setFromName("Qinvoice Development");
|
| 291 |
-
$mail->setType('text');
|
| 292 |
-
$mail->send();
|
| 293 |
-
}
|
| 294 |
-
}
|
| 295 |
-
|
| 296 |
-
class qinvoice{
|
| 297 |
-
|
| 298 |
-
protected $gateway = '';
|
| 299 |
-
private $username;
|
| 300 |
-
private $password;
|
| 301 |
-
|
| 302 |
-
public $companyname;
|
| 303 |
-
public $contactname;
|
| 304 |
-
public $email;
|
| 305 |
-
public $address;
|
| 306 |
-
public $city;
|
| 307 |
-
public $country;
|
| 308 |
-
public $vatnumber;
|
| 309 |
-
public $remark;
|
| 310 |
-
public $paid;
|
| 311 |
-
public $send;
|
| 312 |
-
|
| 313 |
-
public $layout;
|
| 314 |
-
|
| 315 |
-
private $tags = array();
|
| 316 |
-
private $items = array();
|
| 317 |
-
private $files = array();
|
| 318 |
-
private $recurring;
|
| 319 |
-
|
| 320 |
-
function __construct($username, $password){
|
| 321 |
-
$this->username = $username;
|
| 322 |
-
$this->password = $password;
|
| 323 |
-
$this->recurring = 'none';
|
| 324 |
-
|
| 325 |
-
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 326 |
-
|
| 327 |
-
// GETTING API URL
|
| 328 |
-
$varURLPath = 'invoice_options/invoice/api_url';
|
| 329 |
-
$resultURL = $db->query("SELECT value FROM core_config_data WHERE path LIKE '".$varURLPath."'");
|
| 330 |
-
$rowURL = $resultURL->fetch(PDO::FETCH_ASSOC);
|
| 331 |
-
$apiURL = $rowURL['value'];
|
| 332 |
-
|
| 333 |
-
$this->gateway = $apiURL;
|
| 334 |
-
}
|
| 335 |
-
|
| 336 |
-
public function addTag($tag){
|
| 337 |
-
$this->tags[] = $tag;
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
public function setLayout($code){
|
| 341 |
-
$this->layout = $code;
|
| 342 |
-
}
|
| 343 |
-
|
| 344 |
-
public function setRecurring($recurring){
|
| 345 |
-
$this->recurring = strtolower($recurring);
|
| 346 |
-
}
|
| 347 |
-
|
| 348 |
-
public function addItem($params){
|
| 349 |
-
$item['description'] = $params['description'];
|
| 350 |
-
$item['price'] = $params['price'];
|
| 351 |
-
$item['vatpercentage'] = $params['vatpercentage'];
|
| 352 |
-
$item['discount'] = $params['discount'];
|
| 353 |
-
$item['quantity'] = $params['quantity'];
|
| 354 |
-
$item['categories'] = $params['categories'];
|
| 355 |
-
$this->items[] = $item;
|
| 356 |
-
}
|
| 357 |
-
|
| 358 |
-
public function addFile($name, $url){
|
| 359 |
-
$this->files[] = array('url' => $url, 'name' => $name);
|
| 360 |
-
}
|
| 361 |
-
|
| 362 |
-
public function sendRequest() {
|
| 363 |
-
$content = "<?xml version='1.0' encoding='UTF-8'?>";
|
| 364 |
-
$content .= $this->buildXML();
|
| 365 |
-
|
| 366 |
-
$headers = array("Content-type: application/atom+xml");
|
| 367 |
-
$ch = curl_init();
|
| 368 |
-
curl_setopt($ch, CURLOPT_URL, $this->gateway );
|
| 369 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 370 |
-
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
|
| 371 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
| 372 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
| 373 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
| 374 |
-
$data = curl_exec($ch);
|
| 375 |
-
if (curl_errno($ch)) {
|
| 376 |
-
print curl_error($ch);
|
| 377 |
-
} else {
|
| 378 |
-
curl_close($ch);
|
| 379 |
-
}
|
| 380 |
-
if($data == 1){
|
| 381 |
-
return true;
|
| 382 |
-
}else{
|
| 383 |
-
return false;
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
}
|
| 387 |
-
|
| 388 |
-
private function buildXML(){
|
| 389 |
-
$string = '<request>
|
| 390 |
-
<login mode="newInvoice">
|
| 391 |
-
<username>'.$this->username.'</username>
|
| 392 |
-
<password>'.$this->password.'</password>
|
| 393 |
-
</login>
|
| 394 |
-
<invoice>
|
| 395 |
-
<companyname>'. $this->companyname .'</companyname>
|
| 396 |
-
<contactname>'. $this->contactname .'</contactname>
|
| 397 |
-
<email>'. $this->email .'</email>
|
| 398 |
-
<address>'. $this->address .'</address>
|
| 399 |
-
<zipcode>'. $this->zipcode .'</zipcode>
|
| 400 |
-
<city>'. $this->city .'</city>
|
| 401 |
-
<country>'. $this->country .'</country>
|
| 402 |
-
<vat>'. $this->vatnumber .'</vat>
|
| 403 |
-
<recurring>'. $this->recurring .'</recurring>
|
| 404 |
-
<remark>'. $this->remark .'</remark>
|
| 405 |
-
<layout>'. $this->layout .'</layout>
|
| 406 |
-
<paid>'. $this->paid .'</paid>
|
| 407 |
-
<send>'. $this->send .'</send>
|
| 408 |
-
<tags>';
|
| 409 |
-
foreach($this->tags as $tag){
|
| 410 |
-
$string .= '<tag>'. $tag .'</tag>';
|
| 411 |
-
}
|
| 412 |
-
|
| 413 |
-
$string .= '</tags>
|
| 414 |
-
<items>';
|
| 415 |
-
foreach($this->items as $i){
|
| 416 |
-
|
| 417 |
-
$string .= '<item>
|
| 418 |
-
<quantity>'. $i['quantity'] .'</quantity>
|
| 419 |
-
<description>'. $i['description'] .'</description>
|
| 420 |
-
<price>'. $i['price'] .'</price>
|
| 421 |
-
<vatpercentage>'. $i['vatpercentage'] .'</vatpercentage>
|
| 422 |
-
<discount>'. $i['discount'] .'</discount>
|
| 423 |
-
<categories>'. $i['categories'] .'</categories>
|
| 424 |
-
|
| 425 |
-
</item>';
|
| 426 |
-
}
|
| 427 |
-
|
| 428 |
-
$string .= '</items>
|
| 429 |
-
<files>';
|
| 430 |
-
foreach($this->files as $f){
|
| 431 |
-
$string .= '<file url="'.$f['url'].'">'.$f['name'].'</file>';
|
| 432 |
-
}
|
| 433 |
-
$string .= '</files>
|
| 434 |
-
</invoice>
|
| 435 |
-
</request>';
|
| 436 |
-
return $string;
|
| 437 |
-
}
|
| 438 |
-
}
|
| 439 |
-
|
| 440 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Qinvoice_Connect</name>
|
| 4 |
-
<version>1.1
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -10,9 +10,9 @@
|
|
| 10 |
<description>Invoices can be generated upon a successful payment or order and will be added to your administration. Q-invoice offers you the freedom to run multiple webshops or venues but still have your bookkeeping together at one place. Generate invoices in a layout of your choosing for maximal recognition, upload bankstatements and process payment with the click of your mouse. www.q-invoice.com</description>
|
| 11 |
<notes>Fixed issue with multiple products same SKU, different custom option</notes>
|
| 12 |
<authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
|
| 13 |
-
<date>
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magecommunity"><dir name="Qinvoice"><file name="CHANGELOG" hash="
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies><required><php><min>5.1.0</min><max>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Qinvoice_Connect</name>
|
| 4 |
+
<version>2.1.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 10 |
<description>Invoices can be generated upon a successful payment or order and will be added to your administration. Q-invoice offers you the freedom to run multiple webshops or venues but still have your bookkeeping together at one place. Generate invoices in a layout of your choosing for maximal recognition, upload bankstatements and process payment with the click of your mouse. www.q-invoice.com</description>
|
| 11 |
<notes>Fixed issue with multiple products same SKU, different custom option</notes>
|
| 12 |
<authors><author><name>Casper Mekel</name><user>caspermekel</user><email>info@q-invoice.com</email></author></authors>
|
| 13 |
+
<date>2016-10-06</date>
|
| 14 |
+
<time>16:56:24</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Qinvoice"><file name="CHANGELOG" hash="f3fe0ee8957ad7362fe0961114678243"/><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Webshopsecret.php" hash="2157af67cdcf51307bde5efe5cee46d2"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="ccb4b09674319e8b20e9c06a94adfa38"/></dir><dir name="Model"><dir name="Order"><file name="Observer.Boerdereike.php" hash="141eebc8865ff9c7e231d85df1432e96"/><file name="Observer.max4home.php" hash="1f9b754b2184c0079a0d53ecc2d3fdd8"/><file name="Observer.php" hash="b7828acc3cf5bef0f76e74a098e56255"/></dir><dir name="Rewrite"><file name="Observer.php" hash="769e4618f69697b8e3ccddbb9b446fea"/><file name="Order.php" hash="a56c5c21b08c783b2a1435d21d0b2d40"/></dir><dir name="Source"><file name="Attribute.php" hash="72f35ffb8cd873d2c5e1e448ff4bf4e2"/><file name="Invoice.php" hash="4661f369f7e116fd761e5fffac9efeaf"/><file name="Method.php" hash="ac6891fc7e403250b24f5b0f2d6199bc"/><file name="Relation.php" hash="89ab031937b846ab5f0bcac7ccaa31b7"/><file name="Trigger.php" hash="366ba803beda9471e48d5d6da3baa20a"/></dir></dir><dir name="Module"><dir name="Block"><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><file name="Webshop_Secret_Renderer.php" hash="53039328186fd5c9fe15a3f55b2f8d16"/></dir><dir name="etc"><file name="config.xml" hash="46d4577f78a57d533c5292ab74dac0ec"/><file name="system.xml" hash="ed502b22f018d096417f47e62dbc31a8"/></dir><file name="readme.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qinvoice_Connect.xml" hash="fbedefa4e926092705c6941ad28f51f8"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><extension><name>curl</name><min>5.1</min><max>6.0</max></extension></required></dependencies>
|
| 18 |
</package>
|
