Order_Export - Version 0.1.0

Version Notes

This is first release.

Download this release

Release Info

Developer Unicode Systems
Extension Order_Export
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (28) hide show
  1. app/code/community/Uni/Orderexport/Block/Adminhtml/Customer/Grid.php +46 -0
  2. app/code/community/Uni/Orderexport/Block/Adminhtml/Export.php +20 -0
  3. app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport.php +32 -0
  4. app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport/Edit/Form.php +67 -0
  5. app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport/Grid.php +100 -0
  6. app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Creditmemo/Grid.php +47 -0
  7. app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Invoice/Grid.php +45 -0
  8. app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Order/Grid.php +47 -0
  9. app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Shipment/Grid.php +46 -0
  10. app/code/community/Uni/Orderexport/Helper/Data.php +157 -0
  11. app/code/community/Uni/Orderexport/Model/Export/CreditmemoExportCsv.php +127 -0
  12. app/code/community/Uni/Orderexport/Model/Export/CustomerExportCsv.php +127 -0
  13. app/code/community/Uni/Orderexport/Model/Export/InvoiceExportCsv.php +126 -0
  14. app/code/community/Uni/Orderexport/Model/Export/OrderExportCsv.php +139 -0
  15. app/code/community/Uni/Orderexport/Model/Export/ShipmentExportCsv.php +126 -0
  16. app/code/community/Uni/Orderexport/Model/Mysql4/Orderexport.php +16 -0
  17. app/code/community/Uni/Orderexport/Model/Mysql4/Orderexport/Collection.php +17 -0
  18. app/code/community/Uni/Orderexport/Model/Orderexport.php +17 -0
  19. app/code/community/Uni/Orderexport/controllers/Adminhtml/ExportController.php +407 -0
  20. app/code/community/Uni/Orderexport/controllers/Adminhtml/SalesexportController.php +546 -0
  21. app/code/community/Uni/Orderexport/etc/adminhtml.xml +65 -0
  22. app/code/community/Uni/Orderexport/etc/config.xml +124 -0
  23. app/code/community/Uni/Orderexport/etc/system.xml +318 -0
  24. app/code/community/Uni/Orderexport/sql/orderexport_setup/mysql4-install-0.1.0.php +28 -0
  25. app/design/adminhtml/default/default/layout/orderexport.xml +8 -0
  26. app/etc/modules/Uni_Orderexport.xml +11 -0
  27. app/locale/en_US/template/email/orderexport_form.html +8 -0
  28. package.xml +20 -0
