Bluejalappeno_Orderexport - Version 2.8.0

Version Notes

Latest version including format changes for street address and multiple currencies

Download this release

Release Info

Developer Genevieve Eddison
Extension Bluejalappeno_Orderexport
Version 2.8.0
Comparing to
See all releases


Version 2.8.0

app/code/community/Bluejalappeno/Orderexport/Block/Sales/Order/Grid.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Genevieve Eddison <sales@bluejalappeno.com>
26
+ * */
27
+ class Bluejalappeno_Orderexport_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
28
+ {
29
+ protected function _prepareMassaction()
30
+ {
31
+ parent::_prepareMassaction();
32
+ if (Mage::getStoreConfig("order_export/export_orders/active")) {
33
+
34
+ $this->getMassactionBlock()->addItem('orderexport', array(
35
+ 'label'=> Mage::helper('sales')->__('Export orders'),
36
+ 'url' => $this->getUrl('*/sales_order_export/csvexport'),
37
+ ));
38
+ }
39
+ }
40
+ }
41
+ ?>
app/code/community/Bluejalappeno/Orderexport/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Bluejalappeno_Orderexport_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/community/Bluejalappeno/Orderexport/Model/Export/Abstractcsv.php ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2012 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Genevieve Eddison <sales@bluejalappeno.com>
26
+ * */
27
+ abstract class Bluejalappeno_Orderexport_Model_Export_Abstractcsv extends Mage_Core_Model_Abstract
28
+ {
29
+ /**
30
+ * Definition of abstract method to export orders to a file in a specific format in var/export.
31
+ *
32
+ * @param $orders List of orders of type Mage_Sales_Model_Order or order ids to export.
33
+ * @return String The name of the written file in var/export
34
+ */
35
+ abstract public function exportOrders($orders);
36
+
37
+ /**
38
+ * Returns the name of the website, store and store view the order was placed in.
39
+ *
40
+ * @param Mage_Sales_Model_Order $order The order to return info from
41
+ * @return String The name of the website, store and store view the order was placed in
42
+ */
43
+ protected function getStoreName($order)
44
+ {
45
+ $store = Mage::app()->getStore($order->getStoreId);
46
+ $name = array(
47
+ $store->getWebsite()->getName(),
48
+ $store->getGroup()->getName(),
49
+ $store->getName()
50
+ );
51
+ return implode(', ', $name);
52
+ }
53
+
54
+ /**
55
+ * Returns the payment method of the given order.
56
+ *
57
+ * @param Mage_Sales_Model_Order $order The order to return info from
58
+ * @return String The name of the payment method
59
+ */
60
+ protected function getPaymentMethod($order)
61
+ {
62
+ return $order->getPayment()->getMethod();
63
+ }
64
+
65
+ /**
66
+ * Returns the credit card type of the given order.
67
+ *
68
+ * @param Mage_Sales_Model_Order $order The order to return info from
69
+ * @return String The cc type
70
+ */
71
+ protected function getCcType($order)
72
+ {
73
+ return $order->getPayment()->getCcType();
74
+ }
75
+
76
+ /**
77
+ * Returns the shipping method of the given order.
78
+ *
79
+ * @param Mage_Sales_Model_Order $order The order to return info from
80
+ * @return String The name of the shipping method
81
+ */
82
+ protected function getShippingMethod($order)
83
+ {
84
+ if (!$order->getIsVirtual() && $order->getShippingDescription()) {
85
+ return $order->getShippingDescription();
86
+ }
87
+ else if (!$order->getIsVirtual() && $order->getShippingMethod()) {
88
+ return $order->getShippingMethod();
89
+ }
90
+ return '';
91
+ }
92
+
93
+ /**
94
+ * Returns the total quantity of ordered items of the given order.
95
+ *
96
+ * @param Mage_Sales_Model_Order $order The order to return info from
97
+ * @return int The total quantity of ordered items
98
+ */
99
+ protected function getTotalQtyItemsOrdered($order) {
100
+ $qty = 0;
101
+ $orderedItems = $order->getItemsCollection();
102
+ foreach ($orderedItems as $item)
103
+ {
104
+ if (!$item->isDummy()) {
105
+ $qty += (int)$item->getQtyOrdered();
106
+ }
107
+ }
108
+ return $qty;
109
+ }
110
+
111
+ /**
112
+ * Returns the sku of the given item dependant on the product type.
113
+ *
114
+ * @param Mage_Sales_Model_Order_Item $item The item to return info from
115
+ * @return String The sku
116
+ */
117
+ protected function getItemSku($item)
118
+ {
119
+ if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
120
+ return $item->getProductOptionByCode('simple_sku');
121
+ }
122
+ return $item->getSku();
123
+ }
124
+
125
+ /**
126
+ * Returns the options of the given item separated by comma(s) like this:
127
+ * option1: value1, option2: value2
128
+ *
129
+ * @param Mage_Sales_Model_Order_Item $item The item to return info from
130
+ * @return String The item options
131
+ */
132
+ protected function getItemOptions($item)
133
+ {
134
+ $options = '';
135
+ if ($orderOptions = $this->getItemOrderOptions($item)) {
136
+ foreach ($orderOptions as $_option) {
137
+ if (strlen($options) > 0) {
138
+ $options .= ', ';
139
+ }
140
+ $options .= $_option['label'].': '.$_option['value'];
141
+ }
142
+ }
143
+ return $options;
144
+ }
145
+
146
+ /**
147
+ * Returns all the product options of the given item including additional_options and
148
+ * attributes_info.
149
+ *
150
+ * @param Mage_Sales_Model_Order_Item $item The item to return info from
151
+ * @return Array The item options
152
+ */
153
+ protected function getItemOrderOptions($item)
154
+ {
155
+ $result = array();
156
+ if ($options = $item->getProductOptions()) {
157
+ if (isset($options['options'])) {
158
+ $result = array_merge($result, $options['options']);
159
+ }
160
+ if (isset($options['additional_options'])) {
161
+ $result = array_merge($result, $options['additional_options']);
162
+ }
163
+ if (!empty($options['attributes_info'])) {
164
+ $result = array_merge($options['attributes_info'], $result);
165
+ }
166
+ }
167
+ return $result;
168
+ }
169
+
170
+ /**
171
+ * Calculates and returns the grand total of an item including tax and excluding
172
+ * discount.
173
+ *
174
+ * @param Mage_Sales_Model_Order_Item $item The item to return info from
175
+ * @return Float The grand total
176
+ */
177
+ protected function getItemTotal($item)
178
+ {
179
+ return $item->getRowTotal() - $item->getDiscountAmount() + $item->getTaxAmount() + $item->getWeeeTaxAppliedRowAmount();
180
+ }
181
+
182
+ /**
183
+ * Formats a price by adding the currency symbol and formatting the number
184
+ * depending on the current locale.
185
+ *
186
+ * @param Float $price The price to format
187
+ * @param Mage_Sales_Model_Order $formatter The order to format the price by implementing the method formatPriceTxt($price)
188
+ * @return String The formatted price
189
+ */
190
+ protected function formatPrice($price, $formatter)
191
+ {
192
+ $price = $formatter->formatPriceTxt($price);
193
+ $price = str_replace('�', '', $price);
194
+ $price = str_replace('€', '�', $price);
195
+ return $price;
196
+ }
197
+
198
+ protected function getStreet($address) {
199
+ if ($address->getStreet2() != '') {
200
+ return $address->getStreet1() .' ' .$address->getStreet2();
201
+ }
202
+ else {
203
+ return $address->getStreet1();
204
+ }
205
+ }
206
+
207
+ }
208
+ ?>
app/code/community/Bluejalappeno/Orderexport/Model/Export/Csv.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Genevieve Eddison <sales@bluejalappeno.com>
26
+ * */
27
+ class Bluejalappeno_Orderexport_Model_Export_Csv extends Bluejalappeno_Orderexport_Model_Export_Abstractcsv
28
+ {
29
+ const ENCLOSURE = '"';
30
+ const DELIMITER = ',';
31
+
32
+ /**
33
+ * Concrete implementation of abstract method to export given orders to csv file in var/export.
34
+ *
35
+ * @param $orders List of orders of type Mage_Sales_Model_Order or order ids to export.
36
+ * @return String The name of the written csv file in var/export
37
+ */
38
+ public function exportOrders($orders)
39
+ {
40
+ $fileName = 'order_export_'.date("Ymd_His").'.csv';
41
+ $fp = fopen(Mage::getBaseDir('export').'/'.$fileName, 'w');
42
+
43
+ $this->writeHeadRow($fp);
44
+ foreach ($orders as $order) {
45
+ $order = Mage::getModel('sales/order')->load($order);
46
+ $this->writeOrder($order, $fp);
47
+ }
48
+
49
+ fclose($fp);
50
+
51
+ return $fileName;
52
+ }
53
+
54
+ /**
55
+ * Writes the head row with the column names in the csv file.
56
+ *
57
+ * @param $fp The file handle of the csv file
58
+ */
59
+ protected function writeHeadRow($fp)
60
+ {
61
+ fputcsv($fp, $this->getHeadRowValues(), self::DELIMITER, self::ENCLOSURE);
62
+ }
63
+
64
+ /**
65
+ * Writes the row(s) for the given order in the csv file.
66
+ * A row is added to the csv file for each ordered item.
67
+ *
68
+ * @param Mage_Sales_Model_Order $order The order to write csv of
69
+ * @param $fp The file handle of the csv file
70
+ */
71
+ protected function writeOrder($order, $fp)
72
+ {
73
+ $common = $this->getCommonOrderValues($order);
74
+
75
+ $orderItems = $order->getItemsCollection();
76
+ $itemInc = 0;
77
+ foreach ($orderItems as $item)
78
+ {
79
+ if (!$item->isDummy()) {
80
+ $record = array_merge($common, $this->getOrderItemValues($item, $order, ++$itemInc));
81
+ fputcsv($fp, $record, self::DELIMITER, self::ENCLOSURE);
82
+ }
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Returns the head column names.
88
+ *
89
+ * @return Array The array containing all column names
90
+ */
91
+ protected function getHeadRowValues()
92
+ {
93
+ return array(
94
+ 'Order Number',
95
+ 'Order Date',
96
+ 'Order Status',
97
+ 'Order Purchased From',
98
+ 'Order Payment Method',
99
+ 'Credit Card Type',
100
+ 'Order Shipping Method',
101
+ 'Order Subtotal',
102
+ 'Order Tax',
103
+ 'Order Shipping',
104
+ 'Order Discount',
105
+ 'Order Grand Total',
106
+ 'Order Base Grand Total',
107
+ 'Order Paid',
108
+ 'Order Refunded',
109
+ 'Order Due',
110
+ 'Total Qty Items Ordered',
111
+ 'Customer Name',
112
+ 'Customer Email',
113
+ 'Shipping Name',
114
+ 'Shipping Company',
115
+ 'Shipping Street',
116
+ 'Shipping Zip',
117
+ 'Shipping City',
118
+ 'Shipping State',
119
+ 'Shipping State Name',
120
+ 'Shipping Country',
121
+ 'Shipping Country Name',
122
+ 'Shipping Phone Number',
123
+ 'Billing Name',
124
+ 'Billing Company',
125
+ 'Billing Street',
126
+ 'Billing Zip',
127
+ 'Billing City',
128
+ 'Billing State',
129
+ 'Billing State Name',
130
+ 'Billing Country',
131
+ 'Billing Country Name',
132
+ 'Billing Phone Number',
133
+ 'Order Item Increment',
134
+ 'Item Name',
135
+ 'Item Status',
136
+ 'Item SKU',
137
+ 'Item Options',
138
+ 'Item Original Price',
139
+ 'Item Price',
140
+ 'Item Qty Ordered',
141
+ 'Item Qty Invoiced',
142
+ 'Item Qty Shipped',
143
+ 'Item Qty Canceled',
144
+ 'Item Qty Refunded',
145
+ 'Item Tax',
146
+ 'Item Discount',
147
+ 'Item Total'
148
+ );
149
+ }
150
+
151
+ /**
152
+ * Returns the values which are identical for each row of the given order. These are
153
+ * all the values which are not item specific: order data, shipping address, billing
154
+ * address and order totals.
155
+ *
156
+ * @param Mage_Sales_Model_Order $order The order to get values from
157
+ * @return Array The array containing the non item specific values
158
+ */
159
+ protected function getCommonOrderValues($order)
160
+ {
161
+ $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
162
+ $billingAddress = $order->getBillingAddress();
163
+ return array(
164
+ $order->getRealOrderId(),
165
+ Mage::helper('core')->formatDate($order->getCreatedAt(), 'medium', true),
166
+ $order->getStatus(),
167
+ $this->getStoreName($order),
168
+ $this->getPaymentMethod($order),
169
+ $this->getCcType($order),
170
+ $this->getShippingMethod($order),
171
+ $this->formatPrice($order->getData('subtotal'), $order),
172
+ $this->formatPrice($order->getData('tax_amount'), $order),
173
+ $this->formatPrice($order->getData('shipping_amount'), $order),
174
+ $this->formatPrice($order->getData('discount_amount'), $order),
175
+ $this->formatPrice($order->getData('grand_total'), $order),
176
+ $this->formatPrice($order->getData('base_grand_total'), $order),
177
+ $this->formatPrice($order->getData('total_paid'), $order),
178
+ $this->formatPrice($order->getData('total_refunded'), $order),
179
+ $this->formatPrice($order->getData('total_due'), $order),
180
+ $this->getTotalQtyItemsOrdered($order),
181
+ $order->getCustomerName(),
182
+ $order->getCustomerEmail(),
183
+ $shippingAddress ? $shippingAddress->getName() : '',
184
+ $shippingAddress ? $shippingAddress->getData("company") : '',
185
+ $shippingAddress ? $this->getStreet($shippingAddress) : '',
186
+ $shippingAddress ? $shippingAddress->getData("postcode") : '',
187
+ $shippingAddress ? $shippingAddress->getData("city") : '',
188
+ $shippingAddress ? $shippingAddress->getRegionCode() : '',
189
+ $shippingAddress ? $shippingAddress->getRegion() : '',
190
+ $shippingAddress ? $shippingAddress->getCountry() : '',
191
+ $shippingAddress ? $shippingAddress->getCountryModel()->getName() : '',
192
+ $shippingAddress ? $shippingAddress->getData("telephone") : '',
193
+ $billingAddress->getName(),
194
+ $billingAddress->getData("company"),
195
+ $this->getStreet($billingAddress),
196
+ $billingAddress->getData("postcode"),
197
+ $billingAddress->getData("city"),
198
+ $billingAddress->getRegionCode(),
199
+ $billingAddress->getRegion(),
200
+ $billingAddress->getCountry(),
201
+ $billingAddress->getCountryModel()->getName(),
202
+ $billingAddress->getData("telephone")
203
+ );
204
+ }
205
+
206
+ /**
207
+ * Returns the item specific values.
208
+ *
209
+ * @param Mage_Sales_Model_Order_Item $item The item to get values from
210
+ * @param Mage_Sales_Model_Order $order The order the item belongs to
211
+ * @return Array The array containing the item specific values
212
+ */
213
+ protected function getOrderItemValues($item, $order, $itemInc=1)
214
+ {
215
+
216
+ return array(
217
+ $itemInc,
218
+ $item->getName(),
219
+ $item->getStatus(),
220
+ $this->getItemSku($item),
221
+ $this->getItemOptions($item),
222
+ $this->formatPrice($item->getOriginalPrice(), $order),
223
+ $this->formatPrice($item->getData('price'), $order),
224
+ (int)$item->getQtyOrdered(),
225
+ (int)$item->getQtyInvoiced(),
226
+ (int)$item->getQtyShipped(),
227
+ (int)$item->getQtyCanceled(),
228
+ (int)$item->getQtyRefunded(),
229
+ $this->formatPrice($item->getTaxAmount(), $order),
230
+ $this->formatPrice($item->getDiscountAmount(), $order),
231
+ $this->formatPrice($this->getItemTotal($item), $order)
232
+ );
233
+ }
234
+ }
235
+ ?>
app/code/community/Bluejalappeno/Orderexport/Model/Export/Highrise.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Jonathan Feist <sales@bluejalappeno.com>
26
+ * */
27
+ class Bluejalappeno_Orderexport_Model_Export_Highrise extends Mage_Core_Model_Abstract
28
+ {
29
+
30
+ public function exportOrders($orders)
31
+ {
32
+ $this->highrise_url = Mage::getStoreConfig('order_export/highrise/highrise_url');
33
+ $this->api_token = Mage::getStoreConfig('order_export/highrise/highrise_api_key');
34
+ if ((strpos($this->highrise_url, "http://")!== 0) && (strpos($this->highrise_url, "https://")!== 0) ) {
35
+ Mage::throwException('Error: Incorrect URL for Highrise in configuration');
36
+ }
37
+
38
+ $this->highrise_notes = Mage::getStoreConfig('order_export/highrise/highrise_notes');
39
+ $this->highrise_background = Mage::getStoreConfig('order_export/highrise/highrise_background');
40
+ $results = array();
41
+ foreach ($orders as $order) {
42
+
43
+ $order = Mage::getModel('sales/order')->loadByAttribute('entity_id',$order);
44
+ $items = $order->getAllItems();
45
+ $customerDetails = $order->getBillingAddress();
46
+ $products = '';
47
+
48
+ for($i=0;$i<count($items);$i++)
49
+ {
50
+ $products .= $items[$i]->getName().', ';
51
+ }
52
+ $request = array('sFirstName'=>$customerDetails->getFirstname(),
53
+ 'sLastName'=>$customerDetails->getLastname(),
54
+ 'sCompany'=>$customerDetails->getCompany(),
55
+ 'sPhone'=>$customerDetails->getTelephone(),
56
+ 'sStreet'=>$customerDetails->getStreet(1),
57
+ 'sCity'=>$customerDetails->getCity(),
58
+ 'sState'=>$customerDetails->getRegion(),
59
+ 'sCountry'=>$customerDetails->getCountry(),
60
+ 'sZip'=>$customerDetails->getPostcode(),
61
+ 'sEmail'=>$order->getData('customer_email'),
62
+ 'sOrderNo'=>$order->getData('increment_id'),
63
+ 'sOrderDate'=>$order->getData('created_at'),
64
+ 'sProducts'=>$products, 'status' => '');
65
+
66
+ $request = $this->_query_contact($request);
67
+ $results[$request['sOrderNo']] = $request['status'];
68
+ }
69
+ return $results;
70
+ }
71
+
72
+ private function _query_contact($request){
73
+ $id = $this->_person_in_highrise($request);
74
+ if($id < 0){
75
+ $curl = curl_init($this->highrise_url.'/people.xml');
76
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
77
+ curl_setopt($curl,CURLOPT_USERPWD,$this->api_token.':x');
78
+
79
+ if($this->highrise_background){
80
+ $body = "OrderNo: ".$request['sOrderNo']."<br />
81
+ Date: ".$request['sOrderDate']."<br />
82
+ Products: ".$request['sProducts'];
83
+ }else{
84
+ $body = "";
85
+ }
86
+ curl_setopt($curl,CURLOPT_HTTPHEADER,Array("Content-Type: application/xml"));
87
+ curl_setopt($curl,CURLOPT_POST,true);
88
+ curl_setopt($curl,CURLOPT_POSTFIELDS,'<person>
89
+ <first-name>'.htmlspecialchars($request['sFirstName']).'</first-name>
90
+ <last-name>'.htmlspecialchars($request['sLastName']).'</last-name>
91
+ <background>'.htmlspecialchars($body).'</background>
92
+ <company-name>'.htmlspecialchars($request['sCompany']).'</company-name>
93
+ <contact-data>
94
+ <email-addresses>
95
+ <email-address>
96
+ <address>'.htmlspecialchars($request['sEmail']).'</address>
97
+ <location>Work</location>
98
+ </email-address>
99
+ </email-addresses>
100
+ <phone-numbers>
101
+ <phone-number>
102
+ <number>'.htmlspecialchars($request['sPhone']).'</number>
103
+ <location>Work</location>
104
+ </phone-number>
105
+ </phone-numbers>
106
+ <addresses>
107
+ <address>
108
+ <city>'.htmlspecialchars($request['sCity']).'</city>
109
+ <country>'.htmlspecialchars($request['sCountry']).'</country>
110
+ <state>'.htmlspecialchars($request['sState']).'</state>
111
+ <street>'.htmlspecialchars($request['sStreet']).'</street>
112
+ <zip>'.htmlspecialchars($request['sZip']).'</zip>
113
+ <location>Work</location>
114
+ </address>
115
+ </addresses>
116
+ </contact-data>
117
+ </person>');
118
+
119
+ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
120
+ curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
121
+ if (!$curl) {
122
+ Mage::throwException('Error: unable to connect to ' .$this->highrise_url.'/people.xml');
123
+ }
124
+ $xml = curl_exec($curl);
125
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
126
+ curl_close($curl);
127
+ if ($http_code = 201) {
128
+
129
+ $request['status'] = Bluejalappeno_Orderexport_Model_Export_Status::STATUS_CREATED;
130
+ $id = $this->_person_in_highrise($request);
131
+ if(!$this->highrise_background && $this->highrise_notes){
132
+ $this->_order_to_notes($request,$id);
133
+ }
134
+ }
135
+ else {
136
+ $request['status'] = Bluejalappeno_Orderexport_Model_Export_Status::STATUS_FAILED;
137
+ }
138
+ }elseif($this->highrise_notes && !$this->_order_in_highrise($request,$id)){
139
+ $updateStatus = $this->_order_to_notes($request,$id);
140
+ if ($updateStatus == 201) {
141
+ $request['status'] = Bluejalappeno_Orderexport_Model_Export_Status::STATUS_UPDATED;
142
+ }
143
+ else {
144
+ $request['status'] = Bluejalappeno_Orderexport_Model_Export_Status::STATUS_FAILED;
145
+ }
146
+
147
+ }else{
148
+ $request['status'] = Bluejalappeno_Orderexport_Model_Export_Status::STATUS_DUPLICATE;
149
+ }
150
+ return $request;
151
+ }
152
+
153
+ private function _order_to_notes($request,$id){
154
+ $curl = curl_init($this->highrise_url.'/notes.xml');
155
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
156
+ curl_setopt($curl,CURLOPT_USERPWD,$this->api_token.':x');
157
+
158
+ $body = "OrderNo: ".$request['sOrderNo']."<br />
159
+ Date: ".$request['sOrderDate']."<br />
160
+ Products: ".$request['sProducts'];
161
+
162
+ curl_setopt($curl,CURLOPT_HTTPHEADER,Array("Content-Type: application/xml"));
163
+ curl_setopt($curl,CURLOPT_POST,true);
164
+ curl_setopt($curl,CURLOPT_POSTFIELDS,'<note>
165
+ <subject-id type="integer">'.$id.'</subject-id>
166
+ <subject-type>Party</subject-type>
167
+ <body>'.htmlspecialchars($body).'</body>
168
+ </note>');
169
+
170
+ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
171
+ curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
172
+ if (!$curl) {
173
+ Mage::throwException('Error: unable to connect to ' .$this->highrise_url.'/notes.xml');
174
+ }
175
+ $xml = curl_exec($curl);
176
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
177
+ curl_close($curl);
178
+ return $http_code;
179
+
180
+ }
181
+
182
+ private function _person_in_highrise($request){
183
+ $curl = curl_init($this->highrise_url.'/people/search.xml?criteria[email]='.urlencode($request['sEmail']));
184
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
185
+ curl_setopt($curl,CURLOPT_USERPWD,$this->api_token.':x');
186
+
187
+ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
188
+ curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
189
+ if (!$curl) {
190
+ Mage::throwException('Error: unable to connect to ' .$this->highrise_url.'/people/search.xml?criteria[email]='.urlencode($request['sEmail']));
191
+ }
192
+ $xml = curl_exec($curl);
193
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
194
+ curl_close($curl);
195
+ if ($http_code == 200) {
196
+ $people = simplexml_load_string($xml);
197
+ $id = '-1';
198
+ for($i=0;$i<count($people->person);$i++) {
199
+ if($people->person[$i] != null) {
200
+ $id = $people->person[$i]->id;
201
+ }
202
+ }
203
+ }
204
+
205
+
206
+ return $id;
207
+ }
208
+
209
+ private function _order_in_highrise($request,$id){
210
+ $c = true;
211
+ $x = 0;
212
+ while($c){
213
+ $curl = curl_init($this->highrise_url.'/people/'.$id.'/notes?n='.$x);
214
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
215
+ curl_setopt($curl,CURLOPT_USERPWD,$this->api_token.':x');
216
+
217
+ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
218
+ curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
219
+ if (!$curl) {
220
+ Mage::throwException('Error: unable to connect to ' .$this->highrise_url.'/people/'.$id.'/notes?n='.$x);
221
+ }
222
+ $xml = curl_exec($curl);
223
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
224
+ curl_close($curl);
225
+ if ($http_code == 200) {
226
+ $notes = simplexml_load_string($xml);
227
+ for($i=0;$i<count($notes->note);$i++) {
228
+ if($notes->note[$i] != null) {
229
+ if(strpos($notes->note[$i]->body,$request['sOrderNo'])!=false){
230
+ return true;
231
+ }
232
+ }
233
+ }
234
+ if((count($notes)%25==0)&&(count($notes)>0)){
235
+ $x += 25;
236
+ }else{
237
+ $c = false;
238
+ }
239
+ }
240
+ }
241
+ return false;
242
+ }
243
+
244
+ private function _order_in_background_info($request,$id){
245
+ $curl = curl_init($this->highrise_url.'/people/'.$id.'.xml');
246
+ curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
247
+ curl_setopt($curl,CURLOPT_USERPWD,$this->api_token.':x');
248
+
249
+ curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
250
+ curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,0);
251
+
252
+ if (!$curl) {
253
+ Mage::throwException('Error: unable to connect to ' .$this->highrise_url.'/people/'.$id.'.xml');
254
+ }
255
+ $xml = curl_exec($curl);
256
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
257
+ curl_close($curl);
258
+
259
+ if ($http_code == 200) {
260
+ $people = simplexml_load_string($xml);
261
+ for($i=0;$i<count($people->person);$i++) {
262
+ if($people->person[$i] != null) {
263
+ if(strpos($people->person[$i]->background,$request['sOrderNo'])!=false){
264
+ return true;
265
+ }
266
+ }
267
+ }
268
+ }
269
+ return false;
270
+ }
271
+
272
+ }
app/code/community/Bluejalappeno/Orderexport/Model/Export/Sage.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Bluejalappeno <sales@bluejalappeno.com>
26
+ * */
27
+ class Bluejalappeno_Orderexport_Model_Export_Sage extends Bluejalappeno_Orderexport_Model_Export_Abstractcsv
28
+ {
29
+ const ENCLOSURE = '"';
30
+ const DELIMITER = ',';
31
+
32
+ public function exportOrders($orders)
33
+ {
34
+ $fileName = 'order_export_'.date("Ymd_His").'.csv';
35
+ $fp = fopen(Mage::getBaseDir('export').'/'.$fileName, 'w');
36
+
37
+ // $this->writeHeadRow($fp);
38
+
39
+ $csv = '';
40
+ foreach ($orders as $order) {
41
+ $order = Mage::getModel('sales/order')->loadByAttribute('entity_id',$order);
42
+ if ($order->getStatus() == Mage_Sales_Model_Order::STATE_COMPLETE || $order->getStatus() == Mage_Sales_Model_Order::STATE_CLOSED) {
43
+ $this->writeOrder($order, $fp);
44
+ }
45
+ }
46
+ fclose($fp);
47
+
48
+ return $fileName;
49
+ }
50
+
51
+
52
+ protected function taxCharged($order)
53
+ {
54
+ if($order->getData('tax_amount') == '0.00'){
55
+ $taxCharged = false;}
56
+ else{
57
+ $taxCharged = true;
58
+ }
59
+ return $taxCharged;
60
+
61
+ }
62
+
63
+ protected function setTaxCode($country, $order)
64
+ {
65
+
66
+ if($this->isEcCountry($country) && $this->taxCharged($order)){
67
+ $taxcode = "T1";
68
+ }
69
+ elseif($this->isEcCountry($country) && !$this->taxCharged($order) && $order->getData('subtotal') == '0.00'){
70
+ $taxcode = "T1";
71
+ }
72
+ else{
73
+ $taxcode = "T0";
74
+ }
75
+ return $taxcode;
76
+
77
+ }
78
+
79
+ protected function isEcCountry($country)
80
+ {
81
+
82
+ $countries = array(
83
+ 'GB',
84
+ 'AT',
85
+ 'BE',
86
+ 'BG',
87
+ 'CY',
88
+ 'CZ',
89
+ 'DK',
90
+ 'EE',
91
+ 'FI',
92
+ 'FR',
93
+ 'DE',
94
+ 'EL',
95
+ 'HU',
96
+ 'IE',
97
+ 'IT',
98
+ 'LV',
99
+ 'LT',
100
+ 'LV',
101
+ 'LT',
102
+ 'LU',
103
+ 'MT',
104
+ 'NL',
105
+ 'PL',
106
+ 'PT',
107
+ 'RO',
108
+ 'SK',
109
+ 'SI',
110
+ 'ES',
111
+ 'SE'
112
+ );
113
+
114
+ if(in_array($country, $countries)){
115
+
116
+ return true;
117
+ }
118
+ else
119
+ {
120
+ return false;
121
+ }
122
+ }
123
+ /**
124
+ * Writes the head row with the column names in the csv file.
125
+ *
126
+ * @param $fp The file handle of the csv file
127
+ */
128
+ protected function writeHeadRow($fp)
129
+ {
130
+ fputcsv($fp, $this->getHeadRowValues(), self::DELIMITER, self::ENCLOSURE);
131
+ }
132
+
133
+ /**
134
+ * Writes the row(s) for the given order in the csv file.
135
+ * A row is added to the csv file for each ordered item.
136
+ *
137
+ * @param Mage_Sales_Model_Order $order The order to write csv of
138
+ * @param $fp The file handle of the csv file
139
+ */
140
+ protected function writeOrder($order, $fp)
141
+ {
142
+ $customerDetails = $order->getBillingAddress();
143
+
144
+
145
+ $orderdate = substr_replace($order->getData('created_at'), '', -8);
146
+ $orderId = $order->getData('increment_id');
147
+
148
+ $customerFirstName = $customerDetails->getFirstname();
149
+ $customerLastName = $customerDetails->getLastname();
150
+ $fullName = $customerFirstName.$customerLastName;
151
+ $grandTotal = $order->getData('subtotal');
152
+ $taxAmount = $order->getData('tax_amount');
153
+ $paymentMethod = $this->getPaymentMethod($order);
154
+ $taxcode = $this->setTaxCode($customerDetails->getCountry(),$order);
155
+
156
+
157
+ $csvData = array('SI',date("Y/m/d"),'4000', '0',$orderdate,$orderId,$fullName,$grandTotal,$taxcode,$taxAmount,'1',$paymentMethod,'import');
158
+
159
+ fputcsv($fp, $csvData, self::DELIMITER, self::ENCLOSURE);
160
+
161
+
162
+ }
163
+
164
+ /**
165
+ * Returns the head column names.
166
+ *
167
+ * @return Array The array containing all column names
168
+ */
169
+ protected function getHeadRowValues()
170
+ {
171
+ return array(
172
+ 'SI',
173
+ 'Date',
174
+ '..',
175
+ '..',
176
+ 'Order Date',
177
+ 'Order Id',
178
+ 'Customer Name',
179
+ 'Order Grand Total',
180
+ 'Taxcode',
181
+ 'Tax Amount',
182
+ '..',
183
+ 'Payment method',
184
+ 'Action'
185
+ );
186
+ }
187
+
188
+
189
+ }
app/code/community/Bluejalappeno/Orderexport/Model/Export/Status.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluejalappeno_Orderexport_Model_Export_Status extends Mage_Core_Model_Abstract
3
+ {
4
+ const STATUS_DUPLICATE = -2;
5
+ const STATUS_UPDATED = 1;
6
+ const STATUS_FAILED = -1;
7
+ const STATUS_CREATED = 2;
8
+
9
+ }
app/code/community/Bluejalappeno/Orderexport/Model/Options/Options.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Bluejalappeno_Orderexport_Model_Options_Options
3
+ {
4
+
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => 'Standard', 'label'=>Mage::helper('adminhtml')->__('Standard')),
9
+ array('value' => 'Sage', 'label'=>Mage::helper('adminhtml')->__('Sage')),
10
+ array('value' => 'Highrise', 'label'=>Mage::helper('adminhtml')->__('Highrise'))
11
+ );
12
+ }
13
+
14
+
15
+
16
+ }
app/code/community/Bluejalappeno/Orderexport/changelog.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ V2.4.1 - Community release version
2
+
3
+ v2.4.2 - Resolved minor issue with Highrise export
4
+
5
+ v2.5 - altered export to use Shipping Description when available
6
+
7
+ v2.6 - added credit card type to export
8
+
9
+ v2.7 - resolved issue with exporting street address and currency symbols
10
+
11
+ v2.8 - Rebranded to Blue Jalappeno
app/code/community/Bluejalappeno/Orderexport/controllers/Sales/Order/ExportController.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Bluejalappeno Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Bluejalappeno
22
+ * @package Bluejalappeno_OrderExport
23
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Genevieve Eddison, Jonathan Feist, Farai Kanyepi <sales@bluejalappeno.com>
26
+ * */
27
+ class Bluejalappeno_Orderexport_Sales_Order_ExportController extends Mage_Adminhtml_Controller_Action
28
+ {
29
+ /**
30
+ * Exports orders defined by id in post param "order_ids" to csv and offers file directly for download
31
+ * when finished.
32
+ */
33
+ public function csvexportAction()
34
+ {
35
+ $orders = $this->getRequest()->getPost('order_ids', array());
36
+
37
+ switch(Mage::getStoreConfig('order_export/export_orders/output_type')){
38
+ case 'Standard':
39
+ $file = Mage::getModel('bluejalappeno_orderexport/export_csv')->exportOrders($orders);
40
+ $this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export').'/'.$file));
41
+ break;
42
+ case 'Sage':
43
+ $file = Mage::getModel('bluejalappeno_orderexport/export_sage')->exportOrders($orders);
44
+ $this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export').'/'.$file));
45
+ break;
46
+ case 'Highrise':
47
+ $failedList = '';
48
+ $successCount = 0;
49
+ $failCount = 0;
50
+ try {
51
+ $results = Mage::getModel('bluejalappeno_orderexport/export_highrise')->exportOrders($orders);
52
+ foreach ($results as $orderid => $status) {
53
+ if ($status > 0 ) $successCount++;
54
+ else {
55
+ $failedList.= $orderid .' ';
56
+ $failCount++;
57
+ }
58
+ }
59
+ }
60
+ catch (Exception $e) {
61
+ Mage::log($e->getMessage());
62
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('sales')->__($e->getMessage()));
63
+ }
64
+
65
+ if ($failCount > 0) {
66
+ $failedString = $successCount .' order(s) have been imported. The following orders failed to import: ' .$failedList;
67
+ $this->_getSession()->addError($this->__( $failedString));
68
+
69
+ }
70
+ else {
71
+ $this->_getSession()->addSuccess($this->__('%s order(s) have been imported', $successCount));
72
+ }
73
+ $this->_redirect('*/sales_order');
74
+ //$this->_prepareDownloadResponse($file, file_get_contents(Mage::getBaseDir('export').'/'.$file));
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ ?>
app/code/community/Bluejalappeno/Orderexport/etc/config.xml ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ * Magento Webshopapps Order Export Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Webshopapps
22
+ * @package Webshopapps_OrderExport
23
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ * @author Genevieve Eddison <sales@webshopapps.com>
26
+ *
27
+ -->
28
+ <config>
29
+ <modules>
30
+ <Bluejalappeno_Orderexport>
31
+ <version>0.0.1</version>
32
+ </Bluejalappeno_Orderexport>
33
+ </modules>
34
+ <global>
35
+ <models>
36
+ <bluejalappeno_orderexport>
37
+ <class>Bluejalappeno_Orderexport_Model</class>
38
+ </bluejalappeno_orderexport>
39
+ </models>
40
+ <helpers>
41
+ <bluejalappeno_orderexport>
42
+ <class>Bluejalappeno_Orderexport_Helper</class>
43
+ </bluejalappeno_orderexport>
44
+ </helpers>
45
+ <blocks>
46
+ <adminhtml>
47
+ <rewrite>
48
+ <sales_order_grid>Bluejalappeno_Orderexport_Block_Sales_Order_Grid</sales_order_grid>
49
+ </rewrite>
50
+ </adminhtml>
51
+ </blocks>
52
+ </global>
53
+ <admin>
54
+ <routers>
55
+ <adminhtml>
56
+ <args>
57
+ <modules>
58
+ <Bluejalappeno_Orderexport before="Mage_Adminhtml">Bluejalappeno_Orderexport</Bluejalappeno_Orderexport>
59
+ </modules>
60
+ </args>
61
+ </adminhtml>
62
+ </routers>
63
+ </admin>
64
+ <adminhtml>
65
+ <translate>
66
+ <modules>
67
+ <Bluejalappeno_Orderexport>
68
+ <files>
69
+ <default>Bluejalappeno_Orderexport.csv</default>
70
+ </files>
71
+ </Bluejalappeno_Orderexport>
72
+ </modules>
73
+ </translate>
74
+ <default>
75
+ <orderexport>
76
+ <condition_name>order_export</condition_name>
77
+ </orderexport>
78
+ </default>
79
+ <acl>
80
+ <resources>
81
+ <admin>
82
+ <children>
83
+ <system>
84
+ <children>
85
+ <config>
86
+ <children>
87
+ <order_export>
88
+ <title>Export Orders</title>
89
+ </order_export>
90
+ </children>
91
+ </config>
92
+ </children>
93
+ </system>
94
+ </children>
95
+ </admin>
96
+ </resources>
97
+ </acl>
98
+ </adminhtml>
99
+ </config>
app/code/community/Bluejalappeno/Orderexport/etc/system.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+ * Magento Bluejalappeno Order Export Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Bluejalappeno
23
+ * @package Bluejalappeno_OrderExport
24
+ * @copyright Copyright (c) 2010 Wimbolt Ltd (http://www.bluejalappeno.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ * @author Genevieve Eddison <sales@bluejalappeno.com>
27
+ * */ -->
28
+ <config>
29
+ <sections>
30
+ <order_export translate="label" module="bluejalappeno_orderexport">
31
+ <label>Blue Jalappeno Order Export</label>
32
+ <tab>sales</tab>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>301</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <groups>
39
+ <export_orders translate="label">
40
+ <label>Blue Jalappeno Order Export Community</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <comment>
47
+ <![CDATA[
48
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
49
+ This module was developed by <a href="http://www.bluejalappeno.com" target="_blank">www.BlueJalappeno.com</a> - <b>Magento Extension Specialists</b>.
50
+ <br/>For docs & examples refer to the Blue Jalappeno <a href="http://wiki.bluejalappeno.com/home/order-export">wiki</a>.
51
+ <br/>Need an order summary export or more features? We offer <a href="http://www.webshopapps.com/order-export-premium.html" target="_blank">Order Export Premium</a> including adding configurable attributes to export and automatic export with FTP.
52
+ <br/>We have many more extensions for pricing, post order workflow and tax. Visit <a href="www.webshopapps.com/appshop.html" target="_blank">the WebShopApps App Store</a> for more information.</a>
53
+ </div>
54
+ ]]>
55
+ </comment>
56
+ <fields>
57
+ <active translate="label">
58
+ <label>Enabled</label>
59
+ <frontend_type>select</frontend_type>
60
+ <source_model>adminhtml/system_config_source_yesno</source_model>
61
+ <sort_order>0</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>0</show_in_store>
65
+ </active>
66
+ <output_type translate="label">
67
+ <label>Output type</label>
68
+ <frontend_type>select</frontend_type>
69
+ <source_model>bluejalappeno_orderexport_model_options_options</source_model>
70
+ <sort_order>1</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </output_type>
75
+ </fields>
76
+ </export_orders>
77
+ <highrise translate="label">
78
+ <label>Blue Jalappeno Highrise Export</label>
79
+ <frontend_type>text</frontend_type>
80
+ <sort_order>3</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>1</show_in_store>
84
+ <fields>
85
+ <highrise_url translate="label">
86
+ <label>Highrise URL</label>
87
+ <frontend_type>text</frontend_type>
88
+ <sort_order>0</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ <comment>
93
+ <![CDATA[E.g. http://yourcompany.highrisehq.com]]>
94
+ </comment>
95
+ </highrise_url>
96
+ <highrise_api_key translate="label">
97
+ <label>API-Key Password</label>
98
+ <frontend_type>text</frontend_type>
99
+ <sort_order>1</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>0</show_in_store>
103
+ <comment>
104
+ <![CDATA[Your highrise api token; can be found under <em>My Info</em>]]>
105
+ </comment>
106
+ </highrise_api_key>
107
+ <highrise_notes translate="label">
108
+ <label>Use Notes</label>
109
+ <frontend_type>select</frontend_type>
110
+ <source_model>adminhtml/system_config_source_yesno</source_model>
111
+ <sort_order>2</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>0</show_in_store>
115
+ <comment>
116
+ <![CDATA[Use notes of customer to post order details<br />
117
+ If this is set to <em>No</em>, subsequent order details will not be stored]]>
118
+ </comment>
119
+ </highrise_notes>
120
+ <highrise_background translate="label">
121
+ <label>Use Background Info</label>
122
+ <frontend_type>select</frontend_type>
123
+ <source_model>adminhtml/system_config_source_yesno</source_model>
124
+ <sort_order>3</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ <comment>
129
+ <![CDATA[Set to <em>No</em> to exclusively use notes for order details<br />
130
+ Set to <em>Yes</em> for first order record in background information]]>
131
+ </comment>
132
+ </highrise_background>
133
+ </fields>
134
+ </highrise>
135
+ </groups>
136
+ </order_export>
137
+ </sections>
138
+ </config>
app/code/community/Bluejalappeno/Orderexport/versions_supported.txt ADDED
@@ -0,0 +1 @@
 
1
+ 1.4+
app/etc/modules/Bluejalappeno_Orderexport.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Bluejalappeno_Orderexport>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </Bluejalappeno_Orderexport>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Bluejalappeno_Orderexport</name>
4
+ <version>2.8.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php)">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Export full order details in multiple formats. These include standard csv file and preformated for Sage. Inbuilt connectivity with Highrise to update your contacts directly from the order screen. Very easy to install and configure. </summary>
10
+ <description>Order Export includes:&#xD;
11
+ &#xD;
12
+ -export of full order details including customer details, payment, tax, shipping method&#xD;
13
+ - standard csv format also includes item details and custom options with one line item per row&#xD;
14
+ -Sage export is pre-formatted for upload to Sage accounting systems&#xD;
15
+ -Highrise export will connect with your Highrise CRM account and update your customer details, order history and background information. &#xD;
16
+ </description>
17
+ <notes>Latest version including format changes for street address and multiple currencies</notes>
18
+ <authors><author><name>Genevieve Eddison</name><user>japmaple</user><email>sales@bluejalappeno.com</email></author></authors>
19
+ <date>2012-07-18</date>
20
+ <time>04:34:34</time>
21
+ <contents><target name="magecommunity"><dir name="Bluejalappeno"><dir name="Orderexport"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="b9b3a0b810c7fd756d5dbd7ec99a83a5"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="54167d4d52bbe2a993031b12d29f0b89"/></dir><dir name="Model"><dir name="Export"><file name="Abstractcsv.php" hash="01607a1c81b14816fa8236a2f9eaf2bd"/><file name="Csv.php" hash="f00ae2076f43a7f73e30fd86ca940371"/><file name="Highrise.php" hash="31ae70d18988e31ab951bae6ebe0445a"/><file name="Sage.php" hash="1a0ddeb628010327883a9ca7390932af"/><file name="Status.php" hash="9864800aa692cfc3846a50cead36c4b1"/></dir><dir name="Options"><file name="Options.php" hash="21f4fdf0df408aad2a0898d1e1459cfd"/></dir></dir><file name="changelog.txt" hash="8751dfd9d46306c70b2d0428a70d863d"/><dir name="controllers"><dir name="Sales"><dir name="Order"><file name="ExportController.php" hash="8343ada483bb5813eb7d04387267cef0"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="ca9f504d6cf8da1ec80808e2c19046ba"/><file name="system.xml" hash="84050b2d60b7706351982d86a9ccaea2"/></dir><file name="versions_supported.txt" hash="a3e69dd4d9f892aab0dcbf0a5dd246e2"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bluejalappeno_Orderexport.xml" hash="2475d3204e4ed96a2969993d51eacfe2"/></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>