mobile_assistant_connector - Version 1.0.12

Version Notes

Fixed: support of Xtento_CustomTrackers extention

Download this release

Release Info

Developer eMagicOne
Extension mobile_assistant_connector
Version 1.0.12
Comparing to
See all releases


Version 1.0.12

Files changed (31) hide show
  1. app/code/community/Emagicone/Affiliate/Model/Observer.php +49 -0
  2. app/code/community/Emagicone/Affiliate/etc/adminhtml.xml +22 -0
  3. app/code/community/Emagicone/Affiliate/etc/config.xml +33 -0
  4. app/code/community/Emagicone/Affiliate/etc/system.xml +48 -0
  5. app/code/community/Emagicone/Mobassistantconnector/Helper/Data.php +194 -0
  6. app/code/community/Emagicone/Mobassistantconnector/Model/Defpassword.php +29 -0
  7. app/code/community/Emagicone/Mobassistantconnector/Model/Login.php +35 -0
  8. app/code/community/Emagicone/Mobassistantconnector/Model/Observer.php +224 -0
  9. app/code/community/Emagicone/Mobassistantconnector/Model/Order.php +28 -0
  10. app/code/community/Emagicone/Mobassistantconnector/Model/Password.php +38 -0
  11. app/code/community/Emagicone/Mobassistantconnector/controllers/IndexController.php +2414 -0
  12. app/code/community/Emagicone/Mobassistantconnector/controllers/adminhtml/IndexController.php +26 -0
  13. app/code/community/Emagicone/Mobassistantconnector/etc/adminhtml.xml +26 -0
  14. app/code/community/Emagicone/Mobassistantconnector/etc/config.xml +120 -0
  15. app/code/community/Emagicone/Mobassistantconnector/etc/system.xml +80 -0
  16. app/design/adminhtml/default/default/layout/mobassistantconnector.xml +8 -0
  17. app/design/adminhtml/default/default/template/mobassistantconnector/jsinit.phtml +105 -0
  18. app/etc/modules/Emagicone_Mobassistantconnector.xml +9 -0
  19. app/locale/en_GB/Emagicone_Mobassistantconnector.csv +27 -0
  20. app/locale/en_GB/__Emagicone_Mobassistantconnector.csv +27 -0
  21. app/locale/en_US/Emagicone_Mobassistantconnector.csv +27 -0
  22. app/locale/en_US/__Emagicone_Mobassistantconnector.csv +27 -0
  23. app/locale/es_ES/Emagicone_Mobassistantconnector.csv +27 -0
  24. app/locale/es_ES/__Emagicone_Mobassistantconnector.csv +27 -0
  25. app/locale/fr_FR/Emagicone_Mobassistantconnector.csv +42 -0
  26. app/locale/fr_FR/__Emagicone_Mobassistantconnector.csv +42 -0
  27. app/locale/ru_RU/Emagicone_Mobassistantconnector.csv +27 -0
  28. app/locale/ru_RU/__Emagicone_Mobassistantconnector.csv +27 -0
  29. app/locale/uk_UA/Emagicone_Mobassistantconnector.csv +27 -0
  30. app/locale/uk_UA/__Emagicone_Mobassistantconnector.csv +27 -0
  31. package.xml +18 -0