app/code/community/Uni/Orderexport/Block/Adminhtml/Customer/Grid.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_Grid {
11
+
12
+ /**
13
+ * Prepare mass action controls
14
+ *
15
+ * @return Uni_Orderexport_Block_Adminhtml_Customer_Grid
16
+ */
17
+ protected function _prepareMassaction() {
18
+ parent::_prepareMassaction();
19
+ $this->getMassactionBlock()->addItem('customerexport', array(
20
+ 'label' => Mage::helper('customer')->__('Export Customers'),
21
+ 'url' => $this->getUrl('orderexport/adminhtml_export/customerExport'),
22
+ 'additional' => array(
23
+ 'visibility' => array(
24
+ 'name' => 'profiles',
25
+ 'type' => 'select',
26
+ 'class' => 'required-entry',
27
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
28
+ 'values' => Uni_Orderexport_Block_Adminhtml_Customer_Grid::getOptionArray2(),
29
+ )
30
+ )
31
+ ));
32
+ }
33
+
34
+ /**
35
+ * Create options for Customers csv, xml
36
+ *
37
+ * @return array
38
+ */
39
+ static public function getOptionArray2() {
40
+ $data_array = array();
41
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV] = 'Export Customers (sample csv format)';
42
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML] = 'Export Customers (sample xml format)';
43
+ return($data_array);
44
+ }
45
+
46
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Export.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+
11
+ class Uni_Orderexport_Block_Adminhtml_Export extends Mage_Adminhtml_Block_Widget_Grid_Container {
12
+
13
+ public function __construct() {
14
+ $this->_controller = "adminhtml_orderexport"; /*path to grid class folder in Block*/
15
+ $this->_blockGroup = "orderexport"; /*it is module name*/
16
+ $this->_headerText = Mage::helper('orderexport')->__('Manage Export History');
17
+ parent::__construct();
18
+ $this->_removeButton('add');
19
+ }
20
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Orderexport extends Mage_Adminhtml_Block_Widget_Form_Container {
11
+
12
+ public function __construct() {
13
+ $url = Mage::helper('adminhtml')->getUrl('*/export/orderexport');
14
+ parent::__construct();
15
+ $this->_objectId = 'id';
16
+ $this->_blockGroup = 'orderexport';
17
+ $this->_controller = 'adminhtml_orderexport';
18
+ $this->_removeButton('delete');
19
+ $this->_removeButton('save');
20
+ $this->_removeButton('back');
21
+ $this->_removeButton('reset');
22
+ }
23
+
24
+ /**
25
+ *
26
+ * @return string
27
+ */
28
+ public function getHeaderText() {
29
+ return Mage::helper('orderexport')->__('Manual Order Export Manager');
30
+ }
31
+
32
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport/Edit/Form.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ ?>
11
+
12
+ <?php
13
+
14
+ class Uni_Orderexport_Block_Adminhtml_Orderexport_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
15
+
16
+ /**
17
+ *
18
+ * @return form for manual export.
19
+ */
20
+
21
+ protected function _prepareForm() {
22
+
23
+ $_value = '';
24
+ $form = new Varien_Data_Form(array(
25
+ 'id' => 'edit_form',
26
+ 'action' => $this->getUrl('*/adminhtml_salesexport/allExport', array()),
27
+ 'method' => 'post',
28
+ ));
29
+ $fieldset = $form->addFieldset('manualexport', array('legend' => Mage::helper('orderexport')->__('Order Export')));
30
+
31
+ $fieldset->addField('profiles', 'select', array(
32
+ 'name' => 'profiles',
33
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
34
+ 'required' => true,
35
+ 'name' => 'profiles',
36
+ 'value' => '',
37
+ 'values' => Uni_Orderexport_Helper_Data::getExportProfile(),
38
+ ));
39
+ $fieldset->addField('starting_id', 'text', array(
40
+ 'name' => 'starting_id',
41
+ 'label' => Mage::helper('orderexport')->__('Starting ID'),
42
+ 'required' => true,
43
+ ));
44
+ $fieldset->addField('ending_id', 'text', array(
45
+ 'name' => 'ending_id',
46
+ 'label' => Mage::helper('orderexport')->__('Ending ID'),
47
+ 'required' => true,
48
+ ));
49
+ $fieldset->addField('submit', 'submit', array(
50
+ 'type' => 'submit',
51
+ 'class' => 'scalable',
52
+ 'value' => 'Export',
53
+ 'tabindex' => 1
54
+ ));
55
+
56
+ if (Mage::getSingleton('adminhtml/session')->getOrderexportData()) {
57
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getOrderexportData());
58
+ Mage::getSingleton('adminhtml/session')->setOrderexportData(null);
59
+ } elseif (Mage::registry('orderexport_data')) {
60
+ $form->setValues(Mage::registry('orderexport_data')->getData());
61
+ }
62
+ $form->setUseContainer(true);
63
+ $this->setForm($form);
64
+ return parent::_prepareForm();
65
+ }
66
+
67
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Orderexport/Grid.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Orderexport_Grid extends Mage_Adminhtml_Block_Widget_Grid {
11
+
12
+ public function __construct() {
13
+ parent::__construct();
14
+ $this->setId('exporthistory');
15
+ $this->setDefaultSort('id');
16
+ $this->setDefaultDir('ASC');
17
+ $this->setSaveParametersInSession(true);
18
+ }
19
+
20
+ /**
21
+ * Prepare collecttion of exported details.
22
+ *
23
+ * @return collection
24
+ */
25
+ protected function _prepareCollection() {
26
+ $collection = Mage::getModel('orderexport/orderexport')->getCollection();
27
+ $this->setCollection($collection);
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ /**
32
+ * @return grid of exported details.
33
+ */
34
+ protected function _prepareColumns() {
35
+ $this->addColumn('id', array(
36
+ 'header' => Mage::helper('orderexport')->__('Export ID'),
37
+ 'align' => 'right',
38
+ 'width' => '50px',
39
+ 'index' => 'id',
40
+ ));
41
+
42
+ $this->addColumn('profile', array(
43
+ 'header' => Mage::helper('orderexport')->__('Profile'),
44
+ 'align' => 'left',
45
+ 'index' => 'profile',
46
+ 'type' => 'options',
47
+ 'options' => Mage::helper('orderexport')->getEntity()
48
+ ));
49
+
50
+ $this->addColumn('created_time', array(
51
+ 'header' => Mage::helper('orderexport')->__('Export Date-Time'),
52
+ 'width' => '150px',
53
+ 'type' => 'datetime',
54
+ 'index' => 'created_time',
55
+ ));
56
+ $this->addColumn('filename', array(
57
+ 'header' => Mage::helper('orderexport')->__('Exported File'),
58
+ 'index' => 'filename',
59
+ ));
60
+ $this->addColumn('destination', array(
61
+ 'header' => Mage::helper('orderexport')->__('Destination'),
62
+ 'index' => 'destination',
63
+ ));
64
+
65
+ $this->addColumn('action', array(
66
+ 'header' => Mage::helper('orderexport')->__('Action'),
67
+ 'width' => '100px',
68
+ 'type' => 'action',
69
+ 'getter' => 'getId',
70
+ 'actions' => array(
71
+ array(
72
+ 'caption' => Mage::helper('orderexport')->__('Download File(s)'),
73
+ 'url' => array('base' => '*/*/download'), //$this->getUrl('*/*/download'),
74
+ 'field' => 'id'
75
+ )
76
+ ),
77
+ 'filter' => false,
78
+ 'sortable' => false,
79
+ ));
80
+ parent::_prepareColumns();
81
+ }
82
+
83
+ /**
84
+ * Prepare mass action controls
85
+ *
86
+ * @return Mage_Adminhtml_Block_Widget_Grid
87
+ */
88
+ protected function _prepareMassaction() {
89
+ $this->setMassactionIdField('id');
90
+ $this->getMassactionBlock()->setFormFieldName('orderexport');
91
+
92
+ $this->getMassactionBlock()->addItem('delete', array(
93
+ 'label' => Mage::helper('orderexport')->__('Delete'),
94
+ 'url' => $this->getUrl('*/*/massDelete'),
95
+ 'confirm' => Mage::helper('orderexport')->__('Exported file(s) from disk and FTP will be deleted.')
96
+ ));
97
+ return $this;
98
+ }
99
+
100
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Creditmemo/Grid.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Sales_Creditmemo_Grid extends Mage_Adminhtml_Block_Sales_Creditmemo_Grid {
11
+
12
+ /**
13
+ * Prepare mass action controls
14
+ *
15
+ * @return Uni_Orderexport_Block_Adminhtml_Sales_Creditmemo_Grid
16
+ */
17
+ protected function _prepareMassaction() {
18
+ parent::_prepareMassaction();
19
+
20
+ $this->getMassactionBlock()->addItem('creditmemoexport', array(
21
+ 'label' => Mage::helper('sales')->__('Export Creditmemos'),
22
+ 'url' => $this->getUrl('*/adminhtml_export/creditmemoExport'),
23
+ 'additional' => array(
24
+ 'visibility' => array(
25
+ 'name' => 'profiles',
26
+ 'type' => 'select',
27
+ 'class' => 'required-entry',
28
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
29
+ 'values' => Uni_Orderexport_Block_Adminhtml_Sales_Creditmemo_Grid::getOptionArray2(),
30
+ )
31
+ )
32
+ ));
33
+ }
34
+
35
+ /**
36
+ * Create options for Creditmemoes csv, xml
37
+ *
38
+ * @return array
39
+ */
40
+ static public function getOptionArray2() {
41
+ $data_array = array();
42
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV] = 'Export Creditmemoes (sample csv format)';
43
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML] = 'Export Creditmemoes (sample xml format)';
44
+ return($data_array);
45
+ }
46
+
47
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Invoice/Grid.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Sales_Invoice_Grid extends Mage_Adminhtml_Block_Sales_Invoice_Grid {
11
+
12
+ /**
13
+ * @return Uni_Orderexport_Block_Adminhtml_Sales_Invoice_Grid
14
+ */
15
+
16
+ protected function _prepareMassaction() {
17
+ parent::_prepareMassaction();
18
+ $this->getMassactionBlock()->addItem('invoiceexport', array(
19
+ 'label' => Mage::helper('sales')->__('Export Invoices'),
20
+ 'url' => $this->getUrl('*/adminhtml_export/invoiceExport'),
21
+ 'additional' => array(
22
+ 'visibility' => array(
23
+ 'name' => 'profiles',
24
+ 'type' => 'select',
25
+ 'class' => 'required-entry',
26
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
27
+ 'values' => Uni_Orderexport_Block_Adminhtml_Sales_Invoice_Grid::getOptionArray2(),
28
+ )
29
+ )
30
+ ));
31
+ }
32
+
33
+ /**
34
+ * Create options for Invoices csv, xml
35
+ *
36
+ * @return array
37
+ */
38
+ static public function getOptionArray2() {
39
+ $data_array = array();
40
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV] = 'Export Invoices (sample csv format)';
41
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML] = 'Export Invoices (sample xml format)';
42
+ return($data_array);
43
+ }
44
+
45
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+
11
+ class Uni_Orderexport_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid {
12
+
13
+ /**
14
+ * @return Uni_Orderexport_Block_Adminhtml_Sales_Order_Grid
15
+ */
16
+
17
+ protected function _prepareMassaction() {
18
+ parent::_prepareMassaction();
19
+ $this->getMassactionBlock()->addItem('orderexport', array(
20
+ 'label' => Mage::helper('sales')->__('Export orders'),
21
+ 'url' => $this->getUrl('orderexport/adminhtml_export/orderExport'),
22
+ 'additional' => array(
23
+ 'visibility' => array(
24
+ 'name' => 'profiles',
25
+ 'type' => 'select',
26
+ 'class' => 'required-entry',
27
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
28
+ 'values' => Uni_Orderexport_Block_Adminhtml_Sales_Order_Grid::getOptionArray2(),
29
+ )
30
+ )
31
+ ));
32
+ }
33
+
34
+
35
+ /**
36
+ * Create options for Order csv, xml
37
+ *
38
+ * @return array
39
+ */
40
+ static public function getOptionArray2() {
41
+ $data_array = array();
42
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV] = 'Export Order (sample csv format)';
43
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML] = 'Export Order (sample xml format)';
44
+ return($data_array);
45
+ }
46
+
47
+ }
app/code/community/Uni/Orderexport/Block/Adminhtml/Sales/Shipment/Grid.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Block_Adminhtml_Sales_Shipment_Grid extends Mage_Adminhtml_Block_Sales_Shipment_Grid {
11
+
12
+ /**
13
+ *
14
+ * @return Uni_Orderexport_Block_Adminhtml_Sales_Shipment_Grid
15
+ */
16
+ protected function _prepareMassaction() {
17
+ parent::_prepareMassaction();
18
+
19
+ $this->getMassactionBlock()->addItem('shipmentexport', array(
20
+ 'label' => Mage::helper('sales')->__('Export Shipments'),
21
+ 'url' => $this->getUrl('*/adminhtml_export/shipmentExport'),
22
+ 'additional' => array(
23
+ 'visibility' => array(
24
+ 'name' => 'profiles',
25
+ 'type' => 'select',
26
+ 'class' => 'required-entry',
27
+ 'label' => Mage::helper('orderexport')->__('Profiles'),
28
+ 'values' => Uni_Orderexport_Block_Adminhtml_Sales_Shipment_Grid::getOptionArray2(),
29
+ )
30
+ )
31
+ ));
32
+ }
33
+
34
+ /**
35
+ * Create options for Shipment csv, xml
36
+ *
37
+ * @return array
38
+ */
39
+ static public function getOptionArray2() {
40
+ $data_array = array();
41
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV] = 'Export Shipment (sample csv format)';
42
+ $data_array[Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML] = 'Export Shipment (sample xml format)';
43
+ return($data_array);
44
+ }
45
+
46
+ }
app/code/community/Uni/Orderexport/Helper/Data.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Helper_Data extends Mage_Core_Helper_Abstract {
11
+
12
+ /**
13
+ *
14
+ * @return array of export profiles
15
+ */
16
+ public static function getExportProfile() {
17
+ return array(
18
+ '' => Mage::helper('orderexport')->__('--Select Profile--'),
19
+ '9' => array(
20
+ 'value' => array(
21
+ array('value' => '1', 'label' => Mage::helper('orderexport')->__('Export Orders (sample csv format)')),
22
+ array('value' => '2', 'label' => Mage::helper('orderexport')->__('Export Orders (sample xml format)'))),
23
+ 'label' => Mage::helper('orderexport')->__('Order Export'),
24
+ ),
25
+ '10' => array(
26
+ 'value' => array(
27
+ array('value' => '3', 'label' => Mage::helper('orderexport')->__('Export Invoices (sample csv format)')),
28
+ array('value' => '4', 'label' => Mage::helper('orderexport')->__('Export Invoices (sample xml format)'))),
29
+ 'label' => Mage::helper('orderexport')->__('Invoice Export'),
30
+ ),
31
+ '11' => array(
32
+ 'value' => array(
33
+ array('value' => '5', 'label' => Mage::helper('orderexport')->__('Export Shipments (sample csv format)')),
34
+ array('value' => '6', 'label' => Mage::helper('orderexport')->__('Export Shipments (sample xml format)'))),
35
+ 'label' => Mage::helper('orderexport')->__('Shipment Export'),
36
+ ),
37
+ '12' => array(
38
+ 'value' => array(
39
+ array('value' => '7', 'label' => Mage::helper('orderexport')->__('Export Creditmemoes (sample csv format)')),
40
+ array('value' => '8', 'label' => Mage::helper('orderexport')->__('Export Creditmemoes (sample xml format)'))),
41
+ 'label' => Mage::helper('orderexport')->__('Creditmemo Export'),
42
+ ),
43
+ '13' => array(
44
+ 'value' => array(
45
+ array('value' => '10', 'label' => Mage::helper('orderexport')->__('Export Customers (sample csv format)')),
46
+ array('value' => '11', 'label' => Mage::helper('orderexport')->__('Export Customers (sample xml format)'))),
47
+ 'label' => Mage::helper('orderexport')->__('Customer Export'),
48
+ ),
49
+ );
50
+ }
51
+
52
+ /**
53
+ *
54
+ * @return array of export profiles for grid
55
+ */
56
+ public static function getEntity() {
57
+ return array(
58
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV => Mage::helper('orderexport')->__('Order CSV'),
59
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML => Mage::helper('orderexport')->__('Order XML'),
60
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV => Mage::helper('orderexport')->__('Invoice CSV'),
61
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML => Mage::helper('orderexport')->__('Invoice XML'),
62
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV => Mage::helper('orderexport')->__('Shipment CSV'),
63
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML => Mage::helper('orderexport')->__('Shipment XML'),
64
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV => Mage::helper('orderexport')->__('Creditmemoe CSV'),
65
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML => Mage::helper('orderexport')->__('Creditmemoe XML'),
66
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV => Mage::helper('orderexport')->__('Customer CSV'),
67
+ Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML => Mage::helper('orderexport')->__('Customer XML'),
68
+ );
69
+ }
70
+
71
+ /**
72
+ * send email with exported file attachment
73
+ * @param string $file
74
+ * @param string $_option
75
+ * @return boolean
76
+ */
77
+ public function sendMail($file, $_option) {
78
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('orderexport_email_email_template');
79
+ $recipientEmail = '';
80
+ $recipientName = '';
81
+ $attachmentFilePath = '';
82
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
83
+ $attachmentFilePath = Mage::getBaseDir('var') . DS . 'export' . DS . 'order' . DS . $file;
84
+ $recipientEmail = Mage::getStoreConfig('orderexport/order_email/order_export_email');
85
+ $recipientName = Mage::getStoreConfig('orderexport/order_email/order_export_name');
86
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_PDF) {
87
+ $attachmentFilePath = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice' . DS . $file;
88
+ $recipientEmail = Mage::getStoreConfig('orderexport/invoice_email/invoice_export_email');
89
+ $recipientName = Mage::getStoreConfig('orderexport/invoice_email/invoice_export_name');
90
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
91
+ $attachmentFilePath = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment' . DS . $file;
92
+ $recipientEmail = Mage::getStoreConfig('orderexport/shipment_email/shipment_export_email');
93
+ $recipientName = Mage::getStoreConfig('orderexport/shipment_email/shipment_export_name');
94
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
95
+ $attachmentFilePath = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo' . DS . $file;
96
+ $recipientEmail = Mage::getStoreConfig('orderexport/creditmemo_email/creditmemo_export_email');
97
+ $recipientName = Mage::getStoreConfig('orderexport/creditmemo_email/creditmemo_export_name');
98
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
99
+ $attachmentFilePath = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer' . DS . $file;
100
+ $recipientEmail = Mage::getStoreConfig('orderexport/customer_email/customer_export_email');
101
+ $recipientName = Mage::getStoreConfig('orderexport/customer_email/customer_export_name');
102
+ } else {
103
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Oops...??? Something went wrong...!!!'));
104
+ $this->_redirectReferer();
105
+ return false;
106
+ }
107
+ if (file_exists($attachmentFilePath)) {
108
+ $fileContents = file_get_contents($attachmentFilePath);
109
+ $attachment = $emailTemplate->getMail()->createAttachment($fileContents);
110
+ $attachment->filename = $file;
111
+ }
112
+ $emailTemplateVariables = array(
113
+ 'name' => Mage::getStoreConfig('trans_email/ident_general/name'),
114
+ 'email' => Mage::getStoreConfig('trans_email/ident_general/email')
115
+ );
116
+ try {
117
+ $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name'));
118
+ $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email'));
119
+ $emailTemplate->send($recipientEmail, $recipientName, $emailTemplateVariables);
120
+ return true;
121
+ } catch (Exception $e) {
122
+ echo $e->getMessage();
123
+ }
124
+ }
125
+
126
+ /**
127
+ * save export history
128
+ * @param string $profile
129
+ * @param string $file
130
+ */
131
+ public function saveHistory($profile, $file) {
132
+ $dest = Mage::getBaseDir('var') . DS;
133
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV ? $dest.= 'export' . DS . 'order' : '';
134
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML ? $dest.= 'export' . DS . 'order' : '';
135
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV ? $dest.= 'export' . DS . 'invoice' : '';
136
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML ? $dest.= 'export' . DS . 'invoice' : '';
137
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV ? $dest.= 'export' . DS . 'shipment' : '';
138
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML ? $dest.= 'export' . DS . 'shipment' : '';
139
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV ? $dest.= 'export' . DS . 'creditmemo' : '';
140
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML ? $dest.= 'export' . DS . 'creditmemo' : '';
141
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV ? $dest.= 'export' . DS . 'customer' : '';
142
+ $profile == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML ? $dest.= 'export' . DS . 'customer' : '';
143
+ $data = array();
144
+ $data['profile'] = $profile;
145
+ $data['created_time'] = now();
146
+ $data['filename'] = $file;
147
+ $data['destination'] = $dest;
148
+ try {
149
+ $model = Mage::getModel('orderexport/orderexport');
150
+ $model->setData($data);
151
+ $model->save();
152
+ } catch (Exception $exc) {
153
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Exported report can not be saved due to internet failure'));
154
+ }
155
+ }
156
+
157
+ }
app/code/community/Uni/Orderexport/Model/Export/CreditmemoExportCsv.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Model_Export_CreditmemoExportCsv {
11
+
12
+ protected $_list = null;
13
+
14
+ /**
15
+ *
16
+ * @param array $creditmemos selected creditmemo ids
17
+ * @return array
18
+ */
19
+ public function exportCreditmemoCsv($creditmemos) {
20
+ $collection = Mage::getModel('sales/order_creditmemo')->getCollection()
21
+ ->addAttributeToSelect('*')
22
+ ->addFieldToFilter('entity_id', array('in' => array($creditmemos)));
23
+ $this->setList($collection);
24
+ if (!is_null($this->_list)) {
25
+ $items = $this->_list->getItems();
26
+ if (count($items) > 0) {
27
+
28
+ $io = new Varien_Io_File();
29
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo';
30
+ $name = 'creditmemo_export_' . date("Ymd_His");
31
+ $file = $path . DS . $name . '.csv';
32
+ $io->setAllowCreateFolders(true);
33
+ $io->open(array('path' => $path));
34
+ $io->streamOpen($file, 'w+');
35
+ $io->streamLock(true);
36
+ $io->streamWriteCsv($this->_getCsvHeaders($items));
37
+ foreach ($items as $data) {
38
+ $io->streamWriteCsv($data->getData());
39
+ }
40
+ return array(
41
+ 'type' => 'filename',
42
+ 'value' => $file,
43
+ 'rm' => false /* can delete file after use */
44
+ );
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @param Object $collection
52
+ */
53
+ public function setList($collection) {
54
+ $this->_list = $collection;
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param array $creditmemos selected creditmemo ids
60
+ * @return array
61
+ */
62
+ protected function _getCsvHeaders($creditmemos) {
63
+ $creditmemo = current($creditmemos);
64
+ $headers = array_keys($creditmemo->getData());
65
+ return $headers;
66
+ }
67
+
68
+ /**
69
+ *
70
+ * @param array $creditmemos selected creditmemo ids
71
+ * @return array
72
+ */
73
+ protected function _getXmlHeaders($creditmemos) {
74
+ $headers = array();
75
+ $creditmemo = current($creditmemos);
76
+ $headers = array_keys($creditmemo->getData());
77
+ return $headers;
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param array $creditmemos selected creditmemo ids
83
+ * @return array
84
+ */
85
+ public function exportCreditmemoExcel($creditmemos) {
86
+ $collection = Mage::getModel('sales/order_creditmemo')->getCollection()
87
+ ->addAttributeToSelect('*')
88
+ ->addFieldToFilter('entity_id', array('in' => array($creditmemos)));
89
+ $this->setList($collection);
90
+ if (!is_null($this->_list)) {
91
+ $items = $this->_list->getItems();
92
+ if (count($items) > 0) {
93
+
94
+ $parser = new Varien_Convert_Parser_Xml_Excel();
95
+ $io = new Varien_Io_File();
96
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo';
97
+ $name = 'creditmemo_export_' . date("Ymd_His");
98
+ $file = $path . DS . $name . '.xml';
99
+ $io->setAllowCreateFolders(true);
100
+ $io->open(array('path' => $path));
101
+ $io->streamOpen($file, 'w+');
102
+ $io->streamLock(true);
103
+ $headers = $this->_getXmlHeaders($items);
104
+ $io->streamWrite($parser->getHeaderXml());
105
+ $io->streamWrite($parser->getRowXml($headers));
106
+ $val = $collection->getData();
107
+ foreach ($val as $key => $value) {
108
+ $parseData = array();
109
+ foreach ($value as $v) {
110
+ $parseData[] = (string) $v;
111
+ }
112
+ $io->streamWrite($parser->getRowXml($parseData));
113
+ unset($parseData);
114
+ }
115
+ $io->streamWrite($parser->getFooterXml());
116
+ $io->streamUnlock();
117
+ $io->streamClose();
118
+ return array(
119
+ 'type' => 'filename',
120
+ 'value' => $file,
121
+ 'rm' => false
122
+ );
123
+ }
124
+ }
125
+ }
126
+
127
+ }
app/code/community/Uni/Orderexport/Model/Export/CustomerExportCsv.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Model_Export_CustomerExportCsv {
11
+
12
+ protected $_list = null;
13
+
14
+ /**
15
+ *
16
+ * @param Object $collection
17
+ */
18
+ public function setList($collection) {
19
+ $this->_list = $collection;
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param array $customerIds selected customer ids
25
+ * @return array
26
+ */
27
+ protected function _getCsvHeaders($customerIds) {
28
+ $customer = current($customerIds);
29
+ $headers = array_keys($customer->getData());
30
+ return $headers;
31
+ }
32
+
33
+ /**
34
+ *
35
+ * @param array $customerIds selected customer ids
36
+ * @return array
37
+ */
38
+ protected function _getXmlHeaders($customerIds) {
39
+ $headers = array();
40
+ $customer = current($customerIds);
41
+ $headers = array_keys($customer->getData());
42
+ return $headers;
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param array $customerIds selected customer ids
48
+ * @return array
49
+ */
50
+ public function exportCustomerCsv($customerIds) {
51
+ $collection = Mage::getModel('customer/customer')->getCollection()
52
+ ->addAttributeToSelect('*')
53
+ ->addFieldToFilter('entity_id', array('in' => array($customerIds)));
54
+ $this->setList($collection);
55
+ if (!is_null($this->_list)) {
56
+ $items = $this->_list->getItems();
57
+ if (count($items) > 0) {
58
+
59
+ $io = new Varien_Io_File();
60
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer';
61
+ $name = 'customer_export_' . date("Ymd_His");
62
+ $file = $path . DS . $name . '.csv';
63
+ $io->setAllowCreateFolders(true);
64
+ $io->open(array('path' => $path));
65
+ $io->streamOpen($file, 'w+');
66
+ $io->streamLock(true);
67
+ $io->streamWriteCsv($this->_getCsvHeaders($items));
68
+ foreach ($items as $data) {
69
+ $io->streamWriteCsv($data->getData());
70
+ }
71
+
72
+ return array(
73
+ 'type' => 'filename',
74
+ 'value' => $file,
75
+ 'rm' => false
76
+ );
77
+ }
78
+ }
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @param array $customerIds selected customer ids
84
+ * @return array
85
+ */
86
+ public function exportCustomerExcel($customerIds) {
87
+ $collection = Mage::getModel('customer/customer')->getCollection()
88
+ ->addAttributeToSelect('*')
89
+ ->addFieldToFilter('entity_id', array('in' => array($customerIds)));
90
+ $this->setList($collection);
91
+ if (!is_null($this->_list)) {
92
+ $items = $this->_list->getItems();
93
+ if (count($items) > 0) {
94
+ $parser = new Varien_Convert_Parser_Xml_Excel();
95
+ $io = new Varien_Io_File();
96
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer';
97
+ $name = 'customer_export_' . date("Ymd_His");
98
+ $file = $path . DS . $name . '.xml';
99
+ $io->setAllowCreateFolders(true);
100
+ $io->open(array('path' => $path));
101
+ $io->streamOpen($file, 'w+');
102
+ $io->streamLock(true);
103
+ $headers = $this->_getXmlHeaders($items);
104
+ $io->streamWrite($parser->getHeaderXml());
105
+ $io->streamWrite($parser->getRowXml($headers));
106
+ $val = $collection->getData();
107
+ foreach ($val as $key => $value) {
108
+ $parseData = array();
109
+ foreach ($value as $v) {
110
+ $parseData[] = (string) $v;
111
+ }
112
+ $io->streamWrite($parser->getRowXml($parseData));
113
+ unset($parseData);
114
+ }
115
+ $io->streamWrite($parser->getFooterXml());
116
+ $io->streamUnlock();
117
+ $io->streamClose();
118
+ return array(
119
+ 'type' => 'filename',
120
+ 'value' => $file,
121
+ 'rm' => false
122
+ );
123
+ }
124
+ }
125
+ }
126
+
127
+ }
app/code/community/Uni/Orderexport/Model/Export/InvoiceExportCsv.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Model_Export_InvoiceExportCsv {
11
+
12
+ protected $_list = null;
13
+
14
+ /**
15
+ *
16
+ * @param object $collection
17
+ */
18
+ public function setList($collection) {
19
+ $this->_list = $collection;
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @param array $invoices selected invoice ids
25
+ * @return array
26
+ */
27
+ protected function _getCsvHeaders($invoices) {
28
+ $invoice = current($invoices);
29
+ $headers = array_keys($invoice->getData());
30
+ return $headers;
31
+ }
32
+
33
+ /**
34
+ *
35
+ * @param array $invoices selected invoice ids
36
+ * @return array
37
+ */
38
+ protected function _getXmlHeaders($invoices) {
39
+ $headers = array();
40
+ $invoice = current($invoices);
41
+ $headers = array_keys($invoice->getData());
42
+ return $headers;
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param array $invoices selected invoice ids
48
+ * @return array
49
+ */
50
+ public function exportInvoiceCsv($invoices) {
51
+ $collection = Mage::getModel('sales/order_invoice')->getCollection()
52
+ ->addAttributeToSelect('*')
53
+ ->addFieldToFilter('entity_id', array('in' => array($invoices)));
54
+ $this->setList($collection);
55
+ if (!is_null($this->_list)) {
56
+ $items = $this->_list->getItems();
57
+ if (count($items) > 0) {
58
+
59
+ $io = new Varien_Io_File();
60
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice';
61
+ $name = 'invoice_export_' . date("Ymd_His");
62
+ $file = $path . DS . $name . '.csv';
63
+ $io->setAllowCreateFolders(true);
64
+ $io->open(array('path' => $path));
65
+ $io->streamOpen($file, 'w+');
66
+ $io->streamLock(true);
67
+ $io->streamWriteCsv($this->_getCsvHeaders($items));
68
+ foreach ($items as $data) {
69
+ $io->streamWriteCsv($data->getData());
70
+ }
71
+ return array(
72
+ 'type' => 'filename',
73
+ 'value' => $file,
74
+ 'rm' => false
75
+ );
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param array $invoices selected invoice ids
83
+ * @return array
84
+ */
85
+ public function exportInvoiceExcel($invoices) {
86
+ $collection = Mage::getModel('sales/order_invoice')->getCollection()
87
+ ->addAttributeToSelect('*')
88
+ ->addFieldToFilter('entity_id', array('in' => array($invoices)));
89
+ $this->setList($collection);
90
+ if (!is_null($this->_list)) {
91
+ $items = $this->_list->getItems();
92
+ if (count($items) > 0) {
93
+ $parser = new Varien_Convert_Parser_Xml_Excel();
94
+ $io = new Varien_Io_File();
95
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice';
96
+ $name = 'invoice_export_' . date("Ymd_His");
97
+ $file = $path . DS . $name . '.xml';
98
+ $io->setAllowCreateFolders(true);
99
+ $io->open(array('path' => $path));
100
+ $io->streamOpen($file, 'w+');
101
+ $io->streamLock(true);
102
+ $headers = $this->_getXmlHeaders($items);
103
+ $io->streamWrite($parser->getHeaderXml());
104
+ $io->streamWrite($parser->getRowXml($headers));
105
+ $val = $collection->getData();
106
+ foreach ($val as $key => $value) {
107
+ $parseData = array();
108
+ foreach ($value as $v) {
109
+ $parseData[] = (string) $v;
110
+ }
111
+ $io->streamWrite($parser->getRowXml($parseData));
112
+ unset($parseData);
113
+ }
114
+ $io->streamWrite($parser->getFooterXml());
115
+ $io->streamUnlock();
116
+ $io->streamClose();
117
+ return array(
118
+ 'type' => 'filename',
119
+ 'value' => $file,
120
+ 'rm' => false
121
+ );
122
+ }
123
+ }
124
+ }
125
+
126
+ }
app/code/community/Uni/Orderexport/Model/Export/OrderExportCsv.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Model_Export_OrderExportCsv {
11
+
12
+ const EXPORT_ORDER_CSV = 1;
13
+ const EXPORT_ORDER_XML = 2;
14
+ const EXPORT_INVOICE_CSV = 3;
15
+ const EXPORT_INVOICE_XML = 4;
16
+ const EXPORT_SHIPMENT_CSV = 5;
17
+ const EXPORT_SHIPMENT_XML = 6;
18
+ const EXPORT_CREDITMEMO_CSV = 7;
19
+ const EXPORT_CREDITMEMO_XML = 8;
20
+ const EXPORT_INVOICE_PDF = 9;
21
+ const EXPORT_CUSTOMER_CSV=10;
22
+ const EXPORT_CUSTOMER_XML=11;
23
+
24
+ protected $_list = null;
25
+
26
+ /**
27
+ *
28
+ * @param object $collection
29
+ */
30
+ public function setList($collection) {
31
+ $this->_list = $collection;
32
+ }
33
+
34
+ /**
35
+ *
36
+ * @param array $orders selected order ids
37
+ * @return array
38
+ */
39
+ protected function _getCsvHeaders($orders) {
40
+ $order = current($orders);
41
+ $headers = array_keys($order->getData());
42
+ return $headers;
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param array $orders selected order ids
48
+ * @return array
49
+ */
50
+ protected function _getXmlHeaders($orders) {
51
+ $headers = array();
52
+ $order = current($orders);
53
+ $headers = array_keys($order->getData());
54
+ return $headers;
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param array $orders selected order ids
60
+ * @return array
61
+ */
62
+ public function exportOrderCsv($orders) {
63
+ $collection = Mage::getModel('sales/order')->getCollection()
64
+ ->addAttributeToSelect('*')
65
+ ->addFieldToFilter('entity_id', array('in' => array($orders)));
66
+ $this->setList($collection);
67
+ if (!is_null($this->_list)) {
68
+ $items = $this->_list->getItems();
69
+ if (count($items) > 0) {
70
+
71
+ $io = new Varien_Io_File();
72
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'order';
73
+ $name = 'order_export_' . date("Ymd_His");
74
+ $file = $path . DS . $name . '.csv';
75
+ $io->setAllowCreateFolders(true);
76
+ $io->open(array('path' => $path));
77
+ $io->streamOpen($file, 'w+');
78
+ $io->streamLock(true);
79
+ $io->streamWriteCsv($this->_getCsvHeaders($items));
80
+ foreach ($items as $data) {
81
+ $io->streamWriteCsv($data->getData());
82
+ }
83
+
84
+ return array(
85
+ 'type' => 'filename',
86
+ 'value' => $file,
87
+ 'rm' => false
88
+ );
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @param array $orders selected order ids
96
+ * @return array
97
+ */
98
+ public function exportOrderExcel($orders) {
99
+ $collection = Mage::getModel('sales/order')->getCollection()
100
+ ->addAttributeToSelect('*')
101
+ ->addFieldToFilter('entity_id', array('in' => array($orders)));
102
+ $this->setList($collection);
103
+ if (!is_null($this->_list)) {
104
+ $items = $this->_list->getItems();
105
+ if (count($items) > 0) {
106
+ $parser = new Varien_Convert_Parser_Xml_Excel();
107
+ $io = new Varien_Io_File();
108
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'order';
109
+ $name = 'order_export_' . date("Ymd_His");
110
+ $file = $path . DS . $name . '.xml';
111
+ $io->setAllowCreateFolders(true);
112
+ $io->open(array('path' => $path));
113
+ $io->streamOpen($file, 'w+');
114
+ $io->streamLock(true);
115
+ $headers = $this->_getXmlHeaders($items);
116
+ $io->streamWrite($parser->getHeaderXml());
117
+ $io->streamWrite($parser->getRowXml($headers));
118
+ $val = $collection->getData();
119
+ foreach ($val as $key => $value) {
120
+ $parseData = array();
121
+ foreach ($value as $v) {
122
+ $parseData[] = (string) $v;
123
+ }
124
+ $io->streamWrite($parser->getRowXml($parseData));
125
+ unset($parseData);
126
+ }
127
+ $io->streamWrite($parser->getFooterXml());
128
+ $io->streamUnlock();
129
+ $io->streamClose();
130
+ return array(
131
+ 'type' => 'filename',
132
+ 'value' => $file,
133
+ 'rm' => false
134
+ );
135
+ }
136
+ }
137
+ }
138
+
139
+ }
app/code/community/Uni/Orderexport/Model/Export/ShipmentExportCsv.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Model_Export_ShipmentExportCsv {
11
+
12
+ /**
13
+ *
14
+ * @param object $collection
15
+ */
16
+ public function setList($collection) {
17
+ $this->_list = $collection;
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @param array $shipments selected shipment ids
23
+ * @return array
24
+ */
25
+ protected function _getCsvHeaders($shipments) {
26
+ $shipment = current($shipments);
27
+ $headers = array_keys($shipment->getData());
28
+ return $headers;
29
+ }
30
+
31
+ /**
32
+ *
33
+ * @param array $shipments selected shipment ids
34
+ * @return array
35
+ */
36
+ protected function _getXmlHeaders($shipments) {
37
+ $headers = array();
38
+ $shipment = current($shipments);
39
+ $headers = array_keys($shipment->getData());
40
+ return $headers;
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @param array $shipments selected shipment ids
46
+ * @return array
47
+ */
48
+ public function exportShipmentCsv($shipments) {
49
+ $collection = Mage::getModel('sales/order_shipment')->getCollection()
50
+ ->addAttributeToSelect('*')
51
+ ->addFieldToFilter('entity_id', array('in' => array($shipments)));
52
+ $this->setList($collection);
53
+ if (!is_null($this->_list)) {
54
+ $items = $this->_list->getItems();
55
+ if (count($items) > 0) {
56
+
57
+ $io = new Varien_Io_File();
58
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment';
59
+ $name = 'shipment_export_' . date("Ymd_His");
60
+ $file = $path . DS . $name . '.csv';
61
+ $io->setAllowCreateFolders(true);
62
+ $io->open(array('path' => $path));
63
+ $io->streamOpen($file, 'w+');
64
+ $io->streamLock(true);
65
+
66
+ $io->streamWriteCsv($this->_getCsvHeaders($items));
67
+ foreach ($items as $data) {
68
+ $io->streamWriteCsv($data->getData());
69
+ }
70
+
71
+ return array(
72
+ 'type' => 'filename',
73
+ 'value' => $file,
74
+ 'rm' => false
75
+ );
76
+ }
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param array $shipments selected shipment ids
83
+ * @return array
84
+ */
85
+ public function exportShipmentExcel($shipments) {
86
+ $collection = Mage::getModel('sales/order_shipment')->getCollection()
87
+ ->addAttributeToSelect('*')
88
+ ->addFieldToFilter('entity_id', array('in' => array($shipments)));
89
+ $this->setList($collection);
90
+ if (!is_null($this->_list)) {
91
+ $items = $this->_list->getItems();
92
+ if (count($items) > 0) {
93
+ $parser = new Varien_Convert_Parser_Xml_Excel();
94
+ $io = new Varien_Io_File();
95
+ $path = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment';
96
+ $name = 'shipment_export_' . date("Ymd_His");
97
+ $file = $path . DS . $name . '.xml';
98
+ $io->setAllowCreateFolders(true);
99
+ $io->open(array('path' => $path));
100
+ $io->streamOpen($file, 'w+');
101
+ $io->streamLock(true);
102
+ $headers = $this->_getXmlHeaders($items);
103
+ $io->streamWrite($parser->getHeaderXml());
104
+ $io->streamWrite($parser->getRowXml($headers));
105
+ $val = $collection->getData();
106
+ foreach ($val as $key => $value) {
107
+ $parseData = array();
108
+ foreach ($value as $v) {
109
+ $parseData[] = (string) $v;
110
+ }
111
+ $io->streamWrite($parser->getRowXml($parseData));
112
+ unset($parseData);
113
+ }
114
+ $io->streamWrite($parser->getFooterXml());
115
+ $io->streamUnlock();
116
+ $io->streamClose();
117
+ return array(
118
+ 'type' => 'filename',
119
+ 'value' => $file,
120
+ 'rm' => false
121
+ );
122
+ }
123
+ }
124
+ }
125
+
126
+ }
app/code/community/Uni/Orderexport/Model/Mysql4/Orderexport.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+
11
+ class Uni_Orderexport_Model_Mysql4_Orderexport extends Mage_Core_Model_Mysql4_Abstract {
12
+
13
+ public function _construct() {
14
+ $this->_init('orderexport/orderexport','id');
15
+ }
16
+ }
app/code/community/Uni/Orderexport/Model/Mysql4/Orderexport/Collection.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+
11
+ class Uni_Orderexport_Model_Mysql4_Orderexport_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract{
12
+
13
+ public function _construct(){
14
+ parent::_construct();
15
+ $this->_init('orderexport/orderexport');
16
+ }
17
+ }
app/code/community/Uni/Orderexport/Model/Orderexport.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+
11
+ class Uni_Orderexport_Model_Orderexport extends Mage_Core_Model_Abstract {
12
+
13
+ public function _construct() {
14
+ parent::_construct();
15
+ $this->_init('orderexport/orderexport');
16
+ }
17
+ }
app/code/community/Uni/Orderexport/controllers/Adminhtml/ExportController.php ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Adminhtml_ExportController extends Mage_Adminhtml_Controller_Action {
11
+
12
+ /**
13
+ * Exports csv and xml format of orders.
14
+ */
15
+ public function orderExportAction() {
16
+ $orders = $this->getRequest()->getPost('order_ids', array());
17
+ $_option = $this->getRequest()->getParam('profiles');
18
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
19
+ $file = 'order_export_' . date("Ymd_His") . '.xml';
20
+ $content = Mage::getModel('orderexport/export_OrderExportCsv')->exportOrderExcel($orders);
21
+ Mage::helper('orderexport')->saveHistory($_option, $file);
22
+ $this->_prepareDownloadResponses($file, $content, $_option);
23
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV) {
24
+ $file = 'order_export_' . date("Ymd_His") . '.csv';
25
+ $content = Mage::getModel('orderexport/export_OrderExportCsv')->exportOrderCsv($orders);
26
+ Mage::helper('orderexport')->saveHistory($_option, $file);
27
+ $this->_prepareDownloadResponses($file, $content, $_option);
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Exports csv and xml format of shipment.
33
+ */
34
+ public function shipmentExportAction() {
35
+ $shipments = $this->getRequest()->getPost('shipment_ids', array());
36
+ $_option = $this->getRequest()->getParam('profiles');
37
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
38
+ $file = 'shipment_export_' . date("Ymd_His") . '.xml';
39
+ $content = Mage::getModel('orderexport/export_ShipmentExportCsv')->exportShipmentExcel($shipments);
40
+ Mage::helper('orderexport')->saveHistory($_option, $file);
41
+ $this->_prepareDownloadResponses($file, $content, $_option);
42
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV) {
43
+ $file = 'shipment_export_' . date("Ymd_His") . '.csv';
44
+ $content = Mage::getModel('orderexport/export_ShipmentExportCsv')->exportShipmentCsv($shipments);
45
+ Mage::helper('orderexport')->saveHistory($_option, $file);
46
+ $this->_prepareDownloadResponses($file, $content, $_option);
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Exports csv and xml format of invoice.
52
+ */
53
+ public function invoiceExportAction() {
54
+ $invoices = $this->getRequest()->getPost('invoice_ids', array());
55
+ $_option = $this->getRequest()->getParam('profiles');
56
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML) {
57
+ $file = 'invoice_export_' . date("Ymd_His") . '.xml';
58
+ $content = Mage::getModel('orderexport/export_InvoiceExportCsv')->exportInvoiceExcel($invoices);
59
+ Mage::helper('orderexport')->saveHistory($_option, $file);
60
+ $this->_prepareDownloadResponses($file, $content, $_option);
61
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV) {
62
+ $file = 'invoice_export_' . date("Ymd_His") . '.csv';
63
+ $content = Mage::getModel('orderexport/export_InvoiceExportCsv')->exportInvoiceCsv($invoices);
64
+ Mage::helper('orderexport')->saveHistory($_option, $file);
65
+ $this->_prepareDownloadResponses($file, $content, $_option);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Exports csv and xml format of creditmemo.
71
+ */
72
+ public function creditmemoExportAction() {
73
+ $_option = $this->getRequest()->getParam('profiles');
74
+ $creditmemos = $this->getRequest()->getPost('creditmemo_ids', array());
75
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
76
+ $file = 'creditmemo_export_' . date("Ymd_His") . '.xml';
77
+ $content = Mage::getModel('orderexport/export_CreditmemoExportCsv')->exportCreditmemoExcel($creditmemos);
78
+ Mage::helper('orderexport')->saveHistory($_option, $file);
79
+ $this->_prepareDownloadResponses($file, $content, $_option);
80
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV) {
81
+ $file = 'creditmemo_export_' . date("Ymd_His") . '.csv';
82
+ $content = Mage::getModel('orderexport/export_CreditmemoExportCsv')->exportCreditmemoCsv($creditmemos);
83
+ Mage::helper('orderexport')->saveHistory($_option, $file);
84
+ $this->_prepareDownloadResponses($file, $content, $_option);
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Exports csv and xml format of customer.
90
+ */
91
+ public function customerExportAction() {
92
+ $_option = $this->getRequest()->getParam('profiles');
93
+ $customerIds = $this->getRequest()->getPost('customer', array());
94
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
95
+ $file = 'customer_export_' . date("Ymd_His") . '.xml';
96
+ $content = Mage::getModel('orderexport/export_CustomerExportCsv')->exportCustomerExcel($customerIds);
97
+ Mage::helper('orderexport')->saveHistory($_option, $file);
98
+ $this->_prepareDownloadResponses($file, $content, $_option);
99
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV) {
100
+ $file = 'customer_export_' . date("Ymd_His") . '.csv';
101
+ $content = Mage::getModel('orderexport/export_CustomerExportCsv')->exportCustomerCsv($customerIds);
102
+ Mage::helper('orderexport')->saveHistory($_option, $file);
103
+ $this->_prepareDownloadResponses($file, $content, $_option);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Upload exported file to primary ftp if enabled from backend.
109
+ * @param string $fileName name of exported file.
110
+ * @param string $_option export type id.
111
+ */
112
+ public function customFtpOne($fileName, $_option) {
113
+ $host = Mage::getStoreConfig('ftpexport/primary_ftp/host');
114
+ $ftp_path = Mage::getStoreConfig('ftpexport/primary_ftp/updir');
115
+ $username = Mage::getStoreConfig('ftpexport/primary_ftp/username');
116
+ $pass = Mage::getStoreConfig('ftpexport/primary_ftp/password');
117
+ $port = Mage::getStoreConfig('ftpexport/primary_ftp/port');
118
+ $timeout = Mage::getStoreConfig('ftpexport/primary_ftp/timeout');
119
+ $localpath = '';
120
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
121
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'order' . DS . $fileName;
122
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_PDF) {
123
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice' . DS . $fileName;
124
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
125
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment' . DS . $fileName;
126
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
127
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo' . DS . $fileName;
128
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
129
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer' . DS . $fileName;
130
+ }
131
+ try {
132
+ if ($ftp_path && $username && $pass && $host) {
133
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
134
+ ftp_login($conn, $username, $pass);
135
+ ftp_chdir($conn, $ftp_path);
136
+ ftp_pasv($conn, true);
137
+ chmod($ftp_path, 0777);
138
+ ftp_chmod($conn, 0777, $fileName);
139
+ $upload = ftp_put($conn, $fileName, $localpath, FTP_BINARY);
140
+ if (!$upload) {
141
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File' . $fileName . ' failed to upload on primnary FTP.'));
142
+ }
143
+ ftp_close($conn);
144
+ } else {
145
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Please check the credentials values of FTP is correctly set or not'));
146
+ $this->_redirectReferer();
147
+ }
148
+ } catch (Exception $exc) {
149
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Something went wrong. File has not been uploaded to FTP successfully'));
150
+ $this->_redirectReferer();
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Upload exported file to secondary ftp if enabled from backend.
156
+ * @param string $fileName name of exported file.
157
+ * @param string $_option export type id.
158
+ */
159
+ public function customFtpTwo($fileName, $_option) {
160
+ $host = Mage::getStoreConfig('ftpexport/secondary_ftp/host');
161
+ $ftp_path = Mage::getStoreConfig('ftpexport/secondary_ftp/updir');
162
+ $username = Mage::getStoreConfig('ftpexport/secondary_ftp/username');
163
+ $pass = Mage::getStoreConfig('ftpexport/secondary_ftp/password');
164
+ $port = Mage::getStoreConfig('ftpexport/secondary_ftp/port');
165
+ $timeout = Mage::getStoreConfig('ftpexport/secondary_ftp/timeout');
166
+ $localpath = '';
167
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
168
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'order' . DS . $fileName;
169
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_PDF) {
170
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice' . DS . $fileName;
171
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
172
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment' . DS . $fileName;
173
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
174
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo' . DS . $fileName;
175
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
176
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer' . DS . $fileName;
177
+ }
178
+ try {
179
+ if ($ftp_path && $username && $pass && $host) {
180
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
181
+ ftp_login($conn, $username, $pass);
182
+ ftp_chdir($conn, $ftp_path);
183
+ ftp_pasv($conn, true);
184
+ chmod($ftp_path, 0777);
185
+ ftp_chmod($conn, 0777, $fileName);
186
+ $upload = ftp_put($conn, $fileName, $localpath, FTP_BINARY);
187
+ if (!$upload) {
188
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File' . $fileName . ' failed to upload on secondary ftp.'));
189
+ $this->_redirectReferer();
190
+ }
191
+ ftp_close($conn);
192
+ } else {
193
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Please check the credentials values of FTP is correctly set or not'));
194
+ $this->_redirectReferer();
195
+ }
196
+ } catch (Exception $exc) {
197
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Something went wrong. File has not been uploaded to FTP successfully'));
198
+ $this->_redirectReferer();
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Declare headers and content file in response for file download
204
+ *
205
+ * @param string $fileName
206
+ * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
207
+ * @param string $contentType
208
+ * @param int $contentLength explicit content length, if strlen($content) isn't applicable
209
+ * @return Mage_Core_Controller_Varien_Action
210
+ */
211
+ protected function _prepareDownloadResponses(
212
+ $fileName, $content, $_option, $contentType = 'application/octet-stream', $contentLength = null) {
213
+ $session = Mage::getSingleton('admin/session');
214
+ if ($session->isFirstPageAfterLogin()) {
215
+ $this->_redirect($session->getUser()->getStartupPageUrl());
216
+ return $this;
217
+ }
218
+
219
+ $isFile = false;
220
+ $file = null;
221
+ if (is_array($content)) {
222
+ if (!isset($content['type']) || !isset($content['value'])) {
223
+ return $this;
224
+ }
225
+ if ($content['type'] == 'filename') {
226
+ $isFile = true;
227
+ $file = $content['value'];
228
+ $contentLength = filesize($file);
229
+ if (Mage::getStoreConfig('ftpexport/primary_ftp/enable') == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV) {
230
+ $this->customFtpOne($fileName, $_option);
231
+ }
232
+ if (Mage::getStoreConfig('ftpexport/secondary_ftp/enable') == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV) {
233
+ $this->customFtpTwo($fileName, $_option);
234
+ }
235
+ Mage::helper('orderexport')->sendMail($fileName, $_option); /* send invoice mail */
236
+ }
237
+
238
+ $this->getResponse()
239
+ ->setHttpResponseCode(200)
240
+ ->setHeader('Pragma', 'public', true)
241
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
242
+ ->setHeader('Content-type', $contentType, true)
243
+ ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
244
+ ->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true)
245
+ ->setHeader('Last-Modified', date('r'), true);
246
+
247
+
248
+ if (!is_null($content)) {
249
+ if ($isFile) {
250
+ $this->getResponse()->clearBody();
251
+ $this->getResponse()->sendHeaders();
252
+
253
+ $ioAdapter = new Varien_Io_File();
254
+ $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
255
+ $ioAdapter->streamOpen($file, 'r');
256
+ while ($buffer = $ioAdapter->streamRead()) {
257
+ print $buffer;
258
+ }
259
+ $ioAdapter->streamClose();
260
+ if (!empty($content['rm'])) {
261
+ $ioAdapter->rm($file);
262
+ }
263
+ exit(0);
264
+ } else {
265
+ $this->getResponse()->setBody($content);
266
+ }
267
+ }
268
+ return $this;
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Shows history Grid of exported files.
274
+ */
275
+ public function historyAction() {
276
+ $this->_title($this->__('orderexport'))->_title($this->__('Export History'));
277
+ $this->loadLayout();
278
+ $this->renderLayout();
279
+ }
280
+
281
+ /**
282
+ * Download exported files from /var/export folder through grid .
283
+ */
284
+ public function downloadAction() {
285
+ $id = $this->getRequest()->getParam('id');
286
+ $model = Mage::getModel('orderexport/orderexport')->load($id);
287
+ if ($model->getId() || $id == 0) {
288
+ try {
289
+ if (file_exists($model['destination'] . DS . $model['filename'])) {
290
+ $filename = '';
291
+ if ($model) {
292
+ $filename = $model['filename'];
293
+ }
294
+ $filepath = $model['destination'] . DS . $filename;
295
+
296
+ if (!is_file($filepath) || !is_readable($filepath)) {
297
+ throw new Exception ();
298
+ }
299
+ $this->getResponse()
300
+ ->setHttpResponseCode(200)
301
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
302
+ ->setHeader('Pragma', 'public', true)
303
+ ->setHeader('Content-type', 'application/force-download')
304
+ ->setHeader('Content-Length', filesize($filepath))
305
+ ->setHeader('Content-Disposition', 'attachment' . '; filename=' . basename($filepath));
306
+ $this->getResponse()->clearBody();
307
+ $this->getResponse()->sendHeaders();
308
+ readfile($filepath);
309
+ exit;
310
+ } else {
311
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $model['filename'] . ' does not exist on the Disk'));
312
+ $this->_redirectReferer();
313
+ }
314
+ } catch (Exception $exc) {
315
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $model['filename'] . ' does not exist on the Disk'));
316
+ $this->_redirectReferer();
317
+ }
318
+ } else {
319
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $model['filename'] . ' does not exist on the Disk'));
320
+ $this->_redirectReferer();
321
+ }
322
+ }
323
+
324
+ /**
325
+ * Delete items from grid and from export folder also.
326
+ */
327
+ public function massDeleteAction() {
328
+
329
+ $Ids = $this->getRequest()->getParam('orderexport');
330
+ if (!is_array($Ids)) {
331
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please Choose an Item to Delete'));
332
+ } else {
333
+ try {
334
+ $filename = '';
335
+ $errfile = '';
336
+ $path = '';
337
+ foreach ($Ids as $ids) {
338
+ $order = Mage::getModel('orderexport/orderexport')->load($ids);
339
+ $path = $order['destination'];
340
+ $filename = $order['filename'];
341
+ $order->delete();
342
+ if (file_exists($path . DS . $filename)) {
343
+ unlink($path . DS . $filename);
344
+ $this->deleteFtpOne($filename);
345
+ $this->deleteFtpTwo($filename);
346
+ } else {
347
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $filename . ' does not exist on the Disk'));
348
+ $this->_redirectReferer();
349
+ }
350
+ }
351
+ Mage::getSingleton('adminhtml/session')->addSuccess(
352
+ Mage::helper('adminhtml')->__('Total of %d record(s) successfully deleted', count($Ids))
353
+ );
354
+ } catch (Exception $ex) {
355
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $errfile . ' does not exist on the Disk'));
356
+ $this->_redirectReferer();
357
+ }
358
+ }
359
+ $this->_redirect('*/*/history');
360
+ }
361
+
362
+ /**
363
+ * Delete exported file(s) from Primary FTP.
364
+ * @param string $filename
365
+ */
366
+ public function deleteFtpOne($filename) {
367
+ $host = Mage::getStoreConfig('ftpexport/primary_ftp/host');
368
+ $ftp_path = Mage::getStoreConfig('ftpexport/primary_ftp/updir');
369
+ $username = Mage::getStoreConfig('ftpexport/primary_ftp/username');
370
+ $pass = Mage::getStoreConfig('ftpexport/primary_ftp/password');
371
+ $port = Mage::getStoreConfig('ftpexport/primary_ftp/port');
372
+ $timeout = Mage::getStoreConfig('ftpexport/primary_ftp/timeout');
373
+ try {
374
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
375
+ ftp_login($conn, $username, $pass);
376
+ ftp_delete($conn, $ftp_path . DS . $filename);
377
+ ftp_close($conn);
378
+ } catch (Exception $ex) {
379
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $filename . ' does not exist on the ftp'));
380
+ $this->_redirectReferer();
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Delete exported file(s) from Secondary FTP.
386
+ * @param string $filename
387
+ *
388
+ */
389
+ public function deleteFtpTwo($filename) {
390
+ $host = Mage::getStoreConfig('ftpexport/secondary_ftp/host');
391
+ $ftp_path = Mage::getStoreConfig('ftpexport/secondary_ftp/updir');
392
+ $username = Mage::getStoreConfig('ftpexport/secondary_ftp/username');
393
+ $pass = Mage::getStoreConfig('ftpexport/secondary_ftp/password');
394
+ $port = Mage::getStoreConfig('ftpexport/secondary_ftp/port');
395
+ $timeout = Mage::getStoreConfig('ftpexport/secondary_ftp/timeout');
396
+ try {
397
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
398
+ ftp_login($conn, $username, $pass);
399
+ ftp_delete($conn, $ftp_path . DS . $filename);
400
+ ftp_close($conn);
401
+ } catch (Exception $ex) {
402
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File ' . $filename . ' does not exist on the ftp'));
403
+ $this->_redirectReferer();
404
+ }
405
+ }
406
+
407
+ }
app/code/community/Uni/Orderexport/controllers/Adminhtml/SalesexportController.php ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ class Uni_Orderexport_Adminhtml_SalesexportController extends Mage_Adminhtml_Controller_Action {
11
+
12
+ /**
13
+ * @return Shows manual export form.
14
+ */
15
+ public function manualExportAction() {
16
+ $this->loadLayout();
17
+ $this->_addContent($this->getLayout()->createBlock('orderexport/adminhtml_orderexport'));
18
+ $this->renderLayout();
19
+ }
20
+
21
+ /**
22
+ * Checks selected profile to run.
23
+ */
24
+ public function allExportAction() {
25
+ $data = $this->getRequest()->getPost();
26
+ $_option = $data['profiles'];
27
+ switch ($_option) {
28
+ case 1:
29
+ if ($this->orderValidate($data)) {
30
+ $this->orderExport($data, $_option);
31
+ }break;
32
+ case 2:
33
+ if ($this->orderValidate($data)) {
34
+ $this->orderExport($data, $_option);
35
+ }break;
36
+ case 3:
37
+ if ($this->invoiceValidate($data)) {
38
+ $this->invoiceExport($data, $_option);
39
+ }break;
40
+ case 4:
41
+ if ($this->invoiceValidate($data)) {
42
+ $this->invoiceExport($data, $_option);
43
+ }break;
44
+ case 5:
45
+ if ($this->shipmentValidate($data)) {
46
+ $this->shipmentExport($data, $_option);
47
+ }break;
48
+ case 6:
49
+ if ($this->shipmentValidate($data)) {
50
+ $this->shipmentExport($data, $_option);
51
+ }break;
52
+ case 7:
53
+ if ($this->creditmemoValidate($data)) {
54
+ $this->creditmemoExport($data, $_option);
55
+ } break;
56
+ case 8:
57
+ if ($this->creditmemoValidate($data)) {
58
+ $this->creditmemoExport($data, $_option);
59
+ }break;
60
+ case 10:
61
+ if ($this->customerValidate($data)) {
62
+ $this->customerExport($data, $_option);
63
+ }break;
64
+ case 11:
65
+ if ($this->customerValidate($data)) {
66
+ $this->customerExport($data, $_option);
67
+ }break;
68
+ default:
69
+ break;
70
+ }
71
+ }
72
+
73
+ /**
74
+ *
75
+ * Checks entered order ids are valid or not.
76
+
77
+ * @param array $data manual export post data
78
+ */
79
+ public function orderValidate($data) {
80
+ $collection1 = Mage::getModel('sales/order')->getCollection()
81
+ ->addAttributeToFilter('increment_id', $data['starting_id'])
82
+ ->getData();
83
+ $collection2 = Mage::getModel('sales/order')->getCollection()
84
+ ->addAttributeToFilter('increment_id', $data['ending_id'])
85
+ ->getData();
86
+
87
+ if (empty($collection1)) {
88
+
89
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting ID is not valid. Please enter valid Order ID'));
90
+ $this->_redirectReferer();
91
+ return false;
92
+ } elseif (empty($collection2)) {
93
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Ending ID is not valid. Please enter valid Order ID'));
94
+ $this->_redirectReferer();
95
+ return false;
96
+ } elseif (!empty($collection1) && !empty($collection2)) {
97
+ if ($data['starting_id'] > $data['ending_id']) {
98
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting Order ID is greater than Ending Order ID'));
99
+ $this->_redirectReferer();
100
+ return false;
101
+ } else {
102
+ return true;
103
+ }
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Exports csv and xml format of orders.
109
+ * @param array $data manual export post data
110
+ * @param string $_option export type id
111
+ */
112
+ public function orderExport($data, $_option) {
113
+ $ids = array();
114
+ $collection = Mage::getModel('sales/order')->getCollection();
115
+ $collection->addAttributeToSelect('entity_id')
116
+ ->addAttributeToFilter('increment_id', array(
117
+ 'from' => $data['starting_id'],
118
+ 'to' => $data['ending_id']
119
+ ));
120
+ foreach ($collection->getData() as $key => $value) {
121
+ $ids[] = $value['entity_id'];
122
+ }
123
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV) {
124
+ $file = 'order_export_' . date("Ymd_His") . '.csv';
125
+ $content = Mage::getModel('orderexport/export_OrderExportCsv')->exportOrderCsv($ids);
126
+ Mage::helper('orderexport')->saveHistory($_option, $file);
127
+ $this->_prepareDownloadResponses($file, $content, $_option);
128
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
129
+ $file = 'order_export_' . date("Ymd_His") . '.xml';
130
+ $content = Mage::getModel('orderexport/export_OrderExportCsv')->exportOrderExcel($ids);
131
+ Mage::helper('orderexport')->saveHistory($_option, $file);
132
+ $this->_prepareDownloadResponses($file, $content, $_option);
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Checks entered invoice ids are valid or not.
138
+ * @param array $data manual export post data
139
+ */
140
+ public function invoiceValidate($data) {
141
+ $collection1 = Mage::getModel('sales/order_invoice')->getCollection()
142
+ ->addAttributeToFilter('increment_id', $data['starting_id'])
143
+ ->getData();
144
+ $collection2 = Mage::getModel('sales/order_invoice')->getCollection()
145
+ ->addAttributeToFilter('increment_id', $data['ending_id'])
146
+ ->getData();
147
+
148
+ if (empty($collection1)) {
149
+
150
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting ID is not valid. Please enter valid Order ID'));
151
+ $this->_redirectReferer();
152
+ return false;
153
+ } elseif (empty($collection2)) {
154
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Ending ID is not valid. Please enter valid Order ID'));
155
+ $this->_redirectReferer();
156
+ return false;
157
+ } elseif (!empty($collection1) && !empty($collection2)) {
158
+ if ($data['starting_id'] > $data['ending_id']) {
159
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting Order ID is greater than Ending Order ID'));
160
+ $this->_redirectReferer();
161
+ return false;
162
+ } else {
163
+ return true;
164
+ }
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Exports csv and xml format of invoices.
170
+ * @param array $data manual export post data
171
+ * @param string $_option export type id
172
+ */
173
+ public function invoiceExport($data, $_option) {
174
+ $ids = array();
175
+ $collection = Mage::getModel('sales/order_invoice')->getCollection();
176
+ $collection->addAttributeToSelect('entity_id')
177
+ ->addAttributeToFilter('increment_id', array(
178
+ 'from' => $data['starting_id'],
179
+ 'to' => $data['ending_id']
180
+ ));
181
+ foreach ($collection->getData() as $key => $value) {
182
+ $ids[] = $value['entity_id'];
183
+ }
184
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML) {
185
+ $file = 'invoice_export_' . date("Ymd_His") . '.xml';
186
+ $content = Mage::getModel('orderexport/export_InvoiceExportCsv')->exportInvoiceExcel($ids);
187
+ Mage::helper('orderexport')->saveHistory($_option, $file);
188
+ $this->_prepareDownloadResponses($file, $content, $_option);
189
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV) {
190
+ $file = 'invoice_export_' . date("Ymd_His") . '.csv';
191
+ $content = Mage::getModel('orderexport/export_InvoiceExportCsv')->exportInvoiceCsv($ids);
192
+ Mage::helper('orderexport')->saveHistory($_option, $file);
193
+ $this->_prepareDownloadResponses($file, $content, $_option);
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Checks entered shipment ids are valid or not.
199
+ * @param array $data manual export post data
200
+ */
201
+ public function shipmentValidate($data) {
202
+ $collection1 = Mage::getModel('sales/order_shipment')->getCollection()
203
+ ->addAttributeToFilter('increment_id', $data['starting_id'])
204
+ ->getData();
205
+ $collection2 = Mage::getModel('sales/order_shipment')->getCollection()
206
+ ->addAttributeToFilter('increment_id', $data['ending_id'])
207
+ ->getData();
208
+ if (empty($collection1)) {
209
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting ID is not valid. Please enter valid Order ID'));
210
+ $this->_redirectReferer();
211
+ return false;
212
+ } elseif (empty($collection2)) {
213
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Ending ID is not valid. Please enter valid Order ID'));
214
+ $this->_redirectReferer();
215
+ return false;
216
+ } elseif (!empty($collection1) && !empty($collection2)) {
217
+ if ($data['starting_id'] > $data['ending_id']) {
218
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting Order ID is greater than Ending Order ID'));
219
+ $this->_redirectReferer();
220
+ return false;
221
+ } else {
222
+ return true;
223
+ }
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Exports csv and xml format of shipments.
229
+ * @param array $data manual export post data
230
+ * @param string $_option export type id
231
+ */
232
+ public function shipmentExport($data, $_option) {
233
+ $ids = array();
234
+ $collection = Mage::getModel('sales/order_shipment')->getCollection();
235
+ $collection->addAttributeToSelect('entity_id')
236
+ ->addAttributeToFilter('increment_id', array(
237
+ 'from' => $data['starting_id'],
238
+ 'to' => $data['ending_id']
239
+ ));
240
+ foreach ($collection->getData() as $key => $value) {
241
+ $ids[] = $value['entity_id'];
242
+ }
243
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
244
+ $file = 'shipment_export_' . date("Ymd_His") . '.xml';
245
+ $content = Mage::getModel('orderexport/export_ShipmentExportCsv')->exportShipmentExcel($ids);
246
+ Mage::helper('orderexport')->saveHistory($_option, $file);
247
+ $this->_prepareDownloadResponses($file, $content, $_option);
248
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV) {
249
+ $file = 'shipment_export_' . date("Ymd_His") . '.csv';
250
+ $content = Mage::getModel('orderexport/export_ShipmentExportCsv')->exportShipmentCsv($ids);
251
+ Mage::helper('orderexport')->saveHistory($_option, $file);
252
+ $this->_prepareDownloadResponses($file, $content, $_option);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * Checks entered creditmemo ids are valid or not.
258
+ * @param array $data manual export post data
259
+ */
260
+ public function creditmemoValidate($data) {
261
+ $collection1 = Mage::getModel('sales/order_creditmemo')->getCollection()
262
+ ->addAttributeToFilter('increment_id', $data['starting_id'])
263
+ ->getData();
264
+ $collection2 = Mage::getModel('sales/order_creditmemo')->getCollection()
265
+ ->addAttributeToFilter('increment_id', $data['ending_id'])
266
+ ->getData();
267
+
268
+ if (empty($collection1)) {
269
+
270
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting ID is not valid. Please enter valid Order ID'));
271
+ $this->_redirectReferer();
272
+ return false;
273
+ } elseif (empty($collection2)) {
274
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Ending ID is not valid. Please enter valid Order ID'));
275
+ $this->_redirectReferer();
276
+ return false;
277
+ } elseif (!empty($collection1) && !empty($collection2)) {
278
+ if ($data['starting_id'] > $data['ending_id']) {
279
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting Order ID is greater than Ending Order ID'));
280
+ $this->_redirectReferer();
281
+ return false;
282
+ } else {
283
+ return true;
284
+ }
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Exports csv and xml format of creditmemos.
290
+ * @param array $data manual export post data
291
+ * @param string $_option export type id
292
+ */
293
+ public function creditmemoExport($data, $_option) {
294
+ $ids = array();
295
+ $collection = Mage::getModel('sales/order_creditmemo')->getCollection();
296
+ $collection->addAttributeToSelect('entity_id')
297
+ ->addAttributeToFilter('increment_id', array(
298
+ 'from' => $data['starting_id'],
299
+ 'to' => $data['ending_id']
300
+ ));
301
+ foreach ($collection->getData() as $key => $value) {
302
+ $ids[] = $value['entity_id'];
303
+ }
304
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
305
+ $file = 'creditmemo_export_' . date("Ymd_His") . '.xml';
306
+ $content = Mage::getModel('orderexport/export_CreditmemoExportCsv')->exportCreditmemoExcel($ids);
307
+ Mage::helper('orderexport')->saveHistory($_option, $file);
308
+ $this->_prepareDownloadResponses($file, $content, $_option);
309
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV) {
310
+ $file = 'creditmemo_export_' . date("Ymd_His") . '.csv';
311
+ $content = Mage::getModel('orderexport/export_CreditmemoExportCsv')->exportCreditmemoCsv($ids);
312
+ Mage::helper('orderexport')->saveHistory($_option, $file);
313
+ $this->_prepareDownloadResponses($file, $content, $_option);
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Checks entered customer ids are valid or not.
319
+ * @param array $data manual export post data
320
+ */
321
+ public function customerValidate($data) {
322
+ $collection1 = Mage::getModel('customer/customer')->getCollection();
323
+ $collection1 = Mage::getModel('customer/customer')->getCollection()
324
+ ->addAttributeToFilter('entity_id', $data['starting_id'])
325
+ ->getData();
326
+ $collection2 = Mage::getModel('customer/customer')->getCollection()
327
+ ->addAttributeToFilter('entity_id', $data['ending_id'])
328
+ ->getData();
329
+
330
+ if (empty($collection1)) {
331
+
332
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting ID is not valid. Please enter valid Order ID'));
333
+ $this->_redirectReferer();
334
+ return false;
335
+ } elseif (empty($collection2)) {
336
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Ending ID is not valid. Please enter valid Order ID'));
337
+ $this->_redirectReferer();
338
+ return false;
339
+ } elseif (!empty($collection1) && !empty($collection2)) {
340
+ if ($data['starting_id'] > $data['ending_id']) {
341
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Starting Order ID is greater than Ending Order ID'));
342
+ $this->_redirectReferer();
343
+ return false;
344
+ } else {
345
+ return true;
346
+ }
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Exports csv and xml format of customers.
352
+ * @param array $data manual export post data
353
+ * @param string $_option export type id
354
+ */
355
+ public function customerExport($data, $_option) {
356
+ $ids = array();
357
+ $collection = Mage::getModel('customer/customer')->getCollection();
358
+
359
+ $collection->addAttributeToSelect('entity_id')
360
+ ->addAttributeToFilter('entity_id', array(
361
+ 'from' => $data['starting_id'],
362
+ 'to' => $data['ending_id']
363
+ ));
364
+ foreach ($collection->getData() as $key => $value) {
365
+ $ids[] = $value['entity_id'];
366
+ }
367
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
368
+ $file = 'customer_export_' . date("Ymd_His") . '.xml';
369
+ $content = Mage::getModel('orderexport/export_CustomerExportCsv')->exportCustomerExcel($ids);
370
+ Mage::helper('orderexport')->saveHistory($_option, $file);
371
+ $this->_prepareDownloadResponses($file, $content, $_option);
372
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV) {
373
+ $file = 'customer_export_' . date("Ymd_His") . '.csv';
374
+ $content = Mage::getModel('orderexport/export_CustomerExportCsv')->exportCustomerCsv($ids);
375
+ Mage::helper('orderexport')->saveHistory($_option, $file);
376
+ $this->_prepareDownloadResponses($file, $content, $_option);
377
+ }
378
+ }
379
+
380
+ /**
381
+ * Upload exported file to primary ftp if enabled from backend.
382
+ * @param string $fileName name of exported file.
383
+ * @param string $_option export type id.
384
+ */
385
+ public function customFtpOne($fileName, $_option) {
386
+ $host = Mage::getStoreConfig('ftpexport/primary_ftp/host');
387
+ $ftp_path = Mage::getStoreConfig('ftpexport/primary_ftp/updir');
388
+ $username = Mage::getStoreConfig('ftpexport/primary_ftp/username');
389
+ $pass = Mage::getStoreConfig('ftpexport/primary_ftp/password');
390
+ $port = Mage::getStoreConfig('ftpexport/primary_ftp/port');
391
+ $timeout = Mage::getStoreConfig('ftpexport/primary_ftp/timeout');
392
+ $localpath = '';
393
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
394
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'order' . DS . $fileName;
395
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_PDF) {
396
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice' . DS . $fileName;
397
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
398
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment' . DS . $fileName;
399
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
400
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo' . DS . $fileName;
401
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
402
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer' . DS . $fileName;
403
+ }
404
+ try {
405
+ if ($ftp_path && $username && $pass && $host) {
406
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
407
+ ftp_login($conn, $username, $pass);
408
+ ftp_chdir($conn, $ftp_path);
409
+ ftp_pasv($conn, true);
410
+ chmod($ftp_path, 0777);
411
+ ftp_chmod($conn, 0777, $fileName);
412
+ $upload = ftp_put($conn, $fileName, $localpath, FTP_BINARY);
413
+ if (!$upload) {
414
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File' . $fileName . ' failed to upload on primnary FTP.'));
415
+ }
416
+ ftp_close($conn);
417
+ } else {
418
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Please check the credentials values of FTP is correctly set or not'));
419
+ $this->_redirectReferer();
420
+ }
421
+ } catch (Exception $exc) {
422
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Something went wrong. File has not been uploaded successfully'));
423
+ $this->_redirectReferer();
424
+ }
425
+ }
426
+
427
+ /**
428
+ * Upload exported file to secondary ftp if enabled from backend.
429
+ * @param string $fileName name of exported file.
430
+ * @param string $_option export type id.
431
+ */
432
+ public function customFtpTwo($fileName, $_option) {
433
+ $host = Mage::getStoreConfig('ftpexport/secondary_ftp/host');
434
+ $ftp_path = Mage::getStoreConfig('ftpexport/secondary_ftp/updir');
435
+ $username = Mage::getStoreConfig('ftpexport/secondary_ftp/username');
436
+ $pass = Mage::getStoreConfig('ftpexport/secondary_ftp/password');
437
+ $port = Mage::getStoreConfig('ftpexport/secondary_ftp/port');
438
+ $timeout = Mage::getStoreConfig('ftpexport/secondary_ftp/timeout');
439
+ $localpath = '';
440
+ if ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_ORDER_XML) {
441
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'order' . DS . $fileName;
442
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_XML || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_INVOICE_PDF) {
443
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'invoice' . DS . $fileName;
444
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_SHIPMENT_XML) {
445
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'shipment' . DS . $fileName;
446
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CREDITMEMO_XML) {
447
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'creditmemo' . DS . $fileName;
448
+ } elseif ($_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_CSV || $_option == Uni_Orderexport_Model_Export_OrderExportCsv::EXPORT_CUSTOMER_XML) {
449
+ $localpath = Mage::getBaseDir('var') . DS . 'export' . DS . 'customer' . DS . $fileName;
450
+ }
451
+ try {
452
+ if ($ftp_path && $username && $pass && $host) {
453
+ $conn = ftp_connect($host, $port ? $port : '21', $timeout ? $timeout : '90');
454
+ ftp_login($conn, $username, $pass);
455
+ ftp_chdir($conn, $ftp_path);
456
+ ftp_pasv($conn, true);
457
+ chmod($ftp_path, 0777);
458
+ ftp_chmod($conn, 0777, $fileName);
459
+ $upload = ftp_put($conn, $fileName, $localpath, FTP_BINARY);
460
+ if (!$upload) {
461
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('File' . $fileName . ' failed to upload on secondary ftp.'));
462
+ $this->_redirectReferer();
463
+ }
464
+ ftp_close($conn);
465
+ } else {
466
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Please check the credentials values of FTP is correctly set or not'));
467
+ $this->_redirectReferer();
468
+ }
469
+ } catch (Exception $exc) {
470
+ Mage::getSingleton('core/session')->addError(Mage::helper('orderexport')->__('Something went wrong. File has not been uploaded successfully'));
471
+ $this->_redirectReferer();
472
+ }
473
+ }
474
+
475
+ /**
476
+ * Declare headers and content file in response for file download
477
+ *
478
+ * @param string $fileName
479
+ * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
480
+ * that case
481
+ * @param string $contentType
482
+ * @param int $contentLength explicit content length, if strlen($content) isn't applicable
483
+ * @return Mage_Core_Controller_Varien_Action
484
+ */
485
+ protected function _prepareDownloadResponses(
486
+ $fileName, $content, $_option, $contentType = 'application/octet-stream', $contentLength = null) {
487
+ $session = Mage::getSingleton('admin/session');
488
+ if ($session->isFirstPageAfterLogin()) {
489
+ $this->_redirect($session->getUser()->getStartupPageUrl());
490
+ return $this;
491
+ }
492
+
493
+ $isFile = false;
494
+ $file = null;
495
+ if (is_array($content)) {
496
+ if (!isset($content['type']) || !isset($content['value'])) {
497
+ return $this;
498
+ }
499
+ if ($content['type'] == 'filename') {
500
+ $isFile = true;
501
+ $file = $content['value'];
502
+ $contentLength = filesize($file);
503
+ if (Mage::getStoreConfig('ftpexport/primary_ftp/enable') == 1) {
504
+ $this->customFtpOne($fileName, $_option);
505
+ }
506
+ if (Mage::getStoreConfig('ftpexport/secondary_ftp/enable') == 1) {
507
+ $this->customFtpTwo($fileName, $_option);
508
+ }
509
+ Mage::helper('orderexport')->sendMail($fileName, $_option); /* send invoice mail */
510
+ }
511
+ }
512
+
513
+ $this->getResponse()
514
+ ->setHttpResponseCode(200)
515
+ ->setHeader('Pragma', 'public', true)
516
+ ->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
517
+ ->setHeader('Content-type', $contentType, true)
518
+ ->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)
519
+ ->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true)
520
+ ->setHeader('Last-Modified', date('r'), true);
521
+
522
+
523
+ if (!is_null($content)) {
524
+ if ($isFile) {
525
+ $this->getResponse()->clearBody();
526
+ $this->getResponse()->sendHeaders();
527
+
528
+ $ioAdapter = new Varien_Io_File();
529
+ $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
530
+ $ioAdapter->streamOpen($file, 'r');
531
+ while ($buffer = $ioAdapter->streamRead()) {
532
+ print $buffer;
533
+ }
534
+ $ioAdapter->streamClose();
535
+ if (!empty($content['rm'])) {
536
+ $ioAdapter->rm($file);
537
+ }
538
+ exit(0);
539
+ } else {
540
+ $this->getResponse()->setBody($content);
541
+ }
542
+ }
543
+ return $this;
544
+ }
545
+
546
+ }
app/code/community/Uni/Orderexport/etc/adminhtml.xml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <menu>
13
+ <sales translate="title" module="sales">
14
+ <title>Sales</title>
15
+ <sort_order>20</sort_order>
16
+ <depends>
17
+ <module>Mage_Sales</module>
18
+ </depends>
19
+ <children>
20
+ <sales_export translate="title" module="orderexport">
21
+ <title>Sales Export</title>
22
+ <sort_order>50</sort_order>
23
+ <children>
24
+ <manual_export translate="title" module="orderexport">
25
+ <title>Manual Export</title>
26
+ <sort_order>0</sort_order>
27
+ <action>orderexport/adminhtml_salesexport/manualExport</action>
28
+ </manual_export>
29
+
30
+ <execution_history translate="title" module="orderexport">
31
+ <title>Execution History</title>
32
+ <sort_order>2</sort_order>
33
+ <action>orderexport/adminhtml_export/history</action>
34
+ </execution_history>
35
+
36
+ </children>
37
+ </sales_export>
38
+ </children>
39
+ </sales>
40
+ </menu>
41
+ <acl>
42
+ <resources>
43
+ <admin>
44
+ <children>
45
+ <system>
46
+ <children>
47
+ <config>
48
+ <children>
49
+ <orderexport translate="title" module="orderexport">
50
+ <title>Order Export Section</title>
51
+ <sort_order>0</sort_order>
52
+ </orderexport>
53
+ <ftpexport translate="title" module="orderexport">
54
+ <title>FTP settings</title>
55
+ <sort_order>1</sort_order>
56
+ </ftpexport>
57
+ </children>
58
+ </config>
59
+ </children>
60
+ </system>
61
+ </children>
62
+ </admin>
63
+ </resources>
64
+ </acl>
65
+ </config>
app/code/community/Uni/Orderexport/etc/config.xml ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <modules>
13
+ <Uni_Orderexport>
14
+ <version>0.1.0</version>
15
+ </Uni_Orderexport>
16
+ </modules>
17
+ <admin>
18
+ <routers>
19
+ <adminhtml>
20
+ <args>
21
+ <modules>
22
+ <Uni_Orderexport before="Mage_Adminhtml">Uni_Orderexport</Uni_Orderexport>
23
+ </modules>
24
+ </args>
25
+ </adminhtml>
26
+ <orderexport>
27
+ <use>admin</use>
28
+ <args>
29
+ <module>Uni_Orderexport</module>
30
+ <frontName>orderexport</frontName>
31
+ </args>
32
+ </orderexport>
33
+ </routers>
34
+ </admin>
35
+ <adminhtml>
36
+ <layout>
37
+ <updates>
38
+ <orderexport>
39
+ <file>orderexport.xml</file>
40
+ </orderexport>
41
+ </updates>
42
+ </layout>
43
+ </adminhtml>
44
+ <global>
45
+ <template>
46
+ <email>
47
+ <orderexport_email_email_template translate="label" module="orderexport">
48
+ <label>Order Export Form</label>
49
+ <file>orderexport_form.html</file>
50
+ <type>html</type>
51
+ </orderexport_email_email_template>
52
+ </email>
53
+ </template>
54
+ <models>
55
+ <orderexport>
56
+ <class>Uni_Orderexport_Model</class>
57
+ <resourceModel>orderexport_mysql4</resourceModel>
58
+ </orderexport>
59
+ <orderexport_mysql4>
60
+ <class>Uni_Orderexport_Model_Mysql4</class>
61
+ <entities>
62
+ <orderexport>
63
+ <table>exporthistory</table>
64
+ </orderexport>
65
+ </entities>
66
+ </orderexport_mysql4>
67
+ </models>
68
+ <resources>
69
+ <orderexport_setup>
70
+ <setup>
71
+ <module>Uni_Orderexport</module>
72
+ </setup>
73
+ <connection>
74
+ <use>core_setup</use>
75
+ </connection>
76
+ </orderexport_setup>
77
+ <orderexport_write>
78
+ <connection>
79
+ <use>core_write</use>
80
+ </connection>
81
+ </orderexport_write>
82
+ <orderexport_read>
83
+ <connection>
84
+ <use>core_read</use>
85
+ </connection>
86
+ </orderexport_read>
87
+ </resources>
88
+ <helpers>
89
+ <orderexport>
90
+ <class>Uni_Orderexport_Helper</class>
91
+ </orderexport>
92
+ </helpers>
93
+ <blocks>
94
+ <orderexport>
95
+ <class>Uni_Orderexport_Block</class>
96
+ </orderexport>
97
+ <adminhtml>
98
+ <rewrite>
99
+ <sales_order_grid>Uni_Orderexport_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
100
+ </rewrite>
101
+ </adminhtml>
102
+ <adminhtml>
103
+ <rewrite>
104
+ <sales_creditmemo_grid>Uni_Orderexport_Block_Adminhtml_Sales_Creditmemo_Grid</sales_creditmemo_grid>
105
+ </rewrite>
106
+ </adminhtml>
107
+ <adminhtml>
108
+ <rewrite>
109
+ <sales_invoice_grid>Uni_Orderexport_Block_Adminhtml_Sales_Invoice_Grid</sales_invoice_grid>
110
+ </rewrite>
111
+ </adminhtml>
112
+ <adminhtml>
113
+ <rewrite>
114
+ <sales_shipment_grid>Uni_Orderexport_Block_Adminhtml_Sales_Shipment_Grid</sales_shipment_grid>
115
+ </rewrite>
116
+ </adminhtml>
117
+ <adminhtml>
118
+ <rewrite>
119
+ <customer_grid>Uni_Orderexport_Block_Adminhtml_Customer_Grid</customer_grid>
120
+ </rewrite>
121
+ </adminhtml>
122
+ </blocks>
123
+ </global>
124
+ </config>
app/code/community/Uni/Orderexport/etc/system.xml ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ -->
11
+ <config>
12
+ <tabs>
13
+ <order_export translate="label" module="orderexport">
14
+ <label>Unicode Order Export Extension</label>
15
+ <sort_order>0</sort_order>
16
+ </order_export>
17
+ </tabs>
18
+ <sections>
19
+ <orderexport translate="label" module="orderexport">
20
+ <label>Email Settings</label>
21
+ <tab>order_export</tab>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>0</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <groups>
28
+ <order_email translate="label">
29
+ <label>Email Setting For Exporting Orders</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <fields>
36
+ <order_export_name translate="label">
37
+ <label>Recipient Name</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>0</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </order_export_name>
44
+ <order_export_email translate="label">
45
+ <label>Recipient Email</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </order_export_email>
52
+ </fields>
53
+ </order_email>
54
+
55
+ <invoice_email translate="label">
56
+ <label>Email Setting For Export Invoices</label>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>1</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ <fields>
63
+ <invoice_export_name translate="label">
64
+ <label>Recipient Name</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>0</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </invoice_export_name>
71
+ <invoice_export_email translate="label">
72
+ <label>Recipient Email</label>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>1</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </invoice_export_email>
79
+ </fields>
80
+ </invoice_email>
81
+
82
+ <shipment_email translate="label">
83
+ <label>Email Setting For Export Shipments</label>
84
+ <frontend_type>text</frontend_type>
85
+ <sort_order>2</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <fields>
90
+ <shipment_export_name translate="label">
91
+ <label>Recipient Name</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>0</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </shipment_export_name>
98
+ <shipment_export_email translate="label">
99
+ <label>Recipient Email</label>
100
+ <frontend_type>text</frontend_type>
101
+ <sort_order>1</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </shipment_export_email>
106
+ </fields>
107
+ </shipment_email>
108
+
109
+ <creditmemo_email translate="label">
110
+ <label>Email Setting For Export Creditmemos</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>3</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ <fields>
117
+ <creditmemo_export_name translate="label">
118
+ <label>Recipient Name</label>
119
+ <frontend_type>text</frontend_type>
120
+ <sort_order>0</sort_order>
121
+ <show_in_default>1</show_in_default>
122
+ <show_in_website>1</show_in_website>
123
+ <show_in_store>1</show_in_store>
124
+ </creditmemo_export_name>
125
+ <creditmemo_export_email translate="label">
126
+ <label>Recipient Email</label>
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>1</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ </creditmemo_export_email>
133
+ </fields>
134
+ </creditmemo_email>
135
+
136
+ <customer_email translate="label">
137
+ <label>Email Setting For Export Customers</label>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>4</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ <fields>
144
+ <customer_export_name translate="label">
145
+ <label>Recipient Name</label>
146
+ <frontend_type>text</frontend_type>
147
+ <sort_order>0</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ </customer_export_name>
152
+ <customer_export_email translate="label">
153
+ <label>Recipient Email</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>1</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </customer_export_email>
160
+ </fields>
161
+ </customer_email>
162
+ </groups>
163
+ </orderexport>
164
+ <ftpexport translate="label" module="orderexport">
165
+ <label>FTP Credentials Details</label>
166
+ <tab>order_export</tab>
167
+ <frontend_type>text</frontend_type>
168
+ <sort_order>1</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ <groups>
173
+ <primary_ftp translate="label">
174
+ <label>Primary FTP Credential</label>
175
+ <frontend_type>text</frontend_type>
176
+ <sort_order>0</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ <fields>
181
+ <host translate="label">
182
+ <label>Host</label>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>2</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ </host>
189
+ <username translate="label">
190
+ <label>Username</label>
191
+ <frontend_type>text</frontend_type>
192
+ <sort_order>3</sort_order>
193
+ <show_in_default>1</show_in_default>
194
+ <show_in_website>1</show_in_website>
195
+ <show_in_store>1</show_in_store>
196
+ </username>
197
+ <password translate="label">
198
+ <label>Password</label>
199
+ <frontend_type>text</frontend_type>
200
+ <sort_order>4</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>1</show_in_store>
204
+ </password>
205
+ <port translate="label">
206
+ <label>Port</label>
207
+ <frontend_type>text</frontend_type>
208
+ <sort_order>1</sort_order>
209
+ <show_in_default>1</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>1</show_in_store>
212
+ <comment>Default is 21.</comment>
213
+ </port>
214
+ <timeout translate="label">
215
+ <label>Timeout</label>
216
+ <frontend_type>text</frontend_type>
217
+ <sort_order>1</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ <comment>Default is 90 seconds.</comment>
222
+ </timeout>
223
+ <updir translate="label">
224
+ <label>Upload Directory</label>
225
+ <frontend_type>text</frontend_type>
226
+ <sort_order>5</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ <comment>This is the absolute path to the directory on the FTP server. This directory has to exist on the FTP server.</comment>
231
+ </updir>
232
+ <enable translate="label">
233
+ <label>Enable</label>
234
+ <frontend_type>select</frontend_type>
235
+ <sort_order>0</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ <source_model>adminhtml/system_config_source_yesno</source_model>
240
+ <comment>If yes the exported files will be saved to the upload ftp.</comment>
241
+ </enable>
242
+ </fields>
243
+ </primary_ftp>
244
+ <secondary_ftp translate="label">
245
+ <label>Secondary FTP Credential</label>
246
+ <frontend_type>text</frontend_type>
247
+ <sort_order>1</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ <fields>
252
+ <host translate="label">
253
+ <label>Host</label>
254
+ <frontend_type>text</frontend_type>
255
+ <sort_order>2</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ </host>
260
+ <username translate="label">
261
+ <label>Username</label>
262
+ <frontend_type>text</frontend_type>
263
+ <sort_order>3</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </username>
268
+ <password translate="label">
269
+ <label>Password</label>
270
+ <frontend_type>text</frontend_type>
271
+ <sort_order>4</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>1</show_in_store>
275
+ </password>
276
+ <port translate="label">
277
+ <label>Port</label>
278
+ <frontend_type>text</frontend_type>
279
+ <sort_order>1</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>1</show_in_store>
283
+ <comment>Default is 21.</comment>
284
+ </port>
285
+ <timeout translate="label">
286
+ <label>Timeout</label>
287
+ <frontend_type>text</frontend_type>
288
+ <sort_order>1</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>1</show_in_store>
292
+ <comment>Default is 90 seconds.</comment>
293
+ </timeout>
294
+ <updir translate="label">
295
+ <label>Upload Directory</label>
296
+ <frontend_type>text</frontend_type>
297
+ <sort_order>5</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>1</show_in_store>
301
+ <comment>This is the absolute path to the directory on the FTP server. This directory has to exist on the FTP server.</comment>
302
+ </updir>
303
+ <enable translate="label">
304
+ <label>Enable</label>
305
+ <frontend_type>select</frontend_type>
306
+ <sort_order>0</sort_order>
307
+ <show_in_default>1</show_in_default>
308
+ <show_in_website>1</show_in_website>
309
+ <show_in_store>1</show_in_store>
310
+ <source_model>adminhtml/system_config_source_yesno</source_model>
311
+ <comment>If yes the exported files will be saved to the upload ftp.</comment>
312
+ </enable>
313
+ </fields>
314
+ </secondary_ftp>
315
+ </groups>
316
+ </ftpexport>
317
+ </sections>
318
+ </config>
app/code/community/Uni/Orderexport/sql/orderexport_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Unicode Systems
5
+ * @category Uni
6
+ * @package Uni_Orderexport
7
+ * @copyright Copyright (c) 2010-2011 Unicode Systems. (http://www.unicodesystems.in)
8
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
9
+ */
10
+ $installer = $this;
11
+
12
+ $installer->startSetup();
13
+
14
+ $installer->run("
15
+
16
+ DROP TABLE IF EXISTS {$this->getTable('exporthistory')};
17
+ CREATE TABLE {$this->getTable('exporthistory')} (
18
+ `id` int(11) unsigned NOT NULL auto_increment,
19
+ `profile` varchar(255) NOT NULL default '',
20
+ `created_time` datetime NULL,
21
+ `filename` varchar(255) NOT NULL default '',
22
+ `destination` varchar(255) NOT NULL default '',
23
+ PRIMARY KEY (`id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
25
+
26
+ ");
27
+
28
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/orderexport.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.1.0">
3
+ <orderexport_adminhtml_export_history>
4
+ <reference name="content">
5
+ <block type="orderexport/adminhtml_export" name="orderexport"/>
6
+ </reference>
7
+ </orderexport_adminhtml_export_history>
8
+ </layout>
app/etc/modules/Uni_Orderexport.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Uni_Orderexport>
5
+ <active>1</active>
6
+ <codePool>community</codePool>
7
+ <version>0.1.0</version>
8
+ <depends>Mage_Adminhtml</depends>
9
+ </Uni_Orderexport>
10
+ </modules>
11
+ </config>
app/locale/en_US/template/email/orderexport_form.html ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <!--@subject Export File@-->
2
+ <!--@vars
3
+
4
+ @-->
5
+ <p>Exported File</p>
6
+ <p>Attachments Are Below : </p>
7
+ <b>Sender Name :</b> {{var name}}<br>
8
+ <b>Sender E-mail :</b> {{var email}}<br>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Order_Export</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Exporting orders/invoices/shipments/creditmemos/customer into CSV/XML formats.</summary>
10
+ <description>Exporting orders/invoices/shipments/creditmemos/customer into CSV/XML formats.&#xD;
11
+ Sending the exported files of one profile to two FTP servers and one email recipient.&#xD;
12
+ Exporting orders/invoices/shipments/creditmemos/customer on demand for accounting purposes right from the Magento backend.</description>
13
+ <notes>This is first release.</notes>
14
+ <authors><author><name>Unicode Systems</name><user>Unicode_Systems</user><email>magento@unicodesystems.in</email></author></authors>
15
+ <date>2015-01-22</date>
16
+ <time>10:43:10</time>
17
+ <contents><target name="magecommunity"><dir name="Uni"><dir name="Orderexport"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Grid.php" hash="33ae40db46a6ac2059aa1036aa17f827"/></dir><file name="Export.php" hash="ae915c93cccb65f0f8629eeeb95fe540"/><dir name="Orderexport"><dir name="Edit"><file name="Form.php" hash="0f02c1be8e9d851164d25b809c20d498"/></dir><file name="Grid.php" hash="0e83322d152e73571a1e94e60655183f"/></dir><file name="Orderexport.php" hash="144906f08ca09e4a2afafaf259463aa3"/><dir name="Sales"><dir name="Creditmemo"><file name="Grid.php" hash="f114ecfbfd0ad51514f3f6c885a4ddd7"/></dir><dir name="Invoice"><file name="Grid.php" hash="a4b48c5fe30d168379711868e2d07f99"/></dir><dir name="Order"><file name="Grid.php" hash="d3be8928d9682c361e9856e34d0d79cc"/></dir><dir name="Shipment"><file name="Grid.php" hash="761259bf4d1294b00bf1d55993c9bf6c"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="b57f319caa4983466e96e93b35d22791"/></dir><dir name="Model"><dir name="Export"><file name="CreditmemoExportCsv.php" hash="0d40c43ec5e624e3dd8e7fef66ba3dce"/><file name="CustomerExportCsv.php" hash="7ae6099412be095d6c82ef55b15b25e2"/><file name="InvoiceExportCsv.php" hash="5babcaa05599fc81091e0763634a4092"/><file name="OrderExportCsv.php" hash="efc9525a11661cb45fdb8a3074c81128"/><file name="ShipmentExportCsv.php" hash="b7f5edd9e2176e239a469c94f4580ec5"/></dir><dir name="Mysql4"><dir name="Orderexport"><file name="Collection.php" hash="a206c333111e8d9f642843f11fb31baa"/></dir><file name="Orderexport.php" hash="0df46849476ff37d77e416c42f03a670"/></dir><file name="Orderexport.php" hash="bd4b49beb8cb391fc4af10b5a2a3947b"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="235a2b95c0f8344d692e91f697d4aff7"/><file name="SalesexportController.php" hash="6555cb9da2697a8079cbecefd5816041"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b4adf3b552d087f237279966d7d574ee"/><file name="config.xml" hash="548fe518a47fe519caa6959a2173d4ef"/><file name="system.xml" hash="c3339227a366da7d674dfc4deb4af6ab"/></dir><dir name="sql"><dir name="orderexport_setup"><file name="mysql4-install-0.1.0.php" hash="75ddba61755c2955da53e82f9b7f71f6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Uni_Orderexport.xml" hash="5995dd6a402b4e2652ff9b6eac560831"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="orderexport.xml" hash="12871ee8a962353b73b34b1602f015db"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="app"><dir name="locale"><dir name="en_US"><dir name="template"><dir name="email"><file name="orderexport_form.html" hash="25472b5f75ab2ef809a75762c2b230b8"/></dir></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5.0.0</min><max>1.8.1.0</max></package><extension><name>gd</name><min>1.5.0.0</min><max>1.9.0.1</max></extension></required></dependencies>
20
+ </package>