app/code/community/Emagicone/Affiliate/Model/Observer.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: jarchik
5
+ * Date: 12/2/14
6
+ * Time: 4:42 PM
7
+ */
8
+
9
+ class Emagicone_Affiliate_Model_Observer
10
+ {
11
+ const COOKIE_KEY_SOURCE = 'EmagiconeAffiliateURL';
12
+
13
+ public function captureReferral(Varien_Event_Observer $observer)
14
+ {
15
+ $frontController = $observer->getEvent()->getFront();
16
+
17
+ $referrer = $frontController->getRequest()->getServer('HTTP_REFERER');
18
+ $pos = strpos($referrer, '?');
19
+ if($pos) {
20
+ $referrer = substr($referrer, 0, $pos);
21
+ }
22
+
23
+ $cookieReferrer = $this->getAffiliateURL();
24
+ if(!$cookieReferrer) {
25
+ if ($referrer) {
26
+ Mage::getModel('core/cookie')->set(
27
+ self::COOKIE_KEY_SOURCE,
28
+ $referrer,
29
+ $this->_getCookieLifetime()
30
+ );
31
+ }
32
+ }
33
+ }
34
+
35
+ protected function _getCookieLifetime()
36
+ {
37
+ $days = 1;
38
+
39
+ // convert to seconds
40
+ return (int)86400 * $days;
41
+ }
42
+
43
+ public function getAffiliateURL()
44
+ {
45
+ return Mage::getModel('core/cookie')->get(
46
+ self::COOKIE_KEY_SOURCE
47
+ );
48
+ }
49
+ }
app/code/community/Emagicone/Affiliate/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <adminhtml>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <emagicone_affiliate>
12
+ <title>Emagicone Affiliate URL</title>
13
+ </emagicone_affiliate>
14
+ </children>
15
+ </config>
16
+ </children>
17
+ </system>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </adminhtml>
app/code/community/Emagicone/Affiliate/etc/config.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Emagicone_Affiliate>
5
+ <version>0.0.1</version>
6
+ </Emagicone_Affiliate>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <emagicone_affiliate>
11
+ <class>Emagicone_Affiliate_Model</class>
12
+ </emagicone_affiliate>
13
+ </models>
14
+ <events>
15
+ <controller_front_init_before>
16
+ <observers>
17
+ <emagicone_affiliate>
18
+ <class>emagicone_affiliate/observer</class>
19
+ <method>captureReferral</method>
20
+ <type>singleton</type>
21
+ </emagicone_affiliate>
22
+ </observers>
23
+ </controller_front_init_before>
24
+ </events>
25
+ </global>
26
+ <default>
27
+ <emagicone_affiliate>
28
+ <general>
29
+ <trim_params>1</trim_params>
30
+ </general>
31
+ </emagicone_affiliate>
32
+ </default>
33
+ </config>
app/code/community/Emagicone/Affiliate/etc/system.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <mobassistantconnectorinfo>
5
+ <label>Emagicone</label>
6
+ <sort_order>100</sort_order>
7
+ </mobassistantconnectorinfo>
8
+ </tabs>
9
+ <sections>
10
+ <emagicone_affiliate>
11
+ <label>Affiliate URL</label>
12
+ <tab>mobassistantconnectorinfo</tab>
13
+ <sort_order>10</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <groups>
18
+ <general>
19
+ <label>General Settings</label>
20
+ <sort_order>10</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <status>
26
+ <label>Enabled</label>
27
+ <frontend_type>select</frontend_type>
28
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
29
+ <sort_order>10</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>0</show_in_store>
33
+ </status>
34
+ <trim_params>
35
+ <label>Trim parameters</label>
36
+ <frontend_type>select</frontend_type>
37
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
38
+ <sort_order>20</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </trim_params>
43
+ </fields>
44
+ </general>
45
+ </groups>
46
+ </emagicone_affiliate>
47
+ </sections>
48
+ </config>
app/code/community/Emagicone/Mobassistantconnector/Helper/Data.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Helper_Data extends Mage_Core_Helper_Abstract
20
+ {
21
+ public function sendPushMessage($messageContent) {
22
+ Mage::app()->cleanCache();
23
+ $apiKey = Mage::getStoreConfig('mobassistantconnectorinfosec/access/api_key');
24
+ $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json');
25
+
26
+ $ch = curl_init();
27
+ curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
28
+ curl_setopt($ch, CURLOPT_POST, true);
29
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
30
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
31
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
32
+ //curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
33
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $messageContent);
34
+ $result = curl_exec( $ch );
35
+
36
+ if(curl_errno($ch)) {
37
+ Mage::log(
38
+ "Push message error while sending CURL request: {$result}",
39
+ null,
40
+ 'emagicone_mobassistantconnector.log'
41
+ );
42
+ }
43
+
44
+ curl_close($ch);
45
+
46
+ return $result;
47
+ }
48
+
49
+ public function pushSettingsUpgrade() {
50
+ $deviceIds = Mage::getStoreConfig('mobassistantconnectorinfosec/access/google_ids');
51
+
52
+ if(strlen($deviceIds) > 0) {
53
+ $deviceIds = unserialize($deviceIds);
54
+ } else $deviceIds = array();
55
+
56
+ foreach(array_keys($deviceIds) as $key) {
57
+ if (!is_int($key)) {
58
+ $deviceIds[$key]['push_device_id'] = $key;
59
+ if(empty($deviceIds[$key]['push_store_group_id'])) {
60
+ $deviceIds[$key]['push_store_group_id'] = -1;
61
+ }
62
+ if(empty($deviceIds[$key]['push_currency_code'])) {
63
+ $deviceIds[$key]['push_currency_code'] = 'base_currency';
64
+ }
65
+ if(empty($deviceIds[$key]['app_connection_id'])) {
66
+ $deviceIds[$key]['app_connection_id'] = -1;
67
+ }
68
+ array_push($deviceIds, $deviceIds[$key]);
69
+ unset($deviceIds[$key]);
70
+ }
71
+ }
72
+
73
+ //Check for duplicated records
74
+ foreach ($deviceIds as $a1 => $firstDevice) {
75
+ if(empty($firstDevice['push_currency_code'])) {
76
+ $deviceIds[$a1]['push_currency_code'] = 'base_currency';
77
+ }
78
+ if(empty($deviceIds[$key]['app_connection_id'])) {
79
+ $deviceIds[$key]['app_connection_id'] = -1;
80
+ }
81
+ foreach($deviceIds as $a2 => $secondDevice){
82
+ if(($firstDevice === $secondDevice) && ($a1 != $a2)) {
83
+ unset($deviceIds[$a1]);
84
+ }
85
+ }
86
+ }
87
+
88
+ return $deviceIds;
89
+ }
90
+
91
+ public function proceedGoogleResponse($response, $deviceIds, $deviceIdActions) {
92
+ if ($response) {
93
+ $json = json_decode($response, true);
94
+ if (json_last_error() != JSON_ERROR_NONE) {
95
+ $json = array();
96
+ }
97
+ }
98
+ else {
99
+ $json = array();
100
+ }
101
+
102
+ $failure = isset($json['failure']) ? $json['failure'] : null;
103
+
104
+ $canonicalIds = isset($json['canonical_ids']) ? $json['canonical_ids'] : null;
105
+
106
+ if ($failure || $canonicalIds) {
107
+ $results = isset($json['results']) ? $json['results'] : array();
108
+ foreach($results as $id => $result) {
109
+ $newRegId = isset($result['registration_id']) ? $result['registration_id'] : null;
110
+ $error = isset($result['error']) ? $result['error'] : null;
111
+ if ($newRegId) {
112
+ // It's duplicated deviceId
113
+ if(in_array($newRegId, $deviceIds) && $newRegId != $deviceIds[$id]) {
114
+ // Loop through the devices and delete old
115
+ foreach ($deviceIdActions as $settingNum => $deviceId) {
116
+ if($deviceId['push_device_id'] == $deviceIds[$id]) {
117
+ unset($deviceIdActions[$settingNum]);
118
+ }
119
+ }
120
+ // Need to update old deviceId
121
+ } else if(!in_array($newRegId, $deviceIds)) {
122
+ foreach ($deviceIdActions as $settingNum => $deviceId) {
123
+ if($deviceId['push_device_id'] == $deviceIds[$id]) {
124
+ $deviceIdActions[$settingNum]['push_device_id'] = $newRegId;
125
+ }
126
+ }
127
+ }
128
+ }
129
+ else if ($error) {
130
+ // Unset not registered device id
131
+ if ($error == 'NotRegistered' || $error == 'InvalidRegistration') {
132
+ foreach ($deviceIdActions as $settingNum => $deviceId) {
133
+ if($deviceId['push_device_id'] == $deviceIds[$id]) {
134
+ unset($deviceIdActions[$settingNum]);
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ return $deviceIdActions;
143
+ }
144
+
145
+ public function price_format($iso_code, $curr_format, $price, $convert_to, $force = false, $format = true) {
146
+ $currency_symbol = '';
147
+ $price = str_replace(' ', '', $price);
148
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
149
+
150
+ if(strlen($convert_to) == 3){
151
+ try {
152
+ $price = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $convert_to);
153
+ // $price = $this->currencyConvert($price, $baseCurrencyCode, $convert_to);
154
+ $iso_code = $convert_to;
155
+ } catch(Exception $e) {
156
+ Mage::log(
157
+ "Error while currency converting (". var_export($e->getMessage(), true). ")",
158
+ null,
159
+ 'emagicone_mobassistantconnector.log'
160
+ );
161
+ }
162
+
163
+ }
164
+
165
+ if($format) {
166
+ $price = number_format(floatval($price), 2, '.', ' ');
167
+ }
168
+
169
+ preg_match('/^[a-zA-Z]+$/', $iso_code, $matches);
170
+
171
+ if(count($matches) > 0) {
172
+ if(strlen($matches[0]) == 3) {
173
+ $currency_symbol = Mage::app()->getLocale()->currency($iso_code)->getSymbol();
174
+ }
175
+ } else {
176
+ $currency_symbol = $iso_code;
177
+ }
178
+
179
+ if($force) {
180
+ return $currency_symbol;
181
+ }
182
+ // $sign = '<span>' . $currency_symbol . '</span>';
183
+ $sign = $currency_symbol;
184
+ if($curr_format == 1) {
185
+ $price = $sign . $price;
186
+ } elseif ($curr_format == 2) {
187
+ $price = $price;
188
+ } else {
189
+ $price = $price . ' ' . $sign;
190
+ }
191
+
192
+ return $price;
193
+ }
194
+ }
app/code/community/Emagicone/Mobassistantconnector/Model/Defpassword.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Model_Defpassword extends Mage_Core_Model_Config_Data
20
+ {
21
+ public function toOptionArray()
22
+ {
23
+ Mage::app()->cleanCache();
24
+ $password = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/password');
25
+ if($password === 'c4ca4238a0b923820dcc509a6f75849b') {
26
+ Mage::getSingleton('core/session')->addNotice(Mage::helper('mobassistantconnector/data')->__('<span style="color:green">Mobile Assistant Connector: </span> Default password is "1". Please change it because of security reasons!'));
27
+ }
28
+ }
29
+ }
app/code/community/Emagicone/Mobassistantconnector/Model/Login.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Model_Login extends Mage_Core_Model_Config_Data
20
+ {
21
+ public function save()
22
+ {
23
+ Mage::app()->cleanCache();
24
+ $old_login = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/login');
25
+
26
+ $login = $this->getValue();
27
+
28
+ if($login == ''){
29
+ Mage::getSingleton('core/session')->addWarning(Mage::helper('mobassistantconnector/data')->__('<span style="color:green">Mobile Assistant Connector:</span> Login field cannot be empty. Please specify Login.'));
30
+ $this->setValue($old_login);
31
+ }
32
+
33
+ return parent::save();
34
+ }
35
+ }
app/code/community/Emagicone/Mobassistantconnector/Model/Observer.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Model_Observer
20
+ {
21
+ public function checkOrder($observer) {
22
+ Mage::app()->cleanCache();
23
+ if(intval(Mage::getStoreConfig('mobassistantconnectorinfosec/emogeneral/status')) == 1) {
24
+ $order = $observer->getEvent()->getOrder();
25
+ $groupId = $_storeId = Mage::app()->getStore(intval($order->getStoreId()))->getGroupId();
26
+ $state = $order->getState();
27
+ // $state = $observer->getEvent()->getState();
28
+ // $status = $observer->getEvent()->getStatus();
29
+ $status = $order->getStatus();
30
+ $comment = $observer->getEvent()->getComment();
31
+ $statusLabel = $status;
32
+ $statuses = array();
33
+ $deviceIds = array();
34
+ $deviceIdsByCCode = array();
35
+ $deviceArResult = array();
36
+ $type = '';
37
+
38
+ $statuses = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
39
+ foreach($statuses as $st) {
40
+ if($st['status'] == $status) {
41
+ $statusLabel = $st['label'];
42
+ }
43
+ }
44
+
45
+ $deviceIdActions = Mage::helper('mobassistantconnector')->pushSettingsUpgrade();
46
+
47
+ if(count($deviceIdActions) > 0 && !is_null($state)) {
48
+
49
+
50
+ foreach ($deviceIdActions as $settingNum => $deviceId) {
51
+
52
+ Mage::log(
53
+ "push_new_order: ". $deviceId['push_store_group_id'].
54
+ "\n groupId: ". $groupId.
55
+ "\n state: ". $state.
56
+ "\n push_device_id: ". $deviceId['push_device_id']
57
+ ,
58
+ null,
59
+ 'emagicone_mobassistantconnector.log'
60
+ );
61
+
62
+ if($deviceId['push_store_group_id'] == $groupId || $deviceId['push_store_group_id'] == -1) {
63
+ if(intval($deviceId['push_new_order']) == 1 /** && ( ($order->getCreatedAt() == $order->getUpdatedAt()) || $order->getCustomerIsGuest() == true) */ && $state == 'new' && !is_null($deviceId['push_device_id'])){
64
+ array_push($deviceIds, $deviceId);
65
+ // $deviceIdsByCCode[$deviceId['push_currency_code']][] = $deviceId['push_device_id'];
66
+ $type = 'new_order';
67
+ }
68
+ if(strlen($deviceId['push_order_statuses']) > 0 && (!in_array($deviceId['push_device_id'], $deviceIds)) && !($order->getCreatedAt() == $order->getUpdatedAt()) ) {
69
+ $statuses = explode('|', $deviceId['push_order_statuses']);
70
+ if(in_array($status, $statuses) || intval($deviceId['push_order_statuses']) == -1) {
71
+ if (!in_array($deviceId['push_device_id'], $deviceIds)) {
72
+ array_push($deviceIds, $deviceId);
73
+ // $deviceIdsByCCode[$deviceId['push_currency_code']][] = $deviceId['push_device_id'];
74
+ // $deviceIdsByCCode[$deviceId['push_currency_code']]['push_device_id'][] = $deviceId['push_device_id'];
75
+ // $deviceIdsByCCode[$deviceId['push_currency_code']]['app_connection_id'][] = $deviceId['app_connection_id'];
76
+ $type = 'order_changed';
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+ }
84
+
85
+ Mage::log(
86
+ "******* \n Push message: Type: {$type}; All ids: ". count($deviceIdActions). "; Accepted to current event: {". count($deviceIds). "}; ",
87
+ null,
88
+ 'emagicone_mobassistantconnector.log'
89
+ );
90
+
91
+ // foreach($deviceIdsByCCode as $deviceCurrencyCode => $deviceIds) {
92
+ if(count($deviceIds) > 0) {
93
+ foreach ($deviceIds as $key => $value) {
94
+ $currency_code = $order->getGlobalCurrencyCode();
95
+ $currency_symbol = Mage::app()->getLocale()->currency($currency_code)->getSymbol();
96
+
97
+ $deviceCurrencyCode = $value['push_currency_code'];
98
+ $app_connection_id = $value['app_connection_id'];
99
+
100
+ $total = $order->getBaseGrandTotal();
101
+ // $total = $order->getSubtotalInclTax();
102
+ $total = number_format(floatval($total), 2, '.', ' ');
103
+
104
+ if(empty($deviceCurrencyCode) || strval($deviceCurrencyCode) == 'base_currency') {
105
+ $deviceCurrencyCode = $currency_code;
106
+ }
107
+
108
+ $total = Mage::helper('mobassistantconnector')->price_format($currency_code, 1, $total, $deviceCurrencyCode, 0, true);
109
+
110
+ $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
111
+ $storeUrl = str_replace('http://', '', $storeUrl);
112
+ $storeUrl = str_replace('https://', '', $storeUrl);
113
+
114
+ preg_replace('/\/*$/i', '', $storeUrl);
115
+
116
+ $fields = array(
117
+ 'registration_ids' => array(0 => $value['push_device_id']),
118
+ 'data' => array( "message" => array("push_notif_type" => $type, "email" => $order->getCustomerEmail(), 'customer_name' => $order->getCustomerFirstname().' '.$order->getCustomerLastname(),
119
+ "order_id" => $order->getId(), "total" => $total, "store_url" => $storeUrl, "new_status" => $statusLabel, "group_id" => $groupId, 'app_connection_id' => $app_connection_id) ),
120
+ );
121
+
122
+ if($type === 'new_order') {
123
+ unset($fields['data']['new_status']);
124
+ }
125
+
126
+ $fields_log = var_export($fields, true);
127
+
128
+ $send_data = Mage::helper('core')->jsonEncode($fields['data']);
129
+
130
+ Mage::log(
131
+ "Push message: Type: {$type}; data: " . var_export(json_encode($fields), true) ,
132
+ null,
133
+ 'emagicone_mobassistantconnector.log'
134
+ );
135
+
136
+ $fields = Mage::helper('core')->jsonEncode($fields);
137
+
138
+ $response = Mage::helper('mobassistantconnector')->sendPushMessage($fields);
139
+
140
+ $deviceArResult = Mage::helper('mobassistantconnector')->proceedGoogleResponse($response, $value['push_device_id'], $deviceIdActions);
141
+
142
+ Mage::getModel('core/config')->saveConfig('mobassistantconnectorinfosec/access/google_ids', serialize($deviceArResult) );
143
+
144
+ $d_r = Mage::helper('core')->jsonDecode($response, Zend_Json::TYPE_OBJECT);
145
+
146
+ Mage::log(
147
+ "Google response: (multicast_id = {$d_r->multicast_id}, success = {$d_r->success}, failure = {$d_r->failure}, canonical_ids = {$d_r->canonical_ids})",
148
+ null,
149
+ 'emagicone_mobassistantconnector.log'
150
+ );
151
+ }
152
+ // }
153
+ }
154
+ }
155
+ }
156
+
157
+ public function customerRegisterSuccess($observer) {
158
+ $statuses = array();
159
+ $deviceIds = array();
160
+ $deviceArResult = array();
161
+ $type = 'new_customer';
162
+
163
+
164
+ $customer = $observer->getEvent()->getCustomer();
165
+ $groupId = $_storeId = Mage::app()->getStore(intval($customer->getStoreId()))->getGroupId();
166
+
167
+ Mage::app()->cleanCache();
168
+ if(intval(Mage::getStoreConfig('mobassistantconnectorinfosec/emogeneral/status')) == 1) {
169
+
170
+ $deviceIdActions = Mage::helper('mobassistantconnector')->pushSettingsUpgrade();
171
+
172
+ if(count($deviceIdActions) > 0) {
173
+ foreach ($deviceIdActions as $settingNum => $deviceId) {
174
+ if(($groupId == $deviceId['push_store_group_id']) || $deviceId['push_store_group_id'] == -1) {
175
+ if(intval($deviceId['push_new_customer'] == 1)) {
176
+ array_push($deviceIds, $deviceId);
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ Mage::log(
183
+ "******* \n Push message: Type: {$type}; All ids: ". count($deviceIdActions). "; Accepted to current event: {". count($deviceIds). "}; ",
184
+ null,
185
+ 'emagicone_mobassistantconnector.log'
186
+ );
187
+
188
+ if(count($deviceIds) > 0) {
189
+ foreach ($deviceIds as $key => $value) {
190
+ $fields = array(
191
+ 'registration_ids' => array(0 => $value['push_device_id']),
192
+ 'data' => array( "message" => array("push_notif_type" => $type, "email" => $customer->getEmail(), 'customer_name' => $customer->getFirstname().' '.$customer->getLastname(),
193
+ "customer_id" => $customer->getId(), "store_url" => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB), "group_id" => $groupId, 'app_connection_id' => $value['app_connection_id']))
194
+ );
195
+
196
+ $send_data = Mage::helper('core')->jsonEncode($fields['data']);
197
+ $fields = Mage::helper('core')->jsonEncode($fields);
198
+
199
+
200
+ Mage::log(
201
+ "Data: {$fields} ",
202
+ null,
203
+ 'emagicone_mobassistantconnector.log'
204
+ );
205
+
206
+ $response = Mage::helper('mobassistantconnector')->sendPushMessage($fields);
207
+
208
+ // $success = true;
209
+ $deviceArResult = Mage::helper('mobassistantconnector')->proceedGoogleResponse($response, $deviceIds, $deviceIdActions);
210
+
211
+ Mage::getModel('core/config')->saveConfig('mobassistantconnectorinfosec/access/google_ids', serialize($deviceArResult) );
212
+
213
+ $d_r = Mage::helper('core')->jsonDecode($response, Zend_Json::TYPE_OBJECT);
214
+
215
+ Mage::log(
216
+ "Google response: (multicast_id = {$d_r->multicast_id}, success = {$d_r->success}, failure = {$d_r->failure}, canonical_ids = {$d_r->canonical_ids})",
217
+ null,
218
+ 'emagicone_mobassistantconnector.log'
219
+ );
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
app/code/community/Emagicone/Mobassistantconnector/Model/Order.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Model_Order extends Mage_Sales_Model_Order
20
+ {
21
+
22
+ public function setState($state, $status = false, $comment = '', $isCustomerNotified = null)
23
+ {
24
+ Mage::dispatchEvent('sales_order_status_change', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified));
25
+
26
+ return parent::setState($state, $status, $comment, $isCustomerNotified);
27
+ }
28
+ }
app/code/community/Emagicone/Mobassistantconnector/Model/Password.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_Model_Password extends Mage_Core_Model_Config_Data
20
+ {
21
+ public function save()
22
+ {
23
+ Mage::app()->cleanCache();
24
+ $new_password = $this->getValue();
25
+ $old_password = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/password');
26
+
27
+ if($new_password != $old_password){
28
+ $this->setValue(md5($new_password));
29
+ }
30
+
31
+ if($new_password == ''){
32
+ Mage::getSingleton('core/session')->addWarning(Mage::helper('mobassistantconnector/data')->__('<span style="color:green">Mobile Assistant Connector:</span> Password field cannot be empty. Please specify password.'));
33
+ $this->setValue($old_password);
34
+ }
35
+
36
+ return parent::save();
37
+ }
38
+ }
app/code/community/Emagicone/Mobassistantconnector/controllers/IndexController.php ADDED
@@ -0,0 +1,2414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+
20
+ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controller_Front_Action
21
+ {
22
+ public $CartClass = "";
23
+ public $call_function;
24
+ public $callback;
25
+ public $hash;
26
+ public $def_currency;
27
+ public $currency_code;
28
+ const GSM_URL = 'https://android.googleapis.com/gcm/send';
29
+ const MB_VERSION = '$Revision: 81 $';
30
+
31
+ public function indexAction() {
32
+ Mage::app()->cleanCache();
33
+ if(intval(Mage::getStoreConfig('mobassistantconnectorinfosec/emogeneral/status')) != 1) $this->generate_output('module_disabled');
34
+
35
+ $this->loadLayout()->renderLayout();
36
+
37
+ $def_currency = $this->_get_default_currency();
38
+ $this->def_currency = $def_currency['currency'];
39
+
40
+ foreach($this->getRequest()->getParams() as $key=>$value) {
41
+ if(isset($key) && $key == 'callback' && isset($value) && strlen($value) > 0)
42
+ $this->callback = $value;
43
+ if(isset($key) && $key == 'call_function' && isset($value) && strlen($value) > 0)
44
+ $this->call_function = $value;
45
+ if(isset($key) && $key == 'hash' && isset($value) && strlen($value) > 0)
46
+ $this->hash = $value;
47
+ }
48
+
49
+ if(!$this->check_auth()) {
50
+ $this->generate_output('auth_error');
51
+ }
52
+
53
+ $request_params = Mage::app()->getRequest()->getParams();
54
+ $params = $this->validate_types($request_params, array(
55
+ 'show' => 'INT',
56
+ 'page' => 'INT',
57
+ 'search_order_id' => 'STR',
58
+ 'orders_from' => 'STR',
59
+ 'orders_to' => 'STR',
60
+ 'order_number' => 'STR',
61
+ 'customers_from' => 'STR',
62
+ 'customers_to' => 'STR',
63
+ 'date_from' => 'STR',
64
+ 'date_to' => 'STR',
65
+ 'graph_from' => 'STR',
66
+ 'graph_to' => 'STR',
67
+ 'stats_from' => 'STR',
68
+ 'stats_to' => 'STR',
69
+ 'products_to' => 'STR',
70
+ 'products_from' => 'STR',
71
+ 'order_id' => 'INT',
72
+ 'user_id' => 'INT',
73
+ 'params' => 'STR',
74
+ 'val' => 'STR',
75
+ 'search_val' => 'STR',
76
+ 'statuses' => 'STR',
77
+ 'sort_by' => 'STR',
78
+ 'last_order_id' => 'STR',
79
+ 'product_id' => 'INT',
80
+ 'get_statuses' => 'INT',
81
+ 'cust_with_orders' => 'INT',
82
+ 'data_for_widget' => 'INT',
83
+ 'registration_id' => 'STR',
84
+ 'registration_id_old' => 'STR',
85
+ 'registration_id_new' => 'STR',
86
+ 'api_key' => 'STR',
87
+ 'tracking_number' => 'STR',
88
+ 'tracking_title' => 'STR',
89
+ 'action' => 'STR',
90
+ 'carrier_code' => 'STR',
91
+ 'custom_period' => 'INT',
92
+ 'group_id' => 'INT',
93
+ 'push_new_customer' => 'INT',
94
+ 'push_new_order' => 'INT',
95
+ 'push_currency_code' => 'STR',
96
+ 'app_connection_id' => 'STR',
97
+ 'push_store_group_id' => 'STR',
98
+ 'push_order_statuses' => 'STR',
99
+ 'currency_code' => 'STR',
100
+ 'is_mail' => 'INT',
101
+ 'store_group_id' => 'INT'
102
+ ));
103
+
104
+ foreach($params as $k => $value) {
105
+ $this->{$k} = $value;
106
+ }
107
+
108
+ if(empty($this->currency_code) || strval($this->currency_code) == 'base_currency') {
109
+ $this->currency_code = $this->def_currency;
110
+ }
111
+
112
+ if($this->call_function == 'test_config') {
113
+ $this->generate_output(array('test' => 1));
114
+ }
115
+
116
+ $locale = Mage::app()->getLocale()->getLocaleCode();
117
+ Mage::app()->getTranslator()->setLocale($locale);
118
+
119
+ if(!method_exists($this, $this->call_function)) {
120
+ Mage::log(
121
+ "Unknown method call ({$this->call_function})",
122
+ null,
123
+ 'emagicone_mobassistantconnector.log'
124
+ );
125
+ $this->generate_output('old_bridge');
126
+ }
127
+
128
+ $result = call_user_func(array($this, $this->call_function));
129
+
130
+ $this->generate_output($result);
131
+ }
132
+
133
+ protected function generate_output($data) {
134
+
135
+ $add_bridge_version = false;
136
+ if(in_array($this->call_function, array("test_config", "get_store_title", "get_store_stats", "get_data_graphs"))) {
137
+ if(is_array($data) && $data != 'auth_error' && $data != 'connection_error' && $data != 'old_bridge') {
138
+ $add_bridge_version = true;
139
+ }
140
+ }
141
+
142
+ if(!is_array($data)) {
143
+ $data = array($data);
144
+ }
145
+
146
+ if(is_array($data)) {
147
+ array_walk_recursive($data, array($this, 'reset_null'));
148
+ }
149
+
150
+ if($add_bridge_version) {
151
+ $data['module_version'] = self::MB_VERSION;
152
+ }
153
+
154
+ // $data = $this->to_json($data);
155
+ $data = Mage::helper('core')->jsonEncode($data);
156
+
157
+ if($this->callback) {
158
+ header('Content-Type: text/javascript;charset=utf-8');
159
+ die($this->callback . '(' . $data . ');');
160
+ } else {
161
+ header('Content-Type: text/javascript;charset=utf-8');
162
+ die($data);
163
+ }
164
+ }
165
+
166
+ protected function check_auth() {
167
+ $login = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/login');
168
+ $password = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/password');
169
+
170
+ if(md5($login.$password) == $this->hash){
171
+ return true;
172
+ } else {
173
+ Mage::log(
174
+ "Hash accepted ({$this->hash}) is not equal to ({$login} {$password}) stored",
175
+ null,
176
+ 'emagicone_mobassistantconnector.log'
177
+ );
178
+ return false;
179
+ }
180
+ }
181
+
182
+ protected function push_notification_settings() {
183
+ $result = array();
184
+ $statuses = array();
185
+ $matched = false;
186
+ $deviceActions = array('push_device_id' => '',
187
+ 'push_new_order' => 0,
188
+ 'push_order_statuses' => '',
189
+ 'push_new_customer' => 0,
190
+ 'app_connection_id' => -1,
191
+ 'push_store_group_id' => -1,
192
+ 'push_currency_code' => '');
193
+
194
+ $deviceIds = Mage::getStoreConfig('mobassistantconnectorinfosec/access/google_ids');
195
+ if(strlen($deviceIds) > 0) {
196
+ $deviceIds = unserialize($deviceIds);
197
+ } else $deviceIds = array();
198
+
199
+ foreach(array_keys($deviceIds) as $key) {
200
+ if (!is_int($key)) {
201
+ $deviceIds[$key]['push_device_id'] = $key;
202
+ if(empty($deviceIds[$key]['push_store_group_id'])) {
203
+ $deviceIds[$key]['push_store_group_id'] = -1;
204
+ }
205
+ array_push($deviceIds, $deviceIds[$key]);
206
+ unset($deviceIds[$key]);
207
+ }
208
+ }
209
+
210
+ if(strlen($this->registration_id) > 0 && strlen($this->api_key) > 0) {
211
+
212
+ if(strlen($this->registration_id ) > 0) {
213
+ $deviceActions['push_device_id'] = $this->registration_id;
214
+ }
215
+
216
+ if(strlen($this->push_new_order ) > 0) {
217
+ $deviceActions['push_new_order'] = $this->push_new_order;
218
+ } else {
219
+ $deviceActions['push_new_order'] = 0;
220
+ }
221
+
222
+ if(strlen($this->push_order_statuses) > 0) {
223
+ $deviceActions['push_order_statuses'] = $this->push_order_statuses;
224
+ } else {
225
+ $deviceActions['push_order_statuses'] = '';
226
+ }
227
+
228
+ if(strlen($this->push_new_customer ) > 0) {
229
+ $deviceActions['push_new_customer'] = $this->push_new_customer;
230
+ } else {
231
+ $deviceActions['push_new_customer'] = 0;
232
+ }
233
+
234
+ if(!empty($this->store_group_id)) {
235
+ $deviceActions['push_store_group_id'] = $this->store_group_id;
236
+ } else {
237
+ $deviceActions['push_store_group_id'] = -1;
238
+ }
239
+
240
+ if(!empty($this->app_connection_id)) {
241
+ $deviceActions['app_connection_id'] = $this->app_connection_id;
242
+ } else {
243
+ $deviceActions['app_connection_id'] = -1;
244
+ }
245
+
246
+ if(strlen($this->push_currency_code) > 0) {
247
+ $deviceActions['push_currency_code'] = $this->push_currency_code;
248
+ } else if(strlen($this->currency_code) > 0) {
249
+ $deviceActions['push_currency_code'] = $this->currency_code;
250
+ } else {
251
+ $deviceActions['push_currency_code'] = 'base_currency';
252
+ }
253
+
254
+ // Delete empty record
255
+ if((intval($this->push_new_order ) == 0) && (strlen($this->push_order_statuses ) == 0) && (intval($this->push_new_customer ) == 0)) {
256
+ foreach ($deviceIds as $settingNum => $deviceId) {
257
+ if($deviceId['push_device_id'] == $this->registration_id && (isset($deviceId['app_connection_id']) && $deviceId['app_connection_id'] == $deviceActions['app_connection_id'])) {
258
+ unset($deviceIds[$settingNum]);
259
+ } else if($deviceId['push_device_id'] == $this->registration_id && $deviceId['push_store_group_id'] == $this->store_group_id && !isset($deviceId['app_connection_id'])) {
260
+ unset($deviceIds[$settingNum]);
261
+ }
262
+ }
263
+ } else {
264
+ // renew old record
265
+ foreach ($deviceIds as $settingNum => $deviceId) {
266
+ if($deviceId['push_device_id'] == $this->registration_id && (isset($deviceId['app_connection_id']) && $deviceId['app_connection_id'] == $deviceActions['app_connection_id'])) {
267
+ $deviceIds[$settingNum] = $deviceActions;
268
+ $matched = true;
269
+ } else if($deviceId['push_device_id'] == $this->registration_id && $deviceId['push_store_group_id'] == $deviceActions['push_store_group_id'] && !isset($deviceId['app_connection_id'])) {
270
+ $deviceIds[$settingNum] = $deviceActions;
271
+ $matched = true;
272
+ }
273
+ }
274
+ if(!$matched) {
275
+ // add new record
276
+ array_push($deviceIds, $deviceActions);
277
+ }
278
+ }
279
+
280
+ // Delete old registration id
281
+ if(isset($this->registration_id_old) && strlen($this->registration_id_old) > 0) {
282
+ foreach ($deviceIds as $settingNum => $deviceId) {
283
+ if($deviceId['push_device_id'] == $this->registration_id_old) {
284
+ unset($deviceIds[$settingNum]);
285
+ }
286
+ }
287
+ }
288
+
289
+ Mage::getModel('core/config')->saveConfig('mobassistantconnectorinfosec/access/google_ids', serialize($deviceIds) );
290
+
291
+ Mage::getModel('core/config')->saveConfig('mobassistantconnectorinfosec/access/api_key', $this->api_key );
292
+
293
+ $result = array('success' => 'true');
294
+ } else
295
+ $result = array('error' => $this->__('Can not get configuration value'));
296
+
297
+ return $result;
298
+ }
299
+
300
+ protected function get_store_title() {
301
+ if(!empty($this->group_id)) {
302
+ try {
303
+ $name = Mage::app()->getGroup($this->group_id)->getName();
304
+ } catch(Exception $e) {
305
+ $name = Mage::app()->getStore()->getFrontendName();
306
+ }
307
+ } else $name = Mage::app()->getStore()->getFrontendName();
308
+ return array('test' => 1, 'title' => $name);
309
+ }
310
+
311
+ protected function is_group_exists($groupId) {
312
+ $exists = false;
313
+ if(!empty($groupId)) {
314
+ try {
315
+ $name = Mage::app()->getGroup($groupId)->getName();
316
+ $exists = true;
317
+ } catch(Exception $e) {
318
+ $exists = false;
319
+ }
320
+ }
321
+ return $exists;
322
+ }
323
+
324
+ protected function get_stores() {
325
+ $arr_result = array();
326
+
327
+ foreach (Mage::app()->getWebsites() as $website) {
328
+ foreach ($website->getGroups() as $group) {
329
+ // foreach ($group->getStores() as $store) {
330
+ $arr_result[] = array(
331
+ // 'store_id' => $store->getStoreID(),
332
+ // 'store_name' => $store->getName(),
333
+ // 'is_store_active' => $store->getIsActive(),
334
+ 'group_id' => $group->getId(),
335
+ 'name' => $group->getName(),
336
+ 'default_store_id' => $group->getDefaultStoreId(),
337
+ 'website' => $website->getName(),
338
+ 'website_id' => $website->getWebsiteId(),
339
+ 'default_group_id' => $website->getDefaultGroupId(),
340
+ 'website_is_default' => $website->getIsDefault()
341
+ // 'group_currencies' => $this->get_group_currencies($group->getId())
342
+ );
343
+ // }
344
+ }
345
+ }
346
+
347
+ return $arr_result;
348
+ }
349
+
350
+ protected function get_currencies() {
351
+ $currencies = array();
352
+ try {
353
+ $collection = Mage::getModel('core/store')->getCollection(); // ->addFieldToFilter('group_id', $storeId);
354
+ if(!empty($this->group_id) && $this->group_id != -1) {
355
+ $collection->addFieldToFilter('group_id', $this->group_id);
356
+ }
357
+
358
+ foreach ($collection as $store) {
359
+ $storeId = $store->getStoreId();
360
+ $CurrencyCode = Mage::getModel('core/config_data')
361
+ ->getCollection()
362
+ ->addFieldToFilter('path','currency/options/allow')
363
+ ->addFieldToFilter('scope_id',$storeId)
364
+ ->getData();
365
+ $currencies_array = explode(',',$CurrencyCode[0]['value']);
366
+ if($currencies_array[0] == '')
367
+ {
368
+ // $currencies_array[] = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
369
+ $currencies_array = Mage::app()->getStore($storeId)->getAvailableCurrencyCodes();
370
+ }
371
+
372
+ foreach ($currencies_array as $curCode) {
373
+ foreach ($currencies as $currency) {
374
+ if($curCode == $currency['code']){
375
+ continue 2;
376
+ }
377
+ }
378
+
379
+ $currencySymbol = Mage::app()->getLocale()->currency( $curCode )->getSymbol();
380
+ $currencyName = Mage::app()->getLocale()->currency( $curCode )->getName();
381
+ $currencies[] = array('code' => $curCode, 'symbol' => (is_null($currencySymbol) ? $curCode : $currencySymbol), 'name' => $currencyName);
382
+ }
383
+ }
384
+ } catch(Exception $e) {
385
+ Mage::log(
386
+ "Error while getting group currencies (". var_export($e->getMessage(), true). ")",
387
+ null,
388
+ 'emagicone_mobassistantconnector.log'
389
+ );
390
+ }
391
+
392
+ return $currencies;
393
+ }
394
+
395
+ protected function get_store_stats() {
396
+ $data_graphs = '';
397
+ $order_status_stats = array();
398
+
399
+ $offset = $this->_get_timezone_offset();
400
+ $store_stats = array('count_orders' => "0", 'total_sales' => "0", 'count_customers' => "0", 'count_products' => "0", "last_order_id" => "0", "new_orders" => "0");
401
+
402
+ $today = date("Y-m-d", time());
403
+ $date_from = $date_to = $today;
404
+
405
+ if(!empty($this->stats_from)) {
406
+ $date_from = $this->stats_from;
407
+ }
408
+
409
+ if(!empty($this->stats_to)) {
410
+ $date_to = $this->stats_to;
411
+ }
412
+
413
+ if(isset($this->custom_period) && strlen($this->custom_period) > 0) {
414
+ $custom_period = $this->get_custom_period($this->custom_period);
415
+
416
+ $date_from = $custom_period['start_date'];
417
+ $date_to = $custom_period['end_date'];
418
+ }
419
+
420
+ if(!empty($date_from)) {
421
+ $date_from .= " 00:00:00";
422
+ }
423
+ if(!empty($date_to)) {
424
+ $date_to .= " 23:59:59";
425
+ }
426
+
427
+ $ordersCollection = Mage::getModel('sales/order')->getCollection();
428
+ $ordersCollection->addAttributeToSelect('base_grand_total');
429
+ $ordersCollection->addAttributeToSelect('entity_id');
430
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
431
+
432
+ if(strlen($this->statuses) > 0) {
433
+ $this->statuses = '\'' . str_replace('|', '\',\'', $this->statuses) . '\'';
434
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("main_table.status IN ({$this->statuses})"));
435
+ }
436
+
437
+ if (!empty($this->group_id)) {
438
+ if($this->is_group_exists($this->group_id)) {
439
+ $ordersCollection->getSelect()
440
+ ->joinLeft(
441
+ array('cs' => $storeTableName),
442
+ "cs.store_id = main_table.store_id");
443
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
444
+ }
445
+ }
446
+
447
+ if(!empty($date_from)) {
448
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) >= '" . (date('Y-m-d H:i:s', (strtotime($date_from)))) ."'"));
449
+ }
450
+ if(!empty($date_to)) {
451
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '" . (date('Y-m-d H:i:s', (strtotime($date_to)))) ."'"));
452
+ }
453
+
454
+ /*
455
+ if(!empty($date_from) && !empty($date_to)) {
456
+ $ordersCollection->addFieldToFilter('main_table.created_at',
457
+ array('from' => $date_from,
458
+ 'to' => $date_to,
459
+ 'date' => true) );
460
+ }
461
+ */
462
+
463
+ // var_dump($ordersCollection->getSelect()->__toString());die();
464
+
465
+ $ordersSum = array_sum($ordersCollection->getColumnValues('base_grand_total'));
466
+ $row['count_orders'] = $ordersCollection->getSize();
467
+
468
+
469
+
470
+ $nice_nm = $this->bd_nice_number($ordersSum);
471
+
472
+ $row['total_sales'] = $this->_price_format($this->def_currency, 1, $nice_nm, $this->currency_code, 0, true);
473
+ $store_stats = array_merge($store_stats, $row);
474
+
475
+
476
+ $salesCollection = Mage::getModel("sales/order_item")->getCollection()
477
+ ->addFieldToSelect(array('product_id', 'name', 'sku'));
478
+
479
+ $orderTableName = Mage::getSingleton('core/resource')->getTableName('sales/order');
480
+ $salesCollection->getSelect()
481
+ ->joinLeft(
482
+ array('order' => $orderTableName),
483
+ "order.entity_id = main_table.order_id",
484
+ array());
485
+
486
+ if (!empty($this->group_id)) {
487
+ if($this->is_group_exists($this->group_id)) {
488
+ $salesCollection->getSelect()
489
+ ->joinLeft(
490
+ array('cs' => $storeTableName),
491
+ "cs.store_id = main_table.store_id");
492
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
493
+ }
494
+ }
495
+
496
+ if(!empty($date_from)) {
497
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(order.created_at, '+00:00', '".$offset."')) >= '" . (date('Y-m-d H:i:s', (strtotime($date_from)))) ."'"));
498
+ }
499
+ if(!empty($date_to)) {
500
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(order.created_at, '+00:00', '".$offset."')) <= '" . (date('Y-m-d H:i:s', (strtotime($date_to)))) ."'"));
501
+ }
502
+
503
+ if(strlen($this->statuses) > 0) {
504
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("order.status IN ({$this->statuses})"));
505
+ }
506
+ $store_stats['count_products'] = $this->bd_nice_number($salesCollection->count(), true);
507
+
508
+ $salesCollection->setOrder('item_id','DESC');
509
+
510
+ if($this->last_order_id != "") {
511
+ $ordersCollection = Mage::getModel('sales/order')->getCollection();
512
+
513
+ $ordersCollection->addAttributeToFilter('entity_id', array('gt' => intval($this->last_order_id)));
514
+
515
+ $ordersCollection->setOrder('entity_id','DESC');
516
+
517
+ $lastOrder = $ordersCollection->getFirstItem();
518
+
519
+ $store_stats['last_order_id'] = $this->last_order_id;
520
+ if(intval($lastOrder['entity_id']) > intval($this->last_order_id)) {
521
+ $store_stats['last_order_id'] = intval($lastOrder['entity_id']);
522
+ }
523
+
524
+ $store_stats['new_orders'] = $ordersCollection->count();
525
+ }
526
+
527
+ $customerCollection = Mage::getModel('customer/customer')->getCollection();
528
+
529
+ if(!empty($date_from)) {
530
+ $customerCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(created_at, '+00:00', '".$offset."')) >= '" . date('Y-m-d H:i:s', (strtotime($date_from))) ."'"));
531
+ }
532
+ if(!empty($date_to)) {
533
+ $customerCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(created_at, '+00:00', '".$offset."')) <= '" . date('Y-m-d H:i:s', (strtotime($date_to))) ."'"));
534
+ }
535
+
536
+ if (!empty($this->group_id)) {
537
+ if($this->is_group_exists($this->group_id)) {
538
+ $customerCollection->getSelect()
539
+ ->joinLeft(
540
+ array('cs' => $storeTableName),
541
+ "cs.store_id = e.store_id");
542
+ $customerCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
543
+ }
544
+ }
545
+
546
+ $row['count_customers'] = $customerCollection->count();
547
+ $store_stats = array_merge($store_stats, $row);
548
+
549
+ if(!isset($this->data_for_widget) || empty($this->data_for_widget) || $this->data_for_widget != 1) {
550
+ $data_graphs = $this->get_data_graphs();
551
+ }
552
+
553
+ $store_stats['count_orders'] = $this->bd_nice_number($store_stats['count_orders'], true);
554
+ $store_stats['count_customers'] = $this->bd_nice_number($store_stats['count_customers'], true);
555
+
556
+ // $result = array_merge($store_stats, array('data_graphs' => $data_graphs));
557
+
558
+ $order_status_stats = $this->get_status_stats();
559
+
560
+ // $order_status_stats = array(array('code' => 'pending', 'name' => 'Pending', 'count' => 3, 'total' => 'USD33.20'),
561
+ // array('code' => 'complete', 'name' => 'Complete', 'count' => 4, 'total' => 'UAH12.20'),
562
+ // array('code' => 'holded', 'name' => 'On Hold', 'count' => 4, 'total' => 'USD333.20'),
563
+ // array('code' => 'fraud', 'name' => 'Suspected Fraud', 'count' => 0, 'total' => 'USD33.21'),
564
+ // array('code' => 'canceled', 'name' => 'Canceled', 'count' => 1, 'total' => 'USD33.00'));
565
+
566
+
567
+ $result = array_merge($store_stats, array('data_graphs' => $data_graphs), array('order_status_stats' => $order_status_stats));
568
+ return $result;
569
+
570
+ }
571
+
572
+ protected function get_status_stats() {
573
+
574
+ $offset = $this->_get_timezone_offset();
575
+ $store_stats = array('count_orders' => "0", 'total_sales' => "0", 'count_customers' => "0", 'count_products' => "0", "last_order_id" => "0", "new_orders" => "0");
576
+
577
+ $today = date("Y-m-d", time());
578
+ $date_from = $date_to = $today;
579
+
580
+ if(!empty($this->stats_from)) {
581
+ $date_from = $this->stats_from;
582
+ }
583
+
584
+ if(!empty($this->stats_to)) {
585
+ $date_to = $this->stats_to;
586
+ }
587
+
588
+ if(isset($this->custom_period) && strlen($this->custom_period) > 0) {
589
+ $custom_period = $this->get_custom_period($this->custom_period);
590
+
591
+ $date_from = $custom_period['start_date'];
592
+ $date_to = $custom_period['end_date'];
593
+ }
594
+
595
+ if(!empty($date_from)) {
596
+ $date_from .= " 00:00:00";
597
+ }
598
+ if(!empty($date_to)) {
599
+ $date_to .= " 23:59:59";
600
+ }
601
+
602
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
603
+ $orderStatusTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_status');
604
+
605
+ $salesCollection = Mage::getModel("sales/order")->getCollection()
606
+ ->addFieldToSelect(array('state', 'status', 'store_id', 'base_grand_total', 'base_currency_code', 'order_currency_code'));
607
+
608
+ $salesCollection->clear();
609
+
610
+ if (!empty($this->group_id)) {
611
+ if($this->is_group_exists($this->group_id)) {
612
+ $salesCollection->getSelect()
613
+ ->joinLeft(
614
+ array('cs' => $storeTableName),
615
+ "cs.store_id = main_table.store_id");
616
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
617
+ }
618
+ }
619
+
620
+ $salesCollection->getSelect()
621
+ ->joinLeft(
622
+ array('sos' => $orderStatusTableName),
623
+ "sos.status = main_table.status",
624
+ array('name' => 'sos.label'));
625
+
626
+ $salesCollection->getSelect()->columns(array('code' => new Zend_Db_Expr ('main_table.status')));
627
+ $salesCollection->getSelect()->columns(array('count' => new Zend_Db_Expr ('COUNT(main_table.entity_id)')));
628
+ $salesCollection->getSelect()->columns(array('total' => new Zend_Db_Expr ('SUM(main_table.base_grand_total)')));
629
+
630
+
631
+ if(!empty($date_from)) {
632
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) >= '" . (date('Y-m-d H:i:s', (strtotime($date_from)))) ."'"));
633
+ }
634
+ if(!empty($date_to)) {
635
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '" . (date('Y-m-d H:i:s', (strtotime($date_to)))) ."'"));
636
+ }
637
+
638
+ // if(strlen($this->statuses) > 0) {
639
+ // $salesCollection->getSelect()->where(new Zend_Db_Expr("main_table.status IN ({$this->statuses})"));
640
+ // }
641
+
642
+ $salesCollection->getSelect()->group(new Zend_Db_Expr("main_table.status"));
643
+
644
+ $salesCollection->getSelect()->order( new Zend_Db_Expr('count DESC'));
645
+
646
+ $orders = array();
647
+ foreach ($salesCollection as $sale) {
648
+ $order = $sale->toArray();
649
+ unset($order['entity_id']);
650
+ unset($order['store_id']);
651
+ unset($order['state']);
652
+ unset($order['base_grand_total']);
653
+ unset($order['base_currency_code']);
654
+ unset($order['order_currency_code']);
655
+
656
+ $order['total'] = $this->_price_format($this->def_currency, 3, $order['total'], $this->currency_code, 0, true);
657
+
658
+ // $price = $this->_price_format($order['iso_code'], 1, $order['total_paid'], $this->currency_code);
659
+ // $order['customer'] = $order['firstname'] . ' ' . $order['lastname'];
660
+ //
661
+ // if($this->currency_code != false){
662
+ // $order['iso_code'] = $this->currency_code;
663
+ // }
664
+
665
+ $orders[] = $order;
666
+ }
667
+
668
+ return $orders;
669
+
670
+ }
671
+
672
+ protected function get_data_graphs() {
673
+ $orders = array();
674
+ $customers = array();
675
+ $offset = $this->_get_timezone_offset();
676
+ $average = array('avg_sum_orders' => 0, 'avg_orders' => 0, 'avg_customers' => 0, 'avg_cust_order' => '0.00', 'tot_customers' => 0, 'sum_orders' => 0, 'tot_orders' => 0);
677
+
678
+ if(empty($this->graph_from)) {
679
+ $this->graph_from = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d")-7, date("Y")));
680
+ }
681
+
682
+ if(empty($this->graph_to)) {
683
+ if(!empty($this->stats_to)) {
684
+ $this->graph_to = $this->stats_to;
685
+ } else {
686
+ $this->graph_to = date("Y-m-d", time());
687
+ }
688
+ }
689
+ $startDate = $this->graph_from . " 00:00:00";
690
+ $endDate = $this->graph_to . " 23:59:59";
691
+
692
+ $plus_date = "+1 day";
693
+ if(isset($this->custom_period) && strlen($this->custom_period) > 0) {
694
+ $custom_period = $this->get_custom_period($this->custom_period);
695
+
696
+ if($this->custom_period == 3) {
697
+ $plus_date = "+3 day";
698
+ } else if($this->custom_period == 4) {
699
+ $plus_date = "+1 week";
700
+ } else if($this->custom_period == 5 || $this->custom_period == 6 || $this->custom_period == 7) {
701
+ $plus_date = "+1 month";
702
+ }
703
+
704
+ if($this->custom_period == 6) {
705
+ $ordersCollection = Mage::getModel('sales/order')->getCollection();
706
+ $ordersCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
707
+ $ordersCollection->getSelect()->columns(array('min_date_add' => new Zend_Db_Expr ("MIN(`created_at`)")));
708
+ $ordersCollection->getSelect()->columns(array('max_date_add' => new Zend_Db_Expr ("MAX(`created_at`)")));
709
+
710
+ foreach ($ordersCollection as $order) {
711
+ $orders_info = $order->toArray();
712
+ $startDate = $orders_info['min_date_add'];
713
+ $endDate = $orders_info['max_date_add'];
714
+ }
715
+ } else {
716
+ $startDate = $custom_period['start_date']." 00:00:00";
717
+ $endDate = $custom_period['end_date']." 23:59:59";
718
+ }
719
+ }
720
+
721
+ $startDate = strtotime($startDate);
722
+ $endDate = strtotime($endDate);
723
+
724
+ $date = $startDate;
725
+ $d = 0;
726
+ $orders = array();
727
+
728
+ while ($date <= $endDate) {
729
+ $d++;
730
+ $dateStr = date('Y-m-d H:i:s', ($date));
731
+ $ordersCollection = Mage::getModel('sales/order')->getCollection();
732
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
733
+ $ordersCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
734
+
735
+ if (!empty($this->group_id)) {
736
+ if($this->is_group_exists($this->group_id)) {
737
+ $ordersCollection->getSelect()
738
+ ->joinLeft(
739
+ array('cs' => $storeTableName),
740
+ "cs.store_id = main_table.store_id",
741
+ array());
742
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
743
+ }
744
+ }
745
+
746
+ $ordersCollection->getSelect()->columns(array('date_add' => new Zend_Db_Expr ("(CONVERT_TZ(main_table.created_at, '+00:00', '{$offset}'))")));
747
+ $ordersCollection->getSelect()->columns(array('value' => new Zend_Db_Expr ("SUM(main_table.base_grand_total)")));
748
+ $ordersCollection->getSelect()->columns(array('tot_orders' => new Zend_Db_Expr ("COUNT(main_table.entity_id)")));
749
+
750
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("((CONVERT_TZ(main_table.created_at, '+00:00', '{$offset}' )) >= '{$dateStr}'
751
+ AND (CONVERT_TZ(main_table.created_at, '+00:00', '{$offset}')) < '".date('Y-m-d H:i:s', (strtotime($plus_date, $date)))."')"));
752
+
753
+
754
+ if(strlen($this->statuses) > 0) {
755
+ $this->statuses = str_replace('|', '\',\'', $this->statuses);
756
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("main_table.status IN ({$this->statuses})"));
757
+ }
758
+
759
+ $ordersCollection->getSelect()->group(new Zend_Db_Expr("DATE(main_table.created_at)"));
760
+ $ordersCollection->getSelect()->order(new Zend_Db_Expr("main_table.created_at"));
761
+
762
+ $total_order_per_day = 0;
763
+ foreach ($ordersCollection as $order) {
764
+ // var_dump($order->getData());die();
765
+ $order['value'] = $this->_price_format($this->def_currency, 2, $order['value'], $this->currency_code, false, false);
766
+
767
+ $total_order_per_day += $order['value'];
768
+ $order['date_add'] += strtotime($order['date_add']);
769
+ $average['tot_orders'] += $order['tot_orders'];
770
+ $average['sum_orders'] += $order['value'];
771
+ }
772
+
773
+ $total_order_per_day = number_format($total_order_per_day, 2, '.', '');
774
+ $orders[] = array($date*1000, $total_order_per_day);
775
+
776
+ $customersCollection = Mage::getResourceModel('customer/customer_collection');
777
+ $customersCollection->addAttributeToSelect('name');
778
+
779
+ if (!empty($this->group_id)) {
780
+ if($this->is_group_exists($this->group_id)) {
781
+ $customersCollection->getSelect()
782
+ ->joinLeft(
783
+ array('cs' => $storeTableName),
784
+ "cs.store_id = e.store_id");
785
+ $customersCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
786
+ }
787
+ }
788
+
789
+ // $customersCollection->addFieldToFilter('created_at',
790
+ // array('from' => $date,
791
+ // 'to' => strtotime($plus_date, $date),
792
+ // 'date' => true) );
793
+
794
+
795
+ $customersCollection->getSelect()->columns(array('date_add' => new Zend_Db_Expr ("CONVERT_TZ((created_at, '+00:00', {$offset}))")));
796
+ $customersCollection->getSelect()->where(new Zend_Db_Expr("((CONVERT_TZ(created_at, '+00:00', '{$offset}')) >= '{$dateStr}'
797
+ AND (CONVERT_TZ(created_at, '+00:00', '{$offset}')) < '".date('Y-m-d H:i:s', (strtotime($plus_date, $date)))."')"));
798
+
799
+ $total_customer_per_day = $customersCollection->getSize();
800
+ $average['tot_customers'] += $total_customer_per_day;
801
+ $customers_count = $customersCollection->getSize();
802
+
803
+ $customers[] = array($date*1000, $total_customer_per_day);
804
+ $date = strtotime($plus_date, $date);
805
+ }
806
+
807
+ $sum = '0';
808
+ $default_currency_sign = $this->_price_format($this->def_currency, 1, $sum, $this->currency_code, true);
809
+
810
+ if($d <= 0) $d = 1;
811
+ $average['avg_sum_orders'] = number_format($average['sum_orders']/$d, 2, '.', ' ');
812
+ $average['avg_orders'] = number_format($average['tot_orders']/$d, 1, '.', ' ');
813
+ $average['avg_customers'] = number_format($average['tot_customers']/$d, 1, '.', ' ');
814
+
815
+ if($average['tot_customers'] > 0) {
816
+ $average['avg_cust_order'] = number_format($average['sum_orders']/$average['tot_customers'], 1, '.', ' ');
817
+ }
818
+ $average['sum_orders'] = number_format($average['sum_orders'], 2, '.', ' ');
819
+ $average['tot_customers'] = number_format($average['tot_customers'], 1, '.', ' ');
820
+ $average['tot_orders'] = number_format($average['tot_orders'], 1, '.', ' ');
821
+
822
+ return array('orders' => $orders, 'customers' => $customers, 'currency_sign' => $default_currency_sign, 'average' => $average);
823
+ }
824
+
825
+ protected function get_orders() {
826
+ $offset = $this->_get_timezone_offset();
827
+ $max_date = null;
828
+ $min_date = null;
829
+ $orderStats = null;
830
+
831
+ $ordersStatsCollection = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('entity_id');
832
+ $ordersCollection = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('entity_id');
833
+
834
+
835
+ $orderStatusTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_status');
836
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
837
+
838
+ $ordersCollection->getSelect()
839
+ ->joinLeft(
840
+ array('sos' => $orderStatusTableName),
841
+ "sos.status = main_table.status",
842
+ array());
843
+ $ordersStatsCollection->getSelect()
844
+ ->joinLeft(
845
+ array('sos' => $orderStatusTableName),
846
+ "sos.status = main_table.status",
847
+ array());
848
+
849
+ if (!empty($this->group_id)) {
850
+ if($this->is_group_exists($this->group_id)) {
851
+ $ordersCollection->getSelect()
852
+ ->joinLeft(
853
+ array('cs' => $storeTableName),
854
+ "cs.store_id = main_table.store_id");
855
+ $ordersStatsCollection->getSelect()
856
+ ->joinLeft(
857
+ array('cs' => $storeTableName),
858
+ "cs.store_id = main_table.store_id");
859
+
860
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
861
+ $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
862
+ }
863
+ }
864
+
865
+ $ordersStatsCollection->getSelect()->columns(array('count_ords' => new Zend_Db_Expr ('COUNT(main_table.entity_id)')));
866
+ $ordersStatsCollection->getSelect()->columns(array('max_date' => new Zend_Db_Expr ('MAX(CONVERT_TZ(main_table.created_at, "+00:00", "'.$offset.'"))')));
867
+ $ordersStatsCollection->getSelect()->columns(array('min_date' => new Zend_Db_Expr ('MIN(CONVERT_TZ(main_table.created_at, "+00:00", "'.$offset.'"))')));
868
+ $ordersStatsCollection->getSelect()->columns(array('orders_total' => new Zend_Db_Expr ('SUM(main_table.base_grand_total)')));
869
+
870
+ $ordersCollection->getSelect()->columns(array('store_id' => new Zend_Db_Expr ('main_table.store_id')));
871
+ $ordersCollection->getSelect()->columns(array('id_order' => new Zend_Db_Expr ('main_table.entity_id')));
872
+
873
+ $ordersCollection->getSelect()->columns(array('order_number' => new Zend_Db_Expr ('main_table.increment_id')));
874
+ $ordersCollection->getSelect()->columns(array('id_customer' => new Zend_Db_Expr ('main_table.customer_id')));
875
+ $ordersCollection->getSelect()->columns(array('ord_status' => new Zend_Db_Expr ('sos.label')));
876
+ $ordersCollection->getSelect()->columns(array('status_code' => new Zend_Db_Expr ('sos.status')));
877
+ $ordersCollection->getSelect()->columns(array('qty_ordered' => new Zend_Db_Expr ('main_table.total_qty_ordered')));
878
+ $ordersCollection->getSelect()->columns(array('total_paid' => new Zend_Db_Expr ('main_table.base_grand_total')));
879
+ $ordersCollection->getSelect()->columns(array('firstname' => new Zend_Db_Expr ('main_table.customer_firstname')));
880
+ $ordersCollection->getSelect()->columns(array('lastname' => new Zend_Db_Expr ('main_table.customer_lastname')));
881
+ $ordersCollection->getSelect()->columns(array('full_name' => new Zend_Db_Expr ('CONCAT(main_table.customer_firstname, " ", main_table.customer_lastname)')));
882
+ $ordersCollection->getSelect()->columns(array('iso_code' => new Zend_Db_Expr ('main_table.global_currency_code')));
883
+ $ordersCollection->getSelect()->columns(array('date_add' => new Zend_Db_Expr ('CONVERT_TZ(main_table.created_at, "+00:00", "'.$offset.'")')));
884
+ $ordersCollection->getSelect()->columns(array('count_prods' => new Zend_Db_Expr ('main_table.total_item_count')));
885
+
886
+ if(empty($this->sort_by)) {
887
+ $this->sort_by = "id";
888
+ }
889
+
890
+ switch ($this->sort_by) {
891
+ case 'name':
892
+ $ordersCollection->getSelect()->order( array('main_table.customer_firstname ASC'));
893
+ $ordersCollection->getSelect()->order( array('main_table.customer_lastname ASC'));
894
+ $ordersStatsCollection->getSelect()->order( array('main_table.customer_firstname ASC'));
895
+ $ordersStatsCollection->getSelect()->order( array('main_table.customer_lastname ASC'));
896
+ break;
897
+ case 'date':
898
+ $ordersCollection->getSelect()->order( array('main_table.created_at DESC'));
899
+ $ordersStatsCollection->getSelect()->order( array('main_table.created_at DESC'));
900
+ break;
901
+ case 'id':
902
+ $ordersCollection->getSelect()->order( array('main_table.entity_id DESC'));
903
+ $ordersStatsCollection->getSelect()->order( array('main_table.entity_id DESC'));
904
+ break;
905
+ }
906
+
907
+ if(strlen($this->statuses) > 0){
908
+ $this->statuses = '\'' . str_replace('|', '\',\'', $this->statuses) . '\'';
909
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("main_table.status IN ({$this->statuses})"));
910
+ $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr("main_table.status IN ({$this->statuses})"));
911
+ }
912
+
913
+ if(!empty($this->orders_from)) {
914
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) >= '".date('Y-m-d H:i:s', (strtotime(($this->orders_from." 00:00:00")))) ."'"));
915
+ $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr(" (CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) >= '".date('Y-m-d H:i:s', (strtotime(($this->orders_from." 00:00:00")))) ."'"));
916
+ }
917
+
918
+ if(!empty($this->orders_to)) {
919
+ $ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '".date('Y-m-d H:i:s', (strtotime(($this->orders_to." 23:59:59")))) ."'"));
920
+ $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr(" (CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '".date('Y-m-d H:i:s', (strtotime(($this->orders_to." 23:59:59")))) ."'"));
921
+ }
922
+
923
+ $query = '';
924
+ if(!empty($this->search_order_id)) {
925
+ $query_where_parts[] = "(main_table.customer_firstname LIKE ('%".$this->search_order_id."%')
926
+ OR main_table.customer_lastname LIKE ('%".$this->search_order_id."%')
927
+ OR CONCAT(main_table.customer_firstname, ' ', main_table.customer_lastname) LIKE ('%".$this->search_order_id."%'))";
928
+ }
929
+ if(!empty($this->search_order_id) && preg_match('/^\d+(?:,\d+)*$/', $this->search_order_id)) {
930
+ $query_where_parts[] = "(main_table.entity_id IN (".$this->search_order_id.") OR main_table.increment_id IN (".$this->search_order_id."))";
931
+ }
932
+
933
+ if (!empty($query_where_parts)) {
934
+ $query .= "(" .implode(" OR ", $query_where_parts) . ")";
935
+ $ordersCollection->getSelect()->where($query);
936
+ $ordersStatsCollection->getSelect()->where($query);
937
+ }
938
+
939
+ // if(!empty($this->search_order_id)) {
940
+ // $ordersCollection->getSelect()->where(new Zend_Db_Expr("(main_table.customer_firstname LIKE ('%".$this->search_order_id."%') OR main_table.customer_lastname LIKE ('%".$this->search_order_id."%'))"));
941
+ // $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr(" (main_table.customer_firstname LIKE ('%".$this->search_order_id."%') OR main_table.customer_lastname LIKE ('%".$this->search_order_id."%'))"));
942
+ // }
943
+ //
944
+ // if(!empty($this->search_order_id)) {
945
+ // $ordersCollection->getSelect()->where(new Zend_Db_Expr("(main_table.entity_id IN (".intval($this->search_order_id).") OR main_table.increment_id IN (".intval($this->search_order_id)."))"));
946
+ // $ordersStatsCollection->getSelect()->where(new Zend_Db_Expr(" (main_table.entity_id IN (".intval($this->search_order_id).") OR main_table.increment_id IN (".intval($this->search_order_id)."))"));
947
+ // }
948
+
949
+ // echo($ordersCollection->getSelect()->__toString());die();
950
+
951
+ if(!empty($this->page) && !empty($this->show)) {
952
+ // $ordersCollection->setPage(($this->page), $this->show);
953
+ $ordersCollection->getSelect()->limit($this->show, ($this->page-1)*$this->show);
954
+ }
955
+
956
+ $orders= array();
957
+ foreach ($ordersCollection as $order) {
958
+ $orderArray = $order->toArray();
959
+ $price = $this->_price_format($orderArray['iso_code'], 1, $order['total_paid'], $this->currency_code);
960
+ $orderArray['customer'] = $orderArray['firstname'] . ' ' . $orderArray['lastname'];
961
+ $orderArray['total_paid'] = $price;
962
+
963
+ if($this->currency_code != false){
964
+ $orderArray['iso_code'] = $this->currency_code;
965
+ }
966
+
967
+ $orderArray['store_id'] = $order->getStore()->getId();
968
+ $orderArray['store_name'] = $order->getStore()->getName();
969
+ $orderArray['store_group_id'] = $order->getStore()->getGroup()->getId();
970
+ $orderArray['store_group_name'] = $order->getStore()->getGroup()->getName();
971
+
972
+ $orders[] = $orderArray;
973
+ }
974
+
975
+ if($this->page > 1 && intval($this->search_order_id) > 0) {
976
+ $orders = array();
977
+ }
978
+
979
+ foreach ($ordersStatsCollection as $orderStats) {
980
+ $orderStats = $orderStats->toArray();
981
+
982
+ if($orderStats['count_ords'] > 0) {
983
+ $max_date = date("n/j/Y", strtotime($orderStats['max_date']));
984
+ $min_date = date("n/j/Y", strtotime($orderStats['min_date']));
985
+ }
986
+
987
+ }
988
+
989
+ $orders_status = null;
990
+ if(isset($this->get_statuses) && $this->get_statuses == 1) {
991
+ $orders_status = $this->get_orders_statuses();
992
+ }
993
+
994
+ $orderStats['orders_total'] = $this->_price_format($this->def_currency, 1, $orderStats['orders_total'], $this->currency_code, false);
995
+
996
+ return array("orders" => $orders,
997
+ "orders_count" => intval($orderStats['count_ords']),
998
+ "orders_total" => $orderStats['orders_total'],
999
+ "max_date" => $max_date,
1000
+ "min_date" => $min_date,
1001
+ "orders_status" => $orders_status);
1002
+ }
1003
+
1004
+ protected function get_orders_info() {
1005
+ $offset = $this->_get_timezone_offset();
1006
+ $order_products = array();
1007
+ $order_info = array('iso_code' => '', 's_country_id' => '', 'b_country_id' => '', 'telephone' => '', 'shipping_method_mag' => '', 'payment_method_mag' => '');
1008
+
1009
+ $ordersInfoCollection = Mage::getModel('sales/order')->getCollection()->addAttributeToSelect('entity_id');
1010
+ $orderAddressTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_address');
1011
+ $orderStatusTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_status');
1012
+
1013
+ $ordersInfoCollection->getSelect()
1014
+ ->joinLeft(
1015
+ array('oa_s' => $orderAddressTableName),
1016
+ "oa_s.entity_id = main_table.shipping_address_id",
1017
+ array());
1018
+ $ordersInfoCollection->getSelect()
1019
+ ->joinLeft(
1020
+ array('oa_b' => $orderAddressTableName),
1021
+ "oa_b.entity_id = main_table.billing_address_id",
1022
+ array());
1023
+ $ordersInfoCollection->getSelect()
1024
+ ->joinLeft(
1025
+ array('sos' => $orderStatusTableName),
1026
+ "sos.status = main_table.status",
1027
+ array());
1028
+
1029
+ $ordersInfoCollection->getSelect()->columns(array('id_order' => new Zend_Db_Expr ('main_table.entity_id')));
1030
+ $ordersInfoCollection->getSelect()->columns(array('store_id' => new Zend_Db_Expr ('main_table.store_id')));
1031
+ $ordersInfoCollection->getSelect()->columns(array('order_number' => new Zend_Db_Expr ('main_table.increment_id')));
1032
+ $ordersInfoCollection->getSelect()->columns(array('status' => new Zend_Db_Expr ('sos.label')));
1033
+ $ordersInfoCollection->getSelect()->columns(array('status_code' => new Zend_Db_Expr ('sos.status')));
1034
+ $ordersInfoCollection->getSelect()->columns(array('total_paid' => new Zend_Db_Expr ('main_table.base_grand_total')));
1035
+ $ordersInfoCollection->getSelect()->columns(array('customer' => new Zend_Db_Expr ('CONCAT(main_table.customer_firstname, " ", main_table.customer_lastname)')));
1036
+ $ordersInfoCollection->getSelect()->columns(array('iso_code' => new Zend_Db_Expr ('main_table.global_currency_code')));
1037
+ $ordersInfoCollection->getSelect()->columns(array('date_add' => new Zend_Db_Expr ('CONVERT_TZ(main_table.created_at, "+00:00", "'.$offset.'")')));
1038
+ $ordersInfoCollection->getSelect()->columns(array('email' => new Zend_Db_Expr ('main_table.customer_email')));
1039
+ $ordersInfoCollection->getSelect()->columns(array('id_customer' => new Zend_Db_Expr ('main_table.customer_id')));
1040
+ $ordersInfoCollection->getSelect()->columns(array('subtotal' => new Zend_Db_Expr ('main_table.base_subtotal')));
1041
+ $ordersInfoCollection->getSelect()->columns(array('sh_amount' => new Zend_Db_Expr ('main_table.base_shipping_amount')));
1042
+ $ordersInfoCollection->getSelect()->columns(array('tax_amount' => new Zend_Db_Expr ('main_table.base_tax_amount')));
1043
+ $ordersInfoCollection->getSelect()->columns(array('d_amount' => new Zend_Db_Expr ('main_table.discount_amount')));
1044
+ $ordersInfoCollection->getSelect()->columns(array('g_total' => new Zend_Db_Expr ('main_table.base_grand_total')));
1045
+ $ordersInfoCollection->getSelect()->columns(array('t_paid' => new Zend_Db_Expr ('main_table.base_total_paid')));
1046
+ $ordersInfoCollection->getSelect()->columns(array('t_refunded' => new Zend_Db_Expr ('main_table.base_total_refunded')));
1047
+ $ordersInfoCollection->getSelect()->columns(array('t_due' => new Zend_Db_Expr ('main_table.base_total_due')));
1048
+ $ordersInfoCollection->getSelect()->columns(array('s_name' => new Zend_Db_Expr ('CONCAT(oa_s.firstname, " ", oa_s.lastname)')));
1049
+ $ordersInfoCollection->getSelect()->columns(array('s_company' => new Zend_Db_Expr ('oa_s.company')));
1050
+ $ordersInfoCollection->getSelect()->columns(array('s_street' => new Zend_Db_Expr ('oa_s.street')));
1051
+ $ordersInfoCollection->getSelect()->columns(array('s_city' => new Zend_Db_Expr ('oa_s.city')));
1052
+ $ordersInfoCollection->getSelect()->columns(array('s_region' => new Zend_Db_Expr ('oa_s.region')));
1053
+ $ordersInfoCollection->getSelect()->columns(array('s_postcode' => new Zend_Db_Expr ('oa_s.postcode')));
1054
+ $ordersInfoCollection->getSelect()->columns(array('s_country_id' => new Zend_Db_Expr ('oa_s.country_id')));
1055
+ $ordersInfoCollection->getSelect()->columns(array('s_telephone' => new Zend_Db_Expr ('oa_s.telephone')));
1056
+ $ordersInfoCollection->getSelect()->columns(array('s_fax' => new Zend_Db_Expr ('oa_s.fax')));
1057
+ $ordersInfoCollection->getSelect()->columns(array('b_name' => new Zend_Db_Expr ('CONCAT(oa_b.firstname, " ", oa_b.lastname)')));
1058
+ $ordersInfoCollection->getSelect()->columns(array('b_company' => new Zend_Db_Expr ('oa_b.company')));
1059
+ $ordersInfoCollection->getSelect()->columns(array('b_street' => new Zend_Db_Expr ('oa_b.street')));
1060
+ $ordersInfoCollection->getSelect()->columns(array('b_city' => new Zend_Db_Expr ('oa_b.city')));
1061
+ $ordersInfoCollection->getSelect()->columns(array('b_region' => new Zend_Db_Expr ('oa_b.region')));
1062
+ $ordersInfoCollection->getSelect()->columns(array('b_postcode' => new Zend_Db_Expr ('oa_b.postcode')));
1063
+ $ordersInfoCollection->getSelect()->columns(array('b_country_id' => new Zend_Db_Expr ('oa_b.country_id')));
1064
+ $ordersInfoCollection->getSelect()->columns(array('b_telephone' => new Zend_Db_Expr ('oa_b.telephone')));
1065
+ $ordersInfoCollection->getSelect()->columns(array('b_fax' => new Zend_Db_Expr ('oa_b.fax')));
1066
+
1067
+
1068
+ $ordersInfoCollection->addAttributeToFilter('main_table.entity_id', array(
1069
+ 'eq' => intval($this->order_id),
1070
+ ));
1071
+
1072
+ foreach($ordersInfoCollection as $orderInfo) {
1073
+ $order_info_array = $orderInfo->toArray();
1074
+ $order_info_array['store_id'] = $orderInfo->getStore()->getId();
1075
+ $order_info_array['store_name'] = $orderInfo->getStore()->getName();
1076
+ $order_info_array['store_group_id'] = $orderInfo->getStore()->getGroup()->getId();
1077
+ $order_info_array['store_group_name'] = $orderInfo->getStore()->getGroup()->getName();
1078
+
1079
+ $order_info = $order_info_array;
1080
+ }
1081
+
1082
+ $iso_code = $order_info['iso_code'];
1083
+ $elements = array('total_paid', 'subtotal', 'sh_amount', 'tax_amount', 'd_amount', 'g_total', 't_paid', 't_refunded', 't_due');
1084
+ foreach($elements as $element) {
1085
+ $price = $this->_price_format($iso_code, 1, $order_info[$element], $this->currency_code);
1086
+ $order_info[$element] = $price;
1087
+ }
1088
+
1089
+ if($this->currency_code != false){
1090
+ $order_info['iso_code'] = $this->currency_code;
1091
+ }
1092
+
1093
+ $order_info['s_country_id'] = Mage::getModel('directory/country')->load($order_info['s_country_id'])->getName();
1094
+ $order_info['b_country_id'] = Mage::getModel('directory/country')->load($order_info['b_country_id'])->getName();
1095
+
1096
+ $ordersItemsCollection = Mage::getModel('sales/order_item')->getCollection()->addAttributeToSelect('product_id', 'parent_item_id');
1097
+ $orderTableName = Mage::getSingleton('core/resource')->getTableName('sales/order');
1098
+
1099
+ $ordersItemsCollection->getSelect()
1100
+ ->joinLeft(
1101
+ array('sfo' => $orderTableName),
1102
+ "sfo.entity_id = main_table.order_id",
1103
+ array());
1104
+
1105
+ $ordersItemsCollection->getSelect()->columns(array('id_order' => new Zend_Db_Expr ('main_table.order_id')));
1106
+ $ordersItemsCollection->getSelect()->columns(array('type_id' => new Zend_Db_Expr ('main_table.product_type')));
1107
+ $ordersItemsCollection->getSelect()->columns(array('product_name' => new Zend_Db_Expr ('main_table.name')));
1108
+ $ordersItemsCollection->getSelect()->columns(array('product_quantity' => new Zend_Db_Expr ('main_table.qty_ordered')));
1109
+ $ordersItemsCollection->getSelect()->columns(array('product_price' => new Zend_Db_Expr ('main_table.base_row_total_incl_tax')));
1110
+ $ordersItemsCollection->getSelect()->columns(array('sku' => new Zend_Db_Expr ('main_table.sku')));
1111
+ $ordersItemsCollection->getSelect()->columns(array('iso_code' => new Zend_Db_Expr ('sfo.global_currency_code')));
1112
+ $ordersItemsCollection->getSelect()->columns(array('product_options' => new Zend_Db_Expr ('main_table.product_options')));
1113
+
1114
+ $ordersItemsCollection->addAttributeToFilter('main_table.order_id', array(
1115
+ 'eq' => intval($this->order_id),
1116
+ ));
1117
+
1118
+ $allowedParentId = array(
1119
+ array(
1120
+ 'null' => true
1121
+ ),
1122
+ array(
1123
+ 'eq' => 0
1124
+ )
1125
+ );
1126
+
1127
+ $ordersItemsCollection->addAttributeToFilter('main_table.parent_item_id', $allowedParentId);
1128
+
1129
+ if(empty($this->sort_by)) {
1130
+ $this->sort_by = "id";
1131
+ }
1132
+
1133
+ switch ($this->sort_by) {
1134
+ case 'name':
1135
+ $ordersItemsCollection->getSelect()->order( array('full_name ASC'));
1136
+ break;
1137
+ case 'date':
1138
+ $ordersItemsCollection->getSelect()->order( array('date_add DESC'));
1139
+ break;
1140
+ case 'id':
1141
+ $ordersItemsCollection->getSelect()->order( array('id_order DESC'));
1142
+ break;
1143
+ }
1144
+
1145
+ if(!empty($this->page) && !empty($this->show)) {
1146
+ $ordersItemsCollection->setPage($this->page, $this->show);
1147
+ }
1148
+
1149
+ foreach($ordersItemsCollection as $orderItem) {
1150
+ $options = $orderItem->getProductOptions();
1151
+ $thumbnail = $orderItem->getProduct()->getMediaConfig()->getMediaUrl($orderItem->getProduct()->getThumbnail());
1152
+
1153
+ $orderItem = $orderItem->toArray();
1154
+
1155
+ //-- get ordered item options
1156
+ $orderItem['options'] = array();
1157
+ if(isset($options['options'])){
1158
+ foreach ($options['options'] as $option) {
1159
+ array_push($orderItem['options'], array($option['label'] => $option['value']));
1160
+ }
1161
+ }
1162
+
1163
+ $orderItem['thumbnail'] = $thumbnail;
1164
+ $orderItem['product_price'] = $this->_price_format($order_info['iso_code'], 1, $orderItem['product_price'], $this->currency_code);
1165
+ $orderItem['product_quantity'] = intval($orderItem['product_quantity']);
1166
+ $orderItem['type_id'] = ucfirst($orderItem['type_id']);
1167
+ if($this->currency_code != false){
1168
+ $orderItem['iso_code'] = $this->currency_code;
1169
+ }
1170
+ unset($orderItem['product']);
1171
+ $order_products[] = $orderItem;
1172
+ }
1173
+
1174
+
1175
+ $orderCountItemsCollection = Mage::getModel('sales/order_item')->getCollection()->addAttributeToSelect('entity_id');
1176
+ $orderCountItemsCollection->getSelect()->columns(array('count_prods' => new Zend_Db_Expr ('COUNT(item_id)')));
1177
+ $orderCountItemsCollection->addAttributeToFilter('order_id', array(
1178
+ 'eq' => intval($this->order_id),
1179
+ ));
1180
+ $orderCountItemsCollection->addAttributeToFilter('parent_item_id', $allowedParentId);
1181
+
1182
+
1183
+ $count_prods = $orderCountItemsCollection->getSize();
1184
+
1185
+ if(!empty($this->order_id)) {
1186
+
1187
+ $cur_order = Mage::getModel('sales/order')->load($this->order_id);
1188
+
1189
+ $actions = array();
1190
+
1191
+ if($cur_order->canCancel()) {
1192
+ $actions[] = 'cancel';
1193
+ }
1194
+
1195
+ if($cur_order->canHold()) {
1196
+ $actions[] = 'hold';
1197
+ }
1198
+
1199
+ if($cur_order->canUnhold()) {
1200
+ $actions[] = 'unhold';
1201
+ }
1202
+
1203
+ if($cur_order->canShip()) {
1204
+ $actions[] = 'ship';
1205
+ }
1206
+
1207
+ if($cur_order->canInvoice()) {
1208
+ $actions[] = 'invoice';
1209
+ }
1210
+
1211
+ $cus_id = $cur_order->getCustomerId();
1212
+
1213
+ $customer_data = Mage::getModel('customer/customer')->load($cus_id);
1214
+
1215
+ $customerAddressId = $customer_data->getDefaultBilling();
1216
+ if($customerAddressId) {
1217
+ $address = Mage::getModel('customer/address')->load($customerAddressId)->toArray();
1218
+ if(count($address) > 1) {
1219
+ $order_info['telephone'] = $address['telephone'];
1220
+ }
1221
+ }
1222
+
1223
+ if(empty($order_info['telephone'])) {
1224
+ $order_info['telephone'] = '';
1225
+ }
1226
+ $order_info['shipping_method_mag'] = $cur_order->getShippingDescription();
1227
+ $order_info['payment_method_mag'] = $cur_order->getPayment()->getMethodInstance()->getTitle();
1228
+
1229
+
1230
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
1231
+ ->setOrderFilter($cur_order)
1232
+ ->load();
1233
+ $tracks = array();
1234
+ foreach ($shipmentCollection as $shipment) {
1235
+ foreach($shipment->getAllTracks() as $tracknum)
1236
+ {
1237
+ $track['track_number'] = $tracknum->getTrackNumber();
1238
+ $track['title'] = $tracknum->getTitle();
1239
+ $track['carrier_code'] = $tracknum->getCarrierCode();
1240
+ $track['created_at'] = $tracknum->getCreatedAt();
1241
+
1242
+ $tracks[]=$track;
1243
+ }
1244
+
1245
+ }
1246
+
1247
+ $order_full_info = array("order_info" => $order_info, "order_products" => $order_products, "o_products_count" => $count_prods, "order_tracking" => $tracks, "actions" => $actions);
1248
+
1249
+ return $order_full_info;
1250
+ } else return false;
1251
+ }
1252
+
1253
+ protected function map_order_statuses($status) {
1254
+ return array(
1255
+ 'st_id' => $status['status'],
1256
+ 'st_name' => $status['label']
1257
+ );
1258
+ }
1259
+
1260
+ protected function get_orders_statuses() {
1261
+ $statuses = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
1262
+
1263
+ $final_statuses = array_map( array($this, 'map_order_statuses'), $statuses);
1264
+
1265
+ return $final_statuses;
1266
+ }
1267
+
1268
+ private function invoice_order() {
1269
+ $order = Mage::getModel("sales/order")->load($this->order_id);
1270
+ $result = array('error' => $this->__('An error occurred!'));
1271
+ try {
1272
+ if($order->canInvoice())
1273
+ {
1274
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
1275
+ if ($invoice->getTotalQty()) {
1276
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
1277
+ $invoice->register();
1278
+ $transactionSave = Mage::getModel('core/resource_transaction')
1279
+ ->addObject($invoice)
1280
+ ->addObject($invoice->getOrder());
1281
+ $transactionSave->save();
1282
+ $order->addStatusHistoryComment('Invoice was created from Mobile Assistant.', false);
1283
+ $order->save();
1284
+ $result = array('success' => 'true');
1285
+ } else {
1286
+ $order->addStatusHistoryComment('Cannot create an invoice without products.', false);
1287
+ $order->save();
1288
+ $result = array('error' => $this->__('Cannot create an invoice without products!'));
1289
+ }
1290
+ } else {
1291
+ $order->addStatusHistoryComment('Order cannot be invoiced.', false);
1292
+ $order->save();
1293
+ $result = array('error' => $this->__('Cannot create an invoice!'));
1294
+ }
1295
+ }
1296
+ catch (Mage_Core_Exception $e) {
1297
+ }
1298
+
1299
+ return $result;
1300
+ }
1301
+
1302
+
1303
+ private function ship_order() {
1304
+ $result = array('error' => $this->__('An error occurred!'));
1305
+ $title = '';
1306
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1307
+
1308
+ if(isset($this->tracking_title) && strlen($this->tracking_title) > 0) {
1309
+ $title = $this->tracking_title;
1310
+ } else {
1311
+ $carriers = $this->get_carriers();
1312
+
1313
+ foreach($carriers as $carrier) {
1314
+ if($carrier['code'] == $this->carrier_code) {
1315
+ $title = $carrier['label'];
1316
+ }
1317
+ }
1318
+ }
1319
+
1320
+ if($order->hasShipments()) {
1321
+ foreach($order->getShipmentsCollection() as $shipment)
1322
+ {
1323
+ $shipmentIncrementId = $shipment->getIncrementId();
1324
+ if($shipmentIncrementId) {
1325
+ if(isset($this->tracking_number) && strlen($this->tracking_number) > 0 && isset($this->carrier_code) && strlen($this->carrier_code) > 0) {
1326
+ try {
1327
+ Mage::getModel('sales/order_shipment_api')->addTrack($shipmentIncrementId, $this->carrier_code, $title, $this->tracking_number);
1328
+
1329
+ // mail customer
1330
+ if ($this->is_mail == 1) {
1331
+ Mage::getModel('sales/order_shipment_api')->sendInfo($shipmentIncrementId);
1332
+ }
1333
+
1334
+ $result = array('success' => 'true');
1335
+ }
1336
+ catch(Exception $e) {
1337
+ Mage::log(
1338
+ "error: Adding track number: {$e->getMessage()} ({$e->getCustomMessage()})",
1339
+ null,
1340
+ 'emagicone_mobassistantconnector.log'
1341
+ );
1342
+
1343
+ $result = array('error' => $e->getMessage() . ' ('. $e->getCustomMessage() .')');
1344
+ }
1345
+ } else $result = array('error' => $this->__('Empty tracking number!'));
1346
+ }
1347
+ }
1348
+ }
1349
+ else if ($order->canShip()) {
1350
+
1351
+ $shipment = new Mage_Sales_Model_Order_Shipment_Api();
1352
+ $shipmentId = $shipment->create($order->getIncrementId());
1353
+
1354
+ if(isset($this->tracking_number) && strlen($this->tracking_number) > 0 && isset($this->carrier_code) && strlen($this->carrier_code) > 0) {
1355
+ $shipment->addTrack($shipmentId, $this->carrier_code, $title, $this->tracking_number);
1356
+ }
1357
+
1358
+ // mail customer
1359
+ if ($this->is_mail == 1) {
1360
+ $shipment->sendInfo($shipmentId);
1361
+ }
1362
+
1363
+ $result = array('success' => 'true');
1364
+ } else
1365
+ $result = array('error' => $this->__('Current order cannot be shipped!'));
1366
+
1367
+ return $result;
1368
+ }
1369
+
1370
+ private function cancel_order() {
1371
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1372
+ if($order->canCancel()) {
1373
+ $order->cancel();
1374
+ $order->addStatusHistoryComment('Order was canceled by MA', false);
1375
+ $order->save();
1376
+ $result = array('success' => 'true');
1377
+ } else {
1378
+ $order->addStatusHistoryComment('Order cannot be canceled', false);
1379
+ $order->save();
1380
+ $result = array('error' => $this->__('Current order cannot be canceled!'));
1381
+ }
1382
+
1383
+ return $result;
1384
+ }
1385
+
1386
+ private function hold_order() {
1387
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1388
+ if($order->canHold()) {
1389
+ $order->hold();
1390
+ $order->addStatusHistoryComment('Order was holded by MA', false);
1391
+ $order->save();
1392
+ $result = array('success' => 'true');
1393
+ } else {
1394
+ $order->addStatusHistoryComment('Order cannot be holded', false);
1395
+ $order->save();
1396
+ $result = array('error' => $this->__('Current order cannot be holded!'));
1397
+ }
1398
+
1399
+ return $result;
1400
+ }
1401
+
1402
+ private function unhold_order() {
1403
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1404
+ if($order->canUnhold()) {
1405
+ $order->unhold();
1406
+ $order->addStatusHistoryComment('Order was unholded by MA', false);
1407
+ $order->save();
1408
+ $result = array('success' => 'true');
1409
+ } else {
1410
+ $order->addStatusHistoryComment('Order cannot be unholded', false);
1411
+ $order->save();
1412
+ $result = array('error' => $this->__('Current order cannot be unholded!'));
1413
+ }
1414
+
1415
+ return $result;
1416
+ }
1417
+
1418
+ private function delete_track_number() {
1419
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1420
+ $matches = 0;
1421
+
1422
+ $shipCollection = $order->getShipmentsCollection();
1423
+ if($shipCollection) {
1424
+
1425
+ foreach($shipCollection as $_ship) {
1426
+ $trackingNums = $_ship->getAllTracks();
1427
+ $matches = 0;
1428
+ if (count($trackingNums) >= 1) {
1429
+ foreach ($trackingNums as $track) {
1430
+ if ($track->getNumber() == $this->tracking_number) {
1431
+ $track->delete();
1432
+ $matches++;
1433
+ }
1434
+ }
1435
+ }
1436
+ }
1437
+ if($matches > 0) {
1438
+ $result = array('success' => 'true');
1439
+ } else $result = array('error' => $this->__('Current tracking number was not found'));
1440
+
1441
+ } else
1442
+ $result = array('error' => $this->__('Current order does not have shipments!'));
1443
+
1444
+ return $result;
1445
+ }
1446
+
1447
+ protected function set_order_action() {
1448
+ $result = array('error' => $this->__('An error occurred!'));
1449
+ if(isset($this->order_id) && (intval($this->order_id) > 0)) {
1450
+ if(isset($this->action) && strlen($this->action) > 0) {
1451
+ $order = Mage::getModel('sales/order')->load($this->order_id);
1452
+ if ($order->getId()) {
1453
+ switch ($this->action) {
1454
+ case 'cancel':
1455
+ $result = $this->cancel_order();
1456
+ break;
1457
+ case 'hold':
1458
+ $result = $this->hold_order();
1459
+ break;
1460
+ case 'unhold':
1461
+ $result = $this->unhold_order();
1462
+ break;
1463
+ case 'invoice':
1464
+ $result = $this->invoice_order();
1465
+ break;
1466
+ case 'ship':
1467
+ $result = $this->ship_order();
1468
+ break;
1469
+ case 'del_track':
1470
+ $result = $this->delete_track_number();
1471
+ break;
1472
+ }
1473
+ } else $result = array('error' => $this->__('No order was found!'));
1474
+ } else $result = array('error' => $this->__('Action is not set!'));
1475
+ } else $result = array('error' => $this->__('Order id cannot be empty!'));
1476
+
1477
+ return $result;
1478
+ }
1479
+
1480
+ protected function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
1481
+ {
1482
+ if (in_array($attribute, array('carts', 'orders','ordered_qty'))) {
1483
+ $this->getSelect()->order($attribute . ' ' . $dir);
1484
+ } else {
1485
+ parent::setOrder($attribute, $dir);
1486
+ }
1487
+
1488
+ return $this;
1489
+ }
1490
+
1491
+ protected function get_carriers() {
1492
+ $options = array();
1493
+ $originalCarriers = Mage::getSingleton('shipping/config')->getAllCarriers();
1494
+
1495
+ if(!$this->group_id) {
1496
+ $this->group_id = null;
1497
+ }
1498
+ $carriers = array();
1499
+
1500
+ if (Mage::helper('core')->isModuleEnabled('Xtento_CustomTrackers')) {
1501
+ $disabledCarriers = explode(",", Mage::getStoreConfig('customtrackers/general/disabled_carriers', null));
1502
+ foreach ($originalCarriers as $code => $carrierConfig) {
1503
+ if (in_array($code, $disabledCarriers)) {
1504
+ unset($originalCarriers[$code]);
1505
+ }
1506
+ }
1507
+
1508
+ if(strval($this->group_id) != '-1') {
1509
+ $collection = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id', $this->group_id);
1510
+ $carriers = array();
1511
+ foreach ($collection as $store) {
1512
+ //do something with $store
1513
+
1514
+ $config = Mage::getStoreConfig('customtrackers', $store->getStoreId());
1515
+ foreach ($config as $code => $carrierConfig) {
1516
+ if ($code == 'general') continue;
1517
+ if ($carrierConfig['active'] == '1') {
1518
+ $carriers[$code] = $carrierConfig['title'];
1519
+ }
1520
+ }
1521
+ }
1522
+ } else {
1523
+ foreach (Mage::app()->getWebsites() as $website) {
1524
+ foreach ($website->getGroups() as $group) {
1525
+ foreach ($group->getStores() as $store) {
1526
+ $config = Mage::getStoreConfig('customtrackers', $store->getStoreId());
1527
+ foreach ($config as $code => $carrierConfig) {
1528
+ if ($code == 'general') continue;
1529
+ if ($carrierConfig['active'] == '1') {
1530
+ if((preg_match('/^Custom Tracker \d$/', $carriers[$code]) && ($carriers[$code] != $carrierConfig['title'])) || (is_null($carriers[$code]))) {
1531
+ $carriers[$code] = $carrierConfig['title'];
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+
1541
+
1542
+ foreach($originalCarriers as $_code => $_method)
1543
+ {
1544
+ if($_method->isTrackingAvailable()) {
1545
+ if(!$_title = Mage::getStoreConfig("carriers/$_code/title"))
1546
+ $_title = $_code;
1547
+ $options[] = array('code' => $_code, 'label' => (strlen($_title)>0) ? $_title : $_title . " ($_code)");
1548
+ }
1549
+ }
1550
+
1551
+
1552
+ foreach ($options as $id => $option) {
1553
+ if(in_array($option['code'], array_keys($carriers))) {
1554
+ $options[$id]['label'] = $carriers[$option['code']];
1555
+ }
1556
+ }
1557
+
1558
+ return $options;
1559
+ }
1560
+
1561
+ protected function get_customers() {
1562
+ $offset = $this->_get_timezone_offset();
1563
+
1564
+ $customerCollection = Mage::getModel('customer/customer')->getCollection();
1565
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
1566
+
1567
+ $cust_attr_ids = $this->_get_customers_attr();
1568
+
1569
+ if (!empty($this->group_id)) {
1570
+ if($this->is_group_exists($this->group_id)) {
1571
+ $customerCollection->getSelect()
1572
+ ->joinLeft(
1573
+ array('cs' => $storeTableName),
1574
+ "cs.store_id = e.store_id");
1575
+ $customerCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
1576
+ }
1577
+ }
1578
+
1579
+ $customerCollection->getSelect()->joinLeft(array('firstname' => Mage::getConfig()->getTablePrefix().'customer_entity_varchar'),
1580
+ 'e.entity_id = firstname.entity_id AND firstname.attribute_id = "'.$cust_attr_ids['firstname'].'"',
1581
+ array('firstname' => 'value'));
1582
+
1583
+ $customerCollection->getSelect()->joinLeft(array('middlename' => Mage::getConfig()->getTablePrefix().'customer_entity_varchar'),
1584
+ 'e.entity_id = middlename.entity_id AND middlename.attribute_id = "'.$cust_attr_ids['middlename'].'"',
1585
+ array('middlename' => 'value'));
1586
+
1587
+ $customerCollection->getSelect()->joinLeft(array('lastname' => Mage::getConfig()->getTablePrefix().'customer_entity_varchar'),
1588
+ 'e.entity_id = lastname.entity_id AND lastname.attribute_id = "'.$cust_attr_ids['lastname'].'"',
1589
+ array('lastname' => 'value'));
1590
+
1591
+ $orderTableName = Mage::getSingleton('core/resource')->getTableName('sales/order');
1592
+ $customerCollection->getSelect()->joinLeft( array('sfo'=>$orderTableName), 'e.entity_id = sfo.customer_id', array('sale_id' => 'sfo.entity_id'));
1593
+
1594
+ $customerCollection->getSelect()->columns(array('count_ords' => new Zend_Db_Expr ('COUNT(sfo.entity_id)')));
1595
+
1596
+ $customerCollection->getSelect()->group(array('e.entity_id'));
1597
+ $customerCollection->getSelect()->columns(array('c_id' => new Zend_Db_Expr ('e.entity_id')));
1598
+
1599
+ $query = '';
1600
+ if(!empty($this->customers_from)) {
1601
+ $query_where_parts[] = sprintf(" (CONVERT_TZ(e.created_at, '+00:00', '".$offset."')) >= '%s'", (date('Y-m-d H:i:s', (strtotime($this->customers_from." 00:00:00")))));
1602
+ }
1603
+ if(!empty($this->customers_to)) {
1604
+ $query_where_parts[] = sprintf(" (CONVERT_TZ(e.created_at, '+00:00', '".$offset."')) <= '%s'", (date('Y-m-d H:i:s', (strtotime($this->customers_to." 23:59:59")))));
1605
+ }
1606
+ if (!empty($query_where_parts)) {
1607
+ $query .= implode(" AND ", $query_where_parts);
1608
+ $customerCollection->getSelect()->where($query);
1609
+ }
1610
+
1611
+
1612
+ if(!empty($this->search_val)) {
1613
+ $customerCollection->getSelect()->where("e.`email` LIKE '%".$this->search_val."%' OR `firstname`.`value` LIKE '%".$this->search_val."%' OR `lastname`.`value` LIKE '%".$this->search_val."%' OR CONCAT(`firstname`.`value`, ' ', `lastname`.`value`) LIKE '%".$this->search_val."%' OR e.entity_id IN (".intval($this->search_val).")");
1614
+ }
1615
+
1616
+ if(!empty($this->cust_with_orders)) {
1617
+ $customerCollection->getSelect()->having('count_ords > 0');
1618
+ }
1619
+
1620
+ if(empty($this->sort_by)) {
1621
+ $this->sort_by = "id";
1622
+ }
1623
+
1624
+ switch ($this->sort_by) {
1625
+ case 'name':
1626
+ $customerCollection->getSelect()->order( array('firstname ASC'));
1627
+ $customerCollection->getSelect()->order( array('lastname ASC'));
1628
+ break;
1629
+ case 'date':
1630
+ $customerCollection->getSelect()->order( array('e.created_at DESC'));
1631
+ break;
1632
+ case 'id':
1633
+ $customerCollection->getSelect()->order( array('e.entity_id DESC'));
1634
+ break;
1635
+ }
1636
+
1637
+
1638
+
1639
+ $customers_count = count($customerCollection);
1640
+ if(!empty($this->page) && !empty($this->show)) {
1641
+ $customerCollection->clear();
1642
+ $customerCollection->getSelect()->limit($this->show, ($this->page-1)*$this->show);
1643
+ }
1644
+
1645
+ // echo($customerCollection->getSelect()->__toString());die();
1646
+
1647
+ $customers= array();
1648
+
1649
+ if($customers_count > ($this->page-1)*$this->show) {
1650
+ foreach ($customerCollection as $customer) {
1651
+
1652
+ $reg_date = explode(' ', $customer->getCreatedAt());
1653
+ $reg_date = $reg_date[0];
1654
+
1655
+ $cur_customer = array(
1656
+ "id_customer" => $customer->getCId(),
1657
+ "firstname" => $customer->getFirstname(),
1658
+ "middlename" => $customer->getMidlename(),
1659
+ "lastname" => $customer->getLastname(),
1660
+ "full_name" => $customer->getFirstname() . ' ' . $customer->getLastname(),
1661
+ "date_add" => $reg_date,
1662
+ "email" => $customer->getEmail(),
1663
+ "total_orders" => $customer->getCount_ords()
1664
+ );
1665
+
1666
+ $cur_customer['total_orders'] = $customer->getCount_ords();
1667
+ $customers[] = $cur_customer;
1668
+ }
1669
+ }
1670
+
1671
+ return array('customers_count' => $customers_count,
1672
+ 'customers' => $customers);
1673
+ }
1674
+
1675
+ protected function get_customers_info() {
1676
+ $user_info = array('city' => '', 'postcode' => '', 'phone' => '', 'region' => '', 'country' => '', 'street' => '', 'country_name' => '');
1677
+
1678
+ $cust_attr_ids = $this->_get_customers_attr($this->user_id);
1679
+ $offset = $this->_get_timezone_offset();
1680
+
1681
+ $customer = Mage::getModel('customer/customer')->load($this->user_id);
1682
+
1683
+ $user_info['id_customer'] = $customer->getEntityId();
1684
+ $user_info['date_add'] = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp($customer->getCreatedAt()));
1685
+ $user_info['email'] = $customer->getEmail();
1686
+ $user_info['firstname'] = $customer->getFirstname();
1687
+ $user_info['middlename'] = $customer->getMiddlename();
1688
+ $user_info['lastname'] = $customer->getLastname();
1689
+
1690
+
1691
+ $customerAddressId = $customer->getDefaultBilling();
1692
+
1693
+ if($customerAddressId) {
1694
+ $address = Mage::getModel('customer/address')->load($customerAddressId)->toArray();
1695
+ if(count($address) > 1) {
1696
+ $user_info['city'] = $address['city'];
1697
+ $user_info['postcode'] = $address['postcode'];
1698
+ $user_info['phone'] = $address['telephone'];
1699
+ $user_info['region'] = $address['region'];
1700
+ $user_info['country'] = $address['country_id'];
1701
+ $user_info['street'] = $address['street'];
1702
+ $user_info['country_name'] = Mage::getModel('directory/country')->load($address['country_id'])->getName();
1703
+ }
1704
+ }
1705
+
1706
+ $user_info['address'] = $this->split_values($user_info, array('street', 'city', 'region', 'postcode', 'country_name'));
1707
+ unset($user_info['country_name']);
1708
+
1709
+ $ordersCollection = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$this->user_id);
1710
+ $ordersCollection->addAttributeToSelect('base_grand_total');
1711
+ $ordersCollection->addAttributeToSelect('entity_id');
1712
+ $ordersCollection->addAttributeToSelect('status');
1713
+ $ordersCollection->addAttributeToSelect('total_item_count');
1714
+ $ordersCollection->addAttributeToSelect('created_at');
1715
+ $ordersCollection->addAttributeToSelect('global_currency_code');
1716
+ $ordersCollection->addAttributeToSelect('increment_id');
1717
+ $ordersCollection->addAttributeToSelect('store_id');
1718
+
1719
+ $ordersSum = array_sum($ordersCollection->getColumnValues('base_grand_total'));
1720
+ $row_page['count_ords'] = $ordersCollection->count();
1721
+
1722
+ $ordersSum = $this->bd_nice_number($ordersSum);
1723
+ $row_page['sum_ords'] = $this->_price_format($this->def_currency, 1, $ordersSum, 0, 0);
1724
+
1725
+ if(!empty($this->page) && !empty($this->show)) {
1726
+ $ordersCollection->clear();
1727
+ $ordersCollection->getSelect()->limit($this->show, ($this->page-1)*$this->show);
1728
+ }
1729
+
1730
+ $customer_orders = null;
1731
+ foreach($ordersCollection as $order) {
1732
+ $o_status_label = $order->getStatusLabel();
1733
+ $c_order['store_id'] = $order->getStore()->getId();
1734
+ $c_order['store_name'] = $order->getStore()->getName();
1735
+ $c_order['store_group_id'] = $order->getStore()->getGroup()->getId();
1736
+ $c_order['store_group_name'] = $order->getStore()->getGroup()->getName();
1737
+ $c_order['ord_status_code'] = $order->status;
1738
+
1739
+ $order = $order->toArray();
1740
+ // TODO: assign values in simple way
1741
+ list($c_order['total_paid'], $c_order['id_order'], $c_order['ord_status'], $c_order['pr_qty'], $c_order['date_add'], $c_order['iso_code']) = array_values($order);
1742
+
1743
+ $c_order['total_paid'] = $this->_price_format($c_order['iso_code'], 1, $c_order['total_paid'], $this->currency_code);
1744
+ $c_order['pr_qty'] = intval($c_order['pr_qty']);
1745
+ $c_order['ord_status'] = $o_status_label;
1746
+ $c_order['order_number'] = $order['increment_id'];
1747
+
1748
+ unset($order['increment']);
1749
+
1750
+ $customer_orders[] = $c_order;
1751
+ }
1752
+
1753
+ $this->_price_format($this->def_currency, 1, $row_page['sum_ords'], $this->currency_code, false);
1754
+
1755
+ return array('user_info' => $user_info, 'customer_orders' => $customer_orders, "c_orders_count" => intval($row_page['count_ords']), "sum_ords" => $row_page['sum_ords']);
1756
+ }
1757
+
1758
+ protected function _get_customers_attr($user_id = false) {
1759
+ $customer_attrs = array('default_billing' => false, 'default_shipping' => false);
1760
+ $attributes = Mage::getResourceModel('customer/attribute_collection')->getItems();
1761
+
1762
+ foreach ($attributes as $attribute) {
1763
+ $customer_attrs[$attribute->getAttributeCode()] = $attribute->getAttributeId();
1764
+ }
1765
+
1766
+ $customer_data = Mage::getModel('customer/customer')->load($user_id);
1767
+ $customer_attrs['default_billing'] = $customer_data->getDefaultBilling();
1768
+ $customer_attrs['default_shipping'] = $customer_data->getDefaultShipping();
1769
+
1770
+ return $customer_attrs;
1771
+ }
1772
+
1773
+
1774
+ protected function search_products() {
1775
+ $products = array();
1776
+
1777
+ $flatHelper = Mage::helper('catalog/product_flat');
1778
+ if ($flatHelper->isEnabled()) {
1779
+ $emulationModel = Mage::getModel('core/app_emulation');
1780
+ $initialEnvironmentInfo = $emulationModel->startEnvironmentEmulation(0, Mage_Core_Model_App_Area::AREA_ADMINHTML);
1781
+ }
1782
+
1783
+ $collection = Mage::getModel('catalog/product')->getCollection();
1784
+
1785
+ $collection->addAttributeToSelect('*');
1786
+
1787
+ $collection->addAttributeToSelect('name');
1788
+ $collection->joinField(
1789
+ 'qty',
1790
+ 'cataloginventory/stock_item',
1791
+ 'qty',
1792
+ 'product_id=entity_id',
1793
+ '{{table}}.stock_id=1',
1794
+ 'left'
1795
+ );
1796
+
1797
+ $filters = array();
1798
+ if(strlen($this->params) > 0){
1799
+ $this->params = explode("|", $this->params);
1800
+
1801
+ foreach($this->params as $param) {
1802
+ switch ($param) {
1803
+ case 'pr_id':
1804
+ if(isset($this->val) && strlen($this->val) > 0) {
1805
+ $filters[] = array('attribute' => 'entity_id', 'eq' => $this->val );
1806
+ }
1807
+ break;
1808
+ case 'pr_sku':
1809
+ if(isset($this->val) && strlen($this->val) > 0) {
1810
+ $filters[] = array('attribute' => 'sku', 'like' => '%'.$this->val.'%');
1811
+ }
1812
+ break;
1813
+ case 'pr_name':
1814
+ if(isset($this->val) && strlen($this->val) > 0) {
1815
+ $filters[] = array('attribute' => 'name', 'like' => '%'.$this->val.'%');
1816
+ }
1817
+ break;
1818
+ case 'pr_desc':
1819
+ if(isset($this->val) && strlen($this->val) > 0) {
1820
+ $filters[] = array('attribute' => 'description', 'like' => '%'.$this->val.'%');
1821
+ }
1822
+ break;
1823
+ case 'pr_short_desc':
1824
+ if(isset($this->val) && strlen($this->val) > 0) {
1825
+ $filters[] = array('attribute' => 'description', 'like' => '%'.$this->val.'%');
1826
+ }
1827
+ break;
1828
+ }
1829
+ }
1830
+
1831
+ if(count($filters) > 0) {
1832
+ $collection->addFieldToFilter($filters);
1833
+ }
1834
+ }
1835
+
1836
+
1837
+ if($this->sort_by == 'name') {
1838
+ $filters[] = array('attribute' => 'name', 'like' => '%%');
1839
+ $collection->addFieldToFilter($filters);
1840
+ }
1841
+
1842
+ if(empty($this->sort_by)) {
1843
+ $this->sort_by = "id";
1844
+ }
1845
+
1846
+ switch ($this->sort_by) {
1847
+ case 'name':
1848
+ $collection->getSelect()->order( array('name'));
1849
+ break;
1850
+ case 'id':
1851
+ $collection->getSelect()->order( array('e'.'.entity_id DESC'));
1852
+ break;
1853
+ }
1854
+
1855
+ $products_count = $collection->getSize();
1856
+
1857
+ if(!empty($this->page) && !empty($this->show)) {
1858
+ $collection->getSelect()->limit($this->show, ($this->page-1)*$this->show);
1859
+ }
1860
+
1861
+ foreach($collection as $product) {
1862
+ $productFinal['main_id'] = $product->getEntityId();
1863
+ $productFinal['product_id'] = $product->getEntityId();
1864
+ $productFinal['name'] = $product->getName();
1865
+ $productFinal['type_id'] = ucfirst($product->getTypeId());
1866
+ $productFinal['thumbnail'] = $product->getMediaConfig()->getMediaUrl($product->getThumbnail());
1867
+
1868
+ $productFinal['sku'] = $product->getSku();
1869
+ $productFinal['quantity'] = intval($product->getQty());
1870
+ $pArr['price'] = $product->getPrice();
1871
+ $pArr['spec_price'] = $product->getSpecialPrice();
1872
+
1873
+ $productFinal['price'] = $this->_price_format($this->def_currency, 1, $pArr['price'], $this->currency_code);
1874
+
1875
+ if($pArr['spec_price'] > 0 && $pArr['spec_price'] != '') {
1876
+ $productFinal['spec_price'] = $this->_price_format($this->def_currency, 1, $pArr['spec_price'], $this->currency_code);
1877
+ } else {
1878
+ unset($productFinal['spec_price']);
1879
+ }
1880
+
1881
+ $products[] = $productFinal;
1882
+ }
1883
+
1884
+ return array('products_count' => $products_count,
1885
+ 'products' => $products);
1886
+ }
1887
+
1888
+ protected function search_products_ordered() {
1889
+
1890
+ $ordered_products = array();
1891
+ $max_date = "";
1892
+ $min_date = "";
1893
+ $offset = $this->_get_timezone_offset();
1894
+ // $storeId = Mage::app()->getStore()->getId();
1895
+ $salesCollection = Mage::getModel("sales/order_item")->getCollection()
1896
+ ->addFieldToSelect(array('product_id', 'name', 'sku'));
1897
+
1898
+ $salesCollection->getSelect()->columns(array('main_id' => new Zend_Db_Expr ('main_table.order_id')));
1899
+ $salesCollection->getSelect()->columns(array('price' => new Zend_Db_Expr ('main_table.base_row_total_incl_tax')));
1900
+ $salesCollection->getSelect()->columns(array('orig_price' => new Zend_Db_Expr ('main_table.original_price*main_table.qty_ordered')));
1901
+ $salesCollection->getSelect()->columns(array('quantity' => new Zend_Db_Expr ('main_table.qty_ordered')));
1902
+ $salesCollection->getSelect()->columns(array('type_id' => new Zend_Db_Expr ('main_table.product_type')));
1903
+
1904
+ $orderItemTableName = Mage::getSingleton('core/resource')->getTableName('sales/order_item');
1905
+ $orderTableName = Mage::getSingleton('core/resource')->getTableName('sales/order');
1906
+ $storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
1907
+
1908
+ $salesCollection->getSelect()
1909
+ ->joinLeft(
1910
+ array('order' => $orderTableName),
1911
+ "order.entity_id = main_table.order_id",
1912
+ array());
1913
+
1914
+ if (!empty($this->group_id)) {
1915
+ if($this->is_group_exists($this->group_id)) {
1916
+ $salesCollection->getSelect()
1917
+ ->joinLeft(
1918
+ array('cs' => $storeTableName),
1919
+ "cs.store_id = order.store_id",
1920
+ array());
1921
+ $salesCollection->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
1922
+ }
1923
+ }
1924
+
1925
+ $salesCollection->getSelect()->columns(array('iso_code' => new Zend_Db_Expr ('order.global_currency_code')));
1926
+ $salesCollection->getSelect()->columns(array('status' => new Zend_Db_Expr ('order.status')));
1927
+ $salesCollection->getSelect()->columns(array('created_at' => new Zend_Db_Expr ("CONVERT_TZ(order.created_at, '+00:00', '".$offset."' )")));
1928
+
1929
+ if(strlen($this->val) > 0) {
1930
+ $filter_cols = array();
1931
+ $filters = array();
1932
+ if(strlen($this->params) > 0) {
1933
+ $this->params = explode("|", $this->params);
1934
+ foreach($this->params as $param) {
1935
+ switch ($param) {
1936
+ case 'pr_id':
1937
+ $filter_cols[] = 'main_table'.'.product_id';
1938
+ $filters[] = array('eq' => $this->val);
1939
+ break;
1940
+ case 'pr_sku':
1941
+ $filter_cols[] = 'main_table'.'.sku';
1942
+ $filters[] = array('like' => '%'.$this->val.'%');
1943
+ break;
1944
+ case 'pr_name':
1945
+ $filter_cols[] = 'main_table'.'.name';
1946
+ $filters[] = array('like' => '%'.$this->val.'%');
1947
+ break;
1948
+ case 'order_id':
1949
+ $filter_cols[] = 'main_table'.'.order_id';
1950
+ $filters[] = array('eq' => $this->val);
1951
+ break;
1952
+ }
1953
+ }
1954
+ $salesCollection->addFieldToFilter($filter_cols, $filters);
1955
+ }
1956
+ }
1957
+
1958
+ if(!empty($this->products_from)) {
1959
+ $this->products_from .= " 00:00:00";
1960
+ $date_filter['from'] = $this->products_from;
1961
+ }
1962
+
1963
+ if(!empty($this->products_to)) {
1964
+ $this->products_to .= " 23:59:59";
1965
+ $date_filter['to'] = $this->products_to;
1966
+ }
1967
+
1968
+ $date_filter['date'] = true;
1969
+
1970
+
1971
+ if(!empty($this->products_from) || !empty($this->products_to)) {
1972
+ $salesCollection->addFieldToFilter('order'.'.created_at',
1973
+ $date_filter );
1974
+ }
1975
+
1976
+ if(!empty($this->statuses)) {
1977
+ $this->statuses = explode('|', $this->statuses);
1978
+ $salesCollection->addFieldToFilter('order'.'.status',
1979
+ array('in' => array($this->statuses)) );
1980
+ }
1981
+
1982
+ switch ($this->sort_by) {
1983
+ case 'name':
1984
+ $salesCollection->getSelect()->order( array('main_table'.'.name ASC'));
1985
+ break;
1986
+ case 'id':
1987
+ $salesCollection->getSelect()->order( array('main_table'.'.product_id DESC'));
1988
+ break;
1989
+ }
1990
+
1991
+ if(!empty($this->page) && !empty($this->show)) {
1992
+ $salesCollection->getSelect()->limit($this->show, ($this->page-1)*$this->show);
1993
+ }
1994
+
1995
+ $ordersDates = $salesCollection->getColumnValues('order'.'.created_at');
1996
+ $ordersDates = array_map("strtotime", $ordersDates);
1997
+
1998
+ if($salesCollection->count() > 0) {
1999
+ $max_date = date("n/j/Y", max(array_values($ordersDates)));
2000
+ $min_date = date("n/j/Y", min(array_values($ordersDates)));
2001
+ }
2002
+
2003
+ foreach ($salesCollection as $order) {
2004
+ $thumbnail = $order->getProduct()->getMediaConfig()->getMediaUrl($order->getProduct()->getThumbnail());
2005
+
2006
+ $ord_prodArr = $order->toArray();
2007
+
2008
+ $ord_prodArr['thumbnail'] = $thumbnail;
2009
+ $ord_prodArr['price'] = $this->_price_format($ord_prodArr['iso_code'], 1, $ord_prodArr['price'], $this->currency_code);
2010
+ if($ord_prodArr['orig_price'] > 0) {
2011
+ $ord_prodArr['orig_price'] = $this->_price_format($ord_prodArr['iso_code'], 1, $ord_prodArr['orig_price'], $this->currency_code);
2012
+ } else {
2013
+ unset($ord_prodArr['orig_price']);
2014
+ }
2015
+ $ord_prodArr['quantity'] = intval($ord_prodArr['quantity']);
2016
+ $ord_prodArr['order_id'] = $ord_prodArr['main_id'];
2017
+ $ord_prodArr['type_id'] = ucfirst($ord_prodArr['type_id']);
2018
+
2019
+
2020
+ $ordered_products[] = $ord_prodArr;
2021
+ }
2022
+
2023
+ return array(
2024
+ "products_count" => $salesCollection->getSize(),
2025
+ "products" => $ordered_products,
2026
+ "max_date" => $max_date,
2027
+ "min_date" => $min_date
2028
+ );
2029
+ }
2030
+
2031
+
2032
+ protected function get_products_info() {
2033
+ $flatHelper = Mage::helper('catalog/product_flat');
2034
+ if ($flatHelper->isEnabled()) {
2035
+ $emulationModel = Mage::getModel('core/app_emulation');
2036
+ $initialEnvironmentInfo = $emulationModel->startEnvironmentEmulation(0, Mage_Core_Model_App_Area::AREA_ADMINHTML);
2037
+ }
2038
+ $prods_attr_ids = $this->_get_products_attr();
2039
+ $row = null;
2040
+
2041
+ $products = array();
2042
+ $productsCollection = Mage::getModel('catalog/product')->getCollection();
2043
+ $productsCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
2044
+
2045
+ $productsCollection->getSelect()->columns(array('id_product' => new Zend_Db_Expr ('e.entity_id')));
2046
+ $productsCollection->getSelect()->columns(array('type_id' => new Zend_Db_Expr ('e.type_id')));
2047
+ $productsCollection->getSelect()->columns(array('name' => new Zend_Db_Expr ('name.value')));
2048
+ $productsCollection->getSelect()->columns(array('price' => new Zend_Db_Expr ('price.value')));
2049
+ $productsCollection->getSelect()->columns(array('spec_price' => new Zend_Db_Expr ('sp_price.value')));
2050
+ $productsCollection->getSelect()->columns(array('quantity' => new Zend_Db_Expr ('qty.qty')));
2051
+ $productsCollection->getSelect()->columns(array('sku' => new Zend_Db_Expr ('e.sku')));
2052
+ $productsCollection->getSelect()->columns(array('active' => new Zend_Db_Expr ("IF(status.value = 1, 'Enabled', 'Disabled')")));
2053
+
2054
+ $productsCollection->getSelect()->columns(array('total_ordered' => new Zend_Db_Expr ("(SELECT SUM(qty_ordered) FROM ".Mage::getConfig()->getTablePrefix()."sales_flat_order_item WHERE product_id = e.entity_id)")));
2055
+ $productsCollection->getSelect()->columns(array('image' => new Zend_Db_Expr ("(SELECT value FROM ".Mage::getConfig()->getTablePrefix()."catalog_product_entity_media_gallery WHERE entity_id = e.entity_id ORDER BY value_id LIMIT 1)")));
2056
+
2057
+
2058
+ $productsCollection->getSelect()->joinLeft(array('name' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_varchar'),
2059
+ 'e.entity_id = name.entity_id AND name.attribute_id = "'.$prods_attr_ids['name'].'"',
2060
+ array(''));
2061
+
2062
+ $productsCollection->getSelect()->joinLeft(array('price' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_decimal'),
2063
+ 'e.entity_id = price.entity_id AND price.attribute_id = "'.$prods_attr_ids['price'].'"',
2064
+ array('value'));
2065
+
2066
+ $productsCollection->getSelect()->joinLeft(array('sp_price' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_decimal'),
2067
+ 'e.entity_id = sp_price.entity_id AND sp_price.attribute_id = "'.$prods_attr_ids['special_price'].'"',
2068
+ array('value'));
2069
+
2070
+ $productsCollection->getSelect()->joinLeft(array('qty' => Mage::getConfig()->getTablePrefix().'cataloginventory_stock_item'),
2071
+ 'e.entity_id = qty.product_id',
2072
+ array('qty'));
2073
+
2074
+ $productsCollection->getSelect()->joinLeft(array('descr' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_varchar'),
2075
+ 'e.entity_id = descr.entity_id AND descr.attribute_id = "'.$prods_attr_ids['description'].'"',
2076
+ array('value'));
2077
+
2078
+ $productsCollection->getSelect()->joinLeft(array('short_desc' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_text'),
2079
+ 'e.entity_id = short_desc.entity_id AND short_desc.attribute_id = "'.$prods_attr_ids['short_description'].'"',
2080
+ array('value'));
2081
+
2082
+ $productsCollection->getSelect()->joinLeft(array('status' => Mage::getConfig()->getTablePrefix().'catalog_product_entity_int'),
2083
+ 'e.entity_id = status.entity_id AND status.attribute_id = "'.$prods_attr_ids['status'].'"',
2084
+ array('value'));
2085
+
2086
+ $productsCollection->addFieldToFilter('entity_id', array(
2087
+ 'eq' => $this->product_id,
2088
+ ));
2089
+
2090
+ if($productsCollection->getSize() > 0) {
2091
+ // echo($productsCollection->getSelect()->__toString());die();
2092
+ foreach ($productsCollection as $product) {
2093
+ $row = $product->toArray();
2094
+ unset($row['stock_item']);
2095
+ unset($row['value']);
2096
+ unset($row['qty']);
2097
+
2098
+ $row['id_image'] = (string)Mage::helper('catalog/image')->init($product, 'image')->resize(256);
2099
+ $row['id_image_large'] = (string)Mage::helper('catalog/image')->init($product, 'image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(800);
2100
+
2101
+ $row['type_id'] = ucfirst($row['type_id']);
2102
+ $row['price'] = $this->_price_format($this->def_currency, 1, $row['price'], $this->currency_code);
2103
+ if($row['spec_price'] > 0 && $row['spec_price'] != '') {
2104
+ $row['spec_price'] = $this->_price_format($this->def_currency, 1, $row['spec_price'], $this->currency_code);
2105
+ } else {
2106
+ unset($row['spec_price']);
2107
+ }
2108
+ $row['quantity'] = intval($row['quantity']);
2109
+ $row['total_ordered'] = intval($row['total_ordered']);
2110
+
2111
+ }
2112
+
2113
+ return $row;
2114
+ }
2115
+
2116
+ return false;
2117
+ }
2118
+
2119
+ protected function _get_products_attr() {
2120
+ $products_attrs = array();
2121
+ $productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
2122
+ foreach ($productAttrs as $productAttr) {
2123
+ $attr_code = $productAttr->getAttributeCode();
2124
+ if(in_array($attr_code, array('name', 'price', 'special_price', 'description', 'short_description', 'status'))){
2125
+ $products_attrs[$attr_code] = $productAttr->getId();
2126
+ }
2127
+ }
2128
+
2129
+ return $products_attrs;
2130
+ }
2131
+
2132
+ protected function get_products_descr() {
2133
+ $product = Mage::getModel('catalog/product')->load($this->product_id);
2134
+
2135
+ return array('descr' => $product->getDescription(), 'short_descr' => $product->getShortDescription());
2136
+ }
2137
+
2138
+ protected function isEnabledFlat() {
2139
+ if (Mage::app()->getStore()->isAdmin()) {
2140
+ return false;
2141
+ }
2142
+ if (!isset($this->_flatEnabled[$this->getStoreId()])) {
2143
+ $this->_flatEnabled[$this->getStoreId()] = $this->getFlatHelper()
2144
+ ->isEnabled($this->getStoreId());
2145
+ }
2146
+ return $this->_flatEnabled[$this->getStoreId()];
2147
+ }
2148
+
2149
+
2150
+ protected function _price_format($iso_code, $curr_format, $price, $convert_to, $force = false, $format = true) {
2151
+ $currency_symbol = '';
2152
+ $price = str_replace(' ', '', $price);
2153
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
2154
+
2155
+ if(strlen($convert_to) == 3){
2156
+ try {
2157
+ $price = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $convert_to);
2158
+ $iso_code = $convert_to;
2159
+ } catch(Exception $e) {
2160
+ Mage::log(
2161
+ "Error while currency converting (". var_export($e->getMessage(), true). ")",
2162
+ null,
2163
+ 'emagicone_mobassistantconnector.log'
2164
+ );
2165
+ }
2166
+
2167
+ }
2168
+
2169
+ if($format) {
2170
+ $price = number_format(floatval($price), 2, '.', ' ');
2171
+ }
2172
+
2173
+ preg_match('/^[a-zA-Z]+$/', $iso_code, $matches);
2174
+
2175
+ if(count($matches) > 0) {
2176
+ if(strlen($matches[0]) == 3) {
2177
+ $currency_symbol = Mage::app()->getLocale()->currency($iso_code)->getSymbol();
2178
+ }
2179
+ } else {
2180
+ $currency_symbol = $iso_code;
2181
+ }
2182
+
2183
+ if($force) {
2184
+ return $currency_symbol;
2185
+ }
2186
+ $sign = '<span>' . $currency_symbol . '</span>';
2187
+ if($curr_format == 1) {
2188
+ $price = $sign . $price;
2189
+ } elseif ($curr_format == 2) {
2190
+ $price = $price;
2191
+ } elseif ($curr_format == 3) {
2192
+ $price = $currency_symbol . $price;
2193
+ } else {
2194
+ $price = $price . ' ' . $sign;
2195
+ }
2196
+
2197
+ return $price;
2198
+ }
2199
+
2200
+
2201
+ protected function _get_default_currency() {
2202
+ $symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getBaseCurrencyCode())->getSymbol();
2203
+ $currency = Mage::app()->getStore()->getBaseCurrencyCode();
2204
+ return array('currency' => $currency, 'symbol' => $symbol);
2205
+ }
2206
+
2207
+ protected function _get_store_currencies($storeId) {
2208
+ $CurrencyCode = Mage::getModel('core/config_data')
2209
+ ->getCollection()
2210
+ ->addFieldToFilter('path','currency/options/allow')
2211
+ ->addFieldToFilter('scope_id',$storeId)
2212
+ ->getData();
2213
+ $currencies_array = explode(',',$CurrencyCode[0]['value']);
2214
+ if($currencies_array[0] == '')
2215
+ {
2216
+ $currencies_array[]= Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
2217
+ }
2218
+
2219
+ foreach ($currencies_array as $curCode) {
2220
+ $currencySymbol = Mage::app()->getLocale()->currency( $curCode )->getSymbol();
2221
+ $currencyName = Mage::app()->getLocale()->currency( $curCode )->getName();
2222
+ $currencies[] = array('code' => $curCode, 'symbol' => (is_null($currencySymbol) ? $curCode : $currencySymbol), 'name' => $currencyName);
2223
+ }
2224
+
2225
+ return $currencies;
2226
+ }
2227
+
2228
+ protected function _get_timezone_offset() {
2229
+ $timezone = Mage::app()->getStore()->getConfig('general/locale/timezone');
2230
+
2231
+
2232
+ //
2233
+ // $timeoffset = Mage::getModel('core/date')->calculateOffset($timezone);
2234
+ // $hours = intval($timeoffset / 60 / 60);
2235
+ // $mins = $timeoffset / 60 % 60;
2236
+ // $offset2 = (($hours >= 0) ? '+'.$hours : $hours) .':'. $mins;
2237
+
2238
+
2239
+
2240
+ $origin_dtz = new DateTimeZone("UTC");
2241
+ $remote_dtz = new DateTimeZone($timezone);
2242
+ $origin_dt = new DateTime("now", $origin_dtz);
2243
+ $remote_dt = new DateTime("now", $remote_dtz);
2244
+ $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt);
2245
+
2246
+ $hours = intval($offset / 60 / 60);
2247
+ $mins = $offset / 60 % 60;
2248
+ $offset = (($hours >= 0) ? '+'.$hours : $hours) .':'. $mins;
2249
+ //
2250
+ // $offset = $offset / 60 / 60;
2251
+
2252
+ return $offset;
2253
+ }
2254
+
2255
+
2256
+ protected function reset_null(&$item) {
2257
+ if(empty($item) && $item != 0) {
2258
+ $item = '';
2259
+ }
2260
+ $item = trim($item);
2261
+ }
2262
+
2263
+
2264
+ protected function validate_types(&$array, $names) {
2265
+ foreach ($names as $name => $type) {
2266
+ if (isset($array["$name"])) {
2267
+ switch ($type) {
2268
+ case 'INT':
2269
+ $array["$name"] = intval($array["$name"]);
2270
+ break;
2271
+ case 'FLOAT':
2272
+ $array["$name"] = floatval($array["$name"]);
2273
+ break;
2274
+ case 'STR':
2275
+ $array["$name"] = str_replace(array("\r", "\n"), ' ', addslashes(htmlspecialchars(trim(urldecode($array["$name"])))));
2276
+ break;
2277
+ case 'STR_HTML':
2278
+ $array["$name"] = addslashes(trim($array["$name"]));
2279
+ break;
2280
+ default:
2281
+ $array["$name"] = '';
2282
+ }
2283
+ } else {
2284
+ $array["$name"] = '';
2285
+ }
2286
+ }
2287
+
2288
+ foreach ($array as $key => $value) {
2289
+ if (!isset($names[$key]) && $key != "call_function" && $key != "hash") {
2290
+ $array[$key] = "";
2291
+ }
2292
+ }
2293
+
2294
+ return $array;
2295
+ }
2296
+
2297
+
2298
+ protected function get_custom_period($period = 0) {
2299
+ $custom_period = array('start_date' => "", 'end_date' => "");
2300
+ $format = "m/d/Y";
2301
+
2302
+ switch($period) {
2303
+ case 0: //3 days
2304
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date("m"), date("d")-2, date("Y")));
2305
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date("m"), date("d"), date("Y")));
2306
+ break;
2307
+
2308
+ case 1: //7 days
2309
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date("m"), date("d")-6, date("Y")));
2310
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date("m"), date("d"), date("Y")));
2311
+ break;
2312
+
2313
+ case 2: //Prev week
2314
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date("n"), date("j")-6, date("Y")) - ((date("N"))*3600*24));
2315
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date("n"), date("j"), date("Y")) - ((date("N"))*3600*24));
2316
+ break;
2317
+
2318
+ case 3: //Prev month
2319
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date("m")-1, 1, date("Y")));
2320
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date("m"), date("d")-date("j"), date("Y")));
2321
+ break;
2322
+
2323
+ case 4: //This quarter
2324
+ $m = date("n");
2325
+ $start_m = 1;
2326
+ $end_m = 3;
2327
+
2328
+ if($m <= 3) {
2329
+ $start_m = 1;
2330
+ $end_m = 3;
2331
+ } else if($m >= 4 && $m <= 6) {
2332
+ $start_m = 4;
2333
+ $end_m = 6;
2334
+ } else if($m >= 7 && $m <= 9) {
2335
+ $start_m = 7;
2336
+ $end_m = 9;
2337
+ } else if($m >= 10) {
2338
+ $start_m = 10;
2339
+ $end_m = 12;
2340
+ }
2341
+
2342
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, $start_m, 1 , date("Y")));
2343
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, $end_m+1, date(1)-1, date("Y")));
2344
+ break;
2345
+
2346
+ case 5: //This year
2347
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date(1), date(1), date("Y")));
2348
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date(1), date(1)-1, date("Y")+1));
2349
+ break;
2350
+
2351
+ case 7: //Last year
2352
+ $custom_period['start_date'] = date($format, mktime(0, 0, 0, date(1), date(1), date("Y")-1));
2353
+ $custom_period['end_date'] = date($format, mktime(23, 59, 59, date(1), date(1)-1, date("Y")));
2354
+ break;
2355
+ }
2356
+
2357
+ return $custom_period;
2358
+ }
2359
+
2360
+
2361
+ protected function bd_nice_number($n, $is_count = false) {
2362
+ $n = floatval($n);
2363
+
2364
+ if(!is_numeric($n)) return $n;
2365
+
2366
+ $final_number = $n;
2367
+ $number_suf = "";
2368
+ // now filter it;
2369
+ if($n > 1000000000000000) {
2370
+ //return number_format(round(($n / 1000000000000000), 1), 1, '.', ' ') . 'P';
2371
+ $final_number = round(($n / 1000000000000000), 2);
2372
+ $number_suf = "P";
2373
+
2374
+ } else if($n > 1000000000000) {
2375
+ //return number_format(round(($n / 1000000000000),1), 1, '.', ' ') . 'T';
2376
+ $final_number = round(($n / 1000000000000), 2);
2377
+ $number_suf = "T";
2378
+
2379
+ } else if($n > 1000000000) {
2380
+ //return number_format(round(($n / 1000000000),1), 1, '.', ' ') . 'G';
2381
+ $final_number = round(($n / 1000000000), 2);
2382
+ $number_suf = "G";
2383
+
2384
+ } else if($n > 1000000) {
2385
+ //return number_format(round(($n / 1000000),1), 1, '.', ' ') . 'M';
2386
+ $final_number = round(($n / 1000000), 2);
2387
+ $number_suf = "M";
2388
+
2389
+ } else if($n > 10000) {
2390
+ return number_format($n, 0, '', ' ');
2391
+ }
2392
+
2393
+ if($is_count) {
2394
+ $final_number = intval($final_number);
2395
+ } else {
2396
+ $final_number = number_format($final_number, 2, '.', ' ') . $number_suf;
2397
+ }
2398
+
2399
+ return $final_number;
2400
+ }
2401
+
2402
+ protected function split_values($arr, $keys, $sign = ', ') {
2403
+ $new_arr = array();
2404
+ foreach($keys as $key) {
2405
+ if(isset($arr[$key])) {
2406
+ if(!is_null($arr[$key]) && $arr[$key] != '') {
2407
+ $new_arr[] = $arr[$key];
2408
+ }
2409
+ }
2410
+ }
2411
+ return implode($sign, $new_arr);
2412
+ }
2413
+
2414
+ }
app/code/community/Emagicone/Mobassistantconnector/controllers/adminhtml/IndexController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of Mobile Assistant Connector.
4
+ *
5
+ * Mobile Assistant Connector is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * Mobile Assistant Connector is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with Mobile Assistant Connector. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ class Emagicone_Mobassistantconnector_IndexController extends Mage_Adminhtml_Controller_Action
20
+ {
21
+ public function indexAction()
22
+ {
23
+ $this->loadLayout();
24
+ $this->renderLayout();
25
+ }
26
+ }
app/code/community/Emagicone/Mobassistantconnector/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <mobassistantconnectorinfosec translate="title">
15
+ <title>An Example Section</title>
16
+ <sort_order>100</sort_order>
17
+ </mobassistantconnectorinfosec>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/community/Emagicone/Mobassistantconnector/etc/config.xml ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+
4
+ <default>
5
+ <mobassistantconnectorinfosec>
6
+ <emogeneral>
7
+ <status>0</status>
8
+ </emogeneral>
9
+ <emoaccess>
10
+ <login>1</login>
11
+ <password>c4ca4238a0b923820dcc509a6f75849b</password>
12
+ </emoaccess>
13
+ </mobassistantconnectorinfosec>
14
+ </default>
15
+
16
+ <modules>
17
+ <Emagicone_Mobassistantconnector>
18
+ <version>1.0.0</version>
19
+ </Emagicone_Mobassistantconnector>
20
+ </modules>
21
+ <frontend>
22
+ <routers>
23
+ <mobassistantconnector>
24
+ <use>standard</use>
25
+ <args>
26
+ <module>Emagicone_Mobassistantconnector</module>
27
+ <frontName>mobassistantconnector</frontName>
28
+ </args>
29
+ </mobassistantconnector>
30
+ </routers>
31
+ <translate>
32
+ <modules>
33
+ <translations>
34
+ <files>
35
+ <default>Emagicone_Mobassistantconnector.csv</default>
36
+ </files>
37
+ </translations>
38
+ </modules>
39
+ </translate>
40
+ </frontend>
41
+
42
+ <admin>
43
+ <routers>
44
+ <mobassistantconnectoradmin>
45
+ <use>admin</use>
46
+ <args>
47
+ <module>Emagicone_Mobassistantconnector</module>
48
+ <frontName>mobassistantconnector</frontName>
49
+ </args>
50
+ </mobassistantconnectoradmin>
51
+ </routers>
52
+ </admin>
53
+
54
+ <global>
55
+ <helpers>
56
+ <mobassistantconnector>
57
+ <class>Emagicone_Mobassistantconnector_Helper</class>
58
+ </mobassistantconnector>
59
+ </helpers>
60
+
61
+ <models>
62
+ <sales>
63
+ <rewrite>
64
+ <order>Emagicone_Mobassistantconnector_Model_Order</order>
65
+ </rewrite>
66
+ </sales>
67
+ <emagiconemobassistantconnector>
68
+ <class>Emagicone_Mobassistantconnector_Model</class>
69
+ </emagiconemobassistantconnector>
70
+ </models>
71
+
72
+ <events>
73
+ <sales_order_save_after>
74
+ <observers>
75
+ <emagicone_mobassistantconnector_order_change>
76
+ <type>singleton</type>
77
+ <class>Emagicone_Mobassistantconnector_Model_Observer</class>
78
+ <method>checkOrder</method>
79
+ </emagicone_mobassistantconnector_order_change>
80
+ </observers>
81
+ </sales_order_save_after>
82
+ <customer_register_success>
83
+ <observers>
84
+ <emagicone_mobassistantconnector_customer_register_success>
85
+ <type>model</type>
86
+ <class>Emagicone_Mobassistantconnector_Model_Observer</class>
87
+ <method>customerRegisterSuccess</method>
88
+ </emagicone_mobassistantconnector_customer_register_success>
89
+ </observers>
90
+ </customer_register_success>
91
+ </events>
92
+ <layout>
93
+ <updates>
94
+ <emagicone_mobassistantconnector>
95
+ <file>emagicone_mobassistantconnector.xml</file>
96
+ </emagicone_mobassistantconnector>
97
+ </updates>
98
+ </layout>
99
+ </global>
100
+
101
+ <adminhtml>
102
+ <translate>
103
+ <modules>
104
+ <translations>
105
+ <files>
106
+ <default>Emagicone_mobassistantconnector.csv</default>
107
+ </files>
108
+ </translations>
109
+ </modules>
110
+ </translate>
111
+ <layout>
112
+ <updates>
113
+ <mobassistantconnector>
114
+ <file>mobassistantconnector.xml</file>
115
+ </mobassistantconnector>
116
+ </updates>
117
+ </layout>
118
+ </adminhtml>
119
+
120
+ </config>
app/code/community/Emagicone/Mobassistantconnector/etc/system.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <mobassistantconnectorinfo translate="label">
5
+ <label>eMagicOne</label>
6
+ <sort_order>100</sort_order>
7
+ </mobassistantconnectorinfo>
8
+ </tabs>
9
+ <sections>
10
+ <mobassistantconnectorinfosec translate="label">
11
+ <label>Mobile Assistant Connector</label>
12
+ <tab>mobassistantconnectorinfo</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <emogeneral translate="label comment">
20
+ <label>General Settings</label>
21
+ <sort_order>10</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <status translate="label comment">
27
+ <label>Enabled</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>
30
+ adminhtml/system_config_source_enabledisable
31
+ </source_model>
32
+ <sort_order>10</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </status>
37
+ </fields>
38
+ </emogeneral>
39
+ <emoaccess translate="label">
40
+ <label>Access Settings</label>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <fields>
46
+ <login translate="label comment">
47
+ <label>Login</label>
48
+ <frontend_type>text</frontend_type>
49
+ <backend_model>emagiconemobassistantconnector/login</backend_model>
50
+ <sort_order>10</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment><![CDATA[Login for accessing Mobile Assistant Connector from Your mobile application.]]></comment>
55
+ </login>
56
+ <password translate="label comment">
57
+ <label>Password</label>
58
+ <frontend_type>password</frontend_type>
59
+ <source_model>emagiconemobassistantconnector/defpassword</source_model>
60
+ <backend_model>emagiconemobassistantconnector/password</backend_model>
61
+ <sort_order>20</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <comment><![CDATA[Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.]]></comment>
66
+ </password>
67
+ </fields>
68
+ </emoaccess>
69
+ <emoqr translate="label comment">
70
+ <expanded>1</expanded>
71
+ <label>QR Code</label>
72
+ <sort_order>30</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </emoqr>
77
+ </groups>
78
+ </mobassistantconnectorinfosec>
79
+ </sections>
80
+ </config>
app/design/adminhtml/default/default/layout/mobassistantconnector.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="content">
5
+ <block type="core/template" name="mobassistantconnector" template="mobassistantconnector/jsinit.phtml"></block>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+ </layout>
app/design/adminhtml/default/default/template/mobassistantconnector/jsinit.phtml ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $password = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/password');
3
+ $login = Mage::getStoreConfig('mobassistantconnectorinfosec/emoaccess/login');
4
+ $store_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
5
+ $store_url = str_replace('http://', '', $store_url);
6
+ $store_url = str_replace('https://', '', $store_url);
7
+ preg_replace('/\/*$/i', '', $store_url);
8
+ $array['url'] = $store_url;
9
+ $array['login'] = $login;
10
+ $array['password'] = $password;
11
+ $store_url = base64_encode(json_encode($array));
12
+ $qr_url = "https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl=" . $store_url . "&choe=UTF-8";
13
+ ?>
14
+
15
+ <script type="text/javascript">
16
+ var password = "";
17
+ var login = "";
18
+ var password_changed = "";
19
+ var login_changed = "";
20
+
21
+ window.onload = function ()
22
+ {
23
+ var elem_div0 = document.createElement("div");
24
+ var elem = document.createElement("img");
25
+ var elem_div_main = document.createElement("div");
26
+ var elem_p = document.createElement("p");
27
+ var elem_p_span = document.createElement("span");
28
+ var mobassistantconnectorinfosec_emoaccess_password = document.getElementById('mobassistantconnectorinfosec_emoaccess_password');
29
+ var mobassistantconnectorinfosec_emoaccess_login = document.getElementById('mobassistantconnectorinfosec_emoaccess_login');
30
+ var mobassistantconnectorinfosec_emoqr = document.getElementById("mobassistantconnectorinfosec_emoqr");
31
+
32
+
33
+ window.password = mobassistantconnectorinfosec_emoaccess_password.value;
34
+ window.login = mobassistantconnectorinfosec_emoaccess_login.value;
35
+
36
+ mobassistantconnectorinfosec_emoaccess_password.setAttribute("onkeyup" , "changeQRCode()");
37
+ mobassistantconnectorinfosec_emoaccess_login.setAttribute("onkeyup" , "changeQRCode()");
38
+
39
+ elem_div0.setAttribute("id", "mobassistantconnectorinfosec_div0");
40
+ mobassistantconnectorinfosec_emoqr.appendChild(elem_div0);
41
+ var mobassistantconnectorinfosec_div0 = document.getElementById("mobassistantconnectorinfosec_div0");
42
+ mobassistantconnectorinfosec_div0.style.position="relative";
43
+ mobassistantconnectorinfosec_div0.style.width="300px";
44
+ mobassistantconnectorinfosec_div0.style.height="300px";
45
+ mobassistantconnectorinfosec_div0.style.zIndex="800";
46
+
47
+ elem.src = "<?php echo $qr_url; ?>";
48
+ elem.setAttribute("height", "300");
49
+ elem.setAttribute("width", "300");
50
+ elem.setAttribute("alt", "QR Code");
51
+ elem.setAttribute("id", "mobassistantconnectorinfosec_qr_code");
52
+ mobassistantconnectorinfosec_div0.appendChild(elem);
53
+
54
+ elem_div_main.setAttribute("class", "form-list");
55
+ elem_div_main.setAttribute("id", "mobassistantconnectorinfosec_div_main");
56
+ mobassistantconnectorinfosec_emoqr.appendChild(elem_div_main);
57
+ var mobassistantconnectorinfosec_div_main = document.getElementById("mobassistantconnectorinfosec_div_main");
58
+
59
+ elem_p.setAttribute("id", "mobassistantconnectorinfosec_qr_p_note");
60
+ elem_p.setAttribute("class", "note");
61
+ mobassistantconnectorinfosec_div_main.appendChild(elem_p);
62
+ mobassistantconnectorinfosec_div_main.style.paddingLeft="25px";
63
+ mobassistantconnectorinfosec_div_main.style.marginTop="-5px";
64
+
65
+ elem_p_span.setAttribute("id", "mobassistantconnectorinfosec_qr_p_span_note");
66
+ document.getElementById("mobassistantconnectorinfosec_qr_p_note").appendChild(elem_p_span);
67
+
68
+ document.getElementById("mobassistantconnectorinfosec_qr_p_span_note").innerHTML = 'Store URL and access details (login and password) for Mobile Assistant Connector are encoded in this QR code. Scan it with special option available on connection settings page of Magento Mobile Assistant to autofill acess settings and connect to your Magento store.';
69
+ }
70
+
71
+ function changeQRCode() {
72
+ var elem_div_change = document.createElement("div");
73
+ var mobassistantconnectorinfosec_qr_code = document.getElementById('mobassistantconnectorinfosec_qr_code');
74
+ var mobassistantconnectorinfosec_elem_div_change = document.getElementById('mobassistantconnectorinfosec_elem_div_change');
75
+ window.password_changed = document.getElementById('mobassistantconnectorinfosec_emoaccess_password').value;
76
+ window.login_changed = document.getElementById('mobassistantconnectorinfosec_emoaccess_login').value;
77
+
78
+ if (window.password == password_changed && window.login == login_changed) {
79
+ mobassistantconnectorinfosec_qr_code.style.opacity = "1";
80
+ mobassistantconnectorinfosec_elem_div_change.style.display = "none";
81
+ } else {
82
+ if (mobassistantconnectorinfosec_elem_div_change) {
83
+ mobassistantconnectorinfosec_qr_code.style.opacity = "0.1";
84
+ mobassistantconnectorinfosec_elem_div_change.style.display = "block";
85
+ } else {
86
+ mobassistantconnectorinfosec_qr_code.style.opacity = "0.1";
87
+
88
+ elem_div_change.setAttribute("id", "mobassistantconnectorinfosec_elem_div_change");
89
+ document.getElementById("mobassistantconnectorinfosec_div0").appendChild(elem_div_change);
90
+ var mobassistantconnectorinfosec_elem_div_change = document.getElementById('mobassistantconnectorinfosec_elem_div_change');
91
+ mobassistantconnectorinfosec_elem_div_change.innerHTML = "Login details have been changed. Save changes for code to be regenerated";
92
+ mobassistantconnectorinfosec_elem_div_change.style.position="absolute";
93
+ mobassistantconnectorinfosec_elem_div_change.style.width="150px";
94
+ mobassistantconnectorinfosec_elem_div_change.style.top="36%";
95
+ mobassistantconnectorinfosec_elem_div_change.style.zIndex="1000";
96
+ mobassistantconnectorinfosec_elem_div_change.style.left="25%";
97
+ mobassistantconnectorinfosec_elem_div_change.style.color="red";
98
+ mobassistantconnectorinfosec_elem_div_change.style.textAlign="center";
99
+ mobassistantconnectorinfosec_elem_div_change.style.fontWeight="bold";
100
+ mobassistantconnectorinfosec_elem_div_change.style.textShadow="0 0 1px #fff";
101
+ mobassistantconnectorinfosec_elem_div_change.style.display = "block";
102
+ }
103
+ }
104
+ }
105
+ </script>
app/etc/modules/Emagicone_Mobassistantconnector.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Emagicone_Mobassistantconnector>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Emagicone_Mobassistantconnector>
8
+ </modules>
9
+ </config>
app/locale/en_GB/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","General Settings"
3
+ "Access Settings","Access Settings"
4
+ "Login","Login"
5
+ "Password","Password"
6
+ "Enabled","Enabled"
7
+ "URL in Your mobile application should looks like:","URL in Your mobile application should looks like:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Login for accessing Mobile Assistant Connector from Your mobile application."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one."
10
+ "Default password is '1'. Please change it becouse of security reasons","Default password is '1'. Please change it becouse of security reasons"
11
+ "Login field cannot be empty. Please specify Login.","Login field cannot be empty. Please specify Login."
12
+ "Password field cannot be empty. Please specify password.","Password field cannot be empty. Please specify password."
13
+ "Cannot get configuration value","Cannot get configuration value"
14
+ "Registration ID cannot be empty","Registration ID cannot be empty"
15
+ "An error occurred!","An error occurred!"
16
+ "Cannot create an invoice without products!","Cannot create an invoice without products!"
17
+ "Cannot create an invoice!","Cannot create an invoice!"
18
+ "Empty tracking number!","Empty tracking number!"
19
+ "Current order cannot be shipped!","Current order cannot be shipped!"
20
+ "Current order cannot be canceled!","Current order cannot be canceled!"
21
+ "Current order cannot be holded!","Current order cannot be holded!"
22
+ "Current order cannot be unholded!","Current order cannot be unholded!"
23
+ "Current tracking number was not found","Current tracking number was not found"
24
+ "Current order does not have shipments!","Current order does not have shipments!"
25
+ "No order was found!","No order was found!"
26
+ "Action is not set!","Action is not set!"
27
+ "Order id cannot be empty!","Order id cannot be empty!"
app/locale/en_GB/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","General Settings"
3
+ "Access Settings","Access Settings"
4
+ "Login","Login"
5
+ "Password","Password"
6
+ "Enabled","Enabled"
7
+ "URL in Your mobile application should looks like:","URL in Your mobile application should looks like:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Login for accessing Mobile Assistant Connector from Your mobile application."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one."
10
+ "Default password is '1'. Please change it becouse of security reasons","Default password is '1'. Please change it becouse of security reasons"
11
+ "Login field cannot be empty. Please specify Login.","Login field cannot be empty. Please specify Login."
12
+ "Password field cannot be empty. Please specify password.","Password field cannot be empty. Please specify password."
13
+ "Cannot get configuration value","Cannot get configuration value"
14
+ "Registration ID cannot be empty","Registration ID cannot be empty"
15
+ "An error occurred!","An error occurred!"
16
+ "Cannot create an invoice without products!","Cannot create an invoice without products!"
17
+ "Cannot create an invoice!","Cannot create an invoice!"
18
+ "Empty tracking number!","Empty tracking number!"
19
+ "Current order cannot be shipped!","Current order cannot be shipped!"
20
+ "Current order cannot be canceled!","Current order cannot be canceled!"
21
+ "Current order cannot be holded!","Current order cannot be holded!"
22
+ "Current order cannot be unholded!","Current order cannot be unholded!"
23
+ "Current tracking number was not found","Current tracking number was not found"
24
+ "Current order does not have shipments!","Current order does not have shipments!"
25
+ "No order was found!","No order was found!"
26
+ "Action is not set!","Action is not set!"
27
+ "Order id cannot be empty!","Order id cannot be empty!"
app/locale/en_US/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","General Settings"
3
+ "Access Settings","Access Settings"
4
+ "Login","Login"
5
+ "Password","Password"
6
+ "Enabled","Enabled"
7
+ "URL in Your mobile application should looks like:","URL in Your mobile application should looks like:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Login for accessing Mobile Assistant Connector from Your mobile application."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one."
10
+ "Default password is '1'. Please change it becouse of security reasons","Default password is '1'. Please change it becouse of security reasons"
11
+ "Login field cannot be empty. Please specify Login.","Login field cannot be empty. Please specify Login."
12
+ "Password field cannot be empty. Please specify password.","Password field cannot be empty. Please specify password."
13
+ "Cannot get configuration value","Cannot get configuration value"
14
+ "Registration ID cannot be empty","Registration ID cannot be empty"
15
+ "An error occurred!","An error occurred!"
16
+ "Cannot create an invoice without products!","Cannot create an invoice without products!"
17
+ "Cannot create an invoice!","Cannot create an invoice!"
18
+ "Empty tracking number!","Empty tracking numbers!"
19
+ "Current order cannot be shipped!","Current order cannot be shipped!"
20
+ "Current order cannot be canceled!","Current order cannot be canceled!"
21
+ "Current order cannot be holded!","Current order cannot be holded!"
22
+ "Current order cannot be unholded!","Current order cannot be unholded!"
23
+ "Current tracking number was not found","Current tracking number was not found"
24
+ "Current order does not have shipments!","Current order does not have shipments!"
25
+ "No order was found!","No order was found!"
26
+ "Action is not set!","Action is not set!"
27
+ "Order id cannot be empty!","Order id cannot be empty!"
app/locale/en_US/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","General Settings"
3
+ "Access Settings","Access Settings"
4
+ "Login","Login"
5
+ "Password","Password"
6
+ "Enabled","Enabled"
7
+ "URL in Your mobile application should looks like:","URL in Your mobile application should looks like:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Login for accessing Mobile Assistant Connector from Your mobile application."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one."
10
+ "Default password is '1'. Please change it becouse of security reasons","Default password is '1'. Please change it becouse of security reasons"
11
+ "Login field cannot be empty. Please specify Login.","Login field cannot be empty. Please specify Login."
12
+ "Password field cannot be empty. Please specify password.","Password field cannot be empty. Please specify password."
13
+ "Cannot get configuration value","Cannot get configuration value"
14
+ "Registration ID cannot be empty","Registration ID cannot be empty"
15
+ "An error occurred!","An error occurred!"
16
+ "Cannot create an invoice without products!","Cannot create an invoice without products!"
17
+ "Cannot create an invoice!","Cannot create an invoice!"
18
+ "Empty tracking number!","Empty tracking numbers!"
19
+ "Current order cannot be shipped!","Current order cannot be shipped!"
20
+ "Current order cannot be canceled!","Current order cannot be canceled!"
21
+ "Current order cannot be holded!","Current order cannot be holded!"
22
+ "Current order cannot be unholded!","Current order cannot be unholded!"
23
+ "Current tracking number was not found","Current tracking number was not found"
24
+ "Current order does not have shipments!","Current order does not have shipments!"
25
+ "No order was found!","No order was found!"
26
+ "Action is not set!","Action is not set!"
27
+ "Order id cannot be empty!","Order id cannot be empty!"
app/locale/es_ES/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Configuración general"
3
+ "Access Settings","Configuración del acceso"
4
+ "Login","Usuario"
5
+ "Password","Contraseña"
6
+ "Enabled","Activada"
7
+ "URL in Your mobile application should looks like:","URL en Su aplicación móvil debe ser:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Nombre de usuario para acceder a Mobile Assistant Сonector desde su aplicación móvil."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Сontraseña para acceder a Mobile Assistant Сonector desde su aplicación móvil. La contraseña predeterminada es "1". Crea una nueva contraseña."
10
+ "Default password is '1'. Please change it becouse of security reasons","La contraseña predeterminada es "1". Por razones de seguridad, se aconseja cambiar la contraseña."
11
+ "Login field cannot be empty. Please specify Login.","El campo nombre de usuario no puede estar vacío. Por favor, teclee el nombre de usuario."
12
+ "Password field cannot be empty. Please specify password.","El campo contraseña no puede estar vacío. Por favor, teclee la contraseña."
13
+ "Cannot get configuration value","No se puede obtener el valor de configuración"
14
+ "Registration ID cannot be empty","ID de registro no puede estar vacío"
15
+ "An error occurred!","Ha ocurrido un error!"
16
+ "Cannot create an invoice without products!","No puede crear una factura sin productos!"
17
+ "Cannot create an invoice!","No puede crear una factura!"
18
+ "Empty tracking number!","El número de seguimiento está vacío!"
19
+ "Current order cannot be shipped!","El pedido actual no puede ser enviado"
20
+ "Current order cannot be canceled!","El pedido actual no puede ser cancelado!"
21
+ "Current order cannot be holded!","El pedido actual no puede ser en suspenso!"
22
+ "Current order cannot be unholded!","El pedido actual no puede ser reasumido!"
23
+ "Current tracking number was not found","Número de seguimiento no puede ser encontrado"
24
+ "Current order does not have shipments!","Este pedido no tiene ningún envío"
25
+ "No order was found!","No se ha encontrado ningún pedido"
26
+ "Action is not set!","La accion no está definida"
27
+ "Order id cannot be empty!","ID de pedido no puede estar vacío"
app/locale/es_ES/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Configuración general"
3
+ "Access Settings","Configuración del acceso"
4
+ "Login","Usuario"
5
+ "Password","Contraseña"
6
+ "Enabled","Activada"
7
+ "URL in Your mobile application should looks like:","URL en Su aplicación móvil debe ser:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Nombre de usuario para acceder a Mobile Assistant Сonector desde su aplicación móvil."
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Сontraseña para acceder a Mobile Assistant Сonector desde su aplicación móvil. La contraseña predeterminada es "1". Crea una nueva contraseña."
10
+ "Default password is '1'. Please change it becouse of security reasons","La contraseña predeterminada es "1". Por razones de seguridad, se aconseja cambiar la contraseña."
11
+ "Login field cannot be empty. Please specify Login.","El campo nombre de usuario no puede estar vacío. Por favor, teclee el nombre de usuario."
12
+ "Password field cannot be empty. Please specify password.","El campo contraseña no puede estar vacío. Por favor, teclee la contraseña."
13
+ "Cannot get configuration value","No se puede obtener el valor de configuración"
14
+ "Registration ID cannot be empty","ID de registro no puede estar vacío"
15
+ "An error occurred!","Ha ocurrido un error!"
16
+ "Cannot create an invoice without products!","No puede crear una factura sin productos!"
17
+ "Cannot create an invoice!","No puede crear una factura!"
18
+ "Empty tracking number!","El número de seguimiento está vacío!"
19
+ "Current order cannot be shipped!","El pedido actual no puede ser enviado"
20
+ "Current order cannot be canceled!","El pedido actual no puede ser cancelado!"
21
+ "Current order cannot be holded!","El pedido actual no puede ser en suspenso!"
22
+ "Current order cannot be unholded!","El pedido actual no puede ser reasumido!"
23
+ "Current tracking number was not found","Número de seguimiento no puede ser encontrado"
24
+ "Current order does not have shipments!","Este pedido no tiene ningún envío"
25
+ "No order was found!","No se ha encontrado ningún pedido"
26
+ "Action is not set!","La accion no está definida"
27
+ "Order id cannot be empty!","ID de pedido no puede estar vacío"
app/locale/fr_FR/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Configuration Générale"
3
+ "Access Settings","Réglages d'Accès"
4
+ "Login","Identifiant"
5
+ "Password","Mot de passe"
6
+ "Enabled","Activé"
7
+ "URL in Your mobile application should looks like:","Dans Votre application mobile l'URL devrait être:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Identifiant pour accéder à Mobile Assistant Connecteur depuis Votre application mobile"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Mot de passe pour accéder à Mobile Assistant Connecteur depuis Votre application mobile. Le mot de passe par défaut est "1". Créez un nouveau mot de passe."
10
+ "Le mot de passe par défaut est "1". Pour des raisons de sécurité, veuillez changer le mot de passe."
11
+ "Login field cannot be empty. Please specify Login.","Le champ Identifiant ne peut pas être vide. Veuillez indiquer votre Identifiant."
12
+ "Password field cannot be empty. Please specify password.","Le champ mot de passe ne peut pas être vide. Veuillez indiquer votre mot de passe."
13
+ "Can\'t get configuration value","Impossible d'obtenir le valeur de configuration"
14
+ "Registration ID cannot be empty","ID d'enregistrement ne peut pas être vide"
15
+ "An error occurred!","Une erreur est survenue!"
16
+ "Cannot create an invoice without products!","Impossible de créer une facture sans les produits"
17
+ "Cannot create an invoice!","Impossible de créer une facture!"
18
+ "Empty tracking number!","Numéro de repérage vide!"
19
+ "Current order cannot be shipped!","Cette commande ne peut pas être expédiée"
20
+ "Current order cannot be canceled!","Cette commande ne peut pas être annulée!"
21
+ "Current order cannot be holded!","Cette commande ne peut pas être en attente!"
22
+ "Current order cannot be unholded!","Cette commande ne peut pas être reprise"
23
+ "Current tracking number wasn\'t found","Numéro de repérage ne peut pas être retrouvée"
24
+ "Current order doesn\'t have shipments!","Cette commande n'a pas d'expéditions!"
25
+ "No order was found!","Aucune commande n'a été trouvée!"
26
+ "Action is not set!","L'action n'est pas paramétrée"
27
+ "Order id cannot be empty!","ID de la commande ne peut pas être vide"
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
app/locale/fr_FR/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Configuration Générale"
3
+ "Access Settings","Réglages d'Accès"
4
+ "Login","Identifiant"
5
+ "Password","Mot de passe"
6
+ "Enabled","Activé"
7
+ "URL in Your mobile application should looks like:","Dans Votre application mobile l'URL devrait être:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Identifiant pour accéder à Mobile Assistant Connecteur depuis Votre application mobile"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Mot de passe pour accéder à Mobile Assistant Connecteur depuis Votre application mobile. Le mot de passe par défaut est "1". Créez un nouveau mot de passe."
10
+ "Le mot de passe par défaut est "1". Pour des raisons de sécurité, veuillez changer le mot de passe."
11
+ "Login field cannot be empty. Please specify Login.","Le champ Identifiant ne peut pas être vide. Veuillez indiquer votre Identifiant."
12
+ "Password field cannot be empty. Please specify password.","Le champ mot de passe ne peut pas être vide. Veuillez indiquer votre mot de passe."
13
+ "Can\'t get configuration value","Impossible d'obtenir le valeur de configuration"
14
+ "Registration ID cannot be empty","ID d'enregistrement ne peut pas être vide"
15
+ "An error occurred!","Une erreur est survenue!"
16
+ "Cannot create an invoice without products!","Impossible de créer une facture sans les produits"
17
+ "Cannot create an invoice!","Impossible de créer une facture!"
18
+ "Empty tracking number!","Numéro de repérage vide!"
19
+ "Current order cannot be shipped!","Cette commande ne peut pas être expédiée"
20
+ "Current order cannot be canceled!","Cette commande ne peut pas être annulée!"
21
+ "Current order cannot be holded!","Cette commande ne peut pas être en attente!"
22
+ "Current order cannot be unholded!","Cette commande ne peut pas être reprise"
23
+ "Current tracking number wasn\'t found","Numéro de repérage ne peut pas être retrouvée"
24
+ "Current order doesn\'t have shipments!","Cette commande n'a pas d'expéditions!"
25
+ "No order was found!","Aucune commande n'a été trouvée!"
26
+ "Action is not set!","L'action n'est pas paramétrée"
27
+ "Order id cannot be empty!","ID de la commande ne peut pas être vide"
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
app/locale/ru_RU/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Общие Настройки"
3
+ "Access Settings","Настройки доступа"
4
+ "Login","Логин"
5
+ "Password","Пароль"
6
+ "Enabled","Активное"
7
+ "URL in Your mobile application should looks like:","URL в мобильном додатке должно иметь следующий вид:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Логин для доступа к Mobile Assistant Connector с Вашего мобильного приложения:"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Пароль для доступа к Mobile Assistant Connector с Вашего мобильного приложения. По-умолчанию установлен '1 '. Пожалуйста, измените его по своему."
10
+ "Default password is '1'. Please change it becouse of security reasons","По-умолчанию установлен '1 '. Пожалуйста, измените его по соображениям безопасности."
11
+ "Login field cannot be empty. Please specify Login.","Логин не может быть пустым. Пожалуйста, укажите логин."
12
+ "Password field cannot be empty. Please specify password.","Пароль не может быть пустым. Пожалуйста, укажите пароль."
13
+ "Can not get configuration value","Невозможно считать конфигурации значение"
14
+ "Registration ID cannot be empty","Registration ID не может быть пустым!"
15
+ "An error occurred!","Произошла ошибка!"
16
+ "Cannot create an invoice without products!","Невозможно создать инвойс без продуктов!"
17
+ "Cannot create an invoice!","Невозможно создать инвойс!"
18
+ "Empty tracking number!","Пустой tracking number!"
19
+ "Current order cannot be shipped!","Текущий заказ не может быть отправлено!"
20
+ "Current order cannot be canceled!","Неможлиово отменить текущий заказ!"
21
+ "Current order cannot be holded!","Невозможно задержать текущий заказ!"
22
+ "Current order cannot be unholded!","Невозможно восстановить текущий заказ!"
23
+ "Current tracking number was not found","Текущий tracking number не найдено!"
24
+ "Current order does not have shipments!","Текущий заказ не имеет отправлений!"
25
+ "No order was found!","Заказ не найдено!"
26
+ "Action is not set!","Действие не указано!"
27
+ "Order id cannot be empty!","Order id не может быть пустым!"
app/locale/ru_RU/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Общие Настройки"
3
+ "Access Settings","Настройки доступа"
4
+ "Login","Логин"
5
+ "Password","Пароль"
6
+ "Enabled","Активное"
7
+ "URL in Your mobile application should looks like:","URL в мобильном додатке должно иметь следующий вид:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Логин для доступа к Mobile Assistant Connector с Вашего мобильного приложения:"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Пароль для доступа к Mobile Assistant Connector с Вашего мобильного приложения. По-умолчанию установлен '1 '. Пожалуйста, измените его по своему."
10
+ "Default password is '1'. Please change it becouse of security reasons","По-умолчанию установлен '1 '. Пожалуйста, измените его по соображениям безопасности."
11
+ "Login field cannot be empty. Please specify Login.","Логин не может быть пустым. Пожалуйста, укажите логин."
12
+ "Password field cannot be empty. Please specify password.","Пароль не может быть пустым. Пожалуйста, укажите пароль."
13
+ "Can not get configuration value","Невозможно считать конфигурации значение"
14
+ "Registration ID cannot be empty","Registration ID не может быть пустым!"
15
+ "An error occurred!","Произошла ошибка!"
16
+ "Cannot create an invoice without products!","Невозможно создать инвойс без продуктов!"
17
+ "Cannot create an invoice!","Невозможно создать инвойс!"
18
+ "Empty tracking number!","Пустой tracking number!"
19
+ "Current order cannot be shipped!","Текущий заказ не может быть отправлено!"
20
+ "Current order cannot be canceled!","Неможлиово отменить текущий заказ!"
21
+ "Current order cannot be holded!","Невозможно задержать текущий заказ!"
22
+ "Current order cannot be unholded!","Невозможно восстановить текущий заказ!"
23
+ "Current tracking number was not found","Текущий tracking number не найдено!"
24
+ "Current order does not have shipments!","Текущий заказ не имеет отправлений!"
25
+ "No order was found!","Заказ не найдено!"
26
+ "Action is not set!","Действие не указано!"
27
+ "Order id cannot be empty!","Order id не может быть пустым!"
app/locale/uk_UA/Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Загальні налаштування"
3
+ "Access Settings","Налаштування доступу"
4
+ "Login","Логін"
5
+ "Password","Пароль"
6
+ "Enabled","Активне"
7
+ "URL in Your mobile application should looks like:","URL у Вашій мобільній аплікації повинне мати наступний вигляд:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Логін для доступу до Mobile Assistant Connector з Вашої мобільної аплікації:"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Пароль для доступу до Mobile Assistant Connector з Вашої мобільної аплікації. По-замовчуванню встановлений '1'. Будь ласка, змініть його на власний."
10
+ "Default password is '1'. Please change it becouse of security reasons","По-замовчуванню встановлений '1'. Будь ласка, змініть його з міркувань безпеки."
11
+ "Login field cannot be empty. Please specify Login.","Логін не може бути порожнім. Будь ласка, вкажіть логін."
12
+ "Password field cannot be empty. Please specify password.","Пароль не може бути порожнім. Будь ласка, вкажіть пароль."
13
+ "Cannot get configuration value","Не вдається зчитати конфігураційне значення!"
14
+ "Registration ID cannot be empty","Registration ID не може бути порожнім!"
15
+ "An error occurred!","Сталась помилка!"
16
+ "Cannot create an invoice without products!","Неможливо створити інвойс без продуктів!"
17
+ "Cannot create an invoice!","Неможливо створити інвойс!"
18
+ "Empty tracking number!","Порожній tracking number!"
19
+ "Current order cannot be shipped!","Поточне замовлення не може бути відправлено!"
20
+ "Current order cannot be canceled!","Неможливо відміниити поточне замовлення!"
21
+ "Current order cannot be holded!","Неможливо затримати поточне замовлення!"
22
+ "Current order cannot be unholded!","Неможливо відновити поточне замовлення!"
23
+ "Current tracking number was not found","Поточний tracking number не знайдений!"
24
+ "Current order does not have shipments!","Поточне замовлення не має відправлень!"
25
+ "No order was found!","Замовлення не знайдено!"
26
+ "Action is not set!","Дія не передана!"
27
+ "Order id cannot be empty!","Order id не може бути порожнім!"
app/locale/uk_UA/__Emagicone_Mobassistantconnector.csv ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Mobile Bridge","Mobile Bridge"
2
+ "General Settings","Загальні налаштування"
3
+ "Access Settings","Налаштування доступу"
4
+ "Login","Логін"
5
+ "Password","Пароль"
6
+ "Enabled","Активне"
7
+ "URL in Your mobile application should looks like:","URL у Вашій мобільній аплікації повинне мати наступний вигляд:"
8
+ "Login for accessing Mobile Assistant Connector from Your mobile application.","Логін для доступу до Mobile Assistant Connector з Вашої мобільної аплікації:"
9
+ "Password for accessing Mobile Assistant Connector from Your mobile application. Default password is '1'. Please change it to your own one.","Пароль для доступу до Mobile Assistant Connector з Вашої мобільної аплікації. По-замовчуванню встановлений '1'. Будь ласка, змініть його на власний."
10
+ "Default password is '1'. Please change it becouse of security reasons","По-замовчуванню встановлений '1'. Будь ласка, змініть його з міркувань безпеки."
11
+ "Login field cannot be empty. Please specify Login.","Логін не може бути порожнім. Будь ласка, вкажіть логін."
12
+ "Password field cannot be empty. Please specify password.","Пароль не може бути порожнім. Будь ласка, вкажіть пароль."
13
+ "Cannot get configuration value","Не вдається зчитати конфігураційне значення!"
14
+ "Registration ID cannot be empty","Registration ID не може бути порожнім!"
15
+ "An error occurred!","Сталась помилка!"
16
+ "Cannot create an invoice without products!","Неможливо створити інвойс без продуктів!"
17
+ "Cannot create an invoice!","Неможливо створити інвойс!"
18
+ "Empty tracking number!","Порожній tracking number!"
19
+ "Current order cannot be shipped!","Поточне замовлення не може бути відправлено!"
20
+ "Current order cannot be canceled!","Неможливо відміниити поточне замовлення!"
21
+ "Current order cannot be holded!","Неможливо затримати поточне замовлення!"
22
+ "Current order cannot be unholded!","Неможливо відновити поточне замовлення!"
23
+ "Current tracking number was not found","Поточний tracking number не знайдений!"
24
+ "Current order does not have shipments!","Поточне замовлення не має відправлень!"
25
+ "No order was found!","Замовлення не знайдено!"
26
+ "Action is not set!","Дія не передана!"
27
+ "Order id cannot be empty!","Order id не може бути порожнім!"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>mobile_assistant_connector</name>
4
+ <version>1.0.12</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl.html">GNU</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Mobile Assistant Connector</summary>
10
+ <description>Mobile Assistant Connector</description>
11
+ <notes>Fixed: support of Xtento_CustomTrackers extention</notes>
12
+ <authors><author><name>eMagicOne</name><user>mobile</user><email>mobile@emagicone.com</email></author></authors>
13
+ <date>2015-02-19</date>
14
+ <time>16:52:01</time>
15
+ <contents><target name="magecommunity"><dir name="Emagicone"><dir name="Affiliate"><dir name="Model"><file name="Observer.php" hash="34f47695ff6a590f554331fd5ff38ce5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="76cc4c681e62263421f09fdbd94e9b91"/><file name="config.xml" hash="9d4d74e1322ab291275f92ef634ff6fd"/><file name="system.xml" hash="b2baadb73f35fe5a06548e312dcf0b52"/></dir></dir><dir name="Mobassistantconnector"><dir name="Helper"><file name="Data.php" hash="37602f03d9864833f0d306344ddff60f"/></dir><dir name="Model"><file name="Defpassword.php" hash="ab8f696fce0029f113986b83ddeb8232"/><file name="Login.php" hash="6c82713acedcf883203c6bf964a61016"/><file name="Observer.php" hash="bb18972490df3223aeb473d917a2acf4"/><file name="Order.php" hash="f3d5529e0504ea0265cb661e03f41109"/><file name="Password.php" hash="c8fe770cb05b7e45050c6549cb9d39a3"/></dir><dir name="controllers"><file name="IndexController.php" hash="0b7754e77e3823df79d646eda0c8486a"/><dir name="adminhtml"><file name="IndexController.php" hash="ef5ca028e534cbf81b39a643885c9511"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="bd21488195715421d3beb6a512acd5b5"/><file name="config.xml" hash="a3369251198939eba20d2b0fc020b5c2"/><file name="system.xml" hash="916fe7ee643e4dcb15a5498219605896"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Emagicone_Mobassistantconnector.xml" hash="7bb654478173d96ad294000fc9625820"/></dir></target><target name="magelocale"><dir><dir name="en_GB"><file name="Emagicone_Mobassistantconnector.csv" hash="eaf733f81ff47627c4389d487c93709f"/><file name="__Emagicone_Mobassistantconnector.csv" hash="eaf733f81ff47627c4389d487c93709f"/></dir><dir name="en_US"><file name="Emagicone_Mobassistantconnector.csv" hash="510d79a25c0bfb7a096aab57d8c5b458"/><file name="__Emagicone_Mobassistantconnector.csv" hash="510d79a25c0bfb7a096aab57d8c5b458"/></dir><dir name="es_ES"><file name="Emagicone_Mobassistantconnector.csv" hash="acc37c432dd8b4134844291931b70fbf"/><file name="__Emagicone_Mobassistantconnector.csv" hash="acc37c432dd8b4134844291931b70fbf"/></dir><dir name="fr_FR"><file name="Emagicone_Mobassistantconnector.csv" hash="76c48723a6bbd59534781fd3c7f6d86e"/><file name="__Emagicone_Mobassistantconnector.csv" hash="76c48723a6bbd59534781fd3c7f6d86e"/></dir><dir name="ru_RU"><file name="Emagicone_Mobassistantconnector.csv" hash="2346397cbe029dcc724717b953a3f38c"/><file name="__Emagicone_Mobassistantconnector.csv" hash="2346397cbe029dcc724717b953a3f38c"/></dir><dir name="uk_UA"><file name="Emagicone_Mobassistantconnector.csv" hash="cad0e0c3ec7603e6b886d815357d1766"/><file name="__Emagicone_Mobassistantconnector.csv" hash="cad0e0c3ec7603e6b886d815357d1766"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mobassistantconnector.xml" hash="b5c4d423be8de0c5d73d64783dcb9a3c"/></dir><dir name="template"><dir name="mobassistantconnector"><file name="jsinit.phtml" hash="785c82b5cf6b2a7dc94a1436d1c9115f"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min>1.0</min><max>3.0</max></extension><extension><name>json</name><min>1.0</min><max>3.0</max></extension><extension><name>date</name><min>1.0</min><max>3.0</max></extension></required></dependencies>
18
+ </package